Replies: 1 comment
-
|
The short answer is no, there is exactly one code path implemented by default for exporting html and another for importing. You can override it, but you’re in charge of making it work correctly when you do. Note that a lot of the extra stuff in the markup is to support interoperability with other applications via copy and paste, which is the primary use case for lexical’s import and export of HTML, so anything you change may degrade that functionality. The HTML export is not primarily designed for serialization or read-only display (the sorts of use cases where you might want a minimal representation). Another consideration is that the white-space: pre-wrap applied to all text nodes basically affects how the text is parsed. If you have text with contiguous spaces it may not work (or at least render) correctly without that style. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Is there a way to export minimal semantic HTML from Lexical — only formatting tags like:
<strong><em><code><blockquote><pre>...No styles, no classes, no
data-lexical-*, no extra attributes.Requirements
Issue
Using
$generateHtmlFromNodes()adds attributes (classes,data-lexical-text, etc.).Stripping them breaks re-import for some nodes.
Question
Is there an official way (or planned solution) to export pure semantic HTML while keeping re-import reliable?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions