Forráskód Böngészése

fix: normal page cannot be saved

Peng Xiao 3 éve
szülő
commit
357a51c8bd

+ 0 - 3
src/main/frontend/components/page.cljs

@@ -314,9 +314,6 @@
                          "control-show cursor-pointer" "control-hide")}
     (ui/rotating-arrow @*all-collapsed?)]])
 
-(defn get-tldraw-preview [page-name]
-  ((state/get-component :whiteboard/tldraw-preview) page-name))
-
 ;; A page is just a logical block
 (rum/defcs ^:large-vars/cleanup-todo page < rum/reactive
   (rum/local false ::all-collapsed?)

+ 0 - 2
src/main/frontend/extensions/tldraw.cljs

@@ -12,8 +12,6 @@
 
 (def tldraw (r/adapt-class (gobj/get TldrawLogseq "App")))
 
-(def generate-preview (gobj/get TldrawLogseq "generateJSXFromApp"))
-
 (rum/defc page-cp
   [props]
   (page/page {:page-name (gobj/get props "pageName") :whiteboard? true}))

+ 21 - 17
src/main/frontend/modules/outliner/file.cljs

@@ -30,30 +30,34 @@
     {:block/left      [:block/name :block/uuid]}
     {:block/parent    [:block/name :block/uuid]}])
 
+(defn- cleanup-whiteboard-block
+  [block]
+  (if (get-in block [:block/properties :ls-type] false)
+    (dissoc block
+            :block/uuid ;; shape block uuid is read from properties
+            :block/content
+            :block/format
+            :block/left
+            :block/page
+            :block/parent) ;; these are auto-generated for whiteboard shapes
+    (dissoc block :block/page)))
+
 (defn do-write-file!
   [repo page-db-id]
   (let [page-block (db/pull repo '[*] page-db-id)
+        page-db-id (:db/id page-block)
         whiteboard? (:block/whiteboard? page-block)
-        blocks (model/get-page-blocks-no-cache
-                repo (:block/name page-block)
-                {:pull-keys (if whiteboard? whiteboard-blocks-pull-keys-with-persisted-ids '[*])})
-        blocks (map #(if (get-in % [:block/properties :ls-type] false)
-                       (dissoc %
-                               :block/uuid ;; shape block uuid is read from properties
-                               :block/content
-                               :block/format
-                               :block/left
-                               :block/page
-                               :block/parent) ;; these are auto-generated for whiteboard shapes
-                       (dissoc % :block/page)) blocks)]
+        pull-keys (if whiteboard? whiteboard-blocks-pull-keys-with-persisted-ids '[*])
+        blocks (model/get-page-blocks-no-cache repo (:block/name page-block) {:pull-keys pull-keys})
+        blocks (if whiteboard? (map cleanup-whiteboard-block blocks) blocks)]
+
     (when-not (and (= 1 (count blocks))
                    (string/blank? (:block/content (first blocks)))
                    (nil? (:block/file page-block)))
-      (if page-block
-        (file/save-tree! page-block (if whiteboard?
-                                      blocks
-                                      (tree/blocks->vec-tree repo blocks (:block/name page-block))))
-        (js/console.error (str "can't find page id: " page-db-id))))))
+      (let [tree (tree/blocks->vec-tree repo blocks (:block/name page-block))]
+        (if page-block
+          (file/save-tree! page-block (if whiteboard? blocks tree))
+          (js/console.error (str "can't find page id: " page-db-id)))))))
 
 (defn write-files!
   [pages]