mirror of https://github.com/logseq/logseq
perf: faster rendering editor for the new created block
parent
7b6698fc73
commit
ddd9a8246b
|
@ -2969,7 +2969,7 @@
|
|||
selected? (when-not (:slide? config)
|
||||
(state/sub-block-selected? uuid))
|
||||
children (:block/_parent block)]
|
||||
(when-not (= (:ui/deleting-block @state/state) (:block/uuid block))
|
||||
(when-not (= (:editor/deleting-block @state/state) (:block/uuid block))
|
||||
[:div.ls-block
|
||||
(cond->
|
||||
{:id (str "ls-block-" uuid)
|
||||
|
|
|
@ -382,8 +382,8 @@
|
|||
(state/set-edit-content! edit-input-id new-content)))
|
||||
(p/let [_ (let [sibling? (not= (:db/id left-block) (:db/id (:block/parent block)))]
|
||||
(outliner-insert-block! config left-block prev-block {:sibling? sibling?
|
||||
:keep-uuid? true})
|
||||
prev-block)])))
|
||||
:keep-uuid? true}))])
|
||||
prev-block))
|
||||
|
||||
(defn insert-new-block-aux!
|
||||
[config
|
||||
|
@ -406,10 +406,10 @@
|
|||
new-m)
|
||||
(wrap-parse-block))
|
||||
sibling? (when block-self? false)]
|
||||
(p/let [_ (outliner-insert-block! config current-block next-block {:sibling? sibling?
|
||||
:keep-uuid? true})]
|
||||
(util/set-change-value input fst-block-text)
|
||||
(assoc next-block :block/content snd-block-text))))
|
||||
(outliner-insert-block! config current-block next-block {:sibling? sibling?
|
||||
:keep-uuid? true})
|
||||
(assoc next-block :block/content snd-block-text)))
|
||||
|
||||
(defn clear-when-saved!
|
||||
[]
|
||||
|
@ -471,10 +471,11 @@
|
|||
insert-new-block-before-block-aux!
|
||||
|
||||
:else
|
||||
insert-new-block-aux!)]
|
||||
(p/let [last-block (insert-fn config block'' value)]
|
||||
insert-new-block-aux!)
|
||||
next-block (insert-fn config block'' value)]
|
||||
(clear-when-saved!)
|
||||
(edit-block! last-block 0)))))))
|
||||
(state/set-state! :editor/next-edit-block {:block next-block
|
||||
:pos 0}))))))
|
||||
|
||||
(defn api-insert-new-block!
|
||||
[content {:keys [page block-uuid sibling? before? properties
|
||||
|
@ -716,7 +717,7 @@
|
|||
(let [repo (or repo (state/get-current-repo))
|
||||
block (db/pull repo '[*] [:block/uuid uuid])]
|
||||
(when block
|
||||
(state/set-state! :ui/deleting-block uuid)
|
||||
(state/set-state! :editor/deleting-block uuid)
|
||||
(let [blocks (block-handler/get-top-level-blocks [block])]
|
||||
(ui-outliner-tx/transact!
|
||||
{:outliner-op :delete-blocks}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
[datascript.core :as d]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.history :as history]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.util :as util]))
|
||||
|
||||
(defn- get-tx-id
|
||||
|
@ -63,8 +64,14 @@
|
|||
(update-current-tx-editor-cursor! tx-report)))
|
||||
|
||||
(when-not (:graph/importing @state/state)
|
||||
(react/refresh! repo affected-keys)
|
||||
;; safe to edit the next block now since other blocks (e.g. prev editing block)
|
||||
;; has been saved to the db now
|
||||
(when-let [next-edit-block @(:editor/next-edit-block @state/state)]
|
||||
(let [{:keys [block pos]} next-edit-block]
|
||||
(editor-handler/edit-block! block pos)
|
||||
(state/set-state! :editor/next-edit-block nil)))
|
||||
|
||||
(react/refresh! repo affected-keys)
|
||||
(when-let [state (:ui/restore-cursor-state @state/state)]
|
||||
(when (or undo? redo?)
|
||||
(restore-cursor-and-app-state! state undo?)
|
||||
|
@ -87,9 +94,9 @@
|
|||
(when (= (:outliner-op tx-meta) :rename-page)
|
||||
(state/pub-event! [:page/renamed repo (:data tx-meta)]))
|
||||
|
||||
(when-let [deleting-block-id (:ui/deleting-block @state/state)]
|
||||
(when-let [deleting-block-id (:editor/deleting-block @state/state)]
|
||||
(when (some (fn [datom] (and
|
||||
(= :block/uuid (:a datom))
|
||||
(= (:v datom) deleting-block-id)
|
||||
(true? (:added datom)))) tx-data) ; editing-block was added back (could be undo or from remote sync)
|
||||
(state/set-state! :ui/deleting-block nil)))))
|
||||
(state/set-state! :editor/deleting-block nil)))))
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
:db/properties-changed-pages {}
|
||||
:editor/cursor-range (atom nil)
|
||||
:editor/container-id (atom nil)
|
||||
:editor/next-edit-block (atom nil)
|
||||
|
||||
:selection/mode (atom false)
|
||||
;; Warning: blocks order is determined when setting this attribute
|
||||
|
|
Loading…
Reference in New Issue