Browse Source

fix: db import of whiteboards shouldn't fail

Can't visually confirm import yet b/c of whiteboard bug
but at least whiteboard import is valid. Part of LOG-3176
Gabriel Horner 1 year ago
parent
commit
7c19f9faad

+ 5 - 4
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -479,9 +479,9 @@
 
 (defn- handle-page-and-block-properties
   "Returns a map of :block with updated block and :properties-tx with any properties tx.
-   Handles modifying :block/properties, updating classes from property-classes
+   Handles modifying block properties, updating classes from property-classes
   and removing any deprecated property related attributes. Before updating most
-  :block/properties, their property schemas are inferred as that can affect how
+  block properties, their property schemas are inferred as that can affect how
   a property is updated. Only infers property schemas on user properties as
   built-in ones must not change"
   [{:block/keys [properties] :as block} db page-names-to-uuids refs
@@ -626,6 +626,8 @@
                    (update-block-marker options)
                    (update-block-priority options)
                    add-missing-timestamps
+                   ;; old whiteboards may have this
+                   (dissoc :block/left)
                    ;; ((fn [x] (prn :block-out x) x))
                    ;; TODO: org-mode content needs to be handled
                    (assoc :block/format :markdown))]
@@ -865,8 +867,7 @@
                               (map (fn [page-block]
                                      (-> page-block
                                          (assoc :block/format :markdown
-                                                 ;; fixme: missing properties
-                                                :block/properties {(get-pid @conn :ls-type) :whiteboard-page})))))
+                                                :logseq.property/ls-type :whiteboard-page)))))
         pre-blocks (->> blocks (keep #(when (:block/pre-block? %) (:block/uuid %))) set)
         blocks-tx (->> blocks
                        (remove :block/pre-block?)

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

@@ -153,6 +153,7 @@
                                 :where [?b :block/original-name] [_ :block/page ?b]] @conn)
                          (filter #(= ["page"] (:block/type %))))))
           "Correct number of pages with block content")
+      (is (= 3 (count (d/datoms @conn :avet :block/type "whiteboard"))))
       (is (= 1 (count @(:ignored-properties import-state))) ":filters should be the only ignored property")
       (is (= 1 (count @assets))))
 

File diff suppressed because it is too large
+ 2347 - 0
deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn


+ 69 - 0
deps/graph-parser/test/resources/exporter-test-graph/whiteboards/page 9322.edn

@@ -0,0 +1,69 @@
+{:blocks (
+{:block/content "fix/published-embeds"
+:block/format :markdown
+:block/left 
+{:block/uuid #uuid "64551487-ffab-406c-adcf-a4e8f00db19c"}
+:block/parent 
+{:block/uuid #uuid "64551487-ffab-406c-adcf-a4e8f00db19c"}
+:block/uuid #uuid "645514a0-85c2-43db-ac08-12836ae3d147"} 
+{:block/created-at 1683639741650
+:block/properties 
+{:ls-type :whiteboard-shape
+:logseq.tldraw.shape 
+{:index 0
+:scale [1 1]
+:type "youtube"
+:size [853 480]
+:id "e694caf0-eb52-11ed-a877-89e9886a62fe"
+:url "https://www.youtube.com/watch?v=C5m5dIiJMD0"
+:isLocked false
+:point [475.04503224455124 300.94676141866057]
+:parentId "64551487-ffab-406c-adcf-a4e8f00db19c"
+:nonce 1683297680671}}
+:block/updated-at 1683639741650} 
+{:block/created-at 1683639741650
+:block/properties 
+{:ls-type :whiteboard-shape
+:logseq.tldraw.shape 
+{:isSizeLocked true
+:stroke ""
+:borderRadius 0
+:index 1
+:scale [1 1]
+:scaleLevel "md"
+:fill ""
+:type "text"
+:size [78 34]
+:fontFamily "var(--ls-font-family)"
+:strokeType "line"
+:strokeWidth 2
+:opacity 1
+:id "51851490-ee6f-11ed-9c5e-21b9b3de5563"
+:padding 4
+:fontWeight 400
+:noFill true
+:point [719.5019628453911 862.2621018969135]
+:lineHeight 1.2
+:fontSize 20
+:parentId "64551487-ffab-406c-adcf-a4e8f00db19c"
+:nonce 1683639739496
+:italic false
+:text "fsdfsdf"}}
+:block/updated-at 1683639741650})
+:pages (
+{:block/uuid #uuid "64551487-ffab-406c-adcf-a4e8f00db19c"
+:block/properties 
+{:ls-type :whiteboard-page
+:logseq.tldraw.page 
+{:id "64551487-ffab-406c-adcf-a4e8f00db19c"
+:name "page 9322"
+:bindings 
+{}
+:nonce 1
+:assets []
+:shapes-index ("e694caf0-eb52-11ed-a877-89e9886a62fe" "51851490-ee6f-11ed-9c5e-21b9b3de5563")}}
+:block/updated-at 1683639741650
+:block/created-at 1683297415382
+:block/type "whiteboard"
+:block/name "page 9322"
+:block/original-name "page 9322"})}

File diff suppressed because it is too large
+ 39 - 0
deps/graph-parser/test/resources/exporter-test-graph/whiteboards/publishing test.edn


Some files were not shown because too many files changed in this diff