1.0.1 • Published 6 years ago

slate-js-top-level-nodes-limiter v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

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}
/>