diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-11 19:13:09 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-11 19:13:09 +0800 |
commit | 2d99b7a1467cef57c9b71e6c2dd9bbdea67331e3 (patch) | |
tree | c44159efe303b047bf2d9d89ef24012db1c1400c /src/editor.mjs | |
parent | 722b799b22198ff9a25e6be8d3a685afcbaba4f3 (diff) |
feat: Use Query Params to render maps
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 9b245d8..beee35b 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -32,6 +32,7 @@ const getContentFromHash = (hash) => { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | const initialState = getStateFromHash(window.location.hash) | 34 | const initialState = getStateFromHash(window.location.hash) |
35 | const queryParams = new URL(window.location).searchParams | ||
35 | window.location.hash = '' | 36 | window.location.hash = '' |
36 | const contentFromHash = initialState.content | 37 | const contentFromHash = initialState.content |
37 | const lastContent = localStorage.getItem('editorContent') | 38 | const lastContent = localStorage.getItem('editorContent') |
@@ -82,6 +83,10 @@ const cm = editor.codemirror | |||
82 | markdown2HTML(HtmlContainer, editor.value()) | 83 | markdown2HTML(HtmlContainer, editor.value()) |
83 | createDocLinks(HtmlContainer) | 84 | createDocLinks(HtmlContainer) |
84 | 85 | ||
86 | if (queryParams.get('render')) { | ||
87 | toggleMaps(HtmlContainer) | ||
88 | } | ||
89 | |||
85 | // Re-render HTML by editor content | 90 | // Re-render HTML by editor content |
86 | cm.on("change", () => { | 91 | cm.on("change", () => { |
87 | markdown2HTML(HtmlContainer, editor.value()) | 92 | markdown2HTML(HtmlContainer, editor.value()) |