瀏覽代碼

fix: new class should always set :block/type to "class"

New change with :block/type "page" was causing :tag-classes option to
fail. Part of LOG-3176
Gabriel Horner 1 年之前
父節點
當前提交
3d732cb018

+ 5 - 6
deps/db/src/logseq/db/sqlite/util.cljs

@@ -110,12 +110,11 @@
   [block]
   {:pre [(qualified-keyword? (:db/ident block))]}
   (block-with-timestamps
-   (merge (cond->
-           {:block/type (set (concat (:block/type block) ["class" "page"]))
-            :block/format :markdown}
-            (not= (:db/ident block) :logseq.class/Root)
-            (assoc :class/parent :logseq.class/Root))
-          block)))
+   (cond-> (merge block
+                  {:block/type (set (concat (:block/type block) ["class" "page"]))
+                   :block/format :markdown})
+     (not= (:db/ident block) :logseq.class/Root)
+     (assoc :class/parent :logseq.class/Root))))
 
 (defn build-new-page
   "Builds a basic page to be transacted. A minimal version of gp-block/page-name->map"

+ 1 - 1
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -262,7 +262,7 @@
       (is (= (:block/content block) "Inception")
           "tagged block with configured tag strips tag from content")
 
-      (is (= ["class"] (:block/type tag-page))
+      (is (= ["class" "page"] (:block/type tag-page))
           "configured tag page in :tag-classes is a class")
       (is (and another-tag-page (not (contains? (set (:block/type another-tag-page)) "class")))
           "unconfigured tag page is not a class")