slate-angular 17.1.2 → 17.1.3

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.
@@ -47,6 +47,7 @@ const PLACEHOLDER_SYMBOL = Symbol('placeholder');
47
47
  * Weak map for associating the html element with the component.
48
48
  */
49
49
  const ELEMENT_TO_COMPONENT = new WeakMap();
50
+ const EDITOR_TO_AFTER_VIEW_INIT_QUEUE = new WeakMap();
50
51
 
51
52
  /**
52
53
  * Types.
@@ -1837,11 +1838,6 @@ function createEmbeddedViewOrComponent(viewType, context, viewContext, viewConta
1837
1838
  return componentRef;
1838
1839
  }
1839
1840
  }
1840
- function executeAfterViewInit(view) {
1841
- if (view instanceof ComponentRef && view.instance.afterViewInit) {
1842
- view.instance.afterViewInit();
1843
- }
1844
- }
1845
1841
  function updateContext(view, newContext, viewContext) {
1846
1842
  if (view instanceof ComponentRef) {
1847
1843
  view.instance.context = newContext;
@@ -1937,7 +1933,7 @@ class ListRender {
1937
1933
  this.getOutletParent = getOutletParent;
1938
1934
  this.getOutletElement = getOutletElement;
1939
1935
  this.views = [];
1940
- this.addedViews = [];
1936
+ // private addedViews: (EmbeddedViewRef<any> | ComponentRef<any>)[] = [];
1941
1937
  this.blockCards = [];
1942
1938
  this.contexts = [];
1943
1939
  this.viewTypes = [];
@@ -1956,7 +1952,6 @@ class ListRender {
1956
1952
  const view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
1957
1953
  const blockCard = createBlockCard(descendant, view, this.viewContainerRef, this.viewContext);
1958
1954
  this.views.push(view);
1959
- this.addedViews.push(view);
1960
1955
  this.contexts.push(context);
1961
1956
  this.viewTypes.push(viewType);
1962
1957
  this.blockCards.push(blockCard);
@@ -1966,7 +1961,7 @@ class ListRender {
1966
1961
  this.differ = newDiffers.find(children).create(trackBy$1(this.viewContext));
1967
1962
  this.differ.diff(children);
1968
1963
  if (parent === this.viewContext.editor) {
1969
- this.afterViewInit();
1964
+ executeAfterViewInit(this.viewContext.editor);
1970
1965
  }
1971
1966
  }
1972
1967
  update(children, parent, childrenContext) {
@@ -1999,7 +1994,6 @@ class ListRender {
1999
1994
  blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
2000
1995
  newContexts.push(context);
2001
1996
  newViews.push(view);
2002
- this.addedViews.push(view);
2003
1997
  newBlockCards.push(blockCard);
2004
1998
  mountOnItemChange(record.currentIndex, record.item, newViews, newBlockCards, outletParent, firstRootNode, this.viewContext);
2005
1999
  }
@@ -2010,7 +2004,6 @@ class ListRender {
2010
2004
  const previousBlockCard = this.blockCards[record.previousIndex];
2011
2005
  if (previousViewType !== viewType) {
2012
2006
  view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
2013
- this.addedViews.push(view);
2014
2007
  blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
2015
2008
  const firstRootNode = getRootNodes(previousView, previousBlockCard)[0];
2016
2009
  const newRootNodes = getRootNodes(view, blockCard);
@@ -2054,7 +2047,7 @@ class ListRender {
2054
2047
  this.children = children;
2055
2048
  this.blockCards = newBlockCards;
2056
2049
  if (parent === this.viewContext.editor) {
2057
- this.afterViewInit();
2050
+ executeAfterViewInit(this.viewContext.editor);
2058
2051
  }
2059
2052
  }
2060
2053
  else {
@@ -2075,12 +2068,6 @@ class ListRender {
2075
2068
  this.contexts = newContexts;
2076
2069
  }
2077
2070
  }
2078
- afterViewInit() {
2079
- this.addedViews.forEach(view => {
2080
- executeAfterViewInit(view);
2081
- });
2082
- this.addedViews = [];
2083
- }
2084
2071
  destroy() {
2085
2072
  this.children.forEach((element, index) => {
2086
2073
  if (this.views[index]) {
@@ -2213,6 +2200,22 @@ function memoizedTextContext(prev, next) {
2213
2200
  next.text === prev.text &&
2214
2201
  isDecoratorRangeListEqual(next.decorations, prev.decorations));
2215
2202
  }
2203
+ function addAfterViewInitQueue(editor, afterViewInitCallback) {
2204
+ const queue = getAfterViewInitQueue(editor);
2205
+ queue.push(afterViewInitCallback);
2206
+ EDITOR_TO_AFTER_VIEW_INIT_QUEUE.set(editor, queue);
2207
+ }
2208
+ function getAfterViewInitQueue(editor) {
2209
+ return EDITOR_TO_AFTER_VIEW_INIT_QUEUE.get(editor) || [];
2210
+ }
2211
+ function clearAfterViewInitQueue(editor) {
2212
+ EDITOR_TO_AFTER_VIEW_INIT_QUEUE.set(editor, []);
2213
+ }
2214
+ function executeAfterViewInit(editor) {
2215
+ const queue = getAfterViewInitQueue(editor);
2216
+ queue.forEach(callback => callback());
2217
+ clearAfterViewInitQueue(editor);
2218
+ }
2216
2219
 
2217
2220
  class LeavesRender {
2218
2221
  constructor(viewContext, viewContainerRef, getOutletParent, getOutletElement) {
@@ -2492,12 +2495,14 @@ class BaseElementComponent extends BaseComponent {
2492
2495
  if (this.editor.isExpanded(this.element)) {
2493
2496
  this.listRender.initialize(this.children, this.element, this.childrenContext);
2494
2497
  }
2498
+ addAfterViewInitQueue(this.editor, () => {
2499
+ this.afterViewInit();
2500
+ });
2495
2501
  }
2496
2502
  afterViewInit() {
2497
2503
  if (this._context.contentEditable !== undefined) {
2498
2504
  this.nativeElement.setAttribute('contenteditable', this._context.contentEditable + '');
2499
2505
  }
2500
- this.listRender.afterViewInit();
2501
2506
  }
2502
2507
  updateWeakMap() {
2503
2508
  NODE_TO_ELEMENT.set(this.element, this.nativeElement);
@@ -4306,5 +4311,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
4306
4311
  * Generated bundle index. Do not edit.
4307
4312
  */
4308
4313
 
4309
- export { AngularEditor, BaseComponent, BaseElementComponent, BaseLeafComponent, BaseTextComponent, DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, EDITOR_TO_ELEMENT, EDITOR_TO_ON_CHANGE, EDITOR_TO_PLACEHOLDER, EDITOR_TO_WINDOW, ELEMENT_TO_COMPONENT, ELEMENT_TO_NODE, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_CLICKING, IS_DRAGGING, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_FOCUSED, IS_IOS, IS_QQBROWSER, IS_READONLY, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, KEY_TO_ELEMENT, Key, NODE_TO_ELEMENT, NODE_TO_INDEX, NODE_TO_KEY, NODE_TO_PARENT, PLACEHOLDER_SYMBOL, SlateChildren, SlateChildrenOutlet, SlateDefaultString, SlateEditable, SlateElement, SlateErrorCode, SlateLeaves, SlateModule, SlateString, check, createThrottleRAF, defaultScrollSelectionIntoView, getCardTargetAttribute, getClipboardData, getDefaultView, getEditableChild, getEditableChildAndIndex, getPlainText, getSlateFragmentAttribute, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hasEditableTarget, hasShadowRoot, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isComponentType, isDOMComment, isDOMElement, isDOMNode, isDOMSelection, isDOMText, isDecoratorRangeListEqual, isEmpty, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, shallowCompare, withAngular };
4314
+ export { AngularEditor, BaseComponent, BaseElementComponent, BaseLeafComponent, BaseTextComponent, DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, EDITOR_TO_ELEMENT, EDITOR_TO_ON_CHANGE, EDITOR_TO_PLACEHOLDER, EDITOR_TO_WINDOW, ELEMENT_TO_COMPONENT, ELEMENT_TO_NODE, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_CLICKING, IS_DRAGGING, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_FOCUSED, IS_IOS, IS_QQBROWSER, IS_READONLY, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, KEY_TO_ELEMENT, Key, NODE_TO_ELEMENT, NODE_TO_INDEX, NODE_TO_KEY, NODE_TO_PARENT, PLACEHOLDER_SYMBOL, SlateChildren, SlateChildrenOutlet, SlateDefaultString, SlateEditable, SlateElement, SlateErrorCode, SlateLeaves, SlateModule, SlateString, check, createThrottleRAF, defaultScrollSelectionIntoView, getCardTargetAttribute, getClipboardData, getDefaultView, getEditableChild, getEditableChildAndIndex, getPlainText, getSlateFragmentAttribute, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hasEditableTarget, hasShadowRoot, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isComponentType, isDOMComment, isDOMElement, isDOMNode, isDOMSelection, isDOMText, isDecoratorRangeListEqual, isEmpty, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, shallowCompare, withAngular };
4310
4315
  //# sourceMappingURL=slate-angular.mjs.map