slate-angular 20.2.0-next.27 → 20.2.0-next.28
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/fesm2022/slate-angular.mjs +34 -13
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3249,7 +3249,8 @@ class SlateEditable {
|
|
|
3249
3249
|
enabled: false,
|
|
3250
3250
|
scrollTop: 0,
|
|
3251
3251
|
viewportHeight: 0,
|
|
3252
|
-
viewportBoundingTop: 0
|
|
3252
|
+
viewportBoundingTop: 0,
|
|
3253
|
+
scrollContainer: null
|
|
3253
3254
|
};
|
|
3254
3255
|
this.inViewportChildren = [];
|
|
3255
3256
|
this.inViewportIndics = [];
|
|
@@ -3363,6 +3364,7 @@ class SlateEditable {
|
|
|
3363
3364
|
}
|
|
3364
3365
|
calculateVirtualScrollSelection(selection) {
|
|
3365
3366
|
if (selection) {
|
|
3367
|
+
const isBlockCardCursor = AngularEditor.isBlockCardLeftCursor(this.editor) || AngularEditor.isBlockCardRightCursor(this.editor);
|
|
3366
3368
|
const indics = this.inViewportIndics;
|
|
3367
3369
|
if (indics.length > 0) {
|
|
3368
3370
|
const currentVisibleRange = {
|
|
@@ -3370,12 +3372,21 @@ class SlateEditable {
|
|
|
3370
3372
|
focus: Editor.end(this.editor, [indics[indics.length - 1]])
|
|
3371
3373
|
};
|
|
3372
3374
|
const [start, end] = Range.edges(selection);
|
|
3373
|
-
|
|
3375
|
+
let forwardSelection = { anchor: start, focus: end };
|
|
3376
|
+
if (!isBlockCardCursor) {
|
|
3377
|
+
forwardSelection = { anchor: start, focus: end };
|
|
3378
|
+
}
|
|
3379
|
+
else {
|
|
3380
|
+
forwardSelection = { anchor: { path: start.path, offset: 0 }, focus: { path: end.path, offset: 0 } };
|
|
3381
|
+
}
|
|
3374
3382
|
const intersectedSelection = Range.intersection(forwardSelection, currentVisibleRange);
|
|
3383
|
+
if (intersectedSelection && isBlockCardCursor) {
|
|
3384
|
+
return selection;
|
|
3385
|
+
}
|
|
3375
3386
|
EDITOR_TO_VIRTUAL_SCROLL_SELECTION.set(this.editor, intersectedSelection);
|
|
3376
3387
|
if (!intersectedSelection || !Range.equals(intersectedSelection, forwardSelection)) {
|
|
3377
3388
|
if (isDebug) {
|
|
3378
|
-
debugLog('log', `selection is not in visible range, selection: ${JSON.stringify(selection)}, intersectedSelection: ${JSON.stringify(intersectedSelection)}`);
|
|
3389
|
+
debugLog('log', `selection is not in visible range, selection: ${JSON.stringify(selection)}, currentVisibleRange: ${JSON.stringify(currentVisibleRange)}, intersectedSelection: ${JSON.stringify(intersectedSelection)}`);
|
|
3379
3390
|
}
|
|
3380
3391
|
return intersectedSelection;
|
|
3381
3392
|
}
|
|
@@ -3385,7 +3396,7 @@ class SlateEditable {
|
|
|
3385
3396
|
EDITOR_TO_VIRTUAL_SCROLL_SELECTION.set(this.editor, null);
|
|
3386
3397
|
return selection;
|
|
3387
3398
|
}
|
|
3388
|
-
toNativeSelection() {
|
|
3399
|
+
toNativeSelection(autoScroll = true) {
|
|
3389
3400
|
try {
|
|
3390
3401
|
let { selection } = this.editor;
|
|
3391
3402
|
if (this.isEnabledVirtualScroll()) {
|
|
@@ -3451,13 +3462,23 @@ class SlateEditable {
|
|
|
3451
3462
|
domSelection.removeAllRanges();
|
|
3452
3463
|
}
|
|
3453
3464
|
setTimeout(() => {
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3465
|
+
if (this.isEnabledVirtualScroll() &&
|
|
3466
|
+
!selection &&
|
|
3467
|
+
this.editor.selection &&
|
|
3468
|
+
autoScroll &&
|
|
3469
|
+
this.virtualScrollConfig.scrollContainer) {
|
|
3470
|
+
this.virtualScrollConfig.scrollContainer.scrollTop = this.virtualScrollConfig.scrollContainer.scrollTop + 100;
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
else {
|
|
3474
|
+
// handle scrolling in setTimeout because of
|
|
3475
|
+
// dom should not have updated immediately after listRender's updating
|
|
3476
|
+
newDomRange && autoScroll && this.scrollSelectionIntoView(this.editor, newDomRange);
|
|
3477
|
+
// COMPAT: In Firefox, it's not enough to create a range, you also need
|
|
3478
|
+
// to focus the contenteditable element too. (2016/11/16)
|
|
3479
|
+
if (newDomRange && IS_FIREFOX) {
|
|
3480
|
+
el.focus();
|
|
3481
|
+
}
|
|
3461
3482
|
}
|
|
3462
3483
|
this.isUpdatingSelection = false;
|
|
3463
3484
|
});
|
|
@@ -3713,7 +3734,7 @@ class SlateEditable {
|
|
|
3713
3734
|
}
|
|
3714
3735
|
}
|
|
3715
3736
|
if (!AngularEditor.isReadOnly(this.editor) && this.editor.selection) {
|
|
3716
|
-
this.toNativeSelection();
|
|
3737
|
+
this.toNativeSelection(false);
|
|
3717
3738
|
}
|
|
3718
3739
|
}
|
|
3719
3740
|
}
|
|
@@ -3948,7 +3969,7 @@ class SlateEditable {
|
|
|
3948
3969
|
if (this.editor.selection && Range.equals(range, this.editor.selection) && !hasStringTarget(domSelection)) {
|
|
3949
3970
|
if (!isTargetInsideVoid(this.editor, activeElement)) {
|
|
3950
3971
|
// force adjust DOMSelection
|
|
3951
|
-
this.toNativeSelection();
|
|
3972
|
+
this.toNativeSelection(false);
|
|
3952
3973
|
}
|
|
3953
3974
|
}
|
|
3954
3975
|
else {
|