slate-angular 20.0.0 → 20.2.0-next.0

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
@@ -3,7 +3,7 @@ import { DOMEditor, DOMNode, DOMElement, DOMPoint, DOMRange, DOMStaticRange, DOM
3
3
  import * as slate from 'slate';
4
4
  import { Descendant, Range as Range$1, Node, Editor, NodeEntry, Point, Element as Element$1, Path, Text, LeafPosition, Ancestor, BaseRange } from 'slate';
5
5
  import * as i0 from '@angular/core';
6
- import { Injector, ViewContainerRef, TemplateRef, OnInit, ElementRef, OnChanges, OnDestroy, AfterViewChecked, DoCheck, Renderer2, ChangeDetectorRef, NgZone, SimpleChanges } from '@angular/core';
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';
8
8
 
9
9
  declare enum SlateErrorCode {
@@ -274,24 +274,27 @@ interface SlatePlaceholder extends BaseRange {
274
274
  placeholder: string;
275
275
  }
276
276
 
277
- declare class SlateBlockCard implements OnInit {
278
- private elementRef;
279
- centerContainer: ElementRef;
277
+ declare const SLATE_BLOCK_CARD_CLASS_NAME = "slate-block-card";
278
+ declare class SlateBlockCard {
280
279
  centerRootNodes: HTMLElement[];
281
- get nativeElement(): any;
282
- get centerContainerElement(): HTMLElement;
283
- constructor(elementRef: ElementRef);
284
- ngOnInit(): void;
280
+ nativeElement: HTMLElement;
281
+ centerContainer: HTMLElement;
282
+ onInit(): void;
283
+ createContent(): void;
285
284
  append(): void;
286
285
  initializeCenter(rootNodes: HTMLElement[]): void;
287
- static ɵfac: i0.ɵɵFactoryDeclaration<SlateBlockCard, never>;
288
- static ɵcmp: i0.ɵɵComponentDeclaration<SlateBlockCard, "slate-block-card, [slateBlockCard]", never, {}, {}, never, never, true, never>;
286
+ onDestroy(): void;
289
287
  }
288
+ declare const getBlockCardByNativeElement: (nativeElement: HTMLElement) => HTMLElement;
290
289
 
291
290
  declare class FlavourRef {
292
291
  instance: BaseFlavour;
293
292
  destroy(): void;
294
293
  }
294
+ declare class BlockCardRef {
295
+ instance: SlateBlockCard;
296
+ destroy(): void;
297
+ }
295
298
 
296
299
  declare class ListRender {
297
300
  private viewContext;
@@ -311,6 +314,12 @@ declare class ListRender {
311
314
  destroy(): void;
312
315
  }
313
316
 
317
+ interface SlateVirtualScrollConfig {
318
+ enabled?: boolean;
319
+ scrollTop: number;
320
+ viewportHeight: number;
321
+ bufferCount?: number;
322
+ }
314
323
  declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewChecked, DoCheck {
315
324
  elementRef: ElementRef;
316
325
  renderer2: Renderer2;
@@ -339,6 +348,9 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
339
348
  trackBy: (node: Element$1) => any;
340
349
  readonly: boolean;
341
350
  placeholder: string;
351
+ set virtualScroll(config: SlateVirtualScrollConfig);
352
+ virtualTopPadding: number;
353
+ virtualBottomPadding: number;
342
354
  beforeInput: (event: Event) => void;
343
355
  blur: (event: Event) => void;
344
356
  click: (event: MouseEvent) => void;
@@ -364,6 +376,13 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
364
376
  viewContainerRef: ViewContainerRef;
365
377
  getOutletParent: () => any;
366
378
  listRender: ListRender;
379
+ private virtualConfig;
380
+ private renderedChildren;
381
+ private virtualVisibleIndexes;
382
+ private measuredHeights;
383
+ private measurePending;
384
+ private refreshVirtualViewAnimId;
385
+ private measureVisibleHeightsAnimId;
367
386
  constructor(elementRef: ElementRef, renderer2: Renderer2, cdr: ChangeDetectorRef, ngZone: NgZone, injector: Injector);
368
387
  ngOnInit(): void;
369
388
  ngOnChanges(simpleChanges: SimpleChanges): void;
@@ -382,6 +401,13 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
382
401
  initializeViewContext(): void;
383
402
  composePlaceholderDecorate(editor: Editor): SlatePlaceholder[];
384
403
  generateDecorations(): slate.BaseRange[];
404
+ private shouldUseVirtual;
405
+ private refreshVirtualView;
406
+ private getBlockHeight;
407
+ private buildAccumulatedHeight;
408
+ private getBufferBelowHeight;
409
+ private scheduleMeasureVisibleHeights;
410
+ private measureVisibleHeights;
385
411
  private addEventListener;
386
412
  private toSlateSelection;
387
413
  private onDOMBeforeInput;
@@ -403,7 +429,7 @@ declare class SlateEditable implements OnInit, OnChanges, OnDestroy, AfterViewCh
403
429
  private isDOMEventHandled;
404
430
  ngOnDestroy(): void;
405
431
  static ɵfac: i0.ɵɵFactoryDeclaration<SlateEditable, never>;
406
- 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>;
432
+ 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>;
407
433
  }
408
434
  declare const defaultScrollSelectionIntoView: (editor: AngularEditor, domRange: DOMRange) => void;
409
435
 
@@ -456,17 +482,9 @@ declare const createText: (text: string) => {
456
482
  nativeElement: HTMLSpanElement;
457
483
  };
458
484
 
459
- declare class SlateString {
460
- context: SlateLeafContext;
461
- viewContext: SlateViewContext;
462
- ngOnInit(): void;
463
- static ɵfac: i0.ɵɵFactoryDeclaration<SlateString, never>;
464
- static ɵcmp: i0.ɵɵComponentDeclaration<SlateString, "span[slateString]", never, { "context": { "alias": "context"; "required": false; }; "viewContext": { "alias": "viewContext"; "required": false; }; }, {}, never, never, true, never>;
465
- }
466
-
467
485
  declare class SlateModule {
468
486
  static ɵfac: i0.ɵɵFactoryDeclaration<SlateModule, never>;
469
- static ɵmod: i0.ɵɵNgModuleDeclaration<SlateModule, never, [typeof i1.CommonModule, typeof SlateEditable, typeof SlateBlockCard, typeof SlateChildrenOutlet, typeof SlateString], [typeof SlateEditable, typeof SlateChildrenOutlet, typeof SlateString]>;
487
+ static ɵmod: i0.ɵɵNgModuleDeclaration<SlateModule, never, [typeof i1.CommonModule, typeof SlateEditable, typeof SlateChildrenOutlet], [typeof SlateEditable, typeof SlateChildrenOutlet]>;
470
488
  static ɵinj: i0.ɵɵInjectorDeclaration<SlateModule>;
471
489
  }
472
490
 
@@ -543,6 +561,7 @@ declare class BaseElementComponent<T extends Element$1 = Element$1, K extends An
543
561
  onContextChange(): void;
544
562
  updateChildrenView(): void;
545
563
  getChildrenContext(): SlateChildrenContext;
564
+ getRealHeight(): Promise<number>;
546
565
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseElementComponent<any, any>, never>;
547
566
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseElementComponent<any, any>, never, never, {}, {}, never, never, true, never>;
548
567
  }
@@ -582,6 +601,7 @@ declare class BaseLeafComponent extends BaseComponent<SlateLeafContext> implemen
582
601
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseLeafComponent, never, never, {}, {}, never, never, true, never>;
583
602
  }
584
603
 
604
+ declare const DEFAULT_ELEMENT_HEIGHT = 24;
585
605
  declare abstract class BaseElementFlavour<T extends Element$1 = Element$1, K extends AngularEditor = AngularEditor> extends BaseFlavour<SlateElementContext<T>, K> {
586
606
  childrenContext: SlateChildrenContext;
587
607
  get element(): T;
@@ -601,6 +621,7 @@ declare abstract class BaseElementFlavour<T extends Element$1 = Element$1, K ext
601
621
  onContextChange(): void;
602
622
  updateChildrenView(): void;
603
623
  getChildrenContext(): SlateChildrenContext;
624
+ getRealHeight(): Promise<number>;
604
625
  abstract render(): void;
605
626
  abstract rerender(): void;
606
627
  }
@@ -687,6 +708,8 @@ declare const IS_QQBROWSER: boolean;
687
708
  declare const IS_UC_MOBILE: boolean;
688
709
  declare const IS_WECHATBROWSER: boolean;
689
710
  declare const HAS_BEFORE_INPUT_SUPPORT: boolean;
711
+ declare const VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT = 3;
712
+ declare const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 40;
690
713
 
691
714
  declare const shallowCompare: (obj1: {}, obj2: {}) => boolean;
692
715
  /**
@@ -762,8 +785,9 @@ declare const getPlainText: (domNode: DOMNode) => string;
762
785
  */
763
786
  declare const getSelection: (root: Document | ShadowRoot) => Selection | null;
764
787
  declare const getContentHeight: (element: Element) => number;
788
+ declare const getZeroTextNode: () => DOMText;
765
789
 
766
790
  type SafeAny = any;
767
791
 
768
- export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, 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, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, SlateString, VoidTextFlavour, blobAsString, buildHTMLText, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getSelection, getSlateFragmentAttribute, 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 };
769
- export type { AfterContextChange, BaseEmbeddedView, BeforeContextChange, ClipboardData, ComponentType, OriginEvent, SafeAny, SlateChildrenContext, SlateElementAttributes, SlateElementContext, SlateError, SlateLeafContext, SlatePlaceholder, SlateStringContext, SlateTextContext, SlateViewContext, ThrottleRAF, ViewType };
792
+ 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, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, 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 };
793
+ export type { AfterContextChange, BaseEmbeddedView, BeforeContextChange, ClipboardData, ComponentType, OriginEvent, SafeAny, SlateChildrenContext, SlateElementAttributes, SlateElementContext, SlateError, SlateLeafContext, SlatePlaceholder, SlateStringContext, SlateTextContext, SlateViewContext, SlateVirtualScrollConfig, ThrottleRAF, ViewType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slate-angular",
3
- "version": "20.0.0",
3
+ "version": "20.2.0-next.0",
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,8 +2,21 @@
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
+ &::before,
8
+ &::after {
9
+ content: '';
10
+ display: block;
11
+ pointer-events: none;
12
+ height: 0;
13
+ }
14
+ &::before {
15
+ height: var(--virtual-top-padding, 0px);
16
+ }
17
+ &::after {
18
+ height: var(--virtual-bottom-padding, 0px);
19
+ }
7
20
  & [contenteditable='true'] {
8
21
  outline: none;
9
22
  }