slate-angular 20.2.7 → 20.2.8
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 +31 -15
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +7 -5
- package/package.json +1 -1
|
@@ -1459,13 +1459,13 @@ const debugLog = (type, ...args) => {
|
|
|
1459
1459
|
const doc = document;
|
|
1460
1460
|
VirtualScrollDebugOverlay.log(doc, type, ...args);
|
|
1461
1461
|
};
|
|
1462
|
-
const
|
|
1462
|
+
const calcHeightByElement = (editor, element) => {
|
|
1463
1463
|
const key = AngularEditor.findKey(editor, element);
|
|
1464
1464
|
const view = ELEMENT_TO_COMPONENT.get(element);
|
|
1465
1465
|
if (!view) {
|
|
1466
1466
|
return;
|
|
1467
1467
|
}
|
|
1468
|
-
const ret = view.
|
|
1468
|
+
const ret = view.calcHeight();
|
|
1469
1469
|
const heights = ELEMENT_KEY_TO_HEIGHTS.get(editor);
|
|
1470
1470
|
heights.set(key.id, ret);
|
|
1471
1471
|
return ret;
|
|
@@ -1474,25 +1474,25 @@ const measureHeightByIndics = (editor, indics, force = false) => {
|
|
|
1474
1474
|
let hasChanged = false;
|
|
1475
1475
|
indics.forEach((index, i) => {
|
|
1476
1476
|
const element = editor.children[index];
|
|
1477
|
-
const preHeight =
|
|
1477
|
+
const preHeight = getCachedHeightByElement(editor, element);
|
|
1478
1478
|
if (preHeight && !force) {
|
|
1479
1479
|
if (isDebug) {
|
|
1480
|
-
const height =
|
|
1480
|
+
const height = calcHeightByElement(editor, element);
|
|
1481
1481
|
if (height !== preHeight) {
|
|
1482
|
-
debugLog('warn', '
|
|
1482
|
+
debugLog('warn', 'calcHeightByElement: height not equal, index: ', index, 'preHeight: ', preHeight, 'height: ', height);
|
|
1483
1483
|
}
|
|
1484
1484
|
}
|
|
1485
1485
|
return;
|
|
1486
1486
|
}
|
|
1487
1487
|
hasChanged = true;
|
|
1488
|
-
|
|
1488
|
+
calcHeightByElement(editor, element);
|
|
1489
1489
|
});
|
|
1490
1490
|
return hasChanged;
|
|
1491
1491
|
};
|
|
1492
1492
|
const getBusinessTop = (editor) => {
|
|
1493
1493
|
return EDITOR_TO_BUSINESS_TOP.get(editor) ?? 0;
|
|
1494
1494
|
};
|
|
1495
|
-
const
|
|
1495
|
+
const getCachedHeightByElement = (editor, element) => {
|
|
1496
1496
|
const heights = ELEMENT_KEY_TO_HEIGHTS.get(editor);
|
|
1497
1497
|
const key = AngularEditor.findKey(editor, element);
|
|
1498
1498
|
const height = heights?.get(key.id);
|
|
@@ -1510,7 +1510,15 @@ const buildHeightsAndAccumulatedHeights = (editor) => {
|
|
|
1510
1510
|
const accumulatedHeights = new Array(children.length + 1);
|
|
1511
1511
|
accumulatedHeights[0] = 0;
|
|
1512
1512
|
for (let i = 0; i < children.length; i++) {
|
|
1513
|
-
|
|
1513
|
+
let height = getCachedHeightByElement(editor, children[i]);
|
|
1514
|
+
if (height === null) {
|
|
1515
|
+
try {
|
|
1516
|
+
height = editor.getRoughHeight(children[i]);
|
|
1517
|
+
}
|
|
1518
|
+
catch (error) {
|
|
1519
|
+
console.error('buildHeightsAndAccumulatedHeights: getRoughHeight error', error);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1514
1522
|
heights[i] = height;
|
|
1515
1523
|
accumulatedHeights[i + 1] = accumulatedHeights[i] + height;
|
|
1516
1524
|
}
|
|
@@ -2429,7 +2437,10 @@ class BaseElementFlavour extends BaseFlavour {
|
|
|
2429
2437
|
readonly: this._context.readonly
|
|
2430
2438
|
};
|
|
2431
2439
|
}
|
|
2432
|
-
|
|
2440
|
+
hasStableHeight() {
|
|
2441
|
+
return true;
|
|
2442
|
+
}
|
|
2443
|
+
calcHeight() {
|
|
2433
2444
|
const blockCard = getBlockCardByNativeElement(this.nativeElement);
|
|
2434
2445
|
const target = blockCard || this.nativeElement;
|
|
2435
2446
|
const computedStyle = getComputedStyle(target);
|
|
@@ -3085,11 +3096,11 @@ class ListRender {
|
|
|
3085
3096
|
}
|
|
3086
3097
|
}
|
|
3087
3098
|
}
|
|
3088
|
-
if (isDebug) {
|
|
3099
|
+
if (isDebug && isRoot) {
|
|
3089
3100
|
for (let i = 0; i < children.length; i++) {
|
|
3090
3101
|
const rootNodes = [...getRootNodes(this.views[i], this.blockCards[i])];
|
|
3091
3102
|
const index = this.viewContext.editor.children.indexOf(children[i]);
|
|
3092
|
-
const height =
|
|
3103
|
+
const height = getCachedHeightByElement(this.viewContext.editor, children[i]) ||
|
|
3093
3104
|
this.viewContext.editor.getRoughHeight(children[i]);
|
|
3094
3105
|
rootNodes.forEach(rootNode => {
|
|
3095
3106
|
rootNode.setAttribute('debug-index', index.toString());
|
|
@@ -4029,9 +4040,11 @@ class SlateEditable {
|
|
|
4029
4040
|
debugLog('log', 'oldIndexesInViewport:', oldIndexesInViewport);
|
|
4030
4041
|
debugLog('log', 'newIndexesInViewport:', newIndexesInViewport);
|
|
4031
4042
|
// this.editor.children[index] will be undefined when it is removed
|
|
4032
|
-
debugLog('log', 'changedIndexesOfTop:', needRemoveOnTop ? '-' : needAddOnTop ? '+' : '-', changedIndexesOfTop, changedIndexesOfTop.map(index => (this.editor.children[index] &&
|
|
4043
|
+
debugLog('log', 'changedIndexesOfTop:', needRemoveOnTop ? '-' : needAddOnTop ? '+' : '-', changedIndexesOfTop, changedIndexesOfTop.map(index => (this.editor.children[index] &&
|
|
4044
|
+
getCachedHeightByElement(this.editor, this.editor.children[index])) ||
|
|
4033
4045
|
0));
|
|
4034
|
-
debugLog('log', 'changedIndexesOfBottom:', needAddOnBottom ? '+' : needRemoveOnBottom ? '-' : '+', changedIndexesOfBottom, changedIndexesOfBottom.map(index => (this.editor.children[index] &&
|
|
4046
|
+
debugLog('log', 'changedIndexesOfBottom:', needAddOnBottom ? '+' : needRemoveOnBottom ? '-' : '+', changedIndexesOfBottom, changedIndexesOfBottom.map(index => (this.editor.children[index] &&
|
|
4047
|
+
getCachedHeightByElement(this.editor, this.editor.children[index])) ||
|
|
4035
4048
|
0));
|
|
4036
4049
|
const needTop = virtualView.heights.slice(0, newIndexesInViewport[0]).reduce((acc, height) => acc + height, 0);
|
|
4037
4050
|
const needBottom = virtualView.heights
|
|
@@ -5114,7 +5127,10 @@ class BaseElementComponent extends BaseComponent {
|
|
|
5114
5127
|
readonly: this._context.readonly
|
|
5115
5128
|
};
|
|
5116
5129
|
}
|
|
5117
|
-
|
|
5130
|
+
hasStableHeight() {
|
|
5131
|
+
return true;
|
|
5132
|
+
}
|
|
5133
|
+
calcHeight() {
|
|
5118
5134
|
const blockCard = getBlockCardByNativeElement(this.nativeElement);
|
|
5119
5135
|
const target = blockCard || this.nativeElement;
|
|
5120
5136
|
const computedStyle = getComputedStyle(target);
|
|
@@ -5279,5 +5295,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
5279
5295
|
* Generated bundle index. Do not edit.
|
|
5280
5296
|
*/
|
|
5281
5297
|
|
|
5282
|
-
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, calculateVirtualTopHeight, check, completeTable, createClipboardData, createText, createThrottleRAF, debugLog, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText,
|
|
5298
|
+
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, calcHeightByElement, calculateVirtualTopHeight, check, 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, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
5283
5299
|
//# sourceMappingURL=slate-angular.mjs.map
|