-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: Custom HTML serialization config for createEditor
doesn't work
#5262
Comments
This is more the case - nested editors weren't top of mind when this was written, iirc. Agree that this could and should be more ergonomic.
This is definitely a bug - let me see if I can repro locally. |
You'll need this, plus pass in initialNodes like this:
|
@acywatson , is it correct that @GRA0007's component is also not compatible with the yjs collab plugin? We've so far failed to sync nested composer's state with the collab plugin :-( |
Yea the current CollabPlugin frankly does not have great support for nested editors. |
Unfortunate for sure! But I understand your priorities lie with what's crucial to facebook 👍 We'll wait for this to hopefully be resolved one day and look for an alternative in the time being. |
I think generally this problem is fixed, or never really existed in the first place, at least as stated in the title (Custom HTML serialization for Regarding other requests (e.g. a version of |
I'm trying to implement a simple image
DecoratorNode
that has acaption
property which supports rich text (just bold, italics and links), and I'm using theLexicalNestedComposer
component from@lexical/react
inside myDecoratorNode
to create this caption editor.My editor needs to export HTML for this image in the following format:
Importantly, I'm also using the new HTML serialization overrides in the editor config introduced in version 0.12.3/0.12.4, in order to remove
span
elements from text nodes and<i>
elements from italic text etc.My first issue, is that there doesn't seem to be a nice way to serialize nested editors to HTML. My current implementation looks something like this:
Note that in the
exportDOM
function above, I have to re-parse the output of$generateHtmlFromNodes
because this function doesn't provide a way of getting the output as an element/fragment. This is my first issue, but workaround-able.The second issue, is that the
createEditor
function I'm using in myconstructor
, doesn't seem to use the config I pass to it at all. For simplicity, this is essentially the config I'm using:From this, the output I would expect would be something like
Rich <em>caption</em> here
, but what I actually end up with is<span style="white-space: pre-wrap;">Rich </span><i><em class="italic" style="white-space: pre-wrap;">caption</em></i><span style="white-space: pre-wrap;"> here</span>
, and that's after manually removing the surroundingp
tag by specifically selecting the children like so in myexportDOM
function above:dom.body.firstChild?.childNodes
.It feels like there should be a better way of doing this. I've noticed that DecoratorNodes cannot have children, should I be using a different type of node to make my
ImageNode
? Or has the use case of actually exporting the nested editors not yet been explored? It certainly doesn't feel very ergonomic in its current form.Lexical version:
0.12.4
Sandbox
https://codesandbox.io/s/lexical-nested-editor-export-repro-zmk4gz
Please try pressing the
Export DOM
button in the sandbox above and note that the caption is not properly transformed like the text outside the nested editor.The text was updated successfully, but these errors were encountered: