@portabletext/editor 6.6.4 → 6.6.5
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/lib/index.js +7 -5
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3990,13 +3990,15 @@ const RestoreDOM = IS_ANDROID ? RestoreDOMComponent : ({
|
|
|
3990
3990
|
}
|
|
3991
3991
|
}
|
|
3992
3992
|
if ((!type.startsWith("delete") || type.startsWith("deleteBy")) && !editor.isNodeMapDirty) {
|
|
3993
|
-
const [targetRange2] = event.getTargetRanges();
|
|
3994
|
-
if (
|
|
3995
|
-
const range2 = ReactEditor.toSlateRange(editor,
|
|
3993
|
+
const [targetRange2] = event.getTargetRanges(), domSelection = getSelection(ReactEditor.findDocumentOrShadowRoot(editor)), inputTarget = targetRange2 ?? (domSelection && domSelection.rangeCount > 0 ? domSelection : void 0);
|
|
3994
|
+
if (inputTarget) {
|
|
3995
|
+
const range2 = ReactEditor.toSlateRange(editor, inputTarget, {
|
|
3996
3996
|
exactMatch: !1,
|
|
3997
|
-
|
|
3997
|
+
// The DOM selection fallback is not guaranteed to be a valid
|
|
3998
|
+
// Slate range, so don't throw on it.
|
|
3999
|
+
suppressThrow: !targetRange2
|
|
3998
4000
|
});
|
|
3999
|
-
if (!selection || !rangeEquals(selection, range2)) {
|
|
4001
|
+
if (range2 && (!selection || !rangeEquals(selection, range2))) {
|
|
4000
4002
|
native = !1;
|
|
4001
4003
|
const selectionRef = !isCompositionChange && editor.selection && rangeRef(editor, editor.selection);
|
|
4002
4004
|
editor.select(range2), selectionRef && (editor.userSelection = selectionRef);
|