slate-angular 20.2.12 → 20.2.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 +34 -21
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1498,6 +1498,9 @@ const ELEMENT_KEY_TO_HEIGHTS = new WeakMap();
|
|
|
1498
1498
|
const EDITOR_TO_BUSINESS_TOP = new WeakMap();
|
|
1499
1499
|
const EDITOR_TO_ROOT_NODE_WIDTH = new WeakMap();
|
|
1500
1500
|
const EDITOR_TO_IS_FROM_SCROLL_TO = new WeakMap();
|
|
1501
|
+
const isValidNumber = (value) => {
|
|
1502
|
+
return typeof value === 'number' && !Number.isNaN(value);
|
|
1503
|
+
};
|
|
1501
1504
|
const debugLog = (type, ...args) => {
|
|
1502
1505
|
const doc = document;
|
|
1503
1506
|
VirtualScrollDebugOverlay.log(doc, type, ...args);
|
|
@@ -1506,7 +1509,7 @@ const cacheHeightByElement = (editor, element, height) => {
|
|
|
1506
1509
|
if (!AngularEditor.isEnabledVirtualScroll(editor)) {
|
|
1507
1510
|
return;
|
|
1508
1511
|
}
|
|
1509
|
-
if (
|
|
1512
|
+
if (!isValidNumber(height)) {
|
|
1510
1513
|
console.error('cacheHeightByElement: height must be number', height);
|
|
1511
1514
|
return;
|
|
1512
1515
|
}
|
|
@@ -1565,9 +1568,11 @@ const measureHeightByIndics = (editor, indics, force = false) => {
|
|
|
1565
1568
|
}
|
|
1566
1569
|
return;
|
|
1567
1570
|
}
|
|
1568
|
-
hasChanged = true;
|
|
1569
1571
|
const currentHeight = calcHeightByElement(editor, element);
|
|
1570
|
-
if (
|
|
1572
|
+
if (isValidNumber(currentHeight) && currentHeight !== preHeight) {
|
|
1573
|
+
hasChanged = true;
|
|
1574
|
+
}
|
|
1575
|
+
if (isDebug && isValidNumber(currentHeight)) {
|
|
1571
1576
|
debugLog('log', 'measureHeightByIndics: height not equal, index: ', index, 'preHeight: ', preHeight, 'height: ', currentHeight);
|
|
1572
1577
|
}
|
|
1573
1578
|
});
|
|
@@ -3813,9 +3818,12 @@ class SlateEditable {
|
|
|
3813
3818
|
if (entries.length > 0 && entries[0].contentRect.width !== editorResizeObserverRectWidth) {
|
|
3814
3819
|
editorResizeObserverRectWidth = entries[0].contentRect.width;
|
|
3815
3820
|
this.keyHeightMap.clear();
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3821
|
+
let target = this.virtualTopHeightElement;
|
|
3822
|
+
if (this.inViewportChildren[0]) {
|
|
3823
|
+
const firstElement = this.inViewportChildren[0];
|
|
3824
|
+
const firstDomElement = AngularEditor.toDOMNode(this.editor, firstElement);
|
|
3825
|
+
target = firstDomElement;
|
|
3826
|
+
}
|
|
3819
3827
|
EDITOR_TO_ROOT_NODE_WIDTH.set(this.editor, target.offsetWidth);
|
|
3820
3828
|
updatePreRenderingElementWidth(this.editor);
|
|
3821
3829
|
if (isDebug) {
|
|
@@ -3834,12 +3842,14 @@ class SlateEditable {
|
|
|
3834
3842
|
});
|
|
3835
3843
|
}), debounceTime(500), filter(() => pendingRemeasureIndics.length > 0))
|
|
3836
3844
|
.subscribe(() => {
|
|
3837
|
-
measureHeightByIndics(this.editor, pendingRemeasureIndics, true);
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3845
|
+
const changed = measureHeightByIndics(this.editor, pendingRemeasureIndics, true);
|
|
3846
|
+
if (changed) {
|
|
3847
|
+
this.tryUpdateVirtualViewport();
|
|
3848
|
+
if (isDebug) {
|
|
3849
|
+
debugLog('log', 'exist pendingRemeasureIndics: ', pendingRemeasureIndics, 'will try to update virtual viewport');
|
|
3850
|
+
}
|
|
3841
3851
|
}
|
|
3842
|
-
|
|
3852
|
+
pendingRemeasureIndics = [];
|
|
3843
3853
|
});
|
|
3844
3854
|
}
|
|
3845
3855
|
}
|
|
@@ -3948,7 +3958,7 @@ class SlateEditable {
|
|
|
3948
3958
|
}
|
|
3949
3959
|
}
|
|
3950
3960
|
}
|
|
3951
|
-
if (
|
|
3961
|
+
if (this.editor.selection) {
|
|
3952
3962
|
this.toNativeSelection(false);
|
|
3953
3963
|
}
|
|
3954
3964
|
}
|
|
@@ -3970,7 +3980,7 @@ class SlateEditable {
|
|
|
3970
3980
|
};
|
|
3971
3981
|
}
|
|
3972
3982
|
const scrollTop = this.virtualScrollConfig.scrollTop;
|
|
3973
|
-
|
|
3983
|
+
let viewportHeight = this.virtualScrollConfig.viewportHeight ?? 0;
|
|
3974
3984
|
if (!viewportHeight) {
|
|
3975
3985
|
return {
|
|
3976
3986
|
inViewportChildren: [],
|
|
@@ -3991,20 +4001,23 @@ class SlateEditable {
|
|
|
3991
4001
|
EDITOR_TO_BUSINESS_TOP.set(this.editor, businessTop);
|
|
3992
4002
|
if (isDebug) {
|
|
3993
4003
|
debugLog('log', 'businessTop', businessTop);
|
|
4004
|
+
this.virtualTopHeightElement.setAttribute('data-business-top', businessTop.toString());
|
|
3994
4005
|
}
|
|
3995
4006
|
}, 100);
|
|
3996
4007
|
}
|
|
3997
|
-
const
|
|
4008
|
+
const businessTop = getBusinessTop(this.editor);
|
|
3998
4009
|
const { heights, accumulatedHeights } = buildHeightsAndAccumulatedHeights(this.editor, visibleStates);
|
|
3999
|
-
const totalHeight = accumulatedHeights[elementLength];
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4010
|
+
const totalHeight = accumulatedHeights[elementLength] + businessTop;
|
|
4011
|
+
let startPosition = Math.max(scrollTop - businessTop, 0);
|
|
4012
|
+
let endPosition = startPosition + viewportHeight;
|
|
4013
|
+
if (scrollTop < businessTop) {
|
|
4014
|
+
endPosition = startPosition + viewportHeight - (businessTop - scrollTop);
|
|
4015
|
+
}
|
|
4003
4016
|
let accumulatedOffset = 0;
|
|
4004
4017
|
let inViewportStartIndex = -1;
|
|
4005
4018
|
const visible = [];
|
|
4006
4019
|
const inViewportIndics = [];
|
|
4007
|
-
for (let i = 0; i < elementLength && accumulatedOffset <
|
|
4020
|
+
for (let i = 0; i < elementLength && accumulatedOffset < endPosition; i++) {
|
|
4008
4021
|
const currentHeight = heights[i];
|
|
4009
4022
|
const nextOffset = accumulatedOffset + currentHeight;
|
|
4010
4023
|
const isVisible = visibleStates[i];
|
|
@@ -4013,7 +4026,7 @@ class SlateEditable {
|
|
|
4013
4026
|
continue;
|
|
4014
4027
|
}
|
|
4015
4028
|
// 可视区域有交集,加入渲染
|
|
4016
|
-
if (nextOffset >
|
|
4029
|
+
if (nextOffset > startPosition && accumulatedOffset < endPosition) {
|
|
4017
4030
|
if (inViewportStartIndex === -1)
|
|
4018
4031
|
inViewportStartIndex = i; // 第一个相交起始位置
|
|
4019
4032
|
visible.push(children[i]);
|
|
@@ -5370,5 +5383,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
5370
5383
|
* Generated bundle index. Do not edit.
|
|
5371
5384
|
*/
|
|
5372
5385
|
|
|
5373
|
-
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, EDITOR_TO_BUSINESS_TOP, EDITOR_TO_IS_FROM_SCROLL_TO, EDITOR_TO_ROOT_NODE_WIDTH, EDITOR_TO_VIRTUAL_SCROLL_SELECTION, 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, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SLATE_DEBUG_KEY_SCROLL_TOP, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, SlateString, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, cacheHeightByElement, calcHeightByElement, calculateVirtualTopHeight, check, clearMinHeightByElement, completeTable, createClipboardData, createText, createThrottleRAF, debugLog, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCachedHeightByElement, 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, isDebug, isDebugScrollTop, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, measureHeightByIndics, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setMinHeightByElement, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
5386
|
+
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, EDITOR_TO_BUSINESS_TOP, EDITOR_TO_IS_FROM_SCROLL_TO, EDITOR_TO_ROOT_NODE_WIDTH, EDITOR_TO_VIRTUAL_SCROLL_SELECTION, 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, PLACEHOLDER_SYMBOL, SLATE_BLOCK_CARD_CLASS_NAME, SLATE_DEBUG_KEY, SLATE_DEBUG_KEY_SCROLL_TOP, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, SlateString, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, cacheHeightByElement, calcHeightByElement, calculateVirtualTopHeight, check, clearMinHeightByElement, completeTable, createClipboardData, createText, createThrottleRAF, debugLog, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCachedHeightByElement, 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, isDebug, isDebugScrollTop, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, isValidNumber, measureHeightByIndics, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setMinHeightByElement, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
5374
5387
|
//# sourceMappingURL=slate-angular.mjs.map
|