slate-md-shortcuts

1.0.0 • Public • Published

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.

Shortcut Expanded to
Cmd + b Bold
Cmd + i Emphasis
Cmd + k Url
Cmd + Shift + K Image
Cmd + / Inline code
Cmd + Shift + E Strike

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.

Readme

Keywords

none

Package Sidebar

Install

npm i slate-md-shortcuts

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

5.24 kB

Total Files

3

Last publish

Collaborators

  • virk