# smartblock

> intuitive block based wysiwyg editor

Latest version **2.0.3** (published 2026-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install smartblock
pnpm add smartblock
yarn add smartblock
bun add smartblock
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2026-10-06 |
| First published | 2019-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 19 |
| Unpacked size | 45 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 318 |
| Author | appleple |
| Maintainers | uidev1116, atsu666, appleple-bot |

## Links

- npm: https://www.npmjs.com/package/smartblock
- Repository: https://github.com/appleple/smartblock
- Homepage: https://appleple.github.io/smartblock/
- Issues: https://github.com/appleple/smartblock/issues
- npm.io page: https://npm.io/package/smartblock

## Dependencies (19)

- [raf](https://npm.io/package/raf.md) ^3.4.1
- [uuid](https://npm.io/package/uuid.md) ^14.0.1
- [lowlight](https://npm.io/package/lowlight.md) ^1.13.0
- [is-mobile](https://npm.io/package/is-mobile.md) ^2.1.0
- [scroll-to](https://npm.io/package/scroll-to.md) 0.0.2
- [classnames](https://npm.io/package/classnames.md) ^2.5.1
- [imagesloaded](https://npm.io/package/imagesloaded.md) ^4.1.4
- [prosemirror-view](https://npm.io/package/prosemirror-view.md) 1.42.3
- [prosemirror-model](https://npm.io/package/prosemirror-model.md) 1.25.11
- [prosemirror-state](https://npm.io/package/prosemirror-state.md) 1.4.3
- [prosemirror-utils](https://npm.io/package/prosemirror-utils.md) 0.7.7
- [prosemirror-keymap](https://npm.io/package/prosemirror-keymap.md) 1.2.2
- [prosemirror-tables](https://npm.io/package/prosemirror-tables.md) 0.7.11
- [prosemirror-history](https://npm.io/package/prosemirror-history.md) 1.4.0
- [prosemirror-commands](https://npm.io/package/prosemirror-commands.md) 1.5.2
- [prosemirror-gapcursor](https://npm.io/package/prosemirror-gapcursor.md) 1.3.2
- [prosemirror-transform](https://npm.io/package/prosemirror-transform.md) 1.9.0
- [prosemirror-inputrules](https://npm.io/package/prosemirror-inputrules.md) 1.4.0
- [prosemirror-schema-list](https://npm.io/package/prosemirror-schema-list.md) 1.4.0

## Recent versions

- 2.0.3 (latest) — 2026-10-06
- 1.4.9 (legacy) — 2026-10-06
- 1.0.5 (old-version-1.0.5) — 2020-07-08
- 2.0.2 — 2026-07-31
- 2.0.1 — 2026-07-31
- 2.0.0 — 2026-07-31
- 1.4.8 — 2025-08-06
- 1.4.7 — 2024-08-26
- 1.4.6 — 2024-07-22
- 1.4.5 — 2024-07-19
- 1.4.4 — 2024-07-19
- 1.4.3 — 2024-07-18
- 1.4.2 — 2024-07-18
- 1.4.1 — 2024-07-18
- 1.4.0 — 2024-07-18
- … 29 more at https://npm.io/package/smartblock/versions

## README

# SmartBlock

![](https://github.com/appleple/smartblock/workflows/Node%20CI/badge.svg)
[![npm version](https://badge.fury.io/js/smartblock.svg)](https://badge.fury.io/js/smartblock)
[![npm download](http://img.shields.io/npm/dm/smartblock.svg)](https://www.npmjs.com/package/smartblock)
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/appleple/smartblock/master/LICENSE)
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Awesome%20block-based%20JavaScript%20%Editor&url=https://github.com/appleple/smartblock&via=appleplecom&hashtags=blocks,smartblock)



SmartBlock.js is a JavaScript block based editor which enables you to write contents easily on websites even with **SmartPhone**.

| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE11 / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari-ios/safari-ios_48x48.png" alt="iOS Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>iOS Safari |
| --------- | --------- | --------- | --------- | --------- |

## ScreenShot

<img src="./screenshots/paragraph.png" />

## Features

*   Easy to use with SmartPhone
*   Fully customizable
*   Block based
*   Keep clean HTML and wipe out unnecessary tags
*   Get the result as **HTML** or **JSON**
*   copy and paste contents

## Install

```sh
$ npm install smartblock --save
```

## Usage

```js
import * as React from 'react';
import { render } from 'react-dom';
import 'smartblock/css/smartblock.css';
import { SmartBlock, Extensions } from 'smartblock';

render(<>
  <SmartBlock
    extensions={Extensions}
    html={'<h2>Hello World</h2><p>hello</p>'}
    onChange={({ json, html }) => { console.log(json, html);}}
  />
</>, document.getElementById("app"));
```


## Try it on CodeSandbox

[![Edit hardcore-kalam-tghp9](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/hardcore-kalam-tghp9?fontsize=14&hidenavigation=1&theme=dark)


## Customize

You can add custom block like this

```js
import * as React from 'react';
import { Extensions, CustomBlock, CustomMark } from 'smartblock';
Extensions.push(new CustomBlock({
  tagName: 'div',
  className: '.alert',
  icon: <SomeIconComponent />
});

render(<>
  <SmartBlock
    extensions={Extensions}
    html={'<h2>Hello World</h2><p>hello</p>'}
    onChange={({ json, html }) => { console.log(json, html);}}
  />
</>, document.getElementById("app"));
```

You can add custom inline element like this

```js
import * as React from 'react';
import { Extension, CustomBlock, CustomMark } from 'smartblock';
import 'smartblock/css/smartblock.css';
Extension.push(new CustomMark({
  tagName: 'span',
  className: '.small',
  icon: <SomeIconComponent />
});

render(<>
  <SmartBlock
    extensions={Extensions}
    html={'<h2>Hello World</h2><p><small>hello</small></p>'}
    onChange={({ json, html }) => { console.log(json, html);}}
  />
</>, document.getElementById("app"));
```

## Options

| Props        | description                                                                                                 | type               | default                                                                                                                                                                                                                                                                                                                                                                 |
| ------------ | ----------------------------------------------------------------------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| extensions   | Array of extensions which extend the feature of SmartBlock                                                  | Extension[] | array of extensions |
| onChange     | Callback function which is called when the content of the editor is changed. You can get both html and json | Function           |                                                                                                                                                                                                                                                                                                                                                                         |
| onInit       | Callback function which is called when the editor is initialized                                            | Function           |                                                                                                                                                                                                                                                                                                                                                                         |
| json         | The editor contents will be initialized with the json data                                                  | Object             | {}                                                                                                                                                                                                                                                                                                                                                                      |
| HTML         | The editor contents will be initialized with the HTML                                                       | String             | ''                                                                                                                                                                                                                                                                                                                                                                      |
| showTitle    | Title will be shown                                                                                         | Boolean            | false                                                                                                                                                                                                                                                                                                                                                                   |
| showBackBtn  | Btn to support history back will be shown                                                                   | Boolean            | false                                                                                                                                                                                                                                                                                                                                                                   |
| autoSave     | The HTML will be stored to the localstorage every time the content is changed                               | Boolean            | false                                                                                                                                                                                                                                                                                                                                                                   |
| getEditorRef | Get the editor ref object                                                                                   | Function           |                                                                                                                                                                                                                                                                                                                                                                         |
## Download
[Download ZIP](https://github.com/appleple/smartblock/archive/master.zip)

## Github
[https://github.com/appleple/smartblock](https://github.com/appleple/smartblock)

## License
Code and documentation copyright 2020 by appleple, Inc. Code released under the [MIT License](https://github.com/appleple/smartblock/blob/master/LICENSE).

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