Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Code Block Content Corrupted After HTML Export/Reimport #7073

Open
daifuyang opened this issue Jan 21, 2025 · 1 comment
Open

Bug: Code Block Content Corrupted After HTML Export/Reimport #7073

daifuyang opened this issue Jan 21, 2025 · 1 comment

Comments

@daifuyang
Copy link

daifuyang commented Jan 21, 2025

Describe the Bug

When exporting content containing code blocks to HTML and then reinitializing the Lexical editor with that HTML, the code block content becomes misformatted or corrupted. This issue occurs consistently when using the right-click paste method to insert code.

Lexical version: ^0.16.10


Steps to Reproduce

  1. Insert a code block into the Lexical editor.
  2. Copy and paste a code snippet into the editor by right-clicking and selecting "Paste".
  3. Export the content to HTML.
  4. Reload the page and initialize the Lexical editor with the previously exported HTML.
  5. Observe that the code block content is now misformatted or corrupted.

Expected Behavior

The code block content should remain intact and properly formatted after exporting to HTML and reinitializing the Lexical editor with that HTML.


Current Behavior

The code block content becomes misformatted or corrupted after exporting to HTML and reinitializing the Lexical editor.


Code Example

stackblitz Example


Impact of Fix

  • Severity: High, as it affects the integrity of code blocks, which are a common feature in text editors.
  • Frequency: This issue occurs every time a code block is inserted via right-click paste and the content is exported/reimported.
  • Beneficiaries: All users who rely on Lexical for handling code blocks, particularly developers and technical writers.
  • Metrics: This fix would benefit a significant portion of Lexical users, especially those in technical fields who frequently work with code snippets.

Additional Context

Add any other context, screenshots, or logs about the bug here. For example:

  • Screenshots of the misformatted code block.
  • Browser and OS information (if relevant).
  • Any workarounds currently being used.
@daifuyang
Copy link
Author

Is it caused by the space of the label? Should this situation be handled by ourselves or by lexical?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant