[lexical] Fix: preserve block equations ($$) in MarkdownShortcutPlugin#8223
[lexical] Fix: preserve block equations ($$) in MarkdownShortcutPlugin#8223Jynx2004 wants to merge 19 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
There was a problem hiding this comment.
This only handles export, not import, so it's not complete.
|
See also #8194 which is probably a more complete fix but is not yet acceptable because there are no tests. |
I think having a single import for both inline as well as block case will also work fine as both have the same trigger |
|
It could possibly be implemented in one transformer or two, but either way this PR is not complete because it doesn’t have test coverage to show that import works. When you write those tests you’ll see that it probably doesn’t work as-is. |
Made some changes in the unit test to check the import works for both the cases . |
packages/lexical-playground/__tests__/unit/MarkdownTransformers.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Bob Ippolito <bob@redivi.com>
etrepum
left a comment
There was a problem hiding this comment.
What's needed to demonstrate that this PR is complete are tests to ensure that the exported markdown can be imported and the result is an EquationNode with the right setting for inline and the correct contents.
Description
Block math equations
($$...$$)created via the toolbar were incorrectly converted to inline equations($...$)when toggling markdown mode via the MarkdownShortcutPlugin.Root cause: The EQUATION transformer's export function always returned
$${equation}$(inline syntax) regardless of whether the node was a block or inline equation. There was also no transformer to import/match$$...$$patterns.Closes #6936
Test plan
Created a new test for testing this functionality .
Before
inserting a block equation and clicking the Markdown button converted
$$x^2 + y^2 = z^2$$ → $x^2 + y^2 = z^2$(inline)After
block equations are preserved as
$$x^2 + y^2 = z^2$$when toggling markdown mode