slate-angular 1.6.2 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/slate-angular.umd.js +128 -168
- package/bundles/slate-angular.umd.js.map +1 -1
- package/components/editable/editable.component.d.ts +6 -2
- package/esm2015/components/editable/editable.component.js +84 -36
- package/esm2015/components/leaf/default-leaf.component.js +12 -3
- package/esm2015/plugins/with-angular.js +2 -98
- package/esm2015/types/feature.js +2 -0
- package/esm2015/types/index.js +2 -1
- package/esm2015/view/container.js +39 -33
- package/fesm2015/slate-angular.js +130 -164
- package/fesm2015/slate-angular.js.map +1 -1
- package/package.json +2 -3
- package/styles/index.scss +10 -0
- package/types/feature.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/view/container.d.ts +2 -1
|
@@ -5,7 +5,6 @@ import { TemplateRef, Component, ViewChild, Directive, Input, HostBinding, Chang
|
|
|
5
5
|
import { __rest } from 'tslib';
|
|
6
6
|
import getDirection from 'direction';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
8
|
-
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
9
8
|
import Debug from 'debug';
|
|
10
9
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
11
10
|
import { HistoryEditor } from 'slate-history';
|
|
@@ -1183,102 +1182,6 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1183
1182
|
}
|
|
1184
1183
|
}
|
|
1185
1184
|
};
|
|
1186
|
-
// override slate layer logic
|
|
1187
|
-
e.normalizeNode = (entry) => {
|
|
1188
|
-
const [node, path] = entry;
|
|
1189
|
-
// There are no core normalizations for text nodes.
|
|
1190
|
-
if (Text$1.isText(node)) {
|
|
1191
|
-
return;
|
|
1192
|
-
}
|
|
1193
|
-
// Ensure that block and inline nodes have at least one text child.
|
|
1194
|
-
if (Element.isElement(node) && node.children.length === 0) {
|
|
1195
|
-
const child = { text: '' };
|
|
1196
|
-
Transforms.insertNodes(editor, child, {
|
|
1197
|
-
at: path.concat(0),
|
|
1198
|
-
voids: true,
|
|
1199
|
-
});
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
// Determine whether the node should have block or inline children.
|
|
1203
|
-
const shouldHaveInlines = Editor.isEditor(node)
|
|
1204
|
-
? false
|
|
1205
|
-
: Element.isElement(node) &&
|
|
1206
|
-
(editor.isInline(node) ||
|
|
1207
|
-
node.children.length === 0 ||
|
|
1208
|
-
Text$1.isText(node.children[0]) ||
|
|
1209
|
-
editor.isInline(node.children[0]));
|
|
1210
|
-
// Since we'll be applying operations while iterating, keep track of an
|
|
1211
|
-
// index that accounts for any added/removed nodes.
|
|
1212
|
-
let n = 0;
|
|
1213
|
-
for (let i = 0; i < node.children.length; i++, n++) {
|
|
1214
|
-
const child = node.children[i];
|
|
1215
|
-
const prev = node.children[i - 1];
|
|
1216
|
-
const isLast = i === node.children.length - 1;
|
|
1217
|
-
const isInlineOrText = Text$1.isText(child) ||
|
|
1218
|
-
(Element.isElement(child) && editor.isInline(child));
|
|
1219
|
-
// Only allow block nodes in the top-level children and parent blocks
|
|
1220
|
-
// that only contain block nodes. Similarly, only allow inline nodes in
|
|
1221
|
-
// other inline nodes, or parent blocks that only contain inlines and
|
|
1222
|
-
// text.
|
|
1223
|
-
if (isInlineOrText !== shouldHaveInlines) {
|
|
1224
|
-
Transforms.removeNodes(editor, { at: path.concat(n), voids: true });
|
|
1225
|
-
n--;
|
|
1226
|
-
}
|
|
1227
|
-
else if (Element.isElement(child)) {
|
|
1228
|
-
// Ensure that inline nodes are surrounded by text nodes.
|
|
1229
|
-
if (editor.isInline(child)) {
|
|
1230
|
-
if (prev == null || !Text$1.isText(prev)) {
|
|
1231
|
-
const newChild = { text: '' };
|
|
1232
|
-
Transforms.insertNodes(editor, newChild, {
|
|
1233
|
-
at: path.concat(n),
|
|
1234
|
-
voids: true,
|
|
1235
|
-
});
|
|
1236
|
-
n++;
|
|
1237
|
-
}
|
|
1238
|
-
else if (isLast) {
|
|
1239
|
-
const newChild = { text: '' };
|
|
1240
|
-
Transforms.insertNodes(editor, newChild, {
|
|
1241
|
-
at: path.concat(n + 1),
|
|
1242
|
-
voids: true,
|
|
1243
|
-
});
|
|
1244
|
-
n++;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
else {
|
|
1249
|
-
// Merge adjacent text nodes that are empty or match.
|
|
1250
|
-
if (prev != null && Text$1.isText(prev)) {
|
|
1251
|
-
// adjust logic: first remove empty text to avoid merge empty text #WIK-3805
|
|
1252
|
-
if (prev.text === '') {
|
|
1253
|
-
// adjust logic: adjust cursor location when empty text is first child of node #WIK-3631
|
|
1254
|
-
// ensure current selection in the text #WIK-3762
|
|
1255
|
-
const prevFocused = editor.selection &&
|
|
1256
|
-
Range.isCollapsed(editor.selection) &&
|
|
1257
|
-
Path.equals(editor.selection.anchor.path, path.concat(n - 1));
|
|
1258
|
-
if (prev === node.children[0] && prevFocused) {
|
|
1259
|
-
Transforms.select(editor, Editor.start(editor, path.concat(n)));
|
|
1260
|
-
}
|
|
1261
|
-
Transforms.removeNodes(editor, {
|
|
1262
|
-
at: path.concat(n - 1),
|
|
1263
|
-
voids: true,
|
|
1264
|
-
});
|
|
1265
|
-
n--;
|
|
1266
|
-
}
|
|
1267
|
-
else if (Text$1.equals(child, prev, { loose: true })) {
|
|
1268
|
-
Transforms.mergeNodes(editor, { at: path.concat(n), voids: true });
|
|
1269
|
-
n--;
|
|
1270
|
-
}
|
|
1271
|
-
else if (isLast && child.text === '') {
|
|
1272
|
-
Transforms.removeNodes(editor, {
|
|
1273
|
-
at: path.concat(n),
|
|
1274
|
-
voids: true,
|
|
1275
|
-
});
|
|
1276
|
-
n--;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
};
|
|
1282
1185
|
e.onKeydown = () => { };
|
|
1283
1186
|
e.onClick = () => { };
|
|
1284
1187
|
e.isBlockCard = (element) => false;
|
|
@@ -1966,7 +1869,6 @@ class ViewContainer {
|
|
|
1966
1869
|
// first diff
|
|
1967
1870
|
differ.diff(this.childrenComponent);
|
|
1968
1871
|
const parentElement = this.elementRef.nativeElement.parentElement;
|
|
1969
|
-
let firstChildComponent = this.childrenComponent.first;
|
|
1970
1872
|
if (this.childrenComponent.length > 0) {
|
|
1971
1873
|
parentElement.insertBefore(this.createFragment(), this.elementRef.nativeElement);
|
|
1972
1874
|
this.elementRef.nativeElement.remove();
|
|
@@ -1974,41 +1876,15 @@ class ViewContainer {
|
|
|
1974
1876
|
this.childrenComponent.changes.subscribe((value) => {
|
|
1975
1877
|
const iterableChanges = differ.diff(this.childrenComponent);
|
|
1976
1878
|
if (iterableChanges) {
|
|
1977
|
-
iterableChanges.
|
|
1978
|
-
//
|
|
1979
|
-
if (
|
|
1980
|
-
const fragment = document.createDocumentFragment();
|
|
1981
|
-
fragment.append(...record.item.rootNodes);
|
|
1982
|
-
parentElement.insertBefore(fragment, this.elementRef.nativeElement);
|
|
1983
|
-
this.elementRef.nativeElement.remove();
|
|
1879
|
+
iterableChanges.forEachOperation((record, previousIndex, currentIndex) => {
|
|
1880
|
+
// removed
|
|
1881
|
+
if (currentIndex === null) {
|
|
1984
1882
|
return;
|
|
1985
1883
|
}
|
|
1986
|
-
//
|
|
1987
|
-
|
|
1988
|
-
const fragment = document.createDocumentFragment();
|
|
1989
|
-
fragment.append(...record.item.rootNodes);
|
|
1990
|
-
parentElement.prepend(fragment);
|
|
1991
|
-
}
|
|
1992
|
-
else {
|
|
1993
|
-
// insert afterend of previous component end
|
|
1994
|
-
let previousRootNode = this.getPreviousRootNode(record.currentIndex);
|
|
1995
|
-
if (previousRootNode) {
|
|
1996
|
-
record.item.rootNodes.forEach((rootNode) => {
|
|
1997
|
-
previousRootNode.insertAdjacentElement('afterend', rootNode);
|
|
1998
|
-
previousRootNode = rootNode;
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
else {
|
|
2002
|
-
this.viewContext.editor.onError({
|
|
2003
|
-
code: SlateErrorCode.NotFoundPreviousRootNodeError,
|
|
2004
|
-
name: 'not found previous rootNode',
|
|
2005
|
-
nativeError: null
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
1884
|
+
// added or moved
|
|
1885
|
+
this.handleContainerItemChange(record, parentElement);
|
|
2009
1886
|
});
|
|
2010
1887
|
}
|
|
2011
|
-
firstChildComponent = this.childrenComponent.first;
|
|
2012
1888
|
});
|
|
2013
1889
|
}
|
|
2014
1890
|
getPreviousRootNode(currentIndex) {
|
|
@@ -2031,6 +1907,39 @@ class ViewContainer {
|
|
|
2031
1907
|
});
|
|
2032
1908
|
return fragment;
|
|
2033
1909
|
}
|
|
1910
|
+
handleContainerItemChange(record, parentElement) {
|
|
1911
|
+
// first insert
|
|
1912
|
+
if (this.elementRef.nativeElement.parentElement && this.elementRef.nativeElement.parentElement === parentElement) {
|
|
1913
|
+
const fragment = document.createDocumentFragment();
|
|
1914
|
+
fragment.append(...record.item.rootNodes);
|
|
1915
|
+
parentElement.insertBefore(fragment, this.elementRef.nativeElement);
|
|
1916
|
+
this.elementRef.nativeElement.remove();
|
|
1917
|
+
return;
|
|
1918
|
+
}
|
|
1919
|
+
// insert at start location
|
|
1920
|
+
if (record.currentIndex === 0) {
|
|
1921
|
+
const fragment = document.createDocumentFragment();
|
|
1922
|
+
fragment.append(...record.item.rootNodes);
|
|
1923
|
+
parentElement.prepend(fragment);
|
|
1924
|
+
}
|
|
1925
|
+
else {
|
|
1926
|
+
// insert afterend of previous component end
|
|
1927
|
+
let previousRootNode = this.getPreviousRootNode(record.currentIndex);
|
|
1928
|
+
if (previousRootNode) {
|
|
1929
|
+
record.item.rootNodes.forEach((rootNode) => {
|
|
1930
|
+
previousRootNode.insertAdjacentElement('afterend', rootNode);
|
|
1931
|
+
previousRootNode = rootNode;
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
else {
|
|
1935
|
+
this.viewContext.editor.onError({
|
|
1936
|
+
code: SlateErrorCode.NotFoundPreviousRootNodeError,
|
|
1937
|
+
name: 'not found previous rootNode',
|
|
1938
|
+
nativeError: null
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
2034
1943
|
}
|
|
2035
1944
|
ViewContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ViewContainer, deps: [{ token: i0.ElementRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2036
1945
|
ViewContainer.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.7", type: ViewContainer, inputs: { viewContext: "viewContext" }, ngImport: i0 });
|
|
@@ -2111,12 +2020,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
2111
2020
|
class SlateDefaultLeafComponent extends BaseLeafComponent {
|
|
2112
2021
|
}
|
|
2113
2022
|
SlateDefaultLeafComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: SlateDefaultLeafComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2114
|
-
SlateDefaultLeafComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: SlateDefaultLeafComponent, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0, template:
|
|
2023
|
+
SlateDefaultLeafComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: SlateDefaultLeafComponent, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0, template: `
|
|
2024
|
+
<ng-container *ngIf="context.leaf['placeholder']">
|
|
2025
|
+
<span contenteditable="false" data-slate-placeholder="true" slate-placeholder="true">{{context.leaf['placeholder']}}</span>
|
|
2026
|
+
</ng-container>
|
|
2027
|
+
<span slateString [context]="context" [viewContext]="viewContext"><span>`, isInline: true, components: [{ type: SlateStringComponent, selector: "span[slateString]", inputs: ["context"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2115
2028
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: SlateDefaultLeafComponent, decorators: [{
|
|
2116
2029
|
type: Component,
|
|
2117
2030
|
args: [{
|
|
2118
2031
|
selector: 'span[slateDefaultLeaf]',
|
|
2119
|
-
template:
|
|
2032
|
+
template: `
|
|
2033
|
+
<ng-container *ngIf="context.leaf['placeholder']">
|
|
2034
|
+
<span contenteditable="false" data-slate-placeholder="true" slate-placeholder="true">{{context.leaf['placeholder']}}</span>
|
|
2035
|
+
</ng-container>
|
|
2036
|
+
<span slateString [context]="context" [viewContext]="viewContext"><span>`,
|
|
2120
2037
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2121
2038
|
host: {
|
|
2122
2039
|
'data-slate-leaf': 'true'
|
|
@@ -2526,6 +2443,22 @@ class SlateEditableComponent {
|
|
|
2526
2443
|
this.onTouchedCallback = () => { };
|
|
2527
2444
|
this.onChangeCallback = () => { };
|
|
2528
2445
|
this.decorate = () => [];
|
|
2446
|
+
this.placeholderDecorate = (editor) => {
|
|
2447
|
+
if (this.placeholder &&
|
|
2448
|
+
editor.children.length === 1 &&
|
|
2449
|
+
Array.from(Node.texts(editor)).length === 1 &&
|
|
2450
|
+
Node.string(editor) === '') {
|
|
2451
|
+
const start = Editor.start(editor, []);
|
|
2452
|
+
return [{
|
|
2453
|
+
placeholder: this.placeholder,
|
|
2454
|
+
anchor: start,
|
|
2455
|
+
focus: start
|
|
2456
|
+
}];
|
|
2457
|
+
}
|
|
2458
|
+
else {
|
|
2459
|
+
return [];
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2529
2462
|
this.isStrictDecorate = true;
|
|
2530
2463
|
this.trackBy = () => null;
|
|
2531
2464
|
this.readonly = false;
|
|
@@ -2597,6 +2530,7 @@ class SlateEditableComponent {
|
|
|
2597
2530
|
});
|
|
2598
2531
|
this.editor.children = normalize(value);
|
|
2599
2532
|
}
|
|
2533
|
+
this.initializeContext();
|
|
2600
2534
|
this.cdr.markForCheck();
|
|
2601
2535
|
}
|
|
2602
2536
|
}
|
|
@@ -2677,14 +2611,6 @@ class SlateEditableComponent {
|
|
|
2677
2611
|
// eslint-disable-next-line max-len
|
|
2678
2612
|
domSelection.setBaseAndExtent(newDomRange.startContainer, newDomRange.startOffset, newDomRange.endContainer, newDomRange.endOffset);
|
|
2679
2613
|
}
|
|
2680
|
-
const leafEl = newDomRange.startContainer.parentElement;
|
|
2681
|
-
leafEl.getBoundingClientRect = newDomRange.getBoundingClientRect.bind(newDomRange);
|
|
2682
|
-
scrollIntoView(leafEl, {
|
|
2683
|
-
scrollMode: 'if-needed',
|
|
2684
|
-
boundary: el,
|
|
2685
|
-
});
|
|
2686
|
-
// @ts-ignore
|
|
2687
|
-
delete leafEl.getBoundingClientRect;
|
|
2688
2614
|
}
|
|
2689
2615
|
setTimeout(() => {
|
|
2690
2616
|
// COMPAT: In Firefox, it's not enough to create a range, you also need
|
|
@@ -2713,31 +2639,38 @@ class SlateEditableComponent {
|
|
|
2713
2639
|
timeDebug('start data sync');
|
|
2714
2640
|
this.detectContext();
|
|
2715
2641
|
this.cdr.detectChanges();
|
|
2642
|
+
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
2716
2643
|
// when the DOMElement where the selection is located is removed
|
|
2717
2644
|
// the compositionupdate and compositionend events will no longer be fired
|
|
2718
2645
|
// so isComposing needs to be corrected
|
|
2719
2646
|
// need exec after this.cdr.detectChanges() to render HTML
|
|
2720
2647
|
// need exec before this.toNativeSelection() to correct native selection
|
|
2721
2648
|
if (this.isComposing) {
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
//
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2649
|
+
// Composition input text be not rendered when user composition input with selection is expanded
|
|
2650
|
+
// At this time, the following matching conditions are met, assign isComposing to false, and the status is wrong
|
|
2651
|
+
// this time condition is true and isComposiing is assigned false
|
|
2652
|
+
// Therefore, need to wait for the composition input text to be rendered before performing condition matching
|
|
2653
|
+
setTimeout(() => {
|
|
2654
|
+
const textNode = Node.get(this.editor, this.editor.selection.anchor.path);
|
|
2655
|
+
const textDOMNode = AngularEditor.toDOMNode(this.editor, textNode);
|
|
2656
|
+
let textContent = '';
|
|
2657
|
+
// skip decorate text
|
|
2658
|
+
textDOMNode.querySelectorAll('[editable-text]').forEach((stringDOMNode) => {
|
|
2659
|
+
let text = stringDOMNode.textContent;
|
|
2660
|
+
const zeroChar = '\uFEFF';
|
|
2661
|
+
// remove zero with char
|
|
2662
|
+
if (text.startsWith(zeroChar)) {
|
|
2663
|
+
text = text.slice(1);
|
|
2664
|
+
}
|
|
2665
|
+
if (text.endsWith(zeroChar)) {
|
|
2666
|
+
text = text.slice(0, text.length - 1);
|
|
2667
|
+
}
|
|
2668
|
+
textContent += text;
|
|
2669
|
+
});
|
|
2670
|
+
if (Node.string(textNode).endsWith(textContent)) {
|
|
2671
|
+
this.isComposing = false;
|
|
2735
2672
|
}
|
|
2736
|
-
|
|
2737
|
-
});
|
|
2738
|
-
if (Node.string(textNode).endsWith(textContent)) {
|
|
2739
|
-
this.isComposing = false;
|
|
2740
|
-
}
|
|
2673
|
+
}, 0);
|
|
2741
2674
|
}
|
|
2742
2675
|
this.toNativeSelection();
|
|
2743
2676
|
timeDebug('end data sync');
|
|
@@ -2746,7 +2679,7 @@ class SlateEditableComponent {
|
|
|
2746
2679
|
this.context = {
|
|
2747
2680
|
parent: this.editor,
|
|
2748
2681
|
selection: this.editor.selection,
|
|
2749
|
-
decorations: this.
|
|
2682
|
+
decorations: this.generateDecorations(),
|
|
2750
2683
|
decorate: this.decorate,
|
|
2751
2684
|
readonly: this.readonly
|
|
2752
2685
|
};
|
|
@@ -2763,20 +2696,26 @@ class SlateEditableComponent {
|
|
|
2763
2696
|
};
|
|
2764
2697
|
}
|
|
2765
2698
|
detectContext() {
|
|
2699
|
+
const decorations = this.generateDecorations();
|
|
2766
2700
|
if (this.context.selection !== this.editor.selection ||
|
|
2767
2701
|
this.context.decorate !== this.decorate ||
|
|
2768
|
-
this.context.readonly !== this.readonly
|
|
2769
|
-
|
|
2770
|
-
const isSameDecorations = isDecoratorRangeListEqual(this.context.decorations, decorations);
|
|
2702
|
+
this.context.readonly !== this.readonly ||
|
|
2703
|
+
!isDecoratorRangeListEqual(this.context.decorations, decorations)) {
|
|
2771
2704
|
this.context = {
|
|
2772
2705
|
parent: this.editor,
|
|
2773
2706
|
selection: this.editor.selection,
|
|
2774
|
-
decorations:
|
|
2707
|
+
decorations: decorations,
|
|
2775
2708
|
decorate: this.decorate,
|
|
2776
2709
|
readonly: this.readonly
|
|
2777
2710
|
};
|
|
2778
2711
|
}
|
|
2779
2712
|
}
|
|
2713
|
+
generateDecorations() {
|
|
2714
|
+
const decorations = this.decorate([this.editor, []]);
|
|
2715
|
+
const placeholderDecorations = this.isComposing ? [] : this.placeholderDecorate(this.editor);
|
|
2716
|
+
decorations.push(...placeholderDecorations);
|
|
2717
|
+
return decorations;
|
|
2718
|
+
}
|
|
2780
2719
|
//#region event proxy
|
|
2781
2720
|
addEventListener(eventName, listener, target = this.elementRef.nativeElement) {
|
|
2782
2721
|
this.manualListeners.push(this.renderer2.listen(target, eventName, (event) => {
|
|
@@ -2995,6 +2934,8 @@ class SlateEditableComponent {
|
|
|
2995
2934
|
// so we need avoid repeat isnertText by isComposing === true,
|
|
2996
2935
|
this.isComposing = false;
|
|
2997
2936
|
}
|
|
2937
|
+
this.detectContext();
|
|
2938
|
+
this.cdr.detectChanges();
|
|
2998
2939
|
}
|
|
2999
2940
|
onDOMCompositionStart(event) {
|
|
3000
2941
|
const { selection } = this.editor;
|
|
@@ -3008,6 +2949,8 @@ class SlateEditableComponent {
|
|
|
3008
2949
|
if (hasEditableTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.compositionStart)) {
|
|
3009
2950
|
this.isComposing = true;
|
|
3010
2951
|
}
|
|
2952
|
+
this.detectContext();
|
|
2953
|
+
this.cdr.detectChanges();
|
|
3011
2954
|
}
|
|
3012
2955
|
onDOMCopy(event) {
|
|
3013
2956
|
const window = AngularEditor.getWindow(this.editor);
|
|
@@ -3277,6 +3220,25 @@ class SlateEditableComponent {
|
|
|
3277
3220
|
return;
|
|
3278
3221
|
}
|
|
3279
3222
|
}
|
|
3223
|
+
else {
|
|
3224
|
+
if (IS_CHROME || IS_SAFARI) {
|
|
3225
|
+
// COMPAT: Chrome and Safari support `beforeinput` event but do not fire
|
|
3226
|
+
// an event when deleting backwards in a selected void inline node
|
|
3227
|
+
if (selection &&
|
|
3228
|
+
(hotkeys.isDeleteBackward(nativeEvent) ||
|
|
3229
|
+
hotkeys.isDeleteForward(nativeEvent)) &&
|
|
3230
|
+
Range.isCollapsed(selection)) {
|
|
3231
|
+
const currentNode = Node.parent(editor, selection.anchor.path);
|
|
3232
|
+
if (Element.isElement(currentNode) &&
|
|
3233
|
+
Editor.isVoid(editor, currentNode) &&
|
|
3234
|
+
Editor.isInline(editor, currentNode)) {
|
|
3235
|
+
event.preventDefault();
|
|
3236
|
+
Editor.deleteBackward(editor, { unit: 'block' });
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3280
3242
|
}
|
|
3281
3243
|
catch (error) {
|
|
3282
3244
|
this.editor.onError({ code: SlateErrorCode.OnDOMKeydownError, nativeError: error });
|
|
@@ -3339,11 +3301,11 @@ class SlateEditableComponent {
|
|
|
3339
3301
|
}
|
|
3340
3302
|
}
|
|
3341
3303
|
SlateEditableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: SlateEditableComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component });
|
|
3342
|
-
SlateEditableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: SlateEditableComponent, selector: "slate-editable", inputs: { editor: "editor", renderElement: "renderElement", renderLeaf: "renderLeaf", renderText: "renderText", decorate: "decorate", isStrictDecorate: "isStrictDecorate", trackBy: "trackBy", readonly: "readonly", beforeInput: "beforeInput", blur: "blur", click: "click", compositionEnd: "compositionEnd", 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: [{
|
|
3304
|
+
SlateEditableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: SlateEditableComponent, selector: "slate-editable", inputs: { editor: "editor", renderElement: "renderElement", renderLeaf: "renderLeaf", renderText: "renderText", decorate: "decorate", placeholderDecorate: "placeholderDecorate", isStrictDecorate: "isStrictDecorate", trackBy: "trackBy", readonly: "readonly", placeholder: "placeholder", beforeInput: "beforeInput", blur: "blur", click: "click", compositionEnd: "compositionEnd", 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: [{
|
|
3343
3305
|
provide: NG_VALUE_ACCESSOR,
|
|
3344
3306
|
useExisting: forwardRef(() => SlateEditableComponent),
|
|
3345
3307
|
multi: true
|
|
3346
|
-
}], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"
|
|
3308
|
+
}], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"></slate-children>\n<slate-string-template #templateComponent></slate-string-template>", components: [{ type: SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }, { type: SlateStringTemplateComponent, selector: "slate-string-template" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3347
3309
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: SlateEditableComponent, decorators: [{
|
|
3348
3310
|
type: Component,
|
|
3349
3311
|
args: [{
|
|
@@ -3374,12 +3336,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
3374
3336
|
type: Input
|
|
3375
3337
|
}], decorate: [{
|
|
3376
3338
|
type: Input
|
|
3339
|
+
}], placeholderDecorate: [{
|
|
3340
|
+
type: Input
|
|
3377
3341
|
}], isStrictDecorate: [{
|
|
3378
3342
|
type: Input
|
|
3379
3343
|
}], trackBy: [{
|
|
3380
3344
|
type: Input
|
|
3381
3345
|
}], readonly: [{
|
|
3382
3346
|
type: Input
|
|
3347
|
+
}], placeholder: [{
|
|
3348
|
+
type: Input
|
|
3383
3349
|
}], beforeInput: [{
|
|
3384
3350
|
type: Input
|
|
3385
3351
|
}], blur: [{
|