Docs
Serializing Markdown
Serializing Markdown
Copy paste from Markdown to Slate.
Loading...
Installation
npm install @udecode/plate-markdown
Usage
Markdown to Slate
import { MarkdownPlugin } from '@udecode/plate-markdown';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
MarkdownPlugin,
],
});
const value = editor.api.markdown.deserialize('**Hello world!**');
Loading...
Slate to Markdown
Currently supported plugins: paragraph, link, list, heading, italic, bold and code.
const editor = createPlateEditor({
value,
plugins: [
// ...otherPlugins,
MarkdownPlugin,
],
});
const content = editor.api.markdown.serialize();
Plugins
MarkdownPlugin
Options
Collapse all
Object where each key is a Markdown syntax element type and the value is a transformation function.
Object where each key is a Markdown syntax text type and the value is an object providing optional mark and transform functions.
API
editor.api.markdown.deserialize
Converts a Markdown string to a Slate value.
Parameters
Collapse all
The Markdown string to be deserialized.
Returns
Collapse all
An array of Slate nodes representing the deserialized Markdown content.
editor.api.markdown.serialize
Converts the current Slate value to a Markdown string.
Parameters
Collapse all
Returns
Collapse all
A Markdown string representing the serialized Slate content.