slate-react 0.97.2 → 0.98.0-2023626141745
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 +55 -61
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +55 -59
- package/dist/index.js.map +1 -1
- package/dist/plugin/react-editor.d.ts.map +1 -1
- package/dist/slate-react.js +55 -59
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/components/editable.tsx"],"names":[],"mappings":"AAGA,OAAO,KAON,MAAM,OAAO,CAAA;AAEd,OAAO,EAEL,OAAO,EAEP,SAAS,EAET,KAAK,EACL,IAAI,EAEL,MAAM,OAAO,CAAA;AAQd,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,OAAO,EAEL,QAAQ,EAMT,MAAM,cAAc,CAAA;AAsCrB;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,GAAG,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE;QACV,iBAAiB,EAAE,SAAS,CAAA;QAC5B,mBAAmB,CAAC,EAAE,IAAI,CAAA;QAC1B,iBAAiB,CAAC,EAAE,IAAI,CAAA;QACxB,GAAG,CAAC,EAAE,KAAK,CAAA;QACX,GAAG,EAAE,GAAG,CAAA;KACT,CAAA;CACF;AAED;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,GAAG,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,IAAI,CAAA;IACV,UAAU,EAAE;QACV,iBAAiB,EAAE,IAAI,CAAA;KACxB,CAAA;CACF;AAED;;GAEG;AAEH,oBAAY,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,K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aAAa,gBAijD5C,CAAA;AAED;;GAEG;AACH,oBAAY,sBAAsB,GAAG;IACnC,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE;QACV,wBAAwB,EAAE,OAAO,CAAA;QACjC,GAAG,CAAC,EAAE,KAAK,CAAA;QACX,eAAe,EAAE,OAAO,CAAA;QACxB,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAC3B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAA;KAC3B,CAAA;CACF,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,kBAAkB,8BAG5B,sBAAsB,gBAOxB,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,eAAe,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,KAAK,EAAa,CAAA;AA4BtE;;GAEG;AAEH,eAAO,MAAM,cAAc,gHAIO,IAAI,GAAG,OAAO,yBAc/C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,yFAUjC,CAAA;AAED;;GAEG;AAEH,eAAO,MAAM,iBAAiB,uDAEJ,IAAI,GAAG,OAAO,yBAevC,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -890,15 +890,37 @@ var ReactEditor = {
|
|
|
890
890
|
|
|
891
891
|
if (el) {
|
|
892
892
|
if (isDOMSelection(domRange)) {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
893
|
+
// COMPAT: In firefox the normal seletion way does not work
|
|
894
|
+
// (https://github.com/ianstormtaylor/slate/pull/5486#issue-1820720223)
|
|
895
|
+
if (IS_FIREFOX && domRange.rangeCount > 1) {
|
|
896
|
+
focusNode = domRange.focusNode; // Focus node works fine
|
|
897
|
+
|
|
898
|
+
var firstRange = domRange.getRangeAt(0);
|
|
899
|
+
var lastRange = domRange.getRangeAt(domRange.rangeCount - 1); // Right to left
|
|
900
|
+
|
|
901
|
+
if (firstRange.startContainer === focusNode) {
|
|
902
|
+
anchorNode = lastRange.endContainer;
|
|
903
|
+
anchorOffset = lastRange.endOffset;
|
|
904
|
+
focusOffset = firstRange.startOffset;
|
|
905
|
+
} else {
|
|
906
|
+
// Left to right
|
|
907
|
+
anchorNode = firstRange.startContainer;
|
|
908
|
+
anchorOffset = firstRange.endOffset;
|
|
909
|
+
focusOffset = lastRange.startOffset;
|
|
910
|
+
}
|
|
911
|
+
} else {
|
|
912
|
+
anchorNode = domRange.anchorNode;
|
|
913
|
+
anchorOffset = domRange.anchorOffset;
|
|
914
|
+
focusNode = domRange.focusNode;
|
|
915
|
+
focusOffset = domRange.focusOffset;
|
|
916
|
+
} // COMPAT: There's a bug in chrome that always returns `true` for
|
|
897
917
|
// `isCollapsed` for a Selection that comes from a ShadowRoot.
|
|
898
918
|
// (2020/08/08)
|
|
899
919
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=447523
|
|
920
|
+
// IsCollapsed might not work in firefox, but this will
|
|
921
|
+
|
|
900
922
|
|
|
901
|
-
if (IS_CHROME && hasShadowRoot(anchorNode)) {
|
|
923
|
+
if (IS_CHROME && hasShadowRoot(anchorNode) || IS_FIREFOX) {
|
|
902
924
|
isCollapsed = domRange.anchorNode === domRange.focusNode && domRange.anchorOffset === domRange.focusOffset;
|
|
903
925
|
} else {
|
|
904
926
|
isCollapsed = domRange.isCollapsed;
|
|
@@ -943,46 +965,6 @@ var ReactEditor = {
|
|
|
943
965
|
if (!focus) {
|
|
944
966
|
return null;
|
|
945
967
|
}
|
|
946
|
-
/**
|
|
947
|
-
* suppose we have this document:
|
|
948
|
-
*
|
|
949
|
-
* { type: 'paragraph',
|
|
950
|
-
* children: [
|
|
951
|
-
* { text: 'foo ' },
|
|
952
|
-
* { text: 'bar' },
|
|
953
|
-
* { text: ' baz' }
|
|
954
|
-
* ]
|
|
955
|
-
* }
|
|
956
|
-
*
|
|
957
|
-
* a double click on "bar" on chrome will create this range:
|
|
958
|
-
*
|
|
959
|
-
* anchor -> [0,1] offset 0
|
|
960
|
-
* focus -> [0,1] offset 3
|
|
961
|
-
*
|
|
962
|
-
* while on firefox will create this range:
|
|
963
|
-
*
|
|
964
|
-
* anchor -> [0,0] offset 4
|
|
965
|
-
* focus -> [0,2] offset 0
|
|
966
|
-
*
|
|
967
|
-
* let's try to fix it...
|
|
968
|
-
*/
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
if (IS_FIREFOX && !isCollapsed && anchorNode !== focusNode) {
|
|
972
|
-
var isEnd = Editor.isEnd(editor, anchor, anchor.path);
|
|
973
|
-
var isStart = Editor.isStart(editor, focus, focus.path);
|
|
974
|
-
|
|
975
|
-
if (isEnd) {
|
|
976
|
-
var after = Editor.after(editor, anchor); // Editor.after() might return undefined
|
|
977
|
-
|
|
978
|
-
anchor = after || anchor;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
if (isStart) {
|
|
982
|
-
var before = Editor.before(editor, focus);
|
|
983
|
-
focus = before || focus;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
968
|
|
|
987
969
|
var range = {
|
|
988
970
|
anchor: anchor,
|
|
@@ -3280,13 +3262,32 @@ var Editable = props => {
|
|
|
3280
3262
|
|
|
3281
3263
|
if (!selection && !hasDomSelection) {
|
|
3282
3264
|
return;
|
|
3265
|
+
} // Get anchorNode and focusNode
|
|
3266
|
+
|
|
3267
|
+
|
|
3268
|
+
var focusNode = domSelection.focusNode;
|
|
3269
|
+
var anchorNode; // COMPAT: In firefox the normal seletion way does not work
|
|
3270
|
+
// (https://github.com/ianstormtaylor/slate/pull/5486#issue-1820720223)
|
|
3271
|
+
|
|
3272
|
+
if (IS_FIREFOX && domSelection.rangeCount > 1) {
|
|
3273
|
+
var firstRange = domSelection.getRangeAt(0);
|
|
3274
|
+
var lastRange = domSelection.getRangeAt(domSelection.rangeCount - 1); // Right to left
|
|
3275
|
+
|
|
3276
|
+
if (firstRange.startContainer === focusNode) {
|
|
3277
|
+
anchorNode = lastRange.endContainer;
|
|
3278
|
+
} else {
|
|
3279
|
+
// Left to right
|
|
3280
|
+
anchorNode = firstRange.startContainer;
|
|
3281
|
+
}
|
|
3282
|
+
} else {
|
|
3283
|
+
anchorNode = domSelection.anchorNode;
|
|
3283
3284
|
} // verify that the dom selection is in the editor
|
|
3284
3285
|
|
|
3285
3286
|
|
|
3286
3287
|
var editorElement = EDITOR_TO_ELEMENT.get(editor);
|
|
3287
3288
|
var hasDomSelectionInEditor = false;
|
|
3288
3289
|
|
|
3289
|
-
if (editorElement.contains(
|
|
3290
|
+
if (editorElement.contains(anchorNode) && editorElement.contains(focusNode)) {
|
|
3290
3291
|
hasDomSelectionInEditor = true;
|
|
3291
3292
|
} // If the DOM selection is in the editor and the editor selection is already correct, we're done.
|
|
3292
3293
|
|
|
@@ -3300,18 +3301,14 @@ var Editable = props => {
|
|
|
3300
3301
|
});
|
|
3301
3302
|
|
|
3302
3303
|
if (slateRange && Range.equals(slateRange, selection)) {
|
|
3303
|
-
var _anchorNode$parentEle;
|
|
3304
|
+
var _anchorNode, _anchorNode$parentEle;
|
|
3304
3305
|
|
|
3305
3306
|
if (!state.hasMarkPlaceholder) {
|
|
3306
3307
|
return;
|
|
3307
3308
|
} // Ensure selection is inside the mark placeholder
|
|
3308
3309
|
|
|
3309
3310
|
|
|
3310
|
-
|
|
3311
|
-
anchorNode
|
|
3312
|
-
} = domSelection;
|
|
3313
|
-
|
|
3314
|
-
if (anchorNode !== null && anchorNode !== void 0 && (_anchorNode$parentEle = anchorNode.parentElement) !== null && _anchorNode$parentEle !== void 0 && _anchorNode$parentEle.hasAttribute('data-slate-mark-placeholder')) {
|
|
3311
|
+
if ((_anchorNode = anchorNode) !== null && _anchorNode !== void 0 && (_anchorNode$parentEle = _anchorNode.parentElement) !== null && _anchorNode$parentEle !== void 0 && _anchorNode$parentEle.hasAttribute('data-slate-mark-placeholder')) {
|
|
3315
3312
|
return;
|
|
3316
3313
|
}
|
|
3317
3314
|
}
|
|
@@ -3348,20 +3345,17 @@ var Editable = props => {
|
|
|
3348
3345
|
}
|
|
3349
3346
|
|
|
3350
3347
|
return newDomRange;
|
|
3351
|
-
};
|
|
3348
|
+
}; // In firefox if there is more then 1 range and we call setDomSelection we remove the ability to select more cells in a table
|
|
3349
|
+
|
|
3350
|
+
|
|
3351
|
+
if (domSelection.rangeCount <= 1) {
|
|
3352
|
+
setDomSelection();
|
|
3353
|
+
}
|
|
3352
3354
|
|
|
3353
|
-
var newDomRange = setDomSelection();
|
|
3354
3355
|
var ensureSelection = ((_androidInputManagerR2 = androidInputManagerRef.current) === null || _androidInputManagerR2 === void 0 ? void 0 : _androidInputManagerR2.isFlushing()) === 'action';
|
|
3355
3356
|
|
|
3356
3357
|
if (!IS_ANDROID || !ensureSelection) {
|
|
3357
3358
|
setTimeout(() => {
|
|
3358
|
-
// COMPAT: In Firefox, it's not enough to create a range, you also need
|
|
3359
|
-
// to focus the contenteditable element too. (2016/11/16)
|
|
3360
|
-
if (newDomRange && IS_FIREFOX) {
|
|
3361
|
-
var el = ReactEditor.toDOMNode(editor, editor);
|
|
3362
|
-
el.focus();
|
|
3363
|
-
}
|
|
3364
|
-
|
|
3365
3359
|
state.isUpdatingSelection = false;
|
|
3366
3360
|
});
|
|
3367
3361
|
return;
|