mirror of https://github.com/logseq/logseq
fix: save block when editor unmounts is dangerous
The block content will be overwritten in those cases: 1. deleting a block 2. paste blocks to an empty target block 3. undo/redoexperiment/tanstack-table
parent
71dc122a75
commit
b1d4fb3b81
|
@ -816,7 +816,9 @@
|
|||
(.click input-file)))
|
||||
|
||||
(defmethod handle-step :editor/exit [[_]]
|
||||
(state/clear-edit!))
|
||||
(p/do!
|
||||
(state/pub-event! [:editor/save-current-block])
|
||||
(state/clear-edit!)))
|
||||
|
||||
(defmethod handle-step :editor/new-property [[_]]
|
||||
(state/pub-event! [:editor/new-property]))
|
||||
|
|
|
@ -854,12 +854,7 @@
|
|||
::ref (atom nil)))
|
||||
:did-mount (fn [state]
|
||||
(state/set-editor-args! (:rum/args state))
|
||||
state)
|
||||
:will-unmount (fn [state]
|
||||
(let [{:keys [block value]} (editor-handler/get-state)]
|
||||
(when-not (= (:block/uuid block) (:editor/deleting-block @state/state)) ; don't save deleting block
|
||||
(editor-handler/save-block! (state/get-current-repo) (:block/uuid block) value)))
|
||||
state)}
|
||||
state)}
|
||||
(mixins/event-mixin
|
||||
(fn [state]
|
||||
(mixins/hide-when-esc-or-outside
|
||||
|
|
Loading…
Reference in New Issue