slate-edit-code
Version:
A Slate plugin to handle keyboard events in code blocks.
34 lines (22 loc) • 958 B
Markdown
# slate-edit-code
[](http://badge.fury.io/js/slate-edit-code)
[](https://travis-ci.org/SamyPesse/slate-edit-code)
A Slate plugin to handle keyboard events in code blocks.
### Install
```js
npm install slate-edit-code
```
### Features
- Pressing <kbd>Enter</kbd> insert a new line starting with the right indentation
- Pressing <kbd>Tab</kbd> insert the right indentation if selection is collapsed or indent all lines in selection
- Pressing <kbd>Delete</kbd> remove the indentation before cursor if possible
- Pressing <kbd>Command+Enter</kbd> (<kbd>Ctrl+Enter</kbd> on Windows/Linux) exits the code block
### Simple Usage
```js
import EditCode from 'slate-edit-code'
const plugins = [
EditCode()
]
```
#### Arguments
- ``[onlyIn: Function(Node)]`` — a filtering function to select code blocks.