# slate-sidebar

> Quick and easy way to implement sidebar in your slate editor.

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

## Install

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

## 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 | 2018-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 19.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | chilijung |
| Maintainers | chilijung |

## Links

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

## Dependencies (2)

- [styled-components](https://npm.io/package/styled-components.md) ^3.2.5
- [get-selection-range](https://npm.io/package/get-selection-range.md) ^0.1.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K 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
- 1.4.2 — 2018-09-06
- 0.3.0 — 2018-07-12
- 0.2.4 — 2018-04-16
- 0.2.3 — 2018-04-16
- 0.2.2 — 2018-04-16
- 0.2.1 — 2018-04-16
- 0.2.0 — 2018-04-16
- 0.1.0 — 2018-04-13

## README

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

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

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

## Installation

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

## Usage

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

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

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

@sidebar() // ----> Add this line and your sidebar 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 [storybook codes](https://github.com/Canner/canner-slate-editor/tree/master/stories/components/sidebar) for full implementation and demo

## Options

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

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

[Select your icons here](https://github.com/Canner/slate-editor-icons#slate-editor-icons)

There's an example

```js
const options = {
  icons: [
    {
      icon: OlList,
      title: "Order List"
    },
    {
      icon: UlList,
      title: "Unorder List"
    },
    {
      icon: Header1,
      title: "Header One"
    },
    {
      icon: Header2,
      title: "Header Two"
    }
  ],
  leftOffset: 20 // offset to left default -20
};
```

## 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-sidebar.svg
[npm-url]: https://npmjs.org/package/slate-sidebar

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