UNPKG

2.61 kBMarkdownView Raw
1# react-simple-wysiwyg
2[![Build Status](https://travis-ci.org/megahertz/react-simple-wysiwyg.svg?branch=master)](https://travis-ci.org/megahertz/react-simple-wysiwyg)
3[![NPM version](https://badge.fury.io/js/react-simple-wysiwyg.svg)](https://badge.fury.io/js/react-simple-wysiwyg)
4[![Dependencies status](https://david-dm.org/megahertz/react-simple-wysiwyg/status.svg)](https://david-dm.org/megahertz/react-simple-wysiwyg)
5[![npm bundle size](https://img.shields.io/bundlephobia/minzip/react-simple-wysiwyg.svg?color=rgb%2868%2C%20204%2C%2017%29)](https://bundlephobia.com/result?p=react-simple-wysiwyg@0.0.3)
6
7Simple and lightweight React WYSIWYG editor. [Demo](https://megahertz.github.io/react-simple-wysiwyg/).
8
9## Description
10
11**The project is in alpha stage.**
12
13[![Screenshot](docs/resources/screenshot.png)](https://megahertz.github.io/react-simple-wysiwyg/)
14
15It can be helpful if you only need basic text operations. It's:
16
17 - pretty small (~10kb, ~4kb gzipped)
18 - fast
19 - simple to configure
20 - simple to extend
21
22Of course, it's not so powerful as other complex editors. It DOES NOT:
23
24 - ✗ change HTML generated by browser (sometimes it can be too dirty)
25 - ✗ sanitize HTML (you can use [sanitize-html](https://www.npmjs.com/package/sanitize-html))
26 - ✗ contain a lot of feature as others (like table editor, image editor and so on)
27 - ✗ support old browser
28
29If you need more powerful solution for React, you'd better take a look at:
30
31 - [draft.js](https://draftjs.org/) or draft-powered editor like
32 [react-rte](https://github.com/sstur/react-rte)
33 - classic solution like [CKEditor](https://ckeditor.com/) and
34 [TinyMCE](https://www.tiny.cloud/)
35 - [Quill](https://github.com/zenoamaro/react-quill) and
36 [Summernote](https://github.com/summernote/react-summernote)
37
38
39## Usage
40
41 1. Install with [npm](https://npmjs.org/package/react-simple-wysiwyg):
42
43 `npm install react-simple-wysiwyg`
44
45 or [CDN (unpkg.com)](https://unpkg.com/react-simple-wysiwyg/)
46
47 `<script src="//unpkg.com/react-simple-wysiwyg"></script>`
48
49 2. Use it you React component
50
51 ```jsx
52 import { DefaultEditor } from 'react-simple-wysiwyg';
53
54 function App() {
55 const [html, setHtml] = React.useState('my <b>HTML</b>');
56
57 const onChange = (e) => {
58 setHtml(e.target.value);
59 };
60
61 return (
62 <DefaultEditor value={html} onChange={onChange} />
63 );
64 }
65 ```
66
67## Credits
68
69 - Based on
70 [lovasoa/react-contenteditable](https://github.com/lovasoa/react-contenteditable)
71 - Uses [Material Design Icons](http://materialdesignicons.com/)