slate-js-top-level-nodes-limiter

1.0.1 • Public • Published

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

/slate-js-top-level-nodes-limiter/

    Package Sidebar

    Install

    npm i slate-js-top-level-nodes-limiter

    Weekly Downloads

    2

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    2.34 kB

    Total Files

    3

    Last publish

    Collaborators

    • shakil_ahmed