-
Couldn't load subscription status.
- Fork 2k
Description
Lexical version: 0.35.0 (latest version)
Steps To Reproduce
- Go to Lexical playground https://playground.lexical.dev
- Type something in the editor
- Click on indent button
- Click on Markdown button to switch into Markdown code block (which I call Markdown view)
- Notice indent is missing
- Click again on Markdown button
- Indent has been lost
The current behavior
Indent is lost when switching from default view to Markdown.
The expected behavior
Switching to Markdown view should not alter text. Indent should be kept when switching between Markdown and default view.
Impact of fix
I would say it's an important issue because there's data loss.
Observation
This issue doesn't happen when adding an indent while in Markdown view, the reason is a tab node is created and this one is kept when switching view mode.
By looking at the code I see that's because $handleMultilineIndent from CodeHighlightPrism.ts is called.
I think we should be able to fix this issue by reproducing the same behavior as this function or at least creating a tab node when calling INDENT_CONTENT_COMMAND.
I can do a PR but I didn't found how commands are working yet, if anyone can explain I'll be glad to do it.