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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('slate'), require('is-hotkey'), require('@angular/core'), require('direction'), require('rxjs'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('slate-angular', ['exports', 'slate', 'is-hotkey', '@angular/core', 'direction', 'rxjs', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["slate-angular"] = {}, global.slate, global.isHotkey, global.ng.core, global.getDirection, global.rxjs, global.
|
|
5
|
-
})(this, (function (exports, slate, isHotkey, i0, getDirection, rxjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('slate'), require('is-hotkey'), require('@angular/core'), require('direction'), require('rxjs'), require('debug'), require('@angular/forms'), require('slate-history'), require('@angular/common')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('slate-angular', ['exports', 'slate', 'is-hotkey', '@angular/core', 'direction', 'rxjs', 'debug', '@angular/forms', 'slate-history', '@angular/common'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["slate-angular"] = {}, global.slate, global.isHotkey, global.ng.core, global.getDirection, global.rxjs, global.Debug, global.ng.forms, global.slateHistory, global.ng.common));
|
|
5
|
+
})(this, (function (exports, slate, isHotkey, i0, getDirection, rxjs, Debug, forms, slateHistory, i2) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
28
|
var getDirection__default = /*#__PURE__*/_interopDefaultLegacy(getDirection);
|
|
29
|
-
var scrollIntoView__default = /*#__PURE__*/_interopDefaultLegacy(scrollIntoView);
|
|
30
29
|
var Debug__default = /*#__PURE__*/_interopDefaultLegacy(Debug);
|
|
31
30
|
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
32
31
|
|
|
@@ -1588,102 +1587,6 @@
|
|
|
1588
1587
|
}
|
|
1589
1588
|
}
|
|
1590
1589
|
};
|
|
1591
|
-
// override slate layer logic
|
|
1592
|
-
e.normalizeNode = function (entry) {
|
|
1593
|
-
var _a = __read(entry, 2), node = _a[0], path = _a[1];
|
|
1594
|
-
// There are no core normalizations for text nodes.
|
|
1595
|
-
if (slate.Text.isText(node)) {
|
|
1596
|
-
return;
|
|
1597
|
-
}
|
|
1598
|
-
// Ensure that block and inline nodes have at least one text child.
|
|
1599
|
-
if (slate.Element.isElement(node) && node.children.length === 0) {
|
|
1600
|
-
var child = { text: '' };
|
|
1601
|
-
slate.Transforms.insertNodes(editor, child, {
|
|
1602
|
-
at: path.concat(0),
|
|
1603
|
-
voids: true,
|
|
1604
|
-
});
|
|
1605
|
-
return;
|
|
1606
|
-
}
|
|
1607
|
-
// Determine whether the node should have block or inline children.
|
|
1608
|
-
var shouldHaveInlines = slate.Editor.isEditor(node)
|
|
1609
|
-
? false
|
|
1610
|
-
: slate.Element.isElement(node) &&
|
|
1611
|
-
(editor.isInline(node) ||
|
|
1612
|
-
node.children.length === 0 ||
|
|
1613
|
-
slate.Text.isText(node.children[0]) ||
|
|
1614
|
-
editor.isInline(node.children[0]));
|
|
1615
|
-
// Since we'll be applying operations while iterating, keep track of an
|
|
1616
|
-
// index that accounts for any added/removed nodes.
|
|
1617
|
-
var n = 0;
|
|
1618
|
-
for (var i = 0; i < node.children.length; i++, n++) {
|
|
1619
|
-
var child = node.children[i];
|
|
1620
|
-
var prev = node.children[i - 1];
|
|
1621
|
-
var isLast = i === node.children.length - 1;
|
|
1622
|
-
var isInlineOrText = slate.Text.isText(child) ||
|
|
1623
|
-
(slate.Element.isElement(child) && editor.isInline(child));
|
|
1624
|
-
// Only allow block nodes in the top-level children and parent blocks
|
|
1625
|
-
// that only contain block nodes. Similarly, only allow inline nodes in
|
|
1626
|
-
// other inline nodes, or parent blocks that only contain inlines and
|
|
1627
|
-
// text.
|
|
1628
|
-
if (isInlineOrText !== shouldHaveInlines) {
|
|
1629
|
-
slate.Transforms.removeNodes(editor, { at: path.concat(n), voids: true });
|
|
1630
|
-
n--;
|
|
1631
|
-
}
|
|
1632
|
-
else if (slate.Element.isElement(child)) {
|
|
1633
|
-
// Ensure that inline nodes are surrounded by text nodes.
|
|
1634
|
-
if (editor.isInline(child)) {
|
|
1635
|
-
if (prev == null || !slate.Text.isText(prev)) {
|
|
1636
|
-
var newChild = { text: '' };
|
|
1637
|
-
slate.Transforms.insertNodes(editor, newChild, {
|
|
1638
|
-
at: path.concat(n),
|
|
1639
|
-
voids: true,
|
|
1640
|
-
});
|
|
1641
|
-
n++;
|
|
1642
|
-
}
|
|
1643
|
-
else if (isLast) {
|
|
1644
|
-
var newChild = { text: '' };
|
|
1645
|
-
slate.Transforms.insertNodes(editor, newChild, {
|
|
1646
|
-
at: path.concat(n + 1),
|
|
1647
|
-
voids: true,
|
|
1648
|
-
});
|
|
1649
|
-
n++;
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
else {
|
|
1654
|
-
// Merge adjacent text nodes that are empty or match.
|
|
1655
|
-
if (prev != null && slate.Text.isText(prev)) {
|
|
1656
|
-
// adjust logic: first remove empty text to avoid merge empty text #WIK-3805
|
|
1657
|
-
if (prev.text === '') {
|
|
1658
|
-
// adjust logic: adjust cursor location when empty text is first child of node #WIK-3631
|
|
1659
|
-
// ensure current selection in the text #WIK-3762
|
|
1660
|
-
var prevFocused = editor.selection &&
|
|
1661
|
-
slate.Range.isCollapsed(editor.selection) &&
|
|
1662
|
-
slate.Path.equals(editor.selection.anchor.path, path.concat(n - 1));
|
|
1663
|
-
if (prev === node.children[0] && prevFocused) {
|
|
1664
|
-
slate.Transforms.select(editor, slate.Editor.start(editor, path.concat(n)));
|
|
1665
|
-
}
|
|
1666
|
-
slate.Transforms.removeNodes(editor, {
|
|
1667
|
-
at: path.concat(n - 1),
|
|
1668
|
-
voids: true,
|
|
1669
|
-
});
|
|
1670
|
-
n--;
|
|
1671
|
-
}
|
|
1672
|
-
else if (slate.Text.equals(child, prev, { loose: true })) {
|
|
1673
|
-
slate.Transforms.mergeNodes(editor, { at: path.concat(n), voids: true });
|
|
1674
|
-
n--;
|
|
1675
|
-
}
|
|
1676
|
-
else if (isLast && child.text === '') {
|
|
1677
|
-
slate.Transforms.removeNodes(editor, {
|
|
1678
|
-
at: path.concat(n),
|
|
1679
|
-
voids: true,
|
|
1680
|
-
});
|
|
1681
|
-
n--;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
};
|
|
1687
1590
|
e.onKeydown = function () { };
|
|
1688
1591
|
e.onClick = function () { };
|
|
1689
1592
|
e.isBlockCard = function (element) { return false; };
|
|
@@ -2443,7 +2346,6 @@
|
|
|
2443
2346
|
// first diff
|
|
2444
2347
|
differ.diff(this.childrenComponent);
|
|
2445
2348
|
var parentElement = this.elementRef.nativeElement.parentElement;
|
|
2446
|
-
var firstChildComponent = this.childrenComponent.first;
|
|
2447
2349
|
if (this.childrenComponent.length > 0) {
|
|
2448
2350
|
parentElement.insertBefore(this.createFragment(), this.elementRef.nativeElement);
|
|
2449
2351
|
this.elementRef.nativeElement.remove();
|
|
@@ -2451,41 +2353,15 @@
|
|
|
2451
2353
|
this.childrenComponent.changes.subscribe(function (value) {
|
|
2452
2354
|
var iterableChanges = differ.diff(_this.childrenComponent);
|
|
2453
2355
|
if (iterableChanges) {
|
|
2454
|
-
iterableChanges.
|
|
2455
|
-
//
|
|
2456
|
-
if (
|
|
2457
|
-
var fragment = document.createDocumentFragment();
|
|
2458
|
-
fragment.append.apply(fragment, __spreadArray([], __read(record.item.rootNodes)));
|
|
2459
|
-
parentElement.insertBefore(fragment, _this.elementRef.nativeElement);
|
|
2460
|
-
_this.elementRef.nativeElement.remove();
|
|
2356
|
+
iterableChanges.forEachOperation(function (record, previousIndex, currentIndex) {
|
|
2357
|
+
// removed
|
|
2358
|
+
if (currentIndex === null) {
|
|
2461
2359
|
return;
|
|
2462
2360
|
}
|
|
2463
|
-
//
|
|
2464
|
-
|
|
2465
|
-
var fragment = document.createDocumentFragment();
|
|
2466
|
-
fragment.append.apply(fragment, __spreadArray([], __read(record.item.rootNodes)));
|
|
2467
|
-
parentElement.prepend(fragment);
|
|
2468
|
-
}
|
|
2469
|
-
else {
|
|
2470
|
-
// insert afterend of previous component end
|
|
2471
|
-
var previousRootNode_1 = _this.getPreviousRootNode(record.currentIndex);
|
|
2472
|
-
if (previousRootNode_1) {
|
|
2473
|
-
record.item.rootNodes.forEach(function (rootNode) {
|
|
2474
|
-
previousRootNode_1.insertAdjacentElement('afterend', rootNode);
|
|
2475
|
-
previousRootNode_1 = rootNode;
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
else {
|
|
2479
|
-
_this.viewContext.editor.onError({
|
|
2480
|
-
code: exports.SlateErrorCode.NotFoundPreviousRootNodeError,
|
|
2481
|
-
name: 'not found previous rootNode',
|
|
2482
|
-
nativeError: null
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2361
|
+
// added or moved
|
|
2362
|
+
_this.handleContainerItemChange(record, parentElement);
|
|
2486
2363
|
});
|
|
2487
2364
|
}
|
|
2488
|
-
firstChildComponent = _this.childrenComponent.first;
|
|
2489
2365
|
});
|
|
2490
2366
|
};
|
|
2491
2367
|
ViewContainer.prototype.getPreviousRootNode = function (currentIndex) {
|
|
@@ -2508,6 +2384,39 @@
|
|
|
2508
2384
|
});
|
|
2509
2385
|
return fragment;
|
|
2510
2386
|
};
|
|
2387
|
+
ViewContainer.prototype.handleContainerItemChange = function (record, parentElement) {
|
|
2388
|
+
// first insert
|
|
2389
|
+
if (this.elementRef.nativeElement.parentElement && this.elementRef.nativeElement.parentElement === parentElement) {
|
|
2390
|
+
var fragment = document.createDocumentFragment();
|
|
2391
|
+
fragment.append.apply(fragment, __spreadArray([], __read(record.item.rootNodes)));
|
|
2392
|
+
parentElement.insertBefore(fragment, this.elementRef.nativeElement);
|
|
2393
|
+
this.elementRef.nativeElement.remove();
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
// insert at start location
|
|
2397
|
+
if (record.currentIndex === 0) {
|
|
2398
|
+
var fragment = document.createDocumentFragment();
|
|
2399
|
+
fragment.append.apply(fragment, __spreadArray([], __read(record.item.rootNodes)));
|
|
2400
|
+
parentElement.prepend(fragment);
|
|
2401
|
+
}
|
|
2402
|
+
else {
|
|
2403
|
+
// insert afterend of previous component end
|
|
2404
|
+
var previousRootNode_1 = this.getPreviousRootNode(record.currentIndex);
|
|
2405
|
+
if (previousRootNode_1) {
|
|
2406
|
+
record.item.rootNodes.forEach(function (rootNode) {
|
|
2407
|
+
previousRootNode_1.insertAdjacentElement('afterend', rootNode);
|
|
2408
|
+
previousRootNode_1 = rootNode;
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
else {
|
|
2412
|
+
this.viewContext.editor.onError({
|
|
2413
|
+
code: exports.SlateErrorCode.NotFoundPreviousRootNodeError,
|
|
2414
|
+
name: 'not found previous rootNode',
|
|
2415
|
+
nativeError: null
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2511
2420
|
return ViewContainer;
|
|
2512
2421
|
}());
|
|
2513
2422
|
ViewContainer.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: ViewContainer, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.IterableDiffers }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
@@ -2597,12 +2506,12 @@
|
|
|
2597
2506
|
return SlateDefaultLeafComponent;
|
|
2598
2507
|
}(BaseLeafComponent));
|
|
2599
2508
|
SlateDefaultLeafComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SlateDefaultLeafComponent, deps: null, target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
2600
|
-
SlateDefaultLeafComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: SlateDefaultLeafComponent, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0__namespace, template: "<span slateString [context]=\"context\" [viewContext]=\"viewContext\"><span>", isInline: true, components: [{ type: SlateStringComponent, selector: "span[slateString]", inputs: ["context"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
|
|
2509
|
+
SlateDefaultLeafComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: SlateDefaultLeafComponent, selector: "span[slateDefaultLeaf]", host: { attributes: { "data-slate-leaf": "true" } }, usesInheritance: true, ngImport: i0__namespace, template: "\n <ng-container *ngIf=\"context.leaf['placeholder']\">\n <span contenteditable=\"false\" data-slate-placeholder=\"true\" slate-placeholder=\"true\">{{context.leaf['placeholder']}}</span>\n </ng-container>\n <span slateString [context]=\"context\" [viewContext]=\"viewContext\"><span>", isInline: true, components: [{ type: SlateStringComponent, selector: "span[slateString]", inputs: ["context"] }], directives: [{ type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
|
|
2601
2510
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SlateDefaultLeafComponent, decorators: [{
|
|
2602
2511
|
type: i0.Component,
|
|
2603
2512
|
args: [{
|
|
2604
2513
|
selector: 'span[slateDefaultLeaf]',
|
|
2605
|
-
template: "<span slateString [context]=\"context\" [viewContext]=\"viewContext\"><span>",
|
|
2514
|
+
template: "\n <ng-container *ngIf=\"context.leaf['placeholder']\">\n <span contenteditable=\"false\" data-slate-placeholder=\"true\" slate-placeholder=\"true\">{{context.leaf['placeholder']}}</span>\n </ng-container>\n <span slateString [context]=\"context\" [viewContext]=\"viewContext\"><span>",
|
|
2606
2515
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
2607
2516
|
host: {
|
|
2608
2517
|
'data-slate-leaf': 'true'
|
|
@@ -3029,6 +2938,7 @@
|
|
|
3029
2938
|
var forceOnDOMPaste = IS_SAFARI;
|
|
3030
2939
|
var SlateEditableComponent = /** @class */ (function () {
|
|
3031
2940
|
function SlateEditableComponent(elementRef, renderer2, cdr, ngZone, injector) {
|
|
2941
|
+
var _this = this;
|
|
3032
2942
|
this.elementRef = elementRef;
|
|
3033
2943
|
this.renderer2 = renderer2;
|
|
3034
2944
|
this.cdr = cdr;
|
|
@@ -3043,6 +2953,22 @@
|
|
|
3043
2953
|
this.onTouchedCallback = function () { };
|
|
3044
2954
|
this.onChangeCallback = function () { };
|
|
3045
2955
|
this.decorate = function () { return []; };
|
|
2956
|
+
this.placeholderDecorate = function (editor) {
|
|
2957
|
+
if (_this.placeholder &&
|
|
2958
|
+
editor.children.length === 1 &&
|
|
2959
|
+
Array.from(slate.Node.texts(editor)).length === 1 &&
|
|
2960
|
+
slate.Node.string(editor) === '') {
|
|
2961
|
+
var start = slate.Editor.start(editor, []);
|
|
2962
|
+
return [{
|
|
2963
|
+
placeholder: _this.placeholder,
|
|
2964
|
+
anchor: start,
|
|
2965
|
+
focus: start
|
|
2966
|
+
}];
|
|
2967
|
+
}
|
|
2968
|
+
else {
|
|
2969
|
+
return [];
|
|
2970
|
+
}
|
|
2971
|
+
};
|
|
3046
2972
|
this.isStrictDecorate = true;
|
|
3047
2973
|
this.trackBy = function () { return null; };
|
|
3048
2974
|
this.readonly = false;
|
|
@@ -3119,6 +3045,7 @@
|
|
|
3119
3045
|
});
|
|
3120
3046
|
this.editor.children = normalize(value);
|
|
3121
3047
|
}
|
|
3048
|
+
this.initializeContext();
|
|
3122
3049
|
this.cdr.markForCheck();
|
|
3123
3050
|
}
|
|
3124
3051
|
};
|
|
@@ -3201,14 +3128,6 @@
|
|
|
3201
3128
|
// eslint-disable-next-line max-len
|
|
3202
3129
|
domSelection.setBaseAndExtent(newDomRange_1.startContainer, newDomRange_1.startOffset, newDomRange_1.endContainer, newDomRange_1.endOffset);
|
|
3203
3130
|
}
|
|
3204
|
-
var leafEl = newDomRange_1.startContainer.parentElement;
|
|
3205
|
-
leafEl.getBoundingClientRect = newDomRange_1.getBoundingClientRect.bind(newDomRange_1);
|
|
3206
|
-
scrollIntoView__default["default"](leafEl, {
|
|
3207
|
-
scrollMode: 'if-needed',
|
|
3208
|
-
boundary: el_1,
|
|
3209
|
-
});
|
|
3210
|
-
// @ts-ignore
|
|
3211
|
-
delete leafEl.getBoundingClientRect;
|
|
3212
3131
|
}
|
|
3213
3132
|
setTimeout(function () {
|
|
3214
3133
|
// COMPAT: In Firefox, it's not enough to create a range, you also need
|
|
@@ -3234,34 +3153,42 @@
|
|
|
3234
3153
|
timeDebug('editable ngDoCheck');
|
|
3235
3154
|
};
|
|
3236
3155
|
SlateEditableComponent.prototype.forceFlush = function () {
|
|
3156
|
+
var _this = this;
|
|
3237
3157
|
timeDebug('start data sync');
|
|
3238
3158
|
this.detectContext();
|
|
3239
3159
|
this.cdr.detectChanges();
|
|
3160
|
+
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
3240
3161
|
// when the DOMElement where the selection is located is removed
|
|
3241
3162
|
// the compositionupdate and compositionend events will no longer be fired
|
|
3242
3163
|
// so isComposing needs to be corrected
|
|
3243
3164
|
// need exec after this.cdr.detectChanges() to render HTML
|
|
3244
3165
|
// need exec before this.toNativeSelection() to correct native selection
|
|
3245
3166
|
if (this.isComposing) {
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
//
|
|
3250
|
-
|
|
3251
|
-
var
|
|
3252
|
-
var
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3167
|
+
// Composition input text be not rendered when user composition input with selection is expanded
|
|
3168
|
+
// At this time, the following matching conditions are met, assign isComposing to false, and the status is wrong
|
|
3169
|
+
// this time condition is true and isComposiing is assigned false
|
|
3170
|
+
// Therefore, need to wait for the composition input text to be rendered before performing condition matching
|
|
3171
|
+
setTimeout(function () {
|
|
3172
|
+
var textNode = slate.Node.get(_this.editor, _this.editor.selection.anchor.path);
|
|
3173
|
+
var textDOMNode = AngularEditor.toDOMNode(_this.editor, textNode);
|
|
3174
|
+
var textContent = '';
|
|
3175
|
+
// skip decorate text
|
|
3176
|
+
textDOMNode.querySelectorAll('[editable-text]').forEach(function (stringDOMNode) {
|
|
3177
|
+
var text = stringDOMNode.textContent;
|
|
3178
|
+
var zeroChar = '\uFEFF';
|
|
3179
|
+
// remove zero with char
|
|
3180
|
+
if (text.startsWith(zeroChar)) {
|
|
3181
|
+
text = text.slice(1);
|
|
3182
|
+
}
|
|
3183
|
+
if (text.endsWith(zeroChar)) {
|
|
3184
|
+
text = text.slice(0, text.length - 1);
|
|
3185
|
+
}
|
|
3186
|
+
textContent += text;
|
|
3187
|
+
});
|
|
3188
|
+
if (slate.Node.string(textNode).endsWith(textContent)) {
|
|
3189
|
+
_this.isComposing = false;
|
|
3259
3190
|
}
|
|
3260
|
-
|
|
3261
|
-
});
|
|
3262
|
-
if (slate.Node.string(textNode).endsWith(textContent_1)) {
|
|
3263
|
-
this.isComposing = false;
|
|
3264
|
-
}
|
|
3191
|
+
}, 0);
|
|
3265
3192
|
}
|
|
3266
3193
|
this.toNativeSelection();
|
|
3267
3194
|
timeDebug('end data sync');
|
|
@@ -3270,7 +3197,7 @@
|
|
|
3270
3197
|
this.context = {
|
|
3271
3198
|
parent: this.editor,
|
|
3272
3199
|
selection: this.editor.selection,
|
|
3273
|
-
decorations: this.
|
|
3200
|
+
decorations: this.generateDecorations(),
|
|
3274
3201
|
decorate: this.decorate,
|
|
3275
3202
|
readonly: this.readonly
|
|
3276
3203
|
};
|
|
@@ -3287,20 +3214,26 @@
|
|
|
3287
3214
|
};
|
|
3288
3215
|
};
|
|
3289
3216
|
SlateEditableComponent.prototype.detectContext = function () {
|
|
3217
|
+
var decorations = this.generateDecorations();
|
|
3290
3218
|
if (this.context.selection !== this.editor.selection ||
|
|
3291
3219
|
this.context.decorate !== this.decorate ||
|
|
3292
|
-
this.context.readonly !== this.readonly
|
|
3293
|
-
|
|
3294
|
-
var isSameDecorations = isDecoratorRangeListEqual(this.context.decorations, decorations);
|
|
3220
|
+
this.context.readonly !== this.readonly ||
|
|
3221
|
+
!isDecoratorRangeListEqual(this.context.decorations, decorations)) {
|
|
3295
3222
|
this.context = {
|
|
3296
3223
|
parent: this.editor,
|
|
3297
3224
|
selection: this.editor.selection,
|
|
3298
|
-
decorations:
|
|
3225
|
+
decorations: decorations,
|
|
3299
3226
|
decorate: this.decorate,
|
|
3300
3227
|
readonly: this.readonly
|
|
3301
3228
|
};
|
|
3302
3229
|
}
|
|
3303
3230
|
};
|
|
3231
|
+
SlateEditableComponent.prototype.generateDecorations = function () {
|
|
3232
|
+
var decorations = this.decorate([this.editor, []]);
|
|
3233
|
+
var placeholderDecorations = this.isComposing ? [] : this.placeholderDecorate(this.editor);
|
|
3234
|
+
decorations.push.apply(decorations, __spreadArray([], __read(placeholderDecorations)));
|
|
3235
|
+
return decorations;
|
|
3236
|
+
};
|
|
3304
3237
|
//#region event proxy
|
|
3305
3238
|
SlateEditableComponent.prototype.addEventListener = function (eventName, listener, target) {
|
|
3306
3239
|
var _this = this;
|
|
@@ -3521,6 +3454,8 @@
|
|
|
3521
3454
|
// so we need avoid repeat isnertText by isComposing === true,
|
|
3522
3455
|
this.isComposing = false;
|
|
3523
3456
|
}
|
|
3457
|
+
this.detectContext();
|
|
3458
|
+
this.cdr.detectChanges();
|
|
3524
3459
|
};
|
|
3525
3460
|
SlateEditableComponent.prototype.onDOMCompositionStart = function (event) {
|
|
3526
3461
|
var selection = this.editor.selection;
|
|
@@ -3534,6 +3469,8 @@
|
|
|
3534
3469
|
if (hasEditableTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.compositionStart)) {
|
|
3535
3470
|
this.isComposing = true;
|
|
3536
3471
|
}
|
|
3472
|
+
this.detectContext();
|
|
3473
|
+
this.cdr.detectChanges();
|
|
3537
3474
|
};
|
|
3538
3475
|
SlateEditableComponent.prototype.onDOMCopy = function (event) {
|
|
3539
3476
|
var window = AngularEditor.getWindow(this.editor);
|
|
@@ -3803,6 +3740,25 @@
|
|
|
3803
3740
|
return;
|
|
3804
3741
|
}
|
|
3805
3742
|
}
|
|
3743
|
+
else {
|
|
3744
|
+
if (IS_CHROME || IS_SAFARI) {
|
|
3745
|
+
// COMPAT: Chrome and Safari support `beforeinput` event but do not fire
|
|
3746
|
+
// an event when deleting backwards in a selected void inline node
|
|
3747
|
+
if (selection &&
|
|
3748
|
+
(hotkeys.isDeleteBackward(nativeEvent) ||
|
|
3749
|
+
hotkeys.isDeleteForward(nativeEvent)) &&
|
|
3750
|
+
slate.Range.isCollapsed(selection)) {
|
|
3751
|
+
var currentNode = slate.Node.parent(editor, selection.anchor.path);
|
|
3752
|
+
if (slate.Element.isElement(currentNode) &&
|
|
3753
|
+
slate.Editor.isVoid(editor, currentNode) &&
|
|
3754
|
+
slate.Editor.isInline(editor, currentNode)) {
|
|
3755
|
+
event.preventDefault();
|
|
3756
|
+
slate.Editor.deleteBackward(editor, { unit: 'block' });
|
|
3757
|
+
return;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3806
3762
|
}
|
|
3807
3763
|
catch (error) {
|
|
3808
3764
|
this.editor.onError({ code: exports.SlateErrorCode.OnDOMKeydownError, nativeError: error });
|
|
@@ -3866,11 +3822,11 @@
|
|
|
3866
3822
|
return SlateEditableComponent;
|
|
3867
3823
|
}());
|
|
3868
3824
|
SlateEditableComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SlateEditableComponent, deps: [{ token: i0__namespace.ElementRef }, { token: i0__namespace.Renderer2 }, { token: i0__namespace.ChangeDetectorRef }, { token: i0__namespace.NgZone }, { token: i0__namespace.Injector }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
3869
|
-
SlateEditableComponent.ɵcmp = i0__namespace.ɵɵ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: [{
|
|
3825
|
+
SlateEditableComponent.ɵcmp = i0__namespace.ɵɵ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: [{
|
|
3870
3826
|
provide: forms.NG_VALUE_ACCESSOR,
|
|
3871
3827
|
useExisting: i0.forwardRef(function () { return SlateEditableComponent; }),
|
|
3872
3828
|
multi: true
|
|
3873
|
-
}], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: i0.ElementRef, static: true }], usesOnChanges: true, ngImport: i0__namespace, template: "<slate-children [children]=\"editor.children\" [context]=\"context\" [viewContext]=\"viewContext\"
|
|
3829
|
+
}], viewQueries: [{ propertyName: "templateComponent", first: true, predicate: ["templateComponent"], descendants: true, static: true }, { propertyName: "templateElementRef", first: true, predicate: ["templateComponent"], descendants: true, read: i0.ElementRef, static: true }], usesOnChanges: true, ngImport: i0__namespace, 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__namespace.ChangeDetectionStrategy.OnPush });
|
|
3874
3830
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SlateEditableComponent, decorators: [{
|
|
3875
3831
|
type: i0.Component,
|
|
3876
3832
|
args: [{
|
|
@@ -3901,12 +3857,16 @@
|
|
|
3901
3857
|
type: i0.Input
|
|
3902
3858
|
}], decorate: [{
|
|
3903
3859
|
type: i0.Input
|
|
3860
|
+
}], placeholderDecorate: [{
|
|
3861
|
+
type: i0.Input
|
|
3904
3862
|
}], isStrictDecorate: [{
|
|
3905
3863
|
type: i0.Input
|
|
3906
3864
|
}], trackBy: [{
|
|
3907
3865
|
type: i0.Input
|
|
3908
3866
|
}], readonly: [{
|
|
3909
3867
|
type: i0.Input
|
|
3868
|
+
}], placeholder: [{
|
|
3869
|
+
type: i0.Input
|
|
3910
3870
|
}], beforeInput: [{
|
|
3911
3871
|
type: i0.Input
|
|
3912
3872
|
}], blur: [{
|