mirror of https://github.com/logseq/logseq
fix: add block check
parent
efcc3be8c1
commit
11d1de6aa3
|
@ -247,7 +247,7 @@
|
||||||
edit-content (gobj/get input "value")
|
edit-content (gobj/get input "value")
|
||||||
current-pos (:pos (util/get-caret-pos input))
|
current-pos (:pos (util/get-caret-pos input))
|
||||||
prefix (subs edit-content 0 current-pos)
|
prefix (subs edit-content 0 current-pos)
|
||||||
space? (when last-pattern
|
space? (when (and last-pattern prefix)
|
||||||
(let [s (when-let [last-index (string/last-index-of prefix last-pattern)]
|
(let [s (when-let [last-index (string/last-index-of prefix last-pattern)]
|
||||||
(util/safe-subs prefix 0 last-index))]
|
(util/safe-subs prefix 0 last-index))]
|
||||||
(not (and (string/ends-with? s "(")
|
(not (and (string/ends-with? s "(")
|
||||||
|
|
|
@ -779,7 +779,7 @@
|
||||||
(defn- block-property-aux!
|
(defn- block-property-aux!
|
||||||
[block-id key value]
|
[block-id key value]
|
||||||
(let [block-id (if (string? block-id) (uuid block-id) block-id)
|
(let [block-id (if (string? block-id) (uuid block-id) block-id)
|
||||||
key (keyword (string/lower-case (name key)))
|
key (string/lower-case (name key))
|
||||||
repo (state/get-current-repo)]
|
repo (state/get-current-repo)]
|
||||||
(when repo
|
(when repo
|
||||||
(when-let [block (db/entity [:block/uuid block-id])]
|
(when-let [block (db/entity [:block/uuid block-id])]
|
||||||
|
@ -2056,26 +2056,26 @@
|
||||||
(defn indent-on-tab
|
(defn indent-on-tab
|
||||||
([state]
|
([state]
|
||||||
(indent-on-tab state 100))
|
(indent-on-tab state 100))
|
||||||
([state retry-limit]
|
([state]
|
||||||
(if (= :insert (state/get-editor-op))
|
(if (= :insert (state/get-editor-op))
|
||||||
(if (> retry-limit 0)
|
(if (> retry-limit 0)
|
||||||
(js/setTimeout #(indent-on-tab state (dec retry-limit)) 20)
|
(js/setTimeout #(indent-on-tab state (dec retry-limit)) 20)
|
||||||
(log/error :editor/indent-outdent-retry-max-limit "indent on hit tab."))
|
(log/error :editor/indent-outdent-retry-max-limit "indent on hit tab."))
|
||||||
(do
|
(let [{:keys [block block-parent-id value config]} (get-state state)]
|
||||||
(state/set-editor-op! :indent-outdent)
|
(when block
|
||||||
(let [{:keys [block block-parent-id value config]} (get-state state)
|
(state/set-editor-op! :indent-outdent)
|
||||||
current-node (outliner-core/block block)
|
(let [current-node (outliner-core/block block)
|
||||||
first-child? (outliner-core/first-child? current-node)]
|
first-child? (outliner-core/first-child? current-node)]
|
||||||
(when-not first-child?
|
(when-not first-child?
|
||||||
(let [left (tree/-get-left current-node)
|
(let [left (tree/-get-left current-node)
|
||||||
children-of-left (tree/-get-children left)]
|
children-of-left (tree/-get-children left)]
|
||||||
(if (seq children-of-left)
|
(if (seq children-of-left)
|
||||||
(let [target-node (last children-of-left)]
|
(let [target-node (last children-of-left)]
|
||||||
(outliner-core/move-subtree current-node target-node true))
|
(outliner-core/move-subtree current-node target-node true))
|
||||||
(outliner-core/move-subtree current-node left false))
|
(outliner-core/move-subtree current-node left false))
|
||||||
(let [repo (state/get-current-repo)]
|
(let [repo (state/get-current-repo)]
|
||||||
(db/refresh repo
|
(db/refresh repo
|
||||||
{:key :block/change :data [(:data current-node)]})))))
|
{:key :block/change :data [(:data current-node)]}))))))
|
||||||
(state/set-editor-op! nil)))))
|
(state/set-editor-op! nil)))))
|
||||||
|
|
||||||
(defn outdent-on-shift-tab
|
(defn outdent-on-shift-tab
|
||||||
|
|
Loading…
Reference in New Issue