slate-angular 20.2.0-next.24 → 20.2.0-next.25
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 +62 -56
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +0 -2
- package/package.json +1 -1
|
@@ -3634,12 +3634,18 @@ class SlateEditable {
|
|
|
3634
3634
|
VirtualScrollDebugOverlay.log(doc, type, ...args);
|
|
3635
3635
|
}
|
|
3636
3636
|
handlePreRendering() {
|
|
3637
|
-
let preRenderingCount =
|
|
3637
|
+
let preRenderingCount = 1;
|
|
3638
3638
|
const childrenWithPreRendering = [...this.inViewportChildren];
|
|
3639
3639
|
if (this.inViewportIndics[0] !== 0) {
|
|
3640
|
-
preRenderingCount = 1;
|
|
3641
3640
|
childrenWithPreRendering.unshift(this.editor.children[this.inViewportIndics[0] - 1]);
|
|
3642
3641
|
}
|
|
3642
|
+
else {
|
|
3643
|
+
preRenderingCount = 0;
|
|
3644
|
+
}
|
|
3645
|
+
const lastIndex = this.inViewportIndics[this.inViewportIndics.length - 1];
|
|
3646
|
+
if (lastIndex !== this.editor.children.length - 1) {
|
|
3647
|
+
childrenWithPreRendering.push(this.editor.children[lastIndex + 1]);
|
|
3648
|
+
}
|
|
3643
3649
|
return { preRenderingCount, childrenWithPreRendering };
|
|
3644
3650
|
}
|
|
3645
3651
|
tryUpdateVirtualViewport() {
|
|
@@ -3653,7 +3659,7 @@ class SlateEditable {
|
|
|
3653
3659
|
}
|
|
3654
3660
|
let virtualView = this.calculateVirtualViewport();
|
|
3655
3661
|
let diff = this.diffVirtualViewport(virtualView);
|
|
3656
|
-
if (diff.
|
|
3662
|
+
if (diff.isDifferent) {
|
|
3657
3663
|
this.applyVirtualView(virtualView);
|
|
3658
3664
|
if (this.listRender.initialized) {
|
|
3659
3665
|
const { preRenderingCount, childrenWithPreRendering } = this.handlePreRendering();
|
|
@@ -3662,12 +3668,12 @@ class SlateEditable {
|
|
|
3662
3668
|
this.toNativeSelection();
|
|
3663
3669
|
}
|
|
3664
3670
|
}
|
|
3665
|
-
if (diff.
|
|
3666
|
-
const remeasureAddedIndics = diff.
|
|
3671
|
+
if (diff.needAddOnTop) {
|
|
3672
|
+
const remeasureAddedIndics = diff.changedIndexesOfTop;
|
|
3667
3673
|
if (isDebug) {
|
|
3668
|
-
this.debugLog('log', '
|
|
3674
|
+
this.debugLog('log', 'needAddOnTop to remeasure heights: ', remeasureAddedIndics);
|
|
3669
3675
|
}
|
|
3670
|
-
const startIndexBeforeAdd = diff.
|
|
3676
|
+
const startIndexBeforeAdd = diff.changedIndexesOfTop[diff.changedIndexesOfTop.length - 1] + 1;
|
|
3671
3677
|
const topHeightBeforeAdd = virtualView.accumulatedHeights[startIndexBeforeAdd];
|
|
3672
3678
|
const result = this.remeasureHeightByIndics(remeasureAddedIndics);
|
|
3673
3679
|
if (result) {
|
|
@@ -3779,60 +3785,60 @@ class SlateEditable {
|
|
|
3779
3785
|
diffVirtualViewport(virtualView, stage = 'first') {
|
|
3780
3786
|
if (!this.inViewportChildren.length) {
|
|
3781
3787
|
return {
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3788
|
+
isDifferent: true,
|
|
3789
|
+
changedIndexesOfTop: [],
|
|
3790
|
+
changedIndexesOfBottom: []
|
|
3785
3791
|
};
|
|
3786
3792
|
}
|
|
3787
|
-
const
|
|
3788
|
-
const
|
|
3789
|
-
const firstNewIndex =
|
|
3790
|
-
const lastNewIndex =
|
|
3791
|
-
const firstOldIndex =
|
|
3792
|
-
const lastOldIndex =
|
|
3793
|
+
const oldIndexesInViewport = [...this.inViewportIndics];
|
|
3794
|
+
const newIndexesInViewport = [...virtualView.visibleIndexes];
|
|
3795
|
+
const firstNewIndex = newIndexesInViewport[0];
|
|
3796
|
+
const lastNewIndex = newIndexesInViewport[newIndexesInViewport.length - 1];
|
|
3797
|
+
const firstOldIndex = oldIndexesInViewport[0];
|
|
3798
|
+
const lastOldIndex = oldIndexesInViewport[oldIndexesInViewport.length - 1];
|
|
3793
3799
|
if (firstNewIndex !== firstOldIndex || lastNewIndex !== lastOldIndex) {
|
|
3794
|
-
const
|
|
3795
|
-
const
|
|
3796
|
-
const
|
|
3797
|
-
const
|
|
3798
|
-
const
|
|
3799
|
-
const
|
|
3800
|
-
if (
|
|
3800
|
+
const changedIndexesOfTop = [];
|
|
3801
|
+
const changedIndexesOfBottom = [];
|
|
3802
|
+
const needRemoveOnTop = firstNewIndex !== firstOldIndex && firstNewIndex > firstOldIndex;
|
|
3803
|
+
const needAddOnTop = firstNewIndex !== firstOldIndex && firstNewIndex < firstOldIndex;
|
|
3804
|
+
const needRemoveOnBottom = lastNewIndex !== lastOldIndex && lastOldIndex > lastNewIndex;
|
|
3805
|
+
const needAddOnBottom = lastNewIndex !== lastOldIndex && lastOldIndex < lastNewIndex;
|
|
3806
|
+
if (needRemoveOnTop || needAddOnBottom) {
|
|
3801
3807
|
// 向下
|
|
3802
|
-
for (let index = 0; index <
|
|
3803
|
-
const element =
|
|
3804
|
-
if (!
|
|
3805
|
-
|
|
3808
|
+
for (let index = 0; index < oldIndexesInViewport.length; index++) {
|
|
3809
|
+
const element = oldIndexesInViewport[index];
|
|
3810
|
+
if (!newIndexesInViewport.includes(element)) {
|
|
3811
|
+
changedIndexesOfTop.push(element);
|
|
3806
3812
|
}
|
|
3807
3813
|
else {
|
|
3808
3814
|
break;
|
|
3809
3815
|
}
|
|
3810
3816
|
}
|
|
3811
|
-
for (let index =
|
|
3812
|
-
const element =
|
|
3813
|
-
if (!
|
|
3814
|
-
|
|
3817
|
+
for (let index = newIndexesInViewport.length - 1; index >= 0; index--) {
|
|
3818
|
+
const element = newIndexesInViewport[index];
|
|
3819
|
+
if (!oldIndexesInViewport.includes(element)) {
|
|
3820
|
+
changedIndexesOfBottom.push(element);
|
|
3815
3821
|
}
|
|
3816
3822
|
else {
|
|
3817
3823
|
break;
|
|
3818
3824
|
}
|
|
3819
3825
|
}
|
|
3820
3826
|
}
|
|
3821
|
-
else if (
|
|
3827
|
+
else if (needAddOnTop || needRemoveOnBottom) {
|
|
3822
3828
|
// 向上
|
|
3823
|
-
for (let index = 0; index <
|
|
3824
|
-
const element =
|
|
3825
|
-
if (!
|
|
3826
|
-
|
|
3829
|
+
for (let index = 0; index < newIndexesInViewport.length; index++) {
|
|
3830
|
+
const element = newIndexesInViewport[index];
|
|
3831
|
+
if (!oldIndexesInViewport.includes(element)) {
|
|
3832
|
+
changedIndexesOfTop.push(element);
|
|
3827
3833
|
}
|
|
3828
3834
|
else {
|
|
3829
3835
|
break;
|
|
3830
3836
|
}
|
|
3831
3837
|
}
|
|
3832
|
-
for (let index =
|
|
3833
|
-
const element =
|
|
3834
|
-
if (!
|
|
3835
|
-
|
|
3838
|
+
for (let index = oldIndexesInViewport.length - 1; index >= 0; index--) {
|
|
3839
|
+
const element = oldIndexesInViewport[index];
|
|
3840
|
+
if (!newIndexesInViewport.includes(element)) {
|
|
3841
|
+
changedIndexesOfBottom.push(element);
|
|
3836
3842
|
}
|
|
3837
3843
|
else {
|
|
3838
3844
|
break;
|
|
@@ -3841,32 +3847,32 @@ class SlateEditable {
|
|
|
3841
3847
|
}
|
|
3842
3848
|
if (isDebug) {
|
|
3843
3849
|
this.debugLog('log', `====== diffVirtualViewport stage: ${stage} ======`);
|
|
3844
|
-
this.debugLog('log', '
|
|
3845
|
-
this.debugLog('log', '
|
|
3846
|
-
this.debugLog('log', '
|
|
3847
|
-
this.debugLog('log', '
|
|
3848
|
-
const needTop = virtualView.heights.slice(0,
|
|
3850
|
+
this.debugLog('log', 'oldIndexesInViewport:', oldIndexesInViewport);
|
|
3851
|
+
this.debugLog('log', 'newIndexesInViewport:', newIndexesInViewport);
|
|
3852
|
+
this.debugLog('log', 'changedIndexesOfTop:', needRemoveOnTop ? '-' : needAddOnTop ? '+' : '-', changedIndexesOfTop, changedIndexesOfTop.map(index => getRealHeightByElement(this.editor, this.editor.children[index], 0)));
|
|
3853
|
+
this.debugLog('log', 'changedIndexesOfBottom:', needAddOnBottom ? '+' : needRemoveOnBottom ? '-' : '+', changedIndexesOfBottom, changedIndexesOfBottom.map(index => getRealHeightByElement(this.editor, this.editor.children[index], 0)));
|
|
3854
|
+
const needTop = virtualView.heights.slice(0, newIndexesInViewport[0]).reduce((acc, height) => acc + height, 0);
|
|
3849
3855
|
const needBottom = virtualView.heights
|
|
3850
|
-
.slice(
|
|
3856
|
+
.slice(newIndexesInViewport[newIndexesInViewport.length - 1] + 1)
|
|
3851
3857
|
.reduce((acc, height) => acc + height, 0);
|
|
3852
3858
|
this.debugLog('log', needTop - parseFloat(this.virtualTopHeightElement.style.height), 'newTopHeight:', needTop, 'prevTopHeight:', parseFloat(this.virtualTopHeightElement.style.height));
|
|
3853
3859
|
this.debugLog('log', 'newBottomHeight:', needBottom, 'prevBottomHeight:', parseFloat(this.virtualBottomHeightElement.style.height));
|
|
3854
3860
|
this.debugLog('warn', '=========== Dividing line ===========');
|
|
3855
3861
|
}
|
|
3856
3862
|
return {
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3863
|
+
isDifferent: true,
|
|
3864
|
+
needRemoveOnTop,
|
|
3865
|
+
needAddOnTop,
|
|
3866
|
+
needRemoveOnBottom,
|
|
3867
|
+
needAddOnBottom,
|
|
3868
|
+
changedIndexesOfTop,
|
|
3869
|
+
changedIndexesOfBottom
|
|
3864
3870
|
};
|
|
3865
3871
|
}
|
|
3866
3872
|
return {
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3873
|
+
isDifferent: false,
|
|
3874
|
+
changedIndexesOfTop: [],
|
|
3875
|
+
changedIndexesOfBottom: []
|
|
3870
3876
|
};
|
|
3871
3877
|
}
|
|
3872
3878
|
tryMeasureInViewportChildrenHeights() {
|