slate-angular 1.7.0 → 1.7.5
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 +64 -22
- package/bundles/slate-angular.umd.js.map +1 -1
- package/components/editable/editable.component.d.ts +1 -0
- package/components/leaf/default-leaf.component.d.ts +4 -1
- package/esm2015/components/editable/editable.component.js +29 -19
- package/esm2015/components/leaf/default-leaf.component.js +11 -12
- package/esm2015/view/base.js +27 -2
- package/fesm2015/slate-angular.js +64 -29
- package/fesm2015/slate-angular.js.map +1 -1
- package/package.json +7 -7
- package/styles/index.scss +20 -4
- package/view/base.d.ts +3 -0
|
@@ -2177,6 +2177,31 @@
|
|
|
2177
2177
|
}
|
|
2178
2178
|
this.cdr.markForCheck();
|
|
2179
2179
|
};
|
|
2180
|
+
BaseLeafComponent.prototype.renderPlaceholder = function () {
|
|
2181
|
+
// issue-1: IME input was interrupted
|
|
2182
|
+
// issue-2: IME input focus jumping
|
|
2183
|
+
// Issue occurs when the span node of the placeholder is before the slateString span node
|
|
2184
|
+
if (this.context.leaf['placeholder']) {
|
|
2185
|
+
if (!this.placeholderElement) {
|
|
2186
|
+
this.placeholderElement = document.createElement('span');
|
|
2187
|
+
this.placeholderElement.innerText = this.context.leaf['placeholder'];
|
|
2188
|
+
this.placeholderElement.contentEditable = 'false';
|
|
2189
|
+
this.placeholderElement.setAttribute('data-slate-placeholder', 'true');
|
|
2190
|
+
this.nativeElement.classList.add('leaf-with-placeholder');
|
|
2191
|
+
this.nativeElement.appendChild(this.placeholderElement);
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
else {
|
|
2195
|
+
this.destroyPlaceholder();
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
BaseLeafComponent.prototype.destroyPlaceholder = function () {
|
|
2199
|
+
if (this.placeholderElement) {
|
|
2200
|
+
this.placeholderElement.remove();
|
|
2201
|
+
this.placeholderElement = null;
|
|
2202
|
+
this.nativeElement.classList.remove('leaf-with-placeholder');
|
|
2203
|
+
}
|
|
2204
|
+
};
|
|
2180
2205
|
return BaseLeafComponent;
|
|
2181
2206
|
}(BaseComponent));
|
|
2182
2207
|
BaseLeafComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: BaseLeafComponent, deps: null, target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
@@ -2295,7 +2320,7 @@
|
|
|
2295
2320
|
}
|
|
2296
2321
|
Object.defineProperty(BaseTextComponent.prototype, "text", {
|
|
2297
2322
|
get: function () {
|
|
2298
|
-
return this._context.text;
|
|
2323
|
+
return this._context && this._context.text;
|
|
2299
2324
|
},
|
|
2300
2325
|
enumerable: false,
|
|
2301
2326
|
configurable: true
|
|
@@ -2503,15 +2528,23 @@
|
|
|
2503
2528
|
function SlateDefaultLeafComponent() {
|
|
2504
2529
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
2505
2530
|
}
|
|
2531
|
+
SlateDefaultLeafComponent.prototype.onContextChange = function () {
|
|
2532
|
+
_super.prototype.onContextChange.call(this);
|
|
2533
|
+
this.renderPlaceholder();
|
|
2534
|
+
};
|
|
2535
|
+
SlateDefaultLeafComponent.prototype.ngOnDestroy = function () {
|
|
2536
|
+
// Because the placeholder span is not in the current component, it is destroyed along with the current component
|
|
2537
|
+
this.destroyPlaceholder();
|
|
2538
|
+
};
|
|
2506
2539
|
return SlateDefaultLeafComponent;
|
|
2507
2540
|
}(BaseLeafComponent));
|
|
2508
2541
|
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 });
|
|
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: "
|
|
2542
|
+
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 });
|
|
2510
2543
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SlateDefaultLeafComponent, decorators: [{
|
|
2511
2544
|
type: i0.Component,
|
|
2512
2545
|
args: [{
|
|
2513
2546
|
selector: 'span[slateDefaultLeaf]',
|
|
2514
|
-
template: "
|
|
2547
|
+
template: "<span slateString [context]=\"context\" [viewContext]=\"viewContext\"><span>",
|
|
2515
2548
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
2516
2549
|
host: {
|
|
2517
2550
|
'data-slate-leaf': 'true'
|
|
@@ -2938,7 +2971,6 @@
|
|
|
2938
2971
|
var forceOnDOMPaste = IS_SAFARI;
|
|
2939
2972
|
var SlateEditableComponent = /** @class */ (function () {
|
|
2940
2973
|
function SlateEditableComponent(elementRef, renderer2, cdr, ngZone, injector) {
|
|
2941
|
-
var _this = this;
|
|
2942
2974
|
this.elementRef = elementRef;
|
|
2943
2975
|
this.renderer2 = renderer2;
|
|
2944
2976
|
this.cdr = cdr;
|
|
@@ -2953,22 +2985,6 @@
|
|
|
2953
2985
|
this.onTouchedCallback = function () { };
|
|
2954
2986
|
this.onChangeCallback = function () { };
|
|
2955
2987
|
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
|
-
};
|
|
2972
2988
|
this.isStrictDecorate = true;
|
|
2973
2989
|
this.trackBy = function () { return null; };
|
|
2974
2990
|
this.readonly = false;
|
|
@@ -3010,6 +3026,9 @@
|
|
|
3010
3026
|
this.initializeContext();
|
|
3011
3027
|
// remove unused DOM, just keep templateComponent instance
|
|
3012
3028
|
this.templateElementRef.nativeElement.remove();
|
|
3029
|
+
// add browser class
|
|
3030
|
+
var browserClass = IS_FIREFOX ? 'firefox' : (IS_SAFARI ? 'safari' : '');
|
|
3031
|
+
browserClass && this.elementRef.nativeElement.classList.add(browserClass);
|
|
3013
3032
|
};
|
|
3014
3033
|
SlateEditableComponent.prototype.ngOnChanges = function (simpleChanges) {
|
|
3015
3034
|
if (!this.initialized) {
|
|
@@ -3228,9 +3247,32 @@
|
|
|
3228
3247
|
};
|
|
3229
3248
|
}
|
|
3230
3249
|
};
|
|
3250
|
+
SlateEditableComponent.prototype.composePlaceholderDecorate = function (editor) {
|
|
3251
|
+
if (this.placeholderDecorate) {
|
|
3252
|
+
return this.placeholderDecorate(editor) || [];
|
|
3253
|
+
}
|
|
3254
|
+
if (this.placeholder &&
|
|
3255
|
+
editor.children.length === 1 &&
|
|
3256
|
+
Array.from(slate.Node.texts(editor)).length === 1 &&
|
|
3257
|
+
slate.Node.string(editor) === '') {
|
|
3258
|
+
var start = slate.Editor.start(editor, []);
|
|
3259
|
+
return [
|
|
3260
|
+
{
|
|
3261
|
+
placeholder: this.placeholder,
|
|
3262
|
+
anchor: start,
|
|
3263
|
+
focus: start,
|
|
3264
|
+
},
|
|
3265
|
+
];
|
|
3266
|
+
}
|
|
3267
|
+
else {
|
|
3268
|
+
return [];
|
|
3269
|
+
}
|
|
3270
|
+
};
|
|
3231
3271
|
SlateEditableComponent.prototype.generateDecorations = function () {
|
|
3232
3272
|
var decorations = this.decorate([this.editor, []]);
|
|
3233
|
-
var placeholderDecorations = this.isComposing
|
|
3273
|
+
var placeholderDecorations = this.isComposing
|
|
3274
|
+
? []
|
|
3275
|
+
: this.composePlaceholderDecorate(this.editor);
|
|
3234
3276
|
decorations.push.apply(decorations, __spreadArray([], __read(placeholderDecorations)));
|
|
3235
3277
|
return decorations;
|
|
3236
3278
|
};
|
|
@@ -3793,7 +3835,7 @@
|
|
|
3793
3835
|
if (!slate.Range.isCollapsed(this.editor.selection)) {
|
|
3794
3836
|
slate.Editor.deleteFragment(this.editor);
|
|
3795
3837
|
}
|
|
3796
|
-
// just handle Non-IME input
|
|
3838
|
+
// just handle Non-IME input
|
|
3797
3839
|
if (!this.isComposing) {
|
|
3798
3840
|
slate.Editor.insertText(this.editor, text);
|
|
3799
3841
|
}
|