slate-angular 16.1.0-next.9 → 17.0.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/components/children/children.component.d.ts +6 -1
- package/components/descendant/descendant.component.d.ts +35 -0
- package/components/editable/editable.component.d.ts +5 -15
- package/components/leaf/leaf.component.d.ts +16 -0
- package/components/leaves/leaves.component.d.ts +14 -1
- package/components/string/default-string.component.d.ts +1 -1
- package/components/string/string.component.d.ts +0 -8
- package/esm2022/components/block-card/block-card.component.mjs +6 -6
- package/esm2022/components/children/children.component.mjs +35 -7
- package/esm2022/components/descendant/descendant.component.mjs +186 -0
- package/esm2022/components/editable/editable.component.mjs +40 -131
- package/esm2022/components/element/default-element.component.mjs +5 -5
- package/esm2022/components/element/element.component.mjs +5 -5
- package/esm2022/components/leaf/default-leaf.component.mjs +3 -3
- package/esm2022/components/leaf/leaf.component.mjs +38 -0
- package/esm2022/components/leaves/leaves.component.mjs +52 -7
- package/esm2022/components/string/default-string.component.mjs +5 -5
- package/esm2022/components/string/string.component.mjs +10 -20
- package/esm2022/components/string/template.component.mjs +3 -3
- package/esm2022/components/text/default-text.component.mjs +5 -5
- package/esm2022/components/text/void-text.component.mjs +5 -5
- package/esm2022/custom-event/BeforeInputEventPlugin.mjs +1 -1
- package/esm2022/custom-event/FallbackCompositionState.mjs +1 -1
- package/esm2022/module.mjs +26 -11
- package/esm2022/plugins/angular-editor.mjs +7 -28
- package/esm2022/plugins/with-angular.mjs +4 -4
- package/esm2022/public-api.mjs +2 -3
- package/esm2022/utils/dom.mjs +1 -1
- package/esm2022/utils/hotkeys.mjs +1 -1
- package/esm2022/utils/index.mjs +1 -2
- package/esm2022/utils/lines.mjs +1 -1
- package/esm2022/utils/range-list.mjs +1 -1
- package/esm2022/utils/restore-dom.mjs +1 -1
- package/esm2022/view/base.mjs +28 -62
- package/esm2022/view/before-context-change.mjs +7 -0
- package/esm2022/view/container-item.mjs +5 -5
- package/esm2022/view/container.mjs +86 -6
- package/esm2022/view/context.mjs +1 -1
- package/fesm2022/slate-angular.mjs +788 -1079
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/module.d.ts +8 -7
- package/package.json +5 -5
- package/public-api.d.ts +1 -2
- package/utils/index.d.ts +0 -1
- package/view/base.d.ts +4 -15
- package/view/{context-change.d.ts → before-context-change.d.ts} +0 -4
- package/view/container.d.ts +7 -3
- package/view/context.d.ts +2 -6
- package/components/children/children-outlet.component.d.ts +0 -9
- package/components/leaf/token.d.ts +0 -4
- package/components/text/token.d.ts +0 -5
- package/esm2022/components/children/children-outlet.component.mjs +0 -22
- package/esm2022/components/leaf/token.mjs +0 -3
- package/esm2022/components/text/token.mjs +0 -4
- package/esm2022/utils/constants.mjs +0 -2
- package/esm2022/utils/throttle.mjs +0 -18
- package/esm2022/view/context-change.mjs +0 -13
- package/esm2022/view/render/leaves-render.mjs +0 -107
- package/esm2022/view/render/list-render.mjs +0 -252
- package/esm2022/view/render/utils.mjs +0 -117
- package/utils/constants.d.ts +0 -1
- package/utils/throttle.d.ts +0 -2
- package/view/render/leaves-render.d.ts +0 -21
- package/view/render/list-render.d.ts +0 -32
- package/view/render/utils.d.ts +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Editor, Range,
|
|
1
|
+
import { Editor, Range, Transforms, Path, Element, Text as Text$1, Node } from 'slate';
|
|
2
2
|
import { isKeyHotkey } from 'is-hotkey';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { TemplateRef, Component, ChangeDetectionStrategy, ViewChild, Directive, Input,
|
|
4
|
+
import { TemplateRef, Component, ChangeDetectionStrategy, ViewChild, Directive, Input, HostBinding, ViewChildren, InjectionToken, Inject, forwardRef, ElementRef, NgModule } from '@angular/core';
|
|
5
5
|
import { direction } from 'direction';
|
|
6
6
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
@@ -415,7 +415,7 @@ const AngularEditor = {
|
|
|
415
415
|
const [start, end] = Range.edges(selection);
|
|
416
416
|
const endBlock = Editor.above(editor, {
|
|
417
417
|
at: end,
|
|
418
|
-
match: node =>
|
|
418
|
+
match: node => Editor.isBlock(editor, node)
|
|
419
419
|
});
|
|
420
420
|
return Editor.isStart(editor, end, endBlock[1]);
|
|
421
421
|
},
|
|
@@ -637,7 +637,7 @@ const AngularEditor = {
|
|
|
637
637
|
// If the drop target is inside a void node, move it into either the
|
|
638
638
|
// next or previous node, depending on which side the `x` and `y`
|
|
639
639
|
// coordinates are closest to.
|
|
640
|
-
if (
|
|
640
|
+
if (Editor.isVoid(editor, node)) {
|
|
641
641
|
const rect = target.getBoundingClientRect();
|
|
642
642
|
const isPrev = editor.isInline(node) ? x - rect.left < rect.left + rect.width - x : y - rect.top < rect.top + rect.height - y;
|
|
643
643
|
const edge = Editor.point(editor, path, {
|
|
@@ -751,10 +751,9 @@ const AngularEditor = {
|
|
|
751
751
|
else if (voidNode) {
|
|
752
752
|
// For void nodes, the element with the offset key will be a cousin, not an
|
|
753
753
|
// ancestor, so find it by going down from the nearest void parent.
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
textNode = spacer;
|
|
754
|
+
leafNode = voidNode.querySelector('[data-slate-leaf]');
|
|
755
|
+
parentNode = voidNode.querySelector('[data-slate-length="0"]');
|
|
756
|
+
textNode = leafNode.closest('[data-slate-node="text"]');
|
|
758
757
|
domNode = leafNode;
|
|
759
758
|
offset = domNode.textContent.length;
|
|
760
759
|
}
|
|
@@ -815,29 +814,9 @@ const AngularEditor = {
|
|
|
815
814
|
if (anchorNode == null || focusNode == null || anchorOffset == null || focusOffset == null) {
|
|
816
815
|
throw new Error(`Cannot resolve a Slate range from DOM range: ${domRange}`);
|
|
817
816
|
}
|
|
818
|
-
// COMPAT: Triple-clicking a word in chrome will sometimes place the focus
|
|
819
|
-
// inside a `contenteditable="false"` DOM node following the word, which
|
|
820
|
-
// will cause `toSlatePoint` to throw an error. (2023/03/07)
|
|
821
|
-
if ('getAttribute' in focusNode &&
|
|
822
|
-
focusNode.getAttribute('contenteditable') === 'false' &&
|
|
823
|
-
focusNode.getAttribute('data-slate-void') !== 'true') {
|
|
824
|
-
focusNode = anchorNode;
|
|
825
|
-
focusOffset = anchorNode.textContent?.length || 0;
|
|
826
|
-
}
|
|
827
817
|
const anchor = AngularEditor.toSlatePoint(editor, [anchorNode, anchorOffset]);
|
|
828
818
|
const focus = isCollapsed ? anchor : AngularEditor.toSlatePoint(editor, [focusNode, focusOffset]);
|
|
829
|
-
|
|
830
|
-
// if the selection is a hanging range that ends in a void
|
|
831
|
-
// and the DOM focus is an Element
|
|
832
|
-
// (meaning that the selection ends before the element)
|
|
833
|
-
// unhang the range to avoid mistakenly including the void
|
|
834
|
-
if (Range.isExpanded(range) &&
|
|
835
|
-
Range.isForward(range) &&
|
|
836
|
-
isDOMElement(focusNode) &&
|
|
837
|
-
Editor.void(editor, { at: range.focus, mode: 'highest' })) {
|
|
838
|
-
range = Editor.unhangRange(editor, range, { voids: true });
|
|
839
|
-
}
|
|
840
|
-
return range;
|
|
819
|
+
return { anchor, focus };
|
|
841
820
|
},
|
|
842
821
|
isLeafBlock(editor, node) {
|
|
843
822
|
return Element.isElement(node) && !editor.isInline(node) && Editor.hasInlines(editor, node);
|
|
@@ -1029,24 +1008,6 @@ function normalize(document) {
|
|
|
1029
1008
|
return document.filter(value => Element.isElement(value) && isValid(value));
|
|
1030
1009
|
}
|
|
1031
1010
|
|
|
1032
|
-
const createThrottleRAF = () => {
|
|
1033
|
-
let timerId = null;
|
|
1034
|
-
const throttleRAF = (fn) => {
|
|
1035
|
-
const scheduleFunc = () => {
|
|
1036
|
-
timerId = requestAnimationFrame(() => {
|
|
1037
|
-
timerId = null;
|
|
1038
|
-
fn();
|
|
1039
|
-
});
|
|
1040
|
-
};
|
|
1041
|
-
if (timerId !== null) {
|
|
1042
|
-
cancelAnimationFrame(timerId);
|
|
1043
|
-
timerId = null;
|
|
1044
|
-
}
|
|
1045
|
-
scheduleFunc();
|
|
1046
|
-
};
|
|
1047
|
-
return throttleRAF;
|
|
1048
|
-
};
|
|
1049
|
-
|
|
1050
1011
|
/**
|
|
1051
1012
|
* Utilities for single-line deletion
|
|
1052
1013
|
*/
|
|
@@ -1100,7 +1061,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1100
1061
|
}
|
|
1101
1062
|
if (editor.selection && Range.isCollapsed(editor.selection)) {
|
|
1102
1063
|
const parentBlockEntry = Editor.above(editor, {
|
|
1103
|
-
match: n =>
|
|
1064
|
+
match: n => Editor.isBlock(editor, n),
|
|
1104
1065
|
at: editor.selection
|
|
1105
1066
|
});
|
|
1106
1067
|
if (parentBlockEntry) {
|
|
@@ -1250,7 +1211,7 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1250
1211
|
}
|
|
1251
1212
|
else {
|
|
1252
1213
|
const node = Node.parent(editor, selection.anchor.path);
|
|
1253
|
-
if (
|
|
1214
|
+
if (Editor.isVoid(editor, node)) {
|
|
1254
1215
|
Transforms.delete(editor);
|
|
1255
1216
|
}
|
|
1256
1217
|
}
|
|
@@ -1653,10 +1614,10 @@ var SlateErrorCode;
|
|
|
1653
1614
|
})(SlateErrorCode || (SlateErrorCode = {}));
|
|
1654
1615
|
|
|
1655
1616
|
class SlateStringTemplate {
|
|
1656
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1657
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1617
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateStringTemplate, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1618
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateStringTemplate, isStandalone: true, selector: "slate-string-template", viewQueries: [{ propertyName: "compatibleStringTemplate", first: true, predicate: ["compatibleStringTemplate"], descendants: true, read: TemplateRef, static: true }, { propertyName: "voidStringTemplate", first: true, predicate: ["voidStringTemplate"], descendants: true, read: TemplateRef, static: true }, { propertyName: "emptyTextTemplate", first: true, predicate: ["emptyTextTemplate"], descendants: true, read: TemplateRef, static: true }], ngImport: i0, template: "<ng-template #compatibleStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <!-- Compatible with Chinese input in Chrome with \\n -->\n <span editable-text data-slate-string=\"true\"\n >{{ context.text }}<span data-slate-zero-width>{{ '\\uFEFF' }}</span></span\n >\n</ng-template>\n<ng-template #voidStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" attr.data-slate-length=\"{{ context.elementStringLength }}\">{{ '\\uFEFF' }}</span>\n</ng-template>\n<ng-template #emptyTextTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" data-slate-length=\"0\">{{ '\\uFEFF' }}</span>\n</ng-template>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1658
1619
|
}
|
|
1659
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1620
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateStringTemplate, decorators: [{
|
|
1660
1621
|
type: Component,
|
|
1661
1622
|
args: [{ selector: 'slate-string-template', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, template: "<ng-template #compatibleStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <!-- Compatible with Chinese input in Chrome with \\n -->\n <span editable-text data-slate-string=\"true\"\n >{{ context.text }}<span data-slate-zero-width>{{ '\\uFEFF' }}</span></span\n >\n</ng-template>\n<ng-template #voidStringTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" attr.data-slate-length=\"{{ context.elementStringLength }}\">{{ '\\uFEFF' }}</span>\n</ng-template>\n<ng-template #emptyTextTemplate let-context=\"context\" let-viewContext=\"viewContext\">\n <span editable-text data-slate-zero-width=\"z\" data-slate-length=\"0\">{{ '\\uFEFF' }}</span>\n</ng-template>\n" }]
|
|
1662
1623
|
}], propDecorators: { compatibleStringTemplate: [{
|
|
@@ -1702,64 +1663,6 @@ function restoreDom(editor, execute) {
|
|
|
1702
1663
|
}, 0);
|
|
1703
1664
|
}
|
|
1704
1665
|
|
|
1705
|
-
/**
|
|
1706
|
-
* @deprecated
|
|
1707
|
-
* the special container for angular template
|
|
1708
|
-
* Add the rootNodes of each child component to the parentElement
|
|
1709
|
-
* Remove useless DOM elements, eg: comment...
|
|
1710
|
-
*/
|
|
1711
|
-
class ViewContainer {
|
|
1712
|
-
constructor(elementRef, differs) {
|
|
1713
|
-
this.elementRef = elementRef;
|
|
1714
|
-
this.differs = differs;
|
|
1715
|
-
}
|
|
1716
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ViewContainer, deps: [{ token: i0.ElementRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1717
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: ViewContainer, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
1718
|
-
}
|
|
1719
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ViewContainer, decorators: [{
|
|
1720
|
-
type: Directive
|
|
1721
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.IterableDiffers }]; }, propDecorators: { viewContext: [{
|
|
1722
|
-
type: Input
|
|
1723
|
-
}] } });
|
|
1724
|
-
|
|
1725
|
-
class SlateChildren extends ViewContainer {
|
|
1726
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateChildren, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1727
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateChildren, isStandalone: true, selector: "slate-children", inputs: { children: "children", context: "context", viewContext: "viewContext" }, usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1728
|
-
}
|
|
1729
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateChildren, decorators: [{
|
|
1730
|
-
type: Component,
|
|
1731
|
-
args: [{
|
|
1732
|
-
selector: 'slate-children',
|
|
1733
|
-
template: ``,
|
|
1734
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1735
|
-
standalone: true
|
|
1736
|
-
}]
|
|
1737
|
-
}], propDecorators: { children: [{
|
|
1738
|
-
type: Input
|
|
1739
|
-
}], context: [{
|
|
1740
|
-
type: Input
|
|
1741
|
-
}], viewContext: [{
|
|
1742
|
-
type: Input
|
|
1743
|
-
}] } });
|
|
1744
|
-
|
|
1745
|
-
const SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN = new InjectionToken('slate-default-element-token');
|
|
1746
|
-
|
|
1747
|
-
const SLATE_DEFAULT_TEXT_COMPONENT_TOKEN = new InjectionToken('slate-default-text-token');
|
|
1748
|
-
const SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN = new InjectionToken('slate-default-void-text-token');
|
|
1749
|
-
|
|
1750
|
-
function hasBeforeContextChange(value) {
|
|
1751
|
-
if (value.beforeContextChange) {
|
|
1752
|
-
return true;
|
|
1753
|
-
}
|
|
1754
|
-
return false;
|
|
1755
|
-
}
|
|
1756
|
-
function hasAfterContextChange(value) {
|
|
1757
|
-
if (value.afterContextChange) {
|
|
1758
|
-
return true;
|
|
1759
|
-
}
|
|
1760
|
-
return false;
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
1666
|
class SlateBlockCard {
|
|
1764
1667
|
get nativeElement() {
|
|
1765
1668
|
return this.elementRef.nativeElement;
|
|
@@ -1771,6 +1674,7 @@ class SlateBlockCard {
|
|
|
1771
1674
|
this.elementRef = elementRef;
|
|
1772
1675
|
}
|
|
1773
1676
|
ngOnInit() {
|
|
1677
|
+
this.append();
|
|
1774
1678
|
this.nativeElement.classList.add(`slate-block-card`);
|
|
1775
1679
|
}
|
|
1776
1680
|
append() {
|
|
@@ -1778,553 +1682,175 @@ class SlateBlockCard {
|
|
|
1778
1682
|
}
|
|
1779
1683
|
initializeCenter(rootNodes) {
|
|
1780
1684
|
this.centerRootNodes = rootNodes;
|
|
1781
|
-
this.append();
|
|
1782
1685
|
}
|
|
1783
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1784
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
1686
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateBlockCard, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1687
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateBlockCard, isStandalone: true, selector: "slate-block-card, [slateBlockCard]", viewQueries: [{ propertyName: "centerContianer", first: true, predicate: ["centerContianer"], descendants: true, static: true }], ngImport: i0, template: "<span card-target=\"card-left\" class=\"card-left\">{{ '\\uFEFF' }}</span>\n<div card-target=\"card-center\" #centerContianer></div>\n<span card-target=\"card-right\" class=\"card-right\">{{ '\\uFEFF' }}</span>\n" }); }
|
|
1785
1688
|
}
|
|
1786
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateBlockCard, decorators: [{
|
|
1787
1690
|
type: Component,
|
|
1788
1691
|
args: [{ selector: 'slate-block-card, [slateBlockCard]', standalone: true, template: "<span card-target=\"card-left\" class=\"card-left\">{{ '\\uFEFF' }}</span>\n<div card-target=\"card-center\" #centerContianer></div>\n<span card-target=\"card-right\" class=\"card-right\">{{ '\\uFEFF' }}</span>\n" }]
|
|
1789
|
-
}], ctorParameters:
|
|
1692
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { centerContianer: [{
|
|
1790
1693
|
type: ViewChild,
|
|
1791
1694
|
args: ['centerContianer', { static: true }]
|
|
1792
1695
|
}] } });
|
|
1793
1696
|
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
return embeddedViewRef;
|
|
1803
|
-
}
|
|
1804
|
-
if (isComponentType(viewType)) {
|
|
1805
|
-
const componentRef = viewContainerRef.createComponent(viewType, {
|
|
1806
|
-
injector: viewContainerRef.injector
|
|
1807
|
-
});
|
|
1808
|
-
componentRef.instance.viewContext = viewContext;
|
|
1809
|
-
componentRef.instance.context = context;
|
|
1810
|
-
componentRef.changeDetectorRef.detectChanges();
|
|
1811
|
-
return componentRef;
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
function renderView(view) {
|
|
1815
|
-
if (view instanceof ComponentRef) {
|
|
1816
|
-
view.changeDetectorRef.detectChanges();
|
|
1817
|
-
}
|
|
1818
|
-
else {
|
|
1819
|
-
view.detectChanges();
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
function updateContext(view, newContext, viewContext) {
|
|
1823
|
-
if (view instanceof ComponentRef) {
|
|
1824
|
-
view.instance.context = newContext;
|
|
1825
|
-
}
|
|
1826
|
-
else {
|
|
1827
|
-
const embeddedViewContext = {
|
|
1828
|
-
context: newContext,
|
|
1829
|
-
viewContext
|
|
1830
|
-
};
|
|
1831
|
-
view.context = embeddedViewContext;
|
|
1832
|
-
view.detectChanges();
|
|
1697
|
+
/**
|
|
1698
|
+
* Dynamically create/update components or templates
|
|
1699
|
+
* Provide rootNodes for the view container
|
|
1700
|
+
* If the dynamically created component uses onpush mode, then it must call markForCheck when setting the context
|
|
1701
|
+
*/
|
|
1702
|
+
class ViewContainerItem {
|
|
1703
|
+
get rootNodes() {
|
|
1704
|
+
return this.getRootNodes();
|
|
1833
1705
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
const fragment = document.createDocumentFragment();
|
|
1838
|
-
views.forEach((view, index) => {
|
|
1839
|
-
const blockCard = blockCards ? blockCards[index] : undefined;
|
|
1840
|
-
fragment.append(...getRootNodes(view, blockCard));
|
|
1841
|
-
});
|
|
1842
|
-
if (outletElement) {
|
|
1843
|
-
outletParent.insertBefore(fragment, outletElement);
|
|
1844
|
-
outletElement.remove();
|
|
1706
|
+
getRootNodes() {
|
|
1707
|
+
if (this.embeddedViewRef) {
|
|
1708
|
+
return this.embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode));
|
|
1845
1709
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1710
|
+
if (this.componentRef) {
|
|
1711
|
+
return [this.componentRef.instance.nativeElement];
|
|
1848
1712
|
}
|
|
1713
|
+
return [];
|
|
1849
1714
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
return [blockCard.instance.nativeElement];
|
|
1854
|
-
}
|
|
1855
|
-
if (ref instanceof ComponentRef) {
|
|
1856
|
-
ref.hostView.rootNodes.forEach(ele => {
|
|
1857
|
-
if (!(ele instanceof HTMLElement)) {
|
|
1858
|
-
ele.remove();
|
|
1859
|
-
}
|
|
1860
|
-
});
|
|
1861
|
-
return [ref.instance.nativeElement];
|
|
1862
|
-
}
|
|
1863
|
-
else {
|
|
1864
|
-
const result = [];
|
|
1865
|
-
ref.rootNodes.forEach(rootNode => {
|
|
1866
|
-
const isHTMLElement = rootNode instanceof HTMLElement;
|
|
1867
|
-
if (isHTMLElement && result.every(item => !item.contains(rootNode))) {
|
|
1868
|
-
result.push(rootNode);
|
|
1869
|
-
}
|
|
1870
|
-
if (!isHTMLElement) {
|
|
1871
|
-
rootNode.remove();
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
return result;
|
|
1715
|
+
constructor(viewContainerRef) {
|
|
1716
|
+
this.viewContainerRef = viewContainerRef;
|
|
1717
|
+
this.initialized = false;
|
|
1875
1718
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
if (blockCards) {
|
|
1881
|
-
const isBlockCard = viewContext.editor.isBlockCard(item);
|
|
1882
|
-
if (isBlockCard) {
|
|
1883
|
-
const blockCard = blockCards[index];
|
|
1884
|
-
rootNodes = [blockCard.instance.nativeElement];
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
if (index === 0) {
|
|
1888
|
-
if (firstRootNode) {
|
|
1889
|
-
rootNodes.forEach(rootNode => {
|
|
1890
|
-
firstRootNode.insertAdjacentElement('beforebegin', rootNode);
|
|
1891
|
-
});
|
|
1719
|
+
destroyView() {
|
|
1720
|
+
if (this.embeddedViewRef) {
|
|
1721
|
+
this.embeddedViewRef.destroy();
|
|
1722
|
+
this.embeddedViewRef = null;
|
|
1892
1723
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
1724
|
+
if (this.componentRef) {
|
|
1725
|
+
this.componentRef.destroy();
|
|
1726
|
+
this.componentRef = null;
|
|
1895
1727
|
}
|
|
1896
1728
|
}
|
|
1897
|
-
|
|
1898
|
-
const previousView = views[index - 1];
|
|
1899
|
-
const blockCard = blockCards ? blockCards[index - 1] : null;
|
|
1900
|
-
const previousRootNodes = getRootNodes(previousView, blockCard);
|
|
1901
|
-
let previousRootNode = previousRootNodes[previousRootNodes.length - 1];
|
|
1902
|
-
rootNodes.forEach(rootNode => {
|
|
1903
|
-
previousRootNode.insertAdjacentElement('afterend', rootNode);
|
|
1904
|
-
previousRootNode = rootNode;
|
|
1905
|
-
});
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
class ListRender {
|
|
1910
|
-
constructor(viewContext, viewContainerRef, getOutletParent, getOutletElement) {
|
|
1911
|
-
this.viewContext = viewContext;
|
|
1912
|
-
this.viewContainerRef = viewContainerRef;
|
|
1913
|
-
this.getOutletParent = getOutletParent;
|
|
1914
|
-
this.getOutletElement = getOutletElement;
|
|
1915
|
-
this.views = [];
|
|
1916
|
-
this.blockCards = [];
|
|
1917
|
-
this.contexts = [];
|
|
1918
|
-
this.viewTypes = [];
|
|
1919
|
-
this.initialized = false;
|
|
1920
|
-
}
|
|
1921
|
-
initialize(children, parent, childrenContext) {
|
|
1729
|
+
createView() {
|
|
1922
1730
|
this.initialized = true;
|
|
1923
|
-
this.
|
|
1924
|
-
const
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
const
|
|
1931
|
-
|
|
1932
|
-
this.views.push(view);
|
|
1933
|
-
this.contexts.push(context);
|
|
1934
|
-
this.viewTypes.push(viewType);
|
|
1935
|
-
this.blockCards.push(blockCard);
|
|
1936
|
-
});
|
|
1937
|
-
mount(this.views, this.blockCards, this.getOutletParent(), this.getOutletElement());
|
|
1938
|
-
const newDiffers = this.viewContainerRef.injector.get(IterableDiffers);
|
|
1939
|
-
this.differ = newDiffers.find(children).create(trackBy$1(this.viewContext));
|
|
1940
|
-
this.differ.diff(children);
|
|
1941
|
-
}
|
|
1942
|
-
update(children, parent, childrenContext) {
|
|
1943
|
-
if (!this.initialized) {
|
|
1944
|
-
this.initialize(children, parent, childrenContext);
|
|
1945
|
-
return;
|
|
1731
|
+
this.viewType = this.getViewType();
|
|
1732
|
+
const context = this.getContext();
|
|
1733
|
+
if (isTemplateRef(this.viewType)) {
|
|
1734
|
+
this.embeddedViewContext = {
|
|
1735
|
+
context,
|
|
1736
|
+
viewContext: this.viewContext
|
|
1737
|
+
};
|
|
1738
|
+
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
1739
|
+
this.embeddedViewRef = embeddedViewRef;
|
|
1946
1740
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
newViewTypes.push(viewType);
|
|
1962
|
-
let view;
|
|
1963
|
-
let blockCard;
|
|
1964
|
-
if (record.previousIndex === null) {
|
|
1965
|
-
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1966
|
-
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
1967
|
-
newContexts.push(context);
|
|
1968
|
-
newViews.push(view);
|
|
1969
|
-
newBlockCards.push(blockCard);
|
|
1970
|
-
mountOnItemChange(record.currentIndex, record.item, newViews, newBlockCards, outletParent, firstRootNode, this.viewContext);
|
|
1971
|
-
}
|
|
1972
|
-
else {
|
|
1973
|
-
const previousView = this.views[record.previousIndex];
|
|
1974
|
-
const previousViewType = this.viewTypes[record.previousIndex];
|
|
1975
|
-
const previousContext = this.contexts[record.previousIndex];
|
|
1976
|
-
const previousBlockCard = this.blockCards[record.previousIndex];
|
|
1977
|
-
if (previousViewType !== viewType) {
|
|
1978
|
-
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1979
|
-
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
1980
|
-
const firstRootNode = getRootNodes(previousView, previousBlockCard)[0];
|
|
1981
|
-
const newRootNodes = getRootNodes(view, blockCard);
|
|
1982
|
-
firstRootNode.replaceWith(...newRootNodes);
|
|
1983
|
-
previousView.destroy();
|
|
1984
|
-
previousBlockCard?.destroy();
|
|
1985
|
-
}
|
|
1986
|
-
else {
|
|
1987
|
-
view = previousView;
|
|
1988
|
-
blockCard = previousBlockCard;
|
|
1989
|
-
if (memoizedContext(this.viewContext, record.item, previousContext, context)) {
|
|
1990
|
-
context = previousContext;
|
|
1991
|
-
}
|
|
1992
|
-
else {
|
|
1993
|
-
updateContext(previousView, context, this.viewContext);
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
newContexts.push(context);
|
|
1997
|
-
newViews.push(view);
|
|
1998
|
-
newBlockCards.push(blockCard);
|
|
1999
|
-
}
|
|
2000
|
-
});
|
|
2001
|
-
diffResult.forEachOperation(record => {
|
|
2002
|
-
// removed
|
|
2003
|
-
if (record.currentIndex === null) {
|
|
2004
|
-
const view = this.views[record.previousIndex];
|
|
2005
|
-
const blockCard = this.blockCards[record.previousIndex];
|
|
2006
|
-
view.destroy();
|
|
2007
|
-
blockCard?.destroy();
|
|
1741
|
+
if (isComponentType(this.viewType)) {
|
|
1742
|
+
const componentRef = this.viewContainerRef.createComponent(this.viewType);
|
|
1743
|
+
componentRef.instance.viewContext = this.viewContext;
|
|
1744
|
+
componentRef.instance.context = context;
|
|
1745
|
+
this.componentRef = componentRef;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
updateView() {
|
|
1749
|
+
const viewType = this.getViewType();
|
|
1750
|
+
const context = this.getContext();
|
|
1751
|
+
if (this.viewType === viewType) {
|
|
1752
|
+
if (this.componentRef) {
|
|
1753
|
+
if (this.memoizedContext(this.componentRef.instance.context, context)) {
|
|
1754
|
+
return;
|
|
2008
1755
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
1756
|
+
this.componentRef.instance.context = context;
|
|
1757
|
+
}
|
|
1758
|
+
if (this.embeddedViewRef) {
|
|
1759
|
+
if (this.memoizedContext(this.embeddedViewContext.context, context)) {
|
|
1760
|
+
return;
|
|
2014
1761
|
}
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
this.views = newViews;
|
|
2018
|
-
this.contexts = newContexts;
|
|
2019
|
-
this.children = children;
|
|
2020
|
-
this.blockCards = newBlockCards;
|
|
1762
|
+
this.embeddedViewContext.context = context;
|
|
1763
|
+
}
|
|
2021
1764
|
}
|
|
2022
1765
|
else {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
}
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
}
|
|
2035
|
-
this.
|
|
1766
|
+
this.viewType = viewType;
|
|
1767
|
+
const firstRootNode = this.rootNodes[0];
|
|
1768
|
+
if (isTemplateRef(this.viewType)) {
|
|
1769
|
+
this.embeddedViewContext = {
|
|
1770
|
+
context,
|
|
1771
|
+
viewContext: this.viewContext
|
|
1772
|
+
};
|
|
1773
|
+
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
1774
|
+
firstRootNode.replaceWith(...embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode)));
|
|
1775
|
+
this.destroyView();
|
|
1776
|
+
this.embeddedViewRef = embeddedViewRef;
|
|
1777
|
+
}
|
|
1778
|
+
if (isComponentType(this.viewType)) {
|
|
1779
|
+
const componentRef = this.viewContainerRef.createComponent(this.viewType);
|
|
1780
|
+
componentRef.instance.viewContext = this.viewContext;
|
|
1781
|
+
componentRef.instance.context = context;
|
|
1782
|
+
firstRootNode.replaceWith(componentRef.instance.nativeElement);
|
|
1783
|
+
this.destroyView();
|
|
1784
|
+
this.componentRef = componentRef;
|
|
1785
|
+
}
|
|
2036
1786
|
}
|
|
2037
1787
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
const computedContext = getCommonContext(index, item, parentPath, viewContext, childrenContext);
|
|
2042
|
-
const key = AngularEditor.findKey(viewContext.editor, item);
|
|
2043
|
-
const isInline = viewContext.editor.isInline(item);
|
|
2044
|
-
const isVoid = viewContext.editor.isVoid(item);
|
|
2045
|
-
const elementContext = {
|
|
2046
|
-
element: item,
|
|
2047
|
-
...computedContext,
|
|
2048
|
-
attributes: {
|
|
2049
|
-
'data-slate-node': 'element',
|
|
2050
|
-
'data-slate-key': key.id
|
|
2051
|
-
},
|
|
2052
|
-
decorate: childrenContext.decorate,
|
|
2053
|
-
readonly: childrenContext.readonly
|
|
2054
|
-
};
|
|
2055
|
-
if (isInline) {
|
|
2056
|
-
elementContext.attributes['data-slate-inline'] = true;
|
|
2057
|
-
}
|
|
2058
|
-
if (isVoid) {
|
|
2059
|
-
elementContext.attributes['data-slate-void'] = true;
|
|
1788
|
+
appendBlockCardElement() {
|
|
1789
|
+
if (this.blockCardComponentRef) {
|
|
1790
|
+
this.blockCardComponentRef.instance.append();
|
|
2060
1791
|
}
|
|
2061
|
-
return elementContext;
|
|
2062
1792
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
1793
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ViewContainerItem, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1794
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: ViewContainerItem, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
1795
|
+
}
|
|
1796
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ViewContainerItem, decorators: [{
|
|
1797
|
+
type: Directive
|
|
1798
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { viewContext: [{
|
|
1799
|
+
type: Input
|
|
1800
|
+
}] } });
|
|
1801
|
+
|
|
1802
|
+
function hasBeforeContextChange(value) {
|
|
1803
|
+
if (value.beforeContextChange) {
|
|
1804
|
+
return true;
|
|
2073
1805
|
}
|
|
1806
|
+
return false;
|
|
2074
1807
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
for (const dec of childrenContext.decorations) {
|
|
2084
|
-
const d = Range.intersection(dec, range);
|
|
2085
|
-
if (d) {
|
|
2086
|
-
ds.push(d);
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
return { selection: sel, decorations: ds };
|
|
2090
|
-
}
|
|
2091
|
-
else {
|
|
2092
|
-
return { selection: null, decorations: ds };
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* base class for custom element component or text component
|
|
1811
|
+
*/
|
|
1812
|
+
class BaseComponent {
|
|
1813
|
+
set context(value) {
|
|
1814
|
+
if (hasBeforeContextChange(this)) {
|
|
1815
|
+
this.beforeContextChange(value);
|
|
2093
1816
|
}
|
|
1817
|
+
this._context = value;
|
|
1818
|
+
this.onContextChange();
|
|
2094
1819
|
}
|
|
2095
|
-
|
|
2096
|
-
this.
|
|
2097
|
-
code: SlateErrorCode.GetStartPointError,
|
|
2098
|
-
nativeError: error
|
|
2099
|
-
});
|
|
2100
|
-
return { selection: null, decorations: [] };
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
function getViewType$1(item, parent, viewContext) {
|
|
2104
|
-
if (Element.isElement(item)) {
|
|
2105
|
-
return (viewContext.renderElement && viewContext.renderElement(item)) || viewContext.defaultElement;
|
|
1820
|
+
get context() {
|
|
1821
|
+
return this._context;
|
|
2106
1822
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
return isVoid ? viewContext.defaultVoidText : (viewContext.renderText && viewContext.renderText(item)) || viewContext.defaultText;
|
|
1823
|
+
get editor() {
|
|
1824
|
+
return this.viewContext && this.viewContext.editor;
|
|
2110
1825
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
const isBlockCard = viewContext.editor.isBlockCard(item);
|
|
2114
|
-
if (isBlockCard) {
|
|
2115
|
-
const rootNodes = getRootNodes(view);
|
|
2116
|
-
const blockCardComponentRef = viewContainerRef.createComponent(SlateBlockCard, {
|
|
2117
|
-
injector: viewContainerRef.injector
|
|
2118
|
-
});
|
|
2119
|
-
blockCardComponentRef.instance.initializeCenter(rootNodes);
|
|
2120
|
-
return blockCardComponentRef;
|
|
1826
|
+
get nativeElement() {
|
|
1827
|
+
return this.elementRef.nativeElement;
|
|
2121
1828
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
1829
|
+
constructor(elementRef, cdr) {
|
|
1830
|
+
this.elementRef = elementRef;
|
|
1831
|
+
this.cdr = cdr;
|
|
2124
1832
|
}
|
|
1833
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1834
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: BaseComponent, inputs: { context: "context", viewContext: "viewContext" }, ngImport: i0 }); }
|
|
2125
1835
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
1836
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseComponent, decorators: [{
|
|
1837
|
+
type: Directive
|
|
1838
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { context: [{
|
|
1839
|
+
type: Input
|
|
1840
|
+
}], viewContext: [{
|
|
1841
|
+
type: Input
|
|
1842
|
+
}] } });
|
|
1843
|
+
/**
|
|
1844
|
+
* base class for custom leaf component
|
|
1845
|
+
*/
|
|
1846
|
+
class BaseLeafComponent extends BaseComponent {
|
|
1847
|
+
constructor() {
|
|
1848
|
+
super(...arguments);
|
|
1849
|
+
this.initialized = false;
|
|
1850
|
+
this.isSlateLeaf = true;
|
|
2134
1851
|
}
|
|
2135
|
-
|
|
2136
|
-
return
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
function memoizedElementContext(viewContext, prev, next) {
|
|
2140
|
-
return (prev.element === next.element &&
|
|
2141
|
-
(!viewContext.isStrictDecorate || prev.decorate === next.decorate) &&
|
|
2142
|
-
prev.readonly === next.readonly &&
|
|
2143
|
-
isDecoratorRangeListEqual(prev.decorations, next.decorations) &&
|
|
2144
|
-
(prev.selection === next.selection || (!!prev.selection && !!next.selection && Range.equals(prev.selection, next.selection))));
|
|
2145
|
-
}
|
|
2146
|
-
function memoizedTextContext(prev, next) {
|
|
2147
|
-
return (next.parent === prev.parent &&
|
|
2148
|
-
next.isLast === prev.isLast &&
|
|
2149
|
-
next.text === prev.text &&
|
|
2150
|
-
isDecoratorRangeListEqual(next.decorations, prev.decorations));
|
|
2151
|
-
}
|
|
2152
|
-
|
|
2153
|
-
class LeavesRender {
|
|
2154
|
-
constructor(viewContext, viewContainerRef, getOutletParent, getOutletElement) {
|
|
2155
|
-
this.viewContext = viewContext;
|
|
2156
|
-
this.viewContainerRef = viewContainerRef;
|
|
2157
|
-
this.getOutletParent = getOutletParent;
|
|
2158
|
-
this.getOutletElement = getOutletElement;
|
|
2159
|
-
this.views = [];
|
|
2160
|
-
this.contexts = [];
|
|
2161
|
-
this.viewTypes = [];
|
|
2162
|
-
}
|
|
2163
|
-
initialize(context) {
|
|
2164
|
-
const { leaves, contexts } = this.getLeaves(context);
|
|
2165
|
-
this.leaves = leaves;
|
|
2166
|
-
this.contexts = contexts;
|
|
2167
|
-
this.leaves.forEach((leaf, index) => {
|
|
2168
|
-
const context = getContext(index, this.contexts);
|
|
2169
|
-
const viewType = getViewType(context, this.viewContext);
|
|
2170
|
-
const view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2171
|
-
this.views.push(view);
|
|
2172
|
-
this.contexts.push(context);
|
|
2173
|
-
this.viewTypes.push(viewType);
|
|
2174
|
-
});
|
|
2175
|
-
mount(this.views, null, this.getOutletParent(), this.getOutletElement());
|
|
2176
|
-
const newDiffers = this.viewContainerRef.injector.get(IterableDiffers);
|
|
2177
|
-
this.differ = newDiffers.find(this.leaves).create(trackBy(this.viewContext));
|
|
2178
|
-
this.differ.diff(this.leaves);
|
|
2179
|
-
}
|
|
2180
|
-
update(context) {
|
|
2181
|
-
const { leaves, contexts } = this.getLeaves(context);
|
|
2182
|
-
const outletParent = this.getOutletParent();
|
|
2183
|
-
const diffResult = this.differ.diff(leaves);
|
|
2184
|
-
if (diffResult) {
|
|
2185
|
-
let firstRootNode = getRootNodes(this.views[0])[0];
|
|
2186
|
-
const newContexts = [];
|
|
2187
|
-
const newViewTypes = [];
|
|
2188
|
-
const newViews = [];
|
|
2189
|
-
diffResult.forEachItem(record => {
|
|
2190
|
-
let context = getContext(record.currentIndex, contexts);
|
|
2191
|
-
const viewType = getViewType(context, this.viewContext);
|
|
2192
|
-
newViewTypes.push(viewType);
|
|
2193
|
-
let view;
|
|
2194
|
-
if (record.previousIndex === null) {
|
|
2195
|
-
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2196
|
-
newContexts.push(context);
|
|
2197
|
-
newViews.push(view);
|
|
2198
|
-
mountOnItemChange(record.currentIndex, record.item, newViews, null, outletParent, firstRootNode, this.viewContext);
|
|
2199
|
-
}
|
|
2200
|
-
else {
|
|
2201
|
-
const previousView = this.views[record.previousIndex];
|
|
2202
|
-
const previousViewType = this.viewTypes[record.previousIndex];
|
|
2203
|
-
if (previousViewType !== viewType) {
|
|
2204
|
-
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2205
|
-
const firstRootNode = getRootNodes(previousView, null)[0];
|
|
2206
|
-
const newRootNodes = getRootNodes(view, null);
|
|
2207
|
-
firstRootNode.replaceWith(...newRootNodes);
|
|
2208
|
-
previousView.destroy();
|
|
2209
|
-
}
|
|
2210
|
-
else {
|
|
2211
|
-
view = previousView;
|
|
2212
|
-
updateContext(previousView, context, this.viewContext);
|
|
2213
|
-
}
|
|
2214
|
-
newContexts.push(context);
|
|
2215
|
-
newViews.push(view);
|
|
2216
|
-
}
|
|
2217
|
-
});
|
|
2218
|
-
diffResult.forEachRemovedItem(record => {
|
|
2219
|
-
const view = this.views[record.previousIndex];
|
|
2220
|
-
view.destroy();
|
|
2221
|
-
});
|
|
2222
|
-
diffResult.forEachMovedItem(record => {
|
|
2223
|
-
mountOnItemChange(record.currentIndex, record.item, newViews, null, outletParent, firstRootNode, this.viewContext);
|
|
2224
|
-
});
|
|
2225
|
-
this.viewTypes = newViewTypes;
|
|
2226
|
-
this.views = newViews;
|
|
2227
|
-
this.contexts = newContexts;
|
|
2228
|
-
this.leaves = leaves;
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
getLeaves(context) {
|
|
2232
|
-
const leaves = Text$1.decorations(context.text, context.decorations);
|
|
2233
|
-
const contexts = leaves.map((leaf, index) => {
|
|
2234
|
-
return {
|
|
2235
|
-
leaf,
|
|
2236
|
-
text: context.text,
|
|
2237
|
-
parent: context.parent,
|
|
2238
|
-
index,
|
|
2239
|
-
isLast: context.isLast && index === leaves.length - 1
|
|
2240
|
-
};
|
|
2241
|
-
});
|
|
2242
|
-
return { leaves, contexts };
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
function getContext(index, leafContexts) {
|
|
2246
|
-
return leafContexts[index];
|
|
2247
|
-
}
|
|
2248
|
-
function getViewType(leafContext, viewContext) {
|
|
2249
|
-
return (viewContext.renderLeaf && viewContext.renderLeaf(leafContext.leaf)) || viewContext.defaultLeaf;
|
|
2250
|
-
}
|
|
2251
|
-
function trackBy(viewContext) {
|
|
2252
|
-
return (index, node) => {
|
|
2253
|
-
return index;
|
|
2254
|
-
};
|
|
2255
|
-
}
|
|
2256
|
-
|
|
2257
|
-
class SlateChildrenOutlet {
|
|
2258
|
-
constructor(elementRef) {
|
|
2259
|
-
this.elementRef = elementRef;
|
|
2260
|
-
}
|
|
2261
|
-
getNativeElement() {
|
|
2262
|
-
return this.elementRef.nativeElement;
|
|
2263
|
-
}
|
|
2264
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateChildrenOutlet, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2265
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateChildrenOutlet, isStandalone: true, selector: "slate-children-outlet", ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2266
|
-
}
|
|
2267
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateChildrenOutlet, decorators: [{
|
|
2268
|
-
type: Component,
|
|
2269
|
-
args: [{
|
|
2270
|
-
selector: 'slate-children-outlet',
|
|
2271
|
-
template: ``,
|
|
2272
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2273
|
-
standalone: true
|
|
2274
|
-
}]
|
|
2275
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
|
|
2276
|
-
|
|
2277
|
-
/**
|
|
2278
|
-
* base class for custom element component or text component
|
|
2279
|
-
*/
|
|
2280
|
-
class BaseComponent {
|
|
2281
|
-
set context(value) {
|
|
2282
|
-
if (hasBeforeContextChange(this)) {
|
|
2283
|
-
this.beforeContextChange(value);
|
|
2284
|
-
}
|
|
2285
|
-
this._context = value;
|
|
2286
|
-
this.onContextChange();
|
|
2287
|
-
if (this.initialized) {
|
|
2288
|
-
this.cdr.detectChanges();
|
|
2289
|
-
}
|
|
2290
|
-
if (hasAfterContextChange(this)) {
|
|
2291
|
-
this.afterContextChange();
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
get context() {
|
|
2295
|
-
return this._context;
|
|
2296
|
-
}
|
|
2297
|
-
get editor() {
|
|
2298
|
-
return this.viewContext && this.viewContext.editor;
|
|
2299
|
-
}
|
|
2300
|
-
get nativeElement() {
|
|
2301
|
-
return this.elementRef.nativeElement;
|
|
2302
|
-
}
|
|
2303
|
-
constructor(elementRef, cdr) {
|
|
2304
|
-
this.elementRef = elementRef;
|
|
2305
|
-
this.cdr = cdr;
|
|
2306
|
-
this.initialized = false;
|
|
2307
|
-
}
|
|
2308
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: BaseComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2309
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: BaseComponent, inputs: { context: "context", viewContext: "viewContext" }, ngImport: i0 }); }
|
|
2310
|
-
}
|
|
2311
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: BaseComponent, decorators: [{
|
|
2312
|
-
type: Directive
|
|
2313
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
|
|
2314
|
-
type: Input
|
|
2315
|
-
}], viewContext: [{
|
|
2316
|
-
type: Input
|
|
2317
|
-
}] } });
|
|
2318
|
-
/**
|
|
2319
|
-
* base class for custom leaf component
|
|
2320
|
-
*/
|
|
2321
|
-
class BaseLeafComponent extends BaseComponent {
|
|
2322
|
-
constructor() {
|
|
2323
|
-
super(...arguments);
|
|
2324
|
-
this.isSlateLeaf = true;
|
|
2325
|
-
}
|
|
2326
|
-
get text() {
|
|
2327
|
-
return this.context && this.context.text;
|
|
1852
|
+
get text() {
|
|
1853
|
+
return this.context && this.context.text;
|
|
2328
1854
|
}
|
|
2329
1855
|
get leaf() {
|
|
2330
1856
|
return this.context && this.context.leaf;
|
|
@@ -2336,6 +1862,7 @@ class BaseLeafComponent extends BaseComponent {
|
|
|
2336
1862
|
if (!this.initialized) {
|
|
2337
1863
|
return;
|
|
2338
1864
|
}
|
|
1865
|
+
this.cdr.markForCheck();
|
|
2339
1866
|
}
|
|
2340
1867
|
renderPlaceholder() {
|
|
2341
1868
|
// issue-1: IME input was interrupted
|
|
@@ -2372,10 +1899,10 @@ class BaseLeafComponent extends BaseComponent {
|
|
|
2372
1899
|
this.nativeElement.classList.remove('leaf-with-placeholder');
|
|
2373
1900
|
}
|
|
2374
1901
|
}
|
|
2375
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2376
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
1902
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseLeafComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1903
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: BaseLeafComponent, host: { properties: { "attr.data-slate-leaf": "this.isSlateLeaf" } }, usesInheritance: true, ngImport: i0 }); }
|
|
2377
1904
|
}
|
|
2378
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1905
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseLeafComponent, decorators: [{
|
|
2379
1906
|
type: Directive
|
|
2380
1907
|
}], propDecorators: { isSlateLeaf: [{
|
|
2381
1908
|
type: HostBinding,
|
|
@@ -2387,16 +1914,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
2387
1914
|
class BaseElementComponent extends BaseComponent {
|
|
2388
1915
|
constructor() {
|
|
2389
1916
|
super(...arguments);
|
|
2390
|
-
this.
|
|
2391
|
-
this.getOutletParent = () => {
|
|
2392
|
-
return this.elementRef.nativeElement;
|
|
2393
|
-
};
|
|
2394
|
-
this.getOutletElement = () => {
|
|
2395
|
-
if (this.childrenOutletInstance) {
|
|
2396
|
-
return this.childrenOutletInstance.getNativeElement();
|
|
2397
|
-
}
|
|
2398
|
-
return null;
|
|
2399
|
-
};
|
|
1917
|
+
this.initialized = false;
|
|
2400
1918
|
}
|
|
2401
1919
|
get element() {
|
|
2402
1920
|
return this._context && this._context.element;
|
|
@@ -2420,12 +1938,11 @@ class BaseElementComponent extends BaseComponent {
|
|
|
2420
1938
|
return this._context && this._context.readonly;
|
|
2421
1939
|
}
|
|
2422
1940
|
ngOnInit() {
|
|
1941
|
+
this.updateWeakMap();
|
|
2423
1942
|
for (const key in this._context.attributes) {
|
|
2424
1943
|
this.nativeElement.setAttribute(key, this._context.attributes[key]);
|
|
2425
1944
|
}
|
|
2426
1945
|
this.initialized = true;
|
|
2427
|
-
this.listRender = new ListRender(this.viewContext, this.viewContainerRef, this.getOutletParent, this.getOutletElement);
|
|
2428
|
-
this.listRender.initialize(this.children, this.element, this.childrenContext);
|
|
2429
1946
|
}
|
|
2430
1947
|
updateWeakMap() {
|
|
2431
1948
|
NODE_TO_ELEMENT.set(this.element, this.nativeElement);
|
|
@@ -2442,11 +1959,11 @@ class BaseElementComponent extends BaseComponent {
|
|
|
2442
1959
|
}
|
|
2443
1960
|
onContextChange() {
|
|
2444
1961
|
this.childrenContext = this.getChildrenContext();
|
|
2445
|
-
this.updateWeakMap();
|
|
2446
1962
|
if (!this.initialized) {
|
|
2447
1963
|
return;
|
|
2448
1964
|
}
|
|
2449
|
-
this.
|
|
1965
|
+
this.cdr.markForCheck();
|
|
1966
|
+
this.updateWeakMap();
|
|
2450
1967
|
}
|
|
2451
1968
|
getChildrenContext() {
|
|
2452
1969
|
return {
|
|
@@ -2457,39 +1974,26 @@ class BaseElementComponent extends BaseComponent {
|
|
|
2457
1974
|
readonly: this._context.readonly
|
|
2458
1975
|
};
|
|
2459
1976
|
}
|
|
2460
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2461
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
1977
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseElementComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1978
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: BaseElementComponent, usesInheritance: true, ngImport: i0 }); }
|
|
2462
1979
|
}
|
|
2463
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1980
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseElementComponent, decorators: [{
|
|
2464
1981
|
type: Directive
|
|
2465
|
-
}]
|
|
2466
|
-
type: ViewChild,
|
|
2467
|
-
args: [SlateChildrenOutlet, { static: true }]
|
|
2468
|
-
}] } });
|
|
1982
|
+
}] });
|
|
2469
1983
|
/**
|
|
2470
1984
|
* base class for custom text component
|
|
2471
1985
|
*/
|
|
2472
1986
|
class BaseTextComponent extends BaseComponent {
|
|
2473
1987
|
constructor() {
|
|
2474
1988
|
super(...arguments);
|
|
2475
|
-
this.
|
|
2476
|
-
this.getOutletParent = () => {
|
|
2477
|
-
return this.elementRef.nativeElement;
|
|
2478
|
-
};
|
|
2479
|
-
this.getOutletElement = () => {
|
|
2480
|
-
if (this.childrenOutletInstance) {
|
|
2481
|
-
return this.childrenOutletInstance.getNativeElement();
|
|
2482
|
-
}
|
|
2483
|
-
return null;
|
|
2484
|
-
};
|
|
1989
|
+
this.initialized = false;
|
|
2485
1990
|
}
|
|
2486
1991
|
get text() {
|
|
2487
1992
|
return this._context && this._context.text;
|
|
2488
1993
|
}
|
|
2489
1994
|
ngOnInit() {
|
|
1995
|
+
this.updateWeakMap();
|
|
2490
1996
|
this.initialized = true;
|
|
2491
|
-
this.leavesRender = new LeavesRender(this.viewContext, this.viewContainerRef, this.getOutletParent, this.getOutletElement);
|
|
2492
|
-
this.leavesRender.initialize(this.context);
|
|
2493
1997
|
}
|
|
2494
1998
|
updateWeakMap() {
|
|
2495
1999
|
ELEMENT_TO_NODE.set(this.nativeElement, this.text);
|
|
@@ -2501,209 +2005,115 @@ class BaseTextComponent extends BaseComponent {
|
|
|
2501
2005
|
}
|
|
2502
2006
|
}
|
|
2503
2007
|
onContextChange() {
|
|
2504
|
-
this.updateWeakMap();
|
|
2505
2008
|
if (!this.initialized) {
|
|
2506
2009
|
return;
|
|
2507
2010
|
}
|
|
2508
|
-
this.
|
|
2011
|
+
this.cdr.markForCheck();
|
|
2012
|
+
this.updateWeakMap();
|
|
2509
2013
|
}
|
|
2510
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2511
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
2014
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseTextComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2015
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: BaseTextComponent, usesInheritance: true, ngImport: i0 }); }
|
|
2512
2016
|
}
|
|
2513
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2017
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: BaseTextComponent, decorators: [{
|
|
2514
2018
|
type: Directive
|
|
2515
|
-
}], propDecorators: { childrenOutletInstance: [{
|
|
2516
|
-
type: ViewChild,
|
|
2517
|
-
args: [SlateChildrenOutlet, { static: true }]
|
|
2518
|
-
}] } });
|
|
2519
|
-
|
|
2520
|
-
class SlateLeaves extends ViewContainer {
|
|
2521
|
-
constructor() {
|
|
2522
|
-
super(...arguments);
|
|
2523
|
-
this.initialized = false;
|
|
2524
|
-
}
|
|
2525
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateLeaves, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2526
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateLeaves, isStandalone: true, selector: "slate-leaves", inputs: { context: "context" }, usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2527
|
-
}
|
|
2528
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateLeaves, decorators: [{
|
|
2529
|
-
type: Component,
|
|
2530
|
-
args: [{
|
|
2531
|
-
selector: 'slate-leaves',
|
|
2532
|
-
template: ``,
|
|
2533
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2534
|
-
standalone: true,
|
|
2535
|
-
imports: [NgFor]
|
|
2536
|
-
}]
|
|
2537
|
-
}], propDecorators: { context: [{
|
|
2538
|
-
type: Input
|
|
2539
|
-
}] } });
|
|
2540
|
-
|
|
2541
|
-
class SlateVoidText extends BaseTextComponent {
|
|
2542
|
-
ngOnInit() {
|
|
2543
|
-
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2544
|
-
super.ngOnInit();
|
|
2545
|
-
}
|
|
2546
|
-
ngOnChanges() {
|
|
2547
|
-
if (!this.initialized) {
|
|
2548
|
-
return;
|
|
2549
|
-
}
|
|
2550
|
-
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2551
|
-
}
|
|
2552
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateVoidText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2553
|
-
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" }, properties: { "attr.contenteditable": "isLeafBlock" }, classAttribute: "slate-spacer" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2554
|
-
}
|
|
2555
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateVoidText, decorators: [{
|
|
2556
|
-
type: Component,
|
|
2557
|
-
args: [{
|
|
2558
|
-
selector: 'span[slateVoidText]',
|
|
2559
|
-
template: ``,
|
|
2560
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2561
|
-
host: {
|
|
2562
|
-
'[attr.contenteditable]': 'isLeafBlock',
|
|
2563
|
-
'data-slate-spacer': 'true',
|
|
2564
|
-
class: 'slate-spacer',
|
|
2565
|
-
'data-slate-node': 'text'
|
|
2566
|
-
},
|
|
2567
|
-
standalone: true,
|
|
2568
|
-
imports: [SlateLeaves]
|
|
2569
|
-
}]
|
|
2570
|
-
}] });
|
|
2571
|
-
|
|
2572
|
-
class SlateDefaultText extends BaseTextComponent {
|
|
2573
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2574
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateDefaultText, isStandalone: true, selector: "span[slateDefaultText]", host: { attributes: { "data-slate-node": "text" } }, usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2575
|
-
}
|
|
2576
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultText, decorators: [{
|
|
2577
|
-
type: Component,
|
|
2578
|
-
args: [{
|
|
2579
|
-
selector: 'span[slateDefaultText]',
|
|
2580
|
-
template: ``,
|
|
2581
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2582
|
-
host: {
|
|
2583
|
-
'data-slate-node': 'text'
|
|
2584
|
-
},
|
|
2585
|
-
standalone: true,
|
|
2586
|
-
imports: [SlateLeaves]
|
|
2587
|
-
}]
|
|
2588
|
-
}] });
|
|
2589
|
-
|
|
2590
|
-
class SlateDefaultElement extends BaseElementComponent {
|
|
2591
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultElement, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2592
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateDefaultElement, isStandalone: true, selector: "div[slateDefaultElement]", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2593
|
-
}
|
|
2594
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultElement, decorators: [{
|
|
2595
|
-
type: Component,
|
|
2596
|
-
args: [{
|
|
2597
|
-
selector: 'div[slateDefaultElement]',
|
|
2598
|
-
template: ``,
|
|
2599
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2600
|
-
standalone: true,
|
|
2601
|
-
imports: [SlateChildren]
|
|
2602
|
-
}]
|
|
2603
2019
|
}] });
|
|
2604
2020
|
|
|
2605
2021
|
/**
|
|
2606
|
-
*
|
|
2607
|
-
*
|
|
2608
|
-
*
|
|
2022
|
+
* the special container for angular template
|
|
2023
|
+
* Add the rootNodes of each child component to the parentElement
|
|
2024
|
+
* Remove useless DOM elements, eg: comment...
|
|
2609
2025
|
*/
|
|
2610
|
-
class
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
getRootNodes() {
|
|
2615
|
-
if (this.embeddedViewRef) {
|
|
2616
|
-
return this.embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode));
|
|
2617
|
-
}
|
|
2618
|
-
if (this.componentRef) {
|
|
2619
|
-
return [this.componentRef.instance.nativeElement];
|
|
2620
|
-
}
|
|
2621
|
-
return [];
|
|
2026
|
+
class ViewContainer {
|
|
2027
|
+
constructor(elementRef, differs) {
|
|
2028
|
+
this.elementRef = elementRef;
|
|
2029
|
+
this.differs = differs;
|
|
2622
2030
|
}
|
|
2623
|
-
|
|
2624
|
-
this.
|
|
2625
|
-
|
|
2031
|
+
ngAfterViewInit() {
|
|
2032
|
+
const differ = this.differs.find(this.childrenComponent).create((index, item) => {
|
|
2033
|
+
return item;
|
|
2034
|
+
});
|
|
2035
|
+
// first diff
|
|
2036
|
+
differ.diff(this.childrenComponent);
|
|
2037
|
+
const parentElement = this.elementRef.nativeElement.parentElement;
|
|
2038
|
+
if (this.childrenComponent.length > 0) {
|
|
2039
|
+
parentElement.insertBefore(this.createFragment(), this.elementRef.nativeElement);
|
|
2040
|
+
this.elementRef.nativeElement.remove();
|
|
2041
|
+
}
|
|
2042
|
+
this.childrenComponent.changes.subscribe(value => {
|
|
2043
|
+
const iterableChanges = differ.diff(this.childrenComponent);
|
|
2044
|
+
if (iterableChanges) {
|
|
2045
|
+
iterableChanges.forEachOperation((record, previousIndex, currentIndex) => {
|
|
2046
|
+
// removed
|
|
2047
|
+
if (currentIndex === null) {
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
// added or moved
|
|
2051
|
+
this.handleContainerItemChange(record, parentElement);
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
});
|
|
2626
2055
|
}
|
|
2627
|
-
|
|
2628
|
-
if (
|
|
2629
|
-
|
|
2630
|
-
this.embeddedViewRef = null;
|
|
2056
|
+
getPreviousRootNode(currentIndex) {
|
|
2057
|
+
if (currentIndex === 0) {
|
|
2058
|
+
return null;
|
|
2631
2059
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2060
|
+
const previousComponent = this.childrenComponent.find((item, index) => index === currentIndex - 1);
|
|
2061
|
+
let previousRootNode = previousComponent.rootNodes[previousComponent.rootNodes.length - 1];
|
|
2062
|
+
if (previousRootNode) {
|
|
2063
|
+
return previousRootNode;
|
|
2635
2064
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
this.initialized = true;
|
|
2639
|
-
this.viewType = this.getViewType();
|
|
2640
|
-
const context = this.getContext();
|
|
2641
|
-
if (isTemplateRef(this.viewType)) {
|
|
2642
|
-
this.embeddedViewContext = {
|
|
2643
|
-
context,
|
|
2644
|
-
viewContext: this.viewContext
|
|
2645
|
-
};
|
|
2646
|
-
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
2647
|
-
this.embeddedViewRef = embeddedViewRef;
|
|
2648
|
-
}
|
|
2649
|
-
if (isComponentType(this.viewType)) {
|
|
2650
|
-
const componentRef = this.viewContainerRef.createComponent(this.viewType);
|
|
2651
|
-
componentRef.instance.viewContext = this.viewContext;
|
|
2652
|
-
componentRef.instance.context = context;
|
|
2653
|
-
this.componentRef = componentRef;
|
|
2065
|
+
else {
|
|
2066
|
+
return this.getPreviousRootNode(currentIndex - 1);
|
|
2654
2067
|
}
|
|
2655
2068
|
}
|
|
2656
|
-
|
|
2657
|
-
const
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2069
|
+
createFragment() {
|
|
2070
|
+
const fragment = document.createDocumentFragment();
|
|
2071
|
+
this.childrenComponent.forEach((component, index) => {
|
|
2072
|
+
fragment.append(...component.rootNodes);
|
|
2073
|
+
});
|
|
2074
|
+
return fragment;
|
|
2075
|
+
}
|
|
2076
|
+
handleContainerItemChange(record, parentElement) {
|
|
2077
|
+
// first insert
|
|
2078
|
+
if (this.elementRef.nativeElement.parentElement && this.elementRef.nativeElement.parentElement === parentElement) {
|
|
2079
|
+
const fragment = document.createDocumentFragment();
|
|
2080
|
+
fragment.append(...record.item.rootNodes);
|
|
2081
|
+
parentElement.insertBefore(fragment, this.elementRef.nativeElement);
|
|
2082
|
+
this.elementRef.nativeElement.remove();
|
|
2083
|
+
return;
|
|
2084
|
+
}
|
|
2085
|
+
// insert at start location
|
|
2086
|
+
if (record.currentIndex === 0) {
|
|
2087
|
+
const fragment = document.createDocumentFragment();
|
|
2088
|
+
fragment.append(...record.item.rootNodes);
|
|
2089
|
+
parentElement.prepend(fragment);
|
|
2672
2090
|
}
|
|
2673
2091
|
else {
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
if (
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
};
|
|
2681
|
-
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
2682
|
-
firstRootNode.replaceWith(...embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode)));
|
|
2683
|
-
this.destroyView();
|
|
2684
|
-
this.embeddedViewRef = embeddedViewRef;
|
|
2092
|
+
// insert afterend of previous component end
|
|
2093
|
+
let previousRootNode = this.getPreviousRootNode(record.currentIndex);
|
|
2094
|
+
if (previousRootNode) {
|
|
2095
|
+
record.item.rootNodes.forEach(rootNode => {
|
|
2096
|
+
previousRootNode.insertAdjacentElement('afterend', rootNode);
|
|
2097
|
+
previousRootNode = rootNode;
|
|
2098
|
+
});
|
|
2685
2099
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
this.componentRef = componentRef;
|
|
2100
|
+
else {
|
|
2101
|
+
this.viewContext.editor.onError({
|
|
2102
|
+
code: SlateErrorCode.NotFoundPreviousRootNodeError,
|
|
2103
|
+
name: 'not found previous rootNode',
|
|
2104
|
+
nativeError: null
|
|
2105
|
+
});
|
|
2693
2106
|
}
|
|
2694
2107
|
}
|
|
2108
|
+
// Solve the block-card DOMElement loss when moving nodes
|
|
2109
|
+
record.item.appendBlockCardElement();
|
|
2695
2110
|
}
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
this.blockCardComponentRef.instance.append();
|
|
2699
|
-
}
|
|
2700
|
-
}
|
|
2701
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ViewContainerItem, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2702
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: ViewContainerItem, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
2111
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ViewContainer, deps: [{ token: i0.ElementRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2112
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.4", type: ViewContainer, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
2703
2113
|
}
|
|
2704
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2114
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: ViewContainer, decorators: [{
|
|
2705
2115
|
type: Directive
|
|
2706
|
-
}], ctorParameters:
|
|
2116
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.IterableDiffers }], propDecorators: { viewContext: [{
|
|
2707
2117
|
type: Input
|
|
2708
2118
|
}] } });
|
|
2709
2119
|
|
|
@@ -2758,164 +2168,516 @@ class SlateDefaultString extends BaseComponent {
|
|
|
2758
2168
|
this.nativeElement.setAttribute('data-slate-string', 'true');
|
|
2759
2169
|
this.updateStringDOM();
|
|
2760
2170
|
}
|
|
2761
|
-
updateStringDOM() {
|
|
2762
|
-
// Avoid breaking some browser default behaviors, such as spellCheck, android composition input state
|
|
2763
|
-
if (this.nativeElement.textContent !== this.context.text) {
|
|
2764
|
-
this.nativeElement.textContent = this.context.text;
|
|
2171
|
+
updateStringDOM() {
|
|
2172
|
+
// Avoid breaking some browser default behaviors, such as spellCheck, android composition input state
|
|
2173
|
+
if (this.nativeElement.textContent !== this.context.text) {
|
|
2174
|
+
this.nativeElement.textContent = this.context.text;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
removeStringDOM() {
|
|
2178
|
+
this.nativeElement.removeAttribute('data-slate-string');
|
|
2179
|
+
this.nativeElement.textContent = '';
|
|
2180
|
+
}
|
|
2181
|
+
ngOnInit() {
|
|
2182
|
+
this.nativeElement.setAttribute('editable-text', '');
|
|
2183
|
+
}
|
|
2184
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultString, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2185
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateDefaultString, isStandalone: true, selector: "span[slateDefaultString]", usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2186
|
+
}
|
|
2187
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultString, decorators: [{
|
|
2188
|
+
type: Component,
|
|
2189
|
+
args: [{
|
|
2190
|
+
selector: 'span[slateDefaultString]',
|
|
2191
|
+
template: '',
|
|
2192
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2193
|
+
standalone: true
|
|
2194
|
+
}]
|
|
2195
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }] });
|
|
2196
|
+
|
|
2197
|
+
class SlateString extends ViewContainerItem {
|
|
2198
|
+
constructor(elementRef, viewContainerRef) {
|
|
2199
|
+
super(viewContainerRef);
|
|
2200
|
+
this.elementRef = elementRef;
|
|
2201
|
+
this.viewContainerRef = viewContainerRef;
|
|
2202
|
+
}
|
|
2203
|
+
ngOnInit() {
|
|
2204
|
+
this.createView();
|
|
2205
|
+
}
|
|
2206
|
+
ngOnChanges() {
|
|
2207
|
+
if (!this.initialized) {
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
this.updateView();
|
|
2211
|
+
}
|
|
2212
|
+
ngAfterViewInit() {
|
|
2213
|
+
this.elementRef.nativeElement.remove();
|
|
2214
|
+
}
|
|
2215
|
+
// COMPAT: If this is the last text node in an empty block, render a zero-
|
|
2216
|
+
// width space that will convert into a line break when copying and pasting
|
|
2217
|
+
// to support expected plain text.
|
|
2218
|
+
isLineBreakEmptyString() {
|
|
2219
|
+
const path = AngularEditor.findPath(this.viewContext.editor, this.context.text);
|
|
2220
|
+
const parentPath = Path.parent(path);
|
|
2221
|
+
return (this.context.leaf.text === '' &&
|
|
2222
|
+
this.context.parent.children[this.context.parent.children.length - 1] === this.context.text &&
|
|
2223
|
+
!this.viewContext.editor.isInline(this.context.parent) &&
|
|
2224
|
+
Editor.string(this.viewContext.editor, parentPath) === '');
|
|
2225
|
+
}
|
|
2226
|
+
// COMPAT: If the text is empty, it's because it's on the edge of an inline
|
|
2227
|
+
// node, so we render a zero-width space so that the selection can be
|
|
2228
|
+
// inserted next to it still.
|
|
2229
|
+
isEmptyText() {
|
|
2230
|
+
return this.context.leaf.text === '';
|
|
2231
|
+
}
|
|
2232
|
+
// COMPAT: Browsers will collapse trailing new lines at the end of blocks,
|
|
2233
|
+
// so we need to add an extra trailing new lines to prevent that.
|
|
2234
|
+
isCompatibleString() {
|
|
2235
|
+
return this.context.isLast && this.context.leaf.text.slice(-1) === '\n';
|
|
2236
|
+
}
|
|
2237
|
+
// COMPAT: Render text inside void nodes with a zero-width space.
|
|
2238
|
+
// So the node can contain selection but the text is not visible.
|
|
2239
|
+
isVoid() {
|
|
2240
|
+
return this.viewContext.editor.isVoid(this.context.parent);
|
|
2241
|
+
}
|
|
2242
|
+
getViewType() {
|
|
2243
|
+
if (this.isVoid()) {
|
|
2244
|
+
return this.viewContext.templateComponent.voidStringTemplate;
|
|
2245
|
+
}
|
|
2246
|
+
if (this.isLineBreakEmptyString()) {
|
|
2247
|
+
return SlateDefaultString;
|
|
2248
|
+
}
|
|
2249
|
+
if (this.isEmptyText()) {
|
|
2250
|
+
return this.viewContext.templateComponent.emptyTextTemplate;
|
|
2251
|
+
}
|
|
2252
|
+
if (this.isCompatibleString()) {
|
|
2253
|
+
return this.viewContext.templateComponent.compatibleStringTemplate;
|
|
2254
|
+
}
|
|
2255
|
+
return SlateDefaultString;
|
|
2256
|
+
}
|
|
2257
|
+
getType() {
|
|
2258
|
+
if (this.isLineBreakEmptyString()) {
|
|
2259
|
+
return 'lineBreakEmptyString';
|
|
2260
|
+
}
|
|
2261
|
+
return 'string';
|
|
2262
|
+
}
|
|
2263
|
+
getContext() {
|
|
2264
|
+
const stringType = this.getType();
|
|
2265
|
+
return {
|
|
2266
|
+
text: this.context.leaf.text,
|
|
2267
|
+
elementStringLength: Node.string(this.context.parent).length,
|
|
2268
|
+
type: stringType
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
memoizedContext(prev, next) {
|
|
2272
|
+
return false;
|
|
2273
|
+
}
|
|
2274
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateString, deps: [{ token: i0.ElementRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2275
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateString, isStandalone: true, selector: "span[slateString]", inputs: { context: "context" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2276
|
+
}
|
|
2277
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateString, decorators: [{
|
|
2278
|
+
type: Component,
|
|
2279
|
+
args: [{
|
|
2280
|
+
selector: 'span[slateString]',
|
|
2281
|
+
template: '',
|
|
2282
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2283
|
+
standalone: true
|
|
2284
|
+
}]
|
|
2285
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }], propDecorators: { context: [{
|
|
2286
|
+
type: Input
|
|
2287
|
+
}] } });
|
|
2288
|
+
|
|
2289
|
+
class SlateDefaultLeaf extends BaseLeafComponent {
|
|
2290
|
+
onContextChange() {
|
|
2291
|
+
super.onContextChange();
|
|
2292
|
+
this.renderPlaceholder();
|
|
2293
|
+
}
|
|
2294
|
+
ngOnDestroy() {
|
|
2295
|
+
// Because the placeholder span is not in the current component, it is destroyed along with the current component
|
|
2296
|
+
this.destroyPlaceholder();
|
|
2297
|
+
}
|
|
2298
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultLeaf, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2299
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateDefaultLeaf, isStandalone: true, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0, template: `<span slateString [context]="context" [viewContext]="viewContext"><span></span></span>`, isInline: true, dependencies: [{ kind: "component", type: SlateString, selector: "span[slateString]", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2300
|
+
}
|
|
2301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultLeaf, decorators: [{
|
|
2302
|
+
type: Component,
|
|
2303
|
+
args: [{
|
|
2304
|
+
selector: 'span[slateDefaultLeaf]',
|
|
2305
|
+
template: `<span slateString [context]="context" [viewContext]="viewContext"><span></span></span>`,
|
|
2306
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2307
|
+
host: {
|
|
2308
|
+
'data-slate-leaf': 'true'
|
|
2309
|
+
},
|
|
2310
|
+
standalone: true,
|
|
2311
|
+
imports: [SlateString]
|
|
2312
|
+
}]
|
|
2313
|
+
}] });
|
|
2314
|
+
|
|
2315
|
+
class SlateLeaf extends ViewContainerItem {
|
|
2316
|
+
ngOnInit() {
|
|
2317
|
+
this.createView();
|
|
2318
|
+
}
|
|
2319
|
+
getContext() {
|
|
2320
|
+
return this.context;
|
|
2321
|
+
}
|
|
2322
|
+
getViewType() {
|
|
2323
|
+
return (this.viewContext.renderLeaf && this.viewContext.renderLeaf(this.context.leaf)) || SlateDefaultLeaf;
|
|
2324
|
+
}
|
|
2325
|
+
memoizedContext(prev, next) {
|
|
2326
|
+
return false;
|
|
2327
|
+
}
|
|
2328
|
+
ngOnChanges(simpleChanges) {
|
|
2329
|
+
if (!this.initialized) {
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
this.updateView();
|
|
2333
|
+
}
|
|
2334
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateLeaf, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2335
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateLeaf, isStandalone: true, selector: "slate-leaf", inputs: { context: "context" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2336
|
+
}
|
|
2337
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateLeaf, decorators: [{
|
|
2338
|
+
type: Component,
|
|
2339
|
+
args: [{
|
|
2340
|
+
selector: 'slate-leaf',
|
|
2341
|
+
template: '',
|
|
2342
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2343
|
+
standalone: true
|
|
2344
|
+
}]
|
|
2345
|
+
}], propDecorators: { context: [{
|
|
2346
|
+
type: Input
|
|
2347
|
+
}] } });
|
|
2348
|
+
|
|
2349
|
+
class SlateLeaves extends ViewContainer {
|
|
2350
|
+
constructor() {
|
|
2351
|
+
super(...arguments);
|
|
2352
|
+
this.initialized = false;
|
|
2353
|
+
}
|
|
2354
|
+
ngOnInit() {
|
|
2355
|
+
this.leaves = Text$1.decorations(this.context.text, this.context.decorations);
|
|
2356
|
+
this.leafContexts = this.getLeafContexts();
|
|
2357
|
+
this.initialized = true;
|
|
2358
|
+
}
|
|
2359
|
+
getLeafContexts() {
|
|
2360
|
+
return this.leaves.map((leaf, index) => {
|
|
2361
|
+
return {
|
|
2362
|
+
leaf,
|
|
2363
|
+
text: this.context.text,
|
|
2364
|
+
parent: this.context.parent,
|
|
2365
|
+
index,
|
|
2366
|
+
isLast: this.context.isLast && index === this.leaves.length - 1
|
|
2367
|
+
};
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2370
|
+
ngOnChanges(simpleChanges) {
|
|
2371
|
+
if (!this.initialized) {
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
const context = simpleChanges['context'];
|
|
2375
|
+
const previousValue = context.previousValue;
|
|
2376
|
+
const currentValue = context.currentValue;
|
|
2377
|
+
if (previousValue.text !== currentValue.text || !isDecoratorRangeListEqual(previousValue.decorations, currentValue.decorations)) {
|
|
2378
|
+
this.leaves = Text$1.decorations(this.context.text, this.context.decorations);
|
|
2379
|
+
}
|
|
2380
|
+
this.leafContexts = this.getLeafContexts();
|
|
2381
|
+
}
|
|
2382
|
+
trackBy(index, item) {
|
|
2383
|
+
return index;
|
|
2384
|
+
}
|
|
2385
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateLeaves, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2386
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateLeaves, isStandalone: true, selector: "slate-leaves", inputs: { context: "context" }, viewQueries: [{ propertyName: "childrenComponent", predicate: SlateLeaf, descendants: true, read: SlateLeaf }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `<slate-leaf
|
|
2387
|
+
[context]="context"
|
|
2388
|
+
[viewContext]="viewContext"
|
|
2389
|
+
*ngFor="let context of leafContexts; trackBy: trackBy"
|
|
2390
|
+
></slate-leaf>`, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: SlateLeaf, selector: "slate-leaf", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2391
|
+
}
|
|
2392
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateLeaves, decorators: [{
|
|
2393
|
+
type: Component,
|
|
2394
|
+
args: [{
|
|
2395
|
+
selector: 'slate-leaves',
|
|
2396
|
+
template: `<slate-leaf
|
|
2397
|
+
[context]="context"
|
|
2398
|
+
[viewContext]="viewContext"
|
|
2399
|
+
*ngFor="let context of leafContexts; trackBy: trackBy"
|
|
2400
|
+
></slate-leaf>`,
|
|
2401
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2402
|
+
standalone: true,
|
|
2403
|
+
imports: [NgFor, SlateLeaf]
|
|
2404
|
+
}]
|
|
2405
|
+
}], propDecorators: { context: [{
|
|
2406
|
+
type: Input
|
|
2407
|
+
}], childrenComponent: [{
|
|
2408
|
+
type: ViewChildren,
|
|
2409
|
+
args: [SlateLeaf, { read: SlateLeaf }]
|
|
2410
|
+
}] } });
|
|
2411
|
+
|
|
2412
|
+
class SlateDefaultText extends BaseTextComponent {
|
|
2413
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2414
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateDefaultText, isStandalone: true, selector: "span[slateDefaultText]", host: { attributes: { "data-slate-node": "text" } }, usesInheritance: true, ngImport: i0, template: `<slate-leaves [context]="context" [viewContext]="viewContext" [viewContext]="viewContext"></slate-leaves>`, isInline: true, dependencies: [{ kind: "component", type: SlateLeaves, selector: "slate-leaves", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2415
|
+
}
|
|
2416
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultText, decorators: [{
|
|
2417
|
+
type: Component,
|
|
2418
|
+
args: [{
|
|
2419
|
+
selector: 'span[slateDefaultText]',
|
|
2420
|
+
template: `<slate-leaves [context]="context" [viewContext]="viewContext" [viewContext]="viewContext"></slate-leaves>`,
|
|
2421
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2422
|
+
host: {
|
|
2423
|
+
'data-slate-node': 'text'
|
|
2424
|
+
},
|
|
2425
|
+
standalone: true,
|
|
2426
|
+
imports: [SlateLeaves]
|
|
2427
|
+
}]
|
|
2428
|
+
}] });
|
|
2429
|
+
|
|
2430
|
+
class SlateVoidText extends BaseTextComponent {
|
|
2431
|
+
ngOnInit() {
|
|
2432
|
+
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2433
|
+
super.ngOnInit();
|
|
2434
|
+
}
|
|
2435
|
+
ngOnChanges() {
|
|
2436
|
+
if (!this.initialized) {
|
|
2437
|
+
return;
|
|
2765
2438
|
}
|
|
2439
|
+
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2766
2440
|
}
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
this.nativeElement.textContent = '';
|
|
2770
|
-
}
|
|
2771
|
-
ngOnInit() {
|
|
2772
|
-
this.nativeElement.setAttribute('editable-text', '');
|
|
2773
|
-
}
|
|
2774
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultString, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2775
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateDefaultString, isStandalone: true, selector: "span[slateDefaultString]", usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2441
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateVoidText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2442
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateVoidText, isStandalone: true, selector: "span[slateVoidText]", host: { attributes: { "data-slate-spacer": "true", "data-slate-node": "text" }, properties: { "attr.contenteditable": "isLeafBlock" }, classAttribute: "slate-spacer" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `<slate-leaves [context]="context" [viewContext]="viewContext" [viewContext]="viewContext"></slate-leaves>`, isInline: true, dependencies: [{ kind: "component", type: SlateLeaves, selector: "slate-leaves", inputs: ["context"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2776
2443
|
}
|
|
2777
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2444
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateVoidText, decorators: [{
|
|
2778
2445
|
type: Component,
|
|
2779
2446
|
args: [{
|
|
2780
|
-
selector: 'span[
|
|
2781
|
-
template:
|
|
2447
|
+
selector: 'span[slateVoidText]',
|
|
2448
|
+
template: `<slate-leaves [context]="context" [viewContext]="viewContext" [viewContext]="viewContext"></slate-leaves>`,
|
|
2782
2449
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2783
|
-
|
|
2450
|
+
host: {
|
|
2451
|
+
'[attr.contenteditable]': 'isLeafBlock',
|
|
2452
|
+
'data-slate-spacer': 'true',
|
|
2453
|
+
class: 'slate-spacer',
|
|
2454
|
+
'data-slate-node': 'text'
|
|
2455
|
+
},
|
|
2456
|
+
standalone: true,
|
|
2457
|
+
imports: [SlateLeaves]
|
|
2784
2458
|
}]
|
|
2785
|
-
}]
|
|
2459
|
+
}] });
|
|
2786
2460
|
|
|
2787
|
-
|
|
2788
|
-
|
|
2461
|
+
const SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN = new InjectionToken('slate-default-element-token');
|
|
2462
|
+
|
|
2463
|
+
class SlateDescendant extends ViewContainerItem {
|
|
2464
|
+
get rootNodes() {
|
|
2465
|
+
if (this.blockCardComponentRef) {
|
|
2466
|
+
return [this.blockCardComponentRef.instance.nativeElement];
|
|
2467
|
+
}
|
|
2468
|
+
return super.getRootNodes();
|
|
2469
|
+
}
|
|
2470
|
+
get isBlockCard() {
|
|
2471
|
+
return this.viewContext.editor.isBlockCard(this.descendant);
|
|
2472
|
+
}
|
|
2473
|
+
constructor(viewContainerRef, defaultElementComponentType) {
|
|
2789
2474
|
super(viewContainerRef);
|
|
2790
|
-
this.elementRef = elementRef;
|
|
2791
2475
|
this.viewContainerRef = viewContainerRef;
|
|
2476
|
+
this.defaultElementComponentType = defaultElementComponentType;
|
|
2792
2477
|
}
|
|
2793
2478
|
ngOnInit() {
|
|
2479
|
+
NODE_TO_INDEX.set(this.descendant, this.index);
|
|
2480
|
+
NODE_TO_PARENT.set(this.descendant, this.context.parent);
|
|
2794
2481
|
this.createView();
|
|
2482
|
+
if (this.isBlockCard) {
|
|
2483
|
+
this.createBlockCard();
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
destroyView() {
|
|
2487
|
+
super.destroyView();
|
|
2488
|
+
this.destroyBlockCard();
|
|
2795
2489
|
}
|
|
2796
2490
|
ngOnChanges() {
|
|
2797
2491
|
if (!this.initialized) {
|
|
2798
2492
|
return;
|
|
2799
2493
|
}
|
|
2494
|
+
NODE_TO_INDEX.set(this.descendant, this.index);
|
|
2495
|
+
NODE_TO_PARENT.set(this.descendant, this.context.parent);
|
|
2800
2496
|
this.updateView();
|
|
2497
|
+
if (this.isBlockCard) {
|
|
2498
|
+
this.updateBlockCard();
|
|
2499
|
+
}
|
|
2801
2500
|
}
|
|
2802
|
-
|
|
2803
|
-
this.
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
// to support expected plain text.
|
|
2808
|
-
isLineBreakEmptyString() {
|
|
2809
|
-
return (this.context.leaf.text === '' &&
|
|
2810
|
-
this.context.parent.children[this.context.parent.children.length - 1] === this.context.text &&
|
|
2811
|
-
!this.viewContext.editor.isInline(this.context.parent) &&
|
|
2812
|
-
// [list-render] performance optimization: reduce the number of calls to the `Editor.string(editor, path)` method
|
|
2813
|
-
isEmpty(this.viewContext.editor, this.context.parent));
|
|
2814
|
-
}
|
|
2815
|
-
// COMPAT: If the text is empty, it's because it's on the edge of an inline
|
|
2816
|
-
// node, so we render a zero-width space so that the selection can be
|
|
2817
|
-
// inserted next to it still.
|
|
2818
|
-
isEmptyText() {
|
|
2819
|
-
return this.context.leaf.text === '';
|
|
2501
|
+
destroyBlockCard() {
|
|
2502
|
+
if (this.blockCardComponentRef) {
|
|
2503
|
+
this.blockCardComponentRef.destroy();
|
|
2504
|
+
this.blockCardComponentRef = null;
|
|
2505
|
+
}
|
|
2820
2506
|
}
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2507
|
+
createBlockCard() {
|
|
2508
|
+
const rootNodes = this.rootNodes;
|
|
2509
|
+
this.blockCardComponentRef = this.viewContainerRef.createComponent(SlateBlockCard);
|
|
2510
|
+
this.blockCardComponentRef.instance.initializeCenter(rootNodes);
|
|
2825
2511
|
}
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2512
|
+
updateBlockCard() {
|
|
2513
|
+
if (this.blockCardComponentRef) {
|
|
2514
|
+
return;
|
|
2515
|
+
}
|
|
2516
|
+
const rootNodes = this.rootNodes;
|
|
2517
|
+
this.createBlockCard();
|
|
2518
|
+
const firstRootNode = rootNodes[0];
|
|
2519
|
+
firstRootNode.replaceWith(this.blockCardComponentRef.instance.nativeElement);
|
|
2830
2520
|
}
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2521
|
+
getCommonContext() {
|
|
2522
|
+
const path = AngularEditor.findPath(this.viewContext.editor, this.context.parent);
|
|
2523
|
+
const p = path.concat(this.index);
|
|
2524
|
+
try {
|
|
2525
|
+
const range = Editor.range(this.viewContext.editor, p);
|
|
2526
|
+
const sel = this.context.selection && Range.intersection(range, this.context.selection);
|
|
2527
|
+
const ds = this.context.decorate([this.descendant, p]);
|
|
2528
|
+
for (const dec of this.context.decorations) {
|
|
2529
|
+
const d = Range.intersection(dec, range);
|
|
2530
|
+
if (d) {
|
|
2531
|
+
ds.push(d);
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
return { selection: sel, decorations: ds };
|
|
2834
2535
|
}
|
|
2835
|
-
|
|
2836
|
-
|
|
2536
|
+
catch (error) {
|
|
2537
|
+
this.viewContext.editor.onError({
|
|
2538
|
+
code: SlateErrorCode.GetStartPointError,
|
|
2539
|
+
nativeError: error
|
|
2540
|
+
});
|
|
2541
|
+
return { selection: null, decorations: [] };
|
|
2837
2542
|
}
|
|
2838
|
-
|
|
2839
|
-
|
|
2543
|
+
}
|
|
2544
|
+
getContext() {
|
|
2545
|
+
if (Element.isElement(this.descendant)) {
|
|
2546
|
+
const computedContext = this.getCommonContext();
|
|
2547
|
+
const key = AngularEditor.findKey(this.viewContext.editor, this.descendant);
|
|
2548
|
+
const isInline = this.viewContext.editor.isInline(this.descendant);
|
|
2549
|
+
const isVoid = this.viewContext.editor.isVoid(this.descendant);
|
|
2550
|
+
const elementContext = {
|
|
2551
|
+
element: this.descendant,
|
|
2552
|
+
...computedContext,
|
|
2553
|
+
attributes: {
|
|
2554
|
+
'data-slate-node': 'element',
|
|
2555
|
+
'data-slate-key': key.id
|
|
2556
|
+
},
|
|
2557
|
+
decorate: this.context.decorate,
|
|
2558
|
+
readonly: this.context.readonly
|
|
2559
|
+
};
|
|
2560
|
+
if (isInline) {
|
|
2561
|
+
elementContext.attributes['data-slate-inline'] = true;
|
|
2562
|
+
}
|
|
2563
|
+
if (isVoid) {
|
|
2564
|
+
elementContext.attributes['data-slate-void'] = true;
|
|
2565
|
+
elementContext.attributes.contenteditable = false;
|
|
2566
|
+
}
|
|
2567
|
+
return elementContext;
|
|
2840
2568
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2569
|
+
else {
|
|
2570
|
+
const computedContext = this.getCommonContext();
|
|
2571
|
+
const isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2572
|
+
const textContext = {
|
|
2573
|
+
decorations: computedContext.decorations,
|
|
2574
|
+
isLast: isLeafBlock && this.index === this.context.parent.children.length - 1,
|
|
2575
|
+
parent: this.context.parent,
|
|
2576
|
+
text: this.descendant
|
|
2577
|
+
};
|
|
2578
|
+
return textContext;
|
|
2843
2579
|
}
|
|
2844
|
-
return SlateDefaultString;
|
|
2845
2580
|
}
|
|
2846
|
-
|
|
2847
|
-
if (this.
|
|
2848
|
-
return
|
|
2581
|
+
getViewType() {
|
|
2582
|
+
if (Element.isElement(this.descendant)) {
|
|
2583
|
+
return (this.viewContext.renderElement && this.viewContext.renderElement(this.descendant)) || this.defaultElementComponentType;
|
|
2584
|
+
}
|
|
2585
|
+
else {
|
|
2586
|
+
const isVoid = this.viewContext.editor.isVoid(this.context.parent);
|
|
2587
|
+
return isVoid
|
|
2588
|
+
? SlateVoidText
|
|
2589
|
+
: (this.viewContext.renderText && this.viewContext.renderText(this.descendant)) || SlateDefaultText;
|
|
2849
2590
|
}
|
|
2850
|
-
return 'string';
|
|
2851
2591
|
}
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2592
|
+
memoizedElementContext(prev, next) {
|
|
2593
|
+
return (prev.element === next.element &&
|
|
2594
|
+
(!this.viewContext.isStrictDecorate || prev.decorate === next.decorate) &&
|
|
2595
|
+
prev.readonly === next.readonly &&
|
|
2596
|
+
isDecoratorRangeListEqual(prev.decorations, next.decorations) &&
|
|
2597
|
+
(prev.selection === next.selection || (!!prev.selection && !!next.selection && Range.equals(prev.selection, next.selection))));
|
|
2598
|
+
}
|
|
2599
|
+
memoizedTextContext(prev, next) {
|
|
2600
|
+
return (next.parent === prev.parent &&
|
|
2601
|
+
next.isLast === prev.isLast &&
|
|
2602
|
+
next.text === prev.text &&
|
|
2603
|
+
isDecoratorRangeListEqual(next.decorations, prev.decorations));
|
|
2859
2604
|
}
|
|
2860
2605
|
memoizedContext(prev, next) {
|
|
2861
|
-
|
|
2606
|
+
if (Element.isElement(this.descendant)) {
|
|
2607
|
+
return this.memoizedElementContext(prev, next);
|
|
2608
|
+
}
|
|
2609
|
+
else {
|
|
2610
|
+
return this.memoizedTextContext(prev, next);
|
|
2611
|
+
}
|
|
2862
2612
|
}
|
|
2863
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2864
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
2613
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDescendant, deps: [{ token: i0.ViewContainerRef }, { token: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2614
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateDescendant, isStandalone: true, selector: "slate-descendant", inputs: { descendant: "descendant", context: "context", viewContext: "viewContext", index: "index" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2865
2615
|
}
|
|
2866
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2616
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDescendant, decorators: [{
|
|
2867
2617
|
type: Component,
|
|
2868
2618
|
args: [{
|
|
2869
|
-
selector: '
|
|
2619
|
+
selector: 'slate-descendant',
|
|
2870
2620
|
template: '',
|
|
2871
2621
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2872
2622
|
standalone: true
|
|
2873
2623
|
}]
|
|
2874
|
-
}], ctorParameters:
|
|
2624
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: undefined, decorators: [{
|
|
2625
|
+
type: Inject,
|
|
2626
|
+
args: [SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN]
|
|
2627
|
+
}] }], propDecorators: { descendant: [{
|
|
2628
|
+
type: Input
|
|
2629
|
+
}], context: [{
|
|
2630
|
+
type: Input
|
|
2631
|
+
}], viewContext: [{
|
|
2632
|
+
type: Input
|
|
2633
|
+
}], index: [{
|
|
2875
2634
|
type: Input
|
|
2876
2635
|
}] } });
|
|
2877
|
-
/**
|
|
2878
|
-
* TODO: remove when bump slate
|
|
2879
|
-
* copy from slate
|
|
2880
|
-
* @param editor
|
|
2881
|
-
* @param element
|
|
2882
|
-
* @returns
|
|
2883
|
-
*/
|
|
2884
|
-
const isEmpty = (editor, element) => {
|
|
2885
|
-
const { children } = element;
|
|
2886
|
-
const [first] = children;
|
|
2887
|
-
return children.length === 0 || (children.length === 1 && Text$1.isText(first) && first.text === '' && !editor.isVoid(element));
|
|
2888
|
-
};
|
|
2889
2636
|
|
|
2890
|
-
class
|
|
2891
|
-
|
|
2892
|
-
super
|
|
2893
|
-
this.
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
// Because the placeholder span is not in the current component, it is destroyed along with the current component
|
|
2897
|
-
this.destroyPlaceholder();
|
|
2637
|
+
class SlateChildren extends ViewContainer {
|
|
2638
|
+
constructor() {
|
|
2639
|
+
super(...arguments);
|
|
2640
|
+
this.trackBy = (index, node) => {
|
|
2641
|
+
return this.viewContext.trackBy(node) || AngularEditor.findKey(this.viewContext.editor, node);
|
|
2642
|
+
};
|
|
2898
2643
|
}
|
|
2899
|
-
|
|
2900
|
-
static { this.ɵ
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2644
|
+
ngOnInit() { }
|
|
2645
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateChildren, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2646
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateChildren, isStandalone: true, selector: "slate-children", inputs: { children: "children", context: "context", viewContext: "viewContext" }, viewQueries: [{ propertyName: "childrenComponent", predicate: SlateDescendant, descendants: true, read: SlateDescendant }], usesInheritance: true, ngImport: i0, template: `<slate-descendant
|
|
2647
|
+
[descendant]="descendant"
|
|
2648
|
+
[context]="context"
|
|
2649
|
+
[viewContext]="viewContext"
|
|
2650
|
+
[viewContext]="viewContext"
|
|
2651
|
+
[index]="index"
|
|
2652
|
+
*ngFor="let descendant of children; let index = index; trackBy: trackBy"
|
|
2653
|
+
></slate-descendant>`, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: SlateDescendant, selector: "slate-descendant", inputs: ["descendant", "context", "viewContext", "index"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2654
|
+
}
|
|
2655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateChildren, decorators: [{
|
|
2903
2656
|
type: Component,
|
|
2904
2657
|
args: [{
|
|
2905
|
-
selector: '
|
|
2906
|
-
template: `<
|
|
2658
|
+
selector: 'slate-children',
|
|
2659
|
+
template: `<slate-descendant
|
|
2660
|
+
[descendant]="descendant"
|
|
2661
|
+
[context]="context"
|
|
2662
|
+
[viewContext]="viewContext"
|
|
2663
|
+
[viewContext]="viewContext"
|
|
2664
|
+
[index]="index"
|
|
2665
|
+
*ngFor="let descendant of children; let index = index; trackBy: trackBy"
|
|
2666
|
+
></slate-descendant>`,
|
|
2907
2667
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2908
|
-
host: {
|
|
2909
|
-
'data-slate-leaf': 'true'
|
|
2910
|
-
},
|
|
2911
2668
|
standalone: true,
|
|
2912
|
-
imports: [
|
|
2669
|
+
imports: [NgFor, SlateDescendant]
|
|
2913
2670
|
}]
|
|
2914
|
-
}]
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2671
|
+
}], propDecorators: { children: [{
|
|
2672
|
+
type: Input
|
|
2673
|
+
}], context: [{
|
|
2674
|
+
type: Input
|
|
2675
|
+
}], viewContext: [{
|
|
2676
|
+
type: Input
|
|
2677
|
+
}], childrenComponent: [{
|
|
2678
|
+
type: ViewChildren,
|
|
2679
|
+
args: [SlateDescendant, { read: SlateDescendant }]
|
|
2680
|
+
}] } });
|
|
2919
2681
|
|
|
2920
2682
|
// not correctly clipboardData on beforeinput
|
|
2921
2683
|
const forceOnDOMPaste = IS_SAFARI;
|
|
@@ -2923,16 +2685,12 @@ class SlateEditable {
|
|
|
2923
2685
|
get hasBeforeInputSupport() {
|
|
2924
2686
|
return HAS_BEFORE_INPUT_SUPPORT;
|
|
2925
2687
|
}
|
|
2926
|
-
constructor(elementRef, renderer2, cdr, ngZone, injector
|
|
2688
|
+
constructor(elementRef, renderer2, cdr, ngZone, injector) {
|
|
2927
2689
|
this.elementRef = elementRef;
|
|
2928
2690
|
this.renderer2 = renderer2;
|
|
2929
2691
|
this.cdr = cdr;
|
|
2930
2692
|
this.ngZone = ngZone;
|
|
2931
2693
|
this.injector = injector;
|
|
2932
|
-
this.defaultElement = defaultElement;
|
|
2933
|
-
this.defaultText = defaultText;
|
|
2934
|
-
this.defaultVoidText = defaultVoidText;
|
|
2935
|
-
this.defaultLeaf = defaultLeaf;
|
|
2936
2694
|
this.destroy$ = new Subject();
|
|
2937
2695
|
this.isComposing = false;
|
|
2938
2696
|
this.isDraggingInternally = false;
|
|
@@ -2954,10 +2712,6 @@ class SlateEditable {
|
|
|
2954
2712
|
this.dataSlateEditor = true;
|
|
2955
2713
|
this.dataSlateNode = 'value';
|
|
2956
2714
|
this.dataGramm = false;
|
|
2957
|
-
this.viewContainerRef = inject(ViewContainerRef);
|
|
2958
|
-
this.getOutletParent = () => {
|
|
2959
|
-
return this.elementRef.nativeElement;
|
|
2960
|
-
};
|
|
2961
2715
|
}
|
|
2962
2716
|
ngOnInit() {
|
|
2963
2717
|
this.editor.injector = this.injector;
|
|
@@ -2983,7 +2737,6 @@ class SlateEditable {
|
|
|
2983
2737
|
// add browser class
|
|
2984
2738
|
let browserClass = IS_FIREFOX ? 'firefox' : IS_SAFARI ? 'safari' : '';
|
|
2985
2739
|
browserClass && this.elementRef.nativeElement.classList.add(browserClass);
|
|
2986
|
-
this.listRender = new ListRender(this.viewContext, this.viewContainerRef, this.getOutletParent, () => null);
|
|
2987
2740
|
}
|
|
2988
2741
|
ngOnChanges(simpleChanges) {
|
|
2989
2742
|
if (!this.initialized) {
|
|
@@ -2991,16 +2744,16 @@ class SlateEditable {
|
|
|
2991
2744
|
}
|
|
2992
2745
|
const decorateChange = simpleChanges['decorate'];
|
|
2993
2746
|
if (decorateChange) {
|
|
2994
|
-
this.
|
|
2747
|
+
this.forceFlush();
|
|
2995
2748
|
}
|
|
2996
2749
|
const placeholderChange = simpleChanges['placeholder'];
|
|
2997
2750
|
if (placeholderChange) {
|
|
2998
|
-
this.
|
|
2751
|
+
this.detectContext();
|
|
2999
2752
|
}
|
|
3000
2753
|
const readonlyChange = simpleChanges['readonly'];
|
|
3001
2754
|
if (readonlyChange) {
|
|
3002
2755
|
IS_READONLY.set(this.editor, this.readonly);
|
|
3003
|
-
this.
|
|
2756
|
+
this.detectContext();
|
|
3004
2757
|
this.toSlateSelection();
|
|
3005
2758
|
}
|
|
3006
2759
|
}
|
|
@@ -3024,12 +2777,6 @@ class SlateEditable {
|
|
|
3024
2777
|
this.editor.children = normalize(value);
|
|
3025
2778
|
}
|
|
3026
2779
|
this.initializeContext();
|
|
3027
|
-
if (!this.listRender.initialized) {
|
|
3028
|
-
this.listRender.initialize(this.editor.children, this.editor, this.context);
|
|
3029
|
-
}
|
|
3030
|
-
else {
|
|
3031
|
-
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3032
|
-
}
|
|
3033
2780
|
this.cdr.markForCheck();
|
|
3034
2781
|
}
|
|
3035
2782
|
}
|
|
@@ -3139,14 +2886,14 @@ class SlateEditable {
|
|
|
3139
2886
|
}
|
|
3140
2887
|
}
|
|
3141
2888
|
onChange() {
|
|
3142
|
-
this.
|
|
2889
|
+
this.forceFlush();
|
|
3143
2890
|
this.onChangeCallback(this.editor.children);
|
|
3144
2891
|
}
|
|
3145
2892
|
ngAfterViewChecked() { }
|
|
3146
2893
|
ngDoCheck() { }
|
|
3147
|
-
|
|
3148
|
-
this.
|
|
3149
|
-
this.
|
|
2894
|
+
forceFlush() {
|
|
2895
|
+
this.detectContext();
|
|
2896
|
+
this.cdr.detectChanges();
|
|
3150
2897
|
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
3151
2898
|
// when the DOMElement where the selection is located is removed
|
|
3152
2899
|
// the compositionupdate and compositionend events will no longer be fired
|
|
@@ -3182,29 +2929,6 @@ class SlateEditable {
|
|
|
3182
2929
|
}
|
|
3183
2930
|
this.toNativeSelection();
|
|
3184
2931
|
}
|
|
3185
|
-
render() {
|
|
3186
|
-
const changed = this.updateContext();
|
|
3187
|
-
if (changed) {
|
|
3188
|
-
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3189
|
-
}
|
|
3190
|
-
}
|
|
3191
|
-
updateContext() {
|
|
3192
|
-
const decorations = this.generateDecorations();
|
|
3193
|
-
if (this.context.selection !== this.editor.selection ||
|
|
3194
|
-
this.context.decorate !== this.decorate ||
|
|
3195
|
-
this.context.readonly !== this.readonly ||
|
|
3196
|
-
!isDecoratorRangeListEqual(this.context.decorations, decorations)) {
|
|
3197
|
-
this.context = {
|
|
3198
|
-
parent: this.editor,
|
|
3199
|
-
selection: this.editor.selection,
|
|
3200
|
-
decorations: decorations,
|
|
3201
|
-
decorate: this.decorate,
|
|
3202
|
-
readonly: this.readonly
|
|
3203
|
-
};
|
|
3204
|
-
return true;
|
|
3205
|
-
}
|
|
3206
|
-
return false;
|
|
3207
|
-
}
|
|
3208
2932
|
initializeContext() {
|
|
3209
2933
|
this.context = {
|
|
3210
2934
|
parent: this.editor,
|
|
@@ -3222,13 +2946,24 @@ class SlateEditable {
|
|
|
3222
2946
|
renderText: this.renderText,
|
|
3223
2947
|
trackBy: this.trackBy,
|
|
3224
2948
|
isStrictDecorate: this.isStrictDecorate,
|
|
3225
|
-
templateComponent: this.templateComponent
|
|
3226
|
-
defaultElement: this.defaultElement,
|
|
3227
|
-
defaultText: this.defaultText,
|
|
3228
|
-
defaultVoidText: this.defaultVoidText,
|
|
3229
|
-
defaultLeaf: this.defaultLeaf
|
|
2949
|
+
templateComponent: this.templateComponent
|
|
3230
2950
|
};
|
|
3231
2951
|
}
|
|
2952
|
+
detectContext() {
|
|
2953
|
+
const decorations = this.generateDecorations();
|
|
2954
|
+
if (this.context.selection !== this.editor.selection ||
|
|
2955
|
+
this.context.decorate !== this.decorate ||
|
|
2956
|
+
this.context.readonly !== this.readonly ||
|
|
2957
|
+
!isDecoratorRangeListEqual(this.context.decorations, decorations)) {
|
|
2958
|
+
this.context = {
|
|
2959
|
+
parent: this.editor,
|
|
2960
|
+
selection: this.editor.selection,
|
|
2961
|
+
decorations: decorations,
|
|
2962
|
+
decorate: this.decorate,
|
|
2963
|
+
readonly: this.readonly
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
3232
2967
|
composePlaceholderDecorate(editor) {
|
|
3233
2968
|
if (this.placeholderDecorate) {
|
|
3234
2969
|
return this.placeholderDecorate(editor) || [];
|
|
@@ -3520,19 +3255,6 @@ class SlateEditable {
|
|
|
3520
3255
|
const end = Editor.end(this.editor, path);
|
|
3521
3256
|
const startVoid = Editor.void(this.editor, { at: start });
|
|
3522
3257
|
const endVoid = Editor.void(this.editor, { at: end });
|
|
3523
|
-
if (event.detail === TRIPLE_CLICK && path.length >= 1) {
|
|
3524
|
-
let blockPath = path;
|
|
3525
|
-
if (!(Element.isElement(node) && Editor.isBlock(this.editor, node))) {
|
|
3526
|
-
const block = Editor.above(this.editor, {
|
|
3527
|
-
match: n => Element.isElement(n) && Editor.isBlock(this.editor, n),
|
|
3528
|
-
at: path
|
|
3529
|
-
});
|
|
3530
|
-
blockPath = block?.[1] ?? path.slice(0, 1);
|
|
3531
|
-
}
|
|
3532
|
-
const range = Editor.range(this.editor, blockPath);
|
|
3533
|
-
Transforms.select(this.editor, range);
|
|
3534
|
-
return;
|
|
3535
|
-
}
|
|
3536
3258
|
if (startVoid && endVoid && Path.equals(startVoid[1], endVoid[1])) {
|
|
3537
3259
|
const range = Editor.range(this.editor, start);
|
|
3538
3260
|
Transforms.select(this.editor, range);
|
|
@@ -3545,13 +3267,14 @@ class SlateEditable {
|
|
|
3545
3267
|
// solve the problem of cross node Chinese input
|
|
3546
3268
|
if (Range.isExpanded(selection)) {
|
|
3547
3269
|
Editor.deleteFragment(this.editor);
|
|
3548
|
-
this.
|
|
3270
|
+
this.forceFlush();
|
|
3549
3271
|
}
|
|
3550
3272
|
}
|
|
3551
3273
|
if (hasEditableTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.compositionStart)) {
|
|
3552
3274
|
this.isComposing = true;
|
|
3553
3275
|
}
|
|
3554
|
-
this.
|
|
3276
|
+
this.detectContext();
|
|
3277
|
+
this.cdr.detectChanges();
|
|
3555
3278
|
}
|
|
3556
3279
|
onDOMCompositionUpdate(event) {
|
|
3557
3280
|
this.isDOMEventHandled(event, this.compositionUpdate);
|
|
@@ -3573,7 +3296,8 @@ class SlateEditable {
|
|
|
3573
3296
|
// so we need avoid repeat isnertText by isComposing === true,
|
|
3574
3297
|
this.isComposing = false;
|
|
3575
3298
|
}
|
|
3576
|
-
this.
|
|
3299
|
+
this.detectContext();
|
|
3300
|
+
this.cdr.detectChanges();
|
|
3577
3301
|
}
|
|
3578
3302
|
onDOMCopy(event) {
|
|
3579
3303
|
const window = AngularEditor.getWindow(this.editor);
|
|
@@ -3599,7 +3323,7 @@ class SlateEditable {
|
|
|
3599
3323
|
// that drops are allowed. Editable content is droppable by
|
|
3600
3324
|
// default, and calling `preventDefault` hides the cursor.
|
|
3601
3325
|
const node = AngularEditor.toSlateNode(this.editor, event.target);
|
|
3602
|
-
if (
|
|
3326
|
+
if (Editor.isVoid(this.editor, node)) {
|
|
3603
3327
|
event.preventDefault();
|
|
3604
3328
|
}
|
|
3605
3329
|
}
|
|
@@ -3608,7 +3332,7 @@ class SlateEditable {
|
|
|
3608
3332
|
if (!this.readonly && hasTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.dragStart)) {
|
|
3609
3333
|
const node = AngularEditor.toSlateNode(this.editor, event.target);
|
|
3610
3334
|
const path = AngularEditor.findPath(this.editor, node);
|
|
3611
|
-
const voidMatch =
|
|
3335
|
+
const voidMatch = Editor.isVoid(this.editor, node) || Editor.void(this.editor, { at: path, voids: true });
|
|
3612
3336
|
// If starting a drag on a void node, make sure it is selected
|
|
3613
3337
|
// so that it shows up in the selection's fragment.
|
|
3614
3338
|
if (voidMatch) {
|
|
@@ -3946,32 +3670,16 @@ class SlateEditable {
|
|
|
3946
3670
|
this.destroy$.complete();
|
|
3947
3671
|
EDITOR_TO_ON_CHANGE.delete(this.editor);
|
|
3948
3672
|
}
|
|
3949
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
3950
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
3673
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateEditable, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3674
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateEditable, isStandalone: true, selector: "slate-editable", inputs: { editor: "editor", renderElement: "renderElement", renderLeaf: "renderLeaf", renderText: "renderText", decorate: "decorate", placeholderDecorate: "placeholderDecorate", scrollSelectionIntoView: "scrollSelectionIntoView", isStrictDecorate: "isStrictDecorate", trackBy: "trackBy", readonly: "readonly", placeholder: "placeholder", beforeInput: "beforeInput", blur: "blur", click: "click", compositionEnd: "compositionEnd", compositionUpdate: "compositionUpdate", compositionStart: "compositionStart", copy: "copy", cut: "cut", dragOver: "dragOver", dragStart: "dragStart", dragEnd: "dragEnd", drop: "drop", focus: "focus", keydown: "keydown", paste: "paste", spellCheck: "spellCheck", autoCorrect: "autoCorrect", autoCapitalize: "autoCapitalize" }, host: { properties: { "attr.contenteditable": "readonly ? undefined : true", "attr.role": "readonly ? undefined : 'textbox'", "attr.spellCheck": "!hasBeforeInputSupport ? false : spellCheck", "attr.autoCorrect": "!hasBeforeInputSupport ? 'false' : autoCorrect", "attr.autoCapitalize": "!hasBeforeInputSupport ? 'false' : autoCapitalize", "attr.data-slate-editor": "this.dataSlateEditor", "attr.data-slate-node": "this.dataSlateNode", "attr.data-gramm": "this.dataGramm" }, classAttribute: "slate-editable-container" }, providers: [
|
|
3951
3675
|
{
|
|
3952
3676
|
provide: NG_VALUE_ACCESSOR,
|
|
3953
3677
|
useExisting: forwardRef(() => SlateEditable),
|
|
3954
3678
|
multi: true
|
|
3955
|
-
},
|
|
3956
|
-
{
|
|
3957
|
-
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
3958
|
-
useValue: SlateDefaultElement
|
|
3959
|
-
},
|
|
3960
|
-
{
|
|
3961
|
-
provide: SLATE_DEFAULT_TEXT_COMPONENT_TOKEN,
|
|
3962
|
-
useValue: SlateDefaultText
|
|
3963
|
-
},
|
|
3964
|
-
{
|
|
3965
|
-
provide: SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN,
|
|
3966
|
-
useValue: SlateVoidText
|
|
3967
|
-
},
|
|
3968
|
-
{
|
|
3969
|
-
provide: SLATE_DEFAULT_LEAF_COMPONENT_TOKEN,
|
|
3970
|
-
useValue: SlateDefaultLeaf
|
|
3971
3679
|
}
|
|
3972
|
-
], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<slate-string-template #templateComponent></slate-string-template>\n", dependencies: [{ kind: "component", type: SlateStringTemplate, selector: "slate-string-template" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3680
|
+
], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"></slate-children>\n<slate-string-template #templateComponent></slate-string-template>\n", dependencies: [{ kind: "component", type: SlateChildren, selector: "slate-children", inputs: ["children", "context", "viewContext"] }, { kind: "component", type: SlateStringTemplate, selector: "slate-string-template" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3973
3681
|
}
|
|
3974
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateEditable, decorators: [{
|
|
3975
3683
|
type: Component,
|
|
3976
3684
|
args: [{ selector: 'slate-editable', host: {
|
|
3977
3685
|
class: 'slate-editable-container',
|
|
@@ -3985,37 +3693,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
3985
3693
|
provide: NG_VALUE_ACCESSOR,
|
|
3986
3694
|
useExisting: forwardRef(() => SlateEditable),
|
|
3987
3695
|
multi: true
|
|
3988
|
-
},
|
|
3989
|
-
{
|
|
3990
|
-
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
3991
|
-
useValue: SlateDefaultElement
|
|
3992
|
-
},
|
|
3993
|
-
{
|
|
3994
|
-
provide: SLATE_DEFAULT_TEXT_COMPONENT_TOKEN,
|
|
3995
|
-
useValue: SlateDefaultText
|
|
3996
|
-
},
|
|
3997
|
-
{
|
|
3998
|
-
provide: SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN,
|
|
3999
|
-
useValue: SlateVoidText
|
|
4000
|
-
},
|
|
4001
|
-
{
|
|
4002
|
-
provide: SLATE_DEFAULT_LEAF_COMPONENT_TOKEN,
|
|
4003
|
-
useValue: SlateDefaultLeaf
|
|
4004
3696
|
}
|
|
4005
|
-
], standalone: true, imports: [SlateChildren, SlateStringTemplate], template: "<slate-string-template #templateComponent></slate-string-template>\n" }]
|
|
4006
|
-
}], ctorParameters:
|
|
4007
|
-
type: Inject,
|
|
4008
|
-
args: [SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN]
|
|
4009
|
-
}] }, { type: undefined, decorators: [{
|
|
4010
|
-
type: Inject,
|
|
4011
|
-
args: [SLATE_DEFAULT_TEXT_COMPONENT_TOKEN]
|
|
4012
|
-
}] }, { type: undefined, decorators: [{
|
|
4013
|
-
type: Inject,
|
|
4014
|
-
args: [SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN]
|
|
4015
|
-
}] }, { type: undefined, decorators: [{
|
|
4016
|
-
type: Inject,
|
|
4017
|
-
args: [SLATE_DEFAULT_LEAF_COMPONENT_TOKEN]
|
|
4018
|
-
}] }]; }, propDecorators: { editor: [{
|
|
3697
|
+
], standalone: true, imports: [SlateChildren, SlateStringTemplate], template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"></slate-children>\n<slate-string-template #templateComponent></slate-string-template>\n" }]
|
|
3698
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Injector }], propDecorators: { editor: [{
|
|
4019
3699
|
type: Input
|
|
4020
3700
|
}], renderElement: [{
|
|
4021
3701
|
type: Input
|
|
@@ -4131,7 +3811,7 @@ const hasTarget = (editor, target) => {
|
|
|
4131
3811
|
*/
|
|
4132
3812
|
const isTargetInsideVoid = (editor, target) => {
|
|
4133
3813
|
const slateNode = hasTarget(editor, target) && AngularEditor.toSlateNode(editor, target);
|
|
4134
|
-
return
|
|
3814
|
+
return Editor.isVoid(editor, slateNode);
|
|
4135
3815
|
};
|
|
4136
3816
|
const hasStringTarget = (domSelection) => {
|
|
4137
3817
|
return ((domSelection.anchorNode.parentElement.hasAttribute('data-slate-string') ||
|
|
@@ -4159,14 +3839,29 @@ const preventInsertFromComposition = (event, editor) => {
|
|
|
4159
3839
|
};
|
|
4160
3840
|
|
|
4161
3841
|
class SlateElement extends BaseElementComponent {
|
|
4162
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
4163
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
3842
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateElement, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3843
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateElement, isStandalone: true, selector: "[slateElement]", usesInheritance: true, ngImport: i0, template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children><ng-content></ng-content>', isInline: true, dependencies: [{ kind: "component", type: SlateChildren, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
4164
3844
|
}
|
|
4165
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3845
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateElement, decorators: [{
|
|
4166
3846
|
type: Component,
|
|
4167
3847
|
args: [{
|
|
4168
3848
|
selector: '[slateElement]',
|
|
4169
|
-
template: '<ng-content></ng-content>',
|
|
3849
|
+
template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children><ng-content></ng-content>',
|
|
3850
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3851
|
+
standalone: true,
|
|
3852
|
+
imports: [SlateChildren]
|
|
3853
|
+
}]
|
|
3854
|
+
}] });
|
|
3855
|
+
|
|
3856
|
+
class SlateDefaultElement extends BaseElementComponent {
|
|
3857
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultElement, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3858
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: SlateDefaultElement, isStandalone: true, selector: "div[slateDefaultElement]", usesInheritance: true, ngImport: i0, template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`, isInline: true, dependencies: [{ kind: "component", type: SlateChildren, selector: "slate-children", inputs: ["children", "context", "viewContext"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3859
|
+
}
|
|
3860
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateDefaultElement, decorators: [{
|
|
3861
|
+
type: Component,
|
|
3862
|
+
args: [{
|
|
3863
|
+
selector: 'div[slateDefaultElement]',
|
|
3864
|
+
template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`,
|
|
4170
3865
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
4171
3866
|
standalone: true,
|
|
4172
3867
|
imports: [SlateChildren]
|
|
@@ -4174,8 +3869,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
4174
3869
|
}] });
|
|
4175
3870
|
|
|
4176
3871
|
class SlateModule {
|
|
4177
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
4178
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
3872
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3873
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.2.4", ngImport: i0, type: SlateModule, imports: [CommonModule,
|
|
4179
3874
|
SlateEditable,
|
|
4180
3875
|
SlateDefaultElement,
|
|
4181
3876
|
SlateElement,
|
|
@@ -4183,20 +3878,26 @@ class SlateModule {
|
|
|
4183
3878
|
SlateDefaultText,
|
|
4184
3879
|
SlateString,
|
|
4185
3880
|
SlateStringTemplate,
|
|
3881
|
+
SlateDescendant,
|
|
4186
3882
|
SlateChildren,
|
|
4187
3883
|
SlateBlockCard,
|
|
3884
|
+
SlateLeaf,
|
|
4188
3885
|
SlateLeaves,
|
|
4189
3886
|
SlateDefaultLeaf,
|
|
4190
|
-
SlateDefaultString,
|
|
4191
|
-
|
|
4192
|
-
|
|
3887
|
+
SlateDefaultString], exports: [SlateEditable,
|
|
3888
|
+
SlateChildren,
|
|
3889
|
+
SlateElement,
|
|
3890
|
+
SlateLeaves,
|
|
3891
|
+
SlateString,
|
|
3892
|
+
SlateDefaultString] }); }
|
|
3893
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateModule, providers: [
|
|
4193
3894
|
{
|
|
4194
3895
|
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
4195
3896
|
useValue: SlateDefaultElement
|
|
4196
3897
|
}
|
|
4197
3898
|
], imports: [CommonModule] }); }
|
|
4198
3899
|
}
|
|
4199
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3900
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: SlateModule, decorators: [{
|
|
4200
3901
|
type: NgModule,
|
|
4201
3902
|
args: [{
|
|
4202
3903
|
imports: [
|
|
@@ -4208,14 +3909,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
4208
3909
|
SlateDefaultText,
|
|
4209
3910
|
SlateString,
|
|
4210
3911
|
SlateStringTemplate,
|
|
3912
|
+
SlateDescendant,
|
|
4211
3913
|
SlateChildren,
|
|
4212
3914
|
SlateBlockCard,
|
|
3915
|
+
SlateLeaf,
|
|
4213
3916
|
SlateLeaves,
|
|
4214
3917
|
SlateDefaultLeaf,
|
|
4215
|
-
SlateDefaultString
|
|
4216
|
-
|
|
3918
|
+
SlateDefaultString
|
|
3919
|
+
],
|
|
3920
|
+
exports: [
|
|
3921
|
+
SlateEditable,
|
|
3922
|
+
SlateChildren,
|
|
3923
|
+
SlateElement,
|
|
3924
|
+
SlateLeaves,
|
|
3925
|
+
SlateString,
|
|
3926
|
+
SlateDefaultString
|
|
4217
3927
|
],
|
|
4218
|
-
exports: [SlateEditable, SlateChildren, SlateChildrenOutlet, SlateElement, SlateLeaves, SlateString, SlateDefaultString],
|
|
4219
3928
|
providers: [
|
|
4220
3929
|
{
|
|
4221
3930
|
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
@@ -4233,5 +3942,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
4233
3942
|
* Generated bundle index. Do not edit.
|
|
4234
3943
|
*/
|
|
4235
3944
|
|
|
4236
|
-
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,
|
|
3945
|
+
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, SlateDefaultString, SlateEditable, SlateElement, SlateErrorCode, SlateLeaves, SlateModule, SlateString, check, defaultScrollSelectionIntoView, getCardTargetAttribute, getClipboardData, getDefaultView, getEditableChild, getEditableChildAndIndex, getPlainText, getSlateFragmentAttribute, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hasEditableTarget, hasShadowRoot, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isComponentType, isDOMComment, isDOMElement, isDOMNode, isDOMSelection, isDOMText, isDecoratorRangeListEqual, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, shallowCompare, withAngular };
|
|
4237
3946
|
//# sourceMappingURL=slate-angular.mjs.map
|