aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/editor.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-11 17:12:31 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-11 17:33:01 +0800
commit7968922f416146c87d5d6aa4f6e415603d210424 (patch)
tree8e86f35b4368bf55aa7f8ec77361d82faff78af2 /src/editor.mjs
parentc2acb9473d4a19e7ad843ae026d762bf7a5d92e5 (diff)
feat: update tutorial content for adding GeoLink
* add new module for hoding contents * also add settings for linkify
Diffstat (limited to 'src/editor.mjs')
-rw-r--r--src/editor.mjs69
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'
5import { addAnchorByPoint } from './dumbyUtils.mjs' 5import { addAnchorByPoint } from './dumbyUtils.mjs'
6import { shiftByWindow } from './utils.mjs' 6import { shiftByWindow } from './utils.mjs'
7import LeaderLine from 'leader-line' 7import LeaderLine from 'leader-line'
8import * 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 **/
89const defaultContent =
90 `<br>
91
92> <big>Hello My Friend! This is DumbyMap!</big>
93
94<br>
95
96\`\`\`map
97use: Leaflet
98height: 120px
99XYZ: https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png
100\`\`\`
101
102
103DumbyMap generates **interactive document with maps** from raw texts.
104
105You can use it to:
106
1071. [Roll a Dice] for a new map
1082. Hover on [GeoLink][example-geolink] to show point in maps.
1093. Add GeoLink by dragging **selected text**
1104. Change contents by [Editor] with [Markdown] text
1115. **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
117If you want know more, take a look at subjects below:
1181. [How to write Markdown text?](https://www.markdownguide.org/basic-syntax/)
1191. <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>
1281. <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>
1361. [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 **/
151const editor = new EasyMDE({ 90const 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)
305window.location.hash = '' 244window.location.hash = ''
306 245
307if (url.searchParams.get('content') === 'tutorial') { 246if (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()