slate-mark-hotkeys

0.2.0 • Public • Published

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}
/>
Option Type Description
keysToMarks Object An 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.
ignoreIn Function Array String An optional block matcher to ignore triggers inside. If passed an array or string it will match by node.type.
onlyIn Function Array String An optional block matcher to only replace triggers inside. If passed an array or string it will match by node.type.

/slate-mark-hotkeys/

    Package Sidebar

    Install

    npm i slate-mark-hotkeys

    Weekly Downloads

    1,057

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    243 kB

    Total Files

    6

    Last publish

    Collaborators

    • davidchang