diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-06 00:13:41 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-06 00:43:45 +0800 |
| commit | 91c545201c17ed1bfaf5a428bbf03f544e4eed07 (patch) | |
| tree | ea9621f396ea7b23096806590ad8e7e87b31638c | |
| parent | 671a6eb222153b24e8fbf4371a0d97c51debb31e (diff) | |
feat: add editor action for export
hash icon for URL hash, floppy disk icon for export
| -rw-r--r-- | src/editor.mjs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index 2893f94..27744db 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
| @@ -67,16 +67,25 @@ const editor = new EasyMDE({ | |||
| 67 | action: () => addMapRandomlyByPreset() | 67 | action: () => addMapRandomlyByPreset() |
| 68 | }, | 68 | }, |
| 69 | { | 69 | { |
| 70 | name: 'debug', | 70 | name: 'export', |
| 71 | title: 'Save content as URL', | 71 | title: 'Export current page', |
| 72 | text: '\u{1F4BE}', | 72 | text: '\u{1F4BE}', |
| 73 | action: () => { | 73 | action: () => { |
| 74 | } | ||
| 75 | }, | ||
| 76 | { | ||
| 77 | name: 'hash', | ||
| 78 | title: 'Save content as URL', | ||
| 79 | // text: '\u{1F4BE}', | ||
| 80 | text: '#', | ||
| 81 | action: () => { | ||
| 74 | const state = { content: editor.value() } | 82 | const state = { content: editor.value() } |
| 75 | window.location.hash = encodeURIComponent(JSON.stringify(state)) | 83 | window.location.hash = encodeURIComponent(JSON.stringify(state)) |
| 76 | navigator.clipboard.writeText(window.location.href) | 84 | navigator.clipboard.writeText(window.location.href) |
| 77 | window.alert('URL copied to clipboard') | 85 | window.alert('URL updated in address bar, you can save current page as bookmark') |
| 78 | } | 86 | } |
| 79 | }, | 87 | }, |
| 88 | '|', | ||
| 80 | { | 89 | { |
| 81 | name: 'undo', | 90 | name: 'undo', |
| 82 | title: 'Undo last editing', | 91 | title: 'Undo last editing', |