diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-11 21:30:23 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-14 16:34:00 +0800 |
commit | 71ce6889d0a5359e63285d5ec3a299fd79b59778 (patch) | |
tree | 9c11885ef0489e063172a82a98d0232f6aa622fe | |
parent | a295061365349df7adf14d2ed8171a476f46eda9 (diff) |
docs: jsdoc
-rw-r--r-- | src/Layout.mjs | 10 | ||||
-rw-r--r-- | src/MenuItem.mjs | 16 | ||||
-rw-r--r-- | src/dumbyUtils.mjs | 13 | ||||
-rw-r--r-- | src/dumbymap.mjs | 12 | ||||
-rw-r--r-- | src/editor.mjs | 23 |
5 files changed, 40 insertions, 34 deletions
diff --git a/src/Layout.mjs b/src/Layout.mjs index 1b5656d..485b513 100644 --- a/src/Layout.mjs +++ b/src/Layout.mjs | |||
@@ -94,7 +94,7 @@ export class Overlay extends Layout { | |||
94 | /** | 94 | /** |
95 | * saveLeftTopAsData. | 95 | * saveLeftTopAsData. |
96 | * | 96 | * |
97 | * @param {} element | 97 | * @param {HTMLElement} element |
98 | */ | 98 | */ |
99 | saveLeftTopAsData = element => { | 99 | saveLeftTopAsData = element => { |
100 | const { left, top } = element.getBoundingClientRect() | 100 | const { left, top } = element.getBoundingClientRect() |
@@ -105,7 +105,7 @@ export class Overlay extends Layout { | |||
105 | /** | 105 | /** |
106 | * addDraggable. | 106 | * addDraggable. |
107 | * | 107 | * |
108 | * @param {} element | 108 | * @param {HTMLElement} element |
109 | */ | 109 | */ |
110 | addDraggable = element => { | 110 | addDraggable = element => { |
111 | // Make sure current element always on top | 111 | // Make sure current element always on top |
@@ -169,7 +169,8 @@ export class Overlay extends Layout { | |||
169 | /** | 169 | /** |
170 | * enterHandler. | 170 | * enterHandler. |
171 | * | 171 | * |
172 | * @param {} | 172 | * @param {HTMLElement} options.hemlHolder - Parent element for block |
173 | * @param {HTMLElement[]} options.blocks | ||
173 | */ | 174 | */ |
174 | enterHandler = ({ htmlHolder, blocks }) => { | 175 | enterHandler = ({ htmlHolder, blocks }) => { |
175 | // FIXME It is weird rect from this method and this scope are different... | 176 | // FIXME It is weird rect from this method and this scope are different... |
@@ -257,7 +258,8 @@ export class Overlay extends Layout { | |||
257 | /** | 258 | /** |
258 | * leaveHandler. | 259 | * leaveHandler. |
259 | * | 260 | * |
260 | * @param {} | 261 | * @param {HTMLElement} htmlHolder |
262 | * @param {HTMLElement[]} blocks | ||
261 | */ | 263 | */ |
262 | leaveHandler = ({ htmlHolder, blocks }) => { | 264 | leaveHandler = ({ htmlHolder, blocks }) => { |
263 | const resumeFromDraggable = block => { | 265 | const resumeFromDraggable = block => { |
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs index 2fcb144..61ed33e 100644 --- a/src/MenuItem.mjs +++ b/src/MenuItem.mjs | |||
@@ -2,9 +2,9 @@ import { shiftByWindow } from './utils.mjs' | |||
2 | 2 | ||
3 | /** | 3 | /** |
4 | * @typedef {Object} RefLink | 4 | * @typedef {Object} RefLink |
5 | * @property {string} ref -- name of link | 5 | * @property {string} ref - name of link |
6 | * @property {string} link -- content of link | 6 | * @property {string} link - content of link |
7 | * @property {string|null} title -- title of link | 7 | * @property {string|null} title - title of link |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /** | 10 | /** |
@@ -204,7 +204,9 @@ export class Suggestion extends Item { | |||
204 | /** | 204 | /** |
205 | * constructor. | 205 | * constructor. |
206 | * | 206 | * |
207 | * @param {} | 207 | * @param {String} options.text |
208 | * @param {String} options.replace - new text content | ||
209 | * @param {CodeMirror} options.cm | ||
208 | */ | 210 | */ |
209 | constructor ({ text, replace, cm }) { | 211 | constructor ({ text, replace, cm }) { |
210 | super({ text }) | 212 | super({ text }) |
@@ -235,9 +237,9 @@ window.customElements.define('menu-item-suggestion', Suggestion, { extends: 'div | |||
235 | /** | 237 | /** |
236 | * renderResults. return a menu item for reporting render results | 238 | * renderResults. return a menu item for reporting render results |
237 | * | 239 | * |
238 | * @param {Object} options.modal -- Ojbect of plain-modal | 240 | * @param {Object} options.modal - Ojbect of plain-modal |
239 | * @param {HTMLElement} options.modalContent | 241 | * @param {HTMLElement} options.modalContent |
240 | * @param {HTMLElement} map -- Rendered map element | 242 | * @param {HTMLElement} map - Rendered map element |
241 | */ | 243 | */ |
242 | export const renderResults = ({ modal, modalContent }, map) => | 244 | export const renderResults = ({ modal, modalContent }, map) => |
243 | new Item({ | 245 | new Item({ |
@@ -366,7 +368,7 @@ export const toggleMapFocus = map => | |||
366 | * getCoordinatesByPixels. | 368 | * getCoordinatesByPixels. |
367 | * | 369 | * |
368 | * @param {HTMLElement} map instance | 370 | * @param {HTMLElement} map instance |
369 | * @param {Number[]} xy -- pixel of window | 371 | * @param {Number[]} xy - pixel of window |
370 | */ | 372 | */ |
371 | export const getCoordinatesByPixels = (map, xy) => | 373 | export const getCoordinatesByPixels = (map, xy) => |
372 | new Item({ | 374 | new Item({ |
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index f0878cf..a449646 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -5,8 +5,7 @@ export const coordPattern = /^geo:([-]?[0-9.]+),([-]?[0-9.]+)/ | |||
5 | 5 | ||
6 | /** | 6 | /** |
7 | * focusNextMap. | 7 | * focusNextMap. |
8 | * | 8 | * @param {Boolean} reverse - focus previous map |
9 | * @param {Boolean} reverse -- focus previous map | ||
10 | */ | 9 | */ |
11 | export function focusNextMap (reverse = false) { | 10 | export function focusNextMap (reverse = false) { |
12 | const renderedList = this.utils.renderedMaps() | 11 | const renderedList = this.utils.renderedMaps() |
@@ -21,7 +20,7 @@ export function focusNextMap (reverse = false) { | |||
21 | /** | 20 | /** |
22 | * focusNextBlock. | 21 | * focusNextBlock. |
23 | * | 22 | * |
24 | * @param {Boolean} reverse -- focus previous block | 23 | * @param {Boolean} reverse - focus previous block |
25 | */ | 24 | */ |
26 | export function focusNextBlock (reverse = false) { | 25 | export function focusNextBlock (reverse = false) { |
27 | const blocks = this.blocks.filter(b => | 26 | const blocks = this.blocks.filter(b => |
@@ -44,7 +43,7 @@ export function focusNextBlock (reverse = false) { | |||
44 | * scrollToBlock. Smoothly scroll to target block. | 43 | * scrollToBlock. Smoothly scroll to target block. |
45 | * If block is bigger than viewport, then pick strategy wisely. | 44 | * If block is bigger than viewport, then pick strategy wisely. |
46 | * | 45 | * |
47 | * @param {HTMLElement} block -- Scroll to this element | 46 | * @param {HTMLElement} block - Scroll to this element |
48 | */ | 47 | */ |
49 | export const scrollToBlock = block => { | 48 | export const scrollToBlock = block => { |
50 | const parentRect = block.parentElement.getBoundingClientRect() | 49 | const parentRect = block.parentElement.getBoundingClientRect() |
@@ -65,7 +64,7 @@ export function focusDelay () { | |||
65 | /** | 64 | /** |
66 | * switchToNextLayout. | 65 | * switchToNextLayout. |
67 | * | 66 | * |
68 | * @param {Boolean} reverse -- Switch to previous one | 67 | * @param {Boolean} reverse - Switch to previous one |
69 | */ | 68 | */ |
70 | export function switchToNextLayout (reverse = false) { | 69 | export function switchToNextLayout (reverse = false) { |
71 | const layouts = this.layouts | 70 | const layouts = this.layouts |
@@ -297,9 +296,9 @@ const isAnchorVisible = anchor => { | |||
297 | /** | 296 | /** |
298 | * addAnchorByPoint. | 297 | * addAnchorByPoint. |
299 | * | 298 | * |
300 | * @param {point} options.point -- object has {x, y} for window coordinates | 299 | * @param {point} options.point - object has {x, y} for window coordinates |
301 | * @param {HTMLElement} options.map | 300 | * @param {HTMLElement} options.map |
302 | * @param {Function} options.validateAnchorName -- validate anchor name is OK to use | 301 | * @param {Function} options.validateAnchorName - validate anchor name is OK to use |
303 | */ | 302 | */ |
304 | export const addAnchorByPoint = ({ | 303 | export const addAnchorByPoint = ({ |
305 | defaultName, | 304 | defaultName, |
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 4405786..4cfc484 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -12,7 +12,7 @@ import PlainModal from 'plain-modal' | |||
12 | import proj4 from 'proj4' | 12 | import proj4 from 'proj4' |
13 | import { register, fromEPSGCode } from 'ol/proj/proj4' | 13 | import { register, fromEPSGCode } from 'ol/proj/proj4' |
14 | 14 | ||
15 | /** Selector of special HTML Elements */ | 15 | /** CSS Selector for main components */ |
16 | const mapBlockSelector = 'pre:has(.language-map)' | 16 | const mapBlockSelector = 'pre:has(.language-map)' |
17 | const docLinkSelector = 'a[href^="#"][title^="=>"]' | 17 | const docLinkSelector = 'a[href^="#"][title^="=>"]' |
18 | const geoLinkSelector = 'a[href^="geo:"]' | 18 | const geoLinkSelector = 'a[href^="geo:"]' |
@@ -175,11 +175,11 @@ export const generateMaps = (container, { | |||
175 | } | 175 | } |
176 | }) | 176 | }) |
177 | 177 | ||
178 | /** Create DocLinks */ | 178 | /** LINK: Create DocLinks */ |
179 | container.querySelectorAll(docLinkSelector) | 179 | container.querySelectorAll(docLinkSelector) |
180 | .forEach(utils.createDocLink) | 180 | .forEach(utils.createDocLink) |
181 | 181 | ||
182 | /** Add external symbol on anchors */ | 182 | /** LINK: Add external symbol on anchors */ |
183 | container.querySelectorAll('a') | 183 | container.querySelectorAll('a') |
184 | .forEach(a => { | 184 | .forEach(a => { |
185 | if (a.href.startsWith('http') && !a.href.startsWith(window.location.origin)) { | 185 | if (a.href.startsWith('http') && !a.href.startsWith(window.location.origin)) { |
@@ -187,7 +187,7 @@ export const generateMaps = (container, { | |||
187 | } | 187 | } |
188 | }) | 188 | }) |
189 | 189 | ||
190 | /** Set CRS and GeoLinks */ | 190 | /** LINK: Set CRS and GeoLinks */ |
191 | register(proj4) | 191 | register(proj4) |
192 | fromEPSGCode(crs).then(projection => { | 192 | fromEPSGCode(crs).then(projection => { |
193 | const transform = proj4(crs, 'EPSG:4326').forward | 193 | const transform = proj4(crs, 'EPSG:4326').forward |
@@ -417,7 +417,7 @@ export const generateMaps = (container, { | |||
417 | /** | 417 | /** |
418 | * updateAttributeByStep. | 418 | * updateAttributeByStep. |
419 | * | 419 | * |
420 | * @param {Object} -- renderer which is running steps | 420 | * @param {Object} - renderer which is running steps |
421 | */ | 421 | */ |
422 | const updateAttributeByStep = ({ results, target, steps }) => { | 422 | const updateAttributeByStep = ({ results, target, steps }) => { |
423 | let passNum = results.filter( | 423 | let passNum = results.filter( |
@@ -442,7 +442,7 @@ export const generateMaps = (container, { | |||
442 | * config converter for mapclay.renderWith() | 442 | * config converter for mapclay.renderWith() |
443 | * | 443 | * |
444 | * @param {Object} config | 444 | * @param {Object} config |
445 | * @return {Object} -- converted config | 445 | * @return {Object} - converted config |
446 | */ | 446 | */ |
447 | const configConverter = config => ({ | 447 | const configConverter = config => ({ |
448 | use: config.use ?? 'Leaflet', | 448 | use: config.use ?? 'Leaflet', |
diff --git a/src/editor.mjs b/src/editor.mjs index f6c7dab..a8e3e0d 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -9,9 +9,9 @@ import * as tutorial from './tutorial' | |||
9 | 9 | ||
10 | /** | 10 | /** |
11 | * @typedef {Object} RefLink | 11 | * @typedef {Object} RefLink |
12 | * @property {string} ref -- name of link | 12 | * @property {string} ref - name of link |
13 | * @property {string} link -- content of link | 13 | * @property {string} link - content of link |
14 | * @property {string|null} title -- title of link | 14 | * @property {string|null} title - title of link |
15 | */ | 15 | */ |
16 | 16 | ||
17 | // Set up Containers {{{ | 17 | // Set up Containers {{{ |
@@ -291,6 +291,7 @@ const updateScrollLine = (ele) => () => { | |||
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | /** sync scroll from HTML to CodeMirror */ | ||
294 | new window.MutationObserver(() => { | 295 | new window.MutationObserver(() => { |
295 | clearTimeout(dumbyContainer.timer) | 296 | clearTimeout(dumbyContainer.timer) |
296 | dumbyContainer.timer = setTimeout( | 297 | dumbyContainer.timer = setTimeout( |
@@ -377,7 +378,7 @@ addClassToCodeLines() | |||
377 | /** | 378 | /** |
378 | * completeForCodeBlock. | 379 | * completeForCodeBlock. |
379 | * | 380 | * |
380 | * @param {Object} change -- codemirror change object | 381 | * @param {Object} change - codemirror change object |
381 | */ | 382 | */ |
382 | const completeForCodeBlock = change => { | 383 | const completeForCodeBlock = change => { |
383 | const line = change.to.line | 384 | const line = change.to.line |
@@ -436,8 +437,8 @@ const completeForCodeBlock = change => { | |||
436 | /** | 437 | /** |
437 | * menuForEditor. | 438 | * menuForEditor. |
438 | * | 439 | * |
439 | * @param {Event} event -- Event for context menu | 440 | * @param {Event} event - Event for context menu |
440 | * @param {HTMLElement} menu -- menu of dumbymap | 441 | * @param {HTMLElement} menu - menu of dumbymap |
441 | */ | 442 | */ |
442 | const menuForEditor = (event, menu) => { | 443 | const menuForEditor = (event, menu) => { |
443 | event.preventDefault() | 444 | event.preventDefault() |
@@ -583,7 +584,7 @@ const insideCodeblockForMap = anchor => { | |||
583 | /** | 584 | /** |
584 | * getLineWithRenderer. Get Renderer by cursor position in code block {{{ | 585 | * getLineWithRenderer. Get Renderer by cursor position in code block {{{ |
585 | * | 586 | * |
586 | * @param {Object} anchor -- Codemirror Anchor Object | 587 | * @param {Object} anchor - Codemirror Anchor Object |
587 | */ | 588 | */ |
588 | const getLineWithRenderer = anchor => { | 589 | const getLineWithRenderer = anchor => { |
589 | const currentLine = anchor.line | 590 | const currentLine = anchor.line |
@@ -686,7 +687,7 @@ const getSuggestionsFromAliases = option => | |||
686 | /** | 687 | /** |
687 | * handleTypingInCodeBlock. Handler for map codeblock {{{ | 688 | * handleTypingInCodeBlock. Handler for map codeblock {{{ |
688 | * | 689 | * |
689 | * @param {Object} anchor -- Codemirror Anchor Object | 690 | * @param {Object} anchor - Codemirror Anchor Object |
690 | */ | 691 | */ |
691 | const handleTypingInCodeBlock = anchor => { | 692 | const handleTypingInCodeBlock = anchor => { |
692 | const text = cm.getLine(anchor.line) | 693 | const text = cm.getLine(anchor.line) |
@@ -703,7 +704,7 @@ const handleTypingInCodeBlock = anchor => { | |||
703 | /** | 704 | /** |
704 | * getSuggestions. Get suggestions by current input {{{ | 705 | * getSuggestions. Get suggestions by current input {{{ |
705 | * | 706 | * |
706 | * @param {Object} anchor -- Codemirror Anchor Object | 707 | * @param {Object} anchor - Codemirror Anchor Object |
707 | */ | 708 | */ |
708 | const getSuggestions = anchor => { | 709 | const getSuggestions = anchor => { |
709 | const text = cm.getLine(anchor.line) | 710 | const text = cm.getLine(anchor.line) |
@@ -823,7 +824,7 @@ const getSuggestions = anchor => { | |||
823 | /** | 824 | /** |
824 | * addSuggestions. Show element about suggestions {{{ | 825 | * addSuggestions. Show element about suggestions {{{ |
825 | * | 826 | * |
826 | * @param {Object} anchor -- Codemirror Anchor Object | 827 | * @param {Object} anchor - Codemirror Anchor Object |
827 | * @param {Suggestion[]} suggestions | 828 | * @param {Suggestion[]} suggestions |
828 | */ | 829 | */ |
829 | const addSuggestions = (anchor, suggestions) => { | 830 | const addSuggestions = (anchor, suggestions) => { |
@@ -1102,6 +1103,8 @@ dumbyContainer.onmousedown = (e) => { | |||
1102 | lineEnd.style.left = event.clientX + 'px' | 1103 | lineEnd.style.left = event.clientX + 'px' |
1103 | lineEnd.style.top = event.clientY + 'px' | 1104 | lineEnd.style.top = event.clientY + 'px' |
1104 | line.position() | 1105 | line.position() |
1106 | |||
1107 | // TODO Scroll dumbymap.htmlHolder when cursor is at upper/lower side | ||
1105 | } | 1108 | } |
1106 | 1109 | ||
1107 | context.classList.add('dragging-geolink') | 1110 | context.classList.add('dragging-geolink') |