mirror of
https://github.com/logseq/logseq.git
synced 2026-05-02 18:06:32 +00:00
enhance: convert highlighted word to a link when pasting a url
This commit is contained in:
@@ -123,8 +123,11 @@
|
||||
(defn strike-through-format! []
|
||||
(format-text! config/get-strike-through))
|
||||
|
||||
(defn html-link-format! []
|
||||
(when-let [m (get-selection-and-format)]
|
||||
(defn html-link-format!
|
||||
([]
|
||||
(html-link-format! nil))
|
||||
([link]
|
||||
(when-let [m (get-selection-and-format)]
|
||||
(let [{:keys [selection-start selection-end format value edit-id input]} m
|
||||
cur-pos (cursor/pos input)
|
||||
empty-selection? (= selection-start selection-end)
|
||||
@@ -135,6 +138,9 @@
|
||||
empty-selection?
|
||||
(config/get-empty-link-and-forward-pos format)
|
||||
|
||||
link
|
||||
(config/with-label-link format selection link)
|
||||
|
||||
selection-link?
|
||||
(config/with-default-link format selection)
|
||||
|
||||
@@ -146,7 +152,7 @@
|
||||
(subs value selection-end))
|
||||
cur-pos (or selection-start cur-pos)]
|
||||
(state/set-edit-content! edit-id new-value)
|
||||
(cursor/move-cursor-to input (+ cur-pos forward-pos)))))
|
||||
(cursor/move-cursor-to input (+ cur-pos forward-pos))))))
|
||||
|
||||
(defn open-block-in-sidebar!
|
||||
[block-id]
|
||||
@@ -3010,6 +3016,12 @@
|
||||
(paste-block-vec-tree-at-target copied-block-tree [] nil)
|
||||
(util/stop e))
|
||||
|
||||
(and (util/url? text)
|
||||
(not (string/blank? (util/get-selected-text))))
|
||||
(do
|
||||
(util/stop e)
|
||||
(html-link-format! text))
|
||||
|
||||
(and (text/block-ref? text)
|
||||
(wrapped-by? input "((" "))"))
|
||||
(do
|
||||
|
||||
Reference in New Issue
Block a user