fix: indent cursor position

This commit is contained in:
Tienson Qin
2022-04-22 00:28:56 +08:00
parent 33e0fb4fe9
commit ec29848427
2 changed files with 9 additions and 12 deletions

View File

@@ -175,15 +175,12 @@
(defn restore-cursor-pos!
[id markup]
(when-let [node (gdom/getElement (str id))]
(let [last-edit-block (state/get-last-edit-block)
current-edit-block (state/get-edit-block)]
(when-let [cursor-range (state/get-cursor-range)]
(when-let [range cursor-range]
(let [pos (when (= (:db/id last-edit-block) (:db/id current-edit-block))
(state/get-editor-last-pos))
pos (or pos (diff/find-position markup range))]
(cursor/move-cursor-to node pos)
(state/clear-editor-last-pos!)))))))
(let [cursor-range (state/get-cursor-range)
pos (or (state/get-editor-last-pos)
(and cursor-range
(diff/find-position markup cursor-range)))]
(cursor/move-cursor-to node pos)
(state/clear-editor-last-pos!))))
(defn highlight-block!
[block-uuid]