Procházet zdrojové kódy

fix: onFocus & onBlur state error

Roxas před 4 roky
rodič
revize
86af1b1fda

+ 7
- 6
eslib/BraftEditor/index.js Zobrazit soubor

@@ -45,8 +45,8 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
45 45
       onDelete = _ref.onDelete,
46 46
       onSave = _ref.onSave,
47 47
       onTab = _ref.onTab,
48
-      onFocus = _ref.onFocus,
49
-      onBlur = _ref.onBlur,
48
+      _onFocus = _ref.onFocus,
49
+      _onBlur = _ref.onBlur,
50 50
       converts = _ref.converts;
51 51
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
52 52
   var options = {
@@ -72,10 +72,12 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
72 72
     contentClassName: classnames(styles.editorContent, _defineProperty({}, styles.focus, focusState)),
73 73
     contentStyle: contentStyle,
74 74
     onFocus: function onFocus() {
75
-      return setFocusState(true);
75
+      setFocusState(true);
76
+      _onFocus && _onFocus();
76 77
     },
77 78
     onBlur: function onBlur() {
78
-      return setFocusState(false);
79
+      setFocusState(false);
80
+      _onBlur && _onBlur();
79 81
     },
80 82
     hooks: {
81 83
       "toggle-link": function toggleLink(_ref2) {
@@ -98,8 +100,7 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
98 100
     onDelete: onDelete,
99 101
     onSave: onSave,
100 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
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 7
- 6
lib/BraftEditor/index.js Zobrazit soubor

@@ -53,8 +53,8 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
53 53
       onDelete = _ref.onDelete,
54 54
       onSave = _ref.onSave,
55 55
       onTab = _ref.onTab,
56
-      onFocus = _ref.onFocus,
57
-      onBlur = _ref.onBlur,
56
+      _onFocus = _ref.onFocus,
57
+      _onBlur = _ref.onBlur,
58 58
       converts = _ref.converts;
59 59
   var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
60 60
   var options = {
@@ -80,10 +80,12 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
80 80
     contentClassName: index.classnames(styles.editorContent, defineProperty._defineProperty({}, styles.focus, focusState)),
81 81
     contentStyle: contentStyle,
82 82
     onFocus: function onFocus() {
83
-      return setFocusState(true);
83
+      setFocusState(true);
84
+      _onFocus && _onFocus();
84 85
     },
85 86
     onBlur: function onBlur() {
86
-      return setFocusState(false);
87
+      setFocusState(false);
88
+      _onBlur && _onBlur();
87 89
     },
88 90
     hooks: {
89 91
       "toggle-link": function toggleLink(_ref2) {
@@ -106,8 +108,7 @@ var BarftEditorPage = function BarftEditorPage(_ref) {
106 108
     onDelete: onDelete,
107 109
     onSave: onSave,
108 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
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 9
- 3
src/components/Editor/BraftEditor/index.tsx Zobrazit soubor

@@ -1,4 +1,5 @@
1 1
 import React, { useState } from "react";
2
+import axios from 'axios';
2 3
 import classnames from "classnames";
3 4
 import BraftEditor, { ControlType, EditorState } from "braft-editor";
4 5
 import styles from "./index.less";
@@ -106,8 +107,14 @@ export const BarftEditorPage = ({
106 107
           [styles.focus]: focusState,
107 108
         })}
108 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 118
         hooks={{
112 119
           "toggle-link": ({ href, target }) => {
113 120
             href = href.indexOf("http") === 0 ? href : `http://${href}`;
@@ -124,7 +131,6 @@ export const BarftEditorPage = ({
124 131
           onDelete,
125 132
           onSave,
126 133
           onTab,
127
-          onFocus,
128 134
           onBlur,
129 135
         }}
130 136
       />

+ 2
- 1
stats.html
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor