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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-editor.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/plugin/react-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AAEhF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAYlC,OAAO,EAEL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,cAAc,EAKf,MAAM,cAAc,CAAA;AAGrB;;GAEG;AAEH,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IACxC,kBAAkB,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAA;IACnD,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAA;IAC/C,eAAe,EAAE,CACf,IAAI,EAAE,YAAY,EAClB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,KAClC,IAAI,CAAA;IACT,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAA;CACzD;AAED,eAAO,MAAM,WAAW;IACtB;;OAEG;sBAEe,WAAW,GAAG,MAAM;IAQtC;;OAEG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,WAAW,QAAQ,IAAI,GAAG,WAAW;IAevD;;OAEG;uBAEgB,WAAW,SAAS,KAAK;IAgD5C;;;;;;;OAOG;uBAEgB,WAAW,SAAS,KAAK,GAAG,QAAQ;IA8BvD;;OAEG;wBAEiB,WAAW,WAAW,OAAO,GAAG,IAAI;IAgBxD;;OAEG;2BAEoB,WAAW,SAAS,GAAG,GAAG,KAAK;IAiEtD;;OAEG;4CAGO,WAAW;;;;IA0GrB;;OAEG;8CAGO,WAAW,YACT,QAAQ,GAAG,cAAc,GAAG,YAAY;;;;;;qBAyFnC,WAAW,SAAS,KAAK,GAAG,OAAO;CAMrD,CAAA"}
|
package/dist/slate-react.js
CHANGED
|
@@ -947,7 +947,11 @@
|
|
|
947
947
|
var text = props.text,
|
|
948
948
|
_props$isTrailing = props.isTrailing,
|
|
949
949
|
isTrailing = _props$isTrailing === void 0 ? false : _props$isTrailing;
|
|
950
|
-
var ref = React.useRef(null);
|
|
950
|
+
var ref = React.useRef(null);
|
|
951
|
+
|
|
952
|
+
var getTextContent = function getTextContent() {
|
|
953
|
+
return "".concat(text !== null && text !== void 0 ? text : '').concat(isTrailing ? '\n' : '');
|
|
954
|
+
}; // This is the actual text rendering boundary where we interface with the DOM
|
|
951
955
|
// The text is not rendered as part of the virtual DOM, as since we handle basic character insertions natively,
|
|
952
956
|
// updating the DOM is not a one way dataflow anymore. What we need here is not reconciliation and diffing
|
|
953
957
|
// with previous version of the virtual DOM, but rather diffing with the actual DOM element, and replace the DOM <span> content
|
|
@@ -956,16 +960,26 @@
|
|
|
956
960
|
// eg makes native spellcheck opt out from checking the text node.
|
|
957
961
|
// useLayoutEffect: updating our span before browser paint
|
|
958
962
|
|
|
963
|
+
|
|
959
964
|
useIsomorphicLayoutEffect(function () {
|
|
960
965
|
// null coalescing text to make sure we're not outputing "null" as a string in the extreme case it is nullish at runtime
|
|
961
|
-
var textWithTrailing =
|
|
966
|
+
var textWithTrailing = getTextContent();
|
|
962
967
|
|
|
963
968
|
if (ref.current && ref.current.textContent !== textWithTrailing) {
|
|
964
969
|
ref.current.textContent = textWithTrailing;
|
|
965
970
|
} // intentionally not specifying dependencies, so that this effect runs on every render
|
|
966
971
|
// as this effectively replaces "specifying the text in the virtual DOM under the <span> below" on each render
|
|
967
972
|
|
|
968
|
-
}); //
|
|
973
|
+
}); // Render text content immediately if it's the first-time render
|
|
974
|
+
// Ensure that text content is rendered on server-side rendering
|
|
975
|
+
|
|
976
|
+
if (!ref.current) {
|
|
977
|
+
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
978
|
+
"data-slate-string": true,
|
|
979
|
+
ref: ref
|
|
980
|
+
}, getTextContent());
|
|
981
|
+
} // the span is intentionally same on every render in virtual DOM, actual rendering happens in the layout effect above
|
|
982
|
+
|
|
969
983
|
|
|
970
984
|
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
971
985
|
"data-slate-string": true,
|
|
@@ -2302,6 +2316,7 @@
|
|
|
2302
2316
|
// triggering a `beforeinput` expecting the change to be applied to the immediately before
|
|
2303
2317
|
// set selection.
|
|
2304
2318
|
scheduleOnDOMSelectionChange.flush();
|
|
2319
|
+
onDOMSelectionChange.flush();
|
|
2305
2320
|
var selection = editor.selection;
|
|
2306
2321
|
var type = event.inputType;
|
|
2307
2322
|
var data = event.dataTransfer || event.data || undefined; // These two types occur while a user is composing text and can't be
|
|
@@ -3984,22 +3999,25 @@
|
|
|
3984
3999
|
|
|
3985
4000
|
if (leafNode) {
|
|
3986
4001
|
textNode = leafNode.closest('[data-slate-node="text"]');
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4002
|
+
|
|
4003
|
+
if (textNode) {
|
|
4004
|
+
var window = ReactEditor.getWindow(editor);
|
|
4005
|
+
var range = window.document.createRange();
|
|
4006
|
+
range.setStart(textNode, 0);
|
|
4007
|
+
range.setEnd(nearestNode, nearestOffset);
|
|
4008
|
+
var contents = range.cloneContents();
|
|
4009
|
+
var removals = [].concat(_toConsumableArray(Array.prototype.slice.call(contents.querySelectorAll('[data-slate-zero-width]'))), _toConsumableArray(Array.prototype.slice.call(contents.querySelectorAll('[contenteditable=false]'))));
|
|
4010
|
+
removals.forEach(function (el) {
|
|
4011
|
+
el.parentNode.removeChild(el);
|
|
4012
|
+
}); // COMPAT: Edge has a bug where Range.prototype.toString() will
|
|
4013
|
+
// convert \n into \r\n. The bug causes a loop when slate-react
|
|
4014
|
+
// attempts to reposition its cursor to match the native position. Use
|
|
4015
|
+
// textContent.length instead.
|
|
4016
|
+
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10291116/
|
|
4017
|
+
|
|
4018
|
+
offset = contents.textContent.length;
|
|
4019
|
+
domNode = textNode;
|
|
4020
|
+
}
|
|
4003
4021
|
} else if (voidNode) {
|
|
4004
4022
|
// For void nodes, the element with the offset key will be a cousin, not an
|
|
4005
4023
|
// ancestor, so find it by going down from the nearest void parent.
|