0.2.0 • Published 6 years ago

slate-when v0.2.0

Weekly downloads
412
License
MIT
Repository
github
Last release
6 years ago

slate-when

A Slate plugin that wraps another plugin to make it only trigger when the value of the editor is in a certain state.

View Demo ⬈

import SoftBreak from 'slate-soft-break'
import When from 'slate-when'
import { Editor } from 'slate-react'

const plugins = [
  When({
    when: value => value.blocks.some(b => b.type === 'code'),
    plugin: SoftBreak(),
  })
]

<Editor
  ...
  plugins={plugins}
/>
OptionTypeDescription
whenFunction when(value: Value) => BooleanThe constraint to check.
pluginObjectAn instance of the plugin to contrain.