mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
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:
parent
64fe7233e7
commit
bfcb617eeb
4 changed files with 17 additions and 25 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue