slate-angular 16.1.0-next.17 → 16.1.0-next.19
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/components/text/void-text.component.d.ts +0 -1
- package/esm2022/components/editable/editable.component.mjs +5 -2
- package/esm2022/components/text/void-text.component.mjs +2 -6
- package/esm2022/view/base.mjs +7 -1
- package/esm2022/view/context.mjs +1 -1
- package/esm2022/view/render/list-render.mjs +22 -4
- package/esm2022/view/render/utils.mjs +4 -7
- package/fesm2022/slate-angular.mjs +34 -13
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/package.json +1 -1
- package/view/base.d.ts +1 -0
- package/view/context.d.ts +1 -1
- package/view/render/list-render.d.ts +2 -0
- package/view/render/utils.d.ts +1 -1
|
@@ -1836,12 +1836,9 @@ function createEmbeddedViewOrComponent(viewType, context, viewContext, viewConta
|
|
|
1836
1836
|
return componentRef;
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
|
-
function
|
|
1840
|
-
if (view instanceof ComponentRef) {
|
|
1841
|
-
view.
|
|
1842
|
-
}
|
|
1843
|
-
else {
|
|
1844
|
-
view.detectChanges();
|
|
1839
|
+
function executeAfterViewInit(view) {
|
|
1840
|
+
if (view instanceof ComponentRef && view.instance.afterViewInit) {
|
|
1841
|
+
view.instance.afterViewInit();
|
|
1845
1842
|
}
|
|
1846
1843
|
}
|
|
1847
1844
|
function updateContext(view, newContext, viewContext) {
|
|
@@ -1939,6 +1936,7 @@ class ListRender {
|
|
|
1939
1936
|
this.getOutletParent = getOutletParent;
|
|
1940
1937
|
this.getOutletElement = getOutletElement;
|
|
1941
1938
|
this.views = [];
|
|
1939
|
+
this.addedViews = [];
|
|
1942
1940
|
this.blockCards = [];
|
|
1943
1941
|
this.contexts = [];
|
|
1944
1942
|
this.viewTypes = [];
|
|
@@ -1957,6 +1955,7 @@ class ListRender {
|
|
|
1957
1955
|
const view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1958
1956
|
const blockCard = createBlockCard(descendant, view, this.viewContainerRef, this.viewContext);
|
|
1959
1957
|
this.views.push(view);
|
|
1958
|
+
this.addedViews.push(view);
|
|
1960
1959
|
this.contexts.push(context);
|
|
1961
1960
|
this.viewTypes.push(viewType);
|
|
1962
1961
|
this.blockCards.push(blockCard);
|
|
@@ -1965,6 +1964,9 @@ class ListRender {
|
|
|
1965
1964
|
const newDiffers = this.viewContainerRef.injector.get(IterableDiffers);
|
|
1966
1965
|
this.differ = newDiffers.find(children).create(trackBy$1(this.viewContext));
|
|
1967
1966
|
this.differ.diff(children);
|
|
1967
|
+
if (parent === this.viewContext.editor) {
|
|
1968
|
+
this.afterViewInit();
|
|
1969
|
+
}
|
|
1968
1970
|
}
|
|
1969
1971
|
update(children, parent, childrenContext) {
|
|
1970
1972
|
if (!this.initialized || this.children.length === 0) {
|
|
@@ -1996,6 +1998,7 @@ class ListRender {
|
|
|
1996
1998
|
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
1997
1999
|
newContexts.push(context);
|
|
1998
2000
|
newViews.push(view);
|
|
2001
|
+
this.addedViews.push(view);
|
|
1999
2002
|
newBlockCards.push(blockCard);
|
|
2000
2003
|
mountOnItemChange(record.currentIndex, record.item, newViews, newBlockCards, outletParent, firstRootNode, this.viewContext);
|
|
2001
2004
|
}
|
|
@@ -2006,6 +2009,7 @@ class ListRender {
|
|
|
2006
2009
|
const previousBlockCard = this.blockCards[record.previousIndex];
|
|
2007
2010
|
if (previousViewType !== viewType) {
|
|
2008
2011
|
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2012
|
+
this.addedViews.push(view);
|
|
2009
2013
|
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
2010
2014
|
const firstRootNode = getRootNodes(previousView, previousBlockCard)[0];
|
|
2011
2015
|
const newRootNodes = getRootNodes(view, blockCard);
|
|
@@ -2048,10 +2052,15 @@ class ListRender {
|
|
|
2048
2052
|
this.contexts = newContexts;
|
|
2049
2053
|
this.children = children;
|
|
2050
2054
|
this.blockCards = newBlockCards;
|
|
2055
|
+
if (parent === this.viewContext.editor) {
|
|
2056
|
+
this.afterViewInit();
|
|
2057
|
+
}
|
|
2051
2058
|
}
|
|
2052
2059
|
else {
|
|
2053
2060
|
const newContexts = [];
|
|
2054
2061
|
this.children.forEach((child, index) => {
|
|
2062
|
+
NODE_TO_INDEX.set(child, index);
|
|
2063
|
+
NODE_TO_PARENT.set(child, parent);
|
|
2055
2064
|
let context = getContext$1(index, child, parentPath, childrenContext, this.viewContext);
|
|
2056
2065
|
const previousContext = this.contexts[index];
|
|
2057
2066
|
if (memoizedContext(this.viewContext, child, previousContext, context)) {
|
|
@@ -2065,6 +2074,12 @@ class ListRender {
|
|
|
2065
2074
|
this.contexts = newContexts;
|
|
2066
2075
|
}
|
|
2067
2076
|
}
|
|
2077
|
+
afterViewInit() {
|
|
2078
|
+
this.addedViews.forEach(view => {
|
|
2079
|
+
executeAfterViewInit(view);
|
|
2080
|
+
});
|
|
2081
|
+
this.addedViews = [];
|
|
2082
|
+
}
|
|
2068
2083
|
destroy() {
|
|
2069
2084
|
this.children.forEach((element, index) => {
|
|
2070
2085
|
if (this.views[index]) {
|
|
@@ -2103,7 +2118,7 @@ function getContext$1(index, item, parentPath, childrenContext, viewContext) {
|
|
|
2103
2118
|
}
|
|
2104
2119
|
if (isVoid) {
|
|
2105
2120
|
elementContext.attributes['data-slate-void'] = true;
|
|
2106
|
-
elementContext.
|
|
2121
|
+
elementContext.contentEditable = false;
|
|
2107
2122
|
}
|
|
2108
2123
|
return elementContext;
|
|
2109
2124
|
}
|
|
@@ -2140,7 +2155,7 @@ function getCommonContext(index, item, parentPath, viewContext, childrenContext)
|
|
|
2140
2155
|
}
|
|
2141
2156
|
}
|
|
2142
2157
|
catch (error) {
|
|
2143
|
-
|
|
2158
|
+
viewContext.editor.onError({
|
|
2144
2159
|
code: SlateErrorCode.GetStartPointError,
|
|
2145
2160
|
nativeError: error
|
|
2146
2161
|
});
|
|
@@ -2477,6 +2492,12 @@ class BaseElementComponent extends BaseComponent {
|
|
|
2477
2492
|
this.listRender.initialize(this.children, this.element, this.childrenContext);
|
|
2478
2493
|
}
|
|
2479
2494
|
}
|
|
2495
|
+
afterViewInit() {
|
|
2496
|
+
if (this._context.contentEditable !== undefined) {
|
|
2497
|
+
this.nativeElement.setAttribute('contenteditable', this._context.contentEditable + '');
|
|
2498
|
+
}
|
|
2499
|
+
this.listRender.afterViewInit();
|
|
2500
|
+
}
|
|
2480
2501
|
updateWeakMap() {
|
|
2481
2502
|
NODE_TO_ELEMENT.set(this.element, this.nativeElement);
|
|
2482
2503
|
ELEMENT_TO_NODE.set(this.nativeElement, this.element);
|
|
@@ -2602,17 +2623,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
2602
2623
|
|
|
2603
2624
|
class SlateVoidText extends BaseTextComponent {
|
|
2604
2625
|
ngOnInit() {
|
|
2605
|
-
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2606
2626
|
super.ngOnInit();
|
|
2607
2627
|
}
|
|
2608
2628
|
ngOnChanges() {
|
|
2609
2629
|
if (!this.initialized) {
|
|
2610
2630
|
return;
|
|
2611
2631
|
}
|
|
2612
|
-
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2613
2632
|
}
|
|
2614
2633
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateVoidText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2615
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateVoidText, isStandalone: true, selector: "span[slateVoidText]", host: { attributes: { "data-slate-spacer": "true", "data-slate-node": "text" },
|
|
2634
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateVoidText, isStandalone: true, selector: "span[slateVoidText]", host: { attributes: { "data-slate-spacer": "true", "data-slate-node": "text" }, classAttribute: "slate-spacer" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2616
2635
|
}
|
|
2617
2636
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateVoidText, decorators: [{
|
|
2618
2637
|
type: Component,
|
|
@@ -2621,7 +2640,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
2621
2640
|
template: ``,
|
|
2622
2641
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2623
2642
|
host: {
|
|
2624
|
-
'[attr.contenteditable]': 'isLeafBlock',
|
|
2625
2643
|
'data-slate-spacer': 'true',
|
|
2626
2644
|
class: 'slate-spacer',
|
|
2627
2645
|
'data-slate-node': 'text'
|
|
@@ -3594,7 +3612,10 @@ class SlateEditable {
|
|
|
3594
3612
|
Transforms.select(this.editor, range);
|
|
3595
3613
|
return;
|
|
3596
3614
|
}
|
|
3597
|
-
if (startVoid &&
|
|
3615
|
+
if (startVoid &&
|
|
3616
|
+
endVoid &&
|
|
3617
|
+
Path.equals(startVoid[1], endVoid[1]) &&
|
|
3618
|
+
!(AngularEditor.isBlockCardLeftCursor(this.editor) || AngularEditor.isBlockCardRightCursor(this.editor))) {
|
|
3598
3619
|
const range = Editor.range(this.editor, start);
|
|
3599
3620
|
Transforms.select(this.editor, range);
|
|
3600
3621
|
}
|