Browse Source

fix: tab to collapse not working

Tienson Qin 4 years ago
parent
commit
102e68a07a

+ 2 - 1
src/main/frontend/components/block.cljs

@@ -1498,7 +1498,8 @@
      (cond->
       {:id block-id
        :data-refs (let [refs (model/get-page-names-by-ids
-                              (map :db/id refs-with-children))]
+                              (->> (map :db/id refs-with-children)
+                                   (remove nil?)))]
                     (text/build-data-value refs))
        :style {:position "relative"}
        :class (str uuid

+ 5 - 3
src/main/frontend/handler/block.cljs

@@ -31,7 +31,8 @@
               cur-level (:block/level item)
               bottom-level (:block/level (first children))
               pre-block? (:block/pre-block? item)
-              item (assoc item :block/refs-with-children (get-all-refs item))]
+              item (assoc item :block/refs-with-children (->> (get-all-refs item)
+                                                              (remove nil?)))]
           (cond
             (empty? children)
             (recur others (list item))
@@ -46,8 +47,9 @@
             (let [[children other-children] (split-with (fn [h]
                                                           (> (:block/level h) cur-level))
                                                         children)
-                  refs-with-children (-> (mapcat get-all-refs (cons item children))
-                                         distinct)
+                  refs-with-children (->> (mapcat get-all-refs (cons item children))
+                                          (remove nil?)
+                                          distinct)
                   children (cons
                             (assoc item
                                    :block/children children

+ 4 - 4
src/main/frontend/handler/editor.cljs

@@ -1983,7 +1983,7 @@
                                 true)))
 
 (defn cycle-collapse!
-  [_state e]
+  [e]
   (when (and
          ;; not input, t
          (nil? (state/get-edit-input-id))
@@ -1994,7 +1994,7 @@
 
 (defn on-tab
   [direction]
-  (fn [state e]
+  (fn [e]
     (when-let [repo (state/get-current-repo)]
       (let [blocks (seq (state/get-selection-blocks))]
         (cond
@@ -2056,7 +2056,7 @@
           nil
 
           :else
-          (cycle-collapse! state e))))))
+          (cycle-collapse! e))))))
 
 (defn bulk-make-todos
   [state e]
@@ -2115,7 +2115,7 @@
             {:key :block/change
              :data (map (fn [block] (assoc block :block/page page)) blocks)}
             [[file-path new-content]])))
-        (cycle-collapse! state e)))))
+        (cycle-collapse! e)))))
 
 (defn- get-link
   [format link label]

+ 4 - 2
src/main/frontend/keyboards.cljs

@@ -43,9 +43,11 @@
    (enable-when-not-editing-mode! state/toggle-new-block-shortcut!)
    (or (shortcut :ui/toggle-between-page-and-file) "s")
    (enable-when-not-editing-mode! route-handler/toggle-between-page-and-file!)
+   "tab" (-> (editor-handler/on-tab :right)
+             enable-when-not-editing-mode!)
+   "shift+tab" (-> (editor-handler/on-tab :left)
+                   enable-when-not-editing-mode!)
 
-   "tab" (editor-handler/on-tab :right)
-   "shift+tab" (editor-handler/on-tab :left)
    (or (shortcut :editor/undo) "mod+z") [history-handler/undo! true]
    (or (shortcut :editor/redo) "mod+y") [history-handler/redo! true]
    (or (shortcut :go/search) "mod+u") [route-handler/go-to-search! true]