aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/editor.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor.mjs')
-rw-r--r--src/editor.mjs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/editor.mjs b/src/editor.mjs
index ed2ab25..ba54aa9 100644
--- a/src/editor.mjs
+++ b/src/editor.mjs
@@ -7,12 +7,22 @@ import { defaultAliasesForRenderer, parseConfigsFromYaml } from 'mapclay'
7const HtmlContainer = document.querySelector(".result-html") 7const HtmlContainer = document.querySelector(".result-html")
8const mdeElement = document.querySelector("#tinymde") 8const mdeElement = document.querySelector("#tinymde")
9 9
10const getContentFromHash = () => {
11 const hashValue = location.hash.substring(1);
12 window.location.hash = ''
13 return hashValue.startsWith('text=')
14 ? decodeURIComponent(hashValue.substring(5))
15 : null
16}
17
10// Add Editor 18// Add Editor
11const defaultContent = '## Links\n\n- [Go to marker](geo:24,121?id=foo,leaflet&text=normal "Link Test")\n\n```map\nid: foo\nuse: Maplibre\n```\n' 19const contentFromHash = getContentFromHash()
12const lastContent = localStorage.getItem('editorContent') 20const lastContent = localStorage.getItem('editorContent')
21const defaultContent = '## Links\n\n- [Go to marker](geo:24,121?id=foo,leaflet&text=normal "Link Test")\n\n```map\nid: foo\nuse: Maplibre\n```\n'
22
13const tinyEditor = new TinyMDE.Editor({ 23const tinyEditor = new TinyMDE.Editor({
14 element: 'tinymde', 24 element: 'tinymde',
15 content: lastContent ? lastContent : defaultContent 25 content: contentFromHash ?? lastContent ?? defaultContent
16}); 26});
17mdeElement.querySelectorAll('span').forEach(e => e.setAttribute('spellcheck', 'false')) 27mdeElement.querySelectorAll('span').forEach(e => e.setAttribute('spellcheck', 'false'))
18 28
@@ -38,8 +48,7 @@ const debugCommand = {
38 title: 'show debug message', 48 title: 'show debug message',
39 innerHTML: `<div style="font-size: 16px; line-height: 1.1;">🤔</div>`, 49 innerHTML: `<div style="font-size: 16px; line-height: 1.1;">🤔</div>`,
40 action: () => { 50 action: () => {
41 // FIXME 51 window.location.hash = '#text=' + encodeURIComponent(tinyEditor.getContent())
42 alert(tinyEditor.getContent())
43 }, 52 },
44 hotkey: 'Ctrl-i' 53 hotkey: 'Ctrl-i'
45} 54}