slate-react 0.119.0 → 0.120.0-20251121000717
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/index.es.js +10 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +10 -8
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -3791,13 +3791,15 @@ var defaultDecorate = () => [];
|
|
|
3791
3791
|
* A default implement to scroll dom range into view.
|
|
3792
3792
|
*/
|
|
3793
3793
|
var defaultScrollSelectionIntoView = (editor, domRange) => {
|
|
3794
|
-
//
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3794
|
+
// Scroll to the focus point of the selection, in case the selection is expanded
|
|
3795
|
+
var isBackward = !!editor.selection && Range.isBackward(editor.selection);
|
|
3796
|
+
var domFocusPoint = domRange.cloneRange();
|
|
3797
|
+
domFocusPoint.collapse(isBackward);
|
|
3798
|
+
if (domFocusPoint.getBoundingClientRect) {
|
|
3799
|
+
var leafEl = domFocusPoint.startContainer.parentElement;
|
|
3800
|
+
// COMPAT: In Chrome, domFocusPoint.getBoundingClientRect() can return zero dimensions for valid ranges (e.g. line breaks).
|
|
3799
3801
|
// When this happens, do not scroll like most editors do.
|
|
3800
|
-
var domRect =
|
|
3802
|
+
var domRect = domFocusPoint.getBoundingClientRect();
|
|
3801
3803
|
var isZeroDimensionRect = domRect.width === 0 && domRect.height === 0 && domRect.x === 0 && domRect.y === 0;
|
|
3802
3804
|
if (isZeroDimensionRect) {
|
|
3803
3805
|
var leafRect = leafEl.getBoundingClientRect();
|
|
@@ -3806,8 +3808,8 @@ var defaultScrollSelectionIntoView = (editor, domRange) => {
|
|
|
3806
3808
|
return;
|
|
3807
3809
|
}
|
|
3808
3810
|
}
|
|
3809
|
-
// Default behavior: use
|
|
3810
|
-
leafEl.getBoundingClientRect =
|
|
3811
|
+
// Default behavior: use domFocusPoint's getBoundingClientRect
|
|
3812
|
+
leafEl.getBoundingClientRect = domFocusPoint.getBoundingClientRect.bind(domFocusPoint);
|
|
3811
3813
|
scrollIntoView(leafEl, {
|
|
3812
3814
|
scrollMode: 'if-needed'
|
|
3813
3815
|
});
|