slate-angular 14.1.1 → 14.1.3
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/esm2020/components/editable/editable.component.mjs +5 -7
- package/esm2020/utils/environment.mjs +3 -3
- package/esm2020/view/base.mjs +17 -7
- package/fesm2015/slate-angular.mjs +22 -14
- package/fesm2015/slate-angular.mjs.map +1 -1
- package/fesm2020/slate-angular.mjs +22 -14
- package/fesm2020/slate-angular.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/index.scss +1 -1
- package/view/base.d.ts +2 -0
|
@@ -4,7 +4,6 @@ import * as i0 from '@angular/core';
|
|
|
4
4
|
import { TemplateRef, Component, ChangeDetectionStrategy, ViewChild, Directive, Input, HostBinding, ViewChildren, InjectionToken, Inject, forwardRef, ElementRef, NgModule } from '@angular/core';
|
|
5
5
|
import getDirection from 'direction';
|
|
6
6
|
import { Subject } from 'rxjs';
|
|
7
|
-
import Debug from 'debug';
|
|
8
7
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
9
8
|
import { HistoryEditor } from 'slate-history';
|
|
10
9
|
import * as i1 from '@angular/common';
|
|
@@ -261,7 +260,7 @@ const IS_SAFARI = typeof navigator !== 'undefined' &&
|
|
|
261
260
|
/Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
|
|
262
261
|
// "modern" Edge was released at 79.x
|
|
263
262
|
const IS_EDGE_LEGACY = typeof navigator !== 'undefined' &&
|
|
264
|
-
/Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
|
|
263
|
+
/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent);
|
|
265
264
|
const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent);
|
|
266
265
|
// Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
|
|
267
266
|
const IS_CHROME_LEGACY = typeof navigator !== 'undefined' &&
|
|
@@ -270,7 +269,7 @@ const IS_CHROME_LEGACY = typeof navigator !== 'undefined' &&
|
|
|
270
269
|
!/Chrome?\/(?:\d{3,})/i.test(navigator.userAgent);
|
|
271
270
|
// Firefox did not support `beforeInput` until `v87`.
|
|
272
271
|
const IS_FIREFOX_LEGACY = typeof navigator !== 'undefined' &&
|
|
273
|
-
/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])).*/i.test(navigator.userAgent);
|
|
272
|
+
/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent);
|
|
274
273
|
// qq browser
|
|
275
274
|
const IS_QQBROWSER = typeof navigator !== 'undefined' && /.*QQBrowser/.test(navigator.userAgent);
|
|
276
275
|
// UC mobile browser
|
|
@@ -1839,18 +1838,28 @@ class BaseLeafComponent extends BaseComponent {
|
|
|
1839
1838
|
// Issue occurs when the span node of the placeholder is before the slateString span node
|
|
1840
1839
|
if (this.context.leaf['placeholder']) {
|
|
1841
1840
|
if (!this.placeholderElement) {
|
|
1842
|
-
this.
|
|
1843
|
-
this.placeholderElement.innerText = this.context.leaf['placeholder'];
|
|
1844
|
-
this.placeholderElement.contentEditable = 'false';
|
|
1845
|
-
this.placeholderElement.setAttribute('data-slate-placeholder', 'true');
|
|
1846
|
-
this.nativeElement.classList.add('leaf-with-placeholder');
|
|
1847
|
-
this.nativeElement.appendChild(this.placeholderElement);
|
|
1841
|
+
this.createPlaceholder();
|
|
1848
1842
|
}
|
|
1843
|
+
this.updatePlaceholder();
|
|
1849
1844
|
}
|
|
1850
1845
|
else {
|
|
1851
1846
|
this.destroyPlaceholder();
|
|
1852
1847
|
}
|
|
1853
1848
|
}
|
|
1849
|
+
createPlaceholder() {
|
|
1850
|
+
const placeholderElement = document.createElement('span');
|
|
1851
|
+
placeholderElement.innerText = this.context.leaf['placeholder'];
|
|
1852
|
+
placeholderElement.contentEditable = 'false';
|
|
1853
|
+
placeholderElement.setAttribute('data-slate-placeholder', 'true');
|
|
1854
|
+
this.placeholderElement = placeholderElement;
|
|
1855
|
+
this.nativeElement.classList.add('leaf-with-placeholder');
|
|
1856
|
+
this.nativeElement.appendChild(placeholderElement);
|
|
1857
|
+
}
|
|
1858
|
+
updatePlaceholder() {
|
|
1859
|
+
if (this.placeholderElement.innerText !== this.context.leaf['placeholder']) {
|
|
1860
|
+
this.placeholderElement.innerText = this.context.leaf['placeholder'];
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1854
1863
|
destroyPlaceholder() {
|
|
1855
1864
|
if (this.placeholderElement) {
|
|
1856
1865
|
this.placeholderElement.remove();
|
|
@@ -2520,7 +2529,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
2520
2529
|
args: [SlateDescendantComponent, { read: SlateDescendantComponent }]
|
|
2521
2530
|
}] } });
|
|
2522
2531
|
|
|
2523
|
-
const timeDebug = Debug('slate-angular-time');
|
|
2524
2532
|
// not correctly clipboardData on beforeinput
|
|
2525
2533
|
const forceOnDOMPaste = IS_SAFARI;
|
|
2526
2534
|
class SlateEditableComponent {
|
|
@@ -2587,6 +2595,10 @@ class SlateEditableComponent {
|
|
|
2587
2595
|
if (decorateChange) {
|
|
2588
2596
|
this.forceFlush();
|
|
2589
2597
|
}
|
|
2598
|
+
const placeholderChange = simpleChanges['placeholder'];
|
|
2599
|
+
if (placeholderChange) {
|
|
2600
|
+
this.detectContext();
|
|
2601
|
+
}
|
|
2590
2602
|
const readonlyChange = simpleChanges['readonly'];
|
|
2591
2603
|
if (readonlyChange) {
|
|
2592
2604
|
IS_READONLY.set(this.editor, this.readonly);
|
|
@@ -2721,13 +2733,10 @@ class SlateEditableComponent {
|
|
|
2721
2733
|
this.onChangeCallback(this.editor.children);
|
|
2722
2734
|
}
|
|
2723
2735
|
ngAfterViewChecked() {
|
|
2724
|
-
timeDebug('editable ngAfterViewChecked');
|
|
2725
2736
|
}
|
|
2726
2737
|
ngDoCheck() {
|
|
2727
|
-
timeDebug('editable ngDoCheck');
|
|
2728
2738
|
}
|
|
2729
2739
|
forceFlush() {
|
|
2730
|
-
timeDebug('start data sync');
|
|
2731
2740
|
this.detectContext();
|
|
2732
2741
|
this.cdr.detectChanges();
|
|
2733
2742
|
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
@@ -2764,7 +2773,6 @@ class SlateEditableComponent {
|
|
|
2764
2773
|
}, 0);
|
|
2765
2774
|
}
|
|
2766
2775
|
this.toNativeSelection();
|
|
2767
|
-
timeDebug('end data sync');
|
|
2768
2776
|
}
|
|
2769
2777
|
initializeContext() {
|
|
2770
2778
|
this.context = {
|