From 0ad2cd5dc30ba8a1e07c7ccb363d230a81e4515a Mon Sep 17 00:00:00 2001 From: vantage-ola Date: Wed, 18 Dec 2024 19:43:20 +0100 Subject: [PATCH] buggy fix --- .../src/plugins/MarkdownTransformers/index.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts b/packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts index 391e8a7bdb2..01971a540ab 100644 --- a/packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts +++ b/packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts @@ -117,14 +117,17 @@ export const EQUATION: TextMatchTransformer = { if (!$isEquationNode(node)) { return null; } - - return `$${node.getEquation()}$`; + const equation = node.getEquation(); + const isInline = node.isInline(); + return isInline ? `$${equation}$` : `$$${equation}$$`; }, - importRegExp: /\$([^$]+?)\$/, - regExp: /\$([^$]+?)\$$/, + importRegExp: /\$([^$]+?)\$|\$\$([^$]+?)\$\$/, // regex issue + regExp: /\$([^$]+?)\$$|\$\$([^$]+?)\$\$$/, // regex issue replace: (textNode, match) => { - const [, equation] = match; - const equationNode = $createEquationNode(equation, true); + const [, inlineEquation, blockEquation] = match; + const equation = inlineEquation || blockEquation; + const isInline = !!inlineEquation; + const equationNode = $createEquationNode(equation, isInline); textNode.replace(equationNode); }, trigger: '$',