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

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.
@@ -971,6 +971,7 @@ class VirtualScrollDebugOverlay {
971
971
  static log(doc, type, ...args) {
972
972
  this.getInstance(doc).log(type, ...args);
973
973
  }
974
+ // will trigger selectionchange and clear editor's selection
974
975
  static syncScrollTop(doc, value) {
975
976
  const instance = this.getInstance(doc);
976
977
  instance.setScrollTopValue(value);
@@ -1051,9 +1052,6 @@ class VirtualScrollDebugOverlay {
1051
1052
  if (!this.container) {
1052
1053
  this.createContainer();
1053
1054
  }
1054
- else {
1055
- this.applyState();
1056
- }
1057
1055
  }
1058
1056
  log(type, ...args) {
1059
1057
  this.init();
@@ -1432,7 +1430,6 @@ class VirtualScrollDebugOverlay {
1432
1430
  item.appendChild(time);
1433
1431
  item.appendChild(text);
1434
1432
  this.logList.appendChild(item);
1435
- this.logList.scrollTop = this.logList.scrollHeight;
1436
1433
  }
1437
1434
  formatValue(value) {
1438
1435
  if (typeof value === 'string') {
@@ -1521,6 +1518,10 @@ const buildHeightsAndAccumulatedHeights = (editor) => {
1521
1518
  }
1522
1519
  return { heights, accumulatedHeights };
1523
1520
  };
1521
+ const calculateVirtualTopHeight = (editor, startIndex) => {
1522
+ const { accumulatedHeights } = buildHeightsAndAccumulatedHeights(editor);
1523
+ return accumulatedHeights[startIndex] ?? 0;
1524
+ };
1524
1525
  const scrollToElement = (editor, element, scrollTo) => {
1525
1526
  const children = editor.children;
1526
1527
  if (!children.length) {
@@ -3316,6 +3317,9 @@ class SlateEditable {
3316
3317
  const virtualView = this.calculateVirtualViewport();
3317
3318
  this.applyVirtualView(virtualView);
3318
3319
  const childrenForRender = virtualView.inViewportChildren;
3320
+ if (isDebug) {
3321
+ debugLog('log', 'writeValue calculate: ', virtualView.visibleIndexes, 'initialized: ', this.listRender.initialized);
3322
+ }
3319
3323
  if (!this.listRender.initialized) {
3320
3324
  this.listRender.initialize(childrenForRender, this.editor, this.context);
3321
3325
  }
@@ -3670,7 +3674,7 @@ class SlateEditable {
3670
3674
  this.virtualBottomHeightElement.style.height = `${bottomHeight}px`;
3671
3675
  }
3672
3676
  }
3673
- getVirtualTopHeight() {
3677
+ getActualVirtualTopHeight() {
3674
3678
  if (!this.virtualScrollInitialized) {
3675
3679
  return 0;
3676
3680
  }
@@ -3695,6 +3699,17 @@ class SlateEditable {
3695
3699
  if (isDebug) {
3696
3700
  debugLog('log', 'tryUpdateVirtualViewport');
3697
3701
  }
3702
+ if (this.inViewportIndics.length > 0) {
3703
+ const topHeight = this.getActualVirtualTopHeight();
3704
+ const refreshVirtualTopHeight = calculateVirtualTopHeight(this.editor, this.inViewportIndics[0]);
3705
+ if (topHeight !== refreshVirtualTopHeight) {
3706
+ if (isDebug) {
3707
+ debugLog('log', 'update top height since dirty state(正数减去高度,负数代表增加高度): ', topHeight - refreshVirtualTopHeight);
3708
+ }
3709
+ this.setVirtualSpaceHeight(refreshVirtualTopHeight);
3710
+ return;
3711
+ }
3712
+ }
3698
3713
  this.tryUpdateVirtualViewportAnimId && cancelAnimationFrame(this.tryUpdateVirtualViewportAnimId);
3699
3714
  this.tryUpdateVirtualViewportAnimId = requestAnimationFrame(() => {
3700
3715
  if (isDebug) {
@@ -3738,15 +3753,6 @@ class SlateEditable {
3738
3753
  }
3739
3754
  }
3740
3755
  }
3741
- else {
3742
- const topHeight = this.getVirtualTopHeight();
3743
- if (virtualView.top !== topHeight) {
3744
- if (isDebug) {
3745
- debugLog('log', 'update top height since invalid status(正数减去高度,负数代表增加高度): ', topHeight - virtualView.top);
3746
- }
3747
- this.setVirtualSpaceHeight(virtualView.top);
3748
- }
3749
- }
3750
3756
  if (isDebug) {
3751
3757
  debugLog('log', 'tryUpdateVirtualViewport Anim end');
3752
3758
  }
@@ -3764,10 +3770,6 @@ class SlateEditable {
3764
3770
  };
3765
3771
  }
3766
3772
  const scrollTop = this.virtualScrollConfig.scrollTop;
3767
- if (isDebug) {
3768
- const doc = this.elementRef?.nativeElement?.ownerDocument ?? document;
3769
- VirtualScrollDebugOverlay.syncScrollTop(doc, Number.isFinite(scrollTop) ? scrollTop : 0);
3770
- }
3771
3773
  const viewportHeight = this.virtualScrollConfig.viewportHeight ?? 0;
3772
3774
  if (!viewportHeight) {
3773
3775
  return {
@@ -3838,6 +3840,9 @@ class SlateEditable {
3838
3840
  }
3839
3841
  diffVirtualViewport(virtualView, stage = 'first') {
3840
3842
  if (!this.inViewportChildren.length) {
3843
+ if (isDebug) {
3844
+ debugLog('log', 'diffVirtualViewport', stage, 'empty inViewportChildren', virtualView.visibleIndexes);
3845
+ }
3841
3846
  return {
3842
3847
  isDifferent: true,
3843
3848
  changedIndexesOfTop: [],
@@ -5161,5 +5166,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
5161
5166
  * Generated bundle index. Do not edit.
5162
5167
  */
5163
5168
 
5164
- export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, EDITOR_TO_BUSINESS_TOP, EDITOR_TO_VIRTUAL_SCROLL_SELECTION, ELEMENT_KEY_TO_HEIGHTS, ELEMENT_TO_COMPONENT, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, FlavourRef, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_ENABLED_VIRTUAL_SCROLL, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SLATE_DEBUG_KEY_SCROLL_TOP, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, SlateString, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, check, completeTable, createClipboardData, createText, createThrottleRAF, debugLog, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getRealHeightByElement, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDebug, isDebugScrollTop, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, measureHeightByElement, measureHeightByIndics, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
5169
+ export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, EDITOR_TO_BUSINESS_TOP, EDITOR_TO_VIRTUAL_SCROLL_SELECTION, ELEMENT_KEY_TO_HEIGHTS, ELEMENT_TO_COMPONENT, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, FlavourRef, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_ENABLED_VIRTUAL_SCROLL, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SLATE_DEBUG_KEY_SCROLL_TOP, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, SlateString, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, calculateVirtualTopHeight, check, completeTable, createClipboardData, createText, createThrottleRAF, debugLog, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getRealHeightByElement, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDebug, isDebugScrollTop, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, measureHeightByElement, measureHeightByIndics, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
5165
5170
  //# sourceMappingURL=slate-angular.mjs.map