diff options
Diffstat (limited to 'src/dumbymap.mjs')
-rw-r--r-- | src/dumbymap.mjs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index e1bf220..512409b 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -2,13 +2,13 @@ import MarkdownIt from 'markdown-it' | |||
2 | import MarkdownItAnchor from 'markdown-it-anchor' | 2 | import MarkdownItAnchor from 'markdown-it-anchor' |
3 | import MarkdownItFootnote from 'markdown-it-footnote' | 3 | import MarkdownItFootnote from 'markdown-it-footnote' |
4 | import MarkdownItFrontMatter from 'markdown-it-front-matter' | 4 | import MarkdownItFrontMatter from 'markdown-it-front-matter' |
5 | import MarkdownItInjectLinenumbers from 'markdown-it-inject-linenumbers' | ||
5 | import { renderWith, defaultAliases, parseConfigsFromYaml } from 'mapclay' | 6 | import { renderWith, defaultAliases, parseConfigsFromYaml } from 'mapclay' |
6 | import { onRemove, animateRectTransition, throttle, shiftByWindow } from './utils' | 7 | import { onRemove, animateRectTransition, throttle, shiftByWindow } from './utils' |
7 | import { Layout, SideBySide, Overlay } from './Layout' | 8 | import { Layout, SideBySide, Overlay } from './Layout' |
8 | import * as utils from './dumbyUtils' | 9 | import * as utils from './dumbyUtils' |
9 | import * as menuItem from './MenuItem' | 10 | import * as menuItem from './MenuItem' |
10 | import PlainModal from 'plain-modal' | 11 | import PlainModal from 'plain-modal' |
11 | import markdownItInjectLinenumbers from 'markdown-it-inject-linenumbers' | ||
12 | 12 | ||
13 | const mapBlockSelector = 'pre:has(.language-map)' | 13 | const mapBlockSelector = 'pre:has(.language-map)' |
14 | const docLinkSelector = 'a[href^="#"][title^="=>"]' | 14 | const docLinkSelector = 'a[href^="#"][title^="=>"]' |
@@ -46,7 +46,7 @@ export const markdown2HTML = (container, mdContent) => { | |||
46 | }) | 46 | }) |
47 | .use(MarkdownItFootnote) | 47 | .use(MarkdownItFootnote) |
48 | .use(MarkdownItFrontMatter) | 48 | .use(MarkdownItFrontMatter) |
49 | .use(markdownItInjectLinenumbers) | 49 | .use(MarkdownItInjectLinenumbers) |
50 | 50 | ||
51 | // Create links with geo scheme | 51 | // Create links with geo scheme |
52 | const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/g | 52 | const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/g |
@@ -106,9 +106,10 @@ export const markdown2HTML = (container, mdContent) => { | |||
106 | * generateMaps. | 106 | * generateMaps. |
107 | * | 107 | * |
108 | * @param {HTMLElement} container -- Target Element contains HTML contents | 108 | * @param {HTMLElement} container -- Target Element contains HTML contents |
109 | * @param {Object} dumbymap -- Include and Elements and Methods about managing contents | 109 | * @param {Number} options.delay -- delay of map generation, milliseconds |
110 | * @return {Object} dumbymap -- Include and Elements and Methods about managing contents | ||
110 | */ | 111 | */ |
111 | export const generateMaps = (container, { delay, mapCallback }) => { | 112 | export const generateMaps = (container, { delay } = {}) => { |
112 | container.classList.add('Dumby') | 113 | container.classList.add('Dumby') |
113 | container.removeAttribute('data-layout') | 114 | container.removeAttribute('data-layout') |
114 | container.setAttribute('data-layout', layouts[0].name) | 115 | container.setAttribute('data-layout', layouts[0].name) |
@@ -296,9 +297,6 @@ export const generateMaps = (container, { delay, mapCallback }) => { | |||
296 | attributeOldValue: true | 297 | attributeOldValue: true |
297 | }) | 298 | }) |
298 | onRemove(mapElement, () => observer.disconnect()) | 299 | onRemove(mapElement, () => observer.disconnect()) |
299 | |||
300 | // Execute callback from caller | ||
301 | mapCallback?.call(this, mapElement) | ||
302 | } | 300 | } |
303 | 301 | ||
304 | // Set unique ID for map container | 302 | // Set unique ID for map container |