slate-js-top-level-nodes-limiter
v1.0.1
Published
Slate.js plugin to limit the number of top level nodes in a documnet.
Downloads
5
Maintainers
Readme
slate-js-top-level-nodes-limiter
A Slate plugin to run a callback function on every change when the specified limit for the top level nodes is reached. The callback functions are provided the change
object as an argument when invoked.
import topNodesLimiter from 'slate-js-top-level-nodes-limiter'
import { Editor } from 'slate-react'
const overLimitCb = (change) => {
// do something
}
const inLimitCb = (change) => {
// do something
}
// Add the plugin to your set of plugins...
const plugins = [
topNodesLimiter({limit: 5}, overLimitCb, inLimitCb)
]
// And later pass it into the Slate editor...
<Editor
...
plugins={plugins}
/>