Skip to content

Commit

Permalink
defer loading html2canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Jun 30, 2023
1 parent 9dda1ec commit 16e0c37
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion deps/publishing/src/logseq/publishing/html.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ necessary db filtering"
[:script {:src "static/js/interact.min.js"}]
[:script {:src "static/js/highlight.min.js"}]
[:script {:src "static/js/katex.min.js"}]
[:script {:src "static/js/html2canvas.min.js"}]
[:script {:src "static/js/code-editor.js"}]
[:script {:src "static/js/custom.js"}]])))))

Expand Down
1 change: 0 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<script defer src="/static/js/highlight.min.js"></script>
<script defer src="/static/js/interact.min.js"></script>
<script defer src="/static/js/marked.min.js"></script>
<script defer src="/static/js/html2canvas.min.js"></script>
<script defer src="/static/js/main.js"></script>
<script defer src="/static/js/amplify.js"></script>
<script defer src="/static/js/tabler.min.js"></script>
Expand Down
1 change: 0 additions & 1 deletion resources/electron.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<script defer src="./js/highlight.min.js"></script>
<script defer src="./js/interact.min.js"></script>
<script defer src="./js/marked.min.js"></script>
<script defer src="./js/html2canvas.min.js"></script>
<script defer src="./js/lsplugin.core.js"></script>
<script defer src="./js/main.js"></script>
<script defer src="./js/amplify.js"></script>
Expand Down
1 change: 0 additions & 1 deletion resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<script defer src="./js/highlight.min.js"></script>
<script defer src="./js/interact.min.js"></script>
<script defer src="./js/marked.min.js"></script>
<script defer src="./js/html2canvas.min.js"></script>
<script defer src="./js/lsplugin.core.js"></script>
<script defer src="./js/main.js"></script>
<script defer src="./js/amplify.js"></script>
Expand Down
17 changes: 9 additions & 8 deletions src/main/frontend/components/export.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[rum.core :as rum]))
[rum.core :as rum]
[promesa.core :as p]))

(rum/defc export
[]
Expand Down Expand Up @@ -110,13 +111,13 @@
:scale scale
:windowHeight (when (string? block-uuids-or-page-name)
(.-scrollHeight container))}]
(-> (js/html2canvas container options)
(.then (fn [canvas] (.toBlob canvas (fn [blob]
(when blob
(let [img (js/document.getElementById "export-preview")
img-url (image/create-object-url blob)]
(set! (.-src img) img-url)
(callback blob)))) "image/png"))))))
(p/let [_ (util/js-load$ (str util/JS_ROOT "/html2canvas.min.js"))] (-> (js/html2canvas container options)
(.then (fn [canvas] (.toBlob canvas (fn [blob]
(when blob
(let [img (js/document.getElementById "export-preview")
img-url (image/create-object-url blob)]
(set! (.-src img) img-url)
(callback blob)))) "image/png")))))))

(rum/defcs ^:large-vars/cleanup-todo
export-blocks < rum/static
Expand Down

0 comments on commit 16e0c37

Please sign in to comment.