fix: cursor moved to the beginning of the editing block when indent

Resolved #924
pull/927/head
Tienson Qin 2020-12-15 11:03:04 +08:00
parent 9de1f01db8
commit 97239cde65
2 changed files with 17 additions and 11 deletions

View File

@ -607,12 +607,17 @@
(editor-handler/close-autocomplete-if-outside input))))))))
{:did-mount (fn [state]
(let [[{:keys [dummy? format block-parent-id]} id] (:rum/args state)
content (get-in @state/state [:editor/content id])]
content (get-in @state/state [:editor/content id])
input (gdom/getElement id)]
(when block-parent-id
(state/set-editing-block-dom-id! block-parent-id))
(editor-handler/restore-cursor-pos! id content dummy?)
(if (= :indent-outdent (state/get-editor-op))
(when input
(when-let [pos (state/get-edit-pos)]
(util/set-caret-pos! input pos)))
(editor-handler/restore-cursor-pos! id content dummy?))
(when-let [input (gdom/getElement id)]
(when input
(dnd/subscribe!
input
:upload-images

View File

@ -2433,14 +2433,15 @@
;; block/uuid and block/content
(defn get-all-block-contents
[]
(->> (d/datoms (get-conn) :avet :block/uuid)
(map :v)
(map (fn [id]
(let [e (entity [:block/uuid id])]
{:db/id (:db/id e)
:block/uuid id
:block/content (:block/content e)
:block/format (:block/format e)})))))
(when-let [conn (get-conn)]
(->> (d/datoms conn :avet :block/uuid)
(map :v)
(map (fn [id]
(let [e (entity [:block/uuid id])]
{:db/id (:db/id e)
:block/uuid id
:block/content (:block/content e)
:block/format (:block/format e)}))))))
(defn get-all-templates
[]