hedgedoc/src/components/markdown-renderer/replace-components/markmap/markmap-loader.ts
Tilman Vatteroth 28600d6508
Change copyright year from 2020 to 2021 ()
* Change copyright year from 2020 to 2021

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>

* Change copyright year in jetbrains copyright template

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2021-01-06 21:37:59 +01:00

25 lines
636 B
TypeScript

/*
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 { 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)
}
Markmap.create(svg, {}, root)
}