slate-react 0.72.6 → 0.72.7-202202811645
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/CHANGELOG.md +10 -0
- package/dist/components/editable.d.ts.map +1 -1
- package/dist/components/string.d.ts.map +1 -1
- package/dist/index.es.js +37 -19
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +37 -19
- package/dist/index.js.map +1 -1
- package/dist/plugin/react-editor.d.ts.map +1 -1
- package/dist/slate-react.js +37 -19
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# slate-react
|
|
2
2
|
|
|
3
|
+
## 0.72.7-202202811645
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4813](https://github.com/ianstormtaylor/slate/pull/4813) [`a5fd62dd`](https://github.com/ianstormtaylor/slate/commit/a5fd62ddd646553841a54616f7a5528e310bfd22) Thanks [@BitPhinix](https://github.com/BitPhinix)! - Don't throw in toSlatePoint while using supressThrow if leaf has no text node
|
|
8
|
+
|
|
9
|
+
* [#4798](https://github.com/ianstormtaylor/slate/pull/4798) [`3796c514`](https://github.com/ianstormtaylor/slate/commit/3796c514d6da0db8656486151147d92e73a2350a) Thanks [@hueyhe](https://github.com/hueyhe)! - Fix text not rendered on ssr
|
|
10
|
+
|
|
11
|
+
- [#4809](https://github.com/ianstormtaylor/slate/pull/4809) [`e9987529`](https://github.com/ianstormtaylor/slate/commit/e9987529895d3ef2740f8f466a9ef9ce4c3e37c2) Thanks [@BitPhinix](https://github.com/BitPhinix)! - Flush onDOMSelectionChange on onDOMBeforeInput
|
|
12
|
+
|
|
3
13
|
## 0.72.6
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/editable.tsx"],"names":[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AK,KAAK,EAAa,CAAA;AAyBtE;;GAEG;AAEH,eAAO,MAAM,YAAY,MAAO,QAAQ,KAAK,QAAQ,YAWpD,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,SAAS,WACZ,WAAW,UACX,WAAW,GAAG,IAAI,sBAG3B,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,iBAAiB,WACpB,WAAW,UACX,WAAW,GAAG,IAAI,sBAM3B,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,6BAA6B,WAChC,WAAW,UACX,WAAW,GAAG,IAAI,KACzB,OAMF,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,cAAc,gHAIO,IAAI,GAAG,OAAO,yBAc/C,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,iBAAiB,uDAEJ,IAAI,GAAG,OAAO,yBAevC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/string.tsx"],"names":[],"mappings":";AACA,OAAO,EAAU,IAAI,EAAQ,OAAO,EAAQ,MAAM,OAAO,CAAA;AAKzD;;GAEG;AAEH,QAAA,MAAM,MAAM,UAAW;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;CACX,gBAsCA,CAAA;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/string.tsx"],"names":[],"mappings":";AACA,OAAO,EAAU,IAAI,EAAQ,OAAO,EAAQ,MAAM,OAAO,CAAA;AAKzD;;GAEG;AAEH,QAAA,MAAM,MAAM,UAAW;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;CACX,gBAsCA,CAAA;AAkED,eAAe,MAAM,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -151,7 +151,11 @@ var TextString = props => {
|
|
|
151
151
|
text,
|
|
152
152
|
isTrailing = false
|
|
153
153
|
} = props;
|
|
154
|
-
var ref = useRef(null);
|
|
154
|
+
var ref = useRef(null);
|
|
155
|
+
|
|
156
|
+
var getTextContent = () => {
|
|
157
|
+
return "".concat(text !== null && text !== void 0 ? text : '').concat(isTrailing ? '\n' : '');
|
|
158
|
+
}; // This is the actual text rendering boundary where we interface with the DOM
|
|
155
159
|
// The text is not rendered as part of the virtual DOM, as since we handle basic character insertions natively,
|
|
156
160
|
// updating the DOM is not a one way dataflow anymore. What we need here is not reconciliation and diffing
|
|
157
161
|
// with previous version of the virtual DOM, but rather diffing with the actual DOM element, and replace the DOM <span> content
|
|
@@ -160,16 +164,26 @@ var TextString = props => {
|
|
|
160
164
|
// eg makes native spellcheck opt out from checking the text node.
|
|
161
165
|
// useLayoutEffect: updating our span before browser paint
|
|
162
166
|
|
|
167
|
+
|
|
163
168
|
useIsomorphicLayoutEffect(() => {
|
|
164
169
|
// null coalescing text to make sure we're not outputing "null" as a string in the extreme case it is nullish at runtime
|
|
165
|
-
var textWithTrailing =
|
|
170
|
+
var textWithTrailing = getTextContent();
|
|
166
171
|
|
|
167
172
|
if (ref.current && ref.current.textContent !== textWithTrailing) {
|
|
168
173
|
ref.current.textContent = textWithTrailing;
|
|
169
174
|
} // intentionally not specifying dependencies, so that this effect runs on every render
|
|
170
175
|
// as this effectively replaces "specifying the text in the virtual DOM under the <span> below" on each render
|
|
171
176
|
|
|
172
|
-
}); //
|
|
177
|
+
}); // Render text content immediately if it's the first-time render
|
|
178
|
+
// Ensure that text content is rendered on server-side rendering
|
|
179
|
+
|
|
180
|
+
if (!ref.current) {
|
|
181
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
182
|
+
"data-slate-string": true,
|
|
183
|
+
ref: ref
|
|
184
|
+
}, getTextContent());
|
|
185
|
+
} // the span is intentionally same on every render in virtual DOM, actual rendering happens in the layout effect above
|
|
186
|
+
|
|
173
187
|
|
|
174
188
|
return /*#__PURE__*/React.createElement("span", {
|
|
175
189
|
"data-slate-string": true,
|
|
@@ -1190,6 +1204,7 @@ var Editable$1 = props => {
|
|
|
1190
1204
|
// triggering a `beforeinput` expecting the change to be applied to the immediately before
|
|
1191
1205
|
// set selection.
|
|
1192
1206
|
scheduleOnDOMSelectionChange.flush();
|
|
1207
|
+
onDOMSelectionChange.flush();
|
|
1193
1208
|
var {
|
|
1194
1209
|
selection
|
|
1195
1210
|
} = editor;
|
|
@@ -2810,22 +2825,25 @@ var ReactEditor = {
|
|
|
2810
2825
|
|
|
2811
2826
|
if (leafNode) {
|
|
2812
2827
|
textNode = leafNode.closest('[data-slate-node="text"]');
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2828
|
+
|
|
2829
|
+
if (textNode) {
|
|
2830
|
+
var window = ReactEditor.getWindow(editor);
|
|
2831
|
+
var range = window.document.createRange();
|
|
2832
|
+
range.setStart(textNode, 0);
|
|
2833
|
+
range.setEnd(nearestNode, nearestOffset);
|
|
2834
|
+
var contents = range.cloneContents();
|
|
2835
|
+
var removals = [...Array.prototype.slice.call(contents.querySelectorAll('[data-slate-zero-width]')), ...Array.prototype.slice.call(contents.querySelectorAll('[contenteditable=false]'))];
|
|
2836
|
+
removals.forEach(el => {
|
|
2837
|
+
el.parentNode.removeChild(el);
|
|
2838
|
+
}); // COMPAT: Edge has a bug where Range.prototype.toString() will
|
|
2839
|
+
// convert \n into \r\n. The bug causes a loop when slate-react
|
|
2840
|
+
// attempts to reposition its cursor to match the native position. Use
|
|
2841
|
+
// textContent.length instead.
|
|
2842
|
+
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10291116/
|
|
2843
|
+
|
|
2844
|
+
offset = contents.textContent.length;
|
|
2845
|
+
domNode = textNode;
|
|
2846
|
+
}
|
|
2829
2847
|
} else if (voidNode) {
|
|
2830
2848
|
// For void nodes, the element with the offset key will be a cousin, not an
|
|
2831
2849
|
// ancestor, so find it by going down from the nearest void parent.
|