diff options
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 69 |
1 files changed, 4 insertions, 65 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index e12073f..58393aa 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -5,6 +5,7 @@ import * as menuItem from './MenuItem' | |||
5 | import { addAnchorByPoint } from './dumbyUtils.mjs' | 5 | import { addAnchorByPoint } from './dumbyUtils.mjs' |
6 | import { shiftByWindow } from './utils.mjs' | 6 | import { shiftByWindow } from './utils.mjs' |
7 | import LeaderLine from 'leader-line' | 7 | import LeaderLine from 'leader-line' |
8 | import * as tutorial from './tutorial' | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * @typedef {Object} RefLink | 11 | * @typedef {Object} RefLink |
@@ -85,72 +86,10 @@ const toggleEditing = () => { | |||
85 | } | 86 | } |
86 | // }}} | 87 | // }}} |
87 | // Set up EasyMDE {{{ | 88 | // Set up EasyMDE {{{ |
88 | /** Contents for tutorial **/ | ||
89 | const defaultContent = | ||
90 | `<br> | ||
91 | |||
92 | > <big>Hello My Friend! This is DumbyMap!</big> | ||
93 | |||
94 | <br> | ||
95 | |||
96 | \`\`\`map | ||
97 | use: Leaflet | ||
98 | height: 120px | ||
99 | XYZ: https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png | ||
100 | \`\`\` | ||
101 | |||
102 | |||
103 | DumbyMap generates **interactive document with maps** from raw texts. | ||
104 | |||
105 | You can use it to: | ||
106 | |||
107 | 1. [Roll a Dice] for a new map | ||
108 | 2. Hover on [GeoLink][example-geolink] to show point in maps. | ||
109 | 3. Add GeoLink by dragging **selected text** | ||
110 | 4. Change contents by [Editor] with [Markdown] text | ||
111 | 5. **Right click** to call context menu, you can: | ||
112 | + Change focus between maps | ||
113 | + Select a block for browsing | ||
114 | + Switch layouts for various use cases | ||
115 | |||
116 | |||
117 | If you want know more, take a look at subjects below: | ||
118 | 1. [How to write Markdown text?](https://www.markdownguide.org/basic-syntax/) | ||
119 | 1. <details> | ||
120 | <summary>How can I save contents for next use?</summary> | ||
121 | |||
122 | Since All contents come from raw texts, you can: | ||
123 | 1. Save current page as bookmark by [hash button](#create-hash "=>.mde-hash") | ||
124 | 2. Copy texts in editor and save as \`.txt\` file | ||
125 | 3. Use online service for hosting Markdown, for example: [HackMD](https://hackmd.io) | ||
126 | |||
127 | </details> | ||
128 | 1. <details> | ||
129 | <summary>I want more features in map!</summary> | ||
130 | |||
131 | DumbyMap use [mapclay](https://github.com/outdoorsafetylab/mapclay) to render maps. | ||
132 | 1. You can use \`eval\` options to add custom scripts, see [tutorial](https://github.com/outdoorsafetylab/mapclay?tab=readme-ov-file#run-scripts-after-map-is-created) for more details | ||
133 | 2. You can use custom Renderer indtead of default ones, see [tutorial](https://github.com/outdoorsafetylab/mapclay?tab=readme-ov-file#renderer) for more details | ||
134 | |||
135 | </details> | ||
136 | 1. [I am an experienced developer, show me what you got!](https://github.com/outdoorsafetylab/dumbymap) | ||
137 | |||
138 | |||
139 | <br> | ||
140 | |||
141 | > <big>Have Fun ~<big> | ||
142 | |||
143 | <br> | ||
144 | |||
145 | [Roll a dice]: #Click%20it! "=>.mde-roll" | ||
146 | [example-geolink]: geo:24,121?xy=121,24&text=Use%20yellow%20link%20point%20to%20map | ||
147 | [Markdown]: https://www.markdownguide.org/basic-syntax/ | ||
148 | [Editor]: #This%20is%20editor! "=>.editor"` | ||
149 | |||
150 | /** Editor from EasyMDE **/ | 89 | /** Editor from EasyMDE **/ |
151 | const editor = new EasyMDE({ | 90 | const editor = new EasyMDE({ |
152 | element: textArea, | 91 | element: textArea, |
153 | initialValue: defaultContent, | 92 | initialValue: tutorial.md, |
154 | autosave: { | 93 | autosave: { |
155 | enabled: true, | 94 | enabled: true, |
156 | uniqueId: 'dumbymap', | 95 | uniqueId: 'dumbymap', |
@@ -253,7 +192,7 @@ const editor = new EasyMDE({ | |||
253 | text: '\u{2753}', | 192 | text: '\u{2753}', |
254 | title: 'Reset for content for tutorial', | 193 | title: 'Reset for content for tutorial', |
255 | action: () => { | 194 | action: () => { |
256 | editor.value(defaultContent) | 195 | editor.value(tutorial.md) |
257 | refLinks = getRefLinks() | 196 | refLinks = getRefLinks() |
258 | updateDumbyMap() | 197 | updateDumbyMap() |
259 | }, | 198 | }, |
@@ -305,7 +244,7 @@ const contentFromHash = getContentFromHash(window.location.hash) | |||
305 | window.location.hash = '' | 244 | window.location.hash = '' |
306 | 245 | ||
307 | if (url.searchParams.get('content') === 'tutorial') { | 246 | if (url.searchParams.get('content') === 'tutorial') { |
308 | editor.value(defaultContent) | 247 | editor.value(tutorial.md) |
309 | } else if (contentFromHash) { | 248 | } else if (contentFromHash) { |
310 | // Seems like autosave would overwrite initialValue, set content from hash here | 249 | // Seems like autosave would overwrite initialValue, set content from hash here |
311 | editor.cleanup() | 250 | editor.cleanup() |