slate-angular 20.2.8 → 20.2.9
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 +87 -55
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +6 -5
- package/package.json +1 -1
|
@@ -1449,6 +1449,49 @@ class VirtualScrollDebugOverlay {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
1451
|
|
|
1452
|
+
const SLATE_BLOCK_CARD_CLASS_NAME = 'slate-block-card';
|
|
1453
|
+
class SlateBlockCard {
|
|
1454
|
+
onInit() {
|
|
1455
|
+
const nativeElement = document.createElement('div');
|
|
1456
|
+
nativeElement.classList.add(SLATE_BLOCK_CARD_CLASS_NAME);
|
|
1457
|
+
this.nativeElement = nativeElement;
|
|
1458
|
+
this.createContent();
|
|
1459
|
+
}
|
|
1460
|
+
createContent() {
|
|
1461
|
+
const leftCaret = document.createElement('span');
|
|
1462
|
+
leftCaret.setAttribute(`card-target`, 'card-left');
|
|
1463
|
+
leftCaret.classList.add('card-left');
|
|
1464
|
+
leftCaret.appendChild(getZeroTextNode());
|
|
1465
|
+
const rightCaret = document.createElement('span');
|
|
1466
|
+
rightCaret.setAttribute(`card-target`, 'card-right');
|
|
1467
|
+
rightCaret.classList.add('card-right');
|
|
1468
|
+
rightCaret.appendChild(getZeroTextNode());
|
|
1469
|
+
const center = document.createElement('div');
|
|
1470
|
+
center.setAttribute(`card-target`, 'card-center');
|
|
1471
|
+
this.nativeElement.appendChild(leftCaret);
|
|
1472
|
+
this.nativeElement.appendChild(center);
|
|
1473
|
+
this.nativeElement.appendChild(rightCaret);
|
|
1474
|
+
this.centerContainer = center;
|
|
1475
|
+
}
|
|
1476
|
+
append() {
|
|
1477
|
+
this.centerRootNodes.forEach(rootNode => !this.centerContainer.contains(rootNode) && this.centerContainer.appendChild(rootNode));
|
|
1478
|
+
}
|
|
1479
|
+
initializeCenter(rootNodes) {
|
|
1480
|
+
this.centerRootNodes = rootNodes;
|
|
1481
|
+
this.append();
|
|
1482
|
+
}
|
|
1483
|
+
onDestroy() {
|
|
1484
|
+
this.nativeElement.remove();
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
const getBlockCardByNativeElement = (nativeElement) => {
|
|
1488
|
+
const blockCardElement = nativeElement?.parentElement?.parentElement;
|
|
1489
|
+
if (blockCardElement && blockCardElement.classList.contains(SLATE_BLOCK_CARD_CLASS_NAME)) {
|
|
1490
|
+
return blockCardElement;
|
|
1491
|
+
}
|
|
1492
|
+
return null;
|
|
1493
|
+
};
|
|
1494
|
+
|
|
1452
1495
|
const isDebug = localStorage.getItem(SLATE_DEBUG_KEY) === 'true';
|
|
1453
1496
|
const isDebugScrollTop = localStorage.getItem(SLATE_DEBUG_KEY_SCROLL_TOP) === 'true';
|
|
1454
1497
|
const ELEMENT_KEY_TO_HEIGHTS = new WeakMap();
|
|
@@ -1459,16 +1502,54 @@ const debugLog = (type, ...args) => {
|
|
|
1459
1502
|
const doc = document;
|
|
1460
1503
|
VirtualScrollDebugOverlay.log(doc, type, ...args);
|
|
1461
1504
|
};
|
|
1462
|
-
const
|
|
1505
|
+
const cacheHeightByElement = (editor, element, height) => {
|
|
1506
|
+
if (!AngularEditor.isEnabledVirtualScroll(editor)) {
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
if (typeof height !== 'number') {
|
|
1510
|
+
console.error('cacheHeightByElement: height must be number', height);
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1463
1513
|
const key = AngularEditor.findKey(editor, element);
|
|
1514
|
+
const heights = ELEMENT_KEY_TO_HEIGHTS.get(editor);
|
|
1515
|
+
heights.set(key.id, height);
|
|
1516
|
+
};
|
|
1517
|
+
const setMinHeightByElement = (editor, element, rootElementMarginBottom) => {
|
|
1518
|
+
if (!AngularEditor.isEnabledVirtualScroll(editor)) {
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
const realHeight = getCachedHeightByElement(editor, element);
|
|
1522
|
+
if (realHeight) {
|
|
1523
|
+
const nativeElement = AngularEditor.toDOMNode(editor, element);
|
|
1524
|
+
const blockCard = getBlockCardByNativeElement(nativeElement);
|
|
1525
|
+
if (blockCard) {
|
|
1526
|
+
const minHeight = realHeight - rootElementMarginBottom;
|
|
1527
|
+
blockCard.style.minHeight = minHeight + 'px';
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
const clearMinHeightByElement = (editor, element) => {
|
|
1532
|
+
if (!AngularEditor.isEnabledVirtualScroll(editor)) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
const nativeElement = AngularEditor.toDOMNode(editor, element);
|
|
1536
|
+
const blockCard = getBlockCardByNativeElement(nativeElement);
|
|
1537
|
+
if (blockCard && blockCard.style.minHeight) {
|
|
1538
|
+
blockCard.style.minHeight = '';
|
|
1539
|
+
return true;
|
|
1540
|
+
}
|
|
1541
|
+
else {
|
|
1542
|
+
return false;
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
const calcHeightByElement = (editor, element) => {
|
|
1464
1546
|
const view = ELEMENT_TO_COMPONENT.get(element);
|
|
1465
1547
|
if (!view) {
|
|
1466
1548
|
return;
|
|
1467
1549
|
}
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
return ret;
|
|
1550
|
+
const height = view.calcHeight();
|
|
1551
|
+
cacheHeightByElement(editor, element, height);
|
|
1552
|
+
return height;
|
|
1472
1553
|
};
|
|
1473
1554
|
const measureHeightByIndics = (editor, indics, force = false) => {
|
|
1474
1555
|
let hasChanged = false;
|
|
@@ -2298,49 +2379,6 @@ class BaseFlavour {
|
|
|
2298
2379
|
}
|
|
2299
2380
|
}
|
|
2300
2381
|
|
|
2301
|
-
const SLATE_BLOCK_CARD_CLASS_NAME = 'slate-block-card';
|
|
2302
|
-
class SlateBlockCard {
|
|
2303
|
-
onInit() {
|
|
2304
|
-
const nativeElement = document.createElement('div');
|
|
2305
|
-
nativeElement.classList.add(SLATE_BLOCK_CARD_CLASS_NAME);
|
|
2306
|
-
this.nativeElement = nativeElement;
|
|
2307
|
-
this.createContent();
|
|
2308
|
-
}
|
|
2309
|
-
createContent() {
|
|
2310
|
-
const leftCaret = document.createElement('span');
|
|
2311
|
-
leftCaret.setAttribute(`card-target`, 'card-left');
|
|
2312
|
-
leftCaret.classList.add('card-left');
|
|
2313
|
-
leftCaret.appendChild(getZeroTextNode());
|
|
2314
|
-
const rightCaret = document.createElement('span');
|
|
2315
|
-
rightCaret.setAttribute(`card-target`, 'card-right');
|
|
2316
|
-
rightCaret.classList.add('card-right');
|
|
2317
|
-
rightCaret.appendChild(getZeroTextNode());
|
|
2318
|
-
const center = document.createElement('div');
|
|
2319
|
-
center.setAttribute(`card-target`, 'card-center');
|
|
2320
|
-
this.nativeElement.appendChild(leftCaret);
|
|
2321
|
-
this.nativeElement.appendChild(center);
|
|
2322
|
-
this.nativeElement.appendChild(rightCaret);
|
|
2323
|
-
this.centerContainer = center;
|
|
2324
|
-
}
|
|
2325
|
-
append() {
|
|
2326
|
-
this.centerRootNodes.forEach(rootNode => !this.centerContainer.contains(rootNode) && this.centerContainer.appendChild(rootNode));
|
|
2327
|
-
}
|
|
2328
|
-
initializeCenter(rootNodes) {
|
|
2329
|
-
this.centerRootNodes = rootNodes;
|
|
2330
|
-
this.append();
|
|
2331
|
-
}
|
|
2332
|
-
onDestroy() {
|
|
2333
|
-
this.nativeElement.remove();
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
const getBlockCardByNativeElement = (nativeElement) => {
|
|
2337
|
-
const blockCardElement = nativeElement?.parentElement?.parentElement;
|
|
2338
|
-
if (blockCardElement && blockCardElement.classList.contains(SLATE_BLOCK_CARD_CLASS_NAME)) {
|
|
2339
|
-
return blockCardElement;
|
|
2340
|
-
}
|
|
2341
|
-
return null;
|
|
2342
|
-
};
|
|
2343
|
-
|
|
2344
2382
|
const DEFAULT_ELEMENT_HEIGHT = 24;
|
|
2345
2383
|
class BaseElementFlavour extends BaseFlavour {
|
|
2346
2384
|
constructor() {
|
|
@@ -2437,9 +2475,6 @@ class BaseElementFlavour extends BaseFlavour {
|
|
|
2437
2475
|
readonly: this._context.readonly
|
|
2438
2476
|
};
|
|
2439
2477
|
}
|
|
2440
|
-
hasStableHeight() {
|
|
2441
|
-
return true;
|
|
2442
|
-
}
|
|
2443
2478
|
calcHeight() {
|
|
2444
2479
|
const blockCard = getBlockCardByNativeElement(this.nativeElement);
|
|
2445
2480
|
const target = blockCard || this.nativeElement;
|
|
@@ -5127,9 +5162,6 @@ class BaseElementComponent extends BaseComponent {
|
|
|
5127
5162
|
readonly: this._context.readonly
|
|
5128
5163
|
};
|
|
5129
5164
|
}
|
|
5130
|
-
hasStableHeight() {
|
|
5131
|
-
return true;
|
|
5132
|
-
}
|
|
5133
5165
|
calcHeight() {
|
|
5134
5166
|
const blockCard = getBlockCardByNativeElement(this.nativeElement);
|
|
5135
5167
|
const target = blockCard || this.nativeElement;
|
|
@@ -5295,5 +5327,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
5295
5327
|
* Generated bundle index. Do not edit.
|
|
5296
5328
|
*/
|
|
5297
5329
|
|
|
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 };
|
|
5330
|
+
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 };
|
|
5299
5331
|
//# sourceMappingURL=slate-angular.mjs.map
|