@ones-editor/editor 5.0.8-beta.h1475.1 → 5.0.8-beta.h1475.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.
- package/@ones-editor/core/src/core/composition/editor-input.d.ts +1 -0
- package/@ones-editor/core/src/core/composition/focus-restoration.d.ts +25 -0
- package/@ones-editor/core/src/core/composition/index.d.ts +2 -0
- package/@ones-editor/main-toolbar/src/index.d.ts +2 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/package.json +3 -0
- package/@ones-editor/ui/src/toolbar/toolbar-handler.d.ts +2 -1
- package/@ones-editor/ui-base/src/auto-suggest/editor-auto-suggest-menu.d.ts +2 -0
- package/@ones-editor/ui-base/src/command-bar/manual-command-bar.d.ts +3 -0
- package/dist/index.js +329 -81
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26555,6 +26555,114 @@ var __publicField = (obj, key, value) => {
|
|
|
26555
26555
|
};
|
|
26556
26556
|
}
|
|
26557
26557
|
}
|
|
26558
|
+
const controllers = /* @__PURE__ */ new WeakMap();
|
|
26559
|
+
const noop$1 = () => {
|
|
26560
|
+
};
|
|
26561
|
+
class FocusRestoration {
|
|
26562
|
+
constructor(input2, restore) {
|
|
26563
|
+
__publicField(this, "generation", 0);
|
|
26564
|
+
__publicField(this, "owner", null);
|
|
26565
|
+
__publicField(this, "destroyed", false);
|
|
26566
|
+
__publicField(this, "activeScope");
|
|
26567
|
+
__publicField(this, "timers", /* @__PURE__ */ new Set());
|
|
26568
|
+
this.input = input2;
|
|
26569
|
+
this.restore = restore;
|
|
26570
|
+
controllers.set(input2, this);
|
|
26571
|
+
}
|
|
26572
|
+
canFocus() {
|
|
26573
|
+
var _a;
|
|
26574
|
+
return !this.destroyed && !this.owner && !((_a = this.activeScope) == null ? void 0 : _a.cancelled) && this.input.isConnected;
|
|
26575
|
+
}
|
|
26576
|
+
hasOtherInput() {
|
|
26577
|
+
const active = this.input.ownerDocument.activeElement;
|
|
26578
|
+
return active !== this.input && !!(active == null ? void 0 : active.matches('input, textarea, select, [contenteditable="true"], [contenteditable=""]'));
|
|
26579
|
+
}
|
|
26580
|
+
schedule(callback, delay = 0, protectUserFocus = false) {
|
|
26581
|
+
var _a;
|
|
26582
|
+
return this.scheduleInScope(callback, delay, protectUserFocus, (_a = this.activeScope) != null ? _a : this.createScope());
|
|
26583
|
+
}
|
|
26584
|
+
createScope() {
|
|
26585
|
+
return { cancelled: false, timers: /* @__PURE__ */ new Set() };
|
|
26586
|
+
}
|
|
26587
|
+
scheduleInScope(callback, delay, protectUserFocus, scope) {
|
|
26588
|
+
if (scope.cancelled || !this.canFocus()) {
|
|
26589
|
+
return noop$1;
|
|
26590
|
+
}
|
|
26591
|
+
const generation = this.generation;
|
|
26592
|
+
const timer = setTimeout(() => {
|
|
26593
|
+
this.timers.delete(timer);
|
|
26594
|
+
scope.timers.delete(timer);
|
|
26595
|
+
if (!scope.cancelled && generation === this.generation && this.canFocus() && (!protectUserFocus || !this.hasOtherInput())) {
|
|
26596
|
+
const previousScope = this.activeScope;
|
|
26597
|
+
this.activeScope = scope;
|
|
26598
|
+
try {
|
|
26599
|
+
callback();
|
|
26600
|
+
} finally {
|
|
26601
|
+
this.activeScope = previousScope;
|
|
26602
|
+
}
|
|
26603
|
+
}
|
|
26604
|
+
}, delay);
|
|
26605
|
+
this.timers.add(timer);
|
|
26606
|
+
scope.timers.add(timer);
|
|
26607
|
+
return () => {
|
|
26608
|
+
scope.cancelled = true;
|
|
26609
|
+
scope.timers.forEach((pending) => {
|
|
26610
|
+
clearTimeout(pending);
|
|
26611
|
+
this.timers.delete(pending);
|
|
26612
|
+
});
|
|
26613
|
+
scope.timers.clear();
|
|
26614
|
+
};
|
|
26615
|
+
}
|
|
26616
|
+
request(delay = 0) {
|
|
26617
|
+
return this.scheduleInScope(this.restore, delay, !clientType.isMobile, this.createScope());
|
|
26618
|
+
}
|
|
26619
|
+
cancelPending() {
|
|
26620
|
+
if (this.activeScope) {
|
|
26621
|
+
this.activeScope.cancelled = true;
|
|
26622
|
+
}
|
|
26623
|
+
this.generation += 1;
|
|
26624
|
+
this.timers.forEach((timer) => clearTimeout(timer));
|
|
26625
|
+
this.timers.clear();
|
|
26626
|
+
}
|
|
26627
|
+
acquire() {
|
|
26628
|
+
this.cancelPending();
|
|
26629
|
+
const owner = {};
|
|
26630
|
+
this.owner = owner;
|
|
26631
|
+
return () => {
|
|
26632
|
+
if (this.owner === owner) {
|
|
26633
|
+
this.cancelPending();
|
|
26634
|
+
this.owner = null;
|
|
26635
|
+
}
|
|
26636
|
+
};
|
|
26637
|
+
}
|
|
26638
|
+
destroy() {
|
|
26639
|
+
this.destroyed = true;
|
|
26640
|
+
this.cancelPending();
|
|
26641
|
+
this.owner = null;
|
|
26642
|
+
controllers.delete(this.input);
|
|
26643
|
+
}
|
|
26644
|
+
}
|
|
26645
|
+
function requestInputFocus(input2, delay = 0) {
|
|
26646
|
+
var _a, _b;
|
|
26647
|
+
return (_b = (_a = controllers.get(input2)) == null ? void 0 : _a.request(delay)) != null ? _b : noop$1;
|
|
26648
|
+
}
|
|
26649
|
+
function requestEditorFocus(editor, delay = 0) {
|
|
26650
|
+
if (editor.destroyed) {
|
|
26651
|
+
return noop$1;
|
|
26652
|
+
}
|
|
26653
|
+
if (clientType.isMobile && delay === 0) {
|
|
26654
|
+
editor.focus();
|
|
26655
|
+
return noop$1;
|
|
26656
|
+
}
|
|
26657
|
+
return requestInputFocus(editor.input.inputElement, delay);
|
|
26658
|
+
}
|
|
26659
|
+
function acquireEditorFocus(editor) {
|
|
26660
|
+
var _a, _b;
|
|
26661
|
+
if (clientType.isMobile || editor.destroyed) {
|
|
26662
|
+
return noop$1;
|
|
26663
|
+
}
|
|
26664
|
+
return (_b = (_a = controllers.get(editor.input.inputElement)) == null ? void 0 : _a.acquire()) != null ? _b : noop$1;
|
|
26665
|
+
}
|
|
26558
26666
|
const logger$3W = getLogger("editor-input");
|
|
26559
26667
|
class EditorInput$1 {
|
|
26560
26668
|
constructor(editor, callbacks) {
|
|
@@ -26564,6 +26672,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26564
26672
|
__publicField(this, "callbacks");
|
|
26565
26673
|
__publicField(this, "inputElement");
|
|
26566
26674
|
__publicField(this, "focused", false);
|
|
26675
|
+
__publicField(this, "focusRestoration");
|
|
26567
26676
|
__publicField(this, "handleBlur", () => {
|
|
26568
26677
|
this.editor.emit("blur", this.editor);
|
|
26569
26678
|
this.callbacks.onBlur();
|
|
@@ -26585,12 +26694,20 @@ var __publicField = (obj, key, value) => {
|
|
|
26585
26694
|
const isInDisableScrollMask = this.isInDisableScrollMask(target);
|
|
26586
26695
|
if (target && (isInDisableScrollMask || rootElement === target || rootElement.contains(target))) {
|
|
26587
26696
|
if (!isInDisableScrollMask && !isInBlockTools(target)) {
|
|
26588
|
-
|
|
26697
|
+
const focus = () => {
|
|
26698
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26699
|
+
return;
|
|
26700
|
+
}
|
|
26589
26701
|
this.editor.emit("focus", this.editor);
|
|
26590
26702
|
this.callbacks.onFocus();
|
|
26591
26703
|
this.editor.input.focus({ preventScroll: true });
|
|
26592
26704
|
this.focused = true;
|
|
26593
|
-
}
|
|
26705
|
+
};
|
|
26706
|
+
if (clientType.isMobile) {
|
|
26707
|
+
setTimeout(focus);
|
|
26708
|
+
} else {
|
|
26709
|
+
this.focusRestoration.schedule(focus);
|
|
26710
|
+
}
|
|
26594
26711
|
}
|
|
26595
26712
|
return;
|
|
26596
26713
|
}
|
|
@@ -26725,6 +26842,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26725
26842
|
input2.addEventListener("compositionstart", this.handleCompositionstart);
|
|
26726
26843
|
input2.addEventListener("compositionend", this.handleCompositionend);
|
|
26727
26844
|
this.inputElement = input2;
|
|
26845
|
+
this.focusRestoration = new FocusRestoration(input2, () => {
|
|
26846
|
+
if (!this.editor.destroyed) {
|
|
26847
|
+
this.editor.focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
26848
|
+
}
|
|
26849
|
+
});
|
|
26728
26850
|
if (clientType.isMobile) {
|
|
26729
26851
|
document.addEventListener("touchend", this.handleDocumentClick);
|
|
26730
26852
|
} else {
|
|
@@ -26747,6 +26869,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26747
26869
|
return !!(elem == null ? void 0 : elem.closest("div[data-command-bar-id]")) || !!(elem == null ? void 0 : elem.closest("[data-keep-editor-focus]")) || !!(elem == null ? void 0 : elem.closest(".data-keep-editor-focus"));
|
|
26748
26870
|
}
|
|
26749
26871
|
destroy() {
|
|
26872
|
+
this.focusRestoration.destroy();
|
|
26750
26873
|
this.callbacks.destroy();
|
|
26751
26874
|
if (clientType.isMobile) {
|
|
26752
26875
|
document.removeEventListener("touchend", this.handleDocumentClick);
|
|
@@ -26771,24 +26894,36 @@ var __publicField = (obj, key, value) => {
|
|
|
26771
26894
|
return this.inputElement;
|
|
26772
26895
|
}
|
|
26773
26896
|
focus(options) {
|
|
26897
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26898
|
+
return;
|
|
26899
|
+
}
|
|
26774
26900
|
if (!this.editor.selection.caret.visible()) {
|
|
26775
26901
|
this.editor.selection.caret.update();
|
|
26776
26902
|
}
|
|
26777
26903
|
if (clientType.isMobile) {
|
|
26778
26904
|
this.inputElement.focus(options);
|
|
26779
26905
|
this.callbacks.onFocus();
|
|
26906
|
+
this.focused = true;
|
|
26780
26907
|
} else {
|
|
26781
|
-
|
|
26908
|
+
this.focusRestoration.schedule(() => {
|
|
26909
|
+
if (this.editor.destroyed) {
|
|
26910
|
+
return;
|
|
26911
|
+
}
|
|
26782
26912
|
if (document.activeElement !== this.inputElement) {
|
|
26783
|
-
|
|
26784
|
-
this.editor.
|
|
26913
|
+
this.focusRestoration.schedule(() => {
|
|
26914
|
+
if (!this.editor.destroyed && document.activeElement === this.inputElement) {
|
|
26915
|
+
this.editor.emit("focus", this.editor);
|
|
26916
|
+
}
|
|
26785
26917
|
});
|
|
26786
26918
|
}
|
|
26787
26919
|
this.inputElement.focus(options);
|
|
26920
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26921
|
+
return;
|
|
26922
|
+
}
|
|
26788
26923
|
this.callbacks.onFocus();
|
|
26789
|
-
|
|
26924
|
+
this.focused = true;
|
|
26925
|
+
}, 0, (options == null ? void 0 : options.preventScroll) === true);
|
|
26790
26926
|
}
|
|
26791
|
-
this.focused = true;
|
|
26792
26927
|
}
|
|
26793
26928
|
isInDisableScrollMask(target) {
|
|
26794
26929
|
let elem = target;
|
|
@@ -32464,7 +32599,7 @@ ${codeText}
|
|
|
32464
32599
|
editor.doc.endBatchUpdate();
|
|
32465
32600
|
}
|
|
32466
32601
|
if (!clientType.isMobile) {
|
|
32467
|
-
editor
|
|
32602
|
+
requestEditorFocus(editor);
|
|
32468
32603
|
}
|
|
32469
32604
|
return rangeResult;
|
|
32470
32605
|
});
|
|
@@ -42798,7 +42933,9 @@ ${codeText}
|
|
|
42798
42933
|
});
|
|
42799
42934
|
__publicField(this, "tippyInstance", null);
|
|
42800
42935
|
__publicField(this, "_target", null);
|
|
42936
|
+
__publicField(this, "cancelFocus");
|
|
42801
42937
|
__publicField(this, "focusTimer", null);
|
|
42938
|
+
__publicField(this, "focusRestoreGeneration", 0);
|
|
42802
42939
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42803
42940
|
var _a;
|
|
42804
42941
|
const focusOwner = this.getFocusOwner();
|
|
@@ -42818,6 +42955,9 @@ ${codeText}
|
|
|
42818
42955
|
this.clearFocusTimer();
|
|
42819
42956
|
}
|
|
42820
42957
|
});
|
|
42958
|
+
__publicField(this, "handleWindowBlur", () => {
|
|
42959
|
+
this.clearFocusTimer();
|
|
42960
|
+
});
|
|
42821
42961
|
__publicField(this, "setProps", (props) => {
|
|
42822
42962
|
var _a;
|
|
42823
42963
|
(_a = this.tippyInstance) == null ? void 0 : _a.setProps(props);
|
|
@@ -42836,20 +42976,25 @@ ${codeText}
|
|
|
42836
42976
|
if (!parentEditor || event && !this.isFocusOwner(event.target)) {
|
|
42837
42977
|
return;
|
|
42838
42978
|
}
|
|
42839
|
-
|
|
42840
|
-
document.addEventListener("
|
|
42979
|
+
const generation = this.focusRestoreGeneration;
|
|
42980
|
+
document.addEventListener("mousedown", this.handleFocusInteraction, true);
|
|
42981
|
+
document.addEventListener("focusin", this.handleFocusInteraction, true);
|
|
42982
|
+
window.addEventListener("blur", this.handleWindowBlur);
|
|
42841
42983
|
this.focusTimer = setTimeout(() => {
|
|
42984
|
+
if (generation !== this.focusRestoreGeneration) {
|
|
42985
|
+
return;
|
|
42986
|
+
}
|
|
42842
42987
|
this.clearFocusTimer();
|
|
42843
42988
|
const input2 = parentEditor.querySelector(".editor-input");
|
|
42844
|
-
if (!target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected)) {
|
|
42989
|
+
if (this._target !== target || !target.isConnected || !parentEditor.isConnected || !(input2 == null ? void 0 : input2.isConnected) || !document.hasFocus()) {
|
|
42845
42990
|
return;
|
|
42846
42991
|
}
|
|
42847
42992
|
const activeElement = document.activeElement;
|
|
42848
42993
|
if (parentEditor.contains(activeElement)) {
|
|
42849
42994
|
return;
|
|
42850
42995
|
}
|
|
42851
|
-
if (!activeElement || activeElement === document.body || this.isInCommandBar(activeElement)) {
|
|
42852
|
-
|
|
42996
|
+
if (!activeElement || activeElement === document.body || activeElement === document.documentElement || this.isInCommandBar(activeElement)) {
|
|
42997
|
+
this.cancelFocus = requestInputFocus(input2);
|
|
42853
42998
|
}
|
|
42854
42999
|
}, 100);
|
|
42855
43000
|
}
|
|
@@ -42859,12 +43004,17 @@ ${codeText}
|
|
|
42859
43004
|
return target instanceof Node && (!!(parentEditor == null ? void 0 : parentEditor.contains(target)) || this.isInCommandBar(target));
|
|
42860
43005
|
}
|
|
42861
43006
|
clearFocusTimer() {
|
|
43007
|
+
var _a;
|
|
43008
|
+
this.focusRestoreGeneration += 1;
|
|
43009
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
43010
|
+
this.cancelFocus = void 0;
|
|
42862
43011
|
if (this.focusTimer !== null) {
|
|
42863
43012
|
clearTimeout(this.focusTimer);
|
|
42864
43013
|
this.focusTimer = null;
|
|
42865
43014
|
}
|
|
42866
|
-
document.removeEventListener("mousedown", this.handleFocusInteraction);
|
|
42867
|
-
document.removeEventListener("focusin", this.handleFocusInteraction);
|
|
43015
|
+
document.removeEventListener("mousedown", this.handleFocusInteraction, true);
|
|
43016
|
+
document.removeEventListener("focusin", this.handleFocusInteraction, true);
|
|
43017
|
+
window.removeEventListener("blur", this.handleWindowBlur);
|
|
42868
43018
|
}
|
|
42869
43019
|
manualShow(target, options) {
|
|
42870
43020
|
var _a, _b, _c, _d;
|
|
@@ -42917,7 +43067,7 @@ ${codeText}
|
|
|
42917
43067
|
}
|
|
42918
43068
|
close(reason, e2) {
|
|
42919
43069
|
var _a, _b;
|
|
42920
|
-
if (reason
|
|
43070
|
+
if (reason === "clickBackground" || reason && reason !== "cancelBar" && reason !== "clickItem") {
|
|
42921
43071
|
this.clearFocusTimer();
|
|
42922
43072
|
}
|
|
42923
43073
|
super.close(reason);
|
|
@@ -42930,11 +43080,12 @@ ${codeText}
|
|
|
42930
43080
|
}
|
|
42931
43081
|
}
|
|
42932
43082
|
destroy() {
|
|
42933
|
-
var _a;
|
|
43083
|
+
var _a, _b;
|
|
42934
43084
|
this.clearFocusTimer();
|
|
42935
43085
|
(_a = this.tippyInstance) == null ? void 0 : _a.destroy();
|
|
42936
43086
|
this.tippyInstance = null;
|
|
42937
43087
|
super.destroy();
|
|
43088
|
+
(_b = this.cancelFocus) == null ? void 0 : _b.call(this);
|
|
42938
43089
|
}
|
|
42939
43090
|
getCommandBarRoot() {
|
|
42940
43091
|
return this.content.closest("[data-tippy-root]");
|
|
@@ -45060,19 +45211,22 @@ ${codeText}
|
|
|
45060
45211
|
class EditorAutoSuggestMenu extends AutoSuggestMenu {
|
|
45061
45212
|
constructor(editor, editorOptions) {
|
|
45062
45213
|
super(editorOptions);
|
|
45214
|
+
__publicField(this, "cancelFocus");
|
|
45063
45215
|
__publicField(this, "handleClose", () => {
|
|
45064
|
-
var _a, _b;
|
|
45216
|
+
var _a, _b, _c;
|
|
45217
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
45065
45218
|
if (shouldFocusToEditor(this.editor)) {
|
|
45066
|
-
this.editor
|
|
45219
|
+
this.cancelFocus = requestEditorFocus(this.editor);
|
|
45067
45220
|
}
|
|
45068
|
-
(
|
|
45221
|
+
(_c = (_b = this.options).onClose) == null ? void 0 : _c.call(_b);
|
|
45069
45222
|
});
|
|
45070
45223
|
this.editor = editor;
|
|
45071
45224
|
this.editorOptions = editorOptions;
|
|
45072
45225
|
}
|
|
45073
45226
|
async popupInEditor(containerId, blockIndex, offset) {
|
|
45074
|
-
var _a, _b;
|
|
45075
|
-
|
|
45227
|
+
var _a, _b, _c;
|
|
45228
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
45229
|
+
if (((_c = (_b = this.editorOptions).onShow) == null ? void 0 : _c.call(_b, this, containerId, blockIndex, offset)) === false) {
|
|
45076
45230
|
return;
|
|
45077
45231
|
}
|
|
45078
45232
|
if (this.options.showLoading) {
|
|
@@ -45090,6 +45244,11 @@ ${codeText}
|
|
|
45090
45244
|
const anchor2 = createBlockAnchor(this.editor, block, "editor-auto-suggest-menu", rect);
|
|
45091
45245
|
super.popup(anchor2, { noEvent: true });
|
|
45092
45246
|
}
|
|
45247
|
+
destroy() {
|
|
45248
|
+
var _a;
|
|
45249
|
+
super.destroy();
|
|
45250
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
45251
|
+
}
|
|
45093
45252
|
}
|
|
45094
45253
|
const logger$2H = getLogger("auto-suggest-menu");
|
|
45095
45254
|
class OnesEditorAutoSuggest {
|
|
@@ -54431,6 +54590,7 @@ ${codeText}
|
|
|
54431
54590
|
});
|
|
54432
54591
|
__publicField(this, "close", () => {
|
|
54433
54592
|
this.linkPopup.close("cancelBar");
|
|
54593
|
+
this.emit("close");
|
|
54434
54594
|
});
|
|
54435
54595
|
__publicField(this, "createItems", (content) => [{
|
|
54436
54596
|
id: "link-popup",
|
|
@@ -54452,7 +54612,6 @@ ${codeText}
|
|
|
54452
54612
|
this.emit("finished");
|
|
54453
54613
|
});
|
|
54454
54614
|
__publicField(this, "handleClose", () => {
|
|
54455
|
-
this.emit("close");
|
|
54456
54615
|
this.close();
|
|
54457
54616
|
});
|
|
54458
54617
|
__publicField(this, "handleShown", () => {
|
|
@@ -54481,8 +54640,13 @@ ${codeText}
|
|
|
54481
54640
|
this.linkPopup = new MobileBottomMenu(this.createItems(content), void 0, {
|
|
54482
54641
|
id: "link-popup",
|
|
54483
54642
|
header: this.createHeader(),
|
|
54484
|
-
disableSelectedScroll: true
|
|
54643
|
+
disableSelectedScroll: true,
|
|
54644
|
+
beforeClose: () => {
|
|
54645
|
+
this.handleClose();
|
|
54646
|
+
return true;
|
|
54647
|
+
}
|
|
54485
54648
|
});
|
|
54649
|
+
this.linkPopup.addListener("close", () => this.emit("close"));
|
|
54486
54650
|
}
|
|
54487
54651
|
destroy() {
|
|
54488
54652
|
var _a, _b;
|
|
@@ -54501,11 +54665,11 @@ ${codeText}
|
|
|
54501
54665
|
this.emit("finished");
|
|
54502
54666
|
});
|
|
54503
54667
|
__publicField(this, "handleClose", () => {
|
|
54504
|
-
this.emit("close");
|
|
54505
54668
|
this.close();
|
|
54506
54669
|
});
|
|
54507
54670
|
__publicField(this, "close", () => {
|
|
54508
54671
|
this.linkPopup.close("cancelBar");
|
|
54672
|
+
this.emit("close");
|
|
54509
54673
|
});
|
|
54510
54674
|
__publicField(this, "disabledSubmit", () => {
|
|
54511
54675
|
var _a;
|
|
@@ -54525,8 +54689,13 @@ ${codeText}
|
|
|
54525
54689
|
this.content = content;
|
|
54526
54690
|
this.options = options;
|
|
54527
54691
|
this.linkPopup = new Popup(this.createPopupContent(), {
|
|
54528
|
-
id: "link-popup"
|
|
54692
|
+
id: "link-popup",
|
|
54693
|
+
beforeClose: () => {
|
|
54694
|
+
this.handleClose();
|
|
54695
|
+
return true;
|
|
54696
|
+
}
|
|
54529
54697
|
});
|
|
54698
|
+
this.linkPopup.addListener("close", () => this.emit("close"));
|
|
54530
54699
|
}
|
|
54531
54700
|
createPopupContent() {
|
|
54532
54701
|
const container = createElement("div", ["link-popup-content"], null);
|
|
@@ -54559,46 +54728,85 @@ ${codeText}
|
|
|
54559
54728
|
__publicField(this, "onFinished", null);
|
|
54560
54729
|
__publicField(this, "onClose", null);
|
|
54561
54730
|
__publicField(this, "onBeforeFormatUrl", null);
|
|
54731
|
+
__publicField(this, "session", 0);
|
|
54732
|
+
__publicField(this, "submitting", false);
|
|
54733
|
+
__publicField(this, "focusTimer");
|
|
54734
|
+
__publicField(this, "releaseFocus");
|
|
54562
54735
|
__publicField(this, "handleOk", async () => {
|
|
54563
|
-
|
|
54736
|
+
if (!this.linkPopup || this.submitting || this.editor.destroyed) {
|
|
54737
|
+
return;
|
|
54738
|
+
}
|
|
54739
|
+
const session = this.session;
|
|
54740
|
+
const form = this.form;
|
|
54741
|
+
const onFinished = this.onFinished;
|
|
54742
|
+
const beforeFormatUrl = this.onBeforeFormatUrl;
|
|
54743
|
+
this.submitting = true;
|
|
54564
54744
|
try {
|
|
54565
|
-
await this.checkValue();
|
|
54566
|
-
|
|
54745
|
+
await this.checkValue(form);
|
|
54746
|
+
if (!this.isCurrent(session)) {
|
|
54747
|
+
return;
|
|
54748
|
+
}
|
|
54749
|
+
const { linkText, linkUrl } = form;
|
|
54567
54750
|
const inputValue = linkUrl.getInputValue();
|
|
54568
|
-
|
|
54569
|
-
|
|
54570
|
-
|
|
54571
|
-
|
|
54572
|
-
|
|
54751
|
+
const formatted = beforeFormatUrl == null ? void 0 : beforeFormatUrl(inputValue);
|
|
54752
|
+
const link2 = typeof formatted === "string" ? formatted : this.formatUrl(inputValue);
|
|
54753
|
+
const text2 = linkText.getInputValue() || link2;
|
|
54754
|
+
if (!this.isCurrent(session)) {
|
|
54755
|
+
return;
|
|
54573
54756
|
}
|
|
54574
|
-
(_a = this.onFinished) == null ? void 0 : _a.call(this, linkText.getInputValue() || link2, link2);
|
|
54575
54757
|
this._destroy();
|
|
54758
|
+
onFinished == null ? void 0 : onFinished(text2, link2);
|
|
54576
54759
|
} catch (error2) {
|
|
54760
|
+
if (this.isCurrent(session)) {
|
|
54761
|
+
this.submitting = false;
|
|
54762
|
+
}
|
|
54577
54763
|
}
|
|
54578
54764
|
});
|
|
54579
54765
|
__publicField(this, "handleClose", () => {
|
|
54580
|
-
|
|
54581
|
-
|
|
54766
|
+
if (!this.linkPopup) {
|
|
54767
|
+
return;
|
|
54768
|
+
}
|
|
54769
|
+
const onClose = this.onClose;
|
|
54582
54770
|
this._destroy();
|
|
54771
|
+
if (!this.editor.destroyed) {
|
|
54772
|
+
onClose == null ? void 0 : onClose();
|
|
54773
|
+
}
|
|
54583
54774
|
});
|
|
54584
54775
|
__publicField(this, "onShow", () => {
|
|
54585
|
-
|
|
54586
|
-
|
|
54587
|
-
|
|
54776
|
+
var _a;
|
|
54777
|
+
const session = this.session;
|
|
54778
|
+
const field = (_a = this.form.linkUrl) == null ? void 0 : _a.getField();
|
|
54779
|
+
clearTimeout(this.focusTimer);
|
|
54780
|
+
this.focusTimer = setTimeout(() => {
|
|
54781
|
+
if (this.isCurrent(session) && (field == null ? void 0 : field.isConnected)) {
|
|
54782
|
+
field.focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
54783
|
+
}
|
|
54588
54784
|
}, 400);
|
|
54589
54785
|
});
|
|
54590
54786
|
__publicField(this, "showPopup", (options) => {
|
|
54591
|
-
|
|
54787
|
+
const session = this.session;
|
|
54592
54788
|
if (clientType.isMobile) {
|
|
54593
54789
|
this.linkPopup = new MobileLinkPopup(this.editor, this.createPopupContent(options.linkText, options.linkUrl), options);
|
|
54594
54790
|
} else {
|
|
54595
54791
|
this.linkPopup = new LinkPopup(this.createPopupContent(options.linkText, options.linkUrl), options);
|
|
54596
54792
|
}
|
|
54597
|
-
|
|
54598
|
-
|
|
54599
|
-
|
|
54600
|
-
|
|
54601
|
-
|
|
54793
|
+
this.linkPopup.addListener("show", () => {
|
|
54794
|
+
if (this.isCurrent(session)) {
|
|
54795
|
+
this.onShow();
|
|
54796
|
+
}
|
|
54797
|
+
});
|
|
54798
|
+
this.linkPopup.addListener("finished", () => {
|
|
54799
|
+
if (this.isCurrent(session)) {
|
|
54800
|
+
this.handleOk();
|
|
54801
|
+
}
|
|
54802
|
+
});
|
|
54803
|
+
this.linkPopup.addListener("close", () => {
|
|
54804
|
+
if (this.isCurrent(session)) {
|
|
54805
|
+
this.handleClose();
|
|
54806
|
+
}
|
|
54807
|
+
});
|
|
54808
|
+
this.linkPopup.disabledSubmit();
|
|
54809
|
+
this.linkPopup.manualShow();
|
|
54602
54810
|
});
|
|
54603
54811
|
__publicField(this, "onChange", () => {
|
|
54604
54812
|
var _a;
|
|
@@ -54610,11 +54818,14 @@ ${codeText}
|
|
|
54610
54818
|
return;
|
|
54611
54819
|
}
|
|
54612
54820
|
if (event.key === "Enter") {
|
|
54613
|
-
(_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus();
|
|
54821
|
+
(_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
54822
|
+
event.preventDefault();
|
|
54614
54823
|
event.stopPropagation();
|
|
54615
54824
|
return;
|
|
54616
54825
|
}
|
|
54617
54826
|
if (event.key === "Escape") {
|
|
54827
|
+
event.preventDefault();
|
|
54828
|
+
event.stopPropagation();
|
|
54618
54829
|
this.handleClose();
|
|
54619
54830
|
}
|
|
54620
54831
|
});
|
|
@@ -54628,13 +54839,18 @@ ${codeText}
|
|
|
54628
54839
|
return;
|
|
54629
54840
|
}
|
|
54630
54841
|
if (event.key === "Escape") {
|
|
54842
|
+
event.preventDefault();
|
|
54843
|
+
event.stopPropagation();
|
|
54631
54844
|
this.handleClose();
|
|
54632
54845
|
}
|
|
54633
54846
|
});
|
|
54634
54847
|
this.editor = editor;
|
|
54635
54848
|
}
|
|
54636
|
-
|
|
54637
|
-
|
|
54849
|
+
isCurrent(session) {
|
|
54850
|
+
return session === this.session && !!this.linkPopup && !this.editor.destroyed;
|
|
54851
|
+
}
|
|
54852
|
+
async checkValue(form) {
|
|
54853
|
+
const { linkUrl } = form;
|
|
54638
54854
|
if (!linkUrl.getInputValue()) {
|
|
54639
54855
|
linkUrl.setFieldError(i18n$1.t("link.urlPlaceholder"));
|
|
54640
54856
|
throw new Error(i18n$1.t("link.urlPlaceholder"));
|
|
@@ -54652,14 +54868,20 @@ ${codeText}
|
|
|
54652
54868
|
return link2;
|
|
54653
54869
|
}
|
|
54654
54870
|
editLink(options) {
|
|
54655
|
-
this.
|
|
54871
|
+
this._destroy();
|
|
54872
|
+
if (this.editor.destroyed) {
|
|
54873
|
+
return;
|
|
54874
|
+
}
|
|
54875
|
+
this.releaseFocus = acquireEditorFocus(this.editor);
|
|
54656
54876
|
const { onFinished, onClose, onBeforeFormatUrl } = options;
|
|
54657
54877
|
this.onFinished = onFinished;
|
|
54658
|
-
|
|
54659
|
-
|
|
54660
|
-
|
|
54661
|
-
|
|
54662
|
-
|
|
54878
|
+
this.onClose = onClose != null ? onClose : null;
|
|
54879
|
+
this.onBeforeFormatUrl = onBeforeFormatUrl != null ? onBeforeFormatUrl : null;
|
|
54880
|
+
try {
|
|
54881
|
+
this.showPopup(options);
|
|
54882
|
+
} catch (error2) {
|
|
54883
|
+
this._destroy();
|
|
54884
|
+
throw error2;
|
|
54663
54885
|
}
|
|
54664
54886
|
}
|
|
54665
54887
|
createPopupContent(linkText, linkUrl) {
|
|
@@ -54688,12 +54910,21 @@ ${codeText}
|
|
|
54688
54910
|
return content;
|
|
54689
54911
|
}
|
|
54690
54912
|
_destroy() {
|
|
54691
|
-
|
|
54913
|
+
this.session += 1;
|
|
54914
|
+
clearTimeout(this.focusTimer);
|
|
54915
|
+
this.focusTimer = void 0;
|
|
54916
|
+
const popup = this.linkPopup;
|
|
54917
|
+
const releaseFocus = this.releaseFocus;
|
|
54918
|
+
this.linkPopup = null;
|
|
54919
|
+
this.releaseFocus = void 0;
|
|
54920
|
+
this.submitting = false;
|
|
54692
54921
|
this.onFinished = null;
|
|
54693
54922
|
this.onClose = null;
|
|
54923
|
+
this.onBeforeFormatUrl = null;
|
|
54694
54924
|
this.form = {};
|
|
54695
|
-
|
|
54696
|
-
|
|
54925
|
+
popup == null ? void 0 : popup.removeAllListeners();
|
|
54926
|
+
popup == null ? void 0 : popup.destroy();
|
|
54927
|
+
releaseFocus == null ? void 0 : releaseFocus();
|
|
54697
54928
|
}
|
|
54698
54929
|
destroy() {
|
|
54699
54930
|
this._destroy();
|
|
@@ -54733,14 +54964,14 @@ ${codeText}
|
|
|
54733
54964
|
const text2 = [op1, op2];
|
|
54734
54965
|
editor.insertTextToBlock(block, 0, text2);
|
|
54735
54966
|
editor.selection.selectBlock(block, getTextLength(text2));
|
|
54736
|
-
editor
|
|
54967
|
+
requestEditorFocus(editor);
|
|
54737
54968
|
} catch (error2) {
|
|
54738
54969
|
logger$21.error(error2);
|
|
54739
54970
|
}
|
|
54740
54971
|
});
|
|
54741
54972
|
};
|
|
54742
54973
|
const onClose = () => {
|
|
54743
|
-
editor
|
|
54974
|
+
requestEditorFocus(editor);
|
|
54744
54975
|
};
|
|
54745
54976
|
editLink(editor, {
|
|
54746
54977
|
target: block,
|
|
@@ -54772,21 +55003,21 @@ ${codeText}
|
|
|
54772
55003
|
if (isCollapsed) {
|
|
54773
55004
|
newText = insertText(editor.getBlockText(block), end, linkText, { link: linkUrl });
|
|
54774
55005
|
editor.setBlockText(block, newText);
|
|
54775
|
-
editor
|
|
55006
|
+
requestEditorFocus(editor);
|
|
54776
55007
|
return;
|
|
54777
55008
|
}
|
|
54778
55009
|
newText = replaceText(editor.getBlockText(block), start, end, linkText);
|
|
54779
55010
|
newText = rangeAddAttribute(start, linkText.length, newText, "link", linkUrl);
|
|
54780
55011
|
editor.setBlockText(block, newText);
|
|
54781
55012
|
editor.selection.selectBlock(block, start + linkText.length);
|
|
54782
|
-
editor
|
|
55013
|
+
requestEditorFocus(editor);
|
|
54783
55014
|
} catch (error2) {
|
|
54784
55015
|
logger$21.error(error2);
|
|
54785
55016
|
}
|
|
54786
55017
|
});
|
|
54787
55018
|
};
|
|
54788
55019
|
const onClose = () => {
|
|
54789
|
-
editor
|
|
55020
|
+
requestEditorFocus(editor);
|
|
54790
55021
|
};
|
|
54791
55022
|
editLink(editor, {
|
|
54792
55023
|
target: anchor2,
|
|
@@ -55035,14 +55266,14 @@ ${codeText}
|
|
|
55035
55266
|
const newText = insertText(deleted, range.start, linkText, { link: linkUrl });
|
|
55036
55267
|
editor.setBlockText(block, newText);
|
|
55037
55268
|
editor.selection.selectBlock(block, range.start + linkText.length);
|
|
55038
|
-
editor
|
|
55269
|
+
requestEditorFocus(editor);
|
|
55039
55270
|
} catch (error2) {
|
|
55040
55271
|
logger$20.error(error2);
|
|
55041
55272
|
}
|
|
55042
55273
|
};
|
|
55043
55274
|
const onClose = () => {
|
|
55044
55275
|
editor.selection.selectBlock(block, range.end);
|
|
55045
|
-
editor
|
|
55276
|
+
requestEditorFocus(editor);
|
|
55046
55277
|
};
|
|
55047
55278
|
const rect = getBlockClientRects(editor, block, editor.selection.range)[0];
|
|
55048
55279
|
if (!rect) {
|
|
@@ -55544,6 +55775,7 @@ ${codeText}
|
|
|
55544
55775
|
__publicField(this, "_disableTextToolbar", false);
|
|
55545
55776
|
__publicField(this, "_lastClickTime", 0);
|
|
55546
55777
|
__publicField(this, "_disabled", false);
|
|
55778
|
+
__publicField(this, "cancelFocus");
|
|
55547
55779
|
__publicField(this, "isInToolbar", (event) => this.toolbar.isInCommandBar(event.target));
|
|
55548
55780
|
__publicField(this, "handleButtonClick", (toolbar2, item) => {
|
|
55549
55781
|
const tooltip = this.editor.findCustom("editor-tooltip");
|
|
@@ -55567,17 +55799,23 @@ ${codeText}
|
|
|
55567
55799
|
}
|
|
55568
55800
|
this._lastClickTime = Date.now();
|
|
55569
55801
|
});
|
|
55570
|
-
__publicField(this, "handleClose", () => {
|
|
55571
|
-
var _a;
|
|
55802
|
+
__publicField(this, "handleClose", (toolbar2) => {
|
|
55803
|
+
var _a, _b;
|
|
55804
|
+
if (toolbar2.closeReason === "clickBackground" || !this.editor.rootElement.isConnected) {
|
|
55805
|
+
return;
|
|
55806
|
+
}
|
|
55807
|
+
const focusedElement = document.activeElement;
|
|
55808
|
+
if (focusedElement && focusedElement !== document.body && focusedElement !== document.documentElement && !this.editor.rootElement.contains(focusedElement) && !toolbar2.isInCommandBar(focusedElement)) {
|
|
55809
|
+
return;
|
|
55810
|
+
}
|
|
55572
55811
|
if (shouldFocusToEditor(this.editor) && !clientType.isMobile) {
|
|
55573
55812
|
const activeElement = (_a = document.getSelection()) == null ? void 0 : _a.focusNode;
|
|
55574
55813
|
if (activeElement && isInBlockTools(activeElement)) {
|
|
55575
55814
|
logger$1_.debug("focus is in block tools, ignore focus");
|
|
55576
55815
|
return;
|
|
55577
55816
|
}
|
|
55578
|
-
this.
|
|
55579
|
-
|
|
55580
|
-
});
|
|
55817
|
+
(_b = this.cancelFocus) == null ? void 0 : _b.call(this);
|
|
55818
|
+
this.cancelFocus = requestEditorFocus(this.editor);
|
|
55581
55819
|
}
|
|
55582
55820
|
});
|
|
55583
55821
|
__publicField(this, "handleClosing", (bar2, event) => {
|
|
@@ -55706,8 +55944,10 @@ ${codeText}
|
|
|
55706
55944
|
this.toolbar.close("selectionChange");
|
|
55707
55945
|
}
|
|
55708
55946
|
destroy() {
|
|
55947
|
+
var _a;
|
|
55709
55948
|
this.unbindEvents();
|
|
55710
55949
|
this.toolbar.destroy();
|
|
55950
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
55711
55951
|
this.editor.removeListener("selectionChanged", this.handleSelectionChange);
|
|
55712
55952
|
OnesEditorHoveringBlock.get(this.editor).removeListener("childChange", this.handleHoveringBlockChildChange);
|
|
55713
55953
|
}
|
|
@@ -97316,14 +97556,13 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97316
97556
|
__publicField(this, "toolbar");
|
|
97317
97557
|
__publicField(this, "toolbarFullScreen");
|
|
97318
97558
|
__publicField(this, "root");
|
|
97559
|
+
__publicField(this, "cancelFocus");
|
|
97319
97560
|
__publicField(this, "handleClick", (bar2, item) => {
|
|
97320
97561
|
const command = item;
|
|
97321
97562
|
if (command.onClick) {
|
|
97322
97563
|
command.onClick(this.editor, command, bar2);
|
|
97323
97564
|
this.handleSelectionChanged();
|
|
97324
|
-
|
|
97325
|
-
this.editor.focus();
|
|
97326
|
-
});
|
|
97565
|
+
this.restoreFocus();
|
|
97327
97566
|
return;
|
|
97328
97567
|
}
|
|
97329
97568
|
const findParent = (item2, id) => {
|
|
@@ -97369,9 +97608,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97369
97608
|
id: "main-toolbar"
|
|
97370
97609
|
});
|
|
97371
97610
|
this.toolbar.addListener("closing", () => {
|
|
97372
|
-
|
|
97373
|
-
editor.focus();
|
|
97374
|
-
}, 100);
|
|
97611
|
+
this.restoreFocus(100);
|
|
97375
97612
|
return true;
|
|
97376
97613
|
});
|
|
97377
97614
|
this.toolbar.addListener("click", this.handleClick);
|
|
@@ -97402,11 +97639,18 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97402
97639
|
});
|
|
97403
97640
|
}
|
|
97404
97641
|
}
|
|
97405
|
-
|
|
97642
|
+
restoreFocus(delay = 0) {
|
|
97406
97643
|
var _a;
|
|
97644
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
97645
|
+
this.cancelFocus = requestEditorFocus(this.editor, delay);
|
|
97646
|
+
}
|
|
97647
|
+
destroy() {
|
|
97648
|
+
var _a, _b, _c;
|
|
97649
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
97407
97650
|
this.toolbar.destroy();
|
|
97408
97651
|
this.editor.removeListener("selectionChanged", this.handleSelectionChanged);
|
|
97409
|
-
(
|
|
97652
|
+
(_b = this.toolbarFullScreen) == null ? void 0 : _b.destroy();
|
|
97653
|
+
(_c = this.cancelFocus) == null ? void 0 : _c.call(this);
|
|
97410
97654
|
this.root.remove();
|
|
97411
97655
|
}
|
|
97412
97656
|
setItems(items) {
|
|
@@ -98129,7 +98373,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98129
98373
|
}
|
|
98130
98374
|
}
|
|
98131
98375
|
});
|
|
98132
|
-
editor.version = "5.0.8-beta.h1475.
|
|
98376
|
+
editor.version = "5.0.8-beta.h1475.3";
|
|
98133
98377
|
return editor;
|
|
98134
98378
|
}
|
|
98135
98379
|
function isDoc(doc2) {
|
|
@@ -98265,7 +98509,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98265
98509
|
OnesEditorDropTarget.register(editor);
|
|
98266
98510
|
OnesEditorTocProvider.register(editor);
|
|
98267
98511
|
OnesEditorExclusiveBlock.register(editor);
|
|
98268
|
-
editor.version = "5.0.8-beta.h1475.
|
|
98512
|
+
editor.version = "5.0.8-beta.h1475.3";
|
|
98269
98513
|
return editor;
|
|
98270
98514
|
} catch (error2) {
|
|
98271
98515
|
try {
|
|
@@ -98408,7 +98652,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98408
98652
|
}
|
|
98409
98653
|
}
|
|
98410
98654
|
});
|
|
98411
|
-
editor.version = "5.0.8-beta.h1475.
|
|
98655
|
+
editor.version = "5.0.8-beta.h1475.3";
|
|
98412
98656
|
return editor;
|
|
98413
98657
|
}
|
|
98414
98658
|
const emojis$1 = {
|
|
@@ -144234,6 +144478,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144234
144478
|
exports2.FindReplaceItem = FindReplaceItem;
|
|
144235
144479
|
exports2.FitIcon = FitIcon;
|
|
144236
144480
|
exports2.FixedToolbar = FixedToolbar;
|
|
144481
|
+
exports2.FocusRestoration = FocusRestoration;
|
|
144237
144482
|
exports2.FontBoldItem = FontBoldItem;
|
|
144238
144483
|
exports2.FontItalicItem = FontItalicItem;
|
|
144239
144484
|
exports2.FontStrikethroughItem = FontStrikethroughItem;
|
|
@@ -144433,6 +144678,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144433
144678
|
exports2.YoukuIcon = YoukuIcon;
|
|
144434
144679
|
exports2.ZERO_WIDTH_SPACE_CHAR = ZERO_WIDTH_SPACE_CHAR;
|
|
144435
144680
|
exports2.abbreviation = abbreviation;
|
|
144681
|
+
exports2.acquireEditorFocus = acquireEditorFocus;
|
|
144436
144682
|
exports2.activeComment = activeComment;
|
|
144437
144683
|
exports2.addAttribute = addAttribute;
|
|
144438
144684
|
exports2.addClass = addClass;
|
|
@@ -144925,6 +145171,8 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144925
145171
|
exports2.replaceText = replaceText;
|
|
144926
145172
|
exports2.replaceWikiMacroResources = replaceWikiMacroResources;
|
|
144927
145173
|
exports2.requestDownload = requestDownload;
|
|
145174
|
+
exports2.requestEditorFocus = requestEditorFocus;
|
|
145175
|
+
exports2.requestInputFocus = requestInputFocus;
|
|
144928
145176
|
exports2.resetListStart = resetListStart;
|
|
144929
145177
|
exports2.saveAs = saveAs$1;
|
|
144930
145178
|
exports2.scrollBarIntoView = scrollBarIntoView;
|