Browse Source

dev: Editor追加内容样式编辑

Roxas 4 years ago
parent
commit
2e56a16dcc

+ 3
- 1
eslib/BraftEditor/index.d.ts View File

@@ -1,10 +1,12 @@
1 1
 /// <reference types="react" />
2
+import React from "react";
2 3
 import { ControlType, EditorState } from "braft-editor";
3 4
 interface BaseEditorProps {
4 5
     value: EditorState;
5 6
     onChange: (editorState: EditorState) => void;
7
+    contentStyle?: React.CSSProperties;
6 8
     controls?: ControlType[];
7 9
     FloatControls?: any;
8 10
 }
9
-declare const BarftEditorPage: ({ value, onChange, controls, FloatControls }: BaseEditorProps) => JSX.Element;
11
+declare const BarftEditorPage: ({ value, onChange, controls, contentStyle, FloatControls }: BaseEditorProps) => JSX.Element;
10 12
 export { BarftEditorPage as default, BarftEditorPage, BaseEditorProps };

+ 3
- 1
eslib/BraftEditor/index.js View File

@@ -38,6 +38,8 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
38 38
   var value = _ref.value,
39 39
       onChange = _ref.onChange,
40 40
       controls = _ref.controls,
41
+      _ref$contentStyle = _ref.contentStyle,
42
+      contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
41 43
       FloatControls = _ref.FloatControls;
42 44
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
43 45
   var options = {
@@ -62,7 +64,7 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
62 64
       display: "none"
63 65
     },
64 66
     contentClassName: classnames(styles.editorContent, (_classnames2 = {}, _defineProperty(_classnames2, styles.focus, focusState), _defineProperty(_classnames2, styles.hasFloatControls, options.showFloatControls), _classnames2)),
65
-    contentStyle: {},
67
+    contentStyle: contentStyle,
66 68
     onFocus: function onFocus() {
67 69
       return setFocusState(true);
68 70
     },

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


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

@@ -13,6 +13,7 @@ interface SimpleEditorProps extends BaseEditorProps {
13 13
     toolAlign?: "inner" | "bottom";
14 14
     toolList?: Array<ToolListItem>;
15 15
     injectControlsToolBar?: any;
16
+    injectBraftEditorProps?: any;
16 17
     toolBarContainerStyle?: any;
17 18
     appendToolBtn?: any;
18 19
 }

+ 4
- 2
eslib/Editor/index.js View File

@@ -120,6 +120,8 @@ var SimpleEditor = function SimpleEditor(props) {
120 120
       injectControlsToolBar = _props$injectControls === void 0 ? {} : _props$injectControls,
121 121
       _props$toolBarContain = props.toolBarContainerStyle,
122 122
       toolBarContainerStyle = _props$toolBarContain === void 0 ? {} : _props$toolBarContain,
123
+      _props$injectBraftEdi = props.injectBraftEditorProps,
124
+      injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
123 125
       _props$appendToolBtn = props.appendToolBtn,
124 126
       appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn;
125 127
 
@@ -140,11 +142,11 @@ var SimpleEditor = function SimpleEditor(props) {
140 142
     });
141 143
   }
142 144
 
143
-  return React.createElement("div", null, React.createElement(BarftEditorPage, {
145
+  return React.createElement("div", null, React.createElement(BarftEditorPage, Object.assign({
144 146
     value: value,
145 147
     onChange: onChange,
146 148
     controls: []
147
-  }), React.createElement("div", {
149
+  }, injectBraftEditorProps)), React.createElement("div", {
148 150
     style: toolBarContainerStyle
149 151
   }, React.createElement("div", {
150 152
     className: styles.bottomToolBarWrapper

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


+ 3
- 1
lib/BraftEditor/index.d.ts View File

@@ -1,10 +1,12 @@
1 1
 /// <reference types="react" />
2
+import React from "react";
2 3
 import { ControlType, EditorState } from "braft-editor";
3 4
 interface BaseEditorProps {
4 5
     value: EditorState;
5 6
     onChange: (editorState: EditorState) => void;
7
+    contentStyle?: React.CSSProperties;
6 8
     controls?: ControlType[];
7 9
     FloatControls?: any;
8 10
 }
9
-declare const BarftEditorPage: ({ value, onChange, controls, FloatControls }: BaseEditorProps) => JSX.Element;
11
+declare const BarftEditorPage: ({ value, onChange, controls, contentStyle, FloatControls }: BaseEditorProps) => JSX.Element;
10 12
 export { BarftEditorPage as default, BarftEditorPage, BaseEditorProps };

+ 3
- 1
lib/BraftEditor/index.js View File

@@ -46,6 +46,8 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
46 46
   var value = _ref.value,
47 47
       onChange = _ref.onChange,
48 48
       controls = _ref.controls,
49
+      _ref$contentStyle = _ref.contentStyle,
50
+      contentStyle = _ref$contentStyle === void 0 ? {} : _ref$contentStyle,
49 51
       FloatControls = _ref.FloatControls;
50 52
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
51 53
   var options = {
@@ -70,7 +72,7 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
70 72
       display: "none"
71 73
     },
72 74
     contentClassName: index.classnames(styles.editorContent, (_classnames2 = {}, defineProperty._defineProperty(_classnames2, styles.focus, focusState), defineProperty._defineProperty(_classnames2, styles.hasFloatControls, options.showFloatControls), _classnames2)),
73
-    contentStyle: {},
75
+    contentStyle: contentStyle,
74 76
     onFocus: function onFocus() {
75 77
       return setFocusState(true);
76 78
     },

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


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

@@ -13,6 +13,7 @@ interface SimpleEditorProps extends BaseEditorProps {
13 13
     toolAlign?: "inner" | "bottom";
14 14
     toolList?: Array<ToolListItem>;
15 15
     injectControlsToolBar?: any;
16
+    injectBraftEditorProps?: any;
16 17
     toolBarContainerStyle?: any;
17 18
     appendToolBtn?: any;
18 19
 }

+ 4
- 2
lib/Editor/index.js View File

@@ -126,6 +126,8 @@ var SimpleEditor = function SimpleEditor(props) {
126 126
       injectControlsToolBar = _props$injectControls === void 0 ? {} : _props$injectControls,
127 127
       _props$toolBarContain = props.toolBarContainerStyle,
128 128
       toolBarContainerStyle = _props$toolBarContain === void 0 ? {} : _props$toolBarContain,
129
+      _props$injectBraftEdi = props.injectBraftEditorProps,
130
+      injectBraftEditorProps = _props$injectBraftEdi === void 0 ? {} : _props$injectBraftEdi,
129 131
       _props$appendToolBtn = props.appendToolBtn,
130 132
       appendToolBtn = _props$appendToolBtn === void 0 ? null : _props$appendToolBtn;
131 133
 
@@ -146,11 +148,11 @@ var SimpleEditor = function SimpleEditor(props) {
146 148
     });
147 149
   }
148 150
 
149
-  return React__default.createElement("div", null, React__default.createElement(BraftEditor$1.BarftEditorPage, {
151
+  return React__default.createElement("div", null, React__default.createElement(BraftEditor$1.BarftEditorPage, Object.assign({
150 152
     value: value,
151 153
     onChange: onChange,
152 154
     controls: []
153
-  }), React__default.createElement("div", {
155
+  }, injectBraftEditorProps)), React__default.createElement("div", {
154 156
     style: toolBarContainerStyle
155 157
   }, React__default.createElement("div", {
156 158
     className: styles.bottomToolBarWrapper

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


+ 3
- 1
src/components/Editor/BraftEditor/index.tsx View File

@@ -39,6 +39,7 @@ BraftEditor.use(Emoticon(emotionOptions));
39 39
 export interface BaseEditorProps {
40 40
   value: EditorState;
41 41
   onChange: (editorState: EditorState) => void;
42
+  contentStyle?: React.CSSProperties;
42 43
   controls?: ControlType[];
43 44
   FloatControls?: any;
44 45
 }
@@ -47,6 +48,7 @@ export const BarftEditorPage = ({
47 48
   value,
48 49
   onChange,
49 50
   controls,
51
+  contentStyle = {},
50 52
   FloatControls
51 53
 }: BaseEditorProps) => {
52 54
   const optionsControls = controls
@@ -84,7 +86,7 @@ export const BarftEditorPage = ({
84 86
           [styles.focus]: focusState,
85 87
           [styles.hasFloatControls]: options.showFloatControls
86 88
         })}
87
-        contentStyle={{}}
89
+        contentStyle={contentStyle}
88 90
         onFocus={() => setFocusState(true)}
89 91
         onBlur={() => setFocusState(false)}
90 92
         hooks={{

+ 3
- 0
src/components/Editor/ImgTxtEditor/SimpleEditor.tsx View File

@@ -8,6 +8,7 @@ interface SimpleEditorProps extends BaseEditorProps {
8 8
   toolAlign?: 'inner' | 'bottom';
9 9
   toolList?: Array<ToolListItem>;
10 10
   injectControlsToolBar?: any;
11
+  injectBraftEditorProps?: any;
11 12
   toolBarContainerStyle?: any;
12 13
   appendToolBtn?: any;
13 14
 }
@@ -20,6 +21,7 @@ const SimpleEditor = (props: SimpleEditorProps) => {
20 21
     toolList = [],
21 22
     injectControlsToolBar = {},
22 23
     toolBarContainerStyle = {},
24
+    injectBraftEditorProps = {},
23 25
     appendToolBtn = null,
24 26
   } = props;
25 27
 
@@ -47,6 +49,7 @@ const SimpleEditor = (props: SimpleEditorProps) => {
47 49
         value={value}
48 50
         onChange={onChange}
49 51
         controls={[]}
52
+        {...injectBraftEditorProps}
50 53
       />
51 54
       <div style={toolBarContainerStyle}>
52 55
         <div className={styles.bottomToolBarWrapper}>

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


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

@@ -121,6 +121,11 @@ stories.add(
121 121
           value={editorState}
122 122
           onChange={setEditorState}
123 123
           controls={[]}
124
+          injectBraftEditorProps={{
125
+            contentStyle: {
126
+              height: '150px'
127
+            },
128
+          }}
124 129
           toolList={[
125 130
             {
126 131
               key: 1,