1.0.0 • Published 7 years ago

slate-md-shortcuts v1.0.0

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

Slate md shortcuts

Markdown shortcuts for slate.js

npm-image

This repo will insert markdown syntax for certain inline decorations like bold, emphasis, strike, image ,url and inlineCode.

Installation

Install it from npm.

npm i slate-md-shortcuts

# yarn
yarn add slate-md-shortcuts

Usage

This is not a standard Slate.js plugin, but instead a generic module you can use inside the keydown handler.

import shortcuts from 'slate-md-shortcuts'

class App extends React.Component {
  onKeyDown = (event, change) => {
    const handled = shortcuts.handle(event, change)

    if (!handled) {
      // key was not a markdown shortcut
    }
  }

  render() {
    return <Editor
        value={ this.state.value }
        onChange={ this.onChange }
        onKeyDown={ this.onKeyDown }
      />
  }
}

Shortcuts

This only adds shortcuts for inline decorations and not for blocks.

ShortcutExpanded to
Cmd + bBold
Cmd + iEmphasis
Cmd + kUrl
Cmd + Shift + KImage
Cmd + /Inline code
Cmd + Shift + EStrike

Contributing

Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Authors & License

thetutlage and contributors.

MIT License, see the included MIT file.