Просмотр исходного кода

fix: at times can't indent and out-dent an existing bullet

Related to #1386
Tienson Qin 4 лет назад
Родитель
Сommit
8963aa5cb9
2 измененных файлов с 8 добавлено и 4 удалено
  1. 6 3
      src/main/frontend/db/model.cljs
  2. 2 1
      src/main/frontend/handler/editor.cljs

+ 6 - 3
src/main/frontend/db/model.cljs

@@ -604,9 +604,11 @@
   (when-let [conn (conn/get-conn repo)]
     (let [eid (:db/id (db-utils/entity repo [:block/uuid block-uuid]))]
       (->> (d/q
-            '[:find ?c
+            '[:find ?id
               :in $ ?p %
-              :where (parent ?p ?c)]
+              :where
+              (parent ?p ?c)
+              [?c :block/uuid ?id]]
             conn
             eid
             rules)
@@ -623,7 +625,8 @@
 (defn get-block-children
   [repo block-uuid]
   (when-let [conn (conn/get-conn repo)]
-    (let [ids (get-block-children-ids repo block-uuid)]
+    (let [ids (get-block-children-ids repo block-uuid)
+          ids (map (fn [id] [:block/uuid id]) ids)]
       (when (seq ids)
         (db-utils/pull-many repo '[*] ids)))))
 

+ 2 - 1
src/main/frontend/handler/editor.cljs

@@ -2015,7 +2015,8 @@
                 ;;         :last-start-pos @last-start-pos})
                 file-path (:file/path file)
                 file-content (db/get-file file-path)
-                new-content (utf8/insert! file-content start-pos old-end-pos (apply str (map :block/content blocks)))]
+                new-content (utf8/insert! file-content start-pos old-end-pos (apply str (map :block/content blocks)))
+                blocks (map (fn [b] (dissoc b :block/children)) blocks)]
             (profile
              "Indent/outdent: "
              (repo-handler/transact-react-and-alter-file!