aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/css/style.css4
-rw-r--r--src/dumbymap.mjs6
-rw-r--r--src/editor.mjs69
-rw-r--r--src/tutorial.mjs62
4 files changed, 74 insertions, 67 deletions
diff --git a/src/css/style.css b/src/css/style.css
index 6b0c16d..8bae1b8 100644
--- a/src/css/style.css
+++ b/src/css/style.css
@@ -91,7 +91,9 @@ a:hover {
91 91
92code { 92code {
93 display: inline-block; 93 display: inline-block;
94 padding: 0.3em; 94 padding-inline: 0.5em;
95
96 border-radius: 5px;
95 97
96 background-color: whitesmoke; 98 background-color: whitesmoke;
97 99
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs
index 974d4a3..c39a62c 100644
--- a/src/dumbymap.mjs
+++ b/src/dumbymap.mjs
@@ -67,10 +67,14 @@ export const markdown2HTML = (container, mdContent) => {
67 return match 67 return match
68 }, 68 },
69 } 69 }
70 const patterns = ['[', '(', '📍', '\uFF08', '@', 'geo:', 'twd'] 70 const patterns = ['[', '(', '📍', '\uFF08', '@', 'twd']
71 patterns.forEach(prefix => 71 patterns.forEach(prefix =>
72 md.linkify.add(prefix, coordinateValue), 72 md.linkify.add(prefix, coordinateValue),
73 ) 73 )
74 md.linkify.add('geo:', {
75 validate: /(-?\d+\.?\d*),(-?\d+\.?\d*)/,
76 normalize: match => match,
77 })
74 78
75 /** Custom rule for Blocks in DumbyMap */ 79 /** Custom rule for Blocks in DumbyMap */
76 // FIXME A better way to generate blocks 80 // FIXME A better way to generate blocks
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()
diff --git a/src/tutorial.mjs b/src/tutorial.mjs
new file mode 100644
index 0000000..15d5779
--- /dev/null
+++ b/src/tutorial.mjs
@@ -0,0 +1,62 @@
1export const md = `<!-- banner -->
2> <big><br>Hello My Friend! This is DumbyMap!<br><br></big>
3
4\`\`\`map
5use: Maplibre
6height: 120px
7style: https://tile.openstreetmap.jp/styles/openmaptiles/style.json
8\`\`\`
9
10
11DumbyMap generates **interactive document with maps** from raw texts.
12
13You can use it to:
14
151. [Roll a Dice] for a new map
162. Hover on [GeoLink][example-geolink] to show point in maps.
173. Add GeoLink by dragging **selected text**
184. Change contents by [Editor] with [Markdown] text
195. **Right click** to call context menu, you can:
20 + Change focus between maps
21 + Select a block for browsing
22 + Switch layouts for various use cases
23
24
25If you want know more, take a look at subjects below:
261. [How to write Markdown text?](https://www.markdownguide.org/basic-syntax/)
271. <details>
28 <summary>How to add GeoLink in Markdown</summary>
29
30 The following formats are valid for GeoLink:
31 1. Surround coordinated with parenthesis: \`(<x>, <y>)\` or \`(<x>/<y>)\`
32 For example: (121,23)
33 2. Have leading \`@\` symbol: \`@<x>,<y>\` or \`@<x>/<y>\`
34 For example: @121/23
35 3. Use geo URI scheme: \`geo:<lat>,<lon>\`
36 For example: geo:23,121
37 </details>
381. <details>
39 <summary>How can I save contents for next use?</summary>
40
41 Since All contents come from raw texts, you can:
42 1. Save current page as bookmark by [hash button](#create-hash "=>.mde-hash")
43 2. Copy texts in editor and save as \`.txt\` file
44 3. Use online service for hosting Markdown, for example: [HackMD](https://hackmd.io)
45 </details>
461. <details>
47 <summary>I want more features in map!</summary>
48
49 DumbyMap use [mapclay](https://github.com/outdoorsafetylab/mapclay) to render maps.
50 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
51 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
52 </details>
531. [I am an experienced developer, show me what you got!](https://github.com/outdoorsafetylab/dumbymap)
54
55
56<!-- footer -->
57> <big><br>Have Fun ~<br><br></big>
58
59[Roll a Dice]: #Click%20it! "=>.mde-roll"
60[example-geolink]: geo:24,121?xy=121,24&text=Use%20yellow%20link%20point%20to%20map
61[Markdown]: https://www.markdownguide.org/basic-syntax/
62[Editor]: #This%20is%20editor! "=>.editor"`