# hh-slate-editor

> Slate Editor customized by Hahow

Latest version **1.1.0** (published 2019-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install hh-slate-editor
pnpm add hh-slate-editor
yarn add hh-slate-editor
bun add hh-slate-editor
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-05-27 |
| First published | 2019-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=6 |
| Dependencies | 13 |
| Unpacked size | 11.2 MB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | barry800414 |
| Maintainers | barry800414 |

## Links

- npm: https://www.npmjs.com/package/hh-slate-editor
- Repository: https://github.com/hahow/hh-slate-editor
- Homepage: https://github.com/hahow/hh-slate-editor#readme
- Issues: https://github.com/hahow/hh-slate-editor/issues
- npm.io page: https://npm.io/package/hh-slate-editor

## Dependencies (13)

- [slate](https://npm.io/package/slate.md) ^0.44.9
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [bootstrap](https://npm.io/package/bootstrap.md) 3.3.7
- [immutable](https://npm.io/package/immutable.md) ^4.0.0-rc.12
- [is-hotkey](https://npm.io/package/is-hotkey.md) ^0.1.4
- [ismobilejs](https://npm.io/package/ismobilejs.md) ^0.5.1
- [rc-tooltip](https://npm.io/package/rc-tooltip.md) ^3.7.3
- [slate-react](https://npm.io/package/slate-react.md) https://github.com/hahow/slate/releases/download/slate-react%400.21.14/slate-react-0.21.14.tgz
- [font-awesome](https://npm.io/package/font-awesome.md) ^4.7.0
- [slate-soft-break](https://npm.io/package/slate-soft-break.md) ^0.9.0
- [react-fontawesome](https://npm.io/package/react-fontawesome.md) ^1.6.1
- [slate-html-serializer](https://npm.io/package/slate-html-serializer.md) ^0.7.33
- [react-responsive-modal](https://npm.io/package/react-responsive-modal.md) ^3.5.1

## Recent versions

- 1.1.0 (latest) — 2019-05-27
- 1.0.3 — 2019-05-27
- 1.0.2 — 2019-05-27
- 1.0.1 — 2019-05-27
- 1.0.0 — 2019-05-27

## README

# hh-slate-editor

> Slate Editor customized by Hahow

## Install
找 release 裡面的檔案，複製網址。例如：

```bash
npm install --save https://github.com/hahow/hh-slate-editor/releases/download/1.0.1/hh-slate-editor-1.0.1.tgz
```
or
```bash
yarn add https://github.com/hahow/hh-slate-editor/releases/download/1.0.1/hh-slate-editor-1.0.1.tgz
```

## ScreenShot
![](https://i.imgur.com/jSPRnb9.png)

## Usage

### Example
```jsx
import React, { Component } from 'react';

import SlateEditor from 'hh-slate-editor';

class Demo extends Component {
  constructor (props) {
    super(props);
    this.state = {
      value,
    };
  }

  onChange = (newValue) => {
    this.setState({
      value: newValue,
    });
  }

  uploadImage = (file, fulfilledCallback) => {
    // You need to implement the function to upload image
  }

  onWarning = (msg) => {
  }

  render () {
    return (
      <SlateEditor
        value={value}
        onChange={this.onChange}
        debounceTime={250}
        height={350}
        debugMode={false}
        uploadImage={this.uploadImage}
        onWarning={this.onWarning}
        normalizeValue={false}
        normalizePastedValue={false}
        errorMessage=""
      />
    );
  }
}
```

### Props Explanation
| prop | type | explanation | default value |
|---|---|---|---|
| value | String | 編輯器文字內容 (html string) | "`<p></p>`" |
| onChange(`newValue`) | function | 內容有更改時的 onChange。會有 debounce，時間為 `debounceTime`。`newValue` 為更動後新的值。 |  |
| debounceTime | Number | debounce time (in 毫秒) | 250 |
| height | Number | 編輯器預設的寬度 (in px) | 350 |
| uploadImage(`file`, `fulfilledCallback`) | function | 上傳圖片的 function。 `file` 為 file reference object ，包含 `type`, `name` 等參數。 `fulfilledCallback` 為上傳完成後執行的 callback function |  |
| normalizePastedValue | boolean | 是否在複製、貼上時，執行 normalize html string 的功能。| true |
| debugMode | boolean | (平常不會用到) 是否開啟 debug 模式 |   |
| onWarning(`text`) | function | (平常不會用到) 編輯器內部在某些無法處理的情況下，可以噴輸出警告訊息。 |   |
| normalizeValue | boolean | (平常不會用到) 是否在每一次更新內容時，重新 normalize html string ，以符合 slate editor 的格式。這個功能基本上只有在換編輯器時會用到。 | false |
| errorMessage | String | (平常不會用到) 顯示在編輯器下方的警告文字 | ""（空字串） |

## Run example
```bash
  cd ./example
  yarn start
```

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