slate-angular 20.2.0-next.20 → 20.2.0-next.21

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.
@@ -477,6 +477,7 @@ const HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY &&
477
477
  typeof globalThis.InputEvent.prototype.getTargetRanges === 'function';
478
478
  const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 30;
479
479
  const SLATE_DEBUG_KEY = '__SLATE_DEBUG__';
480
+ const SLATE_DEBUG_KEY_SCROLL_TOP = '__SLATE_DEBUG_SCROLL_TOP__';
480
481
 
481
482
  /**
482
483
  * Hotkey mappings for each platform.
@@ -3137,10 +3138,13 @@ class VirtualScrollDebugOverlay {
3137
3138
  // not correctly clipboardData on beforeinput
3138
3139
  const forceOnDOMPaste = IS_SAFARI;
3139
3140
  const isDebug = localStorage.getItem(SLATE_DEBUG_KEY) === 'true';
3141
+ const isDebugScrollTop = localStorage.getItem(SLATE_DEBUG_KEY_SCROLL_TOP) === 'true';
3140
3142
  class SlateEditable {
3141
3143
  set virtualScroll(config) {
3142
3144
  this.virtualScrollConfig = config;
3143
- console.log('virtualScrollConfig', config);
3145
+ if (isDebugScrollTop) {
3146
+ this.debugLog('log', 'virtualScrollConfig scrollTop:', config.scrollTop);
3147
+ }
3144
3148
  IS_ENABLED_VIRTUAL_SCROLL.set(this.editor, config.enabled);
3145
3149
  if (this.isEnabledVirtualScroll()) {
3146
3150
  this.tryUpdateVirtualViewport();
@@ -3625,6 +3629,28 @@ class SlateEditable {
3625
3629
  this.toNativeSelection();
3626
3630
  }
3627
3631
  }
3632
+ if (diff.isAddedTop) {
3633
+ const remeasureAddedIndics = diff.diffTopRenderedIndexes;
3634
+ if (isDebug) {
3635
+ this.debugLog('log', 'isAddedTop to remeasure heights: ', remeasureAddedIndics);
3636
+ }
3637
+ const startIndexBeforeAdd = diff.diffTopRenderedIndexes[diff.diffTopRenderedIndexes.length - 1] + 1;
3638
+ const topHeightBeforeAdd = virtualView.accumulatedHeights[startIndexBeforeAdd];
3639
+ const result = this.remeasureHeightByIndics(remeasureAddedIndics);
3640
+ if (result) {
3641
+ const newHeights = buildHeightsAndAccumulatedHeights(this.editor);
3642
+ const visibleStartIndex = diff.diffTopRenderedIndexes[0];
3643
+ const actualTopHeightAfterAdd = newHeights.accumulatedHeights[startIndexBeforeAdd];
3644
+ const adjustedTopHeight = (visibleStartIndex === -1 ? 0 : newHeights.accumulatedHeights[visibleStartIndex]) -
3645
+ (actualTopHeightAfterAdd - topHeightBeforeAdd);
3646
+ if (adjustedTopHeight !== virtualView.top) {
3647
+ if (isDebug) {
3648
+ this.debugLog('log', `update top height cause added element in top: ${adjustedTopHeight}, old height: ${virtualView.top}`);
3649
+ }
3650
+ this.virtualTopHeightElement.style.height = `${adjustedTopHeight}px`;
3651
+ }
3652
+ }
3653
+ }
3628
3654
  this.tryMeasureInViewportChildrenHeights();
3629
3655
  });
3630
3656
  }
@@ -3703,7 +3729,8 @@ class SlateEditable {
3703
3729
  visibleIndexes: new Set(visibleIndexes),
3704
3730
  top,
3705
3731
  bottom,
3706
- heights
3732
+ heights,
3733
+ accumulatedHeights
3707
3734
  };
3708
3735
  }
3709
3736
  applyVirtualView(virtualView) {
@@ -3891,9 +3918,6 @@ class SlateEditable {
3891
3918
  toSlateSelection() {
3892
3919
  if ((!this.isComposing || IS_ANDROID) && !this.isUpdatingSelection && !this.isDraggingInternally) {
3893
3920
  try {
3894
- if (isDebug) {
3895
- console.log('toSlateSelection');
3896
- }
3897
3921
  const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
3898
3922
  const { activeElement } = root;
3899
3923
  const el = AngularEditor.toDOMNode(this.editor, this.editor);
@@ -5091,5 +5115,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
5091
5115
  * Generated bundle index. Do not edit.
5092
5116
  */
5093
5117
 
5094
- 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, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, check, completeTable, createClipboardData, createText, createThrottleRAF, 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, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
5118
+ 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, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, check, completeTable, createClipboardData, createText, createThrottleRAF, 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, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
5095
5119
  //# sourceMappingURL=slate-angular.mjs.map