Use module build of markmap-lib

If we use the default import then webpack will use the "browser"
bundle which relies on CDN lazy loading of dependencies.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-04-15 22:04:04 +02:00
parent 64fe7233e7
commit bfcb617eeb
4 changed files with 17 additions and 25 deletions

View file

@ -1,26 +1,15 @@
/*
SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: AGPL-3.0-only
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { loadCSS, loadJS } from 'markmap-common'
import { Transformer } from 'markmap-lib'
import { Transformer } from 'markmap-lib/dist/index.esm'
import { Markmap } from 'markmap-view'
const transformer: Transformer = new Transformer()
export const markmapLoader = (svg: SVGSVGElement, code: string): void => {
const { root, features } = transformer.transform(code)
const { styles, scripts } = transformer.getUsedAssets(features)
if (styles) {
loadCSS(styles)
}
if (scripts) {
loadJS(scripts)
.catch(console.log)
}
const { root } = transformer.transform(code)
Markmap.create(svg, {}, root)
}