diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-11 17:12:31 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-11 17:33:01 +0800 |
| commit | 7968922f416146c87d5d6aa4f6e415603d210424 (patch) | |
| tree | 8e86f35b4368bf55aa7f8ec77361d82faff78af2 | |
| parent | c2acb9473d4a19e7ad843ae026d762bf7a5d92e5 (diff) | |
feat: update tutorial content for adding GeoLink
* add new module for hoding contents
* also add settings for linkify
| -rw-r--r-- | src/css/style.css | 4 | ||||
| -rw-r--r-- | src/dumbymap.mjs | 6 | ||||
| -rw-r--r-- | src/editor.mjs | 69 | ||||
| -rw-r--r-- | src/tutorial.mjs | 62 |
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 | ||
| 92 | code { | 92 | code { |
| 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' | |||
| 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() |
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 @@ | |||
| 1 | export const md = `<!-- banner --> | ||
| 2 | > <big><br>Hello My Friend! This is DumbyMap!<br><br></big> | ||
| 3 | |||
| 4 | \`\`\`map | ||
| 5 | use: Maplibre | ||
| 6 | height: 120px | ||
| 7 | style: https://tile.openstreetmap.jp/styles/openmaptiles/style.json | ||
| 8 | \`\`\` | ||
| 9 | |||
| 10 | |||
| 11 | DumbyMap generates **interactive document with maps** from raw texts. | ||
| 12 | |||
| 13 | You can use it to: | ||
| 14 | |||
| 15 | 1. [Roll a Dice] for a new map | ||
| 16 | 2. Hover on [GeoLink][example-geolink] to show point in maps. | ||
| 17 | 3. Add GeoLink by dragging **selected text** | ||
| 18 | 4. Change contents by [Editor] with [Markdown] text | ||
| 19 | 5. **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 | |||
| 25 | If you want know more, take a look at subjects below: | ||
| 26 | 1. [How to write Markdown text?](https://www.markdownguide.org/basic-syntax/) | ||
| 27 | 1. <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> | ||
| 38 | 1. <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> | ||
| 46 | 1. <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> | ||
| 53 | 1. [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"` | ||