slate-react 0.76.0 → 0.76.1-2022231112432
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 +0 -4
- package/dist/components/editable.d.ts.map +1 -1
- package/dist/index.es.js +27 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/with-react.d.ts.map +1 -1
- package/dist/slate-react.js +27 -0
- package/dist/slate-react.min.js +1 -1
- package/dist/utils/weak-maps.d.ts +2 -1
- package/dist/utils/weak-maps.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -417,6 +417,7 @@ var IS_READ_ONLY = new WeakMap();
|
|
|
417
417
|
var IS_FOCUSED = new WeakMap();
|
|
418
418
|
var IS_COMPOSING = new WeakMap();
|
|
419
419
|
var IS_ON_COMPOSITION_END = new WeakMap();
|
|
420
|
+
var EDITOR_TO_USER_SELECTION = new WeakMap();
|
|
420
421
|
/**
|
|
421
422
|
* Weak maps for saving text on composition stage.
|
|
422
423
|
*/
|
|
@@ -1425,6 +1426,8 @@ var Editable$1 = function Editable(props) {
|
|
|
1425
1426
|
|
|
1426
1427
|
var onDOMBeforeInput = React.useCallback(function (event) {
|
|
1427
1428
|
if (!readOnly && hasEditableTarget(editor, event.target) && !isDOMEventHandled(event, propsOnDOMBeforeInput)) {
|
|
1429
|
+
var _EDITOR_TO_USER_SELEC;
|
|
1430
|
+
|
|
1428
1431
|
// Some IMEs/Chrome extensions like e.g. Grammarly set the selection immediately before
|
|
1429
1432
|
// triggering a `beforeinput` expecting the change to be applied to the immediately before
|
|
1430
1433
|
// set selection.
|
|
@@ -1495,7 +1498,12 @@ var Editable$1 = function Editable(props) {
|
|
|
1495
1498
|
});
|
|
1496
1499
|
|
|
1497
1500
|
if (!selection || !slate.Range.equals(selection, range)) {
|
|
1501
|
+
var selectionRef = editor.selection && slate.Editor.rangeRef(editor, editor.selection);
|
|
1498
1502
|
slate.Transforms.select(editor, range);
|
|
1503
|
+
|
|
1504
|
+
if (selectionRef) {
|
|
1505
|
+
EDITOR_TO_USER_SELECTION.set(editor, selectionRef);
|
|
1506
|
+
}
|
|
1499
1507
|
}
|
|
1500
1508
|
}
|
|
1501
1509
|
} // COMPAT: If the selection is expanded, even if the command seems like
|
|
@@ -1645,6 +1653,14 @@ var Editable$1 = function Editable(props) {
|
|
|
1645
1653
|
|
|
1646
1654
|
break;
|
|
1647
1655
|
}
|
|
1656
|
+
} // Restore the actual user section if nothing manually set it.
|
|
1657
|
+
|
|
1658
|
+
|
|
1659
|
+
var toRestore = (_EDITOR_TO_USER_SELEC = EDITOR_TO_USER_SELECTION.get(editor)) === null || _EDITOR_TO_USER_SELEC === void 0 ? void 0 : _EDITOR_TO_USER_SELEC.unref();
|
|
1660
|
+
EDITOR_TO_USER_SELECTION["delete"](editor);
|
|
1661
|
+
|
|
1662
|
+
if (toRestore && (!editor.selection || !slate.Range.equals(editor.selection, toRestore))) {
|
|
1663
|
+
slate.Transforms.select(editor, toRestore);
|
|
1648
1664
|
}
|
|
1649
1665
|
}
|
|
1650
1666
|
}, [readOnly, propsOnDOMBeforeInput]); // Attach a native DOM event handler for `beforeinput` events, because React's
|
|
@@ -2369,6 +2385,7 @@ var defaultScrollSelectionIntoView = function defaultScrollSelectionIntoView(edi
|
|
|
2369
2385
|
* Check if the target is in the editor.
|
|
2370
2386
|
*/
|
|
2371
2387
|
|
|
2388
|
+
|
|
2372
2389
|
var hasTarget = function hasTarget(editor, target) {
|
|
2373
2390
|
return isDOMNode(target) && ReactEditor.hasDOMNode(editor, target);
|
|
2374
2391
|
};
|
|
@@ -4515,6 +4532,16 @@ var withReact = function withReact(editor) {
|
|
|
4515
4532
|
break;
|
|
4516
4533
|
}
|
|
4517
4534
|
|
|
4535
|
+
case 'set_selection':
|
|
4536
|
+
{
|
|
4537
|
+
var _EDITOR_TO_USER_SELEC;
|
|
4538
|
+
|
|
4539
|
+
// Selection was manually set, don't restore the user selection after the change.
|
|
4540
|
+
(_EDITOR_TO_USER_SELEC = EDITOR_TO_USER_SELECTION.get(editor)) === null || _EDITOR_TO_USER_SELEC === void 0 ? void 0 : _EDITOR_TO_USER_SELEC.unref();
|
|
4541
|
+
EDITOR_TO_USER_SELECTION["delete"](editor);
|
|
4542
|
+
break;
|
|
4543
|
+
}
|
|
4544
|
+
|
|
4518
4545
|
case 'insert_node':
|
|
4519
4546
|
case 'remove_node':
|
|
4520
4547
|
{
|