Browse Source

fix: onFocus & onBlur state error

Roxas 4 years ago
parent
commit
86af1b1fda

+ 7
- 6
eslib/BraftEditor/index.js View File

45
       onDelete = _ref.onDelete,
45
       onDelete = _ref.onDelete,
46
       onSave = _ref.onSave,
46
       onSave = _ref.onSave,
47
       onTab = _ref.onTab,
47
       onTab = _ref.onTab,
48
-      onFocus = _ref.onFocus,
49
-      onBlur = _ref.onBlur,
48
+      _onFocus = _ref.onFocus,
49
+      _onBlur = _ref.onBlur,
50
       converts = _ref.converts;
50
       converts = _ref.converts;
51
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
51
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
52
   var options = {
52
   var options = {
72
     contentClassName: classnames(styles.editorContent, _defineProperty({}, styles.focus, focusState)),
72
     contentClassName: classnames(styles.editorContent, _defineProperty({}, styles.focus, focusState)),
73
     contentStyle: contentStyle,
73
     contentStyle: contentStyle,
74
     onFocus: function onFocus() {
74
     onFocus: function onFocus() {
75
-      return setFocusState(true);
75
+      setFocusState(true);
76
+      _onFocus && _onFocus();
76
     },
77
     },
77
     onBlur: function onBlur() {
78
     onBlur: function onBlur() {
78
-      return setFocusState(false);
79
+      setFocusState(false);
80
+      _onBlur && _onBlur();
79
     },
81
     },
80
     hooks: {
82
     hooks: {
81
       "toggle-link": function toggleLink(_ref2) {
83
       "toggle-link": function toggleLink(_ref2) {
98
     onDelete: onDelete,
100
     onDelete: onDelete,
99
     onSave: onSave,
101
     onSave: onSave,
100
     onTab: onTab,
102
     onTab: onTab,
101
-    onFocus: onFocus,
102
-    onBlur: onBlur
103
+    onBlur: _onBlur
103
   })));
104
   })));
104
 };
105
 };
105
 
106
 

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


+ 7
- 6
lib/BraftEditor/index.js View File

53
       onDelete = _ref.onDelete,
53
       onDelete = _ref.onDelete,
54
       onSave = _ref.onSave,
54
       onSave = _ref.onSave,
55
       onTab = _ref.onTab,
55
       onTab = _ref.onTab,
56
-      onFocus = _ref.onFocus,
57
-      onBlur = _ref.onBlur,
56
+      _onFocus = _ref.onFocus,
57
+      _onBlur = _ref.onBlur,
58
       converts = _ref.converts;
58
       converts = _ref.converts;
59
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
59
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
60
   var options = {
60
   var options = {
80
     contentClassName: index.classnames(styles.editorContent, defineProperty._defineProperty({}, styles.focus, focusState)),
80
     contentClassName: index.classnames(styles.editorContent, defineProperty._defineProperty({}, styles.focus, focusState)),
81
     contentStyle: contentStyle,
81
     contentStyle: contentStyle,
82
     onFocus: function onFocus() {
82
     onFocus: function onFocus() {
83
-      return setFocusState(true);
83
+      setFocusState(true);
84
+      _onFocus && _onFocus();
84
     },
85
     },
85
     onBlur: function onBlur() {
86
     onBlur: function onBlur() {
86
-      return setFocusState(false);
87
+      setFocusState(false);
88
+      _onBlur && _onBlur();
87
     },
89
     },
88
     hooks: {
90
     hooks: {
89
       "toggle-link": function toggleLink(_ref2) {
91
       "toggle-link": function toggleLink(_ref2) {
106
     onDelete: onDelete,
108
     onDelete: onDelete,
107
     onSave: onSave,
109
     onSave: onSave,
108
     onTab: onTab,
110
     onTab: onTab,
109
-    onFocus: onFocus,
110
-    onBlur: onBlur
111
+    onBlur: _onBlur
111
   })));
112
   })));
112
 };
113
 };
113
 
114
 

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


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

1
 import React, { useState } from "react";
1
 import React, { useState } from "react";
2
+import axios from 'axios';
2
 import classnames from "classnames";
3
 import classnames from "classnames";
3
 import BraftEditor, { ControlType, EditorState } from "braft-editor";
4
 import BraftEditor, { ControlType, EditorState } from "braft-editor";
4
 import styles from "./index.less";
5
 import styles from "./index.less";
106
           [styles.focus]: focusState,
107
           [styles.focus]: focusState,
107
         })}
108
         })}
108
         contentStyle={contentStyle}
109
         contentStyle={contentStyle}
109
-        onFocus={() => setFocusState(true)}
110
-        onBlur={() => setFocusState(false)}
110
+        onFocus={() => {
111
+          setFocusState(true)
112
+          onFocus && onFocus();
113
+        }}
114
+        onBlur={() => {
115
+          setFocusState(false);
116
+          onBlur && onBlur();
117
+        }}
111
         hooks={{
118
         hooks={{
112
           "toggle-link": ({ href, target }) => {
119
           "toggle-link": ({ href, target }) => {
113
             href = href.indexOf("http") === 0 ? href : `http://${href}`;
120
             href = href.indexOf("http") === 0 ? href : `http://${href}`;
124
           onDelete,
131
           onDelete,
125
           onSave,
132
           onSave,
126
           onTab,
133
           onTab,
127
-          onFocus,
128
           onBlur,
134
           onBlur,
129
         }}
135
         }}
130
       />
136
       />

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