mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-03-15 04:21:58 +00: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
|
@ -176,6 +176,7 @@
|
|||
"webpack-bundle-analyzer": "4.4.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"cypress": "7.1.0"
|
||||
"cypress": "7.1.0",
|
||||
"katex": "0.13.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
9
src/external-types/markmap-lib/index.d.ts
vendored
Normal file
9
src/external-types/markmap-lib/index.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
declare module 'markmap-lib/dist/index.esm' {
|
||||
export * from 'markmap-lib'
|
||||
}
|
|
@ -9053,20 +9053,13 @@ jsprim@^1.2.2:
|
|||
array-includes "^3.1.2"
|
||||
object.assign "^4.1.2"
|
||||
|
||||
katex@0.13.2:
|
||||
katex@0.13.2, katex@^0.12.0:
|
||||
version "0.13.2"
|
||||
resolved "https://registry.yarnpkg.com/katex/-/katex-0.13.2.tgz#4075b9144e6af992ec9a4b772fa3754763be5f26"
|
||||
integrity sha512-u/KhjFDhyPr+70aiBn9SL/9w/QlLagIXBi2NZSbNnBUp2tR8dCjQplyEMkEzniem5gOeSCBjlBUg4VaiWs1JJg==
|
||||
dependencies:
|
||||
commander "^6.0.0"
|
||||
|
||||
katex@^0.12.0:
|
||||
version "0.12.0"
|
||||
resolved "https://registry.yarnpkg.com/katex/-/katex-0.12.0.tgz#2fb1c665dbd2b043edcf8a1f5c555f46beaa0cb9"
|
||||
integrity sha512-y+8btoc/CK70XqcHqjxiGWBOeIL8upbS0peTPXTvgrh21n1RiWWcIpSWM+4uXq+IAgNh9YYQWdc7LVDPDAEEAg==
|
||||
dependencies:
|
||||
commander "^2.19.0"
|
||||
|
||||
khroma@^1.1.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/khroma/-/khroma-1.3.0.tgz#1a0238ffcce1b049b8c733d5b07850a379aca04a"
|
||||
|
|
Loading…
Reference in a new issue