A full reference for every property available inside a slate plugin
type RenderElement = (elementProps: RenderElementProps) => JSX.Element | undefined
Function for rendering elements. It should return a React element if and only if it matches the type it's supposed to handle. If the type isn't supposed to be handled by a given plugin, renderElement
should return undefinded
.
Don't add default cases and make sure there are no conflicts between any and all plugins you're using, because once a renderElement
function returns an element, no further renderElement
functions will be run.
type RenderLeaf = (leafProps: RenderLeafProps) => JSX.Element
Function for rendering leaves. Because a node can have any number of marks, all renderLeaf
functions will be called and the leaf node will often be wrapped in multiple React components.
renderLeaf
always needs to return children
, wrapped or not.
const withSomething = (editor) => {
/* modify editor object */
return editor
}
Function that wraps the slate editor
object and adds and/or modifies it's functionality. It's the same concept as the vanilla slate plugins.
type OnKeyDown = (event: KeyboardEvent, editor: Editor) => void
Function that can be used to add keyboard shortcuts and other special cases for handling keyboard events. Usage.
type Decorate = (entry: NodeEntry) => Range[]
Function for adding decorations. See these examples to learn how it works:
This section is a work in progress