Browse Source

fix: a potential data loss issue for whiteboard blocks

Peng Xiao 3 years ago
parent
commit
f3418a6278

+ 2 - 3
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -668,9 +668,8 @@
   [page-id blocks]
   (let [[blocks other-blocks] (split-with
                                (fn [b]
-                                 (or (not= "macro" (:block/type b))
-                                     (whiteboard-properties? (:block/properties b))))
-                                blocks)
+                                 (not= "macro" (:block/type b)))
+                               blocks)
         result (loop [blocks (map (fn [block] (assoc block :block/level-spaces (:block/level block))) blocks)
                       parents [{:page/id page-id     ; db id or a map {:block/name "xxx"}
                                 :block/level 0

+ 5 - 6
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -216,11 +216,12 @@
   (let [shape (:block/properties block)
         shape? (gp-block/whiteboard-properties? shape)
         default-page-ref {:block/name (gp-util/page-name-sanity-lc page-name)}]
-    (merge (when shape?
+    (merge (if shape?
              (merge
               {:block/uuid (uuid (:id shape))}
               (with-whiteboard-block-refs shape)
-              (with-whiteboard-content shape)))
+              (with-whiteboard-content shape))
+             {:block/unordered true})
            (when (nil? (:block/parent block)) {:block/parent default-page-ref})
            (when (nil? (:block/format block)) {:block/format :markdown}) ;; TODO: read from config
            {:block/page default-page-ref})))
@@ -244,11 +245,9 @@
         page-entity (build-page-entity (:block/properties page-block) file page-name page-original-name nil options)
         page-block (merge page-block page-entity (when-not (:block/uuid page-block) {:block/uuid (d/squuid)}))
         blocks (->> blocks
-                    (map #(merge % {:block/level 1 ;; fixme
-                                    :block/uuid (or (:block/uuid %)
+                    (map #(merge % {:block/uuid (or (:block/uuid %)
                                                     (gp-block/get-custom-id-or-new-id (:block/properties %)))}
-                                 (with-whiteboard-block-props % page-name)))
-                    (gp-block/with-parent-and-left {:block/name page-name}))
+                                 (with-whiteboard-block-props % page-name))))
         _ (when verbose (println "Parsing finished: " file))]
     {:pages (list page-block)
      :blocks blocks}))