Skip to content

Bug: Indent lost when switching to Markdown #7820

@lytion

Description

@lytion

Lexical version: 0.35.0 (latest version)

Steps To Reproduce

  1. Go to Lexical playground https://playground.lexical.dev
  2. Type something in the editor
  3. Click on indent button
  4. Click on Markdown button to switch into Markdown code block (which I call Markdown view)
  5. Notice indent is missing
  6. Click again on Markdown button
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions