slate-angular 20.1.0 → 20.2.0-next.1

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
@@ -314,6 +314,24 @@ declare class ListRender {
314
314
  destroy(): void;
315
315
  }
316
316
 
317
+ interface SlateVirtualScrollConfig {
318
+ enabled?: boolean;
319
+ scrollTop: number;
320
+ viewportHeight: number;
321
+ blockHeight?: number;
322
+ bufferCount?: number;
323
+ }
324
+ interface VirtualViewResult {
325
+ renderedChildren: Element$1[];
326
+ visibleIndexes: Set<number>;
327
+ top: number;
328
+ bottom: number;
329
+ heights: number[];
330
+ }
331
+
332
+ type SafeAny = any;
333
+
334
+ declare const JUST_NOW_UPDATED_VIRTUAL_VIEW: WeakMap<AngularEditor, boolean>;
317
335
  declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewChecked, DoCheck {
318
336
  elementRef: ElementRef;
319
337
  renderer2: Renderer2;
@@ -342,6 +360,7 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
342
360
  trackBy: (node: Element$1) => any;
343
361
  readonly: boolean;
344
362
  placeholder: string;
363
+ set virtualScroll(config: SlateVirtualScrollConfig);
345
364
  beforeInput: (event: Event) => void;
346
365
  blur: (event: Event) => void;
347
366
  click: (event: MouseEvent) => void;
@@ -366,7 +385,15 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
366
385
  get hasBeforeInputSupport(): boolean;
367
386
  viewContainerRef: ViewContainerRef;
368
387
  getOutletParent: () => any;
388
+ getOutletElement: () => HTMLElement;
369
389
  listRender: ListRender;
390
+ private virtualConfig;
391
+ private renderedChildren;
392
+ private virtualVisibleIndexes;
393
+ private measuredHeights;
394
+ private measurePending;
395
+ private refreshVirtualViewAnimId;
396
+ private measureVisibleHeightsAnimId;
370
397
  constructor(elementRef: ElementRef, renderer2: Renderer2, cdr: ChangeDetectorRef, ngZone: NgZone, injector: Injector);
371
398
  ngOnInit(): void;
372
399
  ngOnChanges(simpleChanges: SimpleChanges): void;
@@ -385,6 +412,21 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
385
412
  initializeViewContext(): void;
386
413
  composePlaceholderDecorate(editor: Editor): SlatePlaceholder[];
387
414
  generateDecorations(): slate.BaseRange[];
415
+ private shouldUseVirtual;
416
+ virtualScrollInitialized: boolean;
417
+ virtualTopHeightElement: HTMLElement;
418
+ virtualBottomHeightElement: HTMLElement;
419
+ virtualCenterOutlet: HTMLElement;
420
+ initializeVirtualScrolling(): void;
421
+ changeVirtualHeight(topHeight: number, bottomHeight: number): void;
422
+ private refreshVirtualView;
423
+ private applyVirtualView;
424
+ private diffVirtualView;
425
+ private getBlockHeight;
426
+ private buildAccumulatedHeight;
427
+ private getBufferBelowHeight;
428
+ private scheduleMeasureVisibleHeights;
429
+ private measureVisibleHeights;
388
430
  private addEventListener;
389
431
  private toSlateSelection;
390
432
  private onDOMBeforeInput;
@@ -406,7 +448,7 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
406
448
  private isDOMEventHandled;
407
449
  ngOnDestroy(): void;
408
450
  static ɵfac: i0.ɵɵFactoryDeclaration<SlateEditable, never>;
409
- static ɵcmp: i0.ɵɵComponentDeclaration<SlateEditable, "slate-editable", never, { "editor": { "alias": "editor"; "required": false; }; "renderElement": { "alias": "renderElement"; "required": false; }; "renderLeaf": { "alias": "renderLeaf"; "required": false; }; "renderText": { "alias": "renderText"; "required": false; }; "decorate": { "alias": "decorate"; "required": false; }; "placeholderDecorate": { "alias": "placeholderDecorate"; "required": false; }; "scrollSelectionIntoView": { "alias": "scrollSelectionIntoView"; "required": false; }; "isStrictDecorate": { "alias": "isStrictDecorate"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "beforeInput": { "alias": "beforeInput"; "required": false; }; "blur": { "alias": "blur"; "required": false; }; "click": { "alias": "click"; "required": false; }; "compositionEnd": { "alias": "compositionEnd"; "required": false; }; "compositionUpdate": { "alias": "compositionUpdate"; "required": false; }; "compositionStart": { "alias": "compositionStart"; "required": false; }; "copy": { "alias": "copy"; "required": false; }; "cut": { "alias": "cut"; "required": false; }; "dragOver": { "alias": "dragOver"; "required": false; }; "dragStart": { "alias": "dragStart"; "required": false; }; "dragEnd": { "alias": "dragEnd"; "required": false; }; "drop": { "alias": "drop"; "required": false; }; "focus": { "alias": "focus"; "required": false; }; "keydown": { "alias": "keydown"; "required": false; }; "paste": { "alias": "paste"; "required": false; }; "spellCheck": { "alias": "spellCheck"; "required": false; }; "autoCorrect": { "alias": "autoCorrect"; "required": false; }; "autoCapitalize": { "alias": "autoCapitalize"; "required": false; }; }, {}, never, never, true, never>;
451
+ static ɵcmp: i0.ɵɵComponentDeclaration<SlateEditable, "slate-editable", never, { "editor": { "alias": "editor"; "required": false; }; "renderElement": { "alias": "renderElement"; "required": false; }; "renderLeaf": { "alias": "renderLeaf"; "required": false; }; "renderText": { "alias": "renderText"; "required": false; }; "decorate": { "alias": "decorate"; "required": false; }; "placeholderDecorate": { "alias": "placeholderDecorate"; "required": false; }; "scrollSelectionIntoView": { "alias": "scrollSelectionIntoView"; "required": false; }; "isStrictDecorate": { "alias": "isStrictDecorate"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "virtualScroll": { "alias": "virtualScroll"; "required": false; }; "beforeInput": { "alias": "beforeInput"; "required": false; }; "blur": { "alias": "blur"; "required": false; }; "click": { "alias": "click"; "required": false; }; "compositionEnd": { "alias": "compositionEnd"; "required": false; }; "compositionUpdate": { "alias": "compositionUpdate"; "required": false; }; "compositionStart": { "alias": "compositionStart"; "required": false; }; "copy": { "alias": "copy"; "required": false; }; "cut": { "alias": "cut"; "required": false; }; "dragOver": { "alias": "dragOver"; "required": false; }; "dragStart": { "alias": "dragStart"; "required": false; }; "dragEnd": { "alias": "dragEnd"; "required": false; }; "drop": { "alias": "drop"; "required": false; }; "focus": { "alias": "focus"; "required": false; }; "keydown": { "alias": "keydown"; "required": false; }; "paste": { "alias": "paste"; "required": false; }; "spellCheck": { "alias": "spellCheck"; "required": false; }; "autoCorrect": { "alias": "autoCorrect"; "required": false; }; "autoCapitalize": { "alias": "autoCapitalize"; "required": false; }; }, {}, never, never, true, never>;
410
452
  }
411
453
  declare const defaultScrollSelectionIntoView: (editor: AngularEditor, domRange: DOMRange) => void;
412
454
 
@@ -538,6 +580,7 @@ declare class BaseElementComponent<T extends Element$1 = Element$1, K extends An
538
580
  onContextChange(): void;
539
581
  updateChildrenView(): void;
540
582
  getChildrenContext(): SlateChildrenContext;
583
+ getRealHeight(): Promise<number>;
541
584
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseElementComponent<any, any>, never>;
542
585
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseElementComponent<any, any>, never, never, {}, {}, never, never, true, never>;
543
586
  }
@@ -577,6 +620,7 @@ declare class BaseLeafComponent extends BaseComponent<SlateLeafContext> implemen
577
620
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseLeafComponent, never, never, {}, {}, never, never, true, never>;
578
621
  }
579
622
 
623
+ declare const DEFAULT_ELEMENT_HEIGHT = 24;
580
624
  declare abstract class BaseElementFlavour<T extends Element$1 = Element$1, K extends AngularEditor = AngularEditor> extends BaseFlavour<SlateElementContext<T>, K> {
581
625
  childrenContext: SlateChildrenContext;
582
626
  get element(): T;
@@ -596,6 +640,7 @@ declare abstract class BaseElementFlavour<T extends Element$1 = Element$1, K ext
596
640
  onContextChange(): void;
597
641
  updateChildrenView(): void;
598
642
  getChildrenContext(): SlateChildrenContext;
643
+ getRealHeight(): Promise<number>;
599
644
  abstract render(): void;
600
645
  abstract rerender(): void;
601
646
  }
@@ -682,6 +727,9 @@ declare const IS_QQBROWSER: boolean;
682
727
  declare const IS_UC_MOBILE: boolean;
683
728
  declare const IS_WECHATBROWSER: boolean;
684
729
  declare const HAS_BEFORE_INPUT_SUPPORT: boolean;
730
+ declare const VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT = 3;
731
+ declare const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 40;
732
+ declare const SLATE_DEBUG_KEY = "__SLATE_DEBUG__";
685
733
 
686
734
  declare const shallowCompare: (obj1: {}, obj2: {}) => boolean;
687
735
  /**
@@ -759,7 +807,5 @@ declare const getSelection: (root: Document | ShadowRoot) => Selection | null;
759
807
  declare const getContentHeight: (element: Element) => number;
760
808
  declare const getZeroTextNode: () => DOMText;
761
809
 
762
- type SafeAny = any;
763
-
764
- export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, 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, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, 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 };
765
- export type { AfterContextChange, BaseEmbeddedView, BeforeContextChange, ClipboardData, ComponentType, OriginEvent, SafeAny, SlateChildrenContext, SlateElementAttributes, SlateElementContext, SlateError, SlateLeafContext, SlatePlaceholder, SlateStringContext, SlateTextContext, SlateViewContext, ThrottleRAF, ViewType };
810
+ 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 };
811
+ 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.1.0",
3
+ "version": "20.2.0-next.1",
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",
package/styles/index.scss CHANGED
@@ -2,7 +2,7 @@
2
2
  .slate-editable-container {
3
3
  display: block;
4
4
  outline: none;
5
- padding: 32px;
5
+ padding: 0 32px;
6
6
  white-space: break-spaces;
7
7
  & [contenteditable='true'] {
8
8
  outline: none;