slate-react 0.112.0 → 0.112.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/dist/components/editable.d.ts.map +1 -1
- package/dist/index.es.js +19 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +18 -5
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2379,12 +2379,25 @@ var Editable = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
2379
2379
|
}, [onDOMSelectionChange, scheduleOnDOMSelectionChange, editor, onDOMBeforeInput, forwardedRef]);
|
|
2380
2380
|
useIsomorphicLayoutEffect(function () {
|
|
2381
2381
|
var window = ReactEditor.getWindow(editor);
|
|
2382
|
+
// COMPAT: In Chrome, `selectionchange` events can fire when <input> and
|
|
2383
|
+
// <textarea> elements are appended to the DOM, causing
|
|
2384
|
+
// `editor.selection` to be overwritten in some circumstances.
|
|
2385
|
+
// (2025/01/16) https://issues.chromium.org/issues/389368412
|
|
2386
|
+
var onSelectionChange = function onSelectionChange(_ref) {
|
|
2387
|
+
var target = _ref.target;
|
|
2388
|
+
var targetElement = target instanceof HTMLElement ? target : null;
|
|
2389
|
+
var targetTagName = targetElement === null || targetElement === void 0 ? void 0 : targetElement.tagName;
|
|
2390
|
+
if (targetTagName === 'INPUT' || targetTagName === 'TEXTAREA') {
|
|
2391
|
+
return;
|
|
2392
|
+
}
|
|
2393
|
+
scheduleOnDOMSelectionChange();
|
|
2394
|
+
};
|
|
2382
2395
|
// Attach a native DOM event handler for `selectionchange`, because React's
|
|
2383
2396
|
// built-in `onSelect` handler doesn't fire for all selection changes. It's
|
|
2384
2397
|
// a leaky polyfill that only fires on keypresses or clicks. Instead, we
|
|
2385
2398
|
// want to fire for any change to the selection inside the editor.
|
|
2386
2399
|
// (2019/11/04) https://github.com/facebook/react/issues/5785
|
|
2387
|
-
window.document.addEventListener('selectionchange',
|
|
2400
|
+
window.document.addEventListener('selectionchange', onSelectionChange);
|
|
2388
2401
|
// Listen for dragend and drop globally. In Firefox, if a drop handler
|
|
2389
2402
|
// initiates an operation that causes the originally dragged element to
|
|
2390
2403
|
// unmount, that element will not emit a dragend event. (2024/06/21)
|
|
@@ -2394,7 +2407,7 @@ var Editable = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
2394
2407
|
window.document.addEventListener('dragend', stoppedDragging);
|
|
2395
2408
|
window.document.addEventListener('drop', stoppedDragging);
|
|
2396
2409
|
return function () {
|
|
2397
|
-
window.document.removeEventListener('selectionchange',
|
|
2410
|
+
window.document.removeEventListener('selectionchange', onSelectionChange);
|
|
2398
2411
|
window.document.removeEventListener('dragend', stoppedDragging);
|
|
2399
2412
|
window.document.removeEventListener('drop', stoppedDragging);
|
|
2400
2413
|
};
|
|
@@ -3064,9 +3077,9 @@ var Editable = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
|
|
|
3064
3077
|
/**
|
|
3065
3078
|
* The default placeholder element
|
|
3066
3079
|
*/
|
|
3067
|
-
var DefaultPlaceholder = function DefaultPlaceholder(
|
|
3068
|
-
var attributes =
|
|
3069
|
-
children =
|
|
3080
|
+
var DefaultPlaceholder = function DefaultPlaceholder(_ref2) {
|
|
3081
|
+
var attributes = _ref2.attributes,
|
|
3082
|
+
children = _ref2.children;
|
|
3070
3083
|
return (
|
|
3071
3084
|
/*#__PURE__*/
|
|
3072
3085
|
// COMPAT: Artificially add a line-break to the end on the placeholder element
|