slate-when

A Slate plugin to restrict another plugin to a condition.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
slate-when
223410.2.04 years ago4 years agoMinified + gzip package size for slate-when in KB

Readme

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

| Option | Type | Description | | ------------ | ------------------------------------------ | -------------------------------------- | | when | Function when(value: Value) => Boolean | The constraint to check. | | plugin | Object | An instance of the plugin to contrain. |