# draft-js-block-breakout-plugin

> Break out of block types as you type.

Latest version **2.0.1** (published 2017-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install draft-js-block-breakout-plugin
pnpm add draft-js-block-breakout-plugin
yarn add draft-js-block-breakout-plugin
bun add draft-js-block-breakout-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2017-06-18 |
| First published | 2016-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 40 |
| Maintainers | icelab |
| Keywords | draft-js, draft-js-plugins, plugins, plugin |

## Links

- npm: https://www.npmjs.com/package/draft-js-block-breakout-plugin
- Repository: https://github.com/icelab/draft-js-block-breakout-plugin
- Issues: https://github.com/icelab/draft-js-block-breakout-plugin/issues
- npm.io page: https://npm.io/package/draft-js-block-breakout-plugin

## Dependencies (1)

- [immutable](https://npm.io/package/immutable.md) ~3.7.4

## Recent versions

- 2.0.1 (latest) — 2017-06-18
- 2.0.0 — 2017-06-18
- 1.0.3 — 2017-04-20
- 1.0.2 — 2017-02-15
- 1.0.1 — 2016-12-16
- 1.0.0 — 2016-12-04
- 0.0.2 — 2016-06-08
- 0.0.1 — 2016-06-08

## README

# Draft.js Block Breakout plugin

*This is a plugin for the [`draft-js-plugins-editor`](https://www.draft-js-plugins.com/), a plugin system that sits on top of Draft.js.*

By default draft carries the current block type over to the next line when you press return, which is an undesired behaviour for _some_ of the default block types (headers mostly).

This plugin adds behaviour to the editor to "break out" of certain block types if the user presses `return` at the start or end of the block. Where "break out" means changing the inserted block to the default type (usually `unstyled`)

## Usage

```js
import createBlockBreakoutPlugin from 'draft-js-block-breakout-plugin'
const blockBreakoutPlugin = createBlockBreakoutPlugin()
```

This can then be passed into a `draft-js-plugins-editor` component:

```js
import createBlockBreakoutPlugin from 'draft-js-block-breakout-plugin'
const blockBreakoutPlugin = createBlockBreakoutPlugin()
import Editor from 'draft-js-plugins-editor'

const plugins = [blockBreakoutPlugin]

<Editor plugins={plugins} />
```

## Options

You can pass options to the plugin as you call it:

```js
const options = {
  breakoutBlockType: 'unordered-list-item',
  breakoutBlocks: ['header-one', 'header-two']
}
const blockBreakoutPlugin = createBlockBreakoutPlugin(options)
```

The options and their defaults are:

| Option | Type | Description | Default |
| --- | --- | --- | --- |
| `breakoutBlockType` | `String` | Block type to insert when breaking out | `'unstyled'`
| `breakoutBlocks` | `Array` | List of block types to break out from | `['header-one', 'header-two', 'header-three', 'header-four', 'header-five', 'header-six']`
| `doubleBreakoutBlocks` | `Array` | List of block types to that require return on a blank line in order to break | `['blockquote', 'unordered-list-item', 'ordered-list-item', 'code-block']`

## Developing

```
npm install
npm run test
```

---
_Source: https://npm.io/package/draft-js-block-breakout-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
