-
Hi, I want to create a wysiwyg editor in order to send mails message to a server. I've seen that Here is a simple example of what I am trying to achieve, look at the ...
const Editor = () => {
...
const [value, setValue] = useState()
const onSave = async () => {
// Is it supported by default by Slate-plugins ?
const serializedHTMLData = serializeHTML(value)
await saveMessage({ messageContent: serializedHTMLData })
}
return (
<Slate
editor={editor}
value={value}
onChange={(newValue) => {
setValue(newValue as SlateDocument)
}}>
<Toolbar />
<EditablePlugins
plugins={plugins}
decorate={decorate}
onKeyDown={onKeyDown}
placeholder={placeholder}
/>
<button onClick={onSave}>Save</button>
)
} |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
You can read the code in this sandbox, it uses |
Beta Was this translation helpful? Give feedback.
-
Thx for your fast answer 🔥 However the <div class="slate-align-center">
<div>test</div>
</div> So other email clients will not be able to read styles from that content, I would expect serialisation to add inline-style. <div style="text-align: center;">
<div>test</div>
</div> Also we could keep both class and styles, if needed. <div class="slate-align-center" style="text-align: center;">
<div>test</div>
</div> Is it something I need to configure on my own code, or do you plan to support it ? |
Beta Was this translation helpful? Give feedback.
-
See #305 for custom serialization. |
Beta Was this translation helpful? Give feedback.
-
Any simple example to deserialize data tha stored in database? |
Beta Was this translation helpful? Give feedback.
You can read the code in this sandbox, it uses
serializeHTMLFromNodes
anddeserializeHTMLToDocumentFragment
.