-
Notifications
You must be signed in to change notification settings - Fork 964
/
plugin.tsx
54 lines (49 loc) · 1001 Bytes
/
plugin.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { Builder } from '@builder.io/sdk';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';
const modules = {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline', 'strike', 'blockquote'],
[{ list: 'ordered' }, { list: 'bullet' }, { indent: '-1' }, { indent: '+1' }],
['link', 'image'],
['clean'],
],
};
const formats = [
'header',
'bold',
'italic',
'underline',
'strike',
'blockquote',
'list',
'bullet',
'indent',
'link',
'image',
];
interface TextProps {
value: string;
onChange: () => void;
}
function RichTextEditor(props: TextProps) {
return (
<ReactQuill
theme="snow"
value={props.value}
onChange={props.onChange}
modules={modules}
formats={formats}
/>
);
}
Builder.registerEditor({
/**
* Here we override the built-in richtext editor.
*/
name: 'html',
component: RichTextEditor,
});