slate-angular 15.1.1 → 15.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.
- package/esm2020/components/leaves/leaves.component.mjs +1 -3
- package/esm2020/plugins/angular-editor.mjs +28 -3
- package/esm2020/view/container-item.mjs +2 -2
- package/fesm2015/slate-angular.mjs +28 -5
- package/fesm2015/slate-angular.mjs.map +1 -1
- package/fesm2020/slate-angular.mjs +28 -5
- package/fesm2020/slate-angular.mjs.map +1 -1
- package/package.json +1 -1
- package/plugins/angular-editor.d.ts +3 -1
|
@@ -343,7 +343,7 @@ const AngularEditor = {
|
|
|
343
343
|
while (true) {
|
|
344
344
|
const parent = NODE_TO_PARENT.get(child);
|
|
345
345
|
if (parent == null) {
|
|
346
|
-
if (Editor.isEditor(child)) {
|
|
346
|
+
if (Editor.isEditor(child) && child === editor) {
|
|
347
347
|
return path;
|
|
348
348
|
}
|
|
349
349
|
else {
|
|
@@ -359,6 +359,26 @@ const AngularEditor = {
|
|
|
359
359
|
}
|
|
360
360
|
throw new Error(`Unable to find the path for Slate node: ${JSON.stringify(node)}`);
|
|
361
361
|
},
|
|
362
|
+
isNodeInEditor(editor, node) {
|
|
363
|
+
let child = node;
|
|
364
|
+
while (true) {
|
|
365
|
+
const parent = NODE_TO_PARENT.get(child);
|
|
366
|
+
if (parent == null) {
|
|
367
|
+
if (Editor.isEditor(child) && child === editor) {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const i = NODE_TO_INDEX.get(child);
|
|
375
|
+
if (i == null) {
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
child = parent;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
},
|
|
362
382
|
/**
|
|
363
383
|
* Find the DOM node that implements DocumentOrShadowRoot for the editor.
|
|
364
384
|
*/
|
|
@@ -652,6 +672,11 @@ const AngularEditor = {
|
|
|
652
672
|
const range = AngularEditor.toSlateRange(editor, domRange);
|
|
653
673
|
return range;
|
|
654
674
|
},
|
|
675
|
+
isLeafInEditor(editor, leafNode) {
|
|
676
|
+
const textNode = leafNode.closest('[data-slate-node="text"]');
|
|
677
|
+
const node = AngularEditor.toSlateNode(editor, textNode);
|
|
678
|
+
return AngularEditor.isNodeInEditor(editor, node);
|
|
679
|
+
},
|
|
655
680
|
/**
|
|
656
681
|
* Find a Slate point from a DOM selection's `domNode` and `domOffset`.
|
|
657
682
|
*/
|
|
@@ -702,7 +727,7 @@ const AngularEditor = {
|
|
|
702
727
|
let domNode = null;
|
|
703
728
|
// Calculate how far into the text node the `nearestNode` is, so that we
|
|
704
729
|
// can determine what the offset relative to the text node is.
|
|
705
|
-
if (leafNode) {
|
|
730
|
+
if (leafNode && AngularEditor.isLeafInEditor(editor, leafNode)) {
|
|
706
731
|
textNode = leafNode.closest('[data-slate-node="text"]');
|
|
707
732
|
const window = AngularEditor.getWindow(editor);
|
|
708
733
|
const range = window.document.createRange();
|
|
@@ -1753,8 +1778,8 @@ class ViewContainerItem {
|
|
|
1753
1778
|
}
|
|
1754
1779
|
if (isComponentType(this.viewType)) {
|
|
1755
1780
|
const componentRef = this.viewContainerRef.createComponent(this.viewType);
|
|
1756
|
-
componentRef.instance.context = context;
|
|
1757
1781
|
componentRef.instance.viewContext = this.viewContext;
|
|
1782
|
+
componentRef.instance.context = context;
|
|
1758
1783
|
firstRootNode.replaceWith(componentRef.instance.nativeElement);
|
|
1759
1784
|
this.destroyView();
|
|
1760
1785
|
this.componentRef = componentRef;
|
|
@@ -2358,7 +2383,6 @@ SlateLeavesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", ver
|
|
|
2358
2383
|
SlateLeavesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SlateLeavesComponent, selector: "slate-leaves", inputs: { context: "context" }, viewQueries: [{ propertyName: "childrenComponent", predicate: SlateLeafComponent, descendants: true, read: SlateLeafComponent }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `<slate-leaf
|
|
2359
2384
|
[context]="context"
|
|
2360
2385
|
[viewContext]="viewContext"
|
|
2361
|
-
[viewContext]="viewContext"
|
|
2362
2386
|
*ngFor="let context of leafContexts; trackBy: trackBy"
|
|
2363
2387
|
></slate-leaf>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: SlateLeafComponent, selector: "slate-leaf", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2364
2388
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SlateLeavesComponent, decorators: [{
|
|
@@ -2368,7 +2392,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
|
|
|
2368
2392
|
template: `<slate-leaf
|
|
2369
2393
|
[context]="context"
|
|
2370
2394
|
[viewContext]="viewContext"
|
|
2371
|
-
[viewContext]="viewContext"
|
|
2372
2395
|
*ngFor="let context of leafContexts; trackBy: trackBy"
|
|
2373
2396
|
></slate-leaf>`,
|
|
2374
2397
|
changeDetection: ChangeDetectionStrategy.OnPush
|