slate-angular 20.2.0-next.13 → 20.2.0-next.15
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 +64 -30
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -353,6 +353,17 @@ const CustomDOMEditor = {
|
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Symbols.
|
|
358
|
+
*/
|
|
359
|
+
const PLACEHOLDER_SYMBOL = Symbol('placeholder');
|
|
360
|
+
/**
|
|
361
|
+
* Weak map for associating the html element with the component.
|
|
362
|
+
*/
|
|
363
|
+
const ELEMENT_TO_COMPONENT = new WeakMap();
|
|
364
|
+
const IS_ENABLED_VIRTUAL_SCROLL = new WeakMap();
|
|
365
|
+
const EDITOR_TO_AFTER_VIEW_INIT_QUEUE = new WeakMap();
|
|
366
|
+
|
|
356
367
|
const AngularEditor = {
|
|
357
368
|
...CustomDOMEditor,
|
|
358
369
|
/**
|
|
@@ -424,19 +435,12 @@ const AngularEditor = {
|
|
|
424
435
|
// FocusedContext is updated to the correct value
|
|
425
436
|
el.focus({ preventScroll: true });
|
|
426
437
|
}
|
|
438
|
+
},
|
|
439
|
+
isEnabledVirtualScroll(editor) {
|
|
440
|
+
return IS_ENABLED_VIRTUAL_SCROLL.get(editor);
|
|
427
441
|
}
|
|
428
442
|
};
|
|
429
443
|
|
|
430
|
-
/**
|
|
431
|
-
* Symbols.
|
|
432
|
-
*/
|
|
433
|
-
const PLACEHOLDER_SYMBOL = Symbol('placeholder');
|
|
434
|
-
/**
|
|
435
|
-
* Weak map for associating the html element with the component.
|
|
436
|
-
*/
|
|
437
|
-
const ELEMENT_TO_COMPONENT = new WeakMap();
|
|
438
|
-
const EDITOR_TO_AFTER_VIEW_INIT_QUEUE = new WeakMap();
|
|
439
|
-
|
|
440
444
|
const IS_IOS = typeof navigator !== 'undefined' &&
|
|
441
445
|
typeof window !== 'undefined' &&
|
|
442
446
|
/iPad|iPhone|iPod/.test(navigator.userAgent) &&
|
|
@@ -1801,6 +1805,7 @@ class BaseElementFlavour extends BaseFlavour {
|
|
|
1801
1805
|
if (ELEMENT_TO_COMPONENT.get(this.element) === this) {
|
|
1802
1806
|
ELEMENT_TO_COMPONENT.delete(this.element);
|
|
1803
1807
|
}
|
|
1808
|
+
this.listRender.destroy();
|
|
1804
1809
|
this.nativeElement?.remove();
|
|
1805
1810
|
}
|
|
1806
1811
|
onContextChange() {
|
|
@@ -2197,6 +2202,9 @@ class LeavesRender {
|
|
|
2197
2202
|
});
|
|
2198
2203
|
return { decoratedLeaves, contexts };
|
|
2199
2204
|
}
|
|
2205
|
+
destroy() {
|
|
2206
|
+
this.views.forEach(view => view.destroy());
|
|
2207
|
+
}
|
|
2200
2208
|
}
|
|
2201
2209
|
function getContext$1(index, leafContexts) {
|
|
2202
2210
|
return leafContexts[index];
|
|
@@ -2239,6 +2247,7 @@ class BaseTextFlavour extends BaseFlavour {
|
|
|
2239
2247
|
NODE_TO_ELEMENT.delete(this.text);
|
|
2240
2248
|
}
|
|
2241
2249
|
ELEMENT_TO_NODE.delete(this.nativeElement);
|
|
2250
|
+
this.leavesRender.destroy();
|
|
2242
2251
|
this.nativeElement?.remove();
|
|
2243
2252
|
}
|
|
2244
2253
|
onContextChange() {
|
|
@@ -3075,7 +3084,10 @@ const isDebug = localStorage.getItem(SLATE_DEBUG_KEY) === 'true';
|
|
|
3075
3084
|
class SlateEditable {
|
|
3076
3085
|
set virtualScroll(config) {
|
|
3077
3086
|
this.virtualScrollConfig = config;
|
|
3078
|
-
this.
|
|
3087
|
+
IS_ENABLED_VIRTUAL_SCROLL.set(this.editor, config.enabled);
|
|
3088
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3089
|
+
this.tryUpdateVirtualViewport();
|
|
3090
|
+
}
|
|
3079
3091
|
}
|
|
3080
3092
|
get hasBeforeInputSupport() {
|
|
3081
3093
|
return HAS_BEFORE_INPUT_SUPPORT;
|
|
@@ -3187,16 +3199,26 @@ class SlateEditable {
|
|
|
3187
3199
|
if (value && value.length) {
|
|
3188
3200
|
this.editor.children = value;
|
|
3189
3201
|
this.initializeContext();
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
this.listRender.
|
|
3202
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3203
|
+
const virtualView = this.calculateVirtualViewport();
|
|
3204
|
+
this.applyVirtualView(virtualView);
|
|
3205
|
+
const childrenForRender = virtualView.inViewportChildren;
|
|
3206
|
+
if (!this.listRender.initialized) {
|
|
3207
|
+
this.listRender.initialize(childrenForRender, this.editor, this.context);
|
|
3208
|
+
}
|
|
3209
|
+
else {
|
|
3210
|
+
this.listRender.update(childrenForRender, this.editor, this.context);
|
|
3211
|
+
}
|
|
3212
|
+
this.scheduleMeasureVisibleHeights();
|
|
3195
3213
|
}
|
|
3196
3214
|
else {
|
|
3197
|
-
this.listRender.
|
|
3215
|
+
if (!this.listRender.initialized) {
|
|
3216
|
+
this.listRender.initialize(this.editor.children, this.editor, this.context);
|
|
3217
|
+
}
|
|
3218
|
+
else {
|
|
3219
|
+
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3220
|
+
}
|
|
3198
3221
|
}
|
|
3199
|
-
this.scheduleMeasureVisibleHeights();
|
|
3200
3222
|
this.cdr.markForCheck();
|
|
3201
3223
|
}
|
|
3202
3224
|
}
|
|
@@ -3230,7 +3252,7 @@ class SlateEditable {
|
|
|
3230
3252
|
toNativeSelection() {
|
|
3231
3253
|
try {
|
|
3232
3254
|
let { selection } = this.editor;
|
|
3233
|
-
if (this.
|
|
3255
|
+
if (this.isEnabledVirtualScroll() && selection) {
|
|
3234
3256
|
const indics = Array.from(this.inViewportIndics.values());
|
|
3235
3257
|
if (indics.length > 0) {
|
|
3236
3258
|
const currentVisibleRange = {
|
|
@@ -3335,11 +3357,16 @@ class SlateEditable {
|
|
|
3335
3357
|
ngDoCheck() { }
|
|
3336
3358
|
forceRender() {
|
|
3337
3359
|
this.updateContext();
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3360
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3361
|
+
const virtualView = this.calculateVirtualViewport();
|
|
3362
|
+
this.applyVirtualView(virtualView);
|
|
3363
|
+
this.listRender.update(this.inViewportChildren, this.editor, this.context);
|
|
3364
|
+
const visibleIndexes = Array.from(this.inViewportIndics);
|
|
3365
|
+
this.remeasureHeightByIndics(visibleIndexes);
|
|
3366
|
+
}
|
|
3367
|
+
else {
|
|
3368
|
+
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3369
|
+
}
|
|
3343
3370
|
// repair collaborative editing when Chinese input is interrupted by other users' cursors
|
|
3344
3371
|
// when the DOMElement where the selection is located is removed
|
|
3345
3372
|
// the compositionupdate and compositionend events will no longer be fired
|
|
@@ -3378,10 +3405,15 @@ class SlateEditable {
|
|
|
3378
3405
|
render() {
|
|
3379
3406
|
const changed = this.updateContext();
|
|
3380
3407
|
if (changed) {
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3408
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3409
|
+
const virtualView = this.calculateVirtualViewport();
|
|
3410
|
+
this.applyVirtualView(virtualView);
|
|
3411
|
+
this.listRender.update(virtualView.inViewportChildren, this.editor, this.context);
|
|
3412
|
+
this.scheduleMeasureVisibleHeights();
|
|
3413
|
+
}
|
|
3414
|
+
else {
|
|
3415
|
+
this.listRender.update(this.editor.children, this.editor, this.context);
|
|
3416
|
+
}
|
|
3385
3417
|
}
|
|
3386
3418
|
}
|
|
3387
3419
|
updateContext() {
|
|
@@ -3451,7 +3483,7 @@ class SlateEditable {
|
|
|
3451
3483
|
if (this.virtualScrollInitialized) {
|
|
3452
3484
|
return;
|
|
3453
3485
|
}
|
|
3454
|
-
if (this.
|
|
3486
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3455
3487
|
this.virtualScrollInitialized = true;
|
|
3456
3488
|
this.virtualTopHeightElement = document.createElement('div');
|
|
3457
3489
|
this.virtualTopHeightElement.classList.add('virtual-top-height');
|
|
@@ -4793,6 +4825,7 @@ class BaseElementComponent extends BaseComponent {
|
|
|
4793
4825
|
if (ELEMENT_TO_COMPONENT.get(this.element) === this) {
|
|
4794
4826
|
ELEMENT_TO_COMPONENT.delete(this.element);
|
|
4795
4827
|
}
|
|
4828
|
+
this.listRender.destroy();
|
|
4796
4829
|
}
|
|
4797
4830
|
onContextChange() {
|
|
4798
4831
|
this.childrenContext = this.getChildrenContext();
|
|
@@ -4880,6 +4913,7 @@ class BaseTextComponent extends BaseComponent {
|
|
|
4880
4913
|
NODE_TO_ELEMENT.delete(this.text);
|
|
4881
4914
|
}
|
|
4882
4915
|
ELEMENT_TO_NODE.delete(this.nativeElement);
|
|
4916
|
+
this.leavesRender.destroy();
|
|
4883
4917
|
}
|
|
4884
4918
|
onContextChange() {
|
|
4885
4919
|
this.updateWeakMap();
|
|
@@ -4991,5 +5025,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
4991
5025
|
* Generated bundle index. Do not edit.
|
|
4992
5026
|
*/
|
|
4993
5027
|
|
|
4994
|
-
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, ELEMENT_KEY_TO_HEIGHTS, ELEMENT_TO_COMPONENT, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, FlavourRef, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, JUST_NOW_UPDATED_VIRTUAL_VIEW, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT, VoidTextFlavour, blobAsString, buildHTMLText, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
5028
|
+
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, ELEMENT_KEY_TO_HEIGHTS, ELEMENT_TO_COMPONENT, FAKE_LEFT_BLOCK_CARD_OFFSET, FAKE_RIGHT_BLOCK_CARD_OFFSET, FlavourRef, HAS_BEFORE_INPUT_SUPPORT, IS_ANDROID, IS_APPLE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_ENABLED_VIRTUAL_SCROLL, IS_FIREFOX, IS_FIREFOX_LEGACY, IS_IOS, IS_QQBROWSER, IS_SAFARI, IS_UC_MOBILE, IS_WECHATBROWSER, JUST_NOW_UPDATED_VIRTUAL_VIEW, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT, VoidTextFlavour, blobAsString, buildHTMLText, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
4995
5029
|
//# sourceMappingURL=slate-angular.mjs.map
|