mirror of
https://github.com/logseq/logseq.git
synced 2026-05-23 12:14:06 +00:00
enhance: delete selected text when pressing enter
This commit is contained in:
committed by
Tienson Qin
parent
e8ed9d025d
commit
be9654da94
@@ -407,10 +407,10 @@
|
||||
(save-block-inner! block value opts)))))))
|
||||
|
||||
(defn- compute-fst-snd-block-text
|
||||
[value pos]
|
||||
[value selection-start selection-end]
|
||||
(when (string? value)
|
||||
(let [fst-block-text (subs value 0 pos)
|
||||
snd-block-text (string/triml (subs value pos))]
|
||||
(let [fst-block-text (subs value 0 selection-start)
|
||||
snd-block-text (string/triml (subs value selection-end))]
|
||||
[fst-block-text snd-block-text])))
|
||||
|
||||
(declare save-current-block!)
|
||||
@@ -471,8 +471,9 @@
|
||||
:as _opts}]
|
||||
(let [block-self? (block-self-alone-when-insert? config uuid)
|
||||
input (gdom/getElement (state/get-edit-input-id))
|
||||
pos (cursor/pos input)
|
||||
[fst-block-text snd-block-text] (compute-fst-snd-block-text value pos)
|
||||
selection-start (util/get-selection-start input)
|
||||
selection-end (util/get-selection-end input)
|
||||
[fst-block-text snd-block-text] (compute-fst-snd-block-text value selection-start selection-end)
|
||||
current-block (assoc block :block/content fst-block-text)
|
||||
current-block (apply dissoc current-block db-schema/retract-attributes)
|
||||
current-block (wrap-parse-block current-block)
|
||||
@@ -526,8 +527,9 @@
|
||||
block)
|
||||
block-self? (block-self-alone-when-insert? config block-id)
|
||||
input (gdom/getElement (state/get-edit-input-id))
|
||||
pos (cursor/pos input)
|
||||
[fst-block-text snd-block-text] (compute-fst-snd-block-text value pos)
|
||||
selection-start (util/get-selection-start input)
|
||||
selection-end (util/get-selection-end input)
|
||||
[fst-block-text snd-block-text] (compute-fst-snd-block-text value selection-start selection-end)
|
||||
insert-fn (cond
|
||||
block-self?
|
||||
insert-new-block-aux!
|
||||
|
||||
Reference in New Issue
Block a user