diff --git a/packages/mermaid/src/diagrams/pie/pieRenderer.js b/packages/mermaid/src/diagrams/pie/pieRenderer.js index ca88d58a6ed..67db0ed02e0 100644 --- a/packages/mermaid/src/diagrams/pie/pieRenderer.js +++ b/packages/mermaid/src/diagrams/pie/pieRenderer.js @@ -4,7 +4,7 @@ import { log } from '../../logger.js'; import { configureSvgSize } from '../../setupGraphViewbox.js'; import * as configApi from '../../config.js'; import { parseFontSize } from '../../utils.js'; -import { getTextWidth } from '../../rendering-util/getTextWidth.ts'; +import { getTextWidth } from '../../rendering-util/getTextWidth.js'; let conf = configApi.getConfig(); diff --git a/packages/mermaid/src/rendering-util/getTextWidth.js b/packages/mermaid/src/rendering-util/getTextWidth.js new file mode 100644 index 00000000000..f2976a852a4 --- /dev/null +++ b/packages/mermaid/src/rendering-util/getTextWidth.js @@ -0,0 +1,7 @@ +// https://stackoverflow.com/a/35373030/3469145 +const canvas = document.createElement('canvas'); +const context = canvas.getContext('2d'); + +const getTextWidth = (text) => context.measureText(text).width * window.devicePixelRatio; + +export { getTextWidth }; diff --git a/packages/mermaid/src/rendering-util/getTextWidth.ts b/packages/mermaid/src/rendering-util/getTextWidth.ts deleted file mode 100644 index da44f2a3fb3..00000000000 --- a/packages/mermaid/src/rendering-util/getTextWidth.ts +++ /dev/null @@ -1,7 +0,0 @@ -// https://stackoverflow.com/a/35373030/3469145 -const canvas = document.createElement('canvas'); -const context = canvas.getContext('2d') as CanvasRenderingContext2D; - -const getTextWidth = (text: string) => context.measureText(text).width * window.devicePixelRatio; - -export { getTextWidth };