fix: block content not saved when exit code mode

This commit is contained in:
Tienson Qin
2024-10-03 18:30:40 +08:00
parent ccb6ee48e4
commit a53943e19e
6 changed files with 63 additions and 56 deletions

View File

@@ -2034,7 +2034,7 @@ Similar to re-frame subscriptions"
(set-selection-blocks! blocks direction)))
(defn set-editing!
[edit-input-id content block cursor-range & {:keys [move-cursor? container-id property-block direction event pos]
[edit-input-id content block cursor-range & {:keys [db move-cursor? container-id property-block direction event pos]
:or {move-cursor? true}}]
(when-not (exists? js/process)
(if (> (count content)
@@ -2069,9 +2069,8 @@ Similar to re-frame subscriptions"
(set-state! :editor/last-key-code nil)
(set-state! :editor/set-timestamp-block nil)
(set-state! :editor/cursor-range cursor-range)
(when (= :code (:logseq.property.node/display-type block))
(pub-event! [:editor/focus-code-editor block]))
(when (= :code (:logseq.property.node/display-type (d/entity db (:db/id block))))
(pub-event! [:editor/focus-code-editor block block-element]))
(when-let [input (gdom/getElement edit-input-id)]
(let [pos (count cursor-range)]
(when content