slate-md-shortcuts
v1.0.0
Published
Markdown shortcuts for slate.js
Downloads
6
Readme
Slate md shortcuts
Markdown shortcuts for slate.js
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.