@ones-editor/editor 5.0.7 → 5.0.8-beta.ONES22303263.1
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/@ones-editor/paste-special/src/paste-special-button.d.ts +7 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui-base/src/command-bar/manual-command-bar.d.ts +6 -0
- package/@ones-editor/ui-base/src/command-bar/types.d.ts +1 -0
- package/dist/index.js +111 -26
- package/package.json +1 -1
|
@@ -6,8 +6,14 @@ export default abstract class ManualCommandBar extends CommandBar implements Abs
|
|
|
6
6
|
private manualCommandBarOptions?;
|
|
7
7
|
tippyInstance: Instance | null;
|
|
8
8
|
_target: HTMLElement | null;
|
|
9
|
+
private focusTimer;
|
|
9
10
|
constructor(items: CommandItem[], closeable?: Closeable, manualCommandBarOptions?: CommandBarOptions | undefined);
|
|
10
11
|
handleBeforeClose: (event?: MouseEvent | TouchEvent) => boolean;
|
|
12
|
+
private getFocusOwner;
|
|
13
|
+
private restoreFocusAfterClose;
|
|
14
|
+
private isFocusOwner;
|
|
15
|
+
private handleFocusInteraction;
|
|
16
|
+
private clearFocusTimer;
|
|
11
17
|
setProps: (props: ManualShowCommandBarOptions) => void;
|
|
12
18
|
manualShow(target: HTMLElement, options?: ManualShowCommandBarOptions): void;
|
|
13
19
|
close(reason: CloseReason, e?: MouseEvent | null): void;
|
|
@@ -24,6 +24,7 @@ export interface ManualShowCommandBarOptions {
|
|
|
24
24
|
}
|
|
25
25
|
export interface AbstractCommandBar extends TypedEmitter<CommandBarEvents> {
|
|
26
26
|
readonly isVisible: boolean;
|
|
27
|
+
readonly closeReason: CloseReason;
|
|
27
28
|
readonly parentItem: CommandItem | null;
|
|
28
29
|
closeable: Closeable | null;
|
|
29
30
|
close: (reason: CloseReason, e?: MouseEvent | null) => void;
|
package/dist/index.js
CHANGED
|
@@ -42798,8 +42798,11 @@ ${codeText}
|
|
|
42798
42798
|
});
|
|
42799
42799
|
__publicField(this, "tippyInstance", null);
|
|
42800
42800
|
__publicField(this, "_target", null);
|
|
42801
|
+
__publicField(this, "focusTimer", null);
|
|
42801
42802
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42802
42803
|
var _a;
|
|
42804
|
+
const focusOwner = this.getFocusOwner();
|
|
42805
|
+
focusOwner.clearFocusTimer();
|
|
42803
42806
|
let ret = false;
|
|
42804
42807
|
if ((_a = this.manualCommandBarOptions) == null ? void 0 : _a.beforeClose) {
|
|
42805
42808
|
ret = this.manualCommandBarOptions.beforeClose(event);
|
|
@@ -42807,32 +42810,65 @@ ${codeText}
|
|
|
42807
42810
|
if (ret) {
|
|
42808
42811
|
return ret;
|
|
42809
42812
|
}
|
|
42810
|
-
|
|
42811
|
-
return ret;
|
|
42812
|
-
}
|
|
42813
|
-
const target = this._target;
|
|
42814
|
-
setTimeout(() => {
|
|
42815
|
-
const parentEditor = target.closest(".editor-root");
|
|
42816
|
-
if (parentEditor) {
|
|
42817
|
-
const input2 = parentEditor.querySelector(".editor-input");
|
|
42818
|
-
if (input2) {
|
|
42819
|
-
if (parentEditor.contains(document.activeElement)) {
|
|
42820
|
-
return;
|
|
42821
|
-
}
|
|
42822
|
-
input2.focus();
|
|
42823
|
-
}
|
|
42824
|
-
}
|
|
42825
|
-
}, 100);
|
|
42813
|
+
focusOwner.restoreFocusAfterClose(event);
|
|
42826
42814
|
return ret;
|
|
42827
42815
|
});
|
|
42816
|
+
__publicField(this, "handleFocusInteraction", (event) => {
|
|
42817
|
+
if (!this.isFocusOwner(event.target)) {
|
|
42818
|
+
this.clearFocusTimer();
|
|
42819
|
+
}
|
|
42820
|
+
});
|
|
42828
42821
|
__publicField(this, "setProps", (props) => {
|
|
42829
42822
|
var _a;
|
|
42830
42823
|
(_a = this.tippyInstance) == null ? void 0 : _a.setProps(props);
|
|
42831
42824
|
});
|
|
42832
42825
|
this.manualCommandBarOptions = manualCommandBarOptions;
|
|
42833
42826
|
}
|
|
42827
|
+
getFocusOwner() {
|
|
42828
|
+
return this.closeable instanceof ManualCommandBar ? this.closeable.getFocusOwner() : this;
|
|
42829
|
+
}
|
|
42830
|
+
restoreFocusAfterClose(event) {
|
|
42831
|
+
if (!this._target) {
|
|
42832
|
+
return;
|
|
42833
|
+
}
|
|
42834
|
+
const target = this._target;
|
|
42835
|
+
const parentEditor = target.closest(".editor-root");
|
|
42836
|
+
if (!parentEditor || event && !this.isFocusOwner(event.target)) {
|
|
42837
|
+
return;
|
|
42838
|
+
}
|
|
42839
|
+
document.addEventListener("mousedown", this.handleFocusInteraction);
|
|
42840
|
+
document.addEventListener("focusin", this.handleFocusInteraction);
|
|
42841
|
+
this.focusTimer = setTimeout(() => {
|
|
42842
|
+
this.clearFocusTimer();
|
|
42843
|
+
const input2 = parentEditor.querySelector(".editor-input");
|
|
42844
|
+
if (!target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected)) {
|
|
42845
|
+
return;
|
|
42846
|
+
}
|
|
42847
|
+
const activeElement = document.activeElement;
|
|
42848
|
+
if (parentEditor.contains(activeElement)) {
|
|
42849
|
+
return;
|
|
42850
|
+
}
|
|
42851
|
+
if (!activeElement || activeElement === document.body || this.isInCommandBar(activeElement)) {
|
|
42852
|
+
input2.focus();
|
|
42853
|
+
}
|
|
42854
|
+
}, 100);
|
|
42855
|
+
}
|
|
42856
|
+
isFocusOwner(target) {
|
|
42857
|
+
var _a;
|
|
42858
|
+
const parentEditor = (_a = this._target) == null ? void 0 : _a.closest(".editor-root");
|
|
42859
|
+
return target instanceof Node && (!!(parentEditor == null ? void 0 : parentEditor.contains(target)) || this.isInCommandBar(target));
|
|
42860
|
+
}
|
|
42861
|
+
clearFocusTimer() {
|
|
42862
|
+
if (this.focusTimer !== null) {
|
|
42863
|
+
clearTimeout(this.focusTimer);
|
|
42864
|
+
this.focusTimer = null;
|
|
42865
|
+
}
|
|
42866
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
42867
|
+
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
42868
|
+
}
|
|
42834
42869
|
manualShow(target, options) {
|
|
42835
42870
|
var _a, _b, _c, _d;
|
|
42871
|
+
this.getFocusOwner().clearFocusTimer();
|
|
42836
42872
|
this._target = target;
|
|
42837
42873
|
if (this.isVisible) {
|
|
42838
42874
|
return;
|
|
@@ -42881,6 +42917,9 @@ ${codeText}
|
|
|
42881
42917
|
}
|
|
42882
42918
|
close(reason, e2) {
|
|
42883
42919
|
var _a, _b;
|
|
42920
|
+
if (reason && reason !== "clickBackground" && reason !== "cancelBar" && reason !== "clickItem") {
|
|
42921
|
+
this.clearFocusTimer();
|
|
42922
|
+
}
|
|
42884
42923
|
super.close(reason);
|
|
42885
42924
|
if (this.isVisible) {
|
|
42886
42925
|
if (e2) {
|
|
@@ -42892,6 +42931,7 @@ ${codeText}
|
|
|
42892
42931
|
}
|
|
42893
42932
|
destroy() {
|
|
42894
42933
|
var _a;
|
|
42934
|
+
this.clearFocusTimer();
|
|
42895
42935
|
(_a = this.tippyInstance) == null ? void 0 : _a.destroy();
|
|
42896
42936
|
this.tippyInstance = null;
|
|
42897
42937
|
super.destroy();
|
|
@@ -76594,6 +76634,8 @@ ${codeText}
|
|
|
76594
76634
|
__publicField(this, "item");
|
|
76595
76635
|
__publicField(this, "docs", null);
|
|
76596
76636
|
__publicField(this, "checkedId");
|
|
76637
|
+
__publicField(this, "focusTimer", null);
|
|
76638
|
+
__publicField(this, "destroyed", false);
|
|
76597
76639
|
__publicField(this, "handlePasteSpecial", (bar2, item) => {
|
|
76598
76640
|
if (!item.data) {
|
|
76599
76641
|
return;
|
|
@@ -76604,24 +76646,37 @@ ${codeText}
|
|
|
76604
76646
|
this.checkedId = item.id;
|
|
76605
76647
|
}
|
|
76606
76648
|
this.onPasteSpecial(this.cleaningDoc(item), item.id);
|
|
76607
|
-
|
|
76649
|
+
this.clearFocusTimer();
|
|
76650
|
+
document.addEventListener("mousedown", this.handleFocusInteraction);
|
|
76651
|
+
document.addEventListener("focusin", this.handleFocusInteraction);
|
|
76652
|
+
this.focusTimer = setTimeout(() => {
|
|
76653
|
+
this.clearFocusTimer();
|
|
76654
|
+
if (!this.canRestoreFocus()) {
|
|
76655
|
+
return;
|
|
76656
|
+
}
|
|
76608
76657
|
if (this.docs) {
|
|
76609
76658
|
this.show(this.docs);
|
|
76610
76659
|
}
|
|
76611
76660
|
this.editor.focus();
|
|
76612
76661
|
});
|
|
76613
76662
|
});
|
|
76614
|
-
__publicField(this, "handleClose", () => {
|
|
76615
|
-
|
|
76616
|
-
|
|
76617
|
-
if (tagName === "input" || tagName === "textarea") {
|
|
76663
|
+
__publicField(this, "handleClose", (bar2) => {
|
|
76664
|
+
if (bar2.closeReason === "clickBackground") {
|
|
76665
|
+
this.clearFocusTimer();
|
|
76618
76666
|
return;
|
|
76619
76667
|
}
|
|
76620
|
-
this.
|
|
76668
|
+
if (bar2.closeReason === "cancelBar" && this.canRestoreFocus()) {
|
|
76669
|
+
this.editor.focus();
|
|
76670
|
+
}
|
|
76621
76671
|
});
|
|
76622
76672
|
__publicField(this, "handleSelectionChange", () => {
|
|
76623
76673
|
if (this.toolbar.isVisible) {
|
|
76624
|
-
this.handleClose();
|
|
76674
|
+
this.handleClose(this.toolbar);
|
|
76675
|
+
}
|
|
76676
|
+
});
|
|
76677
|
+
__publicField(this, "handleFocusInteraction", (event) => {
|
|
76678
|
+
if (!this.isFocusOwner(event.target)) {
|
|
76679
|
+
this.clearFocusTimer();
|
|
76625
76680
|
}
|
|
76626
76681
|
});
|
|
76627
76682
|
this.editor = editor;
|
|
@@ -76645,6 +76700,10 @@ ${codeText}
|
|
|
76645
76700
|
this.toolbar.addListener("close", this.handleClose);
|
|
76646
76701
|
}
|
|
76647
76702
|
show(docs) {
|
|
76703
|
+
this.clearFocusTimer();
|
|
76704
|
+
if (this.destroyed || this.editor.destroyed) {
|
|
76705
|
+
return;
|
|
76706
|
+
}
|
|
76648
76707
|
this.docs = docs;
|
|
76649
76708
|
const editor = this.editor;
|
|
76650
76709
|
const range = editor.selection.range;
|
|
@@ -76703,13 +76762,39 @@ ${codeText}
|
|
|
76703
76762
|
return doc2;
|
|
76704
76763
|
}
|
|
76705
76764
|
hide() {
|
|
76765
|
+
this.clearFocusTimer();
|
|
76706
76766
|
this.toolbar.close("selectionChange");
|
|
76707
76767
|
}
|
|
76708
76768
|
clearCheckedState() {
|
|
76709
76769
|
this.checkedId = void 0;
|
|
76710
76770
|
}
|
|
76711
76771
|
destroy() {
|
|
76772
|
+
var _a;
|
|
76773
|
+
this.destroyed = true;
|
|
76774
|
+
this.clearFocusTimer();
|
|
76712
76775
|
this.toolbar.destroy();
|
|
76776
|
+
(_a = this.anchor) == null ? void 0 : _a.remove();
|
|
76777
|
+
this.anchor = null;
|
|
76778
|
+
this.docs = null;
|
|
76779
|
+
}
|
|
76780
|
+
canRestoreFocus() {
|
|
76781
|
+
var _a;
|
|
76782
|
+
if (this.destroyed || this.editor.destroyed || !this.editor.rootElement.isConnected || !((_a = this.anchor) == null ? void 0 : _a.isConnected)) {
|
|
76783
|
+
return false;
|
|
76784
|
+
}
|
|
76785
|
+
const activeElement = document.activeElement;
|
|
76786
|
+
return !activeElement || activeElement === document.body || this.isFocusOwner(activeElement);
|
|
76787
|
+
}
|
|
76788
|
+
isFocusOwner(target) {
|
|
76789
|
+
return target instanceof Node && (this.editor.rootElement.contains(target) || this.toolbar.isInCommandBar(target));
|
|
76790
|
+
}
|
|
76791
|
+
clearFocusTimer() {
|
|
76792
|
+
if (this.focusTimer !== null) {
|
|
76793
|
+
clearTimeout(this.focusTimer);
|
|
76794
|
+
this.focusTimer = null;
|
|
76795
|
+
}
|
|
76796
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
76797
|
+
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
76713
76798
|
}
|
|
76714
76799
|
getCommandItems(docs) {
|
|
76715
76800
|
const getKeepFormatCommand = (format2) => {
|
|
@@ -98044,7 +98129,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98044
98129
|
}
|
|
98045
98130
|
}
|
|
98046
98131
|
});
|
|
98047
|
-
editor.version = "5.0.
|
|
98132
|
+
editor.version = "5.0.8-beta.ONES22303263.1";
|
|
98048
98133
|
return editor;
|
|
98049
98134
|
}
|
|
98050
98135
|
function isDoc(doc2) {
|
|
@@ -98180,7 +98265,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98180
98265
|
OnesEditorDropTarget.register(editor);
|
|
98181
98266
|
OnesEditorTocProvider.register(editor);
|
|
98182
98267
|
OnesEditorExclusiveBlock.register(editor);
|
|
98183
|
-
editor.version = "5.0.
|
|
98268
|
+
editor.version = "5.0.8-beta.ONES22303263.1";
|
|
98184
98269
|
return editor;
|
|
98185
98270
|
} catch (error2) {
|
|
98186
98271
|
try {
|
|
@@ -98323,7 +98408,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98323
98408
|
}
|
|
98324
98409
|
}
|
|
98325
98410
|
});
|
|
98326
|
-
editor.version = "5.0.
|
|
98411
|
+
editor.version = "5.0.8-beta.ONES22303263.1";
|
|
98327
98412
|
return editor;
|
|
98328
98413
|
}
|
|
98329
98414
|
const emojis$1 = {
|