@ones-editor/editor 4.0.6 → 4.0.7-beta.h1474.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
|
@@ -42594,8 +42594,11 @@ ${codeText}
|
|
|
42594
42594
|
});
|
|
42595
42595
|
__publicField(this, "tippyInstance", null);
|
|
42596
42596
|
__publicField(this, "_target", null);
|
|
42597
|
+
__publicField(this, "focusTimer", null);
|
|
42597
42598
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42598
42599
|
var _a;
|
|
42600
|
+
const focusOwner = this.getFocusOwner();
|
|
42601
|
+
focusOwner.clearFocusTimer();
|
|
42599
42602
|
let ret = false;
|
|
42600
42603
|
if ((_a = this.manualCommandBarOptions) == null ? void 0 : _a.beforeClose) {
|
|
42601
42604
|
ret = this.manualCommandBarOptions.beforeClose(event);
|
|
@@ -42603,32 +42606,65 @@ ${codeText}
|
|
|
42603
42606
|
if (ret) {
|
|
42604
42607
|
return ret;
|
|
42605
42608
|
}
|
|
42606
|
-
|
|
42607
|
-
return ret;
|
|
42608
|
-
}
|
|
42609
|
-
const target = this._target;
|
|
42610
|
-
setTimeout(() => {
|
|
42611
|
-
const parentEditor = target.closest(".editor-root");
|
|
42612
|
-
if (parentEditor) {
|
|
42613
|
-
const input2 = parentEditor.querySelector(".editor-input");
|
|
42614
|
-
if (input2) {
|
|
42615
|
-
if (parentEditor.contains(document.activeElement)) {
|
|
42616
|
-
return;
|
|
42617
|
-
}
|
|
42618
|
-
input2.focus();
|
|
42619
|
-
}
|
|
42620
|
-
}
|
|
42621
|
-
}, 100);
|
|
42609
|
+
focusOwner.restoreFocusAfterClose(event);
|
|
42622
42610
|
return ret;
|
|
42623
42611
|
});
|
|
42612
|
+
__publicField(this, "handleFocusInteraction", (event) => {
|
|
42613
|
+
if (!this.isFocusOwner(event.target)) {
|
|
42614
|
+
this.clearFocusTimer();
|
|
42615
|
+
}
|
|
42616
|
+
});
|
|
42624
42617
|
__publicField(this, "setProps", (props) => {
|
|
42625
42618
|
var _a;
|
|
42626
42619
|
(_a = this.tippyInstance) == null ? void 0 : _a.setProps(props);
|
|
42627
42620
|
});
|
|
42628
42621
|
this.manualCommandBarOptions = manualCommandBarOptions;
|
|
42629
42622
|
}
|
|
42623
|
+
getFocusOwner() {
|
|
42624
|
+
return this.closeable instanceof ManualCommandBar ? this.closeable.getFocusOwner() : this;
|
|
42625
|
+
}
|
|
42626
|
+
restoreFocusAfterClose(event) {
|
|
42627
|
+
if (!this._target) {
|
|
42628
|
+
return;
|
|
42629
|
+
}
|
|
42630
|
+
const target = this._target;
|
|
42631
|
+
const parentEditor = target.closest(".editor-root");
|
|
42632
|
+
if (!parentEditor || event && !this.isFocusOwner(event.target)) {
|
|
42633
|
+
return;
|
|
42634
|
+
}
|
|
42635
|
+
document.addEventListener("mousedown", this.handleFocusInteraction);
|
|
42636
|
+
document.addEventListener("focusin", this.handleFocusInteraction);
|
|
42637
|
+
this.focusTimer = setTimeout(() => {
|
|
42638
|
+
this.clearFocusTimer();
|
|
42639
|
+
const input2 = parentEditor.querySelector(".editor-input");
|
|
42640
|
+
if (!target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected)) {
|
|
42641
|
+
return;
|
|
42642
|
+
}
|
|
42643
|
+
const activeElement = document.activeElement;
|
|
42644
|
+
if (parentEditor.contains(activeElement)) {
|
|
42645
|
+
return;
|
|
42646
|
+
}
|
|
42647
|
+
if (!activeElement || activeElement === document.body || this.isInCommandBar(activeElement)) {
|
|
42648
|
+
input2.focus();
|
|
42649
|
+
}
|
|
42650
|
+
}, 100);
|
|
42651
|
+
}
|
|
42652
|
+
isFocusOwner(target) {
|
|
42653
|
+
var _a;
|
|
42654
|
+
const parentEditor = (_a = this._target) == null ? void 0 : _a.closest(".editor-root");
|
|
42655
|
+
return target instanceof Node && (!!(parentEditor == null ? void 0 : parentEditor.contains(target)) || this.isInCommandBar(target));
|
|
42656
|
+
}
|
|
42657
|
+
clearFocusTimer() {
|
|
42658
|
+
if (this.focusTimer !== null) {
|
|
42659
|
+
clearTimeout(this.focusTimer);
|
|
42660
|
+
this.focusTimer = null;
|
|
42661
|
+
}
|
|
42662
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
42663
|
+
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
42664
|
+
}
|
|
42630
42665
|
manualShow(target, options) {
|
|
42631
42666
|
var _a, _b, _c, _d;
|
|
42667
|
+
this.getFocusOwner().clearFocusTimer();
|
|
42632
42668
|
this._target = target;
|
|
42633
42669
|
if (this.isVisible) {
|
|
42634
42670
|
return;
|
|
@@ -42677,6 +42713,9 @@ ${codeText}
|
|
|
42677
42713
|
}
|
|
42678
42714
|
close(reason, e2) {
|
|
42679
42715
|
var _a, _b;
|
|
42716
|
+
if (reason && reason !== "clickBackground" && reason !== "cancelBar" && reason !== "clickItem") {
|
|
42717
|
+
this.clearFocusTimer();
|
|
42718
|
+
}
|
|
42680
42719
|
super.close(reason);
|
|
42681
42720
|
if (this.isVisible) {
|
|
42682
42721
|
if (e2) {
|
|
@@ -42688,6 +42727,7 @@ ${codeText}
|
|
|
42688
42727
|
}
|
|
42689
42728
|
destroy() {
|
|
42690
42729
|
var _a;
|
|
42730
|
+
this.clearFocusTimer();
|
|
42691
42731
|
(_a = this.tippyInstance) == null ? void 0 : _a.destroy();
|
|
42692
42732
|
this.tippyInstance = null;
|
|
42693
42733
|
super.destroy();
|
|
@@ -76307,6 +76347,8 @@ ${codeText}
|
|
|
76307
76347
|
__publicField(this, "item");
|
|
76308
76348
|
__publicField(this, "docs", null);
|
|
76309
76349
|
__publicField(this, "checkedId");
|
|
76350
|
+
__publicField(this, "focusTimer", null);
|
|
76351
|
+
__publicField(this, "destroyed", false);
|
|
76310
76352
|
__publicField(this, "handlePasteSpecial", (bar2, item) => {
|
|
76311
76353
|
if (!item.data) {
|
|
76312
76354
|
return;
|
|
@@ -76317,24 +76359,37 @@ ${codeText}
|
|
|
76317
76359
|
this.checkedId = item.id;
|
|
76318
76360
|
}
|
|
76319
76361
|
this.onPasteSpecial(this.cleaningDoc(item), item.id);
|
|
76320
|
-
|
|
76362
|
+
this.clearFocusTimer();
|
|
76363
|
+
document.addEventListener("mousedown", this.handleFocusInteraction);
|
|
76364
|
+
document.addEventListener("focusin", this.handleFocusInteraction);
|
|
76365
|
+
this.focusTimer = setTimeout(() => {
|
|
76366
|
+
this.clearFocusTimer();
|
|
76367
|
+
if (!this.canRestoreFocus()) {
|
|
76368
|
+
return;
|
|
76369
|
+
}
|
|
76321
76370
|
if (this.docs) {
|
|
76322
76371
|
this.show(this.docs);
|
|
76323
76372
|
}
|
|
76324
76373
|
this.editor.focus();
|
|
76325
76374
|
});
|
|
76326
76375
|
});
|
|
76327
|
-
__publicField(this, "handleClose", () => {
|
|
76328
|
-
|
|
76329
|
-
|
|
76330
|
-
if (tagName === "input" || tagName === "textarea") {
|
|
76376
|
+
__publicField(this, "handleClose", (bar2) => {
|
|
76377
|
+
if (bar2.closeReason === "clickBackground") {
|
|
76378
|
+
this.clearFocusTimer();
|
|
76331
76379
|
return;
|
|
76332
76380
|
}
|
|
76333
|
-
this.
|
|
76381
|
+
if (bar2.closeReason === "cancelBar" && this.canRestoreFocus()) {
|
|
76382
|
+
this.editor.focus();
|
|
76383
|
+
}
|
|
76334
76384
|
});
|
|
76335
76385
|
__publicField(this, "handleSelectionChange", () => {
|
|
76336
76386
|
if (this.toolbar.isVisible) {
|
|
76337
|
-
this.handleClose();
|
|
76387
|
+
this.handleClose(this.toolbar);
|
|
76388
|
+
}
|
|
76389
|
+
});
|
|
76390
|
+
__publicField(this, "handleFocusInteraction", (event) => {
|
|
76391
|
+
if (!this.isFocusOwner(event.target)) {
|
|
76392
|
+
this.clearFocusTimer();
|
|
76338
76393
|
}
|
|
76339
76394
|
});
|
|
76340
76395
|
this.editor = editor;
|
|
@@ -76358,6 +76413,10 @@ ${codeText}
|
|
|
76358
76413
|
this.toolbar.addListener("close", this.handleClose);
|
|
76359
76414
|
}
|
|
76360
76415
|
show(docs) {
|
|
76416
|
+
this.clearFocusTimer();
|
|
76417
|
+
if (this.destroyed || this.editor.destroyed) {
|
|
76418
|
+
return;
|
|
76419
|
+
}
|
|
76361
76420
|
this.docs = docs;
|
|
76362
76421
|
const editor = this.editor;
|
|
76363
76422
|
const range = editor.selection.range;
|
|
@@ -76416,13 +76475,39 @@ ${codeText}
|
|
|
76416
76475
|
return doc2;
|
|
76417
76476
|
}
|
|
76418
76477
|
hide() {
|
|
76478
|
+
this.clearFocusTimer();
|
|
76419
76479
|
this.toolbar.close("selectionChange");
|
|
76420
76480
|
}
|
|
76421
76481
|
clearCheckedState() {
|
|
76422
76482
|
this.checkedId = void 0;
|
|
76423
76483
|
}
|
|
76424
76484
|
destroy() {
|
|
76485
|
+
var _a;
|
|
76486
|
+
this.destroyed = true;
|
|
76487
|
+
this.clearFocusTimer();
|
|
76425
76488
|
this.toolbar.destroy();
|
|
76489
|
+
(_a = this.anchor) == null ? void 0 : _a.remove();
|
|
76490
|
+
this.anchor = null;
|
|
76491
|
+
this.docs = null;
|
|
76492
|
+
}
|
|
76493
|
+
canRestoreFocus() {
|
|
76494
|
+
var _a;
|
|
76495
|
+
if (this.destroyed || this.editor.destroyed || !this.editor.rootElement.isConnected || !((_a = this.anchor) == null ? void 0 : _a.isConnected)) {
|
|
76496
|
+
return false;
|
|
76497
|
+
}
|
|
76498
|
+
const activeElement = document.activeElement;
|
|
76499
|
+
return !activeElement || activeElement === document.body || this.isFocusOwner(activeElement);
|
|
76500
|
+
}
|
|
76501
|
+
isFocusOwner(target) {
|
|
76502
|
+
return target instanceof Node && (this.editor.rootElement.contains(target) || this.toolbar.isInCommandBar(target));
|
|
76503
|
+
}
|
|
76504
|
+
clearFocusTimer() {
|
|
76505
|
+
if (this.focusTimer !== null) {
|
|
76506
|
+
clearTimeout(this.focusTimer);
|
|
76507
|
+
this.focusTimer = null;
|
|
76508
|
+
}
|
|
76509
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
76510
|
+
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
76426
76511
|
}
|
|
76427
76512
|
getCommandItems(docs) {
|
|
76428
76513
|
const getKeepFormatCommand = (format2) => {
|
|
@@ -97532,7 +97617,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97532
97617
|
}
|
|
97533
97618
|
}
|
|
97534
97619
|
});
|
|
97535
|
-
editor.version = "4.0.
|
|
97620
|
+
editor.version = "4.0.7-beta.h1474.1";
|
|
97536
97621
|
return editor;
|
|
97537
97622
|
}
|
|
97538
97623
|
function isDoc(doc2) {
|
|
@@ -97668,7 +97753,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97668
97753
|
OnesEditorDropTarget.register(editor);
|
|
97669
97754
|
OnesEditorTocProvider.register(editor);
|
|
97670
97755
|
OnesEditorExclusiveBlock.register(editor);
|
|
97671
|
-
editor.version = "4.0.
|
|
97756
|
+
editor.version = "4.0.7-beta.h1474.1";
|
|
97672
97757
|
return editor;
|
|
97673
97758
|
} catch (error2) {
|
|
97674
97759
|
try {
|
|
@@ -97811,7 +97896,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97811
97896
|
}
|
|
97812
97897
|
}
|
|
97813
97898
|
});
|
|
97814
|
-
editor.version = "4.0.
|
|
97899
|
+
editor.version = "4.0.7-beta.h1474.1";
|
|
97815
97900
|
return editor;
|
|
97816
97901
|
}
|
|
97817
97902
|
const emojis$1 = {
|