slate-angular 1.6.3 → 1.7.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/bundles/slate-angular.umd.js +111 -153
- package/bundles/slate-angular.umd.js.map +1 -1
- package/components/editable/editable.component.d.ts +7 -2
- package/esm2015/components/editable/editable.component.js +68 -20
- 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/base.js +2 -2
- package/esm2015/view/container.js +39 -33
- package/fesm2015/slate-angular.js +115 -149
- package/fesm2015/slate-angular.js.map +1 -1
- package/package.json +8 -9
- 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; };
|
|
@@ -2392,7 +2295,7 @@
|
|
|
2392
2295
|
}
|
|
2393
2296
|
Object.defineProperty(BaseTextComponent.prototype, "text", {
|
|
2394
2297
|
get: function () {
|
|
2395
|
-
return this._context.text;
|
|
2298
|
+
return this._context && this._context.text;
|
|
2396
2299
|
},
|
|
2397
2300
|
enumerable: false,
|
|
2398
2301
|
configurable: true
|
|
@@ -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'
|
|
@@ -3119,6 +3028,7 @@
|
|
|
3119
3028
|
});
|
|
3120
3029
|
this.editor.children = normalize(value);
|
|
3121
3030
|
}
|
|
3031
|
+
this.initializeContext();
|
|
3122
3032
|
this.cdr.markForCheck();
|
|
3123
3033
|
}
|
|
3124
3034
|
};
|
|
@@ -3201,14 +3111,6 @@
|
|
|
3201
3111
|
// eslint-disable-next-line max-len
|
|
3202
3112
|
domSelection.setBaseAndExtent(newDomRange_1.startContainer, newDomRange_1.startOffset, newDomRange_1.endContainer, newDomRange_1.endOffset);
|
|
3203
3113
|
}
|
|
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
3114
|
}
|
|
3213
3115
|
setTimeout(function () {
|
|
3214
3116
|
// COMPAT: In Firefox, it's not enough to create a range, you also need
|
|
@@ -3245,7 +3147,7 @@
|
|
|
3245
3147
|
// need exec after this.cdr.detectChanges() to render HTML
|
|
3246
3148
|
// need exec before this.toNativeSelection() to correct native selection
|
|
3247
3149
|
if (this.isComposing) {
|
|
3248
|
-
//
|
|
3150
|
+
// Composition input text be not rendered when user composition input with selection is expanded
|
|
3249
3151
|
// At this time, the following matching conditions are met, assign isComposing to false, and the status is wrong
|
|
3250
3152
|
// this time condition is true and isComposiing is assigned false
|
|
3251
3153
|
// Therefore, need to wait for the composition input text to be rendered before performing condition matching
|
|
@@ -3278,7 +3180,7 @@
|
|
|
3278
3180
|
this.context = {
|
|
3279
3181
|
parent: this.editor,
|
|
3280
3182
|
selection: this.editor.selection,
|
|
3281
|
-
decorations: this.
|
|
3183
|
+
decorations: this.generateDecorations(),
|
|
3282
3184
|
decorate: this.decorate,
|
|
3283
3185
|
readonly: this.readonly
|
|
3284
3186
|
};
|
|
@@ -3295,20 +3197,49 @@
|
|
|
3295
3197
|
};
|
|
3296
3198
|
};
|
|
3297
3199
|
SlateEditableComponent.prototype.detectContext = function () {
|
|
3200
|
+
var decorations = this.generateDecorations();
|
|
3298
3201
|
if (this.context.selection !== this.editor.selection ||
|
|
3299
3202
|
this.context.decorate !== this.decorate ||
|
|
3300
|
-
this.context.readonly !== this.readonly
|
|
3301
|
-
|
|
3302
|
-
var isSameDecorations = isDecoratorRangeListEqual(this.context.decorations, decorations);
|
|
3203
|
+
this.context.readonly !== this.readonly ||
|
|
3204
|
+
!isDecoratorRangeListEqual(this.context.decorations, decorations)) {
|
|
3303
3205
|
this.context = {
|
|
3304
3206
|
parent: this.editor,
|
|
3305
3207
|
selection: this.editor.selection,
|
|
3306
|
-
decorations:
|
|
3208
|
+
decorations: decorations,
|
|
3307
3209
|
decorate: this.decorate,
|
|
3308
3210
|
readonly: this.readonly
|
|
3309
3211
|
};
|
|
3310
3212
|
}
|
|
3311
3213
|
};
|
|
3214
|
+
SlateEditableComponent.prototype.composePlaceholderDecorate = function (editor) {
|
|
3215
|
+
if (this.placeholderDecorate) {
|
|
3216
|
+
return this.placeholderDecorate(editor) || [];
|
|
3217
|
+
}
|
|
3218
|
+
if (this.placeholder &&
|
|
3219
|
+
editor.children.length === 1 &&
|
|
3220
|
+
Array.from(slate.Node.texts(editor)).length === 1 &&
|
|
3221
|
+
slate.Node.string(editor) === '') {
|
|
3222
|
+
var start = slate.Editor.start(editor, []);
|
|
3223
|
+
return [
|
|
3224
|
+
{
|
|
3225
|
+
placeholder: this.placeholder,
|
|
3226
|
+
anchor: start,
|
|
3227
|
+
focus: start,
|
|
3228
|
+
},
|
|
3229
|
+
];
|
|
3230
|
+
}
|
|
3231
|
+
else {
|
|
3232
|
+
return [];
|
|
3233
|
+
}
|
|
3234
|
+
};
|
|
3235
|
+
SlateEditableComponent.prototype.generateDecorations = function () {
|
|
3236
|
+
var decorations = this.decorate([this.editor, []]);
|
|
3237
|
+
var placeholderDecorations = this.isComposing
|
|
3238
|
+
? []
|
|
3239
|
+
: this.composePlaceholderDecorate(this.editor);
|
|
3240
|
+
decorations.push.apply(decorations, __spreadArray([], __read(placeholderDecorations)));
|
|
3241
|
+
return decorations;
|
|
3242
|
+
};
|
|
3312
3243
|
//#region event proxy
|
|
3313
3244
|
SlateEditableComponent.prototype.addEventListener = function (eventName, listener, target) {
|
|
3314
3245
|
var _this = this;
|
|
@@ -3529,6 +3460,8 @@
|
|
|
3529
3460
|
// so we need avoid repeat isnertText by isComposing === true,
|
|
3530
3461
|
this.isComposing = false;
|
|
3531
3462
|
}
|
|
3463
|
+
this.detectContext();
|
|
3464
|
+
this.cdr.detectChanges();
|
|
3532
3465
|
};
|
|
3533
3466
|
SlateEditableComponent.prototype.onDOMCompositionStart = function (event) {
|
|
3534
3467
|
var selection = this.editor.selection;
|
|
@@ -3542,6 +3475,8 @@
|
|
|
3542
3475
|
if (hasEditableTarget(this.editor, event.target) && !this.isDOMEventHandled(event, this.compositionStart)) {
|
|
3543
3476
|
this.isComposing = true;
|
|
3544
3477
|
}
|
|
3478
|
+
this.detectContext();
|
|
3479
|
+
this.cdr.detectChanges();
|
|
3545
3480
|
};
|
|
3546
3481
|
SlateEditableComponent.prototype.onDOMCopy = function (event) {
|
|
3547
3482
|
var window = AngularEditor.getWindow(this.editor);
|
|
@@ -3811,6 +3746,25 @@
|
|
|
3811
3746
|
return;
|
|
3812
3747
|
}
|
|
3813
3748
|
}
|
|
3749
|
+
else {
|
|
3750
|
+
if (IS_CHROME || IS_SAFARI) {
|
|
3751
|
+
// COMPAT: Chrome and Safari support `beforeinput` event but do not fire
|
|
3752
|
+
// an event when deleting backwards in a selected void inline node
|
|
3753
|
+
if (selection &&
|
|
3754
|
+
(hotkeys.isDeleteBackward(nativeEvent) ||
|
|
3755
|
+
hotkeys.isDeleteForward(nativeEvent)) &&
|
|
3756
|
+
slate.Range.isCollapsed(selection)) {
|
|
3757
|
+
var currentNode = slate.Node.parent(editor, selection.anchor.path);
|
|
3758
|
+
if (slate.Element.isElement(currentNode) &&
|
|
3759
|
+
slate.Editor.isVoid(editor, currentNode) &&
|
|
3760
|
+
slate.Editor.isInline(editor, currentNode)) {
|
|
3761
|
+
event.preventDefault();
|
|
3762
|
+
slate.Editor.deleteBackward(editor, { unit: 'block' });
|
|
3763
|
+
return;
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3814
3768
|
}
|
|
3815
3769
|
catch (error) {
|
|
3816
3770
|
this.editor.onError({ code: exports.SlateErrorCode.OnDOMKeydownError, nativeError: error });
|
|
@@ -3845,7 +3799,7 @@
|
|
|
3845
3799
|
if (!slate.Range.isCollapsed(this.editor.selection)) {
|
|
3846
3800
|
slate.Editor.deleteFragment(this.editor);
|
|
3847
3801
|
}
|
|
3848
|
-
// just handle Non-IME input
|
|
3802
|
+
// just handle Non-IME input
|
|
3849
3803
|
if (!this.isComposing) {
|
|
3850
3804
|
slate.Editor.insertText(this.editor, text);
|
|
3851
3805
|
}
|
|
@@ -3874,11 +3828,11 @@
|
|
|
3874
3828
|
return SlateEditableComponent;
|
|
3875
3829
|
}());
|
|
3876
3830
|
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 });
|
|
3877
|
-
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: [{
|
|
3831
|
+
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: [{
|
|
3878
3832
|
provide: forms.NG_VALUE_ACCESSOR,
|
|
3879
3833
|
useExisting: i0.forwardRef(function () { return SlateEditableComponent; }),
|
|
3880
3834
|
multi: true
|
|
3881
|
-
}], 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\"
|
|
3835
|
+
}], 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 });
|
|
3882
3836
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SlateEditableComponent, decorators: [{
|
|
3883
3837
|
type: i0.Component,
|
|
3884
3838
|
args: [{
|
|
@@ -3909,12 +3863,16 @@
|
|
|
3909
3863
|
type: i0.Input
|
|
3910
3864
|
}], decorate: [{
|
|
3911
3865
|
type: i0.Input
|
|
3866
|
+
}], placeholderDecorate: [{
|
|
3867
|
+
type: i0.Input
|
|
3912
3868
|
}], isStrictDecorate: [{
|
|
3913
3869
|
type: i0.Input
|
|
3914
3870
|
}], trackBy: [{
|
|
3915
3871
|
type: i0.Input
|
|
3916
3872
|
}], readonly: [{
|
|
3917
3873
|
type: i0.Input
|
|
3874
|
+
}], placeholder: [{
|
|
3875
|
+
type: i0.Input
|
|
3918
3876
|
}], beforeInput: [{
|
|
3919
3877
|
type: i0.Input
|
|
3920
3878
|
}], blur: [{
|