slate-angular 20.2.0-next.30 → 20.2.0-next.32

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.
@@ -2870,6 +2870,19 @@ const createText = (text) => {
2870
2870
  return { nativeElement };
2871
2871
  };
2872
2872
 
2873
+ const setPreRenderingElementStyle = (rootNode, isClear = false) => {
2874
+ if (isClear) {
2875
+ rootNode.style.top = '';
2876
+ rootNode.style.left = '';
2877
+ rootNode.style.right = '';
2878
+ rootNode.style.position = '';
2879
+ return;
2880
+ }
2881
+ rootNode.style.top = '-100%';
2882
+ rootNode.style.left = '0px';
2883
+ rootNode.style.right = '0px';
2884
+ rootNode.style.position = 'absolute';
2885
+ };
2873
2886
  class ListRender {
2874
2887
  constructor(viewContext, viewContainerRef, getOutletParent, getOutletElement) {
2875
2888
  this.viewContext = viewContext;
@@ -2924,8 +2937,7 @@ class ListRender {
2924
2937
  const preRenderingElement = [...this.preRenderingHTMLElement];
2925
2938
  preRenderingElement.forEach((rootNodes, index) => {
2926
2939
  rootNodes.forEach(rootNode => {
2927
- rootNode.style.position = '';
2928
- rootNode.style.top = '';
2940
+ setPreRenderingElementStyle(rootNode, true);
2929
2941
  });
2930
2942
  });
2931
2943
  this.preRenderingHTMLElement = [];
@@ -3031,8 +3043,7 @@ class ListRender {
3031
3043
  for (let i = 0; i < preRenderingCount; i++) {
3032
3044
  const rootNodes = [...getRootNodes(this.views[i], this.blockCards[i])];
3033
3045
  rootNodes.forEach(rootNode => {
3034
- rootNode.style.top = '-100%';
3035
- rootNode.style.position = 'absolute';
3046
+ setPreRenderingElementStyle(rootNode);
3036
3047
  });
3037
3048
  this.preRenderingHTMLElement.push(rootNodes);
3038
3049
  }
@@ -3318,7 +3329,7 @@ class SlateEditable {
3318
3329
  this.applyVirtualView(virtualView);
3319
3330
  const childrenForRender = virtualView.inViewportChildren;
3320
3331
  if (isDebug) {
3321
- debugLog('log', 'writeValue calculate: ', virtualView.visibleIndexes, 'initialized: ', this.listRender.initialized);
3332
+ debugLog('log', 'writeValue calculate: ', virtualView.inViewportIndics, 'initialized: ', this.listRender.initialized);
3322
3333
  }
3323
3334
  if (!this.listRender.initialized) {
3324
3335
  this.listRender.initialize(childrenForRender, this.editor, this.context);
@@ -3763,7 +3774,7 @@ class SlateEditable {
3763
3774
  if (!children.length || !this.isEnabledVirtualScroll()) {
3764
3775
  return {
3765
3776
  inViewportChildren: children,
3766
- visibleIndexes: [],
3777
+ inViewportIndics: [],
3767
3778
  top: 0,
3768
3779
  bottom: 0,
3769
3780
  heights: []
@@ -3774,7 +3785,7 @@ class SlateEditable {
3774
3785
  if (!viewportHeight) {
3775
3786
  return {
3776
3787
  inViewportChildren: [],
3777
- visibleIndexes: [],
3788
+ inViewportIndics: [],
3778
3789
  top: 0,
3779
3790
  bottom: 0,
3780
3791
  heights: []
@@ -3801,32 +3812,32 @@ class SlateEditable {
3801
3812
  const limitedScrollTop = Math.min(adjustedScrollTop, maxScrollTop);
3802
3813
  const viewBottom = limitedScrollTop + viewportHeight;
3803
3814
  let accumulatedOffset = 0;
3804
- let visibleStartIndex = -1;
3815
+ let inViewportStartIndex = -1;
3805
3816
  const visible = [];
3806
- const visibleIndexes = [];
3817
+ const inViewportIndics = [];
3807
3818
  for (let i = 0; i < elementLength && accumulatedOffset < viewBottom; i++) {
3808
3819
  const currentHeight = heights[i];
3809
3820
  const nextOffset = accumulatedOffset + currentHeight;
3810
3821
  // 可视区域有交集,加入渲染
3811
3822
  if (nextOffset > limitedScrollTop && accumulatedOffset < viewBottom) {
3812
- if (visibleStartIndex === -1)
3813
- visibleStartIndex = i; // 第一个相交起始位置
3823
+ if (inViewportStartIndex === -1)
3824
+ inViewportStartIndex = i; // 第一个相交起始位置
3814
3825
  visible.push(children[i]);
3815
- visibleIndexes.push(i);
3826
+ inViewportIndics.push(i);
3816
3827
  }
3817
3828
  accumulatedOffset = nextOffset;
3818
3829
  }
3819
- if (visibleStartIndex === -1 && elementLength) {
3820
- visibleStartIndex = elementLength - 1;
3821
- visible.push(children[visibleStartIndex]);
3822
- visibleIndexes.push(visibleStartIndex);
3830
+ if (inViewportStartIndex === -1 && elementLength) {
3831
+ inViewportStartIndex = elementLength - 1;
3832
+ visible.push(children[inViewportStartIndex]);
3833
+ inViewportIndics.push(inViewportStartIndex);
3823
3834
  }
3824
- const visibleEndIndex = visibleStartIndex === -1 ? elementLength - 1 : (visibleIndexes[visibleIndexes.length - 1] ?? visibleStartIndex);
3825
- const top = visibleStartIndex === -1 ? 0 : accumulatedHeights[visibleStartIndex];
3826
- const bottom = totalHeight - accumulatedHeights[visibleEndIndex + 1];
3835
+ const inViewportEndIndex = inViewportStartIndex === -1 ? elementLength - 1 : (inViewportIndics[inViewportIndics.length - 1] ?? inViewportStartIndex);
3836
+ const top = inViewportStartIndex === -1 ? 0 : accumulatedHeights[inViewportStartIndex];
3837
+ const bottom = totalHeight - accumulatedHeights[inViewportEndIndex + 1];
3827
3838
  return {
3828
3839
  inViewportChildren: visible.length ? visible : children,
3829
- visibleIndexes,
3840
+ inViewportIndics,
3830
3841
  top,
3831
3842
  bottom,
3832
3843
  heights,
@@ -3836,12 +3847,12 @@ class SlateEditable {
3836
3847
  applyVirtualView(virtualView) {
3837
3848
  this.inViewportChildren = virtualView.inViewportChildren;
3838
3849
  this.setVirtualSpaceHeight(virtualView.top, virtualView.bottom);
3839
- this.inViewportIndics = virtualView.visibleIndexes;
3850
+ this.inViewportIndics = virtualView.inViewportIndics;
3840
3851
  }
3841
3852
  diffVirtualViewport(virtualView, stage = 'first') {
3842
3853
  if (!this.inViewportChildren.length) {
3843
3854
  if (isDebug) {
3844
- debugLog('log', 'diffVirtualViewport', stage, 'empty inViewportChildren', virtualView.visibleIndexes);
3855
+ debugLog('log', 'diffVirtualViewport', stage, 'empty inViewportChildren', virtualView.inViewportIndics);
3845
3856
  }
3846
3857
  return {
3847
3858
  isDifferent: true,
@@ -3850,7 +3861,7 @@ class SlateEditable {
3850
3861
  };
3851
3862
  }
3852
3863
  const oldIndexesInViewport = [...this.inViewportIndics];
3853
- const newIndexesInViewport = [...virtualView.visibleIndexes];
3864
+ const newIndexesInViewport = [...virtualView.inViewportIndics];
3854
3865
  const firstNewIndex = newIndexesInViewport[0];
3855
3866
  const lastNewIndex = newIndexesInViewport[newIndexesInViewport.length - 1];
3856
3867
  const firstOldIndex = oldIndexesInViewport[0];