HTML import/export two modes: verbose (with only inline styles) and concise (with mainly CSS classes) #7451
Unanswered
vadimkantorov
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
As I understood, currently JSON is not intended to be a very stable serialization format for Lexical content.
I'm then interested in using HTML with Lexical in two modes:
Export/import fully self-contained verbose HTML (for exchange between editors and viewing HTML in browser without specifying a stylesheet). For this regime I'd like all styles to be fully specified and duplicated inline as
style="..."for all nodes, especially for text formatting. Also this regime needs to support permissive import: Handling unknown / unregistered node types #7212 (comment) to not choke (and maybe skip unknown tags if configured) on unknown HTML nodes. So that e.g. I could export my legacy WordPress posts to HTML and being able to edit them using Lexical. Also would be interesting to be able to ingest WordPress markup: https://developer.wordpress.org/block-editor/getting-started/fundamentals/markup-representation-block/ . It contains an HTML comment opening line before WordPress block begins, and a closing one as well. These comments are preserved byDOMParser, so a recipe to have them taken into account during parsing would be cool (then probably Lexical can be used to edit WordPress documents with core blocks). Example:Rendering mode: I'd like to be able to export/import concise HTML: use CSS classes for specifying node types and for formatting styles (like heading1, heading2 etc). Then this HTML can be used for rendering, and CSS class definitions would be added separately.
It appears that https://github.com/facebook/lexical/blob/main/examples/react-rich/src/App.tsx example does something to achieve these goals. But I'm currently not fully understanding what it does (removing inline styles at export? and parsing inline styles at import?)
Maybe an extension to https://lexical.dev/docs/packages/lexical-html or https://lexical.dev/docs/concepts/serialization with discussion of export/import of two HTML modes (verbose and concise) and more comments in the react-rich example would solve my question.
Thanks!
Probably related:
{ export: ..., import: ...}in EditorConfigMy current impl of HTML export/import:
Currently its problem is that if I have an image src exported correctly as
<img src="/images/blah.jpg" ... />, but when I import it back the current host gets added (and I don't need this, as I have a custom resolver for image source paths to prepend another correct host/prefix)Beta Was this translation helpful? Give feedback.
All reactions