slate-angular 20.2.0-next.20 → 20.2.0-next.22
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 +36 -8
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -477,6 +477,7 @@ const HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY &&
|
|
|
477
477
|
typeof globalThis.InputEvent.prototype.getTargetRanges === 'function';
|
|
478
478
|
const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 30;
|
|
479
479
|
const SLATE_DEBUG_KEY = '__SLATE_DEBUG__';
|
|
480
|
+
const SLATE_DEBUG_KEY_SCROLL_TOP = '__SLATE_DEBUG_SCROLL_TOP__';
|
|
480
481
|
|
|
481
482
|
/**
|
|
482
483
|
* Hotkey mappings for each platform.
|
|
@@ -3137,10 +3138,13 @@ class VirtualScrollDebugOverlay {
|
|
|
3137
3138
|
// not correctly clipboardData on beforeinput
|
|
3138
3139
|
const forceOnDOMPaste = IS_SAFARI;
|
|
3139
3140
|
const isDebug = localStorage.getItem(SLATE_DEBUG_KEY) === 'true';
|
|
3141
|
+
const isDebugScrollTop = localStorage.getItem(SLATE_DEBUG_KEY_SCROLL_TOP) === 'true';
|
|
3140
3142
|
class SlateEditable {
|
|
3141
3143
|
set virtualScroll(config) {
|
|
3142
3144
|
this.virtualScrollConfig = config;
|
|
3143
|
-
|
|
3145
|
+
if (isDebugScrollTop) {
|
|
3146
|
+
this.debugLog('log', 'virtualScrollConfig scrollTop:', config.scrollTop);
|
|
3147
|
+
}
|
|
3144
3148
|
IS_ENABLED_VIRTUAL_SCROLL.set(this.editor, config.enabled);
|
|
3145
3149
|
if (this.isEnabledVirtualScroll()) {
|
|
3146
3150
|
this.tryUpdateVirtualViewport();
|
|
@@ -3576,6 +3580,7 @@ class SlateEditable {
|
|
|
3576
3580
|
this.editorResizeObserver = new ResizeObserver(entries => {
|
|
3577
3581
|
if (entries.length > 0 && entries[0].contentRect.width !== editorResizeObserverRectWidth) {
|
|
3578
3582
|
editorResizeObserverRectWidth = entries[0].contentRect.width;
|
|
3583
|
+
this.keyHeightMap.clear();
|
|
3579
3584
|
const remeasureIndics = Array.from(this.inViewportIndics);
|
|
3580
3585
|
this.remeasureHeightByIndics(remeasureIndics);
|
|
3581
3586
|
}
|
|
@@ -3625,6 +3630,28 @@ class SlateEditable {
|
|
|
3625
3630
|
this.toNativeSelection();
|
|
3626
3631
|
}
|
|
3627
3632
|
}
|
|
3633
|
+
if (diff.isAddedTop) {
|
|
3634
|
+
const remeasureAddedIndics = diff.diffTopRenderedIndexes;
|
|
3635
|
+
if (isDebug) {
|
|
3636
|
+
this.debugLog('log', 'isAddedTop to remeasure heights: ', remeasureAddedIndics);
|
|
3637
|
+
}
|
|
3638
|
+
const startIndexBeforeAdd = diff.diffTopRenderedIndexes[diff.diffTopRenderedIndexes.length - 1] + 1;
|
|
3639
|
+
const topHeightBeforeAdd = virtualView.accumulatedHeights[startIndexBeforeAdd];
|
|
3640
|
+
const result = this.remeasureHeightByIndics(remeasureAddedIndics);
|
|
3641
|
+
if (result) {
|
|
3642
|
+
const newHeights = buildHeightsAndAccumulatedHeights(this.editor);
|
|
3643
|
+
const visibleStartIndex = diff.diffTopRenderedIndexes[0];
|
|
3644
|
+
const actualTopHeightAfterAdd = newHeights.accumulatedHeights[startIndexBeforeAdd];
|
|
3645
|
+
const adjustedTopHeight = (visibleStartIndex === -1 ? 0 : newHeights.accumulatedHeights[visibleStartIndex]) -
|
|
3646
|
+
(actualTopHeightAfterAdd - topHeightBeforeAdd);
|
|
3647
|
+
if (adjustedTopHeight !== virtualView.top) {
|
|
3648
|
+
if (isDebug) {
|
|
3649
|
+
this.debugLog('log', `update top height cause added element in top: ${adjustedTopHeight}, old height: ${virtualView.top}`);
|
|
3650
|
+
}
|
|
3651
|
+
this.virtualTopHeightElement.style.height = `${adjustedTopHeight}px`;
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3628
3655
|
this.tryMeasureInViewportChildrenHeights();
|
|
3629
3656
|
});
|
|
3630
3657
|
}
|
|
@@ -3673,7 +3700,7 @@ class SlateEditable {
|
|
|
3673
3700
|
const totalHeight = accumulatedHeights[elementLength];
|
|
3674
3701
|
const maxScrollTop = Math.max(0, totalHeight - viewportHeight);
|
|
3675
3702
|
const limitedScrollTop = Math.min(adjustedScrollTop, maxScrollTop);
|
|
3676
|
-
const viewBottom = limitedScrollTop + viewportHeight
|
|
3703
|
+
const viewBottom = limitedScrollTop + viewportHeight;
|
|
3677
3704
|
let accumulatedOffset = 0;
|
|
3678
3705
|
let visibleStartIndex = -1;
|
|
3679
3706
|
const visible = [];
|
|
@@ -3703,7 +3730,8 @@ class SlateEditable {
|
|
|
3703
3730
|
visibleIndexes: new Set(visibleIndexes),
|
|
3704
3731
|
top,
|
|
3705
3732
|
bottom,
|
|
3706
|
-
heights
|
|
3733
|
+
heights,
|
|
3734
|
+
accumulatedHeights
|
|
3707
3735
|
};
|
|
3708
3736
|
}
|
|
3709
3737
|
applyVirtualView(virtualView) {
|
|
@@ -3891,9 +3919,6 @@ class SlateEditable {
|
|
|
3891
3919
|
toSlateSelection() {
|
|
3892
3920
|
if ((!this.isComposing || IS_ANDROID) && !this.isUpdatingSelection && !this.isDraggingInternally) {
|
|
3893
3921
|
try {
|
|
3894
|
-
if (isDebug) {
|
|
3895
|
-
console.log('toSlateSelection');
|
|
3896
|
-
}
|
|
3897
3922
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
3898
3923
|
const { activeElement } = root;
|
|
3899
3924
|
const el = AngularEditor.toDOMNode(this.editor, this.editor);
|
|
@@ -5005,6 +5030,9 @@ class BaseLeafComponent extends BaseComponent {
|
|
|
5005
5030
|
super(...arguments);
|
|
5006
5031
|
this.stringRender = null;
|
|
5007
5032
|
this.isSlateLeaf = true;
|
|
5033
|
+
this.getOutletParent = () => {
|
|
5034
|
+
return this.elementRef.nativeElement;
|
|
5035
|
+
};
|
|
5008
5036
|
}
|
|
5009
5037
|
get text() {
|
|
5010
5038
|
return this.context && this.context.text;
|
|
@@ -5019,7 +5047,7 @@ class BaseLeafComponent extends BaseComponent {
|
|
|
5019
5047
|
if (!this.initialized) {
|
|
5020
5048
|
this.stringRender = new SlateStringRender(this.context, this.viewContext);
|
|
5021
5049
|
const stringNode = this.stringRender.render();
|
|
5022
|
-
this.
|
|
5050
|
+
this.getOutletParent().appendChild(stringNode);
|
|
5023
5051
|
}
|
|
5024
5052
|
else {
|
|
5025
5053
|
this.stringRender?.update(this.context, this.viewContext);
|
|
@@ -5091,5 +5119,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
5091
5119
|
* Generated bundle index. Do not edit.
|
|
5092
5120
|
*/
|
|
5093
5121
|
|
|
5094
|
-
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_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, SlateBlockCard, SlateChildrenOutlet, SlateEditable, SlateErrorCode, SlateFragmentAttributeKey, SlateModule, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getRealHeightByElement, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
5122
|
+
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_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, VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT, VoidTextFlavour, blobAsString, buildHTMLText, buildHeightsAndAccumulatedHeights, check, completeTable, createClipboardData, createText, createThrottleRAF, defaultScrollSelectionIntoView, fallbackCopyText, getBlockCardByNativeElement, getBusinessTop, getCardTargetAttribute, getClipboardData, getClipboardFromHTMLText, getContentHeight, getDataTransferClipboard, getDataTransferClipboardText, getNavigatorClipboard, getPlainText, getRealHeightByElement, getSelection, getSlateFragmentAttribute, getZeroTextNode, hasAfterContextChange, hasBeforeContextChange, hasBlockCard, hasBlockCardWithNode, hotkeys, isCardCenterByTargetAttr, isCardLeft, isCardLeftByTargetAttr, isCardRightByTargetAttr, isClipboardFile, isClipboardReadSupported, isClipboardWriteSupported, isClipboardWriteTextSupported, isComponentType, isDOMText, isDecoratorRangeListEqual, isFlavourType, isInvalidTable, isTemplateRef, isValid, normalize, scrollToElement, setClipboardData, setDataTransferClipboard, setDataTransferClipboardText, setNavigatorClipboard, shallowCompare, stripHtml, withAngular };
|
|
5095
5123
|
//# sourceMappingURL=slate-angular.mjs.map
|