fix: add block check

pull/1672/head
Tienson Qin 2021-04-15 15:18:47 +08:00
parent efcc3be8c1
commit 11d1de6aa3
2 changed files with 18 additions and 18 deletions

View File

@ -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 "(")

View File

@ -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,15 +2056,15 @@
(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)]
(when block
(state/set-editor-op! :indent-outdent) (state/set-editor-op! :indent-outdent)
(let [{:keys [block block-parent-id value config]} (get-state state) (let [current-node (outliner-core/block block)
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)
@ -2075,7 +2075,7 @@
(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