浏览代码

fix: no whiteboards in the exported edn/json

Tienson Qin 2 年之前
父节点
当前提交
d8c517039a
共有 2 个文件被更改,包括 17 次插入10 次删除
  1. 13 8
      src/main/frontend/handler/export.cljs
  2. 4 2
      src/main/frontend/handler/external.cljs

+ 13 - 8
src/main/frontend/handler/export.cljs

@@ -311,17 +311,22 @@
                [?b :block/name]] db)
 
         (map (fn [[{:block/keys [name] :as page}]]
-               (let [blocks (db/get-page-blocks-no-cache
+               (let [whiteboard? (= "whiteboard" (:block/type page))
+                     blocks (db/get-page-blocks-no-cache
                              (state/get-current-repo)
                              name
                              {:transform? false})
-                     blocks' (map (fn [b]
-                                    (let [b' (if (seq (:block/properties b))
-                                               (update b :block/content
-                                                       (fn [content] (property/remove-properties (:block/format b) content)))
-                                               b)]
-                                      (safe-keywordize b'))) blocks)
-                     children (outliner-tree/blocks->vec-tree blocks' name)
+                     blocks' (if whiteboard?
+                               blocks
+                               (map (fn [b]
+                                     (let [b' (if (seq (:block/properties b))
+                                                (update b :block/content
+                                                        (fn [content] (property/remove-properties (:block/format b) content)))
+                                                b)]
+                                       (safe-keywordize b'))) blocks))
+                     children (if whiteboard?
+                                blocks'
+                                (outliner-tree/blocks->vec-tree blocks' name))
                      page' (safe-keywordize page)]
                  (assoc page' :block/children children))))
         (nested-select-keys

+ 4 - 2
src/main/frontend/handler/external.cljs

@@ -116,8 +116,9 @@
    :id       - page's uuid
    :title    - page's title (original name)
    :children - tree
+   :properties - map
    "
-  [{:keys [uuid title children] :as tree}]
+  [{:keys [uuid title children properties] :as tree}]
   (let [has-children? (seq children)
         page-format (or (some-> tree (:children) (first) (:format)) :markdown)]
     (try (page-handler/create! title {:redirect?  false
@@ -135,7 +136,8 @@
         (try (editor/insert-block-tree children page-format
                                        {:target-block page-block
                                         :sibling?     false
-                                        :keep-uuid?   true})
+                                        :keep-uuid?   true
+                                        :properties   properties})
              (catch :default e
                (js/console.error e)
                (notification/show! (str "Error happens when creating block content of page " title "\n"