From e0c46480577678e7452073ccb2319235f91873f3 Mon Sep 17 00:00:00 2001 From: Entkenntnis Date: Thu, 15 Feb 2024 11:26:43 +0100 Subject: [PATCH] fix(math): always use static math --- .../plugins/text/components/math-element.tsx | 8 ++---- .../plugins/text/components/math-formula.tsx | 25 ------------------- 2 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 packages/editor/src/plugins/text/components/math-formula.tsx diff --git a/packages/editor/src/plugins/text/components/math-element.tsx b/packages/editor/src/plugins/text/components/math-element.tsx index 22b70f6ef8..714bf19b82 100644 --- a/packages/editor/src/plugins/text/components/math-element.tsx +++ b/packages/editor/src/plugins/text/components/math-element.tsx @@ -11,10 +11,7 @@ import { useSelected, } from 'slate-react' -/* eslint-disable import/no-unassigned-import */ -import 'katex/contrib/mhchem' - -import { MathFormula } from './math-formula' +import { StaticMath } from '../static-components/static-math' import type { MathElement as MathElementType, Paragraph, @@ -53,11 +50,10 @@ export function MathElement({ if (!shouldShowMathEditor) { return ( <> - {/* Slate void elements need to set attributes and contentEditable={false} See: https://docs.slatejs.org/api/nodes/element#rendering-void-elements */} - + {children} diff --git a/packages/editor/src/plugins/text/components/math-formula.tsx b/packages/editor/src/plugins/text/components/math-formula.tsx deleted file mode 100644 index 1a2e1a75b5..0000000000 --- a/packages/editor/src/plugins/text/components/math-formula.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import KaTeX from 'katex' -import { memo } from 'react' - -import type { MathElement } from '../types/text-editor' - -export const MathFormula = memo(function MathFormula({ - element, -}: { - element: MathElement -}) { - const html = KaTeX.renderToString( - `${element.inline ? '' : '\\displaystyle '}${element.src}`, - { - displayMode: false, - throwOnError: false, - } - ) - - return ( - - ) -})