diff options
Diffstat (limited to 'src/dumbymap.mjs')
-rw-r--r-- | src/dumbymap.mjs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 0c6f0be..744d216 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -21,6 +21,12 @@ const layouts = [ | |||
21 | ] | 21 | ] |
22 | const mapCache = {} | 22 | const mapCache = {} |
23 | 23 | ||
24 | /** | ||
25 | * markdown2HTML. | ||
26 | * | ||
27 | * @param {HTMLElement} container -- Target Element to include generated HTML contents | ||
28 | * @param {String} mdContent -- Texts in Markdown | ||
29 | */ | ||
24 | export const markdown2HTML = (container, mdContent) => { | 30 | export const markdown2HTML = (container, mdContent) => { |
25 | // Render: Markdown -> HTML {{{ | 31 | // Render: Markdown -> HTML {{{ |
26 | container.replaceChildren() | 32 | container.replaceChildren() |
@@ -83,7 +89,7 @@ export const markdown2HTML = (container, mdContent) => { | |||
83 | state.tokens.push(new state.Token('dumby_block_close', '', -1)) | 89 | state.tokens.push(new state.Token('dumby_block_close', '', -1)) |
84 | }) | 90 | }) |
85 | 91 | ||
86 | const contentWithToc = '${toc}\n\n\n' + mdContent // eslint-disable-line | 92 | const contentWithToc = '${toc}\n\n\n' + mdContent |
87 | htmlHolder.innerHTML = md.render(contentWithToc) | 93 | htmlHolder.innerHTML = md.render(contentWithToc) |
88 | 94 | ||
89 | // TODO Do this in markdown-it | 95 | // TODO Do this in markdown-it |
@@ -96,6 +102,13 @@ export const markdown2HTML = (container, mdContent) => { | |||
96 | return container | 102 | return container |
97 | // }}} | 103 | // }}} |
98 | } | 104 | } |
105 | |||
106 | /** | ||
107 | * generateMaps. | ||
108 | * | ||
109 | * @param {HTMLElement} container -- Target Element contains HTML contents | ||
110 | * @param {Object} dumbymap -- Include and Elements and Methods about managing contents | ||
111 | */ | ||
99 | export const generateMaps = (container, { delay, mapCallback }) => { | 112 | export const generateMaps = (container, { delay, mapCallback }) => { |
100 | container.classList.add('Dumby') | 113 | container.classList.add('Dumby') |
101 | container.removeAttribute('data-layout') | 114 | container.removeAttribute('data-layout') |
@@ -159,7 +172,7 @@ export const generateMaps = (container, { delay, mapCallback }) => { | |||
159 | const isAnchorPointedBy = link => anchor => { | 172 | const isAnchorPointedBy = link => anchor => { |
160 | const mapContainer = anchor.closest('.mapclay') | 173 | const mapContainer = anchor.closest('.mapclay') |
161 | const isTarget = !link.targets || link.targets.includes(mapContainer.id) | 174 | const isTarget = !link.targets || link.targets.includes(mapContainer.id) |
162 | return anchor.title === link.url.pathname && isTarget | 175 | return anchor.title === link.url.searchParams.get('text') && isTarget |
163 | } | 176 | } |
164 | 177 | ||
165 | const isAnchorVisible = anchor => { | 178 | const isAnchorVisible = anchor => { |
@@ -366,7 +379,7 @@ export const generateMaps = (container, { delay, mapCallback }) => { | |||
366 | mapCallback?.call(this, mapElement) | 379 | mapCallback?.call(this, mapElement) |
367 | const markers = geoLinks | 380 | const markers = geoLinks |
368 | .filter(link => !link.targets || link.targets.includes(mapElement.id)) | 381 | .filter(link => !link.targets || link.targets.includes(mapElement.id)) |
369 | .map(link => ({ xy: link.xy, title: link.url.pathname })) | 382 | .map(link => ({ xy: link.xy, title: link.url.searchParams.get('text') })) |
370 | 383 | ||
371 | // FIXME Here may cause error | 384 | // FIXME Here may cause error |
372 | // Add markers with Geolinks | 385 | // Add markers with Geolinks |