Browse Source

dev: [SimpleEditor] add props: appendInnerBar and type both

Roxas 4 years ago
parent
commit
04f36feeab

+ 2
- 1
eslib/Editor/index.d.ts View File

11
     render?: (i: ToolListItem, innerIcon: any, innerText: any, divWrapStyle: React.CSSProperties | undefined) => any;
11
     render?: (i: ToolListItem, innerIcon: any, innerText: any, divWrapStyle: React.CSSProperties | undefined) => any;
12
 }
12
 }
13
 interface SimpleEditorProps extends BaseEditorProps {
13
 interface SimpleEditorProps extends BaseEditorProps {
14
-    toolAlign?: "inner" | "bottom";
14
+    toolAlign?: "inner" | "bottom" | "both";
15
     toolList?: Array<ToolListItem>;
15
     toolList?: Array<ToolListItem>;
16
     injectControlsToolBar?: any;
16
     injectControlsToolBar?: any;
17
     injectBraftEditorProps?: any;
17
     injectBraftEditorProps?: any;
18
     toolBarContainerStyle?: any;
18
     toolBarContainerStyle?: any;
19
     appendToolBtn?: any;
19
     appendToolBtn?: any;
20
+    appendInnderBar?: any;
20
 }
21
 }
21
 declare const SimpleEditor: (props: SimpleEditorProps) => JSX.Element;
22
 declare const SimpleEditor: (props: SimpleEditorProps) => JSX.Element;
22
 export { default as BraftEditor } from "../BraftEditor/index";
23
 export { default as BraftEditor } from "../BraftEditor/index";

+ 22
- 1
eslib/Editor/index.js View File

124
       _props$injectBraftEdi = props.injectBraftEditorProps,
124
       _props$injectBraftEdi = props.injectBraftEditorProps,
125
       injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
125
       injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
126
       _props$appendToolBtn = props.appendToolBtn,
126
       _props$appendToolBtn = props.appendToolBtn,
127
-      appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn;
127
+      appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn,
128
+      _props$appendInnderBa = props.appendInnderBar,
129
+      appendInnderBar = _props$appendInnderBa === void 0 ? null : _props$appendInnderBa;
128
 
130
 
129
   if (toolAlign === 'inner') {
131
   if (toolAlign === 'inner') {
130
     return React.createElement(BarftEditorPage, Object.assign({
132
     return React.createElement(BarftEditorPage, Object.assign({
143
     }, injectBraftEditorProps));
145
     }, injectBraftEditorProps));
144
   }
146
   }
145
 
147
 
148
+  if (toolAlign === 'both') {
149
+    return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
150
+      value: value,
151
+      onChange: onChange,
152
+      controls: [],
153
+      FloatControls: function FloatControls() {
154
+        return appendInnderBar;
155
+      }
156
+    }, injectBraftEditorProps)), React.createElement("div", {
157
+      style: toolBarContainerStyle
158
+    }, React.createElement("div", {
159
+      className: styles.bottomToolBarWrapper
160
+    }, React.createElement(ControlsToolBar, Object.assign({
161
+      editorState: value,
162
+      setEditorState: onChange,
163
+      toolList: toolList
164
+    }, injectControlsToolBar))), appendToolBtn));
165
+  }
166
+
146
   return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
167
   return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
147
     value: value,
168
     value: value,
148
     onChange: onChange,
169
     onChange: onChange,

+ 1
- 1
eslib/Editor/index.js.map
File diff suppressed because it is too large
View File


+ 2
- 1
lib/Editor/index.d.ts View File

11
     render?: (i: ToolListItem, innerIcon: any, innerText: any, divWrapStyle: React.CSSProperties | undefined) => any;
11
     render?: (i: ToolListItem, innerIcon: any, innerText: any, divWrapStyle: React.CSSProperties | undefined) => any;
12
 }
12
 }
13
 interface SimpleEditorProps extends BaseEditorProps {
13
 interface SimpleEditorProps extends BaseEditorProps {
14
-    toolAlign?: "inner" | "bottom";
14
+    toolAlign?: "inner" | "bottom" | "both";
15
     toolList?: Array<ToolListItem>;
15
     toolList?: Array<ToolListItem>;
16
     injectControlsToolBar?: any;
16
     injectControlsToolBar?: any;
17
     injectBraftEditorProps?: any;
17
     injectBraftEditorProps?: any;
18
     toolBarContainerStyle?: any;
18
     toolBarContainerStyle?: any;
19
     appendToolBtn?: any;
19
     appendToolBtn?: any;
20
+    appendInnderBar?: any;
20
 }
21
 }
21
 declare const SimpleEditor: (props: SimpleEditorProps) => JSX.Element;
22
 declare const SimpleEditor: (props: SimpleEditorProps) => JSX.Element;
22
 export { default as BraftEditor } from "../BraftEditor/index";
23
 export { default as BraftEditor } from "../BraftEditor/index";

+ 22
- 1
lib/Editor/index.js View File

130
       _props$injectBraftEdi = props.injectBraftEditorProps,
130
       _props$injectBraftEdi = props.injectBraftEditorProps,
131
       injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
131
       injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
132
       _props$appendToolBtn = props.appendToolBtn,
132
       _props$appendToolBtn = props.appendToolBtn,
133
-      appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn;
133
+      appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn,
134
+      _props$appendInnderBa = props.appendInnderBar,
135
+      appendInnderBar = _props$appendInnderBa === void 0 ? null : _props$appendInnderBa;
134
 
136
 
135
   if (toolAlign === 'inner') {
137
   if (toolAlign === 'inner') {
136
     return React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
138
     return React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
149
     }, injectBraftEditorProps));
151
     }, injectBraftEditorProps));
150
   }
152
   }
151
 
153
 
154
+  if (toolAlign === 'both') {
155
+    return React__default.createElement("div", null, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
156
+      value: value,
157
+      onChange: onChange,
158
+      controls: [],
159
+      FloatControls: function FloatControls() {
160
+        return appendInnderBar;
161
+      }
162
+    }, injectBraftEditorProps)), React__default.createElement("div", {
163
+      style: toolBarContainerStyle
164
+    }, React__default.createElement("div", {
165
+      className: styles.bottomToolBarWrapper
166
+    }, React__default.createElement(ControlsToolBar, Object.assign({
167
+      editorState: value,
168
+      setEditorState: onChange,
169
+      toolList: toolList
170
+    }, injectControlsToolBar))), appendToolBtn));
171
+  }
172
+
152
   return React__default.createElement("div", null, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
173
   return React__default.createElement("div", null, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
153
     value: value,
174
     value: value,
154
     onChange: onChange,
175
     onChange: onChange,

+ 1
- 1
lib/Editor/index.js.map
File diff suppressed because it is too large
View File


+ 28
- 1
src/components/Editor/ImgTxtEditor/SimpleEditor.tsx View File

5
 import styles from './index.less';
5
 import styles from './index.less';
6
 
6
 
7
 interface SimpleEditorProps extends BaseEditorProps {
7
 interface SimpleEditorProps extends BaseEditorProps {
8
-  toolAlign?: 'inner' | 'bottom';
8
+  toolAlign?: 'inner' | 'bottom' | 'both';
9
   toolList?: Array<ToolListItem>;
9
   toolList?: Array<ToolListItem>;
10
   injectControlsToolBar?: any;
10
   injectControlsToolBar?: any;
11
   injectBraftEditorProps?: any;
11
   injectBraftEditorProps?: any;
12
   toolBarContainerStyle?: any;
12
   toolBarContainerStyle?: any;
13
   appendToolBtn?: any;
13
   appendToolBtn?: any;
14
+  appendInnderBar?: any;
14
 }
15
 }
15
 
16
 
16
 const SimpleEditor = (props: SimpleEditorProps) => {
17
 const SimpleEditor = (props: SimpleEditorProps) => {
23
     toolBarContainerStyle = {},
24
     toolBarContainerStyle = {},
24
     injectBraftEditorProps = {},
25
     injectBraftEditorProps = {},
25
     appendToolBtn = null,
26
     appendToolBtn = null,
27
+    appendInnderBar = null,
26
   } = props;
28
   } = props;
27
 
29
 
28
 
30
 
45
     )
47
     )
46
   }
48
   }
47
 
49
 
50
+  if (toolAlign === 'both') {
51
+    return (
52
+      <div>
53
+        <BarftEditorPage
54
+          value={value}
55
+          onChange={onChange}
56
+          controls={[]}
57
+          FloatControls={() => appendInnderBar}
58
+          {...injectBraftEditorProps}
59
+        />
60
+        <div style={toolBarContainerStyle}>
61
+          <div className={styles.bottomToolBarWrapper}>
62
+            <ControlsToolBar
63
+              editorState={value}
64
+              setEditorState={onChange}
65
+              toolList={toolList}
66
+              {...injectControlsToolBar}
67
+            />
68
+          </div>
69
+          {appendToolBtn}
70
+        </div>
71
+      </div>
72
+    )
73
+  }
74
+
48
   return (
75
   return (
49
     <div>
76
     <div>
50
       <BarftEditorPage
77
       <BarftEditorPage

+ 2
- 1
stats.html
File diff suppressed because it is too large
View File