0.2.0 • Published 7 years ago

slate-mark-hotkeys v0.2.0

Weekly downloads
288
License
MIT
Repository
github
Last release
7 years ago

slate-mark-hotkeys

A Slate plugin to toggle marks based on hotkeys. Useful for adding basic formatting utils like making text bold, italicized, or underlined (through the conventional means of modifier+b, modifier+i, modifier+u, respectively).

View Demo ⬈

import MarkHotkeys from 'slate-mark-hotkeys';
import { Editor } from 'slate-react';

// Add the plugin to your set of plugins...
const plugins = [
  MarkHotkeys()
]

// And later pass it into the Slate editor...
<Editor
  ...
  plugins={plugins}
/>
OptionTypeDescription
keysToMarksObjectAn optional object whose keys are hotkey descriptors and whose respective values are the marks to be applied when the hotkey is triggered. Keys without a + in them are automatically prepended with mod+, but those with an + are not modified. They are all passed to isHotkey, which has its own API for defining hotkeys. Defaults to a map containing marks for bold, underline, italics, strikethrough, and code.
ignoreInFunction Array StringAn optional block matcher to ignore triggers inside. If passed an array or string it will match by node.type.
onlyInFunction Array StringAn optional block matcher to only replace triggers inside. If passed an array or string it will match by node.type.