|
@@ -6,12 +6,16 @@ import { withKnobs, number, boolean, select } from "@storybook/addon-knobs";
|
6
|
6
|
import { addReadme } from "storybook-readme";
|
7
|
7
|
|
8
|
8
|
import { BarftEditorPage } from "@components/Editor/BraftEditor";
|
|
9
|
+import SimpleEditor from "@components/Editor/QAEditor/SimpleEditor";
|
|
10
|
+import { ControlsToolBar } from "@components/Editor/CommonTool/ControlsToolBar";
|
9
|
11
|
import { ContentUtils } from "braft-utils";
|
10
|
12
|
|
11
|
13
|
import EditorData from "./data/articleData.json";
|
12
|
|
-import { Divider, Popover } from "antd";
|
|
14
|
+import { Divider, Popover, Checkbox } from "antd";
|
13
|
15
|
import BraftEditor from "braft-editor";
|
14
|
16
|
|
|
17
|
+import styles from './index.less';
|
|
18
|
+
|
15
|
19
|
const stories = storiesOf("Editor", module);
|
16
|
20
|
stories.addDecorator(storyFn => (
|
17
|
21
|
<div style={{ padding: "0px 40px" }}>{storyFn()}</div>
|
|
@@ -41,54 +45,162 @@ stories.add(
|
41
|
45
|
);
|
42
|
46
|
return (
|
43
|
47
|
<>
|
44
|
|
- <h3>非受控组件</h3>
|
45
|
|
- <BarftEditorPage controls={[]} />
|
46
|
|
- <Divider />
|
47
|
|
- <h3>受控组件</h3>
|
48
|
48
|
<BarftEditorPage
|
49
|
49
|
value={editorState}
|
50
|
50
|
onChange={setEditorState}
|
51
|
51
|
controls={["bold"]}
|
52
|
|
- FloatControls={({ editorState, setEditorState }: any) => {
|
53
|
|
- const IconWrapStyle = {
|
54
|
|
- cursor: "pointer",
|
55
|
|
- textAlign: "center" as const,
|
56
|
|
- width: "42px"
|
57
|
|
- };
|
58
|
|
- const IconStyle = { fontSize: "21px" };
|
59
|
|
- return (
|
60
|
|
- <>
|
61
|
|
- <div
|
62
|
|
- style={{ color: "#f07977", ...IconWrapStyle }}
|
63
|
|
- onClick={() => {
|
|
52
|
+ FloatControls={({ editorState, setEditorState }: any) => (
|
|
53
|
+ <ControlsToolBar
|
|
54
|
+ editorState={editorState}
|
|
55
|
+ setEditorState={setEditorState}
|
|
56
|
+ toolList={[
|
|
57
|
+ {
|
|
58
|
+ key: 1,
|
|
59
|
+ color: "#f07977",
|
|
60
|
+ iconClass: "schedule schedule-icon_story",
|
|
61
|
+ onClick: () => {
|
64
|
62
|
setEditorState(
|
65
|
63
|
ContentUtils.insertText(editorState, "Hello World")
|
66
|
64
|
);
|
67
|
|
- }}
|
68
|
|
- >
|
69
|
|
- <i
|
70
|
|
- className="schedule schedule-icon_story"
|
71
|
|
- style={IconStyle}
|
72
|
|
- />
|
73
|
|
- </div>
|
74
|
|
- <div style={{ ...IconWrapStyle, color: "#3d9bfe" }}>
|
75
|
|
- <i
|
76
|
|
- className="schedule schedule-icon_topic"
|
77
|
|
- style={IconStyle}
|
78
|
|
- />
|
79
|
|
- </div>
|
80
|
|
- <div style={{ ...IconWrapStyle, color: "#ffa405" }}>
|
81
|
|
- <i
|
82
|
|
- className="schedule schedule-icon_emoticon"
|
83
|
|
- style={IconStyle}
|
84
|
|
- />
|
85
|
|
- </div>
|
86
|
|
- <div style={{ ...IconWrapStyle, color: "#71c135" }}>
|
87
|
|
- <i className="schedule schedule-icon_img" style={IconStyle} />
|
88
|
|
- </div>
|
89
|
|
- </>
|
90
|
|
- );
|
|
65
|
+ }
|
|
66
|
+ },
|
|
67
|
+ {
|
|
68
|
+ key: 2,
|
|
69
|
+ color: "#3d9bfe",
|
|
70
|
+ iconClass: "schedule schedule-icon_topic",
|
|
71
|
+ onClick: () => {
|
|
72
|
+ setEditorState(
|
|
73
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
74
|
+ );
|
|
75
|
+ }
|
|
76
|
+ },
|
|
77
|
+ {
|
|
78
|
+ key: 3,
|
|
79
|
+ color: "#ffa405",
|
|
80
|
+ iconClass: "schedule schedule-icon_emoticon",
|
|
81
|
+ onClick: () => {
|
|
82
|
+ setEditorState(
|
|
83
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
84
|
+ );
|
|
85
|
+ }
|
|
86
|
+ },
|
|
87
|
+ {
|
|
88
|
+ key: 4,
|
|
89
|
+ color: "#71c135",
|
|
90
|
+ iconClass: "schedule schedule-icon_img",
|
|
91
|
+ onClick: () => {
|
|
92
|
+ setEditorState(
|
|
93
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
94
|
+ );
|
|
95
|
+ }
|
|
96
|
+ }
|
|
97
|
+ ]}
|
|
98
|
+ />
|
|
99
|
+ )}
|
|
100
|
+ />
|
|
101
|
+ </>
|
|
102
|
+ );
|
|
103
|
+ },
|
|
104
|
+ {
|
|
105
|
+ info: {
|
|
106
|
+ inline: true
|
|
107
|
+ },
|
|
108
|
+ notes: "A very simple example of addon notes"
|
|
109
|
+ }
|
|
110
|
+);
|
|
111
|
+
|
|
112
|
+stories.add(
|
|
113
|
+ "QASimpleEditor",
|
|
114
|
+ () => {
|
|
115
|
+ const [editorState, setEditorState] = useState(
|
|
116
|
+ BraftEditor.createEditorState("<p>Hello <b>World!</b></p>")
|
|
117
|
+ );
|
|
118
|
+ return (
|
|
119
|
+ <>
|
|
120
|
+ <SimpleEditor
|
|
121
|
+ value={editorState}
|
|
122
|
+ onChange={setEditorState}
|
|
123
|
+ controls={[]}
|
|
124
|
+ toolList={[
|
|
125
|
+ {
|
|
126
|
+ key: 1,
|
|
127
|
+ color: "#f07977",
|
|
128
|
+ iconClass: "schedule schedule-icon_story",
|
|
129
|
+ onClick: () => {
|
|
130
|
+ setEditorState(
|
|
131
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
132
|
+ );
|
|
133
|
+ }
|
|
134
|
+ },
|
|
135
|
+ {
|
|
136
|
+ key: 2,
|
|
137
|
+ color: "#3d9bfe",
|
|
138
|
+ iconClass: "schedule schedule-icon_topic",
|
|
139
|
+ onClick: () => {
|
|
140
|
+ setEditorState(
|
|
141
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
142
|
+ );
|
|
143
|
+ }
|
|
144
|
+ },
|
|
145
|
+ {
|
|
146
|
+ key: 3,
|
|
147
|
+ color: "#ffa405",
|
|
148
|
+ iconClass: "schedule schedule-icon_emoticon",
|
|
149
|
+ onClick: () => {
|
|
150
|
+ setEditorState(
|
|
151
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
152
|
+ );
|
|
153
|
+ }
|
|
154
|
+ },
|
|
155
|
+ {
|
|
156
|
+ key: 4,
|
|
157
|
+ color: "#71c135",
|
|
158
|
+ iconClass: "schedule schedule-icon_img",
|
|
159
|
+ onClick: () => {
|
|
160
|
+ setEditorState(
|
|
161
|
+ ContentUtils.insertText(editorState, "Hello World")
|
|
162
|
+ );
|
|
163
|
+ }
|
|
164
|
+ }
|
|
165
|
+ ]}
|
|
166
|
+ toolAlign={select("toolAlign", {
|
|
167
|
+ Inner: 'inner',
|
|
168
|
+ Bottom: 'bottom',
|
|
169
|
+ }, "bottom")}
|
|
170
|
+ toolBarContainerStyle={{
|
|
171
|
+ display: 'flex',
|
|
172
|
+ justifyContent: 'space-between',
|
|
173
|
+ height: '55px',
|
|
174
|
+ alignItems: 'center',
|
91
|
175
|
}}
|
|
176
|
+ appendToolBtn={(
|
|
177
|
+ <div style={{ display: 'flex', alignItems: 'center', width: '400px', justifyContent: 'space-between'}}>
|
|
178
|
+ <div className={styles.QAAnonymous}>
|
|
179
|
+ <Popover
|
|
180
|
+ trigger="hover"
|
|
181
|
+ content={
|
|
182
|
+ <div>
|
|
183
|
+ 警告
|
|
184
|
+ </div>
|
|
185
|
+ }
|
|
186
|
+ >
|
|
187
|
+ <Checkbox>
|
|
188
|
+ anonymous
|
|
189
|
+ </Checkbox>
|
|
190
|
+ </Popover>
|
|
191
|
+ </div>
|
|
192
|
+ <div
|
|
193
|
+ className={styles.QASaveBtn}
|
|
194
|
+ >
|
|
195
|
+ Save
|
|
196
|
+ </div>
|
|
197
|
+ <div
|
|
198
|
+ className={styles.QASubmitBtn}
|
|
199
|
+ >
|
|
200
|
+ Submit
|
|
201
|
+ </div>
|
|
202
|
+ </div>
|
|
203
|
+ )}
|
92
|
204
|
/>
|
93
|
205
|
</>
|
94
|
206
|
);
|
|
@@ -100,3 +212,4 @@ stories.add(
|
100
|
212
|
notes: "A very simple example of addon notes"
|
101
|
213
|
}
|
102
|
214
|
);
|
|
215
|
+
|