Browse Source

feat: block-level export md

rcmerci 4 years ago
parent
commit
5288c374a5
1 changed files with 14 additions and 0 deletions
  1. 14 0
      src/main/frontend/handler/export.cljs

+ 14 - 0
src/main/frontend/handler/export.cljs

@@ -468,6 +468,20 @@
                    "untitled"
                    (js/JSON.stringify (clj->js refs)))))
 
+(defn- export-blocks-as-markdown
+  [repo root-block-uuid]
+  (let [get-page&block-refs-by-query-aux (get-embed-and-refs-blocks-pages-aux)
+        f #(get-page&block-refs-by-query repo % get-page&block-refs-by-query-aux {:is-block? true})
+        root-block (db/entity [:block/uuid root-block-uuid])
+        blocks (db/get-block-and-children repo root-block-uuid)
+        refs (f blocks)
+        content (get-blocks-contents repo root-block-uuid)
+        format (or (:block/format root-block) (state/get-preferred-format))]
+    (def aa refs)
+    (fp/exportMarkdown f/mldoc-record content
+                       (f/get-default-config format)
+                       (js/JSON.stringify (clj->js refs)))))
+
 
 
 (defn- convert-md-files-unordered-list-or-heading