slate-angular 16.1.0-next → 16.1.0-next.1
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 +1 -6
- package/components/editable/editable.component.d.ts +15 -5
- package/components/leaf/token.d.ts +4 -0
- package/components/leaves/leaves.component.d.ts +1 -14
- package/components/string/string.component.d.ts +8 -0
- package/components/text/token.d.ts +5 -0
- package/esm2022/components/children/children.component.mjs +5 -31
- package/esm2022/components/editable/editable.component.mjs +112 -35
- package/esm2022/components/element/default-element.component.mjs +3 -3
- package/esm2022/components/element/element.component.mjs +3 -3
- package/esm2022/components/leaf/token.mjs +3 -0
- package/esm2022/components/leaves/leaves.component.mjs +5 -50
- package/esm2022/components/string/string.component.mjs +16 -6
- package/esm2022/components/text/default-text.component.mjs +3 -3
- package/esm2022/components/text/token.mjs +4 -0
- package/esm2022/components/text/void-text.component.mjs +3 -3
- package/esm2022/module.mjs +1 -7
- package/esm2022/utils/throttle.mjs +18 -0
- package/esm2022/view/base.mjs +26 -9
- package/esm2022/view/container.mjs +2 -82
- package/esm2022/view/context.mjs +1 -1
- package/esm2022/view/render/leaves-render.mjs +105 -0
- package/esm2022/view/render/list-render.mjs +250 -0
- package/esm2022/view/render/utils.mjs +104 -0
- package/fesm2022/slate-angular.mjs +897 -708
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/module.d.ts +6 -8
- package/package.json +1 -1
- package/utils/throttle.d.ts +2 -0
- package/view/base.d.ts +11 -2
- package/view/container.d.ts +3 -7
- package/view/context.d.ts +8 -2
- package/view/render/leaves-render.d.ts +20 -0
- package/view/render/list-render.d.ts +31 -0
- package/view/render/utils.d.ts +11 -0
- package/components/descendant/descendant.component.d.ts +0 -35
- package/components/leaf/leaf.component.d.ts +0 -16
- package/esm2022/components/descendant/descendant.component.mjs +0 -186
- package/esm2022/components/leaf/leaf.component.mjs +0 -38
|
@@ -1,7 +1,7 @@
|
|
|
1
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, InjectionToken, ComponentRef, IterableDiffers, HostBinding, inject, ViewContainerRef, forwardRef, ElementRef, Inject, 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';
|
|
@@ -1663,6 +1663,59 @@ function restoreDom(editor, execute) {
|
|
|
1663
1663
|
}, 0);
|
|
1664
1664
|
}
|
|
1665
1665
|
|
|
1666
|
+
/**
|
|
1667
|
+
* @deprecated
|
|
1668
|
+
* the special container for angular template
|
|
1669
|
+
* Add the rootNodes of each child component to the parentElement
|
|
1670
|
+
* Remove useless DOM elements, eg: comment...
|
|
1671
|
+
*/
|
|
1672
|
+
class ViewContainer {
|
|
1673
|
+
constructor(elementRef, differs) {
|
|
1674
|
+
this.elementRef = elementRef;
|
|
1675
|
+
this.differs = differs;
|
|
1676
|
+
}
|
|
1677
|
+
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 }); }
|
|
1678
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: ViewContainer, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
1679
|
+
}
|
|
1680
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ViewContainer, decorators: [{
|
|
1681
|
+
type: Directive
|
|
1682
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.IterableDiffers }]; }, propDecorators: { viewContext: [{
|
|
1683
|
+
type: Input
|
|
1684
|
+
}] } });
|
|
1685
|
+
|
|
1686
|
+
class SlateChildren extends ViewContainer {
|
|
1687
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateChildren, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1688
|
+
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 }); }
|
|
1689
|
+
}
|
|
1690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateChildren, decorators: [{
|
|
1691
|
+
type: Component,
|
|
1692
|
+
args: [{
|
|
1693
|
+
selector: 'slate-children',
|
|
1694
|
+
template: ``,
|
|
1695
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1696
|
+
standalone: true,
|
|
1697
|
+
imports: [NgFor]
|
|
1698
|
+
}]
|
|
1699
|
+
}], propDecorators: { children: [{
|
|
1700
|
+
type: Input
|
|
1701
|
+
}], context: [{
|
|
1702
|
+
type: Input
|
|
1703
|
+
}], viewContext: [{
|
|
1704
|
+
type: Input
|
|
1705
|
+
}] } });
|
|
1706
|
+
|
|
1707
|
+
const SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN = new InjectionToken('slate-default-element-token');
|
|
1708
|
+
|
|
1709
|
+
const SLATE_DEFAULT_TEXT_COMPONENT_TOKEN = new InjectionToken('slate-default-text-token');
|
|
1710
|
+
const SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN = new InjectionToken('slate-default-void-text-token');
|
|
1711
|
+
|
|
1712
|
+
function hasBeforeContextChange(value) {
|
|
1713
|
+
if (value.beforeContextChange) {
|
|
1714
|
+
return true;
|
|
1715
|
+
}
|
|
1716
|
+
return false;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1666
1719
|
class SlateBlockCard {
|
|
1667
1720
|
get nativeElement() {
|
|
1668
1721
|
return this.elementRef.nativeElement;
|
|
@@ -1694,116 +1747,450 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
1694
1747
|
args: ['centerContianer', { static: true }]
|
|
1695
1748
|
}] } });
|
|
1696
1749
|
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1750
|
+
function createEmbeddedViewOrComponent(viewType, context, viewContext, viewContainerRef) {
|
|
1751
|
+
if (isTemplateRef(viewType)) {
|
|
1752
|
+
const embeddedViewContext = {
|
|
1753
|
+
context,
|
|
1754
|
+
viewContext
|
|
1755
|
+
};
|
|
1756
|
+
const embeddedViewRef = viewContainerRef.createEmbeddedView(viewType, embeddedViewContext);
|
|
1757
|
+
embeddedViewRef.detectChanges();
|
|
1758
|
+
return embeddedViewRef;
|
|
1705
1759
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1760
|
+
if (isComponentType(viewType)) {
|
|
1761
|
+
const componentRef = viewContainerRef.createComponent(viewType, {
|
|
1762
|
+
injector: viewContainerRef.injector
|
|
1763
|
+
});
|
|
1764
|
+
componentRef.instance.viewContext = viewContext;
|
|
1765
|
+
componentRef.instance.context = context;
|
|
1766
|
+
componentRef.changeDetectorRef.detectChanges();
|
|
1767
|
+
return componentRef;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function renderView(view) {
|
|
1771
|
+
if (view instanceof ComponentRef) {
|
|
1772
|
+
view.changeDetectorRef.detectChanges();
|
|
1773
|
+
}
|
|
1774
|
+
else {
|
|
1775
|
+
view.detectChanges();
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
function updateContext(view, newContext, viewContext) {
|
|
1779
|
+
if (view instanceof ComponentRef) {
|
|
1780
|
+
view.instance.context = newContext;
|
|
1781
|
+
}
|
|
1782
|
+
else {
|
|
1783
|
+
const embeddedViewContext = {
|
|
1784
|
+
context: newContext,
|
|
1785
|
+
viewContext
|
|
1786
|
+
};
|
|
1787
|
+
view.context = embeddedViewContext;
|
|
1788
|
+
view.detectChanges();
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
function mount(views, blockCards, outletElement) {
|
|
1792
|
+
if (views.length > 0) {
|
|
1793
|
+
const result = [];
|
|
1794
|
+
views.forEach((view, index) => {
|
|
1795
|
+
const blockCard = blockCards ? blockCards[index] : undefined;
|
|
1796
|
+
result.push(...getRootNodes(view, blockCard));
|
|
1797
|
+
});
|
|
1798
|
+
outletElement.append(...result);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
function getRootNodes(ref, blockCard) {
|
|
1802
|
+
if (blockCard) {
|
|
1803
|
+
return [blockCard.instance.nativeElement];
|
|
1804
|
+
}
|
|
1805
|
+
if (ref instanceof ComponentRef) {
|
|
1806
|
+
ref.hostView.rootNodes.forEach(ele => {
|
|
1807
|
+
if (!(ele instanceof HTMLElement)) {
|
|
1808
|
+
ele.remove();
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
return [ref.instance.nativeElement];
|
|
1812
|
+
}
|
|
1813
|
+
else {
|
|
1814
|
+
const result = [];
|
|
1815
|
+
ref.rootNodes.forEach(rootNode => {
|
|
1816
|
+
const isHTMLElement = rootNode instanceof HTMLElement;
|
|
1817
|
+
if (isHTMLElement && result.every(item => !item.contains(rootNode))) {
|
|
1818
|
+
result.push(rootNode);
|
|
1819
|
+
}
|
|
1820
|
+
if (!isHTMLElement) {
|
|
1821
|
+
rootNode.remove();
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
return result;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function mountOnItemChange(index, item, views, blockCards, outletElement, viewContext) {
|
|
1828
|
+
const view = views[index];
|
|
1829
|
+
let rootNodes = getRootNodes(view);
|
|
1830
|
+
if (blockCards) {
|
|
1831
|
+
const isBlockCard = viewContext.editor.isBlockCard(item);
|
|
1832
|
+
if (isBlockCard) {
|
|
1833
|
+
const blockCard = blockCards[index];
|
|
1834
|
+
rootNodes = [blockCard.instance.nativeElement];
|
|
1712
1835
|
}
|
|
1713
|
-
return [];
|
|
1714
1836
|
}
|
|
1715
|
-
|
|
1837
|
+
if (index === 0) {
|
|
1838
|
+
outletElement.prepend(...rootNodes);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
const previousView = views[index - 1];
|
|
1842
|
+
const blockCard = blockCards ? blockCards[index - 1] : null;
|
|
1843
|
+
const previousRootNodes = getRootNodes(previousView, blockCard);
|
|
1844
|
+
let previousRootNode = previousRootNodes[previousRootNodes.length - 1];
|
|
1845
|
+
rootNodes.forEach(rootNode => {
|
|
1846
|
+
previousRootNode.insertAdjacentElement('afterend', rootNode);
|
|
1847
|
+
previousRootNode = rootNode;
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
class ListRender {
|
|
1853
|
+
constructor(viewContext, viewContainerRef, getOutletElement) {
|
|
1854
|
+
this.viewContext = viewContext;
|
|
1716
1855
|
this.viewContainerRef = viewContainerRef;
|
|
1856
|
+
this.getOutletElement = getOutletElement;
|
|
1857
|
+
this.views = [];
|
|
1858
|
+
this.blockCards = [];
|
|
1859
|
+
this.contexts = [];
|
|
1860
|
+
this.viewTypes = [];
|
|
1717
1861
|
this.initialized = false;
|
|
1718
1862
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1863
|
+
initialize(children, parent, parentPath, childrenContext) {
|
|
1864
|
+
this.initialized = true;
|
|
1865
|
+
this.children = children;
|
|
1866
|
+
children.forEach((descendant, index) => {
|
|
1867
|
+
NODE_TO_INDEX.set(descendant, index);
|
|
1868
|
+
NODE_TO_PARENT.set(descendant, parent);
|
|
1869
|
+
const context = getContext$1(index, descendant, parentPath, childrenContext, this.viewContext);
|
|
1870
|
+
const viewType = getViewType$1(descendant, parent, this.viewContext);
|
|
1871
|
+
const view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1872
|
+
const blockCard = createBlockCard(descendant, view, this.viewContainerRef, this.viewContext);
|
|
1873
|
+
this.views.push(view);
|
|
1874
|
+
this.contexts.push(context);
|
|
1875
|
+
this.viewTypes.push(viewType);
|
|
1876
|
+
this.blockCards.push(blockCard);
|
|
1877
|
+
});
|
|
1878
|
+
mount(this.views, this.blockCards, this.getOutletElement());
|
|
1879
|
+
const newDiffers = this.viewContainerRef.injector.get(IterableDiffers);
|
|
1880
|
+
this.differ = newDiffers.find(children).create(trackBy$1(this.viewContext));
|
|
1881
|
+
this.differ.diff(children);
|
|
1882
|
+
}
|
|
1883
|
+
update(children, parent, parentPath, childrenContext) {
|
|
1884
|
+
if (!this.initialized) {
|
|
1885
|
+
this.initialize(children, parent, parentPath, childrenContext);
|
|
1886
|
+
return;
|
|
1723
1887
|
}
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1888
|
+
const outletElement = this.getOutletElement();
|
|
1889
|
+
const diffResult = this.differ.diff(children);
|
|
1890
|
+
if (diffResult) {
|
|
1891
|
+
const newContexts = [];
|
|
1892
|
+
const newViewTypes = [];
|
|
1893
|
+
const newViews = [];
|
|
1894
|
+
const newBlockCards = [];
|
|
1895
|
+
diffResult.forEachItem(record => {
|
|
1896
|
+
NODE_TO_INDEX.set(record.item, record.currentIndex);
|
|
1897
|
+
NODE_TO_PARENT.set(record.item, parent);
|
|
1898
|
+
let context = getContext$1(record.currentIndex, record.item, parentPath, childrenContext, this.viewContext);
|
|
1899
|
+
const viewType = getViewType$1(record.item, parent, this.viewContext);
|
|
1900
|
+
newViewTypes.push(viewType);
|
|
1901
|
+
let view;
|
|
1902
|
+
let blockCard;
|
|
1903
|
+
if (record.previousIndex === null) {
|
|
1904
|
+
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1905
|
+
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
1906
|
+
newContexts.push(context);
|
|
1907
|
+
newViews.push(view);
|
|
1908
|
+
newBlockCards.push(blockCard);
|
|
1909
|
+
mountOnItemChange(record.currentIndex, record.item, newViews, newBlockCards, outletElement, this.viewContext);
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1912
|
+
const previousView = this.views[record.previousIndex];
|
|
1913
|
+
const previousViewType = this.viewTypes[record.previousIndex];
|
|
1914
|
+
const previousContext = this.contexts[record.previousIndex];
|
|
1915
|
+
const previousBlockCard = this.blockCards[record.previousIndex];
|
|
1916
|
+
if (previousViewType !== viewType) {
|
|
1917
|
+
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
1918
|
+
blockCard = createBlockCard(record.item, view, this.viewContainerRef, this.viewContext);
|
|
1919
|
+
const firstRootNode = getRootNodes(previousView, previousBlockCard)[0];
|
|
1920
|
+
const newRootNodes = getRootNodes(view, blockCard);
|
|
1921
|
+
firstRootNode.replaceWith(...newRootNodes);
|
|
1922
|
+
previousView.destroy();
|
|
1923
|
+
previousBlockCard?.destroy();
|
|
1924
|
+
}
|
|
1925
|
+
else {
|
|
1926
|
+
view = previousView;
|
|
1927
|
+
blockCard = previousBlockCard;
|
|
1928
|
+
if (memoizedContext(this.viewContext, record.item, previousContext, context)) {
|
|
1929
|
+
context = previousContext;
|
|
1930
|
+
}
|
|
1931
|
+
else {
|
|
1932
|
+
updateContext(previousView, context, this.viewContext);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
newContexts.push(context);
|
|
1936
|
+
newViews.push(view);
|
|
1937
|
+
newBlockCards.push(blockCard);
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
diffResult.forEachOperation((record) => {
|
|
1941
|
+
// removed
|
|
1942
|
+
if (record.currentIndex === null) {
|
|
1943
|
+
const view = this.views[record.previousIndex];
|
|
1944
|
+
const blockCard = this.blockCards[record.previousIndex];
|
|
1945
|
+
view.destroy();
|
|
1946
|
+
blockCard?.destroy();
|
|
1947
|
+
}
|
|
1948
|
+
// moved
|
|
1949
|
+
if (record.previousIndex !== null && record.currentIndex !== null) {
|
|
1950
|
+
mountOnItemChange(record.currentIndex, record.item, newViews, newBlockCards, outletElement, this.viewContext);
|
|
1951
|
+
// Solve the block-card DOMElement loss when moving nodes
|
|
1952
|
+
newBlockCards[record.currentIndex]?.instance.append();
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1955
|
+
this.viewTypes = newViewTypes;
|
|
1956
|
+
this.views = newViews;
|
|
1957
|
+
this.contexts = newContexts;
|
|
1958
|
+
this.children = children;
|
|
1959
|
+
this.blockCards = newBlockCards;
|
|
1960
|
+
}
|
|
1961
|
+
else {
|
|
1962
|
+
const newContexts = [];
|
|
1963
|
+
this.children.forEach((child, index) => {
|
|
1964
|
+
let context = getContext$1(index, child, parentPath, childrenContext, this.viewContext);
|
|
1965
|
+
const previousContext = this.contexts[index];
|
|
1966
|
+
if (memoizedContext(this.viewContext, child, previousContext, context)) {
|
|
1967
|
+
context = previousContext;
|
|
1968
|
+
}
|
|
1969
|
+
else {
|
|
1970
|
+
updateContext(this.views[index], context, this.viewContext);
|
|
1971
|
+
}
|
|
1972
|
+
newContexts.push(context);
|
|
1973
|
+
});
|
|
1974
|
+
this.contexts = newContexts;
|
|
1727
1975
|
}
|
|
1728
1976
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1977
|
+
}
|
|
1978
|
+
function getContext$1(index, item, parentPath, childrenContext, viewContext) {
|
|
1979
|
+
if (Element.isElement(item)) {
|
|
1980
|
+
const computedContext = getCommonContext(index, item, parentPath, viewContext, childrenContext);
|
|
1981
|
+
const key = AngularEditor.findKey(viewContext.editor, item);
|
|
1982
|
+
const isInline = viewContext.editor.isInline(item);
|
|
1983
|
+
const isVoid = viewContext.editor.isVoid(item);
|
|
1984
|
+
const elementContext = {
|
|
1985
|
+
element: item,
|
|
1986
|
+
path: parentPath.concat(index),
|
|
1987
|
+
...computedContext,
|
|
1988
|
+
attributes: {
|
|
1989
|
+
'data-slate-node': 'element',
|
|
1990
|
+
'data-slate-key': key.id
|
|
1991
|
+
},
|
|
1992
|
+
decorate: childrenContext.decorate,
|
|
1993
|
+
readonly: childrenContext.readonly
|
|
1994
|
+
};
|
|
1995
|
+
if (isInline) {
|
|
1996
|
+
elementContext.attributes['data-slate-inline'] = true;
|
|
1740
1997
|
}
|
|
1741
|
-
if (
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
componentRef.instance.context = context;
|
|
1745
|
-
this.componentRef = componentRef;
|
|
1998
|
+
if (isVoid) {
|
|
1999
|
+
elementContext.attributes['data-slate-void'] = true;
|
|
2000
|
+
elementContext.attributes.contenteditable = false;
|
|
1746
2001
|
}
|
|
2002
|
+
return elementContext;
|
|
1747
2003
|
}
|
|
1748
|
-
|
|
1749
|
-
const
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
2004
|
+
else {
|
|
2005
|
+
const computedContext = getCommonContext(index, item, parentPath, viewContext, childrenContext);
|
|
2006
|
+
const isLeafBlock = AngularEditor.isLeafBlock(viewContext.editor, childrenContext.parent);
|
|
2007
|
+
const textContext = {
|
|
2008
|
+
decorations: computedContext.decorations,
|
|
2009
|
+
isLast: isLeafBlock && index === childrenContext.parent.children.length - 1,
|
|
2010
|
+
parent: childrenContext.parent,
|
|
2011
|
+
text: item
|
|
2012
|
+
};
|
|
2013
|
+
return textContext;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
function getCommonContext(index, item, parentPath, viewContext, childrenContext) {
|
|
2017
|
+
const p = parentPath.concat(index);
|
|
2018
|
+
try {
|
|
2019
|
+
const ds = childrenContext.decorate([item, p]);
|
|
2020
|
+
// [list-render] performance optimization: reduce the number of calls to the `Editor.range(viewContext.editor, p)` method
|
|
2021
|
+
if (childrenContext.selection || childrenContext.decorations.length > 0) {
|
|
2022
|
+
const range = Editor.range(viewContext.editor, p);
|
|
2023
|
+
const sel = childrenContext.selection && Range.intersection(range, childrenContext.selection);
|
|
2024
|
+
for (const dec of childrenContext.decorations) {
|
|
2025
|
+
const d = Range.intersection(dec, range);
|
|
2026
|
+
if (d) {
|
|
2027
|
+
ds.push(d);
|
|
1761
2028
|
}
|
|
1762
|
-
this.embeddedViewContext.context = context;
|
|
1763
2029
|
}
|
|
2030
|
+
return { selection: sel, decorations: ds };
|
|
1764
2031
|
}
|
|
1765
2032
|
else {
|
|
1766
|
-
|
|
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
|
-
}
|
|
2033
|
+
return { selection: null, decorations: ds };
|
|
1786
2034
|
}
|
|
1787
2035
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2036
|
+
catch (error) {
|
|
2037
|
+
this.options.viewContext.editor.onError({
|
|
2038
|
+
code: SlateErrorCode.GetStartPointError,
|
|
2039
|
+
nativeError: error
|
|
2040
|
+
});
|
|
2041
|
+
return { selection: null, decorations: [] };
|
|
1792
2042
|
}
|
|
1793
|
-
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 }); }
|
|
1794
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: ViewContainerItem, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
1795
2043
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2044
|
+
function getViewType$1(item, parent, viewContext) {
|
|
2045
|
+
if (Element.isElement(item)) {
|
|
2046
|
+
return (viewContext.renderElement && viewContext.renderElement(item)) || viewContext.defaultElement;
|
|
2047
|
+
}
|
|
2048
|
+
else {
|
|
2049
|
+
const isVoid = viewContext.editor.isVoid(parent);
|
|
2050
|
+
return isVoid ? viewContext.defaultVoidText : (viewContext.renderText && viewContext.renderText(item)) || viewContext.defaultText;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
function createBlockCard(item, view, viewContainerRef, viewContext) {
|
|
2054
|
+
const isBlockCard = viewContext.editor.isBlockCard(item);
|
|
2055
|
+
if (isBlockCard) {
|
|
2056
|
+
const rootNodes = getRootNodes(view);
|
|
2057
|
+
const blockCardComponentRef = viewContainerRef.createComponent(SlateBlockCard, {
|
|
2058
|
+
injector: viewContainerRef.injector
|
|
2059
|
+
});
|
|
2060
|
+
blockCardComponentRef.instance.initializeCenter(rootNodes);
|
|
2061
|
+
return blockCardComponentRef;
|
|
2062
|
+
}
|
|
2063
|
+
else {
|
|
2064
|
+
return null;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
function trackBy$1(viewContext) {
|
|
2068
|
+
return (index, node) => {
|
|
2069
|
+
return viewContext.trackBy(node) || AngularEditor.findKey(viewContext.editor, node);
|
|
2070
|
+
};
|
|
2071
|
+
}
|
|
2072
|
+
function memoizedContext(viewContext, descendant, prev, next) {
|
|
2073
|
+
if (Element.isElement(descendant)) {
|
|
2074
|
+
return memoizedElementContext(viewContext, prev, next);
|
|
2075
|
+
}
|
|
2076
|
+
else {
|
|
2077
|
+
return memoizedTextContext(prev, next);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
function memoizedElementContext(viewContext, prev, next) {
|
|
2081
|
+
return (prev.element === next.element &&
|
|
2082
|
+
(!viewContext.isStrictDecorate || prev.decorate === next.decorate) &&
|
|
2083
|
+
prev.readonly === next.readonly &&
|
|
2084
|
+
isDecoratorRangeListEqual(prev.decorations, next.decorations) &&
|
|
2085
|
+
(prev.selection === next.selection || (!!prev.selection && !!next.selection && Range.equals(prev.selection, next.selection))));
|
|
2086
|
+
}
|
|
2087
|
+
function memoizedTextContext(prev, next) {
|
|
2088
|
+
return (next.parent === prev.parent &&
|
|
2089
|
+
next.isLast === prev.isLast &&
|
|
2090
|
+
next.text === prev.text &&
|
|
2091
|
+
isDecoratorRangeListEqual(next.decorations, prev.decorations));
|
|
2092
|
+
}
|
|
1801
2093
|
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2094
|
+
class LeavesRender {
|
|
2095
|
+
constructor(viewContext, viewContainerRef, getOutletElement) {
|
|
2096
|
+
this.viewContext = viewContext;
|
|
2097
|
+
this.viewContainerRef = viewContainerRef;
|
|
2098
|
+
this.getOutletElement = getOutletElement;
|
|
2099
|
+
this.views = [];
|
|
2100
|
+
this.contexts = [];
|
|
2101
|
+
this.viewTypes = [];
|
|
2102
|
+
}
|
|
2103
|
+
initialize(context) {
|
|
2104
|
+
const { leaves, contexts } = this.getLeaves(context);
|
|
2105
|
+
this.leaves = leaves;
|
|
2106
|
+
this.contexts = contexts;
|
|
2107
|
+
this.leaves.forEach((leaf, index) => {
|
|
2108
|
+
const context = getContext(index, this.contexts);
|
|
2109
|
+
const viewType = getViewType(context, this.viewContext);
|
|
2110
|
+
const view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2111
|
+
this.views.push(view);
|
|
2112
|
+
this.contexts.push(context);
|
|
2113
|
+
this.viewTypes.push(viewType);
|
|
2114
|
+
});
|
|
2115
|
+
mount(this.views, null, this.getOutletElement());
|
|
2116
|
+
const newDiffers = this.viewContainerRef.injector.get(IterableDiffers);
|
|
2117
|
+
this.differ = newDiffers.find(this.leaves).create(trackBy(this.viewContext));
|
|
2118
|
+
this.differ.diff(this.leaves);
|
|
2119
|
+
}
|
|
2120
|
+
update(context) {
|
|
2121
|
+
const { leaves, contexts } = this.getLeaves(context);
|
|
2122
|
+
const outletElement = this.getOutletElement();
|
|
2123
|
+
const diffResult = this.differ.diff(leaves);
|
|
2124
|
+
if (diffResult) {
|
|
2125
|
+
const newContexts = [];
|
|
2126
|
+
const newViewTypes = [];
|
|
2127
|
+
const newViews = [];
|
|
2128
|
+
diffResult.forEachItem(record => {
|
|
2129
|
+
let context = getContext(record.currentIndex, contexts);
|
|
2130
|
+
const viewType = getViewType(context, this.viewContext);
|
|
2131
|
+
newViewTypes.push(viewType);
|
|
2132
|
+
let view;
|
|
2133
|
+
if (record.previousIndex === null) {
|
|
2134
|
+
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2135
|
+
newContexts.push(context);
|
|
2136
|
+
newViews.push(view);
|
|
2137
|
+
mountOnItemChange(record.currentIndex, record.item, newViews, null, outletElement, this.viewContext);
|
|
2138
|
+
}
|
|
2139
|
+
else {
|
|
2140
|
+
const previousView = this.views[record.previousIndex];
|
|
2141
|
+
const previousViewType = this.viewTypes[record.previousIndex];
|
|
2142
|
+
if (previousViewType !== viewType) {
|
|
2143
|
+
view = createEmbeddedViewOrComponent(viewType, context, this.viewContext, this.viewContainerRef);
|
|
2144
|
+
const firstRootNode = getRootNodes(previousView, null)[0];
|
|
2145
|
+
const newRootNodes = getRootNodes(view, null);
|
|
2146
|
+
firstRootNode.replaceWith(...newRootNodes);
|
|
2147
|
+
previousView.destroy();
|
|
2148
|
+
}
|
|
2149
|
+
else {
|
|
2150
|
+
view = previousView;
|
|
2151
|
+
updateContext(previousView, context, this.viewContext);
|
|
2152
|
+
}
|
|
2153
|
+
newContexts.push(context);
|
|
2154
|
+
newViews.push(view);
|
|
2155
|
+
}
|
|
2156
|
+
});
|
|
2157
|
+
diffResult.forEachRemovedItem(record => {
|
|
2158
|
+
const view = this.views[record.previousIndex];
|
|
2159
|
+
view.destroy();
|
|
2160
|
+
});
|
|
2161
|
+
diffResult.forEachMovedItem(record => {
|
|
2162
|
+
mountOnItemChange(record.currentIndex, record.item, newViews, null, outletElement, this.viewContext);
|
|
2163
|
+
});
|
|
2164
|
+
this.viewTypes = newViewTypes;
|
|
2165
|
+
this.views = newViews;
|
|
2166
|
+
this.contexts = newContexts;
|
|
2167
|
+
this.leaves = leaves;
|
|
2168
|
+
}
|
|
1805
2169
|
}
|
|
1806
|
-
|
|
2170
|
+
getLeaves(context) {
|
|
2171
|
+
const leaves = Text$1.decorations(context.text, context.decorations);
|
|
2172
|
+
const contexts = leaves.map((leaf, index) => {
|
|
2173
|
+
return {
|
|
2174
|
+
leaf,
|
|
2175
|
+
text: context.text,
|
|
2176
|
+
parent: context.parent,
|
|
2177
|
+
index,
|
|
2178
|
+
isLast: context.isLast && index === leaves.length - 1
|
|
2179
|
+
};
|
|
2180
|
+
});
|
|
2181
|
+
return { leaves, contexts };
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
function getContext(index, leafContexts) {
|
|
2185
|
+
return leafContexts[index];
|
|
2186
|
+
}
|
|
2187
|
+
function getViewType(leafContext, viewContext) {
|
|
2188
|
+
return (viewContext.renderLeaf && viewContext.renderLeaf(leafContext.leaf)) || viewContext.defaultLeaf;
|
|
2189
|
+
}
|
|
2190
|
+
function trackBy(viewContext) {
|
|
2191
|
+
return (index, node) => {
|
|
2192
|
+
return index;
|
|
2193
|
+
};
|
|
1807
2194
|
}
|
|
1808
2195
|
|
|
1809
2196
|
/**
|
|
@@ -1862,7 +2249,7 @@ class BaseLeafComponent extends BaseComponent {
|
|
|
1862
2249
|
if (!this.initialized) {
|
|
1863
2250
|
return;
|
|
1864
2251
|
}
|
|
1865
|
-
this.cdr.
|
|
2252
|
+
this.cdr.detectChanges();
|
|
1866
2253
|
}
|
|
1867
2254
|
renderPlaceholder() {
|
|
1868
2255
|
// issue-1: IME input was interrupted
|
|
@@ -1914,7 +2301,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
1914
2301
|
class BaseElementComponent extends BaseComponent {
|
|
1915
2302
|
constructor() {
|
|
1916
2303
|
super(...arguments);
|
|
2304
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
1917
2305
|
this.initialized = false;
|
|
2306
|
+
this.getOutletElement = () => {
|
|
2307
|
+
return this.elementRef.nativeElement;
|
|
2308
|
+
};
|
|
1918
2309
|
}
|
|
1919
2310
|
get element() {
|
|
1920
2311
|
return this._context && this._context.element;
|
|
@@ -1922,6 +2313,9 @@ class BaseElementComponent extends BaseComponent {
|
|
|
1922
2313
|
get selection() {
|
|
1923
2314
|
return this._context && this._context.selection;
|
|
1924
2315
|
}
|
|
2316
|
+
get path() {
|
|
2317
|
+
return this._context && this._context.path;
|
|
2318
|
+
}
|
|
1925
2319
|
get decorations() {
|
|
1926
2320
|
return this._context && this._context.decorations;
|
|
1927
2321
|
}
|
|
@@ -1938,11 +2332,12 @@ class BaseElementComponent extends BaseComponent {
|
|
|
1938
2332
|
return this._context && this._context.readonly;
|
|
1939
2333
|
}
|
|
1940
2334
|
ngOnInit() {
|
|
1941
|
-
this.updateWeakMap();
|
|
1942
2335
|
for (const key in this._context.attributes) {
|
|
1943
2336
|
this.nativeElement.setAttribute(key, this._context.attributes[key]);
|
|
1944
2337
|
}
|
|
1945
2338
|
this.initialized = true;
|
|
2339
|
+
this.listRender = new ListRender(this.viewContext, this.viewContainerRef, this.getOutletElement);
|
|
2340
|
+
this.listRender.initialize(this.children, this.element, this.path, this.childrenContext);
|
|
1946
2341
|
}
|
|
1947
2342
|
updateWeakMap() {
|
|
1948
2343
|
NODE_TO_ELEMENT.set(this.element, this.nativeElement);
|
|
@@ -1959,11 +2354,12 @@ class BaseElementComponent extends BaseComponent {
|
|
|
1959
2354
|
}
|
|
1960
2355
|
onContextChange() {
|
|
1961
2356
|
this.childrenContext = this.getChildrenContext();
|
|
2357
|
+
this.updateWeakMap();
|
|
1962
2358
|
if (!this.initialized) {
|
|
1963
2359
|
return;
|
|
1964
2360
|
}
|
|
1965
|
-
this.
|
|
1966
|
-
this.
|
|
2361
|
+
this.listRender.update(this.children, this.element, this.path, this.childrenContext);
|
|
2362
|
+
this.cdr.detectChanges();
|
|
1967
2363
|
}
|
|
1968
2364
|
getChildrenContext() {
|
|
1969
2365
|
return {
|
|
@@ -1987,13 +2383,18 @@ class BaseTextComponent extends BaseComponent {
|
|
|
1987
2383
|
constructor() {
|
|
1988
2384
|
super(...arguments);
|
|
1989
2385
|
this.initialized = false;
|
|
2386
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
2387
|
+
this.getOutletElement = () => {
|
|
2388
|
+
return this.elementRef.nativeElement;
|
|
2389
|
+
};
|
|
1990
2390
|
}
|
|
1991
2391
|
get text() {
|
|
1992
2392
|
return this._context && this._context.text;
|
|
1993
2393
|
}
|
|
1994
2394
|
ngOnInit() {
|
|
1995
|
-
this.updateWeakMap();
|
|
1996
2395
|
this.initialized = true;
|
|
2396
|
+
this.leavesRender = new LeavesRender(this.viewContext, this.viewContainerRef, this.getOutletElement);
|
|
2397
|
+
this.leavesRender.initialize(this.context);
|
|
1997
2398
|
}
|
|
1998
2399
|
updateWeakMap() {
|
|
1999
2400
|
ELEMENT_TO_NODE.set(this.nativeElement, this.text);
|
|
@@ -2005,11 +2406,12 @@ class BaseTextComponent extends BaseComponent {
|
|
|
2005
2406
|
}
|
|
2006
2407
|
}
|
|
2007
2408
|
onContextChange() {
|
|
2409
|
+
this.updateWeakMap();
|
|
2008
2410
|
if (!this.initialized) {
|
|
2009
2411
|
return;
|
|
2010
2412
|
}
|
|
2011
|
-
this.
|
|
2012
|
-
this.
|
|
2413
|
+
this.leavesRender.update(this.context);
|
|
2414
|
+
this.cdr.detectChanges();
|
|
2013
2415
|
}
|
|
2014
2416
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: BaseTextComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2015
2417
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: BaseTextComponent, usesInheritance: true, ngImport: i0 }); }
|
|
@@ -2018,102 +2420,193 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
2018
2420
|
type: Directive
|
|
2019
2421
|
}] });
|
|
2020
2422
|
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
*/
|
|
2026
|
-
class ViewContainer {
|
|
2027
|
-
constructor(elementRef, differs) {
|
|
2028
|
-
this.elementRef = elementRef;
|
|
2029
|
-
this.differs = differs;
|
|
2423
|
+
class SlateLeaves extends ViewContainer {
|
|
2424
|
+
constructor() {
|
|
2425
|
+
super(...arguments);
|
|
2426
|
+
this.initialized = false;
|
|
2030
2427
|
}
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
this.handleContainerItemChange(record, parentElement);
|
|
2052
|
-
});
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2428
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateLeaves, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2429
|
+
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 }); }
|
|
2430
|
+
}
|
|
2431
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateLeaves, decorators: [{
|
|
2432
|
+
type: Component,
|
|
2433
|
+
args: [{
|
|
2434
|
+
selector: 'slate-leaves',
|
|
2435
|
+
template: ``,
|
|
2436
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2437
|
+
standalone: true,
|
|
2438
|
+
imports: [NgFor]
|
|
2439
|
+
}]
|
|
2440
|
+
}], propDecorators: { context: [{
|
|
2441
|
+
type: Input
|
|
2442
|
+
}] } });
|
|
2443
|
+
|
|
2444
|
+
class SlateVoidText extends BaseTextComponent {
|
|
2445
|
+
ngOnInit() {
|
|
2446
|
+
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2447
|
+
super.ngOnInit();
|
|
2055
2448
|
}
|
|
2056
|
-
|
|
2057
|
-
if (
|
|
2058
|
-
return
|
|
2449
|
+
ngOnChanges() {
|
|
2450
|
+
if (!this.initialized) {
|
|
2451
|
+
return;
|
|
2059
2452
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2453
|
+
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2454
|
+
}
|
|
2455
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateVoidText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2456
|
+
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 }); }
|
|
2457
|
+
}
|
|
2458
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateVoidText, decorators: [{
|
|
2459
|
+
type: Component,
|
|
2460
|
+
args: [{
|
|
2461
|
+
selector: 'span[slateVoidText]',
|
|
2462
|
+
template: ``,
|
|
2463
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2464
|
+
host: {
|
|
2465
|
+
'[attr.contenteditable]': 'isLeafBlock',
|
|
2466
|
+
'data-slate-spacer': 'true',
|
|
2467
|
+
class: 'slate-spacer',
|
|
2468
|
+
'data-slate-node': 'text'
|
|
2469
|
+
},
|
|
2470
|
+
standalone: true,
|
|
2471
|
+
imports: [SlateLeaves]
|
|
2472
|
+
}]
|
|
2473
|
+
}] });
|
|
2474
|
+
|
|
2475
|
+
class SlateDefaultText extends BaseTextComponent {
|
|
2476
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2477
|
+
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 }); }
|
|
2478
|
+
}
|
|
2479
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultText, decorators: [{
|
|
2480
|
+
type: Component,
|
|
2481
|
+
args: [{
|
|
2482
|
+
selector: 'span[slateDefaultText]',
|
|
2483
|
+
template: ``,
|
|
2484
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2485
|
+
host: {
|
|
2486
|
+
'data-slate-node': 'text'
|
|
2487
|
+
},
|
|
2488
|
+
standalone: true,
|
|
2489
|
+
imports: [SlateLeaves]
|
|
2490
|
+
}]
|
|
2491
|
+
}] });
|
|
2492
|
+
|
|
2493
|
+
class SlateDefaultElement extends BaseElementComponent {
|
|
2494
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultElement, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2495
|
+
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 }); }
|
|
2496
|
+
}
|
|
2497
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultElement, decorators: [{
|
|
2498
|
+
type: Component,
|
|
2499
|
+
args: [{
|
|
2500
|
+
selector: 'div[slateDefaultElement]',
|
|
2501
|
+
template: ``,
|
|
2502
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2503
|
+
standalone: true,
|
|
2504
|
+
imports: [SlateChildren]
|
|
2505
|
+
}]
|
|
2506
|
+
}] });
|
|
2507
|
+
|
|
2508
|
+
/**
|
|
2509
|
+
* Dynamically create/update components or templates
|
|
2510
|
+
* Provide rootNodes for the view container
|
|
2511
|
+
* If the dynamically created component uses onpush mode, then it must call markForCheck when setting the context
|
|
2512
|
+
*/
|
|
2513
|
+
class ViewContainerItem {
|
|
2514
|
+
get rootNodes() {
|
|
2515
|
+
return this.getRootNodes();
|
|
2516
|
+
}
|
|
2517
|
+
getRootNodes() {
|
|
2518
|
+
if (this.embeddedViewRef) {
|
|
2519
|
+
return this.embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode));
|
|
2064
2520
|
}
|
|
2065
|
-
|
|
2066
|
-
return this.
|
|
2521
|
+
if (this.componentRef) {
|
|
2522
|
+
return [this.componentRef.instance.nativeElement];
|
|
2067
2523
|
}
|
|
2524
|
+
return [];
|
|
2068
2525
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
this.
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
if (this.
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2526
|
+
constructor(viewContainerRef) {
|
|
2527
|
+
this.viewContainerRef = viewContainerRef;
|
|
2528
|
+
this.initialized = false;
|
|
2529
|
+
}
|
|
2530
|
+
destroyView() {
|
|
2531
|
+
if (this.embeddedViewRef) {
|
|
2532
|
+
this.embeddedViewRef.destroy();
|
|
2533
|
+
this.embeddedViewRef = null;
|
|
2534
|
+
}
|
|
2535
|
+
if (this.componentRef) {
|
|
2536
|
+
this.componentRef.destroy();
|
|
2537
|
+
this.componentRef = null;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
createView() {
|
|
2541
|
+
this.initialized = true;
|
|
2542
|
+
this.viewType = this.getViewType();
|
|
2543
|
+
const context = this.getContext();
|
|
2544
|
+
if (isTemplateRef(this.viewType)) {
|
|
2545
|
+
this.embeddedViewContext = {
|
|
2546
|
+
context,
|
|
2547
|
+
viewContext: this.viewContext
|
|
2548
|
+
};
|
|
2549
|
+
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
2550
|
+
this.embeddedViewRef = embeddedViewRef;
|
|
2551
|
+
}
|
|
2552
|
+
if (isComponentType(this.viewType)) {
|
|
2553
|
+
const componentRef = this.viewContainerRef.createComponent(this.viewType);
|
|
2554
|
+
componentRef.instance.viewContext = this.viewContext;
|
|
2555
|
+
componentRef.instance.context = context;
|
|
2556
|
+
this.componentRef = componentRef;
|
|
2084
2557
|
}
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2558
|
+
}
|
|
2559
|
+
updateView() {
|
|
2560
|
+
const viewType = this.getViewType();
|
|
2561
|
+
const context = this.getContext();
|
|
2562
|
+
if (this.viewType === viewType) {
|
|
2563
|
+
if (this.componentRef) {
|
|
2564
|
+
if (this.memoizedContext(this.componentRef.instance.context, context)) {
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
this.componentRef.instance.context = context;
|
|
2568
|
+
}
|
|
2569
|
+
if (this.embeddedViewRef) {
|
|
2570
|
+
if (this.memoizedContext(this.embeddedViewContext.context, context)) {
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
this.embeddedViewContext.context = context;
|
|
2574
|
+
}
|
|
2090
2575
|
}
|
|
2091
2576
|
else {
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
if (
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
}
|
|
2577
|
+
this.viewType = viewType;
|
|
2578
|
+
const firstRootNode = this.rootNodes[0];
|
|
2579
|
+
if (isTemplateRef(this.viewType)) {
|
|
2580
|
+
this.embeddedViewContext = {
|
|
2581
|
+
context,
|
|
2582
|
+
viewContext: this.viewContext
|
|
2583
|
+
};
|
|
2584
|
+
const embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.viewType, this.embeddedViewContext);
|
|
2585
|
+
firstRootNode.replaceWith(...embeddedViewRef.rootNodes.filter(rootNode => isDOMElement(rootNode)));
|
|
2586
|
+
this.destroyView();
|
|
2587
|
+
this.embeddedViewRef = embeddedViewRef;
|
|
2099
2588
|
}
|
|
2100
|
-
|
|
2101
|
-
this.
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2589
|
+
if (isComponentType(this.viewType)) {
|
|
2590
|
+
const componentRef = this.viewContainerRef.createComponent(this.viewType);
|
|
2591
|
+
componentRef.instance.viewContext = this.viewContext;
|
|
2592
|
+
componentRef.instance.context = context;
|
|
2593
|
+
firstRootNode.replaceWith(componentRef.instance.nativeElement);
|
|
2594
|
+
this.destroyView();
|
|
2595
|
+
this.componentRef = componentRef;
|
|
2106
2596
|
}
|
|
2107
2597
|
}
|
|
2108
|
-
// Solve the block-card DOMElement loss when moving nodes
|
|
2109
|
-
record.item.appendBlockCardElement();
|
|
2110
2598
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2599
|
+
appendBlockCardElement() {
|
|
2600
|
+
if (this.blockCardComponentRef) {
|
|
2601
|
+
this.blockCardComponentRef.instance.append();
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
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 }); }
|
|
2605
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.1", type: ViewContainerItem, inputs: { viewContext: "viewContext" }, ngImport: i0 }); }
|
|
2113
2606
|
}
|
|
2114
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type:
|
|
2607
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: ViewContainerItem, decorators: [{
|
|
2115
2608
|
type: Directive
|
|
2116
|
-
}], ctorParameters: function () { return [{ type: i0.
|
|
2609
|
+
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; }, propDecorators: { viewContext: [{
|
|
2117
2610
|
type: Input
|
|
2118
2611
|
}] } });
|
|
2119
2612
|
|
|
@@ -2151,533 +2644,179 @@ class SlateDefaultString extends BaseComponent {
|
|
|
2151
2644
|
}
|
|
2152
2645
|
createLineBreakEmptyStringDOM() {
|
|
2153
2646
|
this.nativeElement.setAttribute('data-slate-zero-width', 'n');
|
|
2154
|
-
this.nativeElement.setAttribute('data-slate-length', `${this.context.elementStringLength}`);
|
|
2155
|
-
this.textNode = document.createTextNode(`\uFEFF`);
|
|
2156
|
-
this.brNode = document.createElement('br');
|
|
2157
|
-
this.nativeElement.append(this.textNode, this.brNode);
|
|
2158
|
-
}
|
|
2159
|
-
removeLineBreakEmptyStringDOM() {
|
|
2160
|
-
this.brNode?.remove();
|
|
2161
|
-
// remove zero width character
|
|
2162
|
-
const zeroWidthCharacterIndex = this.textNode?.textContent.indexOf(`\uFEFF`);
|
|
2163
|
-
this.textNode?.deleteData(zeroWidthCharacterIndex, 1);
|
|
2164
|
-
this.nativeElement.removeAttribute('data-slate-zero-width');
|
|
2165
|
-
this.nativeElement.removeAttribute('data-slate-length');
|
|
2166
|
-
}
|
|
2167
|
-
createStringDOM() {
|
|
2168
|
-
this.nativeElement.setAttribute('data-slate-string', 'true');
|
|
2169
|
-
this.updateStringDOM();
|
|
2170
|
-
}
|
|
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: "16.2.1", 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: "16.2.1", 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: "16.2.1", 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: function () { return [{ 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: "16.2.1", 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: "16.2.1", 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: "16.2.1", 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: function () { return [{ 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: "16.2.1", ngImport: i0, type: SlateDefaultLeaf, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2299
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", 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: "16.2.1", 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: "16.2.1", ngImport: i0, type: SlateLeaf, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2335
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", 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: "16.2.1", 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: "16.2.1", ngImport: i0, type: SlateLeaves, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2386
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", 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: "16.2.1", 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: "16.2.1", ngImport: i0, type: SlateDefaultText, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2414
|
-
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: `<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: "16.2.1", 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();
|
|
2647
|
+
this.nativeElement.setAttribute('data-slate-length', `${this.context.elementStringLength}`);
|
|
2648
|
+
this.textNode = document.createTextNode(`\uFEFF`);
|
|
2649
|
+
this.brNode = document.createElement('br');
|
|
2650
|
+
this.nativeElement.append(this.textNode, this.brNode);
|
|
2434
2651
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2652
|
+
removeLineBreakEmptyStringDOM() {
|
|
2653
|
+
this.brNode?.remove();
|
|
2654
|
+
// remove zero width character
|
|
2655
|
+
const zeroWidthCharacterIndex = this.textNode?.textContent.indexOf(`\uFEFF`);
|
|
2656
|
+
this.textNode?.deleteData(zeroWidthCharacterIndex, 1);
|
|
2657
|
+
this.nativeElement.removeAttribute('data-slate-zero-width');
|
|
2658
|
+
this.nativeElement.removeAttribute('data-slate-length');
|
|
2659
|
+
}
|
|
2660
|
+
createStringDOM() {
|
|
2661
|
+
this.nativeElement.setAttribute('data-slate-string', 'true');
|
|
2662
|
+
this.updateStringDOM();
|
|
2663
|
+
}
|
|
2664
|
+
updateStringDOM() {
|
|
2665
|
+
// Avoid breaking some browser default behaviors, such as spellCheck, android composition input state
|
|
2666
|
+
if (this.nativeElement.textContent !== this.context.text) {
|
|
2667
|
+
this.nativeElement.textContent = this.context.text;
|
|
2438
2668
|
}
|
|
2439
|
-
this.isLeafBlock = AngularEditor.isLeafBlock(this.viewContext.editor, this.context.parent);
|
|
2440
2669
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2670
|
+
removeStringDOM() {
|
|
2671
|
+
this.nativeElement.removeAttribute('data-slate-string');
|
|
2672
|
+
this.nativeElement.textContent = '';
|
|
2673
|
+
}
|
|
2674
|
+
ngOnInit() {
|
|
2675
|
+
this.nativeElement.setAttribute('editable-text', '');
|
|
2676
|
+
}
|
|
2677
|
+
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 }); }
|
|
2678
|
+
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 }); }
|
|
2443
2679
|
}
|
|
2444
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type:
|
|
2680
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultString, decorators: [{
|
|
2445
2681
|
type: Component,
|
|
2446
2682
|
args: [{
|
|
2447
|
-
selector: 'span[
|
|
2448
|
-
template:
|
|
2683
|
+
selector: 'span[slateDefaultString]',
|
|
2684
|
+
template: '',
|
|
2449
2685
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2450
|
-
|
|
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]
|
|
2686
|
+
standalone: true
|
|
2458
2687
|
}]
|
|
2459
|
-
}] });
|
|
2460
|
-
|
|
2461
|
-
const SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN = new InjectionToken('slate-default-element-token');
|
|
2688
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; } });
|
|
2462
2689
|
|
|
2463
|
-
class
|
|
2464
|
-
|
|
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) {
|
|
2690
|
+
class SlateString extends ViewContainerItem {
|
|
2691
|
+
constructor(elementRef, viewContainerRef) {
|
|
2474
2692
|
super(viewContainerRef);
|
|
2693
|
+
this.elementRef = elementRef;
|
|
2475
2694
|
this.viewContainerRef = viewContainerRef;
|
|
2476
|
-
this.defaultElementComponentType = defaultElementComponentType;
|
|
2477
2695
|
}
|
|
2478
2696
|
ngOnInit() {
|
|
2479
|
-
NODE_TO_INDEX.set(this.descendant, this.index);
|
|
2480
|
-
NODE_TO_PARENT.set(this.descendant, this.context.parent);
|
|
2481
2697
|
this.createView();
|
|
2482
|
-
if (this.isBlockCard) {
|
|
2483
|
-
this.createBlockCard();
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
destroyView() {
|
|
2487
|
-
super.destroyView();
|
|
2488
|
-
this.destroyBlockCard();
|
|
2489
2698
|
}
|
|
2490
2699
|
ngOnChanges() {
|
|
2491
2700
|
if (!this.initialized) {
|
|
2492
2701
|
return;
|
|
2493
2702
|
}
|
|
2494
|
-
NODE_TO_INDEX.set(this.descendant, this.index);
|
|
2495
|
-
NODE_TO_PARENT.set(this.descendant, this.context.parent);
|
|
2496
2703
|
this.updateView();
|
|
2497
|
-
if (this.isBlockCard) {
|
|
2498
|
-
this.updateBlockCard();
|
|
2499
|
-
}
|
|
2500
2704
|
}
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
this.blockCardComponentRef.destroy();
|
|
2504
|
-
this.blockCardComponentRef = null;
|
|
2505
|
-
}
|
|
2705
|
+
ngAfterViewInit() {
|
|
2706
|
+
this.elementRef.nativeElement.remove();
|
|
2506
2707
|
}
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2708
|
+
// COMPAT: If this is the last text node in an empty block, render a zero-
|
|
2709
|
+
// width space that will convert into a line break when copying and pasting
|
|
2710
|
+
// to support expected plain text.
|
|
2711
|
+
isLineBreakEmptyString() {
|
|
2712
|
+
return (this.context.leaf.text === '' &&
|
|
2713
|
+
this.context.parent.children[this.context.parent.children.length - 1] === this.context.text &&
|
|
2714
|
+
!this.viewContext.editor.isInline(this.context.parent) &&
|
|
2715
|
+
// [list-render] performance optimization: reduce the number of calls to the `Editor.string(editor, path)` method
|
|
2716
|
+
isEmpty(this.viewContext.editor, this.context.parent));
|
|
2511
2717
|
}
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
this.createBlockCard();
|
|
2518
|
-
const firstRootNode = rootNodes[0];
|
|
2519
|
-
firstRootNode.replaceWith(this.blockCardComponentRef.instance.nativeElement);
|
|
2718
|
+
// COMPAT: If the text is empty, it's because it's on the edge of an inline
|
|
2719
|
+
// node, so we render a zero-width space so that the selection can be
|
|
2720
|
+
// inserted next to it still.
|
|
2721
|
+
isEmptyText() {
|
|
2722
|
+
return this.context.leaf.text === '';
|
|
2520
2723
|
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
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 };
|
|
2535
|
-
}
|
|
2536
|
-
catch (error) {
|
|
2537
|
-
this.viewContext.editor.onError({
|
|
2538
|
-
code: SlateErrorCode.GetStartPointError,
|
|
2539
|
-
nativeError: error
|
|
2540
|
-
});
|
|
2541
|
-
return { selection: null, decorations: [] };
|
|
2542
|
-
}
|
|
2724
|
+
// COMPAT: Browsers will collapse trailing new lines at the end of blocks,
|
|
2725
|
+
// so we need to add an extra trailing new lines to prevent that.
|
|
2726
|
+
isCompatibleString() {
|
|
2727
|
+
return this.context.isLast && this.context.leaf.text.slice(-1) === '\n';
|
|
2543
2728
|
}
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
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;
|
|
2568
|
-
}
|
|
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;
|
|
2579
|
-
}
|
|
2729
|
+
// COMPAT: Render text inside void nodes with a zero-width space.
|
|
2730
|
+
// So the node can contain selection but the text is not visible.
|
|
2731
|
+
isVoid() {
|
|
2732
|
+
return this.viewContext.editor.isVoid(this.context.parent);
|
|
2580
2733
|
}
|
|
2581
2734
|
getViewType() {
|
|
2582
|
-
if (
|
|
2583
|
-
return
|
|
2735
|
+
if (this.isVoid()) {
|
|
2736
|
+
return this.viewContext.templateComponent.voidStringTemplate;
|
|
2584
2737
|
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2738
|
+
if (this.isLineBreakEmptyString()) {
|
|
2739
|
+
return SlateDefaultString;
|
|
2740
|
+
}
|
|
2741
|
+
if (this.isEmptyText()) {
|
|
2742
|
+
return this.viewContext.templateComponent.emptyTextTemplate;
|
|
2743
|
+
}
|
|
2744
|
+
if (this.isCompatibleString()) {
|
|
2745
|
+
return this.viewContext.templateComponent.compatibleStringTemplate;
|
|
2590
2746
|
}
|
|
2747
|
+
return SlateDefaultString;
|
|
2591
2748
|
}
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
(prev.selection === next.selection || (!!prev.selection && !!next.selection && Range.equals(prev.selection, next.selection))));
|
|
2749
|
+
getType() {
|
|
2750
|
+
if (this.isLineBreakEmptyString()) {
|
|
2751
|
+
return 'lineBreakEmptyString';
|
|
2752
|
+
}
|
|
2753
|
+
return 'string';
|
|
2598
2754
|
}
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2755
|
+
getContext() {
|
|
2756
|
+
const stringType = this.getType();
|
|
2757
|
+
return {
|
|
2758
|
+
text: this.context.leaf.text,
|
|
2759
|
+
elementStringLength: Node.string(this.context.parent).length,
|
|
2760
|
+
type: stringType
|
|
2761
|
+
};
|
|
2604
2762
|
}
|
|
2605
2763
|
memoizedContext(prev, next) {
|
|
2606
|
-
|
|
2607
|
-
return this.memoizedElementContext(prev, next);
|
|
2608
|
-
}
|
|
2609
|
-
else {
|
|
2610
|
-
return this.memoizedTextContext(prev, next);
|
|
2611
|
-
}
|
|
2764
|
+
return false;
|
|
2612
2765
|
}
|
|
2613
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type:
|
|
2614
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type:
|
|
2766
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateString, deps: [{ token: i0.ElementRef }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2767
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateString, isStandalone: true, selector: "span[slateString]", inputs: { context: "context" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
2615
2768
|
}
|
|
2616
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type:
|
|
2769
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateString, decorators: [{
|
|
2617
2770
|
type: Component,
|
|
2618
2771
|
args: [{
|
|
2619
|
-
selector: '
|
|
2772
|
+
selector: 'span[slateString]',
|
|
2620
2773
|
template: '',
|
|
2621
2774
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2622
2775
|
standalone: true
|
|
2623
2776
|
}]
|
|
2624
|
-
}], ctorParameters: function () { return [{ type: i0.
|
|
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: [{
|
|
2777
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ViewContainerRef }]; }, propDecorators: { context: [{
|
|
2634
2778
|
type: Input
|
|
2635
2779
|
}] } });
|
|
2780
|
+
/**
|
|
2781
|
+
* TODO: remove when bump slate
|
|
2782
|
+
* copy from slate
|
|
2783
|
+
* @param editor
|
|
2784
|
+
* @param element
|
|
2785
|
+
* @returns
|
|
2786
|
+
*/
|
|
2787
|
+
const isEmpty = (editor, element) => {
|
|
2788
|
+
const { children } = element;
|
|
2789
|
+
const [first] = children;
|
|
2790
|
+
return children.length === 0 || (children.length === 1 && Text$1.isText(first) && first.text === '' && !editor.isVoid(element));
|
|
2791
|
+
};
|
|
2636
2792
|
|
|
2637
|
-
class
|
|
2638
|
-
|
|
2639
|
-
super(
|
|
2640
|
-
this.
|
|
2641
|
-
return this.viewContext.trackBy(node) || AngularEditor.findKey(this.viewContext.editor, node);
|
|
2642
|
-
};
|
|
2793
|
+
class SlateDefaultLeaf extends BaseLeafComponent {
|
|
2794
|
+
onContextChange() {
|
|
2795
|
+
super.onContextChange();
|
|
2796
|
+
this.renderPlaceholder();
|
|
2643
2797
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
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 }); }
|
|
2798
|
+
ngOnDestroy() {
|
|
2799
|
+
// Because the placeholder span is not in the current component, it is destroyed along with the current component
|
|
2800
|
+
this.destroyPlaceholder();
|
|
2801
|
+
}
|
|
2802
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultLeaf, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
2803
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", 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 }); }
|
|
2654
2804
|
}
|
|
2655
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type:
|
|
2805
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateDefaultLeaf, decorators: [{
|
|
2656
2806
|
type: Component,
|
|
2657
2807
|
args: [{
|
|
2658
|
-
selector: '
|
|
2659
|
-
template: `<
|
|
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>`,
|
|
2808
|
+
selector: 'span[slateDefaultLeaf]',
|
|
2809
|
+
template: `<span slateString [context]="context" [viewContext]="viewContext"><span></span></span>`,
|
|
2667
2810
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2811
|
+
host: {
|
|
2812
|
+
'data-slate-leaf': 'true'
|
|
2813
|
+
},
|
|
2668
2814
|
standalone: true,
|
|
2669
|
-
imports: [
|
|
2815
|
+
imports: [SlateString]
|
|
2670
2816
|
}]
|
|
2671
|
-
}]
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
type: Input
|
|
2675
|
-
}], viewContext: [{
|
|
2676
|
-
type: Input
|
|
2677
|
-
}], childrenComponent: [{
|
|
2678
|
-
type: ViewChildren,
|
|
2679
|
-
args: [SlateDescendant, { read: SlateDescendant }]
|
|
2680
|
-
}] } });
|
|
2817
|
+
}] });
|
|
2818
|
+
|
|
2819
|
+
const SLATE_DEFAULT_LEAF_COMPONENT_TOKEN = new InjectionToken('slate-default-leaf-token');
|
|
2681
2820
|
|
|
2682
2821
|
// not correctly clipboardData on beforeinput
|
|
2683
2822
|
const forceOnDOMPaste = IS_SAFARI;
|
|
@@ -2685,12 +2824,16 @@ class SlateEditable {
|
|
|
2685
2824
|
get hasBeforeInputSupport() {
|
|
2686
2825
|
return HAS_BEFORE_INPUT_SUPPORT;
|
|
2687
2826
|
}
|
|
2688
|
-
constructor(elementRef, renderer2, cdr, ngZone, injector) {
|
|
2827
|
+
constructor(elementRef, renderer2, cdr, ngZone, injector, defaultElement, defaultText, defaultVoidText, defaultLeaf) {
|
|
2689
2828
|
this.elementRef = elementRef;
|
|
2690
2829
|
this.renderer2 = renderer2;
|
|
2691
2830
|
this.cdr = cdr;
|
|
2692
2831
|
this.ngZone = ngZone;
|
|
2693
2832
|
this.injector = injector;
|
|
2833
|
+
this.defaultElement = defaultElement;
|
|
2834
|
+
this.defaultText = defaultText;
|
|
2835
|
+
this.defaultVoidText = defaultVoidText;
|
|
2836
|
+
this.defaultLeaf = defaultLeaf;
|
|
2694
2837
|
this.destroy$ = new Subject();
|
|
2695
2838
|
this.isComposing = false;
|
|
2696
2839
|
this.isDraggingInternally = false;
|
|
@@ -2712,6 +2855,10 @@ class SlateEditable {
|
|
|
2712
2855
|
this.dataSlateEditor = true;
|
|
2713
2856
|
this.dataSlateNode = 'value';
|
|
2714
2857
|
this.dataGramm = false;
|
|
2858
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
2859
|
+
this.getOutletElement = () => {
|
|
2860
|
+
return this.elementRef.nativeElement;
|
|
2861
|
+
};
|
|
2715
2862
|
}
|
|
2716
2863
|
ngOnInit() {
|
|
2717
2864
|
this.editor.injector = this.injector;
|
|
@@ -2737,6 +2884,7 @@ class SlateEditable {
|
|
|
2737
2884
|
// add browser class
|
|
2738
2885
|
let browserClass = IS_FIREFOX ? 'firefox' : IS_SAFARI ? 'safari' : '';
|
|
2739
2886
|
browserClass && this.elementRef.nativeElement.classList.add(browserClass);
|
|
2887
|
+
this.listRender = new ListRender(this.viewContext, this.viewContainerRef, this.getOutletElement);
|
|
2740
2888
|
}
|
|
2741
2889
|
ngOnChanges(simpleChanges) {
|
|
2742
2890
|
if (!this.initialized) {
|
|
@@ -2744,16 +2892,16 @@ class SlateEditable {
|
|
|
2744
2892
|
}
|
|
2745
2893
|
const decorateChange = simpleChanges['decorate'];
|
|
2746
2894
|
if (decorateChange) {
|
|
2747
|
-
this.
|
|
2895
|
+
this.forceRender();
|
|
2748
2896
|
}
|
|
2749
2897
|
const placeholderChange = simpleChanges['placeholder'];
|
|
2750
2898
|
if (placeholderChange) {
|
|
2751
|
-
this.
|
|
2899
|
+
this.render();
|
|
2752
2900
|
}
|
|
2753
2901
|
const readonlyChange = simpleChanges['readonly'];
|
|
2754
2902
|
if (readonlyChange) {
|
|
2755
2903
|
IS_READONLY.set(this.editor, this.readonly);
|
|
2756
|
-
this.
|
|
2904
|
+
this.render();
|
|
2757
2905
|
this.toSlateSelection();
|
|
2758
2906
|
}
|
|
2759
2907
|
}
|
|
@@ -2777,6 +2925,12 @@ class SlateEditable {
|
|
|
2777
2925
|
this.editor.children = normalize(value);
|
|
2778
2926
|
}
|
|
2779
2927
|
this.initializeContext();
|
|
2928
|
+
if (!this.listRender.initialized) {
|
|
2929
|
+
this.listRender.initialize(this.editor.children, this.editor, [], this.context);
|
|
2930
|
+
}
|
|
2931
|
+
else {
|
|
2932
|
+
this.listRender.update(this.editor.children, this.editor, [], this.context);
|
|
2933
|
+
}
|
|
2780
2934
|
this.cdr.markForCheck();
|
|
2781
2935
|
}
|
|
2782
2936
|
}
|
|
@@ -2886,14 +3040,14 @@ class SlateEditable {
|
|
|
2886
3040
|
}
|
|
2887
3041
|
}
|
|
2888
3042
|
onChange() {
|
|
2889
|
-
this.
|
|
3043
|
+
this.forceRender();
|
|
2890
3044
|
this.onChangeCallback(this.editor.children);
|
|
2891
3045
|
}
|
|
2892
3046
|
ngAfterViewChecked() { }
|
|
2893
3047
|
ngDoCheck() { }
|
|
2894
|
-
|
|
2895
|
-
this.
|
|
2896
|
-
this.
|
|
3048
|
+
forceRender() {
|
|
3049
|
+
this.updateContext();
|
|
3050
|
+
this.listRender.update(this.editor.children, this.editor, [], this.context);
|
|
2897
3051
|
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
2898
3052
|
// when the DOMElement where the selection is located is removed
|
|
2899
3053
|
// the compositionupdate and compositionend events will no longer be fired
|
|
@@ -2929,6 +3083,29 @@ class SlateEditable {
|
|
|
2929
3083
|
}
|
|
2930
3084
|
this.toNativeSelection();
|
|
2931
3085
|
}
|
|
3086
|
+
render() {
|
|
3087
|
+
const changed = this.updateContext();
|
|
3088
|
+
if (changed) {
|
|
3089
|
+
this.listRender.update(this.editor.children, this.editor, [], this.context);
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
updateContext() {
|
|
3093
|
+
const decorations = this.generateDecorations();
|
|
3094
|
+
if (this.context.selection !== this.editor.selection ||
|
|
3095
|
+
this.context.decorate !== this.decorate ||
|
|
3096
|
+
this.context.readonly !== this.readonly ||
|
|
3097
|
+
!isDecoratorRangeListEqual(this.context.decorations, decorations)) {
|
|
3098
|
+
this.context = {
|
|
3099
|
+
parent: this.editor,
|
|
3100
|
+
selection: this.editor.selection,
|
|
3101
|
+
decorations: decorations,
|
|
3102
|
+
decorate: this.decorate,
|
|
3103
|
+
readonly: this.readonly
|
|
3104
|
+
};
|
|
3105
|
+
return true;
|
|
3106
|
+
}
|
|
3107
|
+
return false;
|
|
3108
|
+
}
|
|
2932
3109
|
initializeContext() {
|
|
2933
3110
|
this.context = {
|
|
2934
3111
|
parent: this.editor,
|
|
@@ -2946,24 +3123,13 @@ class SlateEditable {
|
|
|
2946
3123
|
renderText: this.renderText,
|
|
2947
3124
|
trackBy: this.trackBy,
|
|
2948
3125
|
isStrictDecorate: this.isStrictDecorate,
|
|
2949
|
-
templateComponent: this.templateComponent
|
|
3126
|
+
templateComponent: this.templateComponent,
|
|
3127
|
+
defaultElement: this.defaultElement,
|
|
3128
|
+
defaultText: this.defaultText,
|
|
3129
|
+
defaultVoidText: this.defaultVoidText,
|
|
3130
|
+
defaultLeaf: this.defaultLeaf
|
|
2950
3131
|
};
|
|
2951
3132
|
}
|
|
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
|
-
}
|
|
2967
3133
|
composePlaceholderDecorate(editor) {
|
|
2968
3134
|
if (this.placeholderDecorate) {
|
|
2969
3135
|
return this.placeholderDecorate(editor) || [];
|
|
@@ -3267,14 +3433,13 @@ class SlateEditable {
|
|
|
3267
3433
|
// solve the problem of cross node Chinese input
|
|
3268
3434
|
if (Range.isExpanded(selection)) {
|
|
3269
3435
|
Editor.deleteFragment(this.editor);
|
|
3270
|
-
this.
|
|
3436
|
+
this.forceRender();
|
|
3271
3437
|
}
|
|
3272
3438
|
}
|
|
3273
3439
|
if (hasEditableTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.compositionStart)) {
|
|
3274
3440
|
this.isComposing = true;
|
|
3275
3441
|
}
|
|
3276
|
-
this.
|
|
3277
|
-
this.cdr.detectChanges();
|
|
3442
|
+
this.render();
|
|
3278
3443
|
}
|
|
3279
3444
|
onDOMCompositionUpdate(event) {
|
|
3280
3445
|
this.isDOMEventHandled(event, this.compositionUpdate);
|
|
@@ -3296,8 +3461,7 @@ class SlateEditable {
|
|
|
3296
3461
|
// so we need avoid repeat isnertText by isComposing === true,
|
|
3297
3462
|
this.isComposing = false;
|
|
3298
3463
|
}
|
|
3299
|
-
this.
|
|
3300
|
-
this.cdr.detectChanges();
|
|
3464
|
+
this.render();
|
|
3301
3465
|
}
|
|
3302
3466
|
onDOMCopy(event) {
|
|
3303
3467
|
const window = AngularEditor.getWindow(this.editor);
|
|
@@ -3670,14 +3834,30 @@ class SlateEditable {
|
|
|
3670
3834
|
this.destroy$.complete();
|
|
3671
3835
|
EDITOR_TO_ON_CHANGE.delete(this.editor);
|
|
3672
3836
|
}
|
|
3673
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateEditable, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3837
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateEditable, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Injector }, { token: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN }, { token: SLATE_DEFAULT_TEXT_COMPONENT_TOKEN }, { token: SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN }, { token: SLATE_DEFAULT_LEAF_COMPONENT_TOKEN }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3674
3838
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", 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: [
|
|
3675
3839
|
{
|
|
3676
3840
|
provide: NG_VALUE_ACCESSOR,
|
|
3677
3841
|
useExisting: forwardRef(() => SlateEditable),
|
|
3678
3842
|
multi: true
|
|
3843
|
+
},
|
|
3844
|
+
{
|
|
3845
|
+
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
3846
|
+
useValue: SlateDefaultElement
|
|
3847
|
+
},
|
|
3848
|
+
{
|
|
3849
|
+
provide: SLATE_DEFAULT_TEXT_COMPONENT_TOKEN,
|
|
3850
|
+
useValue: SlateDefaultText
|
|
3851
|
+
},
|
|
3852
|
+
{
|
|
3853
|
+
provide: SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN,
|
|
3854
|
+
useValue: SlateVoidText
|
|
3855
|
+
},
|
|
3856
|
+
{
|
|
3857
|
+
provide: SLATE_DEFAULT_LEAF_COMPONENT_TOKEN,
|
|
3858
|
+
useValue: SlateDefaultLeaf
|
|
3679
3859
|
}
|
|
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-
|
|
3860
|
+
], 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 }); }
|
|
3681
3861
|
}
|
|
3682
3862
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateEditable, decorators: [{
|
|
3683
3863
|
type: Component,
|
|
@@ -3693,9 +3873,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
3693
3873
|
provide: NG_VALUE_ACCESSOR,
|
|
3694
3874
|
useExisting: forwardRef(() => SlateEditable),
|
|
3695
3875
|
multi: true
|
|
3876
|
+
},
|
|
3877
|
+
{
|
|
3878
|
+
provide: SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN,
|
|
3879
|
+
useValue: SlateDefaultElement
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
provide: SLATE_DEFAULT_TEXT_COMPONENT_TOKEN,
|
|
3883
|
+
useValue: SlateDefaultText
|
|
3884
|
+
},
|
|
3885
|
+
{
|
|
3886
|
+
provide: SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN,
|
|
3887
|
+
useValue: SlateVoidText
|
|
3888
|
+
},
|
|
3889
|
+
{
|
|
3890
|
+
provide: SLATE_DEFAULT_LEAF_COMPONENT_TOKEN,
|
|
3891
|
+
useValue: SlateDefaultLeaf
|
|
3696
3892
|
}
|
|
3697
|
-
], standalone: true, imports: [SlateChildren, SlateStringTemplate], template: "<slate-
|
|
3698
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Injector }
|
|
3893
|
+
], standalone: true, imports: [SlateChildren, SlateStringTemplate], template: "<slate-string-template #templateComponent></slate-string-template>\n" }]
|
|
3894
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Injector }, { type: undefined, decorators: [{
|
|
3895
|
+
type: Inject,
|
|
3896
|
+
args: [SLATE_DEFAULT_ELEMENT_COMPONENT_TOKEN]
|
|
3897
|
+
}] }, { type: undefined, decorators: [{
|
|
3898
|
+
type: Inject,
|
|
3899
|
+
args: [SLATE_DEFAULT_TEXT_COMPONENT_TOKEN]
|
|
3900
|
+
}] }, { type: undefined, decorators: [{
|
|
3901
|
+
type: Inject,
|
|
3902
|
+
args: [SLATE_DEFAULT_VOID_TEXT_COMPONENT_TOKEN]
|
|
3903
|
+
}] }, { type: undefined, decorators: [{
|
|
3904
|
+
type: Inject,
|
|
3905
|
+
args: [SLATE_DEFAULT_LEAF_COMPONENT_TOKEN]
|
|
3906
|
+
}] }]; }, propDecorators: { editor: [{
|
|
3699
3907
|
type: Input
|
|
3700
3908
|
}], renderElement: [{
|
|
3701
3909
|
type: Input
|
|
@@ -3840,28 +4048,13 @@ const preventInsertFromComposition = (event, editor) => {
|
|
|
3840
4048
|
|
|
3841
4049
|
class SlateElement extends BaseElementComponent {
|
|
3842
4050
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateElement, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3843
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateElement, isStandalone: true, selector: "[slateElement]", usesInheritance: true, ngImport: i0, template: '<
|
|
4051
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.1", type: SlateElement, isStandalone: true, selector: "[slateElement]", usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3844
4052
|
}
|
|
3845
4053
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImport: i0, type: SlateElement, decorators: [{
|
|
3846
4054
|
type: Component,
|
|
3847
4055
|
args: [{
|
|
3848
4056
|
selector: '[slateElement]',
|
|
3849
|
-
template: '<
|
|
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: "16.2.1", ngImport: i0, type: SlateDefaultElement, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
3858
|
-
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: `<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: "16.2.1", 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>`,
|
|
4057
|
+
template: '<ng-content></ng-content>',
|
|
3865
4058
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3866
4059
|
standalone: true,
|
|
3867
4060
|
imports: [SlateChildren]
|
|
@@ -3878,10 +4071,8 @@ class SlateModule {
|
|
|
3878
4071
|
SlateDefaultText,
|
|
3879
4072
|
SlateString,
|
|
3880
4073
|
SlateStringTemplate,
|
|
3881
|
-
SlateDescendant,
|
|
3882
4074
|
SlateChildren,
|
|
3883
4075
|
SlateBlockCard,
|
|
3884
|
-
SlateLeaf,
|
|
3885
4076
|
SlateLeaves,
|
|
3886
4077
|
SlateDefaultLeaf,
|
|
3887
4078
|
SlateDefaultString], exports: [SlateEditable,
|
|
@@ -3909,10 +4100,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
3909
4100
|
SlateDefaultText,
|
|
3910
4101
|
SlateString,
|
|
3911
4102
|
SlateStringTemplate,
|
|
3912
|
-
SlateDescendant,
|
|
3913
4103
|
SlateChildren,
|
|
3914
4104
|
SlateBlockCard,
|
|
3915
|
-
SlateLeaf,
|
|
3916
4105
|
SlateLeaves,
|
|
3917
4106
|
SlateDefaultLeaf,
|
|
3918
4107
|
SlateDefaultString
|
|
@@ -3942,5 +4131,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.1", ngImpor
|
|
|
3942
4131
|
* Generated bundle index. Do not edit.
|
|
3943
4132
|
*/
|
|
3944
4133
|
|
|
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 };
|
|
4134
|
+
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, isEmpty, isPlainTextOnlyPaste, isTemplateRef, isValid, normalize, normalizeDOMPoint, shallowCompare, withAngular };
|
|
3946
4135
|
//# sourceMappingURL=slate-angular.mjs.map
|