refactor indent-and-outdent

This commit is contained in:
Tienson Qin
2024-02-02 00:16:49 +08:00
parent 95cd7d51fc
commit 4b9b825101
6 changed files with 108 additions and 76 deletions

View File

@@ -326,17 +326,20 @@
last)]
(get-original-block-by-dom last-block-node)))))
(defn indent-outdent-block!
[block direction]
(ui-outliner-tx/transact!
{:outliner-op :move-blocks
:real-outliner-op :indent-outdent}
(outliner-core/indent-outdent-blocks! (state/get-current-repo)
(db/get-db false)
(get-top-level-blocks [block])
(= direction :right)
{:get-first-block-original get-first-block-original
:logical-outdenting? (state/logical-outdenting?)})))
(defn indent-outdent-blocks!
[blocks indent? save-current-block]
(when (seq blocks)
(let [blocks (get-top-level-blocks blocks)]
(ui-outliner-tx/transact!
{:outliner-op :move-blocks
:real-outliner-op :indent-outdent}
(when save-current-block (save-current-block))
(outliner-core/indent-outdent-blocks! (state/get-current-repo)
(db/get-db false)
(get-top-level-blocks blocks)
indent?
{:parent-original (get-first-block-original)
:logical-outdenting? (state/logical-outdenting?)})))))
(def *swipe (atom nil))
@@ -461,13 +464,13 @@
(and left-menu (>= (.-clientWidth left-menu) 40))
(when (indentable? block)
(haptics/with-haptics-impact
(indent-outdent-block! block :right)
(indent-outdent-blocks! [block] true nil)
:light))
(and right-menu (<= 40 (.-clientWidth right-menu) 79))
(when (outdentable? block)
(haptics/with-haptics-impact
(indent-outdent-block! block :left)
(indent-outdent-blocks! [block] false nil)
:light))
(and right-menu (>= (.-clientWidth right-menu) 80))