|
|
@@ -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]
|