slate-react 0.133.7 → 0.133.8-20261012223128
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 +37 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +39 -10
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +39 -10
- package/dist/slate-react.min.js +1 -1
- package/dist/utils/character-move.d.ts +3 -0
- package/dist/utils/character-move.d.ts.map +1 -0
- 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,KASN,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,OAAO,EAEL,OAAO,EAEP,SAAS,EAIT,IAAI,EAEJ,cAAc,EACd,YAAY,EACb,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"editable.d.ts","sourceRoot":"","sources":["../../../../packages/slate-react/src/components/editable.tsx"],"names":[],"mappings":"AAGA,OAAO,KASN,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,OAAO,EAEL,OAAO,EAEP,SAAS,EAIT,IAAI,EAEJ,cAAc,EACd,YAAY,EACb,MAAM,OAAO,CAAA;AAWd,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGpD,OAAO,EAGL,QAAQ,EAQT,MAAM,WAAW,CAAA;AA0DlB;;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;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GAEG;AAEH,eAAO,MAAM,eAAe,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,cAAc,EAAa,CAAA;AAE/E;;GAEG;AAEH,eAAO,MAAM,8BAA8B,WACjC,WAAW,YACT,QAAQ,SAwCnB,CAAA;AAED;;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
|
@@ -2663,6 +2663,25 @@ const getPointAboveTrailingNewline = (editor, point) => {
|
|
|
2663
2663
|
return before;
|
|
2664
2664
|
};
|
|
2665
2665
|
|
|
2666
|
+
const getCharacterMoveUnit = (editor, point, reverse) => {
|
|
2667
|
+
const inline = Editor.above(editor, {
|
|
2668
|
+
at: point,
|
|
2669
|
+
match: node => Node.isElement(node) && editor.isInline(node)
|
|
2670
|
+
});
|
|
2671
|
+
if (!inline || editor.isVoid(inline[0]) || editor.isElementReadOnly(inline[0]) || !(reverse ? Editor.isStart(editor, point, inline[1]) : Editor.isEnd(editor, point, inline[1]))) {
|
|
2672
|
+
return 'character';
|
|
2673
|
+
}
|
|
2674
|
+
if (reverse && !Path.hasPrevious(inline[1])) {
|
|
2675
|
+
return 'character';
|
|
2676
|
+
}
|
|
2677
|
+
const siblingPath = reverse ? Path.previous(inline[1]) : Path.next(inline[1]);
|
|
2678
|
+
if (!Editor.hasPath(editor, siblingPath)) {
|
|
2679
|
+
return 'character';
|
|
2680
|
+
}
|
|
2681
|
+
const sibling = Node.get(editor, siblingPath);
|
|
2682
|
+
return Node.isText(sibling) && sibling.text === '' ? 'offset' : 'character';
|
|
2683
|
+
};
|
|
2684
|
+
|
|
2666
2685
|
const blockPathAt = (editor, point) => {
|
|
2667
2686
|
var _Editor$above;
|
|
2668
2687
|
return (_Editor$above = Editor.above(editor, {
|
|
@@ -2822,6 +2841,9 @@ const Editable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
2822
2841
|
// Rerender editor when composition status changed
|
|
2823
2842
|
const [isComposing, setIsComposing] = useState(false);
|
|
2824
2843
|
const ref = useRef(null);
|
|
2844
|
+
const previousChildren = useRef(editor.children);
|
|
2845
|
+
const previousSelection = useRef(editor.selection);
|
|
2846
|
+
const pendingInputScroll = useRef(false);
|
|
2825
2847
|
const deferredOperations = useRef([]);
|
|
2826
2848
|
const [placeholderHeight, setPlaceholderHeight] = useState();
|
|
2827
2849
|
const processing = useRef(false);
|
|
@@ -2969,6 +2991,11 @@ const Editable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
2969
2991
|
const {
|
|
2970
2992
|
selection
|
|
2971
2993
|
} = editor;
|
|
2994
|
+
const scrollForInput = pendingInputScroll.current;
|
|
2995
|
+
pendingInputScroll.current = false;
|
|
2996
|
+
const selectionChangedByEdit = scrollForInput && previousChildren.current !== editor.children && !!selection && (!previousSelection.current || !Range.equals(previousSelection.current, selection));
|
|
2997
|
+
previousChildren.current = editor.children;
|
|
2998
|
+
previousSelection.current = selection;
|
|
2972
2999
|
const root = ReactEditor.findDocumentOrShadowRoot(editor);
|
|
2973
3000
|
const domSelection = getSelection(root);
|
|
2974
3001
|
if (!domSelection || !ReactEditor.isFocused(editor) || (_androidInputManagerR = androidInputManagerRef.current) !== null && _androidInputManagerR !== void 0 && _androidInputManagerR.hasPendingAction()) {
|
|
@@ -3006,21 +3033,18 @@ const Editable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
3006
3033
|
}
|
|
3007
3034
|
// If the DOM selection is in the editor and the editor selection is already correct, we're done.
|
|
3008
3035
|
if (hasDomSelection && hasDomSelectionInEditor && selection && !forceChange) {
|
|
3036
|
+
var _anchorNode;
|
|
3009
3037
|
const slateRange = ReactEditor.toSlateRange(editor, domSelection, {
|
|
3010
3038
|
exactMatch: true,
|
|
3011
3039
|
// domSelection is not necessarily a valid Slate range
|
|
3012
3040
|
// (e.g. when clicking on contentEditable:false element)
|
|
3013
3041
|
suppressThrow: true
|
|
3014
3042
|
});
|
|
3015
|
-
if (slateRange && Range.equals(slateRange, selection)) {
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
return;
|
|
3019
|
-
}
|
|
3020
|
-
// Ensure selection is inside the mark placeholder
|
|
3021
|
-
if ((_anchorNode = anchorNode) !== null && _anchorNode !== void 0 && (_anchorNode = _anchorNode.parentElement) !== null && _anchorNode !== void 0 && _anchorNode.hasAttribute('data-slate-mark-placeholder')) {
|
|
3022
|
-
return;
|
|
3043
|
+
if (slateRange && Range.equals(slateRange, selection) && (!state.hasMarkPlaceholder || (_anchorNode = anchorNode) !== null && _anchorNode !== void 0 && (_anchorNode = _anchorNode.parentElement) !== null && _anchorNode !== void 0 && _anchorNode.hasAttribute('data-slate-mark-placeholder'))) {
|
|
3044
|
+
if (selectionChangedByEdit) {
|
|
3045
|
+
scrollSelectionIntoView(editor, domSelection.getRangeAt(0));
|
|
3023
3046
|
}
|
|
3047
|
+
return;
|
|
3024
3048
|
}
|
|
3025
3049
|
}
|
|
3026
3050
|
// when <Editable/> is being controlled through external value
|
|
@@ -3138,6 +3162,7 @@ const Editable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
3138
3162
|
return;
|
|
3139
3163
|
}
|
|
3140
3164
|
onUserInput();
|
|
3165
|
+
pendingInputScroll.current = true;
|
|
3141
3166
|
if (!readOnly && !isDOMEventHandled(event, propsOnDOMBeforeInput)) {
|
|
3142
3167
|
var _EDITOR_TO_USER_SELEC;
|
|
3143
3168
|
// COMPAT: BeforeInput events aren't cancelable on android, so we have to handle them differently using the android input manager.
|
|
@@ -4021,7 +4046,8 @@ const Editable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
4021
4046
|
event.preventDefault();
|
|
4022
4047
|
if (selection && Range.isCollapsed(selection)) {
|
|
4023
4048
|
Transforms.move(editor, {
|
|
4024
|
-
reverse: !isRTL
|
|
4049
|
+
reverse: !isRTL,
|
|
4050
|
+
unit: getCharacterMoveUnit(editor, selection.focus, !isRTL)
|
|
4025
4051
|
});
|
|
4026
4052
|
} else {
|
|
4027
4053
|
Transforms.collapse(editor, {
|
|
@@ -4034,7 +4060,8 @@ const Editable = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
|
4034
4060
|
event.preventDefault();
|
|
4035
4061
|
if (selection && Range.isCollapsed(selection)) {
|
|
4036
4062
|
Transforms.move(editor, {
|
|
4037
|
-
reverse: isRTL
|
|
4063
|
+
reverse: isRTL,
|
|
4064
|
+
unit: getCharacterMoveUnit(editor, selection.focus, isRTL)
|
|
4038
4065
|
});
|
|
4039
4066
|
} else {
|
|
4040
4067
|
Transforms.collapse(editor, {
|