[lexical-playground] Bug Fix: Add BLOCK_EQUATION markdown transformer for $$...$$ syntax#8435
[lexical-playground] Bug Fix: Add BLOCK_EQUATION markdown transformer for $$...$$ syntax#8435matingathani wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds proper Markdown import/export support for display (block) equations in the Lexical playground, preventing block equations from being treated as inline equations.
Changes:
- Update inline
EQUATIONtransformer export logic to only export inline equation nodes. - Add a new
BLOCK_EQUATIONtext-match transformer to import/export$$...$$as a non-inlineEquationNode. - Register
BLOCK_EQUATIONbeforeEQUATIONinPLAYGROUND_TRANSFORMERS.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| */ | ||
| import {CodeExtension} from '@lexical/code-core'; | ||
| import {buildEditorFromExtensions} from '@lexical/extension'; | ||
| import {createHeadlessEditor} from '@lexical/headless'; |
There was a problem hiding this comment.
The tests shouldn't be using createHeadlessEditor, this is a modernized suite using buildEditorFromExtensions - all the new tests in here should be using that method to construct an editor and register the shortcuts extension as well.
There was a problem hiding this comment.
This feedback hasn't been addressed yet
| }); | ||
|
|
||
| test('$convertFromMarkdownString imports $$...$$ as code format (block) when BLOCK_FORMAT precedes INLINE_FORMAT', () => { | ||
| const editor = createHeadlessEditor({ |
There was a problem hiding this comment.
switch to buildEditorFromExtensions
| }); | ||
|
|
||
| test('$convertFromMarkdownString imports $...$ as bold format (inline) when BLOCK_FORMAT fails', () => { | ||
| const editor = createHeadlessEditor({ |
There was a problem hiding this comment.
switch to buildEditorFromExtensions
d834f54 to
980f42d
Compare
|
Tests were added after the initial review in a follow-up commit (the original first push was without tests). The branch has now been rebased on Three unit tests are now in
Happy to add more cases if there are specific edge cases you want covered. |
|
Still waiting for feedback to be addressed |
Description
Currently, the
EQUATIONmarkdown transformer only handles inline equations ($...$). When a block equation using$$...$$syntax is provided, the existing transformer falsely converts it to an inline equation.This PR adds a
BLOCK_EQUATIONtransformer that:$$...$$$$...$$as a block equation node (inline: false)EQUATIONtransformer to prevent false conversionCloses #6936
Test plan
Before
Typing
$$x=1$$in the playground with markdown shortcuts enabled converts it to an inline equation.After
Typing
$$x=1$$correctly converts to a block (display) equation. Inline$...$equations continue to work as before.