@ones-editor/editor 4.0.7-beta.ONES22303263.1 → 4.0.7-beta.h1474.2
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 +1 -0
- 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 +1 -0
- package/dist/index.js +303 -73
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26485,6 +26485,114 @@ var __publicField = (obj, key, value) => {
|
|
|
26485
26485
|
};
|
|
26486
26486
|
}
|
|
26487
26487
|
}
|
|
26488
|
+
const controllers = /* @__PURE__ */ new WeakMap();
|
|
26489
|
+
const noop$1 = () => {
|
|
26490
|
+
};
|
|
26491
|
+
class FocusRestoration {
|
|
26492
|
+
constructor(input2, restore) {
|
|
26493
|
+
__publicField(this, "generation", 0);
|
|
26494
|
+
__publicField(this, "owner", null);
|
|
26495
|
+
__publicField(this, "destroyed", false);
|
|
26496
|
+
__publicField(this, "activeScope");
|
|
26497
|
+
__publicField(this, "timers", /* @__PURE__ */ new Set());
|
|
26498
|
+
this.input = input2;
|
|
26499
|
+
this.restore = restore;
|
|
26500
|
+
controllers.set(input2, this);
|
|
26501
|
+
}
|
|
26502
|
+
canFocus() {
|
|
26503
|
+
var _a;
|
|
26504
|
+
return !this.destroyed && !this.owner && !((_a = this.activeScope) == null ? void 0 : _a.cancelled) && this.input.isConnected;
|
|
26505
|
+
}
|
|
26506
|
+
hasOtherInput() {
|
|
26507
|
+
const active = this.input.ownerDocument.activeElement;
|
|
26508
|
+
return active !== this.input && !!(active == null ? void 0 : active.matches('input, textarea, select, [contenteditable="true"], [contenteditable=""]'));
|
|
26509
|
+
}
|
|
26510
|
+
schedule(callback, delay = 0, protectUserFocus = false) {
|
|
26511
|
+
var _a;
|
|
26512
|
+
return this.scheduleInScope(callback, delay, protectUserFocus, (_a = this.activeScope) != null ? _a : this.createScope());
|
|
26513
|
+
}
|
|
26514
|
+
createScope() {
|
|
26515
|
+
return { cancelled: false, timers: /* @__PURE__ */ new Set() };
|
|
26516
|
+
}
|
|
26517
|
+
scheduleInScope(callback, delay, protectUserFocus, scope) {
|
|
26518
|
+
if (scope.cancelled || !this.canFocus()) {
|
|
26519
|
+
return noop$1;
|
|
26520
|
+
}
|
|
26521
|
+
const generation = this.generation;
|
|
26522
|
+
const timer = setTimeout(() => {
|
|
26523
|
+
this.timers.delete(timer);
|
|
26524
|
+
scope.timers.delete(timer);
|
|
26525
|
+
if (!scope.cancelled && generation === this.generation && this.canFocus() && (!protectUserFocus || !this.hasOtherInput())) {
|
|
26526
|
+
const previousScope = this.activeScope;
|
|
26527
|
+
this.activeScope = scope;
|
|
26528
|
+
try {
|
|
26529
|
+
callback();
|
|
26530
|
+
} finally {
|
|
26531
|
+
this.activeScope = previousScope;
|
|
26532
|
+
}
|
|
26533
|
+
}
|
|
26534
|
+
}, delay);
|
|
26535
|
+
this.timers.add(timer);
|
|
26536
|
+
scope.timers.add(timer);
|
|
26537
|
+
return () => {
|
|
26538
|
+
scope.cancelled = true;
|
|
26539
|
+
scope.timers.forEach((pending) => {
|
|
26540
|
+
clearTimeout(pending);
|
|
26541
|
+
this.timers.delete(pending);
|
|
26542
|
+
});
|
|
26543
|
+
scope.timers.clear();
|
|
26544
|
+
};
|
|
26545
|
+
}
|
|
26546
|
+
request(delay = 0) {
|
|
26547
|
+
return this.scheduleInScope(this.restore, delay, !clientType.isMobile, this.createScope());
|
|
26548
|
+
}
|
|
26549
|
+
cancelPending() {
|
|
26550
|
+
if (this.activeScope) {
|
|
26551
|
+
this.activeScope.cancelled = true;
|
|
26552
|
+
}
|
|
26553
|
+
this.generation += 1;
|
|
26554
|
+
this.timers.forEach((timer) => clearTimeout(timer));
|
|
26555
|
+
this.timers.clear();
|
|
26556
|
+
}
|
|
26557
|
+
acquire() {
|
|
26558
|
+
this.cancelPending();
|
|
26559
|
+
const owner = {};
|
|
26560
|
+
this.owner = owner;
|
|
26561
|
+
return () => {
|
|
26562
|
+
if (this.owner === owner) {
|
|
26563
|
+
this.cancelPending();
|
|
26564
|
+
this.owner = null;
|
|
26565
|
+
}
|
|
26566
|
+
};
|
|
26567
|
+
}
|
|
26568
|
+
destroy() {
|
|
26569
|
+
this.destroyed = true;
|
|
26570
|
+
this.cancelPending();
|
|
26571
|
+
this.owner = null;
|
|
26572
|
+
controllers.delete(this.input);
|
|
26573
|
+
}
|
|
26574
|
+
}
|
|
26575
|
+
function requestInputFocus(input2, delay = 0) {
|
|
26576
|
+
var _a, _b;
|
|
26577
|
+
return (_b = (_a = controllers.get(input2)) == null ? void 0 : _a.request(delay)) != null ? _b : noop$1;
|
|
26578
|
+
}
|
|
26579
|
+
function requestEditorFocus(editor, delay = 0) {
|
|
26580
|
+
if (editor.destroyed) {
|
|
26581
|
+
return noop$1;
|
|
26582
|
+
}
|
|
26583
|
+
if (clientType.isMobile && delay === 0) {
|
|
26584
|
+
editor.focus();
|
|
26585
|
+
return noop$1;
|
|
26586
|
+
}
|
|
26587
|
+
return requestInputFocus(editor.input.inputElement, delay);
|
|
26588
|
+
}
|
|
26589
|
+
function acquireEditorFocus(editor) {
|
|
26590
|
+
var _a, _b;
|
|
26591
|
+
if (clientType.isMobile || editor.destroyed) {
|
|
26592
|
+
return noop$1;
|
|
26593
|
+
}
|
|
26594
|
+
return (_b = (_a = controllers.get(editor.input.inputElement)) == null ? void 0 : _a.acquire()) != null ? _b : noop$1;
|
|
26595
|
+
}
|
|
26488
26596
|
const logger$3V = getLogger("editor-input");
|
|
26489
26597
|
class EditorInput$1 {
|
|
26490
26598
|
constructor(editor, callbacks) {
|
|
@@ -26494,6 +26602,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26494
26602
|
__publicField(this, "callbacks");
|
|
26495
26603
|
__publicField(this, "inputElement");
|
|
26496
26604
|
__publicField(this, "focused", false);
|
|
26605
|
+
__publicField(this, "focusRestoration");
|
|
26497
26606
|
__publicField(this, "handleBlur", () => {
|
|
26498
26607
|
this.editor.emit("blur", this.editor);
|
|
26499
26608
|
this.callbacks.onBlur();
|
|
@@ -26515,12 +26624,20 @@ var __publicField = (obj, key, value) => {
|
|
|
26515
26624
|
const isInDisableScrollMask = this.isInDisableScrollMask(target);
|
|
26516
26625
|
if (target && (isInDisableScrollMask || rootElement === target || rootElement.contains(target))) {
|
|
26517
26626
|
if (!isInDisableScrollMask && !isInBlockTools(target)) {
|
|
26518
|
-
|
|
26627
|
+
const focus = () => {
|
|
26628
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26629
|
+
return;
|
|
26630
|
+
}
|
|
26519
26631
|
this.editor.emit("focus", this.editor);
|
|
26520
26632
|
this.callbacks.onFocus();
|
|
26521
26633
|
this.editor.input.focus();
|
|
26522
26634
|
this.focused = true;
|
|
26523
|
-
}
|
|
26635
|
+
};
|
|
26636
|
+
if (clientType.isMobile) {
|
|
26637
|
+
setTimeout(focus);
|
|
26638
|
+
} else {
|
|
26639
|
+
this.focusRestoration.schedule(focus);
|
|
26640
|
+
}
|
|
26524
26641
|
}
|
|
26525
26642
|
return;
|
|
26526
26643
|
}
|
|
@@ -26655,6 +26772,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26655
26772
|
input2.addEventListener("compositionstart", this.handleCompositionstart);
|
|
26656
26773
|
input2.addEventListener("compositionend", this.handleCompositionend);
|
|
26657
26774
|
this.inputElement = input2;
|
|
26775
|
+
this.focusRestoration = new FocusRestoration(input2, () => {
|
|
26776
|
+
if (!this.editor.destroyed) {
|
|
26777
|
+
this.editor.focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
26778
|
+
}
|
|
26779
|
+
});
|
|
26658
26780
|
if (clientType.isMobile) {
|
|
26659
26781
|
document.addEventListener("touchend", this.handleDocumentClick);
|
|
26660
26782
|
} else {
|
|
@@ -26677,6 +26799,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26677
26799
|
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"));
|
|
26678
26800
|
}
|
|
26679
26801
|
destroy() {
|
|
26802
|
+
this.focusRestoration.destroy();
|
|
26680
26803
|
this.callbacks.destroy();
|
|
26681
26804
|
if (clientType.isMobile) {
|
|
26682
26805
|
document.removeEventListener("touchend", this.handleDocumentClick);
|
|
@@ -26701,24 +26824,36 @@ var __publicField = (obj, key, value) => {
|
|
|
26701
26824
|
return this.inputElement;
|
|
26702
26825
|
}
|
|
26703
26826
|
focus(options) {
|
|
26827
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26828
|
+
return;
|
|
26829
|
+
}
|
|
26704
26830
|
if (!this.editor.selection.caret.visible()) {
|
|
26705
26831
|
this.editor.selection.caret.update();
|
|
26706
26832
|
}
|
|
26707
26833
|
if (clientType.isMobile) {
|
|
26708
26834
|
this.inputElement.focus(options);
|
|
26709
26835
|
this.callbacks.onFocus();
|
|
26836
|
+
this.focused = true;
|
|
26710
26837
|
} else {
|
|
26711
|
-
|
|
26838
|
+
this.focusRestoration.schedule(() => {
|
|
26839
|
+
if (this.editor.destroyed) {
|
|
26840
|
+
return;
|
|
26841
|
+
}
|
|
26712
26842
|
if (document.activeElement !== this.inputElement) {
|
|
26713
|
-
|
|
26714
|
-
this.editor.
|
|
26843
|
+
this.focusRestoration.schedule(() => {
|
|
26844
|
+
if (!this.editor.destroyed && document.activeElement === this.inputElement) {
|
|
26845
|
+
this.editor.emit("focus", this.editor);
|
|
26846
|
+
}
|
|
26715
26847
|
});
|
|
26716
26848
|
}
|
|
26717
26849
|
this.inputElement.focus(options);
|
|
26850
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26851
|
+
return;
|
|
26852
|
+
}
|
|
26718
26853
|
this.callbacks.onFocus();
|
|
26719
|
-
|
|
26854
|
+
this.focused = true;
|
|
26855
|
+
}, 0, (options == null ? void 0 : options.preventScroll) === true);
|
|
26720
26856
|
}
|
|
26721
|
-
this.focused = true;
|
|
26722
26857
|
}
|
|
26723
26858
|
isInDisableScrollMask(target) {
|
|
26724
26859
|
let elem = target;
|
|
@@ -32282,7 +32417,7 @@ ${codeText}
|
|
|
32282
32417
|
editor.doc.endBatchUpdate();
|
|
32283
32418
|
}
|
|
32284
32419
|
if (!clientType.isMobile) {
|
|
32285
|
-
editor
|
|
32420
|
+
requestEditorFocus(editor);
|
|
32286
32421
|
}
|
|
32287
32422
|
return rangeResult;
|
|
32288
32423
|
});
|
|
@@ -42594,6 +42729,7 @@ ${codeText}
|
|
|
42594
42729
|
});
|
|
42595
42730
|
__publicField(this, "tippyInstance", null);
|
|
42596
42731
|
__publicField(this, "_target", null);
|
|
42732
|
+
__publicField(this, "cancelFocus");
|
|
42597
42733
|
__publicField(this, "focusTimer", null);
|
|
42598
42734
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42599
42735
|
var _a;
|
|
@@ -42645,7 +42781,7 @@ ${codeText}
|
|
|
42645
42781
|
return;
|
|
42646
42782
|
}
|
|
42647
42783
|
if (!activeElement || activeElement === document.body || this.isInCommandBar(activeElement)) {
|
|
42648
|
-
|
|
42784
|
+
this.cancelFocus = requestInputFocus(input2);
|
|
42649
42785
|
}
|
|
42650
42786
|
}, 100);
|
|
42651
42787
|
}
|
|
@@ -42655,6 +42791,9 @@ ${codeText}
|
|
|
42655
42791
|
return target instanceof Node && (!!(parentEditor == null ? void 0 : parentEditor.contains(target)) || this.isInCommandBar(target));
|
|
42656
42792
|
}
|
|
42657
42793
|
clearFocusTimer() {
|
|
42794
|
+
var _a;
|
|
42795
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
42796
|
+
this.cancelFocus = void 0;
|
|
42658
42797
|
if (this.focusTimer !== null) {
|
|
42659
42798
|
clearTimeout(this.focusTimer);
|
|
42660
42799
|
this.focusTimer = null;
|
|
@@ -42726,11 +42865,12 @@ ${codeText}
|
|
|
42726
42865
|
}
|
|
42727
42866
|
}
|
|
42728
42867
|
destroy() {
|
|
42729
|
-
var _a;
|
|
42868
|
+
var _a, _b;
|
|
42730
42869
|
this.clearFocusTimer();
|
|
42731
42870
|
(_a = this.tippyInstance) == null ? void 0 : _a.destroy();
|
|
42732
42871
|
this.tippyInstance = null;
|
|
42733
42872
|
super.destroy();
|
|
42873
|
+
(_b = this.cancelFocus) == null ? void 0 : _b.call(this);
|
|
42734
42874
|
}
|
|
42735
42875
|
getCommandBarRoot() {
|
|
42736
42876
|
return this.content.closest("[data-tippy-root]");
|
|
@@ -44856,19 +44996,22 @@ ${codeText}
|
|
|
44856
44996
|
class EditorAutoSuggestMenu extends AutoSuggestMenu {
|
|
44857
44997
|
constructor(editor, editorOptions) {
|
|
44858
44998
|
super(editorOptions);
|
|
44999
|
+
__publicField(this, "cancelFocus");
|
|
44859
45000
|
__publicField(this, "handleClose", () => {
|
|
44860
|
-
var _a, _b;
|
|
45001
|
+
var _a, _b, _c;
|
|
45002
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
44861
45003
|
if (shouldFocusToEditor(this.editor)) {
|
|
44862
|
-
this.editor
|
|
45004
|
+
this.cancelFocus = requestEditorFocus(this.editor);
|
|
44863
45005
|
}
|
|
44864
|
-
(
|
|
45006
|
+
(_c = (_b = this.options).onClose) == null ? void 0 : _c.call(_b);
|
|
44865
45007
|
});
|
|
44866
45008
|
this.editor = editor;
|
|
44867
45009
|
this.editorOptions = editorOptions;
|
|
44868
45010
|
}
|
|
44869
45011
|
async popupInEditor(containerId, blockIndex, offset) {
|
|
44870
|
-
var _a, _b;
|
|
44871
|
-
|
|
45012
|
+
var _a, _b, _c;
|
|
45013
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
45014
|
+
if (((_c = (_b = this.editorOptions).onShow) == null ? void 0 : _c.call(_b, this, containerId, blockIndex, offset)) === false) {
|
|
44872
45015
|
return;
|
|
44873
45016
|
}
|
|
44874
45017
|
if (this.options.showLoading) {
|
|
@@ -44886,6 +45029,11 @@ ${codeText}
|
|
|
44886
45029
|
const anchor2 = createBlockAnchor(this.editor, block, "editor-auto-suggest-menu", rect);
|
|
44887
45030
|
super.popup(anchor2, { noEvent: true });
|
|
44888
45031
|
}
|
|
45032
|
+
destroy() {
|
|
45033
|
+
var _a;
|
|
45034
|
+
super.destroy();
|
|
45035
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
45036
|
+
}
|
|
44889
45037
|
}
|
|
44890
45038
|
const logger$2G = getLogger("auto-suggest-menu");
|
|
44891
45039
|
class OnesEditorAutoSuggest {
|
|
@@ -54227,6 +54375,7 @@ ${codeText}
|
|
|
54227
54375
|
});
|
|
54228
54376
|
__publicField(this, "close", () => {
|
|
54229
54377
|
this.linkPopup.close("cancelBar");
|
|
54378
|
+
this.emit("close");
|
|
54230
54379
|
});
|
|
54231
54380
|
__publicField(this, "createItems", (content) => [{
|
|
54232
54381
|
id: "link-popup",
|
|
@@ -54248,7 +54397,6 @@ ${codeText}
|
|
|
54248
54397
|
this.emit("finished");
|
|
54249
54398
|
});
|
|
54250
54399
|
__publicField(this, "handleClose", () => {
|
|
54251
|
-
this.emit("close");
|
|
54252
54400
|
this.close();
|
|
54253
54401
|
});
|
|
54254
54402
|
__publicField(this, "handleShown", () => {
|
|
@@ -54277,8 +54425,13 @@ ${codeText}
|
|
|
54277
54425
|
this.linkPopup = new MobileBottomMenu(this.createItems(content), void 0, {
|
|
54278
54426
|
id: "link-popup",
|
|
54279
54427
|
header: this.createHeader(),
|
|
54280
|
-
disableSelectedScroll: true
|
|
54428
|
+
disableSelectedScroll: true,
|
|
54429
|
+
beforeClose: () => {
|
|
54430
|
+
this.handleClose();
|
|
54431
|
+
return true;
|
|
54432
|
+
}
|
|
54281
54433
|
});
|
|
54434
|
+
this.linkPopup.addListener("close", () => this.emit("close"));
|
|
54282
54435
|
}
|
|
54283
54436
|
destroy() {
|
|
54284
54437
|
var _a, _b;
|
|
@@ -54297,11 +54450,11 @@ ${codeText}
|
|
|
54297
54450
|
this.emit("finished");
|
|
54298
54451
|
});
|
|
54299
54452
|
__publicField(this, "handleClose", () => {
|
|
54300
|
-
this.emit("close");
|
|
54301
54453
|
this.close();
|
|
54302
54454
|
});
|
|
54303
54455
|
__publicField(this, "close", () => {
|
|
54304
54456
|
this.linkPopup.close("cancelBar");
|
|
54457
|
+
this.emit("close");
|
|
54305
54458
|
});
|
|
54306
54459
|
__publicField(this, "disabledSubmit", () => {
|
|
54307
54460
|
var _a;
|
|
@@ -54321,8 +54474,13 @@ ${codeText}
|
|
|
54321
54474
|
this.content = content;
|
|
54322
54475
|
this.options = options;
|
|
54323
54476
|
this.linkPopup = new Popup(this.createPopupContent(), {
|
|
54324
|
-
id: "link-popup"
|
|
54477
|
+
id: "link-popup",
|
|
54478
|
+
beforeClose: () => {
|
|
54479
|
+
this.handleClose();
|
|
54480
|
+
return true;
|
|
54481
|
+
}
|
|
54325
54482
|
});
|
|
54483
|
+
this.linkPopup.addListener("close", () => this.emit("close"));
|
|
54326
54484
|
}
|
|
54327
54485
|
createPopupContent() {
|
|
54328
54486
|
const container = createElement("div", ["link-popup-content"], null);
|
|
@@ -54355,46 +54513,85 @@ ${codeText}
|
|
|
54355
54513
|
__publicField(this, "onFinished", null);
|
|
54356
54514
|
__publicField(this, "onClose", null);
|
|
54357
54515
|
__publicField(this, "onBeforeFormatUrl", null);
|
|
54516
|
+
__publicField(this, "session", 0);
|
|
54517
|
+
__publicField(this, "submitting", false);
|
|
54518
|
+
__publicField(this, "focusTimer");
|
|
54519
|
+
__publicField(this, "releaseFocus");
|
|
54358
54520
|
__publicField(this, "handleOk", async () => {
|
|
54359
|
-
|
|
54521
|
+
if (!this.linkPopup || this.submitting || this.editor.destroyed) {
|
|
54522
|
+
return;
|
|
54523
|
+
}
|
|
54524
|
+
const session = this.session;
|
|
54525
|
+
const form = this.form;
|
|
54526
|
+
const onFinished = this.onFinished;
|
|
54527
|
+
const beforeFormatUrl = this.onBeforeFormatUrl;
|
|
54528
|
+
this.submitting = true;
|
|
54360
54529
|
try {
|
|
54361
|
-
await this.checkValue();
|
|
54362
|
-
|
|
54530
|
+
await this.checkValue(form);
|
|
54531
|
+
if (!this.isCurrent(session)) {
|
|
54532
|
+
return;
|
|
54533
|
+
}
|
|
54534
|
+
const { linkText, linkUrl } = form;
|
|
54363
54535
|
const inputValue = linkUrl.getInputValue();
|
|
54364
|
-
|
|
54365
|
-
|
|
54366
|
-
|
|
54367
|
-
|
|
54368
|
-
|
|
54536
|
+
const formatted = beforeFormatUrl == null ? void 0 : beforeFormatUrl(inputValue);
|
|
54537
|
+
const link2 = typeof formatted === "string" ? formatted : this.formatUrl(inputValue);
|
|
54538
|
+
const text2 = linkText.getInputValue() || link2;
|
|
54539
|
+
if (!this.isCurrent(session)) {
|
|
54540
|
+
return;
|
|
54369
54541
|
}
|
|
54370
|
-
(_a = this.onFinished) == null ? void 0 : _a.call(this, linkText.getInputValue() || link2, link2);
|
|
54371
54542
|
this._destroy();
|
|
54543
|
+
onFinished == null ? void 0 : onFinished(text2, link2);
|
|
54372
54544
|
} catch (error2) {
|
|
54545
|
+
if (this.isCurrent(session)) {
|
|
54546
|
+
this.submitting = false;
|
|
54547
|
+
}
|
|
54373
54548
|
}
|
|
54374
54549
|
});
|
|
54375
54550
|
__publicField(this, "handleClose", () => {
|
|
54376
|
-
|
|
54377
|
-
|
|
54551
|
+
if (!this.linkPopup) {
|
|
54552
|
+
return;
|
|
54553
|
+
}
|
|
54554
|
+
const onClose = this.onClose;
|
|
54378
54555
|
this._destroy();
|
|
54556
|
+
if (!this.editor.destroyed) {
|
|
54557
|
+
onClose == null ? void 0 : onClose();
|
|
54558
|
+
}
|
|
54379
54559
|
});
|
|
54380
54560
|
__publicField(this, "onShow", () => {
|
|
54381
|
-
|
|
54382
|
-
|
|
54383
|
-
|
|
54561
|
+
var _a;
|
|
54562
|
+
const session = this.session;
|
|
54563
|
+
const field = (_a = this.form.linkUrl) == null ? void 0 : _a.getField();
|
|
54564
|
+
clearTimeout(this.focusTimer);
|
|
54565
|
+
this.focusTimer = setTimeout(() => {
|
|
54566
|
+
if (this.isCurrent(session) && (field == null ? void 0 : field.isConnected)) {
|
|
54567
|
+
field.focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
54568
|
+
}
|
|
54384
54569
|
}, 400);
|
|
54385
54570
|
});
|
|
54386
54571
|
__publicField(this, "showPopup", (options) => {
|
|
54387
|
-
|
|
54572
|
+
const session = this.session;
|
|
54388
54573
|
if (clientType.isMobile) {
|
|
54389
54574
|
this.linkPopup = new MobileLinkPopup(this.editor, this.createPopupContent(options.linkText, options.linkUrl), options);
|
|
54390
54575
|
} else {
|
|
54391
54576
|
this.linkPopup = new LinkPopup(this.createPopupContent(options.linkText, options.linkUrl), options);
|
|
54392
54577
|
}
|
|
54393
|
-
|
|
54394
|
-
|
|
54395
|
-
|
|
54396
|
-
|
|
54397
|
-
|
|
54578
|
+
this.linkPopup.addListener("show", () => {
|
|
54579
|
+
if (this.isCurrent(session)) {
|
|
54580
|
+
this.onShow();
|
|
54581
|
+
}
|
|
54582
|
+
});
|
|
54583
|
+
this.linkPopup.addListener("finished", () => {
|
|
54584
|
+
if (this.isCurrent(session)) {
|
|
54585
|
+
this.handleOk();
|
|
54586
|
+
}
|
|
54587
|
+
});
|
|
54588
|
+
this.linkPopup.addListener("close", () => {
|
|
54589
|
+
if (this.isCurrent(session)) {
|
|
54590
|
+
this.handleClose();
|
|
54591
|
+
}
|
|
54592
|
+
});
|
|
54593
|
+
this.linkPopup.disabledSubmit();
|
|
54594
|
+
this.linkPopup.manualShow();
|
|
54398
54595
|
});
|
|
54399
54596
|
__publicField(this, "onChange", () => {
|
|
54400
54597
|
var _a;
|
|
@@ -54406,11 +54603,14 @@ ${codeText}
|
|
|
54406
54603
|
return;
|
|
54407
54604
|
}
|
|
54408
54605
|
if (event.key === "Enter") {
|
|
54409
|
-
(_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus();
|
|
54606
|
+
(_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
54607
|
+
event.preventDefault();
|
|
54410
54608
|
event.stopPropagation();
|
|
54411
54609
|
return;
|
|
54412
54610
|
}
|
|
54413
54611
|
if (event.key === "Escape") {
|
|
54612
|
+
event.preventDefault();
|
|
54613
|
+
event.stopPropagation();
|
|
54414
54614
|
this.handleClose();
|
|
54415
54615
|
}
|
|
54416
54616
|
});
|
|
@@ -54424,13 +54624,18 @@ ${codeText}
|
|
|
54424
54624
|
return;
|
|
54425
54625
|
}
|
|
54426
54626
|
if (event.key === "Escape") {
|
|
54627
|
+
event.preventDefault();
|
|
54628
|
+
event.stopPropagation();
|
|
54427
54629
|
this.handleClose();
|
|
54428
54630
|
}
|
|
54429
54631
|
});
|
|
54430
54632
|
this.editor = editor;
|
|
54431
54633
|
}
|
|
54432
|
-
|
|
54433
|
-
|
|
54634
|
+
isCurrent(session) {
|
|
54635
|
+
return session === this.session && !!this.linkPopup && !this.editor.destroyed;
|
|
54636
|
+
}
|
|
54637
|
+
async checkValue(form) {
|
|
54638
|
+
const { linkUrl } = form;
|
|
54434
54639
|
if (!linkUrl.getInputValue()) {
|
|
54435
54640
|
linkUrl.setFieldError(i18n$1.t("link.urlPlaceholder"));
|
|
54436
54641
|
throw new Error(i18n$1.t("link.urlPlaceholder"));
|
|
@@ -54448,14 +54653,20 @@ ${codeText}
|
|
|
54448
54653
|
return link2;
|
|
54449
54654
|
}
|
|
54450
54655
|
editLink(options) {
|
|
54451
|
-
this.
|
|
54656
|
+
this._destroy();
|
|
54657
|
+
if (this.editor.destroyed) {
|
|
54658
|
+
return;
|
|
54659
|
+
}
|
|
54660
|
+
this.releaseFocus = acquireEditorFocus(this.editor);
|
|
54452
54661
|
const { onFinished, onClose, onBeforeFormatUrl } = options;
|
|
54453
54662
|
this.onFinished = onFinished;
|
|
54454
|
-
|
|
54455
|
-
|
|
54456
|
-
|
|
54457
|
-
|
|
54458
|
-
|
|
54663
|
+
this.onClose = onClose != null ? onClose : null;
|
|
54664
|
+
this.onBeforeFormatUrl = onBeforeFormatUrl != null ? onBeforeFormatUrl : null;
|
|
54665
|
+
try {
|
|
54666
|
+
this.showPopup(options);
|
|
54667
|
+
} catch (error2) {
|
|
54668
|
+
this._destroy();
|
|
54669
|
+
throw error2;
|
|
54459
54670
|
}
|
|
54460
54671
|
}
|
|
54461
54672
|
createPopupContent(linkText, linkUrl) {
|
|
@@ -54484,12 +54695,21 @@ ${codeText}
|
|
|
54484
54695
|
return content;
|
|
54485
54696
|
}
|
|
54486
54697
|
_destroy() {
|
|
54487
|
-
|
|
54698
|
+
this.session += 1;
|
|
54699
|
+
clearTimeout(this.focusTimer);
|
|
54700
|
+
this.focusTimer = void 0;
|
|
54701
|
+
const popup = this.linkPopup;
|
|
54702
|
+
const releaseFocus = this.releaseFocus;
|
|
54703
|
+
this.linkPopup = null;
|
|
54704
|
+
this.releaseFocus = void 0;
|
|
54705
|
+
this.submitting = false;
|
|
54488
54706
|
this.onFinished = null;
|
|
54489
54707
|
this.onClose = null;
|
|
54708
|
+
this.onBeforeFormatUrl = null;
|
|
54490
54709
|
this.form = {};
|
|
54491
|
-
|
|
54492
|
-
|
|
54710
|
+
popup == null ? void 0 : popup.removeAllListeners();
|
|
54711
|
+
popup == null ? void 0 : popup.destroy();
|
|
54712
|
+
releaseFocus == null ? void 0 : releaseFocus();
|
|
54493
54713
|
}
|
|
54494
54714
|
destroy() {
|
|
54495
54715
|
this._destroy();
|
|
@@ -54529,14 +54749,14 @@ ${codeText}
|
|
|
54529
54749
|
const text2 = [op1, op2];
|
|
54530
54750
|
editor.insertTextToBlock(block, 0, text2);
|
|
54531
54751
|
editor.selection.selectBlock(block, getTextLength(text2));
|
|
54532
|
-
editor
|
|
54752
|
+
requestEditorFocus(editor);
|
|
54533
54753
|
} catch (error2) {
|
|
54534
54754
|
logger$20.error(error2);
|
|
54535
54755
|
}
|
|
54536
54756
|
});
|
|
54537
54757
|
};
|
|
54538
54758
|
const onClose = () => {
|
|
54539
|
-
editor
|
|
54759
|
+
requestEditorFocus(editor);
|
|
54540
54760
|
};
|
|
54541
54761
|
editLink(editor, {
|
|
54542
54762
|
target: block,
|
|
@@ -54568,21 +54788,21 @@ ${codeText}
|
|
|
54568
54788
|
if (isCollapsed) {
|
|
54569
54789
|
newText = insertText(editor.getBlockText(block), end, linkText, { link: linkUrl });
|
|
54570
54790
|
editor.setBlockText(block, newText);
|
|
54571
|
-
editor
|
|
54791
|
+
requestEditorFocus(editor);
|
|
54572
54792
|
return;
|
|
54573
54793
|
}
|
|
54574
54794
|
newText = replaceText(editor.getBlockText(block), start, end, linkText);
|
|
54575
54795
|
newText = rangeAddAttribute(start, linkText.length, newText, "link", linkUrl);
|
|
54576
54796
|
editor.setBlockText(block, newText);
|
|
54577
54797
|
editor.selection.selectBlock(block, start + linkText.length);
|
|
54578
|
-
editor
|
|
54798
|
+
requestEditorFocus(editor);
|
|
54579
54799
|
} catch (error2) {
|
|
54580
54800
|
logger$20.error(error2);
|
|
54581
54801
|
}
|
|
54582
54802
|
});
|
|
54583
54803
|
};
|
|
54584
54804
|
const onClose = () => {
|
|
54585
|
-
editor
|
|
54805
|
+
requestEditorFocus(editor);
|
|
54586
54806
|
};
|
|
54587
54807
|
editLink(editor, {
|
|
54588
54808
|
target: anchor2,
|
|
@@ -54831,14 +55051,14 @@ ${codeText}
|
|
|
54831
55051
|
const newText = insertText(deleted, range.start, linkText, { link: linkUrl });
|
|
54832
55052
|
editor.setBlockText(block, newText);
|
|
54833
55053
|
editor.selection.selectBlock(block, range.start + linkText.length);
|
|
54834
|
-
editor
|
|
55054
|
+
requestEditorFocus(editor);
|
|
54835
55055
|
} catch (error2) {
|
|
54836
55056
|
logger$1$.error(error2);
|
|
54837
55057
|
}
|
|
54838
55058
|
};
|
|
54839
55059
|
const onClose = () => {
|
|
54840
55060
|
editor.selection.selectBlock(block, range.end);
|
|
54841
|
-
editor
|
|
55061
|
+
requestEditorFocus(editor);
|
|
54842
55062
|
};
|
|
54843
55063
|
const rect = getBlockClientRects(editor, block, editor.selection.range)[0];
|
|
54844
55064
|
if (!rect) {
|
|
@@ -55340,6 +55560,7 @@ ${codeText}
|
|
|
55340
55560
|
__publicField(this, "_disableTextToolbar", false);
|
|
55341
55561
|
__publicField(this, "_lastClickTime", 0);
|
|
55342
55562
|
__publicField(this, "_disabled", false);
|
|
55563
|
+
__publicField(this, "cancelFocus");
|
|
55343
55564
|
__publicField(this, "isInToolbar", (event) => this.toolbar.isInCommandBar(event.target));
|
|
55344
55565
|
__publicField(this, "handleButtonClick", (toolbar2, item) => {
|
|
55345
55566
|
const tooltip = this.editor.findCustom("editor-tooltip");
|
|
@@ -55364,16 +55585,15 @@ ${codeText}
|
|
|
55364
55585
|
this._lastClickTime = Date.now();
|
|
55365
55586
|
});
|
|
55366
55587
|
__publicField(this, "handleClose", () => {
|
|
55367
|
-
var _a;
|
|
55588
|
+
var _a, _b;
|
|
55368
55589
|
if (shouldFocusToEditor(this.editor) && !clientType.isMobile) {
|
|
55369
55590
|
const activeElement = (_a = document.getSelection()) == null ? void 0 : _a.focusNode;
|
|
55370
55591
|
if (activeElement && isInBlockTools(activeElement)) {
|
|
55371
55592
|
logger$1Z.debug("focus is in block tools, ignore focus");
|
|
55372
55593
|
return;
|
|
55373
55594
|
}
|
|
55374
|
-
this.
|
|
55375
|
-
|
|
55376
|
-
});
|
|
55595
|
+
(_b = this.cancelFocus) == null ? void 0 : _b.call(this);
|
|
55596
|
+
this.cancelFocus = requestEditorFocus(this.editor);
|
|
55377
55597
|
}
|
|
55378
55598
|
});
|
|
55379
55599
|
__publicField(this, "handleClosing", (bar2, event) => {
|
|
@@ -55502,8 +55722,10 @@ ${codeText}
|
|
|
55502
55722
|
this.toolbar.close("selectionChange");
|
|
55503
55723
|
}
|
|
55504
55724
|
destroy() {
|
|
55725
|
+
var _a;
|
|
55505
55726
|
this.unbindEvents();
|
|
55506
55727
|
this.toolbar.destroy();
|
|
55728
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
55507
55729
|
this.editor.removeListener("selectionChanged", this.handleSelectionChange);
|
|
55508
55730
|
OnesEditorHoveringBlock.get(this.editor).removeListener("childChange", this.handleHoveringBlockChildChange);
|
|
55509
55731
|
}
|
|
@@ -96935,14 +97157,13 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96935
97157
|
__publicField(this, "toolbar");
|
|
96936
97158
|
__publicField(this, "toolbarFullScreen");
|
|
96937
97159
|
__publicField(this, "root");
|
|
97160
|
+
__publicField(this, "cancelFocus");
|
|
96938
97161
|
__publicField(this, "handleClick", (bar2, item) => {
|
|
96939
97162
|
const command = item;
|
|
96940
97163
|
if (command.onClick) {
|
|
96941
97164
|
command.onClick(this.editor, command, bar2);
|
|
96942
97165
|
this.handleSelectionChanged();
|
|
96943
|
-
|
|
96944
|
-
this.editor.focus();
|
|
96945
|
-
});
|
|
97166
|
+
this.restoreFocus();
|
|
96946
97167
|
return;
|
|
96947
97168
|
}
|
|
96948
97169
|
const findParent = (item2, id) => {
|
|
@@ -96988,9 +97209,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96988
97209
|
id: "main-toolbar"
|
|
96989
97210
|
});
|
|
96990
97211
|
this.toolbar.addListener("closing", () => {
|
|
96991
|
-
|
|
96992
|
-
editor.focus();
|
|
96993
|
-
}, 100);
|
|
97212
|
+
this.restoreFocus(100);
|
|
96994
97213
|
return true;
|
|
96995
97214
|
});
|
|
96996
97215
|
this.toolbar.addListener("click", this.handleClick);
|
|
@@ -97021,11 +97240,18 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97021
97240
|
});
|
|
97022
97241
|
}
|
|
97023
97242
|
}
|
|
97024
|
-
|
|
97243
|
+
restoreFocus(delay = 0) {
|
|
97025
97244
|
var _a;
|
|
97245
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
97246
|
+
this.cancelFocus = requestEditorFocus(this.editor, delay);
|
|
97247
|
+
}
|
|
97248
|
+
destroy() {
|
|
97249
|
+
var _a, _b, _c;
|
|
97250
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
97026
97251
|
this.toolbar.destroy();
|
|
97027
97252
|
this.editor.removeListener("selectionChanged", this.handleSelectionChanged);
|
|
97028
|
-
(
|
|
97253
|
+
(_b = this.toolbarFullScreen) == null ? void 0 : _b.destroy();
|
|
97254
|
+
(_c = this.cancelFocus) == null ? void 0 : _c.call(this);
|
|
97029
97255
|
this.root.remove();
|
|
97030
97256
|
}
|
|
97031
97257
|
setItems(items) {
|
|
@@ -97617,7 +97843,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97617
97843
|
}
|
|
97618
97844
|
}
|
|
97619
97845
|
});
|
|
97620
|
-
editor.version = "4.0.7-beta.
|
|
97846
|
+
editor.version = "4.0.7-beta.h1474.2";
|
|
97621
97847
|
return editor;
|
|
97622
97848
|
}
|
|
97623
97849
|
function isDoc(doc2) {
|
|
@@ -97753,7 +97979,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97753
97979
|
OnesEditorDropTarget.register(editor);
|
|
97754
97980
|
OnesEditorTocProvider.register(editor);
|
|
97755
97981
|
OnesEditorExclusiveBlock.register(editor);
|
|
97756
|
-
editor.version = "4.0.7-beta.
|
|
97982
|
+
editor.version = "4.0.7-beta.h1474.2";
|
|
97757
97983
|
return editor;
|
|
97758
97984
|
} catch (error2) {
|
|
97759
97985
|
try {
|
|
@@ -97896,7 +98122,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97896
98122
|
}
|
|
97897
98123
|
}
|
|
97898
98124
|
});
|
|
97899
|
-
editor.version = "4.0.7-beta.
|
|
98125
|
+
editor.version = "4.0.7-beta.h1474.2";
|
|
97900
98126
|
return editor;
|
|
97901
98127
|
}
|
|
97902
98128
|
const emojis$1 = {
|
|
@@ -143722,6 +143948,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
143722
143948
|
exports2.FindReplaceItem = FindReplaceItem;
|
|
143723
143949
|
exports2.FitIcon = FitIcon;
|
|
143724
143950
|
exports2.FixedToolbar = FixedToolbar;
|
|
143951
|
+
exports2.FocusRestoration = FocusRestoration;
|
|
143725
143952
|
exports2.FontBoldItem = FontBoldItem;
|
|
143726
143953
|
exports2.FontItalicItem = FontItalicItem;
|
|
143727
143954
|
exports2.FontStrikethroughItem = FontStrikethroughItem;
|
|
@@ -143920,6 +144147,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
143920
144147
|
exports2.YoukuIcon = YoukuIcon;
|
|
143921
144148
|
exports2.ZERO_WIDTH_SPACE_CHAR = ZERO_WIDTH_SPACE_CHAR;
|
|
143922
144149
|
exports2.abbreviation = abbreviation;
|
|
144150
|
+
exports2.acquireEditorFocus = acquireEditorFocus;
|
|
143923
144151
|
exports2.activeComment = activeComment;
|
|
143924
144152
|
exports2.addAttribute = addAttribute;
|
|
143925
144153
|
exports2.addClass = addClass;
|
|
@@ -144405,6 +144633,8 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144405
144633
|
exports2.replaceAllText = replaceAllText;
|
|
144406
144634
|
exports2.replaceText = replaceText;
|
|
144407
144635
|
exports2.requestDownload = requestDownload;
|
|
144636
|
+
exports2.requestEditorFocus = requestEditorFocus;
|
|
144637
|
+
exports2.requestInputFocus = requestInputFocus;
|
|
144408
144638
|
exports2.resetListStart = resetListStart;
|
|
144409
144639
|
exports2.saveAs = saveAs$1;
|
|
144410
144640
|
exports2.scrollBarIntoView = scrollBarIntoView;
|