@ones-editor/editor 3.1.7-beta.h1473.2 → 3.1.7-beta.h1473.3
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.
|
@@ -25,7 +25,7 @@ export default class OnesEditorToolbar implements OnesEditorHoveringBlockFilter,
|
|
|
25
25
|
isInToolbar: (event: MouseEvent) => boolean;
|
|
26
26
|
isInBlock(block: BlockElement, event: MouseEvent): boolean;
|
|
27
27
|
handleButtonClick: (toolbar: AbstractCommandBar, item: CommandItem) => void;
|
|
28
|
-
handleClose: () => void;
|
|
28
|
+
handleClose: (toolbar: AbstractCommandBar) => void;
|
|
29
29
|
handleClosing: (bar: unknown, event: MouseEvent | TouchEvent) => boolean;
|
|
30
30
|
bindEvents(): void;
|
|
31
31
|
unbindEvents(): void;
|
|
@@ -8,12 +8,14 @@ export default abstract class ManualCommandBar extends CommandBar implements Abs
|
|
|
8
8
|
_target: HTMLElement | null;
|
|
9
9
|
private cancelFocus?;
|
|
10
10
|
private focusTimer;
|
|
11
|
+
private focusRestoreGeneration;
|
|
11
12
|
constructor(items: CommandItem[], closeable?: Closeable, manualCommandBarOptions?: CommandBarOptions | undefined);
|
|
12
13
|
handleBeforeClose: (event?: MouseEvent | TouchEvent) => boolean;
|
|
13
14
|
private getFocusOwner;
|
|
14
15
|
private restoreFocusAfterClose;
|
|
15
16
|
private isFocusOwner;
|
|
16
17
|
private handleFocusInteraction;
|
|
18
|
+
private handleWindowBlur;
|
|
17
19
|
private clearFocusTimer;
|
|
18
20
|
setProps: (props: ManualShowCommandBarOptions) => void;
|
|
19
21
|
manualShow(target: HTMLElement, options?: ManualShowCommandBarOptions): void;
|
package/dist/index.js
CHANGED
|
@@ -42653,6 +42653,7 @@ ${codeText}
|
|
|
42653
42653
|
__publicField(this, "_target", null);
|
|
42654
42654
|
__publicField(this, "cancelFocus");
|
|
42655
42655
|
__publicField(this, "focusTimer", null);
|
|
42656
|
+
__publicField(this, "focusRestoreGeneration", 0);
|
|
42656
42657
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42657
42658
|
var _a;
|
|
42658
42659
|
const focusOwner = this.getFocusOwner();
|
|
@@ -42672,6 +42673,9 @@ ${codeText}
|
|
|
42672
42673
|
this.clearFocusTimer();
|
|
42673
42674
|
}
|
|
42674
42675
|
});
|
|
42676
|
+
__publicField(this, "handleWindowBlur", () => {
|
|
42677
|
+
this.clearFocusTimer();
|
|
42678
|
+
});
|
|
42675
42679
|
__publicField(this, "setProps", (props) => {
|
|
42676
42680
|
var _a;
|
|
42677
42681
|
(_a = this.tippyInstance) == null ? void 0 : _a.setProps(props);
|
|
@@ -42690,19 +42694,24 @@ ${codeText}
|
|
|
42690
42694
|
if (!parentEditor || event && !this.isFocusOwner(event.target)) {
|
|
42691
42695
|
return;
|
|
42692
42696
|
}
|
|
42693
|
-
|
|
42694
|
-
document.addEventListener("
|
|
42697
|
+
const generation = this.focusRestoreGeneration;
|
|
42698
|
+
document.addEventListener("mousedown", this.handleFocusInteraction, true);
|
|
42699
|
+
document.addEventListener("focusin", this.handleFocusInteraction, true);
|
|
42700
|
+
window.addEventListener("blur", this.handleWindowBlur);
|
|
42695
42701
|
this.focusTimer = setTimeout(() => {
|
|
42702
|
+
if (generation !== this.focusRestoreGeneration) {
|
|
42703
|
+
return;
|
|
42704
|
+
}
|
|
42696
42705
|
this.clearFocusTimer();
|
|
42697
42706
|
const input2 = parentEditor.querySelector(".editor-input");
|
|
42698
|
-
if (!target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected)) {
|
|
42707
|
+
if (this._target !== target || !target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected) || !document.hasFocus()) {
|
|
42699
42708
|
return;
|
|
42700
42709
|
}
|
|
42701
42710
|
const activeElement = document.activeElement;
|
|
42702
42711
|
if (parentEditor.contains(activeElement)) {
|
|
42703
42712
|
return;
|
|
42704
42713
|
}
|
|
42705
|
-
if (!activeElement || activeElement === document.body || this.isInCommandBar(activeElement)) {
|
|
42714
|
+
if (!activeElement || activeElement === document.body || activeElement === document.documentElement || this.isInCommandBar(activeElement)) {
|
|
42706
42715
|
this.cancelFocus = requestInputFocus(input2);
|
|
42707
42716
|
}
|
|
42708
42717
|
}, 100);
|
|
@@ -42714,14 +42723,16 @@ ${codeText}
|
|
|
42714
42723
|
}
|
|
42715
42724
|
clearFocusTimer() {
|
|
42716
42725
|
var _a;
|
|
42726
|
+
this.focusRestoreGeneration += 1;
|
|
42717
42727
|
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
42718
42728
|
this.cancelFocus = void 0;
|
|
42719
42729
|
if (this.focusTimer !== null) {
|
|
42720
42730
|
clearTimeout(this.focusTimer);
|
|
42721
42731
|
this.focusTimer = null;
|
|
42722
42732
|
}
|
|
42723
|
-
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
42724
|
-
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
42733
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction, true);
|
|
42734
|
+
document.removeEventListener("focusin", this.handleFocusInteraction, true);
|
|
42735
|
+
window.removeEventListener("blur", this.handleWindowBlur);
|
|
42725
42736
|
}
|
|
42726
42737
|
manualShow(target, options) {
|
|
42727
42738
|
var _a, _b, _c, _d;
|
|
@@ -42774,7 +42785,7 @@ ${codeText}
|
|
|
42774
42785
|
}
|
|
42775
42786
|
close(reason, e2) {
|
|
42776
42787
|
var _a, _b;
|
|
42777
|
-
if (reason
|
|
42788
|
+
if (reason === "clickBackground" || reason && reason !== "cancelBar" && reason !== "clickItem") {
|
|
42778
42789
|
this.clearFocusTimer();
|
|
42779
42790
|
}
|
|
42780
42791
|
super.close(reason);
|
|
@@ -55485,8 +55496,15 @@ ${codeText}
|
|
|
55485
55496
|
}
|
|
55486
55497
|
this._lastClickTime = Date.now();
|
|
55487
55498
|
});
|
|
55488
|
-
__publicField(this, "handleClose", () => {
|
|
55499
|
+
__publicField(this, "handleClose", (toolbar2) => {
|
|
55489
55500
|
var _a, _b;
|
|
55501
|
+
if (toolbar2.closeReason === "clickBackground" || !this.editor.rootElement.isConnected) {
|
|
55502
|
+
return;
|
|
55503
|
+
}
|
|
55504
|
+
const focusedElement = document.activeElement;
|
|
55505
|
+
if (focusedElement && focusedElement !== document.body && focusedElement !== document.documentElement && !this.editor.rootElement.contains(focusedElement) && !toolbar2.isInCommandBar(focusedElement)) {
|
|
55506
|
+
return;
|
|
55507
|
+
}
|
|
55490
55508
|
if (shouldFocusToEditor(this.editor) && !clientType.isMobile) {
|
|
55491
55509
|
const activeElement = (_a = document.getSelection()) == null ? void 0 : _a.focusNode;
|
|
55492
55510
|
if (activeElement && isInBlockTools(activeElement)) {
|
|
@@ -97698,7 +97716,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97698
97716
|
}
|
|
97699
97717
|
}
|
|
97700
97718
|
});
|
|
97701
|
-
editor.version = "3.1.7-beta.h1473.
|
|
97719
|
+
editor.version = "3.1.7-beta.h1473.3";
|
|
97702
97720
|
return editor;
|
|
97703
97721
|
}
|
|
97704
97722
|
function isDoc(doc2) {
|
|
@@ -97839,7 +97857,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97839
97857
|
OnesEditorDropTarget.register(editor);
|
|
97840
97858
|
OnesEditorTocProvider.register(editor);
|
|
97841
97859
|
OnesEditorExclusiveBlock.register(editor);
|
|
97842
|
-
editor.version = "3.1.7-beta.h1473.
|
|
97860
|
+
editor.version = "3.1.7-beta.h1473.3";
|
|
97843
97861
|
return editor;
|
|
97844
97862
|
} catch (error2) {
|
|
97845
97863
|
if (editorForCleanup) {
|