diff --git a/packages/lexical-playground/src/nodes/EquationNode.tsx b/packages/lexical-playground/src/nodes/EquationNode.tsx index c32aa5bea3c..62937571e25 100644 --- a/packages/lexical-playground/src/nodes/EquationNode.tsx +++ b/packages/lexical-playground/src/nodes/EquationNode.tsx @@ -144,6 +144,10 @@ export class EquationNode extends DecoratorNode { writable.__equation = equation; } + isInline(): boolean { + return this.__inline; + } + decorate(): JSX.Element { return ( { - const [, equation] = match; - const equationNode = $createEquationNode(equation, true); + const fullMatch = match[0]; + const blockEq = match[1]; + const inlineEq = match[2]; + + // If the equation has $$ it's a block equation + const isBlock = fullMatch.startsWith('$$') && fullMatch.endsWith('$$'); + const equation = isBlock ? blockEq : inlineEq; + + if (!equation) { + return; + } + + const equationNode = $createEquationNode(equation.trim(), !isBlock); textNode.replace(equationNode); }, trigger: '$',