• Stars
    star
    307
  • Rank 136,067 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

intuitive block based wysiwyg editor built with React and ProseMirror

SmartBlock

npm version npm download GitHub license Tweet

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

IE / Edge
IE11 / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari

ScreenShot

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

$ npm install smartblock --save

Usage

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

Customize

You can add custom block like this

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

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

Github

https://github.com/appleple/smartblock

Contributor

@steelydylan

License

Code and documentation copyright 2020 by appleple, Inc. Code released under the MIT License.

More Repositories

1

SmartPhoto

The most easy to use responsive image viewer especially for mobile devices
JavaScript
904
star
2

scroll-hint

A JS library to suggest that the elements are scrollable horizontally, with the pointer icon.
JavaScript
338
star
3

lookforward

A small library that helps you to create smooth transitions between pages with the easiest way
JavaScript
303
star
4

modal-video

JavaScript
267
star
5

react-modal-video

Accessible React Modal Video Component
JavaScript
176
star
6

lite-editor

A Modern WYSIWYG Editor especially for inline elements
JavaScript
176
star
7

form-storage

A JavaScript library stores the form-data to the localstorage so you don't have to fill the form again.
JavaScript
164
star
8

pretty-scroll

A modern JS library to make an element follow you as you scroll
JavaScript
143
star
9

a-table.js

Simple Table UI for generating table html
JavaScript
83
star
10

hiraku

jQuery Offcanvas Menu Plugin
JavaScript
76
star
11

hiraku2

Vanilla JavaScript library to make drawer menus
JavaScript
69
star
12

document-outliner

HTML5 outliner
TypeScript
20
star
13

yahoo-map-cluster

Yahoo! Map Cluster
TypeScript
19
star
14

multi-menu

JavaScript for multi level menu
TypeScript
19
star
15

backpax

Simple JavaScript Library to add parallax image to background-image
TypeScript
16
star
16

responsive-auto-height

JavaScript library to equalize elements's height
JavaScript
11
star
17

acms-utsuwa

HTML
10
star
18

a-template.js

Simple Template Engine
JavaScript
9
star
19

a-starter-kit

アップルップルの受託案件用スターターキット
HTML
8
star
20

appleple.github.io

HTML
6
star
21

nice-spy

A library used to update classnames of links based on scroll position
JavaScript
5
star
22

acms-slack

Slack app for a-blog cms
PHP
5
star
23

guideline

アップルップルのガイドライン
5
star
24

acms-zoho

a-blog cmsのフォームと連携することによってお客様が入力した情報をZoho CRM 上に蓄積することができます。
PHP
5
star
25

wp-smartphoto

SmartPhoto plugin for WordPress
PHP
4
star
26

acms-recaptcha

a-blog cms の 拡張アプリ「reCAPTCHA for a-blog cms」を使うと、GoogleのreCAPTCHAを使用してボットからの フォームアクセスを防御することが出来るようになります。
PHP
4
star
27

geo-picker

JavaScript
4
star
28

react-device-mode

TypeScript
4
star
29

ui-expand

Just a simple UI helper to expand elements to full screen
HTML
4
star
30

custom-field-maker

JavaScript
4
star
31

assign-holiday

Simple library for adding class attributes to holiday elements in a calendar
JavaScript
3
star
32

acms-google-translate

Google Translation for a-blog cms
PHP
3
star
33

acms-easy-setup

より簡単に、ご利用の環境に合わせて a-blog cms をインストール、アップデートできるパッケージです。
PHP
3
star
34

scroll-up

This library is for a fixed scroll to top button.
JavaScript
3
star
35

acms-google-sheets

Google Sheets API と連携し、お問い合わせフォームなどで送信された内容を任意のGoogle スプレッドシートの最後の行に追記することができます。
PHP
3
star
36

a-dispatcher

Just a simple url-dispatcher you can use with regex
JavaScript
3
star
37

yahoo-map-loader

Just a simple yahoo map loader for Webpack/Browserify
JavaScript
3
star
38

lite-editor-emoji-picker-plugin

Emoji Picker plugin for Lite Editor
CSS
3
star
39

acms-base

HTML
2
star
40

ablogcms-docker

Shell
2
star
41

acms-chatwork

a-blog cms のフォームからの送信データをchatworkで通知します
PHP
2
star
42

react-ui-expand

Just a simple UI helper to expand elements
HTML
2
star
43

acms-image-placeholder

Image placeholder for a-blog cms.
PHP
2
star
44

PhotoCollage

HTML
2
star
45

ScrollScale

JavaScript
1
star
46

react-icon-picker

Just a simple icon picker for React
TypeScript
1
star
47

fold-menu

TypeScript
1
star
48

acms-tiny-png

PHP
1
star
49

lang-select

JavaScript
1
star
50

cfg-csv

JavaScript
1
star
51

dom-content-loaded

JavaScript
1
star
52

react-hiragana-picker

React Component to pick Japanese Character (Hiragana)
TypeScript
1
star
53

lazy-hover

delay appear effect and leave effect when mousein mouseout
CSS
1
star
54

react-car-number-picker

TypeScript
1
star
55

acms-google-calendar

Google Calendar API と連携し、お問い合わせフォームなどで送信された内容を任意のGoogleカレンダーに登録できます。
PHP
1
star