# slate-toolbar

> Quick and easy way to implement medium like toolbar in you slate editor

Latest version **1.5.0** (published 2018-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install slate-toolbar
pnpm add slate-toolbar
yarn add slate-toolbar
bun add slate-toolbar
```

## 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 | 1.5.0 |
| Published | 2018-09-07 |
| First published | 2016-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | chilijung |
| Maintainers | chilijung |
| Keywords | slate, toolbar, plugins |

## Links

- npm: https://www.npmjs.com/package/slate-toolbar
- Repository: https://github.com/Canner/slate-toolbar
- Homepage: http:
- npm.io page: https://npm.io/package/slate-toolbar

## Dependencies (8)

- [is-hotkey](https://npm.io/package/is-hotkey.md) ^0.1.2
- [styled-components](https://npm.io/package/styled-components.md) ^3.2.3
- [get-selection-range](https://npm.io/package/get-selection-range.md) ^0.1.0
- [@canner/slate-icon-bold](https://npm.io/package/@canner/slate-icon-bold.md) ^1.5.0
- [@canner/slate-icon-italic](https://npm.io/package/@canner/slate-icon-italic.md) ^1.5.0
- [@canner/slate-icon-shared](https://npm.io/package/@canner/slate-icon-shared.md) ^1.5.0
- [@canner/slate-icon-underline](https://npm.io/package/@canner/slate-icon-underline.md) ^1.5.0
- [react-window-detect-dimensions](https://npm.io/package/react-window-detect-dimensions.md) ^0.2.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.5.0 (latest) — 2018-09-07
- 1.4.4 — 2018-09-06
- 1.4.3 — 2018-09-06
- 1.4.3-alpha.0 — 2018-09-06
- 0.12.1 — 2018-07-12
- 0.12.0 — 2018-07-12
- 0.11.0 — 2018-04-19
- 0.10.0 — 2018-04-13
- 0.9.0 — 2018-04-10
- 0.8.0 — 2018-04-10
- 0.7.3 — 2018-03-29
- 0.7.2 — 2018-03-23
- 0.7.1 — 2018-03-20
- 0.7.0 — 2018-03-20
- 0.6.4 — 2017-01-16
- … 15 more at https://npm.io/package/slate-toolbar/versions

## README

# slate-toolbar [![NPM version][npm-image]][npm-url]

> Quick and easy way to implement medium like toolbar in your [slate editor](https://docs.slatejs.org)

![demo](https://github.com/Canner/canner-slate-editor/blob/master/preview/toolbar-demo.gif?raw=true)

## Installation

```sh
$ npm install --save slate-toolbar
```

## Usage

`slate-toolbar` is the easiest way to implement a medium-like toolbar in your slate editor.

Just add a decorator `@toolbar()` on you editor component. The parent component of this component must pass two props `value: Value` and `onChange: (change: Change) => void`.

```js
import toolbar from "slate-toolbar";

@toolbar() // ----> Add this line and your toolbar is implemented in your editor
class EditorContainer extends React.Component<Props> {
  // On change, update the app's React state with the new editor state.
  render() {
    return (
      <div className="editor">
        <Editor {...this.props} />
      </div>
    );
  }
}

class App extends React.Component<{}, { value: Value }> {
  // Set the initial state when the app is first constructed.
  state = {
    value: initialValue
  };

  render() {
    return (
      <div className="container markdown-body">
        <EditorContainer
          value={this.state.value}
          onChange={({ value }) => this.setState({ value })}
          plugins={plugins}
        />
      </div>
    );
  }
}
```

see [codes](https://github.com/Canner/canner-slate-editor/tree/master/stories/components/toolbar) for full implementation and demo

## Options

`slate-toolbar` is fully customizable, so it allows you to pass options to setup items you want to implement in your toolbar.

**NOTE: Remember to add certain plugin to your editor's plugins**

[Select your icons here](https://github.com/Canner/canner-slate-editor/tree/master/packages/slate-icons)

There's an example

```js
const options = {
  // default icons are Bold, Undo, Italic
  icons: [
    Undo, // ----> this must be one of icon in https://github.com/Canner/slate-editor-icons#icon-packages
    Bold,
    Italic,
    Underline,
    Code,
    StrikeThrough,
    Clean,
    "divider", // ---> insert a divider to seperate icons
    AlignCenter,
    AlignLeft,
    AlignRight
  ],

  // position, where toolbar should show up.
  position: "bottom" | "top",

  // disabled in block types in the list
  disabledTypes: ["code_block", "code_line", "header_one", "header_two"]
};
```

## Start example server

```
npm start
```

<a href="https://canner.io">
  <img src="https://user-images.githubusercontent.com/26116324/37811196-a437d930-2e93-11e8-97d8-0653ace2a46d.png"/>
</a>

[npm-image]: https://badge.fury.io/js/slate-toolbar.svg
[npm-url]: https://npmjs.org/package/slate-toolbar

---
_Source: https://npm.io/package/slate-toolbar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
