1 | import { StyledEditorToolbar } from './styles';
|
---|
2 |
|
---|
3 | // ----------------------------------------------------------------------
|
---|
4 |
|
---|
5 | const HEADINGS = ['Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6'];
|
---|
6 |
|
---|
7 | export const formats = [
|
---|
8 | 'align',
|
---|
9 | 'background',
|
---|
10 | 'blockquote',
|
---|
11 | 'bold',
|
---|
12 | 'bullet',
|
---|
13 | 'code',
|
---|
14 | 'code-block',
|
---|
15 | 'color',
|
---|
16 | 'direction',
|
---|
17 | 'font',
|
---|
18 | 'formula',
|
---|
19 | 'header',
|
---|
20 | 'image',
|
---|
21 | 'indent',
|
---|
22 | 'italic',
|
---|
23 | 'link',
|
---|
24 | 'list',
|
---|
25 | 'script',
|
---|
26 | 'size',
|
---|
27 | 'strike',
|
---|
28 | 'table',
|
---|
29 | 'underline',
|
---|
30 | 'video',
|
---|
31 | ];
|
---|
32 |
|
---|
33 | type EditorToolbarProps = {
|
---|
34 | id: string;
|
---|
35 | isSimple?: boolean;
|
---|
36 | };
|
---|
37 |
|
---|
38 | export default function Toolbar({ id, isSimple, ...other }: EditorToolbarProps) {
|
---|
39 | return (
|
---|
40 | <StyledEditorToolbar {...other}>
|
---|
41 | <div id={id}>
|
---|
42 | <div className="ql-formats">
|
---|
43 | <select className="ql-header" defaultValue="">
|
---|
44 | {HEADINGS.map((heading, index) => (
|
---|
45 | <option key={heading} value={index + 1}>
|
---|
46 | {heading}
|
---|
47 | </option>
|
---|
48 | ))}
|
---|
49 | <option value="">Normal</option>
|
---|
50 | </select>
|
---|
51 | </div>
|
---|
52 |
|
---|
53 | <div className="ql-formats">
|
---|
54 | <button type="button" className="ql-bold" />
|
---|
55 | <button type="button" className="ql-italic" />
|
---|
56 | <button type="button" className="ql-underline" />
|
---|
57 | <button type="button" className="ql-strike" />
|
---|
58 | </div>
|
---|
59 |
|
---|
60 | {!isSimple && (
|
---|
61 | <div className="ql-formats">
|
---|
62 | <select className="ql-color" />
|
---|
63 | <select className="ql-background" />
|
---|
64 | </div>
|
---|
65 | )}
|
---|
66 |
|
---|
67 | <div className="ql-formats">
|
---|
68 | <button type="button" className="ql-list" value="ordered" />
|
---|
69 | <button type="button" className="ql-list" value="bullet" />
|
---|
70 | {!isSimple && <button type="button" className="ql-indent" value="-1" />}
|
---|
71 | {!isSimple && <button type="button" className="ql-indent" value="+1" />}
|
---|
72 | </div>
|
---|
73 |
|
---|
74 | {!isSimple && (
|
---|
75 | <div className="ql-formats">
|
---|
76 | <button type="button" className="ql-script" value="super" />
|
---|
77 | <button type="button" className="ql-script" value="sub" />
|
---|
78 | </div>
|
---|
79 | )}
|
---|
80 |
|
---|
81 | {!isSimple && (
|
---|
82 | <div className="ql-formats">
|
---|
83 | <button type="button" className="ql-code-block" />
|
---|
84 | <button type="button" className="ql-blockquote" />
|
---|
85 | </div>
|
---|
86 | )}
|
---|
87 |
|
---|
88 | <div className="ql-formats">
|
---|
89 | <button type="button" className="ql-direction" value="rtl" />
|
---|
90 | <select className="ql-align" />
|
---|
91 | </div>
|
---|
92 |
|
---|
93 | <div className="ql-formats">
|
---|
94 | <button type="button" className="ql-link" />
|
---|
95 | <button type="button" className="ql-image" />
|
---|
96 | <button type="button" className="ql-video" />
|
---|
97 | </div>
|
---|
98 |
|
---|
99 | <div className="ql-formats">
|
---|
100 | {!isSimple && <button type="button" className="ql-formula" />}
|
---|
101 | <button type="button" className="ql-clean" />
|
---|
102 | </div>
|
---|
103 | </div>
|
---|
104 | </StyledEditorToolbar>
|
---|
105 | );
|
---|
106 | }
|
---|