slate-angular 20.2.21 → 20.2.22

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.
@@ -3650,6 +3650,12 @@ class SlateEditable {
3650
3650
  this.virtualBottomHeightElement.style.height = `${roundTo(bottomHeight, 1)}px`;
3651
3651
  }
3652
3652
  }
3653
+ setTopHeightDebugInfo(accumulatedHeight, accumulatedEndIndex) {
3654
+ if (isDebug) {
3655
+ this.virtualTopHeightElement.setAttribute('accumulated-height', accumulatedHeight.toString());
3656
+ this.virtualTopHeightElement.setAttribute('accumulated-height-end-index', accumulatedEndIndex.toString());
3657
+ }
3658
+ }
3653
3659
  getActualVirtualTopHeight() {
3654
3660
  if (!this.virtualScrollInitialized) {
3655
3661
  return 0;
@@ -3711,6 +3717,7 @@ class SlateEditable {
3711
3717
  const realTopHeight = this.getActualVirtualTopHeight();
3712
3718
  const visibleStates = this.editor.getAllVisibleStates();
3713
3719
  const accumulateTopHeigh = calculateAccumulatedTopHeight(this.editor, this.inViewportIndics[0], visibleStates);
3720
+ this.setTopHeightDebugInfo(accumulateTopHeigh, this.inViewportIndics[0] - 1);
3714
3721
  if (realTopHeight !== accumulateTopHeigh) {
3715
3722
  if (isDebug) {
3716
3723
  debugLog('log', 'update top height since dirty state,增加高度: ', accumulateTopHeigh - realTopHeight);
@@ -3740,7 +3747,7 @@ class SlateEditable {
3740
3747
  if (this.listRender.initialized) {
3741
3748
  const { preRenderingCount, childrenWithPreRendering, childrenWithPreRenderingIndics } = this.appendPreRenderingToViewport(visibleStates);
3742
3749
  this.listRender.update(childrenWithPreRendering, this.editor, this.context, preRenderingCount, childrenWithPreRenderingIndics);
3743
- if (diff.needAddOnTop && !isFromScrollTo) {
3750
+ if (diff.needAddOnTop && !isFromScrollTo && diff.changedIndexesOfTop.length === 1) {
3744
3751
  const remeasureAddedIndics = diff.changedIndexesOfTop;
3745
3752
  if (isDebug) {
3746
3753
  debugLog('log', 'needAddOnTop to remeasure heights: ', remeasureAddedIndics);
@@ -3752,10 +3759,11 @@ class SlateEditable {
3752
3759
  const newHeights = buildHeightsAndAccumulatedHeights(this.editor, visibleStates);
3753
3760
  const actualTopHeightAfterAdd = newHeights.accumulatedHeights[startIndexBeforeAdd];
3754
3761
  const newTopHeight = virtualView.top - (actualTopHeightAfterAdd - topHeightBeforeAdd);
3762
+ this.setTopHeightDebugInfo(newHeights.accumulatedHeights[this.inViewportIndics[0]], this.inViewportIndics[0] - 1);
3755
3763
  if (topHeightBeforeAdd !== actualTopHeightAfterAdd) {
3756
3764
  this.setVirtualSpaceHeight(newTopHeight);
3757
3765
  if (isDebug) {
3758
- debugLog('log', `update top height since will add element in top,减去高度: ${topHeightBeforeAdd - actualTopHeightAfterAdd}`);
3766
+ debugLog('log', `update top height since will add element in top,减去高度: ${actualTopHeightAfterAdd - topHeightBeforeAdd}`);
3759
3767
  }
3760
3768
  }
3761
3769
  }
@@ -3830,7 +3838,7 @@ class SlateEditable {
3830
3838
  const inViewportStartIndex = inViewportIndics[0];
3831
3839
  const inViewportEndIndex = inViewportIndics[inViewportIndics.length - 1];
3832
3840
  const top = accumulatedHeights[inViewportStartIndex];
3833
- // todo: toggleHeight: toggleHeight 逻辑需要优化
3841
+ // todo: totalHeight: totalHeight 逻辑需要优化
3834
3842
  const bottom = totalHeight - accumulatedHeights[inViewportEndIndex + 1];
3835
3843
  return {
3836
3844
  inViewportChildren,
@@ -3845,6 +3853,7 @@ class SlateEditable {
3845
3853
  this.inViewportChildren = virtualView.inViewportChildren;
3846
3854
  this.setVirtualSpaceHeight(virtualView.top, virtualView.bottom);
3847
3855
  this.inViewportIndics = virtualView.inViewportIndics;
3856
+ this.setTopHeightDebugInfo(virtualView.top, this.inViewportIndics[0] - 1);
3848
3857
  }
3849
3858
  diffVirtualViewport(virtualView, stage = 'first') {
3850
3859
  if (!this.inViewportChildren.length) {