Skip to content

victorbueno/slate-auto-exit-block

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

slate-auto-exit-block

Let's say you are working on a Word Document.

You are using an ordered list. When you hit 'Enter' twice, the editor clears the last list line and add a new paragraph. That's what this plugin does.

Installation

yarn add slate-auto-exit-block

Usage

import AutoExitBlock from 'slate-auto-exit-block'
import { Editor } from 'slate-react'

// Add the plugin to your set of plugins...
const plugins = [
  AutoExitBlock({
    blockType: /^(h{1,6})$/,
    exitBlockType: 'paragraph'
  }),
  AutoExitBlock({
    blockType: 'blockquote',
    exitBlockType: 'paragraph',
    onEmptyBlock: true
  }),
  AutoExitBlock({
    blockType: 'li',
    exitBlockType: 'paragraph',
    onEmptyBlock: true,
    unwrap: true
  })
]

// And later pass it into the Slate editor...
<Editor
  ...
  plugins={plugins}
/>

Blocks

H1-H6

Insert a new paragrah on simple Enter.

Blockquote, UL and OL

Insert a new paragraph on a double Enter if the last block is empty. Also removes this last block.

TO-DO

  • Make it work for tables and other elements.

About

Auto Exit blockquotes, ULs, OLs, Headers - just like word

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published