-
Hi, first of all thanks for this repo and all the plugins, it's been really really helpful! IssueSo about my issue: I'm currently working on using a slate rich text formatting with HTML on an element that only had text inside it before. The initial value is Am I missing something during the serialization/deserialization process which would prevent this issue or is this a bug? Any help would be really appreciated. 🙏 More details from investigationI see that when I pass the initial value, it's serialized as <div>Deserialized paragraph here.</div><blockquote>blockquote</blockquote> This works ok and I can edit the value and add any other elements, e.g. another blockquote. But when I save this deserialized string to database and use it as initial value when opening the editor again, right when I click into the editor the value is changed to: <div>Deserialized paragraph here.<blockquote class="slate-blockquote">Blockquote</blockquote></div> so now the div is wrapping the whole element. And it seems this results in the issue, where if you change anything in the input, it will remove the blockquote, as seen on the video below. slate-element-removed-onchange.mov |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Any news on this, please? Maybe there's some quick workaround for this? Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
There is indeed a div wrapping all the blocks, as you can see in the console of this sandbox. Can you try to reproduce in it? |
Beta Was this translation helpful? Give feedback.
-
Thank you for the answer, @zbeyens! 🙏 I've tried to reproduce the issue in the sandbox from your previous message (I've just removed the other initial values in that sandbox), in that one it crashed (attaching a video), here's a link to the fork. In the sandbox mentioned in the original issue description, it doesn't crash, but still removes the blockquote. The main issue for us here is not that it wraps the whole value thing into a div, but that it changes the actual structure, which then results in removal of blockquote. slate-plugins-reproduce.mov |
Beta Was this translation helpful? Give feedback.
-
Here is the problem: the These are the default rules for paragraph. |
Beta Was this translation helpful? Give feedback.
Here is the problem: the
div
element is not deserialized as a paragraph but as a leaf (text), you can see that it works forp
instead. The reason behind that isdiv
is too much generic and we don't want to create a paragraph for adiv
that can just be a "wrapper". The workaround is to usep
ordiv
+ optionp.deserialize
to add a custom class name to the deserializer rules.These are the default rules for paragraph.