Browse Source

fix:修改逻辑,保证state修改时不影响tooltip渲染

Roxas 4 years ago
parent
commit
b1dc290a06

+ 6
- 2
eslib/BraftEditor/index.d.ts View File

@@ -6,12 +6,16 @@ interface BaseEditorProps {
6 6
     onChange: (editorState: EditorState) => void;
7 7
     contentStyle?: React.CSSProperties;
8 8
     controls?: ControlType[];
9
-    FloatControls?: any;
10 9
     blockRenderMap?: any;
11 10
     blockRendererFn?: any;
11
+    onDelete?: Function;
12
+    onSave?: Function;
13
+    onTab?: Function;
14
+    onFocus?: Function;
15
+    onBlur?: Function;
12 16
     draftProps?: any;
13 17
     placeholder?: string;
14 18
     converts?: any;
15 19
 }
16
-declare const BarftEditorPage: ({ value, onChange, controls, contentStyle, FloatControls, draftProps, placeholder, blockRenderMap, blockRendererFn, converts, }: BaseEditorProps) => JSX.Element;
20
+declare const BarftEditorPage: ({ value, onChange, controls, contentStyle, draftProps, placeholder, blockRenderMap, blockRendererFn, onDelete, onSave, onTab, onFocus, onBlur, converts, }: BaseEditorProps) => JSX.Element;
17 21
 export { BarftEditorPage as default, BarftEditorPage, BaseEditorProps };

+ 16
- 16
eslib/BraftEditor/index.js View File

@@ -9,13 +9,12 @@ import 'braft-extensions/dist/emoticon.css';
9 9
 import Emoticon, { defaultEmoticons } from 'braft-extensions/dist/emoticon';
10 10
 import MaxLength from 'braft-extensions/dist/max-length';
11 11
 
12
-var css = ".index_baseWrapper__1_-58 {\n  position: relative;\n}\n.index_baseWrapper__1_-58 .bf-container {\n  display: flex;\n  flex-direction: column;\n}\n.index_baseWrapper__1_-58 .bf-container .index_controlBar__3SzSH {\n  box-shadow: none;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX {\n  border: 1px solid #ccc;\n  border-radius: 4px;\n  height: auto;\n  transition: border-color 0.3s;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX.index_focus__puDJA {\n  border-color: #1790ff;\n}\n.index_baseWrapper__1_-58 .index_floatControls__2hVPf {\n  position: absolute;\n  right: 15px;\n  bottom: 15px;\n  display: flex;\n  z-index: 2;\n}\n";
12
+var css = ".index_baseWrapper__1_-58 {\n  position: relative;\n}\n.index_baseWrapper__1_-58 .bf-container {\n  display: flex;\n  flex-direction: column;\n}\n.index_baseWrapper__1_-58 .bf-container .index_controlBar__3SzSH {\n  box-shadow: none;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX {\n  border: 1px solid #ccc;\n  border-radius: 4px;\n  height: auto;\n  transition: border-color 0.3s;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX.index_focus__puDJA {\n  border-color: #1790ff;\n}\n";
13 13
 var styles = {
14 14
   "baseWrapper": "index_baseWrapper__1_-58",
15 15
   "controlBar": "index_controlBar__3SzSH",
16 16
   "editorContent": "index_editorContent__2UOaX",
17
-  "focus": "index_focus__puDJA",
18
-  "floatControls": "index_floatControls__2hVPf"
17
+  "focus": "index_focus__puDJA"
19 18
 };
20 19
 styleInject(css);
21 20
 
@@ -33,24 +32,25 @@ var emotionOptions = {
33 32
 };
34 33
 BraftEditor.use(Emoticon(emotionOptions));
35 34
 var BarftEditorPage = function BarftEditorPage(_ref) {
36
-  var _classnames2;
37
-
38 35
   var value = _ref.value,
39 36
       onChange = _ref.onChange,
40 37
       controls = _ref.controls,
41 38
       _ref$contentStyle = _ref.contentStyle,
42 39
       contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
43
-      FloatControls = _ref.FloatControls,
44 40
       draftProps = _ref.draftProps,
45 41
       placeholder = _ref.placeholder,
46 42
       blockRenderMap = _ref.blockRenderMap,
47 43
       blockRendererFn = _ref.blockRendererFn,
44
+      onDelete = _ref.onDelete,
45
+      onSave = _ref.onSave,
46
+      onTab = _ref.onTab,
47
+      onFocus = _ref.onFocus,
48
+      onBlur = _ref.onBlur,
48 49
       converts = _ref.converts;
49 50
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
50 51
   var options = {
51 52
     controls: optionsControls,
52
-    showControlsBar: optionsControls && optionsControls.length > 0 && !FloatControls,
53
-    showFloatControls: FloatControls
53
+    showControlsBar: optionsControls && optionsControls.length > 0
54 54
   };
55 55
 
56 56
   var _useState = useState(false),
@@ -68,7 +68,7 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
68 68
     controlBarStyle: options.showControlsBar ? {} : {
69 69
       display: "none"
70 70
     },
71
-    contentClassName: classnames(styles.editorContent, (_classnames2 = {}, _defineProperty(_classnames2, styles.focus, focusState), _defineProperty(_classnames2, styles.hasFloatControls, options.showFloatControls), _classnames2)),
71
+    contentClassName: classnames(styles.editorContent, _defineProperty({}, styles.focus, focusState)),
72 72
     contentStyle: contentStyle,
73 73
     onFocus: function onFocus() {
74 74
       return setFocusState(true);
@@ -92,13 +92,13 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
92 92
     blockRendererFn: blockRendererFn,
93 93
     converts: converts,
94 94
     placeholder: placeholder,
95
-    draftProps: draftProps
96
-  })), options.showFloatControls ? React.createElement("div", {
97
-    className: classnames(styles.floatControls)
98
-  }, React.createElement(FloatControls, {
99
-    editorState: value,
100
-    setEditorState: onChange
101
-  })) : null);
95
+    draftProps: draftProps,
96
+    onDelete: onDelete,
97
+    onSave: onSave,
98
+    onTab: onTab,
99
+    onFocus: onFocus,
100
+    onBlur: onBlur
101
+  })));
102 102
 };
103 103
 
104 104
 export default BarftEditorPage;

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


+ 25
- 23
eslib/Editor/index.js View File

@@ -1,7 +1,7 @@
1 1
 import React from 'react';
2 2
 import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
3 3
 import { _ as _defineProperty } from '../defineProperty-18999f8e.js';
4
-import '../index-e3cf212a.js';
4
+import { c as classnames } from '../index-e3cf212a.js';
5 5
 import '../slicedToArray-4cd9e6d3.js';
6 6
 import 'braft-editor';
7 7
 import { BarftEditorPage } from '../BraftEditor/index.js';
@@ -104,9 +104,11 @@ var ControlsToolBar = function ControlsToolBar(props) {
104 104
   }));
105 105
 };
106 106
 
107
-var css = ".index_bottomToolBarWrapper__DzhzC {\n  display: flex;\n}\n";
107
+var css = ".index_bottomToolBarWrapper__DzhzC {\n  display: flex;\n}\n.index_innerWrapper__1oX5A {\n  position: relative;\n}\n.index_innerWrapper__1oX5A .index_floatControls__16aMl {\n  position: absolute;\n  right: 15px;\n  bottom: 15px;\n  display: flex;\n  z-index: 2;\n}\n";
108 108
 var styles = {
109
-  "bottomToolBarWrapper": "index_bottomToolBarWrapper__DzhzC"
109
+  "bottomToolBarWrapper": "index_bottomToolBarWrapper__DzhzC",
110
+  "innerWrapper": "index_innerWrapper__1oX5A",
111
+  "floatControls": "index_floatControls__16aMl"
110 112
 };
111 113
 styleInject(css);
112 114
 
@@ -114,7 +116,7 @@ var SimpleEditor = function SimpleEditor(props) {
114 116
   var value = props.value,
115 117
       onChange = props.onChange,
116 118
       _props$toolAlign = props.toolAlign,
117
-      toolAlign = _props$toolAlign === void 0 ? 'inner' : _props$toolAlign,
119
+      toolAlign = _props$toolAlign === void 0 ? "inner" : _props$toolAlign,
118 120
       _props$toolList = props.toolList,
119 121
       toolList = _props$toolList === void 0 ? [] : _props$toolList,
120 122
       _props$injectControls = props.injectControlsToolBar,
@@ -128,32 +130,32 @@ var SimpleEditor = function SimpleEditor(props) {
128 130
       _props$appendInnderBa = props.appendInnderBar,
129 131
       appendInnderBar = _props$appendInnderBa === void 0 ? null : _props$appendInnderBa;
130 132
 
131
-  if (toolAlign === 'inner') {
132
-    return React.createElement(BarftEditorPage, Object.assign({
133
+  if (toolAlign === "inner") {
134
+    return React.createElement("div", {
135
+      className: styles.innerWrapper
136
+    }, React.createElement(BarftEditorPage, Object.assign({
133 137
       value: value,
134 138
       onChange: onChange,
135
-      controls: [],
136
-      FloatControls: function FloatControls(_ref) {
137
-        var editorState = _ref.editorState,
138
-            setEditorState = _ref.setEditorState;
139
-        return React.createElement(ControlsToolBar, Object.assign({
140
-          editorState: editorState,
141
-          setEditorState: setEditorState,
142
-          toolList: toolList
143
-        }, injectControlsToolBar));
144
-      }
145
-    }, injectBraftEditorProps));
139
+      controls: []
140
+    }, injectBraftEditorProps)), React.createElement("div", {
141
+      className: classnames(styles.floatControls)
142
+    }, React.createElement(ControlsToolBar, Object.assign({
143
+      editorState: value,
144
+      setEditorState: onChange,
145
+      toolList: toolList
146
+    }, injectControlsToolBar))));
146 147
   }
147 148
 
148
-  if (toolAlign === 'both') {
149
-    return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
149
+  if (toolAlign === "both") {
150
+    return React.createElement("div", null, React.createElement("div", {
151
+      className: styles.innerWrapper
152
+    }, React.createElement(BarftEditorPage, Object.assign({
150 153
       value: value,
151 154
       onChange: onChange,
152
-      controls: [],
153
-      FloatControls: function FloatControls() {
154
-        return appendInnderBar;
155
-      }
155
+      controls: []
156 156
     }, injectBraftEditorProps)), React.createElement("div", {
157
+      className: classnames(styles.floatControls)
158
+    }, appendInnderBar)), React.createElement("div", {
157 159
       style: toolBarContainerStyle
158 160
     }, React.createElement("div", {
159 161
       className: styles.bottomToolBarWrapper

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


+ 6
- 2
lib/BraftEditor/index.d.ts View File

@@ -6,12 +6,16 @@ interface BaseEditorProps {
6 6
     onChange: (editorState: EditorState) => void;
7 7
     contentStyle?: React.CSSProperties;
8 8
     controls?: ControlType[];
9
-    FloatControls?: any;
10 9
     blockRenderMap?: any;
11 10
     blockRendererFn?: any;
11
+    onDelete?: Function;
12
+    onSave?: Function;
13
+    onTab?: Function;
14
+    onFocus?: Function;
15
+    onBlur?: Function;
12 16
     draftProps?: any;
13 17
     placeholder?: string;
14 18
     converts?: any;
15 19
 }
16
-declare const BarftEditorPage: ({ value, onChange, controls, contentStyle, FloatControls, draftProps, placeholder, blockRenderMap, blockRendererFn, converts, }: BaseEditorProps) => JSX.Element;
20
+declare const BarftEditorPage: ({ value, onChange, controls, contentStyle, draftProps, placeholder, blockRenderMap, blockRendererFn, onDelete, onSave, onTab, onFocus, onBlur, converts, }: BaseEditorProps) => JSX.Element;
17 21
 export { BarftEditorPage as default, BarftEditorPage, BaseEditorProps };

+ 16
- 16
lib/BraftEditor/index.js View File

@@ -17,13 +17,12 @@ var Emoticon = require('braft-extensions/dist/emoticon');
17 17
 var Emoticon__default = _interopDefault(Emoticon);
18 18
 var MaxLength = _interopDefault(require('braft-extensions/dist/max-length'));
19 19
 
20
-var css = ".index_baseWrapper__1_-58 {\n  position: relative;\n}\n.index_baseWrapper__1_-58 .bf-container {\n  display: flex;\n  flex-direction: column;\n}\n.index_baseWrapper__1_-58 .bf-container .index_controlBar__3SzSH {\n  box-shadow: none;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX {\n  border: 1px solid #ccc;\n  border-radius: 4px;\n  height: auto;\n  transition: border-color 0.3s;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX.index_focus__puDJA {\n  border-color: #1790ff;\n}\n.index_baseWrapper__1_-58 .index_floatControls__2hVPf {\n  position: absolute;\n  right: 15px;\n  bottom: 15px;\n  display: flex;\n  z-index: 2;\n}\n";
20
+var css = ".index_baseWrapper__1_-58 {\n  position: relative;\n}\n.index_baseWrapper__1_-58 .bf-container {\n  display: flex;\n  flex-direction: column;\n}\n.index_baseWrapper__1_-58 .bf-container .index_controlBar__3SzSH {\n  box-shadow: none;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX {\n  border: 1px solid #ccc;\n  border-radius: 4px;\n  height: auto;\n  transition: border-color 0.3s;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX.index_focus__puDJA {\n  border-color: #1790ff;\n}\n";
21 21
 var styles = {
22 22
   "baseWrapper": "index_baseWrapper__1_-58",
23 23
   "controlBar": "index_controlBar__3SzSH",
24 24
   "editorContent": "index_editorContent__2UOaX",
25
-  "focus": "index_focus__puDJA",
26
-  "floatControls": "index_floatControls__2hVPf"
25
+  "focus": "index_focus__puDJA"
27 26
 };
28 27
 styleInject_es.styleInject(css);
29 28
 
@@ -41,24 +40,25 @@ var emotionOptions = {
41 40
 };
42 41
 BraftEditor.use(Emoticon__default(emotionOptions));
43 42
 var BarftEditorPage = function BarftEditorPage(_ref) {
44
-  var _classnames2;
45
-
46 43
   var value = _ref.value,
47 44
       onChange = _ref.onChange,
48 45
       controls = _ref.controls,
49 46
       _ref$contentStyle = _ref.contentStyle,
50 47
       contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
51
-      FloatControls = _ref.FloatControls,
52 48
       draftProps = _ref.draftProps,
53 49
       placeholder = _ref.placeholder,
54 50
       blockRenderMap = _ref.blockRenderMap,
55 51
       blockRendererFn = _ref.blockRendererFn,
52
+      onDelete = _ref.onDelete,
53
+      onSave = _ref.onSave,
54
+      onTab = _ref.onTab,
55
+      onFocus = _ref.onFocus,
56
+      onBlur = _ref.onBlur,
56 57
       converts = _ref.converts;
57 58
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
58 59
   var options = {
59 60
     controls: optionsControls,
60
-    showControlsBar: optionsControls && optionsControls.length > 0 && !FloatControls,
61
-    showFloatControls: FloatControls
61
+    showControlsBar: optionsControls && optionsControls.length > 0
62 62
   };
63 63
 
64 64
   var _useState = React.useState(false),
@@ -76,7 +76,7 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
76 76
     controlBarStyle: options.showControlsBar ? {} : {
77 77
       display: "none"
78 78
     },
79
-    contentClassName: index.classnames(styles.editorContent, (_classnames2 = {}, defineProperty._defineProperty(_classnames2, styles.focus, focusState), defineProperty._defineProperty(_classnames2, styles.hasFloatControls, options.showFloatControls), _classnames2)),
79
+    contentClassName: index.classnames(styles.editorContent, defineProperty._defineProperty({}, styles.focus, focusState)),
80 80
     contentStyle: contentStyle,
81 81
     onFocus: function onFocus() {
82 82
       return setFocusState(true);
@@ -100,13 +100,13 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
100 100
     blockRendererFn: blockRendererFn,
101 101
     converts: converts,
102 102
     placeholder: placeholder,
103
-    draftProps: draftProps
104
-  })), options.showFloatControls ? React__default.createElement("div", {
105
-    className: index.classnames(styles.floatControls)
106
-  }, React__default.createElement(FloatControls, {
107
-    editorState: value,
108
-    setEditorState: onChange
109
-  })) : null);
103
+    draftProps: draftProps,
104
+    onDelete: onDelete,
105
+    onSave: onSave,
106
+    onTab: onTab,
107
+    onFocus: onFocus,
108
+    onBlur: onBlur
109
+  })));
110 110
 };
111 111
 
112 112
 exports.BarftEditorPage = BarftEditorPage;

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


+ 25
- 23
lib/Editor/index.js View File

@@ -8,7 +8,7 @@ var React = require('react');
8 8
 var React__default = _interopDefault(React);
9 9
 var styleInject_es = require('../style-inject.es-dcee06b6.js');
10 10
 var defineProperty = require('../defineProperty-ba7cd53d.js');
11
-require('../index-4c407188.js');
11
+var index = require('../index-4c407188.js');
12 12
 require('../slicedToArray-172f4624.js');
13 13
 require('braft-editor');
14 14
 var BraftEditor$1 = require('../BraftEditor/index.js');
@@ -110,9 +110,11 @@ var ControlsToolBar = function ControlsToolBar(props) {
110 110
   }));
111 111
 };
112 112
 
113
-var css = ".index_bottomToolBarWrapper__DzhzC {\n  display: flex;\n}\n";
113
+var css = ".index_bottomToolBarWrapper__DzhzC {\n  display: flex;\n}\n.index_innerWrapper__1oX5A {\n  position: relative;\n}\n.index_innerWrapper__1oX5A .index_floatControls__16aMl {\n  position: absolute;\n  right: 15px;\n  bottom: 15px;\n  display: flex;\n  z-index: 2;\n}\n";
114 114
 var styles = {
115
-  "bottomToolBarWrapper": "index_bottomToolBarWrapper__DzhzC"
115
+  "bottomToolBarWrapper": "index_bottomToolBarWrapper__DzhzC",
116
+  "innerWrapper": "index_innerWrapper__1oX5A",
117
+  "floatControls": "index_floatControls__16aMl"
116 118
 };
117 119
 styleInject_es.styleInject(css);
118 120
 
@@ -120,7 +122,7 @@ var SimpleEditor = function SimpleEditor(props) {
120 122
   var value = props.value,
121 123
       onChange = props.onChange,
122 124
       _props$toolAlign = props.toolAlign,
123
-      toolAlign = _props$toolAlign === void 0 ? 'inner' : _props$toolAlign,
125
+      toolAlign = _props$toolAlign === void 0 ? "inner" : _props$toolAlign,
124 126
       _props$toolList = props.toolList,
125 127
       toolList = _props$toolList === void 0 ? [] : _props$toolList,
126 128
       _props$injectControls = props.injectControlsToolBar,
@@ -134,32 +136,32 @@ var SimpleEditor = function SimpleEditor(props) {
134 136
       _props$appendInnderBa = props.appendInnderBar,
135 137
       appendInnderBar = _props$appendInnderBa === void 0 ? null : _props$appendInnderBa;
136 138
 
137
-  if (toolAlign === 'inner') {
138
-    return React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
139
+  if (toolAlign === "inner") {
140
+    return React__default.createElement("div", {
141
+      className: styles.innerWrapper
142
+    }, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
139 143
       value: value,
140 144
       onChange: onChange,
141
-      controls: [],
142
-      FloatControls: function FloatControls(_ref) {
143
-        var editorState = _ref.editorState,
144
-            setEditorState = _ref.setEditorState;
145
-        return React__default.createElement(ControlsToolBar, Object.assign({
146
-          editorState: editorState,
147
-          setEditorState: setEditorState,
148
-          toolList: toolList
149
-        }, injectControlsToolBar));
150
-      }
151
-    }, injectBraftEditorProps));
145
+      controls: []
146
+    }, injectBraftEditorProps)), React__default.createElement("div", {
147
+      className: index.classnames(styles.floatControls)
148
+    }, React__default.createElement(ControlsToolBar, Object.assign({
149
+      editorState: value,
150
+      setEditorState: onChange,
151
+      toolList: toolList
152
+    }, injectControlsToolBar))));
152 153
   }
153 154
 
154
-  if (toolAlign === 'both') {
155
-    return React__default.createElement("div", null, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
155
+  if (toolAlign === "both") {
156
+    return React__default.createElement("div", null, React__default.createElement("div", {
157
+      className: styles.innerWrapper
158
+    }, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
156 159
       value: value,
157 160
       onChange: onChange,
158
-      controls: [],
159
-      FloatControls: function FloatControls() {
160
-        return appendInnderBar;
161
-      }
161
+      controls: []
162 162
     }, injectBraftEditorProps)), React__default.createElement("div", {
163
+      className: index.classnames(styles.floatControls)
164
+    }, appendInnderBar)), React__default.createElement("div", {
163 165
       style: toolBarContainerStyle
164 166
     }, React__default.createElement("div", {
165 167
       className: styles.bottomToolBarWrapper

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


+ 0
- 8
src/components/Editor/BraftEditor/index.less View File

@@ -20,12 +20,4 @@
20 20
       }
21 21
     }
22 22
   }
23
-
24
-  .floatControls {
25
-    position: absolute;
26
-    right: 15px;
27
-    bottom: 15px;
28
-    display: flex;
29
-    z-index: 2;
30
-  }
31 23
 }

+ 16
- 15
src/components/Editor/BraftEditor/index.tsx View File

@@ -41,10 +41,14 @@ export interface BaseEditorProps {
41 41
   onChange: (editorState: EditorState) => void;
42 42
   contentStyle?: React.CSSProperties;
43 43
   controls?: ControlType[];
44
-  FloatControls?: any;
45 44
   
46 45
   blockRenderMap?: any;
47 46
   blockRendererFn?: any;
47
+  onDelete?: Function;
48
+  onSave?: Function;
49
+  onTab?: Function;
50
+  onFocus?: Function;
51
+  onBlur?: Function;
48 52
   draftProps?: any;
49 53
   placeholder?: string;
50 54
   converts?: any;
@@ -55,11 +59,15 @@ export const BarftEditorPage = ({
55 59
   onChange,
56 60
   controls,
57 61
   contentStyle = {},
58
-  FloatControls,
59 62
   draftProps,
60 63
   placeholder,
61 64
   blockRenderMap,
62 65
   blockRendererFn,
66
+  onDelete,
67
+  onSave,
68
+  onTab,
69
+  onFocus,
70
+  onBlur,
63 71
   converts,
64 72
 }: BaseEditorProps) => {
65 73
   const optionsControls = controls
@@ -77,8 +85,7 @@ export const BarftEditorPage = ({
77 85
   const options: any = {
78 86
     controls: optionsControls,
79 87
     showControlsBar:
80
-      optionsControls && optionsControls.length > 0 && !FloatControls,
81
-    showFloatControls: FloatControls
88
+      optionsControls && optionsControls.length > 0,
82 89
   };
83 90
 
84 91
   const [focusState, setFocusState] = useState(false);
@@ -95,7 +102,6 @@ export const BarftEditorPage = ({
95 102
         controlBarStyle={options.showControlsBar ? {} : { display: "none" }}
96 103
         contentClassName={classnames(styles.editorContent, {
97 104
           [styles.focus]: focusState,
98
-          [styles.hasFloatControls]: options.showFloatControls
99 105
         })}
100 106
         contentStyle={contentStyle}
101 107
         onFocus={() => setFocusState(true)}
@@ -112,18 +118,13 @@ export const BarftEditorPage = ({
112 118
           converts,
113 119
           placeholder,
114 120
           draftProps,
121
+          onDelete,
122
+          onSave,
123
+          onTab,
124
+          onFocus,
125
+          onBlur,
115 126
         }}
116 127
       />
117
-      {options.showFloatControls ? (
118
-        <div className={classnames(styles.floatControls)}>
119
-          {
120
-            <FloatControls
121
-              editorState={value}
122
-              setEditorState={onChange}
123
-            />
124
-          }
125
-        </div>
126
-      ) : null}
127 128
     </div>
128 129
   );
129 130
 };

+ 44
- 32
src/components/Editor/ImgTxtEditor/SimpleEditor.tsx View File

@@ -1,11 +1,18 @@
1
-import React from 'react';
2
-import { BarftEditorPage, BaseEditorProps } from "@components/Editor/BraftEditor";
3
-import { ControlsToolBar, ToolListItem } from "@components/Editor/CommonTool/ControlsToolBar";
1
+import React from "react";
2
+import classnames from "classnames";
3
+import {
4
+  BarftEditorPage,
5
+  BaseEditorProps,
6
+} from "@components/Editor/BraftEditor";
7
+import {
8
+  ControlsToolBar,
9
+  ToolListItem,
10
+} from "@components/Editor/CommonTool/ControlsToolBar";
4 11
 import { ContentUtils } from "braft-utils";
5
-import styles from './index.less';
12
+import styles from "./index.less";
6 13
 
7 14
 interface SimpleEditorProps extends BaseEditorProps {
8
-  toolAlign?: 'inner' | 'bottom' | 'both';
15
+  toolAlign?: "inner" | "bottom" | "both";
9 16
   toolList?: Array<ToolListItem>;
10 17
   injectControlsToolBar?: any;
11 18
   injectBraftEditorProps?: any;
@@ -17,8 +24,8 @@ interface SimpleEditorProps extends BaseEditorProps {
17 24
 const SimpleEditor = (props: SimpleEditorProps) => {
18 25
   const {
19 26
     value,
20
-    onChange, 
21
-    toolAlign = 'inner',
27
+    onChange,
28
+    toolAlign = "inner",
22 29
     toolList = [],
23 30
     injectControlsToolBar = {},
24 31
     toolBarContainerStyle = {},
@@ -27,36 +34,41 @@ const SimpleEditor = (props: SimpleEditorProps) => {
27 34
     appendInnderBar = null,
28 35
   } = props;
29 36
 
30
-
31
-  if (toolAlign === 'inner') {
37
+  if (toolAlign === "inner") {
32 38
     return (
33
-      <BarftEditorPage
34
-        value={value}
35
-        onChange={onChange}
36
-        controls={[]}
37
-        FloatControls={({ editorState, setEditorState }: any) => (
39
+      <div className={styles.innerWrapper}>
40
+        <BarftEditorPage
41
+          value={value}
42
+          onChange={onChange}
43
+          controls={[]}
44
+          {...injectBraftEditorProps}
45
+        />
46
+        <div className={classnames(styles.floatControls)}>
38 47
           <ControlsToolBar
39
-            editorState={editorState}
40
-            setEditorState={setEditorState}
48
+            editorState={value}
49
+            setEditorState={onChange}
41 50
             toolList={toolList}
42 51
             {...injectControlsToolBar}
43
-          />)
44
-        }
45
-        {...injectBraftEditorProps}
46
-      />
47
-    )
52
+          />
53
+        </div>
54
+      </div>
55
+    );
48 56
   }
49 57
 
50
-  if (toolAlign === 'both') {
58
+  if (toolAlign === "both") {
51 59
     return (
52 60
       <div>
53
-        <BarftEditorPage
54
-          value={value}
55
-          onChange={onChange}
56
-          controls={[]}
57
-          FloatControls={() => appendInnderBar}
58
-          {...injectBraftEditorProps}
59
-        />
61
+        <div className={styles.innerWrapper}>
62
+          <BarftEditorPage
63
+            value={value}
64
+            onChange={onChange}
65
+            controls={[]}
66
+            {...injectBraftEditorProps}
67
+          />
68
+          <div className={classnames(styles.floatControls)}>
69
+            {appendInnderBar}
70
+          </div>
71
+        </div>
60 72
         <div style={toolBarContainerStyle}>
61 73
           <div className={styles.bottomToolBarWrapper}>
62 74
             <ControlsToolBar
@@ -69,7 +81,7 @@ const SimpleEditor = (props: SimpleEditorProps) => {
69 81
           {appendToolBtn}
70 82
         </div>
71 83
       </div>
72
-    )
84
+    );
73 85
   }
74 86
 
75 87
   return (
@@ -93,6 +105,6 @@ const SimpleEditor = (props: SimpleEditorProps) => {
93 105
       </div>
94 106
     </div>
95 107
   );
96
-}
108
+};
97 109
 
98
-export default SimpleEditor;
110
+export default SimpleEditor;

+ 11
- 0
src/components/Editor/ImgTxtEditor/index.less View File

@@ -1,3 +1,14 @@
1 1
 .bottomToolBarWrapper {
2 2
   display: flex;
3
+}
4
+.innerWrapper {
5
+  position: relative;
6
+
7
+  .floatControls {
8
+    position: absolute;
9
+    right: 15px;
10
+    bottom: 15px;
11
+    display: flex;
12
+    z-index: 2;
13
+  }
3 14
 }

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


+ 5
- 1
stories/Editor.stories.tsx View File

@@ -11,7 +11,7 @@ import { ControlsToolBar } from "@components/Editor/CommonTool/ControlsToolBar";
11 11
 import { ContentUtils } from "braft-utils";
12 12
 
13 13
 import EditorData from "./data/articleData.json";
14
-import { Divider, Popover, Checkbox } from "antd";
14
+import { Divider, Popover, Checkbox, Tooltip } from "antd";
15 15
 import BraftEditor from "braft-editor";
16 16
 
17 17
 import styles from './index.less';
@@ -193,6 +193,7 @@ stories.add(
193 193
           toolAlign={select("toolAlign", {
194 194
             Inner: 'inner',
195 195
             Bottom: 'bottom',
196
+            Both: 'both',
196 197
           }, "bottom")}
197 198
           toolBarContainerStyle={{
198 199
             display: 'flex',
@@ -228,6 +229,9 @@ stories.add(
228 229
               </div>
229 230
             </div>
230 231
           )}
232
+          appendInnderBar={(
233
+            <div><Tooltip visible={true} title="123">123</Tooltip></div>
234
+          )}
231 235
         />
232 236
       </>
233 237
     );