slate-angular 20.2.4 → 20.2.5

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.
@@ -1473,7 +1473,7 @@ const measureHeightByIndics = (editor, indics, force = false) => {
1473
1473
  let hasChanged = false;
1474
1474
  indics.forEach((index, i) => {
1475
1475
  const element = editor.children[index];
1476
- const preHeight = getRealHeightByElement(editor, element, 0);
1476
+ const preHeight = getRealHeightByElement(editor, element);
1477
1477
  if (preHeight && !force) {
1478
1478
  if (isDebug) {
1479
1479
  const height = measureHeightByElement(editor, element);
@@ -1491,7 +1491,7 @@ const measureHeightByIndics = (editor, indics, force = false) => {
1491
1491
  const getBusinessTop = (editor) => {
1492
1492
  return EDITOR_TO_BUSINESS_TOP.get(editor) ?? 0;
1493
1493
  };
1494
- const getRealHeightByElement = (editor, element, defaultHeight) => {
1494
+ const getRealHeightByElement = (editor, element) => {
1495
1495
  const heights = ELEMENT_KEY_TO_HEIGHTS.get(editor);
1496
1496
  const key = AngularEditor.findKey(editor, element);
1497
1497
  const height = heights?.get(key.id);
@@ -1501,7 +1501,7 @@ const getRealHeightByElement = (editor, element, defaultHeight) => {
1501
1501
  if (heights?.has(key.id)) {
1502
1502
  console.error('getBlockHeight: invalid height value', key.id, height);
1503
1503
  }
1504
- return editor.getRoughHeight(element, defaultHeight);
1504
+ return null;
1505
1505
  };
1506
1506
  const buildHeightsAndAccumulatedHeights = (editor) => {
1507
1507
  const children = (editor.children || []);
@@ -1509,7 +1509,7 @@ const buildHeightsAndAccumulatedHeights = (editor) => {
1509
1509
  const accumulatedHeights = new Array(children.length + 1);
1510
1510
  accumulatedHeights[0] = 0;
1511
1511
  for (let i = 0; i < children.length; i++) {
1512
- const height = getRealHeightByElement(editor, children[i], VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT);
1512
+ const height = getRealHeightByElement(editor, children[i]) || editor.getRoughHeight(children[i]);
1513
1513
  heights[i] = height;
1514
1514
  accumulatedHeights[i + 1] = accumulatedHeights[i] + height;
1515
1515
  }
@@ -3083,10 +3083,11 @@ class ListRender {
3083
3083
  for (let i = 0; i < children.length; i++) {
3084
3084
  const rootNodes = [...getRootNodes(this.views[i], this.blockCards[i])];
3085
3085
  const index = this.viewContext.editor.children.indexOf(children[i]);
3086
- const height = getRealHeightByElement(this.viewContext.editor, children[i]);
3086
+ const height = getRealHeightByElement(this.viewContext.editor, children[i]) ||
3087
+ this.viewContext.editor.getRoughHeight(children[i]);
3087
3088
  rootNodes.forEach(rootNode => {
3088
3089
  rootNode.setAttribute('debug-index', index.toString());
3089
- rootNode.setAttribute('debug-height', height.toString());
3090
+ rootNode.setAttribute('debug-height', height?.toString());
3090
3091
  });
3091
3092
  }
3092
3093
  }
@@ -4021,11 +4022,9 @@ class SlateEditable {
4021
4022
  debugLog('log', 'oldIndexesInViewport:', oldIndexesInViewport);
4022
4023
  debugLog('log', 'newIndexesInViewport:', newIndexesInViewport);
4023
4024
  // this.editor.children[index] will be undefined when it is removed
4024
- debugLog('log', 'changedIndexesOfTop:', needRemoveOnTop ? '-' : needAddOnTop ? '+' : '-', changedIndexesOfTop, changedIndexesOfTop.map(index => (this.editor.children[index] &&
4025
- getRealHeightByElement(this.editor, this.editor.children[index], 0)) ||
4025
+ debugLog('log', 'changedIndexesOfTop:', needRemoveOnTop ? '-' : needAddOnTop ? '+' : '-', changedIndexesOfTop, changedIndexesOfTop.map(index => (this.editor.children[index] && getRealHeightByElement(this.editor, this.editor.children[index])) ||
4026
4026
  0));
4027
- debugLog('log', 'changedIndexesOfBottom:', needAddOnBottom ? '+' : needRemoveOnBottom ? '-' : '+', changedIndexesOfBottom, changedIndexesOfBottom.map(index => (this.editor.children[index] &&
4028
- getRealHeightByElement(this.editor, this.editor.children[index], 0)) ||
4027
+ debugLog('log', 'changedIndexesOfBottom:', needAddOnBottom ? '+' : needRemoveOnBottom ? '-' : '+', changedIndexesOfBottom, changedIndexesOfBottom.map(index => (this.editor.children[index] && getRealHeightByElement(this.editor, this.editor.children[index])) ||
4029
4028
  0));
4030
4029
  const needTop = virtualView.heights.slice(0, newIndexesInViewport[0]).reduce((acc, height) => acc + height, 0);
4031
4030
  const needBottom = virtualView.heights