slate-angular 20.2.0-next.13 → 20.2.0-next.14
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/fesm2022/slate-angular.mjs +48 -19
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1801,6 +1801,7 @@ class BaseElementFlavour extends BaseFlavour {
|
|
|
1801
1801
|
if (ELEMENT_TO_COMPONENT.get(this.element) === this) {
|
|
1802
1802
|
ELEMENT_TO_COMPONENT.delete(this.element);
|
|
1803
1803
|
}
|
|
1804
|
+
this.listRender.destroy();
|
|
1804
1805
|
this.nativeElement?.remove();
|
|
1805
1806
|
}
|
|
1806
1807
|
onContextChange() {
|
|
@@ -2197,6 +2198,9 @@ class LeavesRender {
|
|
|
2197
2198
|
});
|
|
2198
2199
|
return { decoratedLeaves, contexts };
|
|
2199
2200
|
}
|
|
2201
|
+
destroy() {
|
|
2202
|
+
this.views.forEach(view => view.destroy());
|
|
2203
|
+
}
|
|
2200
2204
|
}
|
|
2201
2205
|
function getContext$1(index, leafContexts) {
|
|
2202
2206
|
return leafContexts[index];
|
|
@@ -2239,6 +2243,7 @@ class BaseTextFlavour extends BaseFlavour {
|
|
|
2239
2243
|
NODE_TO_ELEMENT.delete(this.text);
|
|
2240
2244
|
}
|
|
2241
2245
|
ELEMENT_TO_NODE.delete(this.nativeElement);
|
|
2246
|
+
this.leavesRender.destroy();
|
|
2242
2247
|
this.nativeElement?.remove();
|
|
2243
2248
|
}
|
|
2244
2249
|
onContextChange() {
|
|
@@ -3075,7 +3080,9 @@ const isDebug = localStorage.getItem(SLATE_DEBUG_KEY) === 'true';
|
|
|
3075
3080
|
class SlateEditable {
|
|
3076
3081
|
set virtualScroll(config) {
|
|
3077
3082
|
this.virtualScrollConfig = config;
|
|
3078
|
-
this.
|
|
3083
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3084
|
+
this.tryUpdateVirtualViewport();
|
|
3085
|
+
}
|
|
3079
3086
|
}
|
|
3080
3087
|
get hasBeforeInputSupport() {
|
|
3081
3088
|
return HAS_BEFORE_INPUT_SUPPORT;
|
|
@@ -3187,16 +3194,26 @@ class SlateEditable {
|
|
|
3187
3194
|
if (value && value.length) {
|
|
3188
3195
|
this.editor.children = value;
|
|
3189
3196
|
this.initializeContext();
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
this.listRender.
|
|
3197
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3198
|
+
const virtualView = this.calculateVirtualViewport();
|
|
3199
|
+
this.applyVirtualView(virtualView);
|
|
3200
|
+
const childrenForRender = virtualView.inViewportChildren;
|
|
3201
|
+
if (!this.listRender.initialized) {
|
|
3202
|
+
this.listRender.initialize(childrenForRender, this.editor, this.context);
|
|
3203
|
+
}
|
|
3204
|
+
else {
|
|
3205
|
+
this.listRender.update(childrenForRender, this.editor, this.context);
|
|
3206
|
+
}
|
|
3207
|
+
this.scheduleMeasureVisibleHeights();
|
|
3195
3208
|
}
|
|
3196
3209
|
else {
|
|
3197
|
-
this.listRender.
|
|
3210
|
+
if (!this.listRender.initialized) {
|
|
3211
|
+
this.listRender.initialize(this.editor.children, this.editor, this.context);
|
|
3212
|
+
}
|
|
3213
|
+
else {
|
|
3214
|
+
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3215
|
+
}
|
|
3198
3216
|
}
|
|
3199
|
-
this.scheduleMeasureVisibleHeights();
|
|
3200
3217
|
this.cdr.markForCheck();
|
|
3201
3218
|
}
|
|
3202
3219
|
}
|
|
@@ -3230,7 +3247,7 @@ class SlateEditable {
|
|
|
3230
3247
|
toNativeSelection() {
|
|
3231
3248
|
try {
|
|
3232
3249
|
let { selection } = this.editor;
|
|
3233
|
-
if (this.
|
|
3250
|
+
if (this.isEnabledVirtualScroll() && selection) {
|
|
3234
3251
|
const indics = Array.from(this.inViewportIndics.values());
|
|
3235
3252
|
if (indics.length > 0) {
|
|
3236
3253
|
const currentVisibleRange = {
|
|
@@ -3335,11 +3352,16 @@ class SlateEditable {
|
|
|
3335
3352
|
ngDoCheck() { }
|
|
3336
3353
|
forceRender() {
|
|
3337
3354
|
this.updateContext();
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3355
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3356
|
+
const virtualView = this.calculateVirtualViewport();
|
|
3357
|
+
this.applyVirtualView(virtualView);
|
|
3358
|
+
this.listRender.update(this.inViewportChildren, this.editor, this.context);
|
|
3359
|
+
const visibleIndexes = Array.from(this.inViewportIndics);
|
|
3360
|
+
this.remeasureHeightByIndics(visibleIndexes);
|
|
3361
|
+
}
|
|
3362
|
+
else {
|
|
3363
|
+
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3364
|
+
}
|
|
3343
3365
|
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
3344
3366
|
// when the DOMElement where the selection is located is removed
|
|
3345
3367
|
// the compositionupdate and compositionend events will no longer be fired
|
|
@@ -3378,10 +3400,15 @@ class SlateEditable {
|
|
|
3378
3400
|
render() {
|
|
3379
3401
|
const changed = this.updateContext();
|
|
3380
3402
|
if (changed) {
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3403
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3404
|
+
const virtualView = this.calculateVirtualViewport();
|
|
3405
|
+
this.applyVirtualView(virtualView);
|
|
3406
|
+
this.listRender.update(virtualView.inViewportChildren, this.editor, this.context);
|
|
3407
|
+
this.scheduleMeasureVisibleHeights();
|
|
3408
|
+
}
|
|
3409
|
+
else {
|
|
3410
|
+
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3411
|
+
}
|
|
3385
3412
|
}
|
|
3386
3413
|
}
|
|
3387
3414
|
updateContext() {
|
|
@@ -3451,7 +3478,7 @@ class SlateEditable {
|
|
|
3451
3478
|
if (this.virtualScrollInitialized) {
|
|
3452
3479
|
return;
|
|
3453
3480
|
}
|
|
3454
|
-
if (this.
|
|
3481
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3455
3482
|
this.virtualScrollInitialized = true;
|
|
3456
3483
|
this.virtualTopHeightElement = document.createElement('div');
|
|
3457
3484
|
this.virtualTopHeightElement.classList.add('virtual-top-height');
|
|
@@ -4793,6 +4820,7 @@ class BaseElementComponent extends BaseComponent {
|
|
|
4793
4820
|
if (ELEMENT_TO_COMPONENT.get(this.element) === this) {
|
|
4794
4821
|
ELEMENT_TO_COMPONENT.delete(this.element);
|
|
4795
4822
|
}
|
|
4823
|
+
this.listRender.destroy();
|
|
4796
4824
|
}
|
|
4797
4825
|
onContextChange() {
|
|
4798
4826
|
this.childrenContext = this.getChildrenContext();
|
|
@@ -4880,6 +4908,7 @@ class BaseTextComponent extends BaseComponent {
|
|
|
4880
4908
|
NODE_TO_ELEMENT.delete(this.text);
|
|
4881
4909
|
}
|
|
4882
4910
|
ELEMENT_TO_NODE.delete(this.nativeElement);
|
|
4911
|
+
this.leavesRender.destroy();
|
|
4883
4912
|
}
|
|
4884
4913
|
onContextChange() {
|
|
4885
4914
|
this.updateWeakMap();
|