payload 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -85,6 +85,23 @@ const RichText = (props) => {
|
|
|
85
85
|
CreatedEditor = enablePlugins(CreatedEditor, leaves);
|
|
86
86
|
return CreatedEditor;
|
|
87
87
|
}, [elements, leaves]);
|
|
88
|
+
// All slate changes fire the onChange event
|
|
89
|
+
// including selection changes
|
|
90
|
+
// so we will filter the set_selection operations out
|
|
91
|
+
// and only fire setValue when onChange is because of value
|
|
92
|
+
const handleChange = useCallback((val) => {
|
|
93
|
+
const ops = editor.operations.filter((o) => {
|
|
94
|
+
if (o) {
|
|
95
|
+
return o.type !== 'set_selection';
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
});
|
|
99
|
+
if (ops && Array.isArray(ops) && ops.length > 0) {
|
|
100
|
+
if (!readOnly && val !== defaultValue && val !== value) {
|
|
101
|
+
setValue(val);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, [editor.operations, readOnly, setValue, value]);
|
|
88
105
|
useEffect(() => {
|
|
89
106
|
if (!loaded) {
|
|
90
107
|
const mergedElements = mergeCustomFunctions(elements, elementTypes);
|
|
@@ -149,11 +166,7 @@ const RichText = (props) => {
|
|
|
149
166
|
React.createElement("div", { className: `${baseClass}__wrap` },
|
|
150
167
|
React.createElement(Error, { showError: showError, message: errorMessage }),
|
|
151
168
|
React.createElement(Label, { htmlFor: `field-${path.replace(/\./gi, '__')}`, label: label, required: required }),
|
|
152
|
-
React.createElement(Slate, { editor: editor, value: valueToRender, onChange:
|
|
153
|
-
if (!readOnly && val !== defaultValue && val !== value) {
|
|
154
|
-
setValue(val);
|
|
155
|
-
}
|
|
156
|
-
} },
|
|
169
|
+
React.createElement(Slate, { editor: editor, value: valueToRender, onChange: handleChange },
|
|
157
170
|
React.createElement("div", { className: `${baseClass}__wrapper` },
|
|
158
171
|
React.createElement("div", { className: [
|
|
159
172
|
`${baseClass}__toolbar`,
|