feat(editor/copy-paste): refactor copy/export in cljs (#8530)

Huge performance improvement for copy and export

Refactor copy/export in cljs instead of Mldoc
This commit is contained in:
rcmerci
2023-02-20 23:08:58 +08:00
committed by GitHub
parent c0f8dc4ee2
commit 2a12ffc331
14 changed files with 2341 additions and 297 deletions

View File

@@ -3,6 +3,7 @@
[frontend.test.helper :as test-helper :include-macros true :refer [deftest-async]]
[clojure.edn :as edn]
[frontend.handler.export :as export]
[frontend.handler.export.text :as export-text]
[frontend.state :as state]
[promesa.core :as p]))
@@ -11,18 +12,18 @@
:file/content
"- 1
id:: 61506710-484c-46d5-9983-3d1651ec02c8
- 2
id:: 61506711-5638-4899-ad78-187bdc2eaffc
- 3
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
- ((61506712-3007-407e-b6d3-d008a8dfa88b))
- 2
id:: 61506711-5638-4899-ad78-187bdc2eaffc
- 3
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
- ((61506712-3007-407e-b6d3-d008a8dfa88b))
- 4
id:: 61506712-b8a7-491d-ad84-b71651c3fdab"}
{:file/path "pages/page2.md"
:file/content
"- 3
id:: 97a00e55-48c3-48d8-b9ca-417b16e3a616
- {{embed [[page1]]}}"}])
- {{embed [[page1]]}}"}])
(use-fixtures :once
{:before (fn []
@@ -36,23 +37,23 @@
(p/do!
(are [expect block-uuid-s]
(= expect
(export/export-blocks-as-markdown (state/get-current-repo) [(uuid block-uuid-s)] "dashes" []))
"- 1 \n\t- 2 \n\t\t- 3 \n\t\t- 3 "
"61506710-484c-46d5-9983-3d1651ec02c8"
(export-text/export-blocks-as-markdown (state/get-current-repo) [(uuid block-uuid-s)] {}))
"- 1\n\t- 2\n\t\t- 3\n\t\t- 3\n"
"61506710-484c-46d5-9983-3d1651ec02c8"
"- 3 \n\t- 1 \n\t\t- 2 \n\t\t\t- 3 \n\t\t\t- 3 \n\t- 4 "
"97a00e55-48c3-48d8-b9ca-417b16e3a616")))
"- 3\n\t- 1\n\t\t- 2\n\t\t\t- 3\n\t\t\t- 3\n\t- 4\n"
"97a00e55-48c3-48d8-b9ca-417b16e3a616")))
(deftest-async export-files-as-markdown
(p/do!
(are [expect files]
(= expect
(@#'export/export-files-as-markdown (state/get-current-repo) files true))
[["pages/page1.md" "- 1 \n\t- 2 \n\t\t- 3 \n\t\t- 3 \n- 4 "]]
[{:path "pages/page1.md" :content (:file/content (nth test-files 0)) :names ["page1"] :format :markdown}]
(@#'export-text/export-files-as-markdown files nil))
[["pages/page1.md" "- 1\n\t- 2\n\t\t- 3\n\t\t- 3\n- 4\n"]]
[{:path "pages/page1.md" :content (:file/content (nth test-files 0)) :names ["page1"] :format :markdown}]
[["pages/page2.md" "- 3 \n\t- 1 \n\t\t- 2 \n\t\t\t- 3 \n\t\t\t- 3 \n\t- 4 "]]
[{:path "pages/page2.md" :content (:file/content (nth test-files 1)) :names ["page2"] :format :markdown}])))
[["pages/page2.md" "- 3\n\t- 1\n\t\t- 2\n\t\t\t- 3\n\t\t\t- 3\n\t- 4\n"]]
[{:path "pages/page2.md" :content (:file/content (nth test-files 1)) :names ["page2"] :format :markdown}])))
(deftest-async export-repo-as-edn-str
(p/do!