@ones-editor/editor 3.1.6 → 3.1.7-beta.ONES22302172.4
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 +22 -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 +294 -90
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26414,6 +26414,90 @@ var __publicField = (obj, key, value) => {
|
|
|
26414
26414
|
};
|
|
26415
26415
|
}
|
|
26416
26416
|
}
|
|
26417
|
+
const controllers = /* @__PURE__ */ new WeakMap();
|
|
26418
|
+
const noop$1 = () => {
|
|
26419
|
+
};
|
|
26420
|
+
class FocusRestoration {
|
|
26421
|
+
constructor(input2, restore) {
|
|
26422
|
+
__publicField(this, "generation", 0);
|
|
26423
|
+
__publicField(this, "owner", null);
|
|
26424
|
+
__publicField(this, "destroyed", false);
|
|
26425
|
+
__publicField(this, "timers", /* @__PURE__ */ new Set());
|
|
26426
|
+
this.input = input2;
|
|
26427
|
+
this.restore = restore;
|
|
26428
|
+
controllers.set(input2, this);
|
|
26429
|
+
}
|
|
26430
|
+
canFocus() {
|
|
26431
|
+
return !this.destroyed && !this.owner && this.input.isConnected;
|
|
26432
|
+
}
|
|
26433
|
+
hasOtherInput() {
|
|
26434
|
+
const active = this.input.ownerDocument.activeElement;
|
|
26435
|
+
return active !== this.input && !!(active == null ? void 0 : active.matches('input, textarea, select, [contenteditable="true"], [contenteditable=""]'));
|
|
26436
|
+
}
|
|
26437
|
+
schedule(callback, delay = 0, protectUserFocus = false) {
|
|
26438
|
+
if (!this.canFocus()) {
|
|
26439
|
+
return noop$1;
|
|
26440
|
+
}
|
|
26441
|
+
const generation = this.generation;
|
|
26442
|
+
const timer = setTimeout(() => {
|
|
26443
|
+
this.timers.delete(timer);
|
|
26444
|
+
if (generation === this.generation && this.canFocus() && (!protectUserFocus || !this.hasOtherInput())) {
|
|
26445
|
+
callback();
|
|
26446
|
+
}
|
|
26447
|
+
}, delay);
|
|
26448
|
+
this.timers.add(timer);
|
|
26449
|
+
return () => {
|
|
26450
|
+
clearTimeout(timer);
|
|
26451
|
+
this.timers.delete(timer);
|
|
26452
|
+
};
|
|
26453
|
+
}
|
|
26454
|
+
request(delay = 0) {
|
|
26455
|
+
return this.schedule(this.restore, delay, !clientType.isMobile);
|
|
26456
|
+
}
|
|
26457
|
+
cancelPending() {
|
|
26458
|
+
this.generation += 1;
|
|
26459
|
+
this.timers.forEach((timer) => clearTimeout(timer));
|
|
26460
|
+
this.timers.clear();
|
|
26461
|
+
}
|
|
26462
|
+
acquire() {
|
|
26463
|
+
this.cancelPending();
|
|
26464
|
+
const owner = {};
|
|
26465
|
+
this.owner = owner;
|
|
26466
|
+
return () => {
|
|
26467
|
+
if (this.owner === owner) {
|
|
26468
|
+
this.cancelPending();
|
|
26469
|
+
this.owner = null;
|
|
26470
|
+
}
|
|
26471
|
+
};
|
|
26472
|
+
}
|
|
26473
|
+
destroy() {
|
|
26474
|
+
this.destroyed = true;
|
|
26475
|
+
this.cancelPending();
|
|
26476
|
+
this.owner = null;
|
|
26477
|
+
controllers.delete(this.input);
|
|
26478
|
+
}
|
|
26479
|
+
}
|
|
26480
|
+
function requestInputFocus(input2, delay = 0) {
|
|
26481
|
+
var _a, _b;
|
|
26482
|
+
return (_b = (_a = controllers.get(input2)) == null ? void 0 : _a.request(delay)) != null ? _b : noop$1;
|
|
26483
|
+
}
|
|
26484
|
+
function requestEditorFocus(editor, delay = 0) {
|
|
26485
|
+
if (editor.destroyed) {
|
|
26486
|
+
return noop$1;
|
|
26487
|
+
}
|
|
26488
|
+
if (clientType.isMobile && delay === 0) {
|
|
26489
|
+
editor.focus();
|
|
26490
|
+
return noop$1;
|
|
26491
|
+
}
|
|
26492
|
+
return requestInputFocus(editor.input.inputElement, delay);
|
|
26493
|
+
}
|
|
26494
|
+
function acquireEditorFocus(editor) {
|
|
26495
|
+
var _a, _b;
|
|
26496
|
+
if (clientType.isMobile || editor.destroyed) {
|
|
26497
|
+
return noop$1;
|
|
26498
|
+
}
|
|
26499
|
+
return (_b = (_a = controllers.get(editor.input.inputElement)) == null ? void 0 : _a.acquire()) != null ? _b : noop$1;
|
|
26500
|
+
}
|
|
26417
26501
|
const logger$3V = getLogger("editor-input");
|
|
26418
26502
|
class EditorInput$1 {
|
|
26419
26503
|
constructor(editor, callbacks) {
|
|
@@ -26423,6 +26507,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26423
26507
|
__publicField(this, "callbacks");
|
|
26424
26508
|
__publicField(this, "inputElement");
|
|
26425
26509
|
__publicField(this, "focused", false);
|
|
26510
|
+
__publicField(this, "focusRestoration");
|
|
26426
26511
|
__publicField(this, "handleBlur", () => {
|
|
26427
26512
|
this.editor.emit("blur", this.editor);
|
|
26428
26513
|
this.callbacks.onBlur();
|
|
@@ -26444,12 +26529,20 @@ var __publicField = (obj, key, value) => {
|
|
|
26444
26529
|
const isInDisableScrollMask = this.isInDisableScrollMask(target);
|
|
26445
26530
|
if (target && (isInDisableScrollMask || rootElement === target || rootElement.contains(target))) {
|
|
26446
26531
|
if (!isInDisableScrollMask && !isInBlockTools(target)) {
|
|
26447
|
-
|
|
26532
|
+
const focus = () => {
|
|
26533
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26534
|
+
return;
|
|
26535
|
+
}
|
|
26448
26536
|
this.editor.emit("focus", this.editor);
|
|
26449
26537
|
this.callbacks.onFocus();
|
|
26450
26538
|
this.editor.input.focus();
|
|
26451
26539
|
this.focused = true;
|
|
26452
|
-
}
|
|
26540
|
+
};
|
|
26541
|
+
if (clientType.isMobile) {
|
|
26542
|
+
setTimeout(focus);
|
|
26543
|
+
} else {
|
|
26544
|
+
this.focusRestoration.schedule(focus);
|
|
26545
|
+
}
|
|
26453
26546
|
}
|
|
26454
26547
|
return;
|
|
26455
26548
|
}
|
|
@@ -26584,6 +26677,11 @@ var __publicField = (obj, key, value) => {
|
|
|
26584
26677
|
input2.addEventListener("compositionstart", this.handleCompositionstart);
|
|
26585
26678
|
input2.addEventListener("compositionend", this.handleCompositionend);
|
|
26586
26679
|
this.inputElement = input2;
|
|
26680
|
+
this.focusRestoration = new FocusRestoration(input2, () => {
|
|
26681
|
+
if (!this.editor.destroyed) {
|
|
26682
|
+
this.editor.focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
26683
|
+
}
|
|
26684
|
+
});
|
|
26587
26685
|
if (clientType.isMobile) {
|
|
26588
26686
|
document.addEventListener("touchend", this.handleDocumentClick);
|
|
26589
26687
|
} else {
|
|
@@ -26606,6 +26704,7 @@ var __publicField = (obj, key, value) => {
|
|
|
26606
26704
|
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"));
|
|
26607
26705
|
}
|
|
26608
26706
|
destroy() {
|
|
26707
|
+
this.focusRestoration.destroy();
|
|
26609
26708
|
this.callbacks.destroy();
|
|
26610
26709
|
if (clientType.isMobile) {
|
|
26611
26710
|
document.removeEventListener("touchend", this.handleDocumentClick);
|
|
@@ -26630,24 +26729,36 @@ var __publicField = (obj, key, value) => {
|
|
|
26630
26729
|
return this.inputElement;
|
|
26631
26730
|
}
|
|
26632
26731
|
focus(options) {
|
|
26732
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26733
|
+
return;
|
|
26734
|
+
}
|
|
26633
26735
|
if (!this.editor.selection.caret.visible()) {
|
|
26634
26736
|
this.editor.selection.caret.update();
|
|
26635
26737
|
}
|
|
26636
26738
|
if (clientType.isMobile) {
|
|
26637
26739
|
this.inputElement.focus(options);
|
|
26638
26740
|
this.callbacks.onFocus();
|
|
26741
|
+
this.focused = true;
|
|
26639
26742
|
} else {
|
|
26640
|
-
|
|
26743
|
+
this.focusRestoration.schedule(() => {
|
|
26744
|
+
if (this.editor.destroyed) {
|
|
26745
|
+
return;
|
|
26746
|
+
}
|
|
26641
26747
|
if (document.activeElement !== this.inputElement) {
|
|
26642
|
-
|
|
26643
|
-
this.editor.
|
|
26748
|
+
this.focusRestoration.schedule(() => {
|
|
26749
|
+
if (!this.editor.destroyed && document.activeElement === this.inputElement) {
|
|
26750
|
+
this.editor.emit("focus", this.editor);
|
|
26751
|
+
}
|
|
26644
26752
|
});
|
|
26645
26753
|
}
|
|
26646
26754
|
this.inputElement.focus(options);
|
|
26755
|
+
if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
|
|
26756
|
+
return;
|
|
26757
|
+
}
|
|
26647
26758
|
this.callbacks.onFocus();
|
|
26648
|
-
|
|
26759
|
+
this.focused = true;
|
|
26760
|
+
}, 0, (options == null ? void 0 : options.preventScroll) === true);
|
|
26649
26761
|
}
|
|
26650
|
-
this.focused = true;
|
|
26651
26762
|
}
|
|
26652
26763
|
isInDisableScrollMask(target) {
|
|
26653
26764
|
let elem = target;
|
|
@@ -32206,7 +32317,7 @@ ${codeText}
|
|
|
32206
32317
|
editor.doc.endBatchUpdate();
|
|
32207
32318
|
}
|
|
32208
32319
|
if (!clientType.isMobile) {
|
|
32209
|
-
editor
|
|
32320
|
+
requestEditorFocus(editor);
|
|
32210
32321
|
}
|
|
32211
32322
|
return rangeResult;
|
|
32212
32323
|
});
|
|
@@ -42516,10 +42627,12 @@ ${codeText}
|
|
|
42516
42627
|
});
|
|
42517
42628
|
__publicField(this, "tippyInstance", null);
|
|
42518
42629
|
__publicField(this, "_target", null);
|
|
42630
|
+
__publicField(this, "cancelFocus");
|
|
42519
42631
|
__publicField(this, "handleBeforeClose", (event) => {
|
|
42520
|
-
var _a;
|
|
42632
|
+
var _a, _b;
|
|
42633
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
42521
42634
|
let ret = false;
|
|
42522
|
-
if ((
|
|
42635
|
+
if ((_b = this.manualCommandBarOptions) == null ? void 0 : _b.beforeClose) {
|
|
42523
42636
|
ret = this.manualCommandBarOptions.beforeClose(event);
|
|
42524
42637
|
}
|
|
42525
42638
|
if (ret) {
|
|
@@ -42529,18 +42642,16 @@ ${codeText}
|
|
|
42529
42642
|
return ret;
|
|
42530
42643
|
}
|
|
42531
42644
|
const target = this._target;
|
|
42532
|
-
|
|
42533
|
-
|
|
42534
|
-
|
|
42535
|
-
|
|
42536
|
-
|
|
42537
|
-
|
|
42538
|
-
|
|
42539
|
-
|
|
42540
|
-
input2.focus();
|
|
42541
|
-
}
|
|
42645
|
+
const parentEditor = target.closest(".editor-root");
|
|
42646
|
+
const input2 = parentEditor == null ? void 0 : parentEditor.querySelector(".editor-input");
|
|
42647
|
+
if (input2 && !(parentEditor == null ? void 0 : parentEditor.contains(document.activeElement))) {
|
|
42648
|
+
if (clientType.isMobile) {
|
|
42649
|
+
const timer = setTimeout(() => input2.focus(), 100);
|
|
42650
|
+
this.cancelFocus = () => clearTimeout(timer);
|
|
42651
|
+
} else {
|
|
42652
|
+
this.cancelFocus = requestInputFocus(input2, 100);
|
|
42542
42653
|
}
|
|
42543
|
-
}
|
|
42654
|
+
}
|
|
42544
42655
|
return ret;
|
|
42545
42656
|
});
|
|
42546
42657
|
__publicField(this, "setProps", (props) => {
|
|
@@ -42550,7 +42661,8 @@ ${codeText}
|
|
|
42550
42661
|
this.manualCommandBarOptions = manualCommandBarOptions;
|
|
42551
42662
|
}
|
|
42552
42663
|
manualShow(target, options) {
|
|
42553
|
-
var _a, _b, _c, _d;
|
|
42664
|
+
var _a, _b, _c, _d, _e;
|
|
42665
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
42554
42666
|
this._target = target;
|
|
42555
42667
|
if (this.isVisible) {
|
|
42556
42668
|
return;
|
|
@@ -42565,16 +42677,16 @@ ${codeText}
|
|
|
42565
42677
|
trigger: "manual",
|
|
42566
42678
|
triggerTarget: null,
|
|
42567
42679
|
hideOnClick: false,
|
|
42568
|
-
placement: (
|
|
42569
|
-
maxWidth: (
|
|
42570
|
-
arrow: (
|
|
42680
|
+
placement: (_b = options == null ? void 0 : options.placement) != null ? _b : "bottom-start",
|
|
42681
|
+
maxWidth: (_c = this.options.maxWidth) != null ? _c : 650,
|
|
42682
|
+
arrow: (_d = options == null ? void 0 : options.arrow) != null ? _d : this.options.tippyArrow,
|
|
42571
42683
|
appendTo: this.options.appendTo || target.closest(".command-bar-container") || document.body,
|
|
42572
42684
|
onShow: this.handleShow,
|
|
42573
42685
|
onHidden: this.handleHidden,
|
|
42574
42686
|
onShown: this.handleShown,
|
|
42575
42687
|
theme: options == null ? void 0 : options.theme,
|
|
42576
42688
|
getReferenceClientRect: options == null ? void 0 : options.getReferenceClientRect,
|
|
42577
|
-
offset: (
|
|
42689
|
+
offset: (_e = options == null ? void 0 : options.offset) != null ? _e : [0, 0],
|
|
42578
42690
|
popperOptions: this.createPopperOptions(),
|
|
42579
42691
|
delay: 500
|
|
42580
42692
|
});
|
|
@@ -42609,10 +42721,12 @@ ${codeText}
|
|
|
42609
42721
|
}
|
|
42610
42722
|
}
|
|
42611
42723
|
destroy() {
|
|
42612
|
-
var _a;
|
|
42613
|
-
(_a = this.
|
|
42724
|
+
var _a, _b, _c;
|
|
42725
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
42726
|
+
(_b = this.tippyInstance) == null ? void 0 : _b.destroy();
|
|
42614
42727
|
this.tippyInstance = null;
|
|
42615
42728
|
super.destroy();
|
|
42729
|
+
(_c = this.cancelFocus) == null ? void 0 : _c.call(this);
|
|
42616
42730
|
}
|
|
42617
42731
|
getCommandBarRoot() {
|
|
42618
42732
|
return this.content.closest("[data-tippy-root]");
|
|
@@ -44732,19 +44846,22 @@ ${codeText}
|
|
|
44732
44846
|
class EditorAutoSuggestMenu extends AutoSuggestMenu {
|
|
44733
44847
|
constructor(editor, editorOptions) {
|
|
44734
44848
|
super(editorOptions);
|
|
44849
|
+
__publicField(this, "cancelFocus");
|
|
44735
44850
|
__publicField(this, "handleClose", () => {
|
|
44736
|
-
var _a, _b;
|
|
44851
|
+
var _a, _b, _c;
|
|
44852
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
44737
44853
|
if (shouldFocusToEditor(this.editor)) {
|
|
44738
|
-
this.editor
|
|
44854
|
+
this.cancelFocus = requestEditorFocus(this.editor);
|
|
44739
44855
|
}
|
|
44740
|
-
(
|
|
44856
|
+
(_c = (_b = this.options).onClose) == null ? void 0 : _c.call(_b);
|
|
44741
44857
|
});
|
|
44742
44858
|
this.editor = editor;
|
|
44743
44859
|
this.editorOptions = editorOptions;
|
|
44744
44860
|
}
|
|
44745
44861
|
async popupInEditor(containerId, blockIndex, offset) {
|
|
44746
|
-
var _a, _b;
|
|
44747
|
-
|
|
44862
|
+
var _a, _b, _c;
|
|
44863
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
44864
|
+
if (((_c = (_b = this.editorOptions).onShow) == null ? void 0 : _c.call(_b, this, containerId, blockIndex, offset)) === false) {
|
|
44748
44865
|
return;
|
|
44749
44866
|
}
|
|
44750
44867
|
if (this.options.showLoading) {
|
|
@@ -44762,6 +44879,11 @@ ${codeText}
|
|
|
44762
44879
|
const anchor2 = createBlockAnchor(this.editor, block, "editor-auto-suggest-menu", rect);
|
|
44763
44880
|
super.popup(anchor2, { noEvent: true });
|
|
44764
44881
|
}
|
|
44882
|
+
destroy() {
|
|
44883
|
+
var _a;
|
|
44884
|
+
super.destroy();
|
|
44885
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
44886
|
+
}
|
|
44765
44887
|
}
|
|
44766
44888
|
const logger$2G = getLogger("auto-suggest-menu");
|
|
44767
44889
|
class OnesEditorAutoSuggest {
|
|
@@ -54088,6 +54210,7 @@ ${codeText}
|
|
|
54088
54210
|
});
|
|
54089
54211
|
__publicField(this, "close", () => {
|
|
54090
54212
|
this.linkPopup.close("cancelBar");
|
|
54213
|
+
this.emit("close");
|
|
54091
54214
|
});
|
|
54092
54215
|
__publicField(this, "createItems", (content) => [{
|
|
54093
54216
|
id: "link-popup",
|
|
@@ -54109,7 +54232,6 @@ ${codeText}
|
|
|
54109
54232
|
this.emit("finished");
|
|
54110
54233
|
});
|
|
54111
54234
|
__publicField(this, "handleClose", () => {
|
|
54112
|
-
this.emit("close");
|
|
54113
54235
|
this.close();
|
|
54114
54236
|
});
|
|
54115
54237
|
__publicField(this, "handleShown", () => {
|
|
@@ -54138,8 +54260,13 @@ ${codeText}
|
|
|
54138
54260
|
this.linkPopup = new MobileBottomMenu(this.createItems(content), void 0, {
|
|
54139
54261
|
id: "link-popup",
|
|
54140
54262
|
header: this.createHeader(),
|
|
54141
|
-
disableSelectedScroll: true
|
|
54263
|
+
disableSelectedScroll: true,
|
|
54264
|
+
beforeClose: () => {
|
|
54265
|
+
this.handleClose();
|
|
54266
|
+
return true;
|
|
54267
|
+
}
|
|
54142
54268
|
});
|
|
54269
|
+
this.linkPopup.addListener("close", () => this.emit("close"));
|
|
54143
54270
|
}
|
|
54144
54271
|
destroy() {
|
|
54145
54272
|
var _a, _b;
|
|
@@ -54158,11 +54285,11 @@ ${codeText}
|
|
|
54158
54285
|
this.emit("finished");
|
|
54159
54286
|
});
|
|
54160
54287
|
__publicField(this, "handleClose", () => {
|
|
54161
|
-
this.emit("close");
|
|
54162
54288
|
this.close();
|
|
54163
54289
|
});
|
|
54164
54290
|
__publicField(this, "close", () => {
|
|
54165
54291
|
this.linkPopup.close("cancelBar");
|
|
54292
|
+
this.emit("close");
|
|
54166
54293
|
});
|
|
54167
54294
|
__publicField(this, "disabledSubmit", () => {
|
|
54168
54295
|
var _a;
|
|
@@ -54182,8 +54309,13 @@ ${codeText}
|
|
|
54182
54309
|
this.content = content;
|
|
54183
54310
|
this.options = options;
|
|
54184
54311
|
this.linkPopup = new Popup(this.createPopupContent(), {
|
|
54185
|
-
id: "link-popup"
|
|
54312
|
+
id: "link-popup",
|
|
54313
|
+
beforeClose: () => {
|
|
54314
|
+
this.handleClose();
|
|
54315
|
+
return true;
|
|
54316
|
+
}
|
|
54186
54317
|
});
|
|
54318
|
+
this.linkPopup.addListener("close", () => this.emit("close"));
|
|
54187
54319
|
}
|
|
54188
54320
|
createPopupContent() {
|
|
54189
54321
|
const container = createElement("div", ["link-popup-content"], null);
|
|
@@ -54216,46 +54348,85 @@ ${codeText}
|
|
|
54216
54348
|
__publicField(this, "onFinished", null);
|
|
54217
54349
|
__publicField(this, "onClose", null);
|
|
54218
54350
|
__publicField(this, "onBeforeFormatUrl", null);
|
|
54351
|
+
__publicField(this, "session", 0);
|
|
54352
|
+
__publicField(this, "submitting", false);
|
|
54353
|
+
__publicField(this, "focusTimer");
|
|
54354
|
+
__publicField(this, "releaseFocus");
|
|
54219
54355
|
__publicField(this, "handleOk", async () => {
|
|
54220
|
-
|
|
54356
|
+
if (!this.linkPopup || this.submitting || this.editor.destroyed) {
|
|
54357
|
+
return;
|
|
54358
|
+
}
|
|
54359
|
+
const session = this.session;
|
|
54360
|
+
const form = this.form;
|
|
54361
|
+
const onFinished = this.onFinished;
|
|
54362
|
+
const beforeFormatUrl = this.onBeforeFormatUrl;
|
|
54363
|
+
this.submitting = true;
|
|
54221
54364
|
try {
|
|
54222
|
-
await this.checkValue();
|
|
54223
|
-
|
|
54365
|
+
await this.checkValue(form);
|
|
54366
|
+
if (!this.isCurrent(session)) {
|
|
54367
|
+
return;
|
|
54368
|
+
}
|
|
54369
|
+
const { linkText, linkUrl } = form;
|
|
54224
54370
|
const inputValue = linkUrl.getInputValue();
|
|
54225
|
-
|
|
54226
|
-
|
|
54227
|
-
|
|
54228
|
-
|
|
54229
|
-
|
|
54371
|
+
const formatted = beforeFormatUrl == null ? void 0 : beforeFormatUrl(inputValue);
|
|
54372
|
+
const link2 = typeof formatted === "string" ? formatted : this.formatUrl(inputValue);
|
|
54373
|
+
const text2 = linkText.getInputValue() || link2;
|
|
54374
|
+
if (!this.isCurrent(session)) {
|
|
54375
|
+
return;
|
|
54230
54376
|
}
|
|
54231
|
-
(_a = this.onFinished) == null ? void 0 : _a.call(this, linkText.getInputValue() || link2, link2);
|
|
54232
54377
|
this._destroy();
|
|
54378
|
+
onFinished == null ? void 0 : onFinished(text2, link2);
|
|
54233
54379
|
} catch (error2) {
|
|
54380
|
+
if (this.isCurrent(session)) {
|
|
54381
|
+
this.submitting = false;
|
|
54382
|
+
}
|
|
54234
54383
|
}
|
|
54235
54384
|
});
|
|
54236
54385
|
__publicField(this, "handleClose", () => {
|
|
54237
|
-
|
|
54238
|
-
|
|
54386
|
+
if (!this.linkPopup) {
|
|
54387
|
+
return;
|
|
54388
|
+
}
|
|
54389
|
+
const onClose = this.onClose;
|
|
54239
54390
|
this._destroy();
|
|
54391
|
+
if (!this.editor.destroyed) {
|
|
54392
|
+
onClose == null ? void 0 : onClose();
|
|
54393
|
+
}
|
|
54240
54394
|
});
|
|
54241
54395
|
__publicField(this, "onShow", () => {
|
|
54242
|
-
|
|
54243
|
-
|
|
54244
|
-
|
|
54396
|
+
var _a;
|
|
54397
|
+
const session = this.session;
|
|
54398
|
+
const field = (_a = this.form.linkUrl) == null ? void 0 : _a.getField();
|
|
54399
|
+
clearTimeout(this.focusTimer);
|
|
54400
|
+
this.focusTimer = setTimeout(() => {
|
|
54401
|
+
if (this.isCurrent(session) && (field == null ? void 0 : field.isConnected)) {
|
|
54402
|
+
field.focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
54403
|
+
}
|
|
54245
54404
|
}, 400);
|
|
54246
54405
|
});
|
|
54247
54406
|
__publicField(this, "showPopup", (options) => {
|
|
54248
|
-
|
|
54407
|
+
const session = this.session;
|
|
54249
54408
|
if (clientType.isMobile) {
|
|
54250
54409
|
this.linkPopup = new MobileLinkPopup(this.editor, this.createPopupContent(options.linkText, options.linkUrl), options);
|
|
54251
54410
|
} else {
|
|
54252
54411
|
this.linkPopup = new LinkPopup(this.createPopupContent(options.linkText, options.linkUrl), options);
|
|
54253
54412
|
}
|
|
54254
|
-
|
|
54255
|
-
|
|
54256
|
-
|
|
54257
|
-
|
|
54258
|
-
|
|
54413
|
+
this.linkPopup.addListener("show", () => {
|
|
54414
|
+
if (this.isCurrent(session)) {
|
|
54415
|
+
this.onShow();
|
|
54416
|
+
}
|
|
54417
|
+
});
|
|
54418
|
+
this.linkPopup.addListener("finished", () => {
|
|
54419
|
+
if (this.isCurrent(session)) {
|
|
54420
|
+
this.handleOk();
|
|
54421
|
+
}
|
|
54422
|
+
});
|
|
54423
|
+
this.linkPopup.addListener("close", () => {
|
|
54424
|
+
if (this.isCurrent(session)) {
|
|
54425
|
+
this.handleClose();
|
|
54426
|
+
}
|
|
54427
|
+
});
|
|
54428
|
+
this.linkPopup.disabledSubmit();
|
|
54429
|
+
this.linkPopup.manualShow();
|
|
54259
54430
|
});
|
|
54260
54431
|
__publicField(this, "onChange", () => {
|
|
54261
54432
|
var _a;
|
|
@@ -54267,11 +54438,14 @@ ${codeText}
|
|
|
54267
54438
|
return;
|
|
54268
54439
|
}
|
|
54269
54440
|
if (event.key === "Enter") {
|
|
54270
|
-
(_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus();
|
|
54441
|
+
(_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus(clientType.isMobile ? void 0 : { preventScroll: true });
|
|
54442
|
+
event.preventDefault();
|
|
54271
54443
|
event.stopPropagation();
|
|
54272
54444
|
return;
|
|
54273
54445
|
}
|
|
54274
54446
|
if (event.key === "Escape") {
|
|
54447
|
+
event.preventDefault();
|
|
54448
|
+
event.stopPropagation();
|
|
54275
54449
|
this.handleClose();
|
|
54276
54450
|
}
|
|
54277
54451
|
});
|
|
@@ -54285,13 +54459,18 @@ ${codeText}
|
|
|
54285
54459
|
return;
|
|
54286
54460
|
}
|
|
54287
54461
|
if (event.key === "Escape") {
|
|
54462
|
+
event.preventDefault();
|
|
54463
|
+
event.stopPropagation();
|
|
54288
54464
|
this.handleClose();
|
|
54289
54465
|
}
|
|
54290
54466
|
});
|
|
54291
54467
|
this.editor = editor;
|
|
54292
54468
|
}
|
|
54293
|
-
|
|
54294
|
-
|
|
54469
|
+
isCurrent(session) {
|
|
54470
|
+
return session === this.session && !!this.linkPopup && !this.editor.destroyed;
|
|
54471
|
+
}
|
|
54472
|
+
async checkValue(form) {
|
|
54473
|
+
const { linkUrl } = form;
|
|
54295
54474
|
if (!linkUrl.getInputValue()) {
|
|
54296
54475
|
linkUrl.setFieldError(i18n$1.t("link.urlPlaceholder"));
|
|
54297
54476
|
throw new Error(i18n$1.t("link.urlPlaceholder"));
|
|
@@ -54309,14 +54488,20 @@ ${codeText}
|
|
|
54309
54488
|
return link2;
|
|
54310
54489
|
}
|
|
54311
54490
|
editLink(options) {
|
|
54312
|
-
this.
|
|
54491
|
+
this._destroy();
|
|
54492
|
+
if (this.editor.destroyed) {
|
|
54493
|
+
return;
|
|
54494
|
+
}
|
|
54495
|
+
this.releaseFocus = acquireEditorFocus(this.editor);
|
|
54313
54496
|
const { onFinished, onClose, onBeforeFormatUrl } = options;
|
|
54314
54497
|
this.onFinished = onFinished;
|
|
54315
|
-
|
|
54316
|
-
|
|
54317
|
-
|
|
54318
|
-
|
|
54319
|
-
|
|
54498
|
+
this.onClose = onClose != null ? onClose : null;
|
|
54499
|
+
this.onBeforeFormatUrl = onBeforeFormatUrl != null ? onBeforeFormatUrl : null;
|
|
54500
|
+
try {
|
|
54501
|
+
this.showPopup(options);
|
|
54502
|
+
} catch (error2) {
|
|
54503
|
+
this._destroy();
|
|
54504
|
+
throw error2;
|
|
54320
54505
|
}
|
|
54321
54506
|
}
|
|
54322
54507
|
createPopupContent(linkText, linkUrl) {
|
|
@@ -54345,12 +54530,21 @@ ${codeText}
|
|
|
54345
54530
|
return content;
|
|
54346
54531
|
}
|
|
54347
54532
|
_destroy() {
|
|
54348
|
-
|
|
54533
|
+
this.session += 1;
|
|
54534
|
+
clearTimeout(this.focusTimer);
|
|
54535
|
+
this.focusTimer = void 0;
|
|
54536
|
+
const popup = this.linkPopup;
|
|
54537
|
+
const releaseFocus = this.releaseFocus;
|
|
54538
|
+
this.linkPopup = null;
|
|
54539
|
+
this.releaseFocus = void 0;
|
|
54540
|
+
this.submitting = false;
|
|
54349
54541
|
this.onFinished = null;
|
|
54350
54542
|
this.onClose = null;
|
|
54543
|
+
this.onBeforeFormatUrl = null;
|
|
54351
54544
|
this.form = {};
|
|
54352
|
-
|
|
54353
|
-
|
|
54545
|
+
popup == null ? void 0 : popup.removeAllListeners();
|
|
54546
|
+
popup == null ? void 0 : popup.destroy();
|
|
54547
|
+
releaseFocus == null ? void 0 : releaseFocus();
|
|
54354
54548
|
}
|
|
54355
54549
|
destroy() {
|
|
54356
54550
|
this._destroy();
|
|
@@ -54390,14 +54584,14 @@ ${codeText}
|
|
|
54390
54584
|
const text2 = [op1, op2];
|
|
54391
54585
|
editor.insertTextToBlock(block, 0, text2);
|
|
54392
54586
|
editor.selection.selectBlock(block, getTextLength(text2));
|
|
54393
|
-
editor
|
|
54587
|
+
requestEditorFocus(editor);
|
|
54394
54588
|
} catch (error2) {
|
|
54395
54589
|
logger$20.error(error2);
|
|
54396
54590
|
}
|
|
54397
54591
|
});
|
|
54398
54592
|
};
|
|
54399
54593
|
const onClose = () => {
|
|
54400
|
-
editor
|
|
54594
|
+
requestEditorFocus(editor);
|
|
54401
54595
|
};
|
|
54402
54596
|
editLink(editor, {
|
|
54403
54597
|
target: block,
|
|
@@ -54429,21 +54623,21 @@ ${codeText}
|
|
|
54429
54623
|
if (isCollapsed) {
|
|
54430
54624
|
newText = insertText(editor.getBlockText(block), end, linkText, { link: linkUrl });
|
|
54431
54625
|
editor.setBlockText(block, newText);
|
|
54432
|
-
editor
|
|
54626
|
+
requestEditorFocus(editor);
|
|
54433
54627
|
return;
|
|
54434
54628
|
}
|
|
54435
54629
|
newText = replaceText(editor.getBlockText(block), start, end, linkText);
|
|
54436
54630
|
newText = rangeAddAttribute(start, linkText.length, newText, "link", linkUrl);
|
|
54437
54631
|
editor.setBlockText(block, newText);
|
|
54438
54632
|
editor.selection.selectBlock(block, start + linkText.length);
|
|
54439
|
-
editor
|
|
54633
|
+
requestEditorFocus(editor);
|
|
54440
54634
|
} catch (error2) {
|
|
54441
54635
|
logger$20.error(error2);
|
|
54442
54636
|
}
|
|
54443
54637
|
});
|
|
54444
54638
|
};
|
|
54445
54639
|
const onClose = () => {
|
|
54446
|
-
editor
|
|
54640
|
+
requestEditorFocus(editor);
|
|
54447
54641
|
};
|
|
54448
54642
|
editLink(editor, {
|
|
54449
54643
|
target: anchor2,
|
|
@@ -54692,14 +54886,14 @@ ${codeText}
|
|
|
54692
54886
|
const newText = insertText(deleted, range.start, linkText, { link: linkUrl });
|
|
54693
54887
|
editor.setBlockText(block, newText);
|
|
54694
54888
|
editor.selection.selectBlock(block, range.start + linkText.length);
|
|
54695
|
-
editor
|
|
54889
|
+
requestEditorFocus(editor);
|
|
54696
54890
|
} catch (error2) {
|
|
54697
54891
|
logger$1$.error(error2);
|
|
54698
54892
|
}
|
|
54699
54893
|
};
|
|
54700
54894
|
const onClose = () => {
|
|
54701
54895
|
editor.selection.selectBlock(block, range.end);
|
|
54702
|
-
editor
|
|
54896
|
+
requestEditorFocus(editor);
|
|
54703
54897
|
};
|
|
54704
54898
|
const rect = getBlockClientRects(editor, block, editor.selection.range)[0];
|
|
54705
54899
|
if (!rect) {
|
|
@@ -55201,6 +55395,7 @@ ${codeText}
|
|
|
55201
55395
|
__publicField(this, "_disableTextToolbar", false);
|
|
55202
55396
|
__publicField(this, "_lastClickTime", 0);
|
|
55203
55397
|
__publicField(this, "_disabled", false);
|
|
55398
|
+
__publicField(this, "cancelFocus");
|
|
55204
55399
|
__publicField(this, "isInToolbar", (event) => this.toolbar.isInCommandBar(event.target));
|
|
55205
55400
|
__publicField(this, "handleButtonClick", (toolbar2, item) => {
|
|
55206
55401
|
const tooltip = this.editor.findCustom("editor-tooltip");
|
|
@@ -55225,16 +55420,15 @@ ${codeText}
|
|
|
55225
55420
|
this._lastClickTime = Date.now();
|
|
55226
55421
|
});
|
|
55227
55422
|
__publicField(this, "handleClose", () => {
|
|
55228
|
-
var _a;
|
|
55423
|
+
var _a, _b;
|
|
55229
55424
|
if (shouldFocusToEditor(this.editor) && !clientType.isMobile) {
|
|
55230
55425
|
const activeElement = (_a = document.getSelection()) == null ? void 0 : _a.focusNode;
|
|
55231
55426
|
if (activeElement && isInBlockTools(activeElement)) {
|
|
55232
55427
|
logger$1Z.debug("focus is in block tools, ignore focus");
|
|
55233
55428
|
return;
|
|
55234
55429
|
}
|
|
55235
|
-
this.
|
|
55236
|
-
|
|
55237
|
-
});
|
|
55430
|
+
(_b = this.cancelFocus) == null ? void 0 : _b.call(this);
|
|
55431
|
+
this.cancelFocus = requestEditorFocus(this.editor);
|
|
55238
55432
|
}
|
|
55239
55433
|
});
|
|
55240
55434
|
__publicField(this, "handleClosing", (bar2, event) => {
|
|
@@ -55363,8 +55557,10 @@ ${codeText}
|
|
|
55363
55557
|
this.toolbar.close("selectionChange");
|
|
55364
55558
|
}
|
|
55365
55559
|
destroy() {
|
|
55560
|
+
var _a;
|
|
55366
55561
|
this.unbindEvents();
|
|
55367
55562
|
this.toolbar.destroy();
|
|
55563
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
55368
55564
|
this.editor.removeListener("selectionChanged", this.handleSelectionChange);
|
|
55369
55565
|
OnesEditorHoveringBlock.get(this.editor).removeListener("childChange", this.handleHoveringBlockChildChange);
|
|
55370
55566
|
}
|
|
@@ -96704,14 +96900,13 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96704
96900
|
__publicField(this, "toolbar");
|
|
96705
96901
|
__publicField(this, "toolbarFullScreen");
|
|
96706
96902
|
__publicField(this, "root");
|
|
96903
|
+
__publicField(this, "cancelFocus");
|
|
96707
96904
|
__publicField(this, "handleClick", (bar2, item) => {
|
|
96708
96905
|
const command = item;
|
|
96709
96906
|
if (command.onClick) {
|
|
96710
96907
|
command.onClick(this.editor, command, bar2);
|
|
96711
96908
|
this.handleSelectionChanged();
|
|
96712
|
-
|
|
96713
|
-
this.editor.focus();
|
|
96714
|
-
});
|
|
96909
|
+
this.restoreFocus();
|
|
96715
96910
|
return;
|
|
96716
96911
|
}
|
|
96717
96912
|
const findParent = (item2, id) => {
|
|
@@ -96757,9 +96952,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96757
96952
|
id: "main-toolbar"
|
|
96758
96953
|
});
|
|
96759
96954
|
this.toolbar.addListener("closing", () => {
|
|
96760
|
-
|
|
96761
|
-
editor.focus();
|
|
96762
|
-
}, 100);
|
|
96955
|
+
this.restoreFocus(100);
|
|
96763
96956
|
return true;
|
|
96764
96957
|
});
|
|
96765
96958
|
this.toolbar.addListener("click", this.handleClick);
|
|
@@ -96790,11 +96983,18 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96790
96983
|
});
|
|
96791
96984
|
}
|
|
96792
96985
|
}
|
|
96793
|
-
|
|
96986
|
+
restoreFocus(delay = 0) {
|
|
96794
96987
|
var _a;
|
|
96988
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
96989
|
+
this.cancelFocus = requestEditorFocus(this.editor, delay);
|
|
96990
|
+
}
|
|
96991
|
+
destroy() {
|
|
96992
|
+
var _a, _b, _c;
|
|
96993
|
+
(_a = this.cancelFocus) == null ? void 0 : _a.call(this);
|
|
96795
96994
|
this.toolbar.destroy();
|
|
96796
96995
|
this.editor.removeListener("selectionChanged", this.handleSelectionChanged);
|
|
96797
|
-
(
|
|
96996
|
+
(_b = this.toolbarFullScreen) == null ? void 0 : _b.destroy();
|
|
96997
|
+
(_c = this.cancelFocus) == null ? void 0 : _c.call(this);
|
|
96798
96998
|
this.root.remove();
|
|
96799
96999
|
}
|
|
96800
97000
|
setItems(items) {
|
|
@@ -97387,7 +97587,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97387
97587
|
}
|
|
97388
97588
|
}
|
|
97389
97589
|
});
|
|
97390
|
-
editor.version = "3.1.
|
|
97590
|
+
editor.version = "3.1.7-beta.ONES22302172.4";
|
|
97391
97591
|
return editor;
|
|
97392
97592
|
}
|
|
97393
97593
|
function isDoc(doc2) {
|
|
@@ -97528,7 +97728,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97528
97728
|
OnesEditorDropTarget.register(editor);
|
|
97529
97729
|
OnesEditorTocProvider.register(editor);
|
|
97530
97730
|
OnesEditorExclusiveBlock.register(editor);
|
|
97531
|
-
editor.version = "3.1.
|
|
97731
|
+
editor.version = "3.1.7-beta.ONES22302172.4";
|
|
97532
97732
|
return editor;
|
|
97533
97733
|
} catch (error2) {
|
|
97534
97734
|
if (editorForCleanup) {
|
|
@@ -143431,6 +143631,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
143431
143631
|
exports2.FindReplaceItem = FindReplaceItem;
|
|
143432
143632
|
exports2.FitIcon = FitIcon;
|
|
143433
143633
|
exports2.FixedToolbar = FixedToolbar;
|
|
143634
|
+
exports2.FocusRestoration = FocusRestoration;
|
|
143434
143635
|
exports2.FontBoldItem = FontBoldItem;
|
|
143435
143636
|
exports2.FontItalicItem = FontItalicItem;
|
|
143436
143637
|
exports2.FontStrikethroughItem = FontStrikethroughItem;
|
|
@@ -143626,6 +143827,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
143626
143827
|
exports2.YoukuIcon = YoukuIcon;
|
|
143627
143828
|
exports2.ZERO_WIDTH_SPACE_CHAR = ZERO_WIDTH_SPACE_CHAR;
|
|
143628
143829
|
exports2.abbreviation = abbreviation;
|
|
143830
|
+
exports2.acquireEditorFocus = acquireEditorFocus;
|
|
143629
143831
|
exports2.activeComment = activeComment;
|
|
143630
143832
|
exports2.addAttribute = addAttribute;
|
|
143631
143833
|
exports2.addClass = addClass;
|
|
@@ -144109,6 +144311,8 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144109
144311
|
exports2.replaceAllText = replaceAllText;
|
|
144110
144312
|
exports2.replaceText = replaceText;
|
|
144111
144313
|
exports2.requestDownload = requestDownload;
|
|
144314
|
+
exports2.requestEditorFocus = requestEditorFocus;
|
|
144315
|
+
exports2.requestInputFocus = requestInputFocus;
|
|
144112
144316
|
exports2.resetListStart = resetListStart;
|
|
144113
144317
|
exports2.saveAs = saveAs$1;
|
|
144114
144318
|
exports2.scrollBarIntoView = scrollBarIntoView;
|