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

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.
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as slate_dom from 'slate-dom';
2
2
  import { DOMEditor, DOMNode, DOMElement, DOMPoint, DOMRange, DOMStaticRange, DOMSelection, DOMText } from 'slate-dom';
3
3
  import * as slate from 'slate';
4
- import { Descendant, Range as Range$1, Node, Editor, NodeEntry, Point, Element as Element$1, Path, Text, LeafPosition, Ancestor, BaseRange } from 'slate';
4
+ import { Descendant, Range as Range$1, Node, Editor, NodeEntry, Point, Element as Element$1, Path, Text, LeafPosition, Ancestor, BaseRange, Selection as Selection$1 } from 'slate';
5
5
  import * as i0 from '@angular/core';
6
6
  import { Injector, ViewContainerRef, TemplateRef, OnInit, OnChanges, OnDestroy, AfterViewChecked, DoCheck, ElementRef, Renderer2, ChangeDetectorRef, NgZone, SimpleChanges } from '@angular/core';
7
7
  import * as i1 from '@angular/common';
@@ -102,6 +102,8 @@ type OriginEvent = 'drag' | 'copy' | 'cut';
102
102
  */
103
103
  interface AngularEditor extends CustomDOMEditor {
104
104
  deleteCutData: () => void;
105
+ selectAll: () => void;
106
+ isVisible: (element: Element$1) => boolean;
105
107
  onKeydown: (event: KeyboardEvent) => void;
106
108
  onClick: (event: MouseEvent) => void;
107
109
  injector: Injector;
@@ -147,6 +149,7 @@ declare const AngularEditor: {
147
149
  focus: (editor: any, options?: {
148
150
  retries: number;
149
151
  }) => void;
152
+ isEnabledVirtualScroll(editor: AngularEditor): boolean;
150
153
  isNodeInEditor(editor: CustomDOMEditor, node: Node): boolean;
151
154
  isLeafInEditor(editor: CustomDOMEditor, leafNode: globalThis.Element): boolean;
152
155
  isBlockHangingRight(editor: Editor): boolean;
@@ -320,9 +323,10 @@ interface SlateVirtualScrollConfig {
320
323
  viewportHeight: number;
321
324
  blockHeight?: number;
322
325
  bufferCount?: number;
326
+ viewportBoundingTop: number;
323
327
  }
324
328
  interface VirtualViewResult {
325
- renderedChildren: Element$1[];
329
+ inViewportChildren: Element$1[];
326
330
  visibleIndexes: Set<number>;
327
331
  top: number;
328
332
  bottom: number;
@@ -331,7 +335,6 @@ interface VirtualViewResult {
331
335
 
332
336
  type SafeAny = any;
333
337
 
334
- declare const JUST_NOW_UPDATED_VIRTUAL_VIEW: WeakMap<AngularEditor, boolean>;
335
338
  declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewChecked, DoCheck {
336
339
  elementRef: ElementRef;
337
340
  renderer2: Renderer2;
@@ -387,13 +390,13 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
387
390
  getOutletParent: () => any;
388
391
  getOutletElement: () => HTMLElement;
389
392
  listRender: ListRender;
390
- private virtualConfig;
391
- private renderedChildren;
392
- private virtualVisibleIndexes;
393
- private measuredHeights;
394
- private measurePending;
395
- private refreshVirtualViewAnimId;
396
- private measureVisibleHeightsAnimId;
393
+ private virtualScrollConfig;
394
+ private inViewportChildren;
395
+ private inViewportIndics;
396
+ private keyHeightMap;
397
+ private tryUpdateVirtualViewportAnimId;
398
+ private tryMeasureInViewportChildrenHeightsAnimId;
399
+ private editorResizeObserver?;
397
400
  constructor(elementRef: ElementRef, renderer2: Renderer2, cdr: ChangeDetectorRef, ngZone: NgZone, injector: Injector);
398
401
  ngOnInit(): void;
399
402
  ngOnChanges(simpleChanges: SimpleChanges): void;
@@ -401,33 +404,34 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
401
404
  registerOnTouched(fn: any): void;
402
405
  writeValue(value: Element$1[]): void;
403
406
  initialize(): void;
407
+ calculateVirtualScrollSelection(selection: Selection$1): slate.BaseRange;
404
408
  toNativeSelection(): void;
405
409
  onChange(): void;
406
410
  ngAfterViewChecked(): void;
407
411
  ngDoCheck(): void;
408
412
  forceRender(): void;
409
413
  render(): void;
414
+ updateListRenderAndRemeasureHeights(): void;
410
415
  updateContext(): boolean;
411
416
  initializeContext(): void;
412
417
  initializeViewContext(): void;
413
418
  composePlaceholderDecorate(editor: Editor): SlatePlaceholder[];
414
419
  generateDecorations(): slate.BaseRange[];
415
- private shouldUseVirtual;
420
+ private isEnabledVirtualScroll;
416
421
  virtualScrollInitialized: boolean;
417
422
  virtualTopHeightElement: HTMLElement;
418
423
  virtualBottomHeightElement: HTMLElement;
419
424
  virtualCenterOutlet: HTMLElement;
420
- initializeVirtualScrolling(): void;
421
- changeVirtualHeight(topHeight: number, bottomHeight: number): void;
422
- private refreshVirtualView;
425
+ initializeVirtualScroll(): void;
426
+ setVirtualSpaceHeight(topHeight: number, bottomHeight: number): void;
427
+ private debugLog;
428
+ private tryUpdateVirtualViewport;
429
+ private calculateVirtualViewport;
423
430
  private applyVirtualView;
424
- private diffVirtualView;
425
- private getBlockHeight;
426
- private buildAccumulatedHeight;
427
- private getBufferBelowHeight;
428
- private scheduleMeasureVisibleHeights;
431
+ private diffVirtualViewport;
432
+ private tryMeasureInViewportChildrenHeights;
429
433
  private measureVisibleHeights;
430
- private measureHeightByIndexes;
434
+ private remeasureHeightByIndics;
431
435
  private addEventListener;
432
436
  private toSlateSelection;
433
437
  private onDOMBeforeInput;
@@ -475,6 +479,7 @@ declare class LeavesRender {
475
479
  initialize(context: SlateTextContext): void;
476
480
  update(context: SlateTextContext): void;
477
481
  private getLeaves;
482
+ destroy(): void;
478
483
  }
479
484
 
480
485
  declare abstract class BaseTextFlavour<T extends Text = Text> extends BaseFlavour<SlateTextContext<T>> {
@@ -581,7 +586,9 @@ declare class BaseElementComponent<T extends Element$1 = Element$1, K extends An
581
586
  onContextChange(): void;
582
587
  updateChildrenView(): void;
583
588
  getChildrenContext(): SlateChildrenContext;
584
- getRealHeight(): Promise<number>;
589
+ stableHeight: null | number;
590
+ isStableHeight(): boolean;
591
+ getRealHeight(): number | Promise<number>;
585
592
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseElementComponent<any, any>, never>;
586
593
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseElementComponent<any, any>, never, never, {}, {}, never, never, true, never>;
587
594
  }
@@ -641,7 +648,9 @@ declare abstract class BaseElementFlavour<T extends Element$1 = Element$1, K ext
641
648
  onContextChange(): void;
642
649
  updateChildrenView(): void;
643
650
  getChildrenContext(): SlateChildrenContext;
644
- getRealHeight(): Promise<number>;
651
+ stableHeight: null | number;
652
+ isStableHeight(): boolean;
653
+ getRealHeight(): number | Promise<number>;
645
654
  abstract render(): void;
646
655
  abstract rerender(): void;
647
656
  }
@@ -678,6 +687,8 @@ declare const PLACEHOLDER_SYMBOL: string;
678
687
  * Weak map for associating the html element with the component.
679
688
  */
680
689
  declare const ELEMENT_TO_COMPONENT: WeakMap<Node, BaseElementComponent | BaseFlavour>;
690
+ declare const IS_ENABLED_VIRTUAL_SCROLL: WeakMap<Editor, boolean>;
691
+ declare const EDITOR_TO_VIRTUAL_SCROLL_SELECTION: WeakMap<slate.BaseEditor, slate.BaseRange>;
681
692
  declare const EDITOR_TO_AFTER_VIEW_INIT_QUEUE: WeakMap<Editor, (() => void)[]>;
682
693
 
683
694
  /**
@@ -728,8 +739,7 @@ declare const IS_QQBROWSER: boolean;
728
739
  declare const IS_UC_MOBILE: boolean;
729
740
  declare const IS_WECHATBROWSER: boolean;
730
741
  declare const HAS_BEFORE_INPUT_SUPPORT: boolean;
731
- declare const VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT = 3;
732
- declare const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 40;
742
+ declare const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 30;
733
743
  declare const SLATE_DEBUG_KEY = "__SLATE_DEBUG__";
734
744
 
735
745
  declare const shallowCompare: (obj1: {}, obj2: {}) => boolean;
@@ -808,5 +818,15 @@ declare const getSelection: (root: Document | ShadowRoot) => Selection | null;
808
818
  declare const getContentHeight: (element: Element) => number;
809
819
  declare const getZeroTextNode: () => DOMText;
810
820
 
811
- export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, 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_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, JUST_NOW_UPDATED_VIRTUAL_VIEW, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT, VoidTextFlavour, blobAsString, buildHTMLText, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
821
+ declare const ELEMENT_KEY_TO_HEIGHTS: WeakMap<AngularEditor, Map<string, number>>;
822
+ declare const EDITOR_TO_BUSINESS_TOP: WeakMap<AngularEditor, number>;
823
+ declare const getBusinessTop: (editor: AngularEditor) => number;
824
+ declare const getRealHeightByElement: (editor: AngularEditor, element: Element$1, defaultHeight?: number) => number;
825
+ declare const buildHeightsAndAccumulatedHeights: (editor: AngularEditor) => {
826
+ heights: any[];
827
+ accumulatedHeights: any[];
828
+ };
829
+ declare const scrollToElement: (editor: AngularEditor, element: Element$1, scrollTo: (scrollTop: number) => void) => void;
830
+
831
+ 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 };
812
832
  export type { AfterContextChange, BaseEmbeddedView, BeforeContextChange, ClipboardData, ComponentType, OriginEvent, SafeAny, SlateChildrenContext, SlateElementAttributes, SlateElementContext, SlateError, SlateLeafContext, SlatePlaceholder, SlateStringContext, SlateTextContext, SlateViewContext, SlateVirtualScrollConfig, ThrottleRAF, ViewType, VirtualViewResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-angular",
3
- "version": "20.2.0-next.2",
3
+ "version": "20.2.0-next.20",
4
4
  "description": "Angular view layer for Slate",
5
5
  "author": "pubuzhixing <pubuzhixing@gmail.com>",
6
6
  "homepage": "https://github.com/worktile/slate-angular#readme",