slate-angular 20.2.0-next.16 → 20.2.0-next.17
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 +39 -20
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +4 -3
- package/package.json +1 -1
|
@@ -362,6 +362,7 @@ const PLACEHOLDER_SYMBOL = Symbol('placeholder');
|
|
|
362
362
|
*/
|
|
363
363
|
const ELEMENT_TO_COMPONENT = new WeakMap();
|
|
364
364
|
const IS_ENABLED_VIRTUAL_SCROLL = new WeakMap();
|
|
365
|
+
const EDITOR_TO_VIRTUAL_SCROLL_SELECTION = new WeakMap();
|
|
365
366
|
const EDITOR_TO_AFTER_VIEW_INIT_QUEUE = new WeakMap();
|
|
366
367
|
|
|
367
368
|
const AngularEditor = {
|
|
@@ -474,7 +475,6 @@ const HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY &&
|
|
|
474
475
|
globalThis.InputEvent &&
|
|
475
476
|
// @ts-ignore The `getTargetRanges` property isn't recognized.
|
|
476
477
|
typeof globalThis.InputEvent.prototype.getTargetRanges === 'function';
|
|
477
|
-
const VIRTUAL_SCROLL_DEFAULT_BUFFER_COUNT = 3;
|
|
478
478
|
const VIRTUAL_SCROLL_DEFAULT_BLOCK_HEIGHT = 40;
|
|
479
479
|
const SLATE_DEBUG_KEY = '__SLATE_DEBUG__';
|
|
480
480
|
|
|
@@ -971,7 +971,14 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
971
971
|
}
|
|
972
972
|
// Create a fake selection so that we can add a Base64-encoded copy of the
|
|
973
973
|
// fragment to the HTML, to decode on future pastes.
|
|
974
|
-
|
|
974
|
+
let domRange;
|
|
975
|
+
if (AngularEditor.isEnabledVirtualScroll(e)) {
|
|
976
|
+
const virtualScrollSelection = EDITOR_TO_VIRTUAL_SCROLL_SELECTION.get(e);
|
|
977
|
+
if (virtualScrollSelection) {
|
|
978
|
+
domRange = AngularEditor.toDOMRange(e, virtualScrollSelection);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
domRange = domRange ?? AngularEditor.toDOMRange(e, selection);
|
|
975
982
|
let contents = domRange.cloneContents();
|
|
976
983
|
let attach = contents.childNodes[0];
|
|
977
984
|
// Make sure attach is non-empty, since empty nodes will not get copied.
|
|
@@ -3251,26 +3258,35 @@ class SlateEditable {
|
|
|
3251
3258
|
this.addEventListener(event.name, () => { });
|
|
3252
3259
|
});
|
|
3253
3260
|
}
|
|
3261
|
+
calculateVirtualScrollSelection(selection) {
|
|
3262
|
+
if (selection) {
|
|
3263
|
+
const indics = Array.from(this.inViewportIndics.values());
|
|
3264
|
+
if (indics.length > 0) {
|
|
3265
|
+
const currentVisibleRange = {
|
|
3266
|
+
anchor: Editor.start(this.editor, [indics[0]]),
|
|
3267
|
+
focus: Editor.end(this.editor, [indics[indics.length - 1]])
|
|
3268
|
+
};
|
|
3269
|
+
const [start, end] = Range.edges(selection);
|
|
3270
|
+
const forwardSelection = { anchor: start, focus: end };
|
|
3271
|
+
const intersectedSelection = Range.intersection(forwardSelection, currentVisibleRange);
|
|
3272
|
+
EDITOR_TO_VIRTUAL_SCROLL_SELECTION.set(this.editor, intersectedSelection);
|
|
3273
|
+
if (!intersectedSelection || !Range.equals(intersectedSelection, forwardSelection)) {
|
|
3274
|
+
if (isDebug) {
|
|
3275
|
+
this.debugLog('log', `selection is not in visible range, selection: ${JSON.stringify(selection)}, intersectedSelection: ${JSON.stringify(intersectedSelection)}`);
|
|
3276
|
+
}
|
|
3277
|
+
return intersectedSelection;
|
|
3278
|
+
}
|
|
3279
|
+
return selection;
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
EDITOR_TO_VIRTUAL_SCROLL_SELECTION.set(this.editor, null);
|
|
3283
|
+
return selection;
|
|
3284
|
+
}
|
|
3254
3285
|
toNativeSelection() {
|
|
3255
3286
|
try {
|
|
3256
3287
|
let { selection } = this.editor;
|
|
3257
|
-
if (this.isEnabledVirtualScroll()
|
|
3258
|
-
|
|
3259
|
-
if (indics.length > 0) {
|
|
3260
|
-
const currentVisibleRange = {
|
|
3261
|
-
anchor: Editor.start(this.editor, [indics[0]]),
|
|
3262
|
-
focus: Editor.end(this.editor, [indics[indics.length - 1]])
|
|
3263
|
-
};
|
|
3264
|
-
const [start, end] = Range.edges(selection);
|
|
3265
|
-
const forwardSelection = { anchor: start, focus: end };
|
|
3266
|
-
const intersectedSelection = Range.intersection(forwardSelection, currentVisibleRange);
|
|
3267
|
-
if (!intersectedSelection || !Range.equals(intersectedSelection, forwardSelection)) {
|
|
3268
|
-
selection = intersectedSelection;
|
|
3269
|
-
if (isDebug) {
|
|
3270
|
-
this.debugLog('log', `selection is not in visible range, selection: ${JSON.stringify(selection)}, intersectedSelection: ${JSON.stringify(intersectedSelection)}`);
|
|
3271
|
-
}
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3288
|
+
if (this.isEnabledVirtualScroll()) {
|
|
3289
|
+
selection = this.calculateVirtualScrollSelection(selection);
|
|
3274
3290
|
}
|
|
3275
3291
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
3276
3292
|
const { activeElement } = root;
|
|
@@ -3830,6 +3846,9 @@ class SlateEditable {
|
|
|
3830
3846
|
toSlateSelection() {
|
|
3831
3847
|
if ((!this.isComposing || IS_ANDROID) && !this.isUpdatingSelection && !this.isDraggingInternally) {
|
|
3832
3848
|
try {
|
|
3849
|
+
if (isDebug) {
|
|
3850
|
+
console.log('toSlateSelection');
|
|
3851
|
+
}
|
|
3833
3852
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
3834
3853
|
const { activeElement } = root;
|
|
3835
3854
|
const el = AngularEditor.toDOMNode(this.editor, this.editor);
|
|
@@ -5027,5 +5046,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
5027
5046
|
* Generated bundle index. Do not edit.
|
|
5028
5047
|
*/
|
|
5029
5048
|
|
|
5030
|
-
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,
|
|
5049
|
+
export { AngularEditor, BaseComponent, BaseElementComponent, BaseElementFlavour, BaseFlavour, BaseLeafComponent, BaseLeafFlavour, BaseTextComponent, BaseTextFlavour, BlockCardRef, DEFAULT_ELEMENT_HEIGHT, DefaultTextFlavour, EDITOR_TO_AFTER_VIEW_INIT_QUEUE, 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, 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, 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 };
|
|
5031
5050
|
//# sourceMappingURL=slate-angular.mjs.map
|