slate-angular 20.2.0-next.5 → 20.2.0-next.6
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 +32 -3
- package/fesm2022/slate-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1135,6 +1135,9 @@ const withAngular = (editor, clipboardFormatKey = 'x-slate-fragment') => {
|
|
|
1135
1135
|
NODE_TO_KEY.set(node, key);
|
|
1136
1136
|
}
|
|
1137
1137
|
};
|
|
1138
|
+
e.selectAll = () => {
|
|
1139
|
+
Transforms.select(e, []);
|
|
1140
|
+
};
|
|
1138
1141
|
return e;
|
|
1139
1142
|
};
|
|
1140
1143
|
|
|
@@ -1835,7 +1838,7 @@ class BaseElementFlavour extends BaseFlavour {
|
|
|
1835
1838
|
const blockCard = getBlockCardByNativeElement(this.nativeElement);
|
|
1836
1839
|
const target = blockCard || this.nativeElement;
|
|
1837
1840
|
const computedStyle = getComputedStyle(target);
|
|
1838
|
-
const height = target.
|
|
1841
|
+
const height = Math.ceil(target.getBoundingClientRect().height) + parseFloat(computedStyle.marginTop) + parseFloat(computedStyle.marginBottom);
|
|
1839
1842
|
if (this.isStableHeight()) {
|
|
1840
1843
|
this.stableHeight = height;
|
|
1841
1844
|
}
|
|
@@ -2591,6 +2594,9 @@ class SlateEditable {
|
|
|
2591
2594
|
this.applyVirtualView(virtualView);
|
|
2592
2595
|
if (this.listRender.initialized) {
|
|
2593
2596
|
this.listRender.update(virtualView.renderedChildren, this.editor, this.context);
|
|
2597
|
+
if (!AngularEditor.isReadOnly(this.editor) && this.editor.selection) {
|
|
2598
|
+
this.toNativeSelection();
|
|
2599
|
+
}
|
|
2594
2600
|
}
|
|
2595
2601
|
this.scheduleMeasureVisibleHeights();
|
|
2596
2602
|
});
|
|
@@ -2746,7 +2752,23 @@ class SlateEditable {
|
|
|
2746
2752
|
}
|
|
2747
2753
|
toNativeSelection() {
|
|
2748
2754
|
try {
|
|
2749
|
-
|
|
2755
|
+
let { selection: currentSelection } = this.editor;
|
|
2756
|
+
let selection = currentSelection;
|
|
2757
|
+
if (this.virtualConfig?.enabled) {
|
|
2758
|
+
const indics = Array.from(this.virtualVisibleIndexes.values());
|
|
2759
|
+
if (indics.length > 0) {
|
|
2760
|
+
const currentVisibleRange = {
|
|
2761
|
+
anchor: Editor.start(this.editor, [indics[0]]),
|
|
2762
|
+
focus: Editor.end(this.editor, [indics[indics.length - 1]])
|
|
2763
|
+
};
|
|
2764
|
+
selection = Range.intersection(selection, currentVisibleRange);
|
|
2765
|
+
if ((!selection && currentSelection) || (selection && !Range.equals(selection, currentSelection))) {
|
|
2766
|
+
if (isDebug) {
|
|
2767
|
+
console.log(`selection is not in visible range, selection: ${JSON.stringify(currentSelection)}, intersection selection: ${JSON.stringify(selection)}`);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2750
2772
|
const root = AngularEditor.findDocumentOrShadowRoot(this.editor);
|
|
2751
2773
|
const { activeElement } = root;
|
|
2752
2774
|
const domSelection = root.getSelection();
|
|
@@ -2953,8 +2975,10 @@ class SlateEditable {
|
|
|
2953
2975
|
this.virtualScrollInitialized = true;
|
|
2954
2976
|
this.virtualTopHeightElement = document.createElement('div');
|
|
2955
2977
|
this.virtualTopHeightElement.classList.add('virtual-top-height');
|
|
2978
|
+
this.virtualTopHeightElement.contentEditable = 'false';
|
|
2956
2979
|
this.virtualBottomHeightElement = document.createElement('div');
|
|
2957
2980
|
this.virtualBottomHeightElement.classList.add('virtual-bottom-height');
|
|
2981
|
+
this.virtualBottomHeightElement.contentEditable = 'false';
|
|
2958
2982
|
this.virtualCenterOutlet = document.createElement('div');
|
|
2959
2983
|
this.virtualCenterOutlet.classList.add('virtual-center-outlet');
|
|
2960
2984
|
this.elementRef.nativeElement.appendChild(this.virtualTopHeightElement);
|
|
@@ -3744,6 +3768,11 @@ class SlateEditable {
|
|
|
3744
3768
|
Transforms.move(editor, { unit: 'word', reverse: isRTL });
|
|
3745
3769
|
return;
|
|
3746
3770
|
}
|
|
3771
|
+
if (isKeyHotkey('mod+a', event)) {
|
|
3772
|
+
this.editor.selectAll();
|
|
3773
|
+
event.preventDefault();
|
|
3774
|
+
return;
|
|
3775
|
+
}
|
|
3747
3776
|
// COMPAT: Certain browsers don't support the `beforeinput` event, so we
|
|
3748
3777
|
// fall back to guessing at the input intention for hotkeys.
|
|
3749
3778
|
// COMPAT: In iOS, some of these hotkeys are handled in the
|
|
@@ -4262,7 +4291,7 @@ class BaseElementComponent extends BaseComponent {
|
|
|
4262
4291
|
const blockCard = getBlockCardByNativeElement(this.nativeElement);
|
|
4263
4292
|
const target = blockCard || this.nativeElement;
|
|
4264
4293
|
const computedStyle = getComputedStyle(target);
|
|
4265
|
-
const height = target.
|
|
4294
|
+
const height = Math.ceil(target.getBoundingClientRect().height) + parseFloat(computedStyle.marginTop) + parseFloat(computedStyle.marginBottom);
|
|
4266
4295
|
if (this.isStableHeight()) {
|
|
4267
4296
|
this.stableHeight = height;
|
|
4268
4297
|
}
|