@ones-editor/editor 3.1.7-beta.ONES22302172.5 → 3.1.7-beta.ONES22303310.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -26414,114 +26414,6 @@ 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, "activeScope");
26426
- __publicField(this, "timers", /* @__PURE__ */ new Set());
26427
- this.input = input2;
26428
- this.restore = restore;
26429
- controllers.set(input2, this);
26430
- }
26431
- canFocus() {
26432
- var _a;
26433
- return !this.destroyed && !this.owner && !((_a = this.activeScope) == null ? void 0 : _a.cancelled) && this.input.isConnected;
26434
- }
26435
- hasOtherInput() {
26436
- const active = this.input.ownerDocument.activeElement;
26437
- return active !== this.input && !!(active == null ? void 0 : active.matches('input, textarea, select, [contenteditable="true"], [contenteditable=""]'));
26438
- }
26439
- schedule(callback, delay = 0, protectUserFocus = false) {
26440
- var _a;
26441
- return this.scheduleInScope(callback, delay, protectUserFocus, (_a = this.activeScope) != null ? _a : this.createScope());
26442
- }
26443
- createScope() {
26444
- return { cancelled: false, timers: /* @__PURE__ */ new Set() };
26445
- }
26446
- scheduleInScope(callback, delay, protectUserFocus, scope) {
26447
- if (scope.cancelled || !this.canFocus()) {
26448
- return noop$1;
26449
- }
26450
- const generation = this.generation;
26451
- const timer = setTimeout(() => {
26452
- this.timers.delete(timer);
26453
- scope.timers.delete(timer);
26454
- if (!scope.cancelled && generation === this.generation && this.canFocus() && (!protectUserFocus || !this.hasOtherInput())) {
26455
- const previousScope = this.activeScope;
26456
- this.activeScope = scope;
26457
- try {
26458
- callback();
26459
- } finally {
26460
- this.activeScope = previousScope;
26461
- }
26462
- }
26463
- }, delay);
26464
- this.timers.add(timer);
26465
- scope.timers.add(timer);
26466
- return () => {
26467
- scope.cancelled = true;
26468
- scope.timers.forEach((pending) => {
26469
- clearTimeout(pending);
26470
- this.timers.delete(pending);
26471
- });
26472
- scope.timers.clear();
26473
- };
26474
- }
26475
- request(delay = 0) {
26476
- return this.scheduleInScope(this.restore, delay, !clientType.isMobile, this.createScope());
26477
- }
26478
- cancelPending() {
26479
- if (this.activeScope) {
26480
- this.activeScope.cancelled = true;
26481
- }
26482
- this.generation += 1;
26483
- this.timers.forEach((timer) => clearTimeout(timer));
26484
- this.timers.clear();
26485
- }
26486
- acquire() {
26487
- this.cancelPending();
26488
- const owner = {};
26489
- this.owner = owner;
26490
- return () => {
26491
- if (this.owner === owner) {
26492
- this.cancelPending();
26493
- this.owner = null;
26494
- }
26495
- };
26496
- }
26497
- destroy() {
26498
- this.destroyed = true;
26499
- this.cancelPending();
26500
- this.owner = null;
26501
- controllers.delete(this.input);
26502
- }
26503
- }
26504
- function requestInputFocus(input2, delay = 0) {
26505
- var _a, _b;
26506
- return (_b = (_a = controllers.get(input2)) == null ? void 0 : _a.request(delay)) != null ? _b : noop$1;
26507
- }
26508
- function requestEditorFocus(editor, delay = 0) {
26509
- if (editor.destroyed) {
26510
- return noop$1;
26511
- }
26512
- if (clientType.isMobile && delay === 0) {
26513
- editor.focus();
26514
- return noop$1;
26515
- }
26516
- return requestInputFocus(editor.input.inputElement, delay);
26517
- }
26518
- function acquireEditorFocus(editor) {
26519
- var _a, _b;
26520
- if (clientType.isMobile || editor.destroyed) {
26521
- return noop$1;
26522
- }
26523
- return (_b = (_a = controllers.get(editor.input.inputElement)) == null ? void 0 : _a.acquire()) != null ? _b : noop$1;
26524
- }
26525
26417
  const logger$3V = getLogger("editor-input");
26526
26418
  class EditorInput$1 {
26527
26419
  constructor(editor, callbacks) {
@@ -26531,7 +26423,6 @@ var __publicField = (obj, key, value) => {
26531
26423
  __publicField(this, "callbacks");
26532
26424
  __publicField(this, "inputElement");
26533
26425
  __publicField(this, "focused", false);
26534
- __publicField(this, "focusRestoration");
26535
26426
  __publicField(this, "handleBlur", () => {
26536
26427
  this.editor.emit("blur", this.editor);
26537
26428
  this.callbacks.onBlur();
@@ -26553,20 +26444,12 @@ var __publicField = (obj, key, value) => {
26553
26444
  const isInDisableScrollMask = this.isInDisableScrollMask(target);
26554
26445
  if (target && (isInDisableScrollMask || rootElement === target || rootElement.contains(target))) {
26555
26446
  if (!isInDisableScrollMask && !isInBlockTools(target)) {
26556
- const focus = () => {
26557
- if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
26558
- return;
26559
- }
26447
+ setTimeout(() => {
26560
26448
  this.editor.emit("focus", this.editor);
26561
26449
  this.callbacks.onFocus();
26562
26450
  this.editor.input.focus();
26563
26451
  this.focused = true;
26564
- };
26565
- if (clientType.isMobile) {
26566
- setTimeout(focus);
26567
- } else {
26568
- this.focusRestoration.schedule(focus);
26569
- }
26452
+ });
26570
26453
  }
26571
26454
  return;
26572
26455
  }
@@ -26701,11 +26584,6 @@ var __publicField = (obj, key, value) => {
26701
26584
  input2.addEventListener("compositionstart", this.handleCompositionstart);
26702
26585
  input2.addEventListener("compositionend", this.handleCompositionend);
26703
26586
  this.inputElement = input2;
26704
- this.focusRestoration = new FocusRestoration(input2, () => {
26705
- if (!this.editor.destroyed) {
26706
- this.editor.focus(clientType.isMobile ? void 0 : { preventScroll: true });
26707
- }
26708
- });
26709
26587
  if (clientType.isMobile) {
26710
26588
  document.addEventListener("touchend", this.handleDocumentClick);
26711
26589
  } else {
@@ -26728,7 +26606,6 @@ var __publicField = (obj, key, value) => {
26728
26606
  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"));
26729
26607
  }
26730
26608
  destroy() {
26731
- this.focusRestoration.destroy();
26732
26609
  this.callbacks.destroy();
26733
26610
  if (clientType.isMobile) {
26734
26611
  document.removeEventListener("touchend", this.handleDocumentClick);
@@ -26753,36 +26630,24 @@ var __publicField = (obj, key, value) => {
26753
26630
  return this.inputElement;
26754
26631
  }
26755
26632
  focus(options) {
26756
- if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
26757
- return;
26758
- }
26759
26633
  if (!this.editor.selection.caret.visible()) {
26760
26634
  this.editor.selection.caret.update();
26761
26635
  }
26762
26636
  if (clientType.isMobile) {
26763
26637
  this.inputElement.focus(options);
26764
26638
  this.callbacks.onFocus();
26765
- this.focused = true;
26766
26639
  } else {
26767
- this.focusRestoration.schedule(() => {
26768
- if (this.editor.destroyed) {
26769
- return;
26770
- }
26640
+ setTimeout(() => {
26771
26641
  if (document.activeElement !== this.inputElement) {
26772
- this.focusRestoration.schedule(() => {
26773
- if (!this.editor.destroyed && document.activeElement === this.inputElement) {
26774
- this.editor.emit("focus", this.editor);
26775
- }
26642
+ setTimeout(() => {
26643
+ this.editor.emit("focus", this.editor);
26776
26644
  });
26777
26645
  }
26778
26646
  this.inputElement.focus(options);
26779
- if (this.editor.destroyed || !this.focusRestoration.canFocus()) {
26780
- return;
26781
- }
26782
26647
  this.callbacks.onFocus();
26783
- this.focused = true;
26784
- }, 0, (options == null ? void 0 : options.preventScroll) === true);
26648
+ });
26785
26649
  }
26650
+ this.focused = true;
26786
26651
  }
26787
26652
  isInDisableScrollMask(target) {
26788
26653
  let elem = target;
@@ -32341,7 +32206,7 @@ ${codeText}
32341
32206
  editor.doc.endBatchUpdate();
32342
32207
  }
32343
32208
  if (!clientType.isMobile) {
32344
- requestEditorFocus(editor);
32209
+ editor.focus();
32345
32210
  }
32346
32211
  return rangeResult;
32347
32212
  });
@@ -42651,12 +42516,10 @@ ${codeText}
42651
42516
  });
42652
42517
  __publicField(this, "tippyInstance", null);
42653
42518
  __publicField(this, "_target", null);
42654
- __publicField(this, "cancelFocus");
42655
42519
  __publicField(this, "handleBeforeClose", (event) => {
42656
- var _a, _b;
42657
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
42520
+ var _a;
42658
42521
  let ret = false;
42659
- if ((_b = this.manualCommandBarOptions) == null ? void 0 : _b.beforeClose) {
42522
+ if ((_a = this.manualCommandBarOptions) == null ? void 0 : _a.beforeClose) {
42660
42523
  ret = this.manualCommandBarOptions.beforeClose(event);
42661
42524
  }
42662
42525
  if (ret) {
@@ -42666,16 +42529,18 @@ ${codeText}
42666
42529
  return ret;
42667
42530
  }
42668
42531
  const target = this._target;
42669
- const parentEditor = target.closest(".editor-root");
42670
- const input2 = parentEditor == null ? void 0 : parentEditor.querySelector(".editor-input");
42671
- if (input2 && !(parentEditor == null ? void 0 : parentEditor.contains(document.activeElement))) {
42672
- if (clientType.isMobile) {
42673
- const timer = setTimeout(() => input2.focus(), 100);
42674
- this.cancelFocus = () => clearTimeout(timer);
42675
- } else {
42676
- this.cancelFocus = requestInputFocus(input2, 100);
42532
+ setTimeout(() => {
42533
+ const parentEditor = target.closest(".editor-root");
42534
+ if (parentEditor) {
42535
+ const input2 = parentEditor.querySelector(".editor-input");
42536
+ if (input2) {
42537
+ if (parentEditor.contains(document.activeElement)) {
42538
+ return;
42539
+ }
42540
+ input2.focus();
42541
+ }
42677
42542
  }
42678
- }
42543
+ }, 100);
42679
42544
  return ret;
42680
42545
  });
42681
42546
  __publicField(this, "setProps", (props) => {
@@ -42685,8 +42550,7 @@ ${codeText}
42685
42550
  this.manualCommandBarOptions = manualCommandBarOptions;
42686
42551
  }
42687
42552
  manualShow(target, options) {
42688
- var _a, _b, _c, _d, _e;
42689
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
42553
+ var _a, _b, _c, _d;
42690
42554
  this._target = target;
42691
42555
  if (this.isVisible) {
42692
42556
  return;
@@ -42701,16 +42565,16 @@ ${codeText}
42701
42565
  trigger: "manual",
42702
42566
  triggerTarget: null,
42703
42567
  hideOnClick: false,
42704
- placement: (_b = options == null ? void 0 : options.placement) != null ? _b : "bottom-start",
42705
- maxWidth: (_c = this.options.maxWidth) != null ? _c : 650,
42706
- arrow: (_d = options == null ? void 0 : options.arrow) != null ? _d : this.options.tippyArrow,
42568
+ placement: (_a = options == null ? void 0 : options.placement) != null ? _a : "bottom-start",
42569
+ maxWidth: (_b = this.options.maxWidth) != null ? _b : 650,
42570
+ arrow: (_c = options == null ? void 0 : options.arrow) != null ? _c : this.options.tippyArrow,
42707
42571
  appendTo: this.options.appendTo || target.closest(".command-bar-container") || document.body,
42708
42572
  onShow: this.handleShow,
42709
42573
  onHidden: this.handleHidden,
42710
42574
  onShown: this.handleShown,
42711
42575
  theme: options == null ? void 0 : options.theme,
42712
42576
  getReferenceClientRect: options == null ? void 0 : options.getReferenceClientRect,
42713
- offset: (_e = options == null ? void 0 : options.offset) != null ? _e : [0, 0],
42577
+ offset: (_d = options == null ? void 0 : options.offset) != null ? _d : [0, 0],
42714
42578
  popperOptions: this.createPopperOptions(),
42715
42579
  delay: 500
42716
42580
  });
@@ -42745,12 +42609,10 @@ ${codeText}
42745
42609
  }
42746
42610
  }
42747
42611
  destroy() {
42748
- var _a, _b, _c;
42749
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
42750
- (_b = this.tippyInstance) == null ? void 0 : _b.destroy();
42612
+ var _a;
42613
+ (_a = this.tippyInstance) == null ? void 0 : _a.destroy();
42751
42614
  this.tippyInstance = null;
42752
42615
  super.destroy();
42753
- (_c = this.cancelFocus) == null ? void 0 : _c.call(this);
42754
42616
  }
42755
42617
  getCommandBarRoot() {
42756
42618
  return this.content.closest("[data-tippy-root]");
@@ -44870,22 +44732,19 @@ ${codeText}
44870
44732
  class EditorAutoSuggestMenu extends AutoSuggestMenu {
44871
44733
  constructor(editor, editorOptions) {
44872
44734
  super(editorOptions);
44873
- __publicField(this, "cancelFocus");
44874
44735
  __publicField(this, "handleClose", () => {
44875
- var _a, _b, _c;
44876
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
44736
+ var _a, _b;
44877
44737
  if (shouldFocusToEditor(this.editor)) {
44878
- this.cancelFocus = requestEditorFocus(this.editor);
44738
+ this.editor.focus();
44879
44739
  }
44880
- (_c = (_b = this.options).onClose) == null ? void 0 : _c.call(_b);
44740
+ (_b = (_a = this.options).onClose) == null ? void 0 : _b.call(_a);
44881
44741
  });
44882
44742
  this.editor = editor;
44883
44743
  this.editorOptions = editorOptions;
44884
44744
  }
44885
44745
  async popupInEditor(containerId, blockIndex, offset) {
44886
- var _a, _b, _c;
44887
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
44888
- if (((_c = (_b = this.editorOptions).onShow) == null ? void 0 : _c.call(_b, this, containerId, blockIndex, offset)) === false) {
44746
+ var _a, _b;
44747
+ if (((_b = (_a = this.editorOptions).onShow) == null ? void 0 : _b.call(_a, this, containerId, blockIndex, offset)) === false) {
44889
44748
  return;
44890
44749
  }
44891
44750
  if (this.options.showLoading) {
@@ -44903,11 +44762,6 @@ ${codeText}
44903
44762
  const anchor2 = createBlockAnchor(this.editor, block, "editor-auto-suggest-menu", rect);
44904
44763
  super.popup(anchor2, { noEvent: true });
44905
44764
  }
44906
- destroy() {
44907
- var _a;
44908
- super.destroy();
44909
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
44910
- }
44911
44765
  }
44912
44766
  const logger$2G = getLogger("auto-suggest-menu");
44913
44767
  class OnesEditorAutoSuggest {
@@ -54234,7 +54088,6 @@ ${codeText}
54234
54088
  });
54235
54089
  __publicField(this, "close", () => {
54236
54090
  this.linkPopup.close("cancelBar");
54237
- this.emit("close");
54238
54091
  });
54239
54092
  __publicField(this, "createItems", (content) => [{
54240
54093
  id: "link-popup",
@@ -54256,6 +54109,7 @@ ${codeText}
54256
54109
  this.emit("finished");
54257
54110
  });
54258
54111
  __publicField(this, "handleClose", () => {
54112
+ this.emit("close");
54259
54113
  this.close();
54260
54114
  });
54261
54115
  __publicField(this, "handleShown", () => {
@@ -54284,13 +54138,8 @@ ${codeText}
54284
54138
  this.linkPopup = new MobileBottomMenu(this.createItems(content), void 0, {
54285
54139
  id: "link-popup",
54286
54140
  header: this.createHeader(),
54287
- disableSelectedScroll: true,
54288
- beforeClose: () => {
54289
- this.handleClose();
54290
- return true;
54291
- }
54141
+ disableSelectedScroll: true
54292
54142
  });
54293
- this.linkPopup.addListener("close", () => this.emit("close"));
54294
54143
  }
54295
54144
  destroy() {
54296
54145
  var _a, _b;
@@ -54309,11 +54158,11 @@ ${codeText}
54309
54158
  this.emit("finished");
54310
54159
  });
54311
54160
  __publicField(this, "handleClose", () => {
54161
+ this.emit("close");
54312
54162
  this.close();
54313
54163
  });
54314
54164
  __publicField(this, "close", () => {
54315
54165
  this.linkPopup.close("cancelBar");
54316
- this.emit("close");
54317
54166
  });
54318
54167
  __publicField(this, "disabledSubmit", () => {
54319
54168
  var _a;
@@ -54333,13 +54182,8 @@ ${codeText}
54333
54182
  this.content = content;
54334
54183
  this.options = options;
54335
54184
  this.linkPopup = new Popup(this.createPopupContent(), {
54336
- id: "link-popup",
54337
- beforeClose: () => {
54338
- this.handleClose();
54339
- return true;
54340
- }
54185
+ id: "link-popup"
54341
54186
  });
54342
- this.linkPopup.addListener("close", () => this.emit("close"));
54343
54187
  }
54344
54188
  createPopupContent() {
54345
54189
  const container = createElement("div", ["link-popup-content"], null);
@@ -54372,85 +54216,46 @@ ${codeText}
54372
54216
  __publicField(this, "onFinished", null);
54373
54217
  __publicField(this, "onClose", null);
54374
54218
  __publicField(this, "onBeforeFormatUrl", null);
54375
- __publicField(this, "session", 0);
54376
- __publicField(this, "submitting", false);
54377
- __publicField(this, "focusTimer");
54378
- __publicField(this, "releaseFocus");
54379
54219
  __publicField(this, "handleOk", async () => {
54380
- if (!this.linkPopup || this.submitting || this.editor.destroyed) {
54381
- return;
54382
- }
54383
- const session = this.session;
54384
- const form = this.form;
54385
- const onFinished = this.onFinished;
54386
- const beforeFormatUrl = this.onBeforeFormatUrl;
54387
- this.submitting = true;
54220
+ var _a;
54388
54221
  try {
54389
- await this.checkValue(form);
54390
- if (!this.isCurrent(session)) {
54391
- return;
54392
- }
54393
- const { linkText, linkUrl } = form;
54222
+ await this.checkValue();
54223
+ const { linkText, linkUrl } = this.form;
54394
54224
  const inputValue = linkUrl.getInputValue();
54395
- const formatted = beforeFormatUrl == null ? void 0 : beforeFormatUrl(inputValue);
54396
- const link2 = typeof formatted === "string" ? formatted : this.formatUrl(inputValue);
54397
- const text2 = linkText.getInputValue() || link2;
54398
- if (!this.isCurrent(session)) {
54399
- return;
54225
+ let link2 = "";
54226
+ if (this.onBeforeFormatUrl && this.onBeforeFormatUrl(inputValue) !== false) {
54227
+ link2 = this.onBeforeFormatUrl(inputValue);
54228
+ } else {
54229
+ link2 = this.formatUrl(inputValue);
54400
54230
  }
54231
+ (_a = this.onFinished) == null ? void 0 : _a.call(this, linkText.getInputValue() || link2, link2);
54401
54232
  this._destroy();
54402
- onFinished == null ? void 0 : onFinished(text2, link2);
54403
54233
  } catch (error2) {
54404
- if (this.isCurrent(session)) {
54405
- this.submitting = false;
54406
- }
54407
54234
  }
54408
54235
  });
54409
54236
  __publicField(this, "handleClose", () => {
54410
- if (!this.linkPopup) {
54411
- return;
54412
- }
54413
- const onClose = this.onClose;
54237
+ var _a;
54238
+ (_a = this.onClose) == null ? void 0 : _a.call(this);
54414
54239
  this._destroy();
54415
- if (!this.editor.destroyed) {
54416
- onClose == null ? void 0 : onClose();
54417
- }
54418
54240
  });
54419
54241
  __publicField(this, "onShow", () => {
54420
- var _a;
54421
- const session = this.session;
54422
- const field = (_a = this.form.linkUrl) == null ? void 0 : _a.getField();
54423
- clearTimeout(this.focusTimer);
54424
- this.focusTimer = setTimeout(() => {
54425
- if (this.isCurrent(session) && (field == null ? void 0 : field.isConnected)) {
54426
- field.focus(clientType.isMobile ? void 0 : { preventScroll: true });
54427
- }
54242
+ setTimeout(() => {
54243
+ var _a;
54244
+ (_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus();
54428
54245
  }, 400);
54429
54246
  });
54430
54247
  __publicField(this, "showPopup", (options) => {
54431
- const session = this.session;
54248
+ var _a, _b, _c, _d, _e;
54432
54249
  if (clientType.isMobile) {
54433
54250
  this.linkPopup = new MobileLinkPopup(this.editor, this.createPopupContent(options.linkText, options.linkUrl), options);
54434
54251
  } else {
54435
54252
  this.linkPopup = new LinkPopup(this.createPopupContent(options.linkText, options.linkUrl), options);
54436
54253
  }
54437
- this.linkPopup.addListener("show", () => {
54438
- if (this.isCurrent(session)) {
54439
- this.onShow();
54440
- }
54441
- });
54442
- this.linkPopup.addListener("finished", () => {
54443
- if (this.isCurrent(session)) {
54444
- this.handleOk();
54445
- }
54446
- });
54447
- this.linkPopup.addListener("close", () => {
54448
- if (this.isCurrent(session)) {
54449
- this.handleClose();
54450
- }
54451
- });
54452
- this.linkPopup.disabledSubmit();
54453
- this.linkPopup.manualShow();
54254
+ (_a = this.linkPopup) == null ? void 0 : _a.addListener("show", this.onShow);
54255
+ (_b = this.linkPopup) == null ? void 0 : _b.manualShow();
54256
+ (_c = this.linkPopup) == null ? void 0 : _c.disabledSubmit();
54257
+ (_d = this.linkPopup) == null ? void 0 : _d.addListener("finished", this.handleOk);
54258
+ (_e = this.linkPopup) == null ? void 0 : _e.addListener("close", this.handleClose);
54454
54259
  });
54455
54260
  __publicField(this, "onChange", () => {
54456
54261
  var _a;
@@ -54462,14 +54267,11 @@ ${codeText}
54462
54267
  return;
54463
54268
  }
54464
54269
  if (event.key === "Enter") {
54465
- (_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus(clientType.isMobile ? void 0 : { preventScroll: true });
54466
- event.preventDefault();
54270
+ (_a = this.form.linkUrl) == null ? void 0 : _a.getField().focus();
54467
54271
  event.stopPropagation();
54468
54272
  return;
54469
54273
  }
54470
54274
  if (event.key === "Escape") {
54471
- event.preventDefault();
54472
- event.stopPropagation();
54473
54275
  this.handleClose();
54474
54276
  }
54475
54277
  });
@@ -54483,18 +54285,13 @@ ${codeText}
54483
54285
  return;
54484
54286
  }
54485
54287
  if (event.key === "Escape") {
54486
- event.preventDefault();
54487
- event.stopPropagation();
54488
54288
  this.handleClose();
54489
54289
  }
54490
54290
  });
54491
54291
  this.editor = editor;
54492
54292
  }
54493
- isCurrent(session) {
54494
- return session === this.session && !!this.linkPopup && !this.editor.destroyed;
54495
- }
54496
- async checkValue(form) {
54497
- const { linkUrl } = form;
54293
+ async checkValue() {
54294
+ const { linkUrl } = this.form;
54498
54295
  if (!linkUrl.getInputValue()) {
54499
54296
  linkUrl.setFieldError(i18n$1.t("link.urlPlaceholder"));
54500
54297
  throw new Error(i18n$1.t("link.urlPlaceholder"));
@@ -54512,20 +54309,14 @@ ${codeText}
54512
54309
  return link2;
54513
54310
  }
54514
54311
  editLink(options) {
54515
- this._destroy();
54516
- if (this.editor.destroyed) {
54517
- return;
54518
- }
54519
- this.releaseFocus = acquireEditorFocus(this.editor);
54312
+ this.showPopup(options);
54520
54313
  const { onFinished, onClose, onBeforeFormatUrl } = options;
54521
54314
  this.onFinished = onFinished;
54522
- this.onClose = onClose != null ? onClose : null;
54523
- this.onBeforeFormatUrl = onBeforeFormatUrl != null ? onBeforeFormatUrl : null;
54524
- try {
54525
- this.showPopup(options);
54526
- } catch (error2) {
54527
- this._destroy();
54528
- throw error2;
54315
+ if (onClose) {
54316
+ this.onClose = onClose;
54317
+ }
54318
+ if (onBeforeFormatUrl) {
54319
+ this.onBeforeFormatUrl = onBeforeFormatUrl;
54529
54320
  }
54530
54321
  }
54531
54322
  createPopupContent(linkText, linkUrl) {
@@ -54554,21 +54345,12 @@ ${codeText}
54554
54345
  return content;
54555
54346
  }
54556
54347
  _destroy() {
54557
- this.session += 1;
54558
- clearTimeout(this.focusTimer);
54559
- this.focusTimer = void 0;
54560
- const popup = this.linkPopup;
54561
- const releaseFocus = this.releaseFocus;
54562
- this.linkPopup = null;
54563
- this.releaseFocus = void 0;
54564
- this.submitting = false;
54348
+ var _a, _b;
54565
54349
  this.onFinished = null;
54566
54350
  this.onClose = null;
54567
- this.onBeforeFormatUrl = null;
54568
54351
  this.form = {};
54569
- popup == null ? void 0 : popup.removeAllListeners();
54570
- popup == null ? void 0 : popup.destroy();
54571
- releaseFocus == null ? void 0 : releaseFocus();
54352
+ (_a = this.linkPopup) == null ? void 0 : _a.removeAllListeners();
54353
+ (_b = this.linkPopup) == null ? void 0 : _b.destroy();
54572
54354
  }
54573
54355
  destroy() {
54574
54356
  this._destroy();
@@ -54608,14 +54390,14 @@ ${codeText}
54608
54390
  const text2 = [op1, op2];
54609
54391
  editor.insertTextToBlock(block, 0, text2);
54610
54392
  editor.selection.selectBlock(block, getTextLength(text2));
54611
- requestEditorFocus(editor);
54393
+ editor.focus();
54612
54394
  } catch (error2) {
54613
54395
  logger$20.error(error2);
54614
54396
  }
54615
54397
  });
54616
54398
  };
54617
54399
  const onClose = () => {
54618
- requestEditorFocus(editor);
54400
+ editor.focus();
54619
54401
  };
54620
54402
  editLink(editor, {
54621
54403
  target: block,
@@ -54647,21 +54429,21 @@ ${codeText}
54647
54429
  if (isCollapsed) {
54648
54430
  newText = insertText(editor.getBlockText(block), end, linkText, { link: linkUrl });
54649
54431
  editor.setBlockText(block, newText);
54650
- requestEditorFocus(editor);
54432
+ editor.focus();
54651
54433
  return;
54652
54434
  }
54653
54435
  newText = replaceText(editor.getBlockText(block), start, end, linkText);
54654
54436
  newText = rangeAddAttribute(start, linkText.length, newText, "link", linkUrl);
54655
54437
  editor.setBlockText(block, newText);
54656
54438
  editor.selection.selectBlock(block, start + linkText.length);
54657
- requestEditorFocus(editor);
54439
+ editor.focus();
54658
54440
  } catch (error2) {
54659
54441
  logger$20.error(error2);
54660
54442
  }
54661
54443
  });
54662
54444
  };
54663
54445
  const onClose = () => {
54664
- requestEditorFocus(editor);
54446
+ editor.focus();
54665
54447
  };
54666
54448
  editLink(editor, {
54667
54449
  target: anchor2,
@@ -54910,14 +54692,14 @@ ${codeText}
54910
54692
  const newText = insertText(deleted, range.start, linkText, { link: linkUrl });
54911
54693
  editor.setBlockText(block, newText);
54912
54694
  editor.selection.selectBlock(block, range.start + linkText.length);
54913
- requestEditorFocus(editor);
54695
+ editor.focus();
54914
54696
  } catch (error2) {
54915
54697
  logger$1$.error(error2);
54916
54698
  }
54917
54699
  };
54918
54700
  const onClose = () => {
54919
54701
  editor.selection.selectBlock(block, range.end);
54920
- requestEditorFocus(editor);
54702
+ editor.focus();
54921
54703
  };
54922
54704
  const rect = getBlockClientRects(editor, block, editor.selection.range)[0];
54923
54705
  if (!rect) {
@@ -55419,7 +55201,6 @@ ${codeText}
55419
55201
  __publicField(this, "_disableTextToolbar", false);
55420
55202
  __publicField(this, "_lastClickTime", 0);
55421
55203
  __publicField(this, "_disabled", false);
55422
- __publicField(this, "cancelFocus");
55423
55204
  __publicField(this, "isInToolbar", (event) => this.toolbar.isInCommandBar(event.target));
55424
55205
  __publicField(this, "handleButtonClick", (toolbar2, item) => {
55425
55206
  const tooltip = this.editor.findCustom("editor-tooltip");
@@ -55444,15 +55225,16 @@ ${codeText}
55444
55225
  this._lastClickTime = Date.now();
55445
55226
  });
55446
55227
  __publicField(this, "handleClose", () => {
55447
- var _a, _b;
55228
+ var _a;
55448
55229
  if (shouldFocusToEditor(this.editor) && !clientType.isMobile) {
55449
55230
  const activeElement = (_a = document.getSelection()) == null ? void 0 : _a.focusNode;
55450
55231
  if (activeElement && isInBlockTools(activeElement)) {
55451
55232
  logger$1Z.debug("focus is in block tools, ignore focus");
55452
55233
  return;
55453
55234
  }
55454
- (_b = this.cancelFocus) == null ? void 0 : _b.call(this);
55455
- this.cancelFocus = requestEditorFocus(this.editor);
55235
+ this.editor.focus({
55236
+ preventScroll: true
55237
+ });
55456
55238
  }
55457
55239
  });
55458
55240
  __publicField(this, "handleClosing", (bar2, event) => {
@@ -55581,10 +55363,8 @@ ${codeText}
55581
55363
  this.toolbar.close("selectionChange");
55582
55364
  }
55583
55365
  destroy() {
55584
- var _a;
55585
55366
  this.unbindEvents();
55586
55367
  this.toolbar.destroy();
55587
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
55588
55368
  this.editor.removeListener("selectionChanged", this.handleSelectionChange);
55589
55369
  OnesEditorHoveringBlock.get(this.editor).removeListener("childChange", this.handleHoveringBlockChildChange);
55590
55370
  }
@@ -74058,10 +73838,11 @@ ${codeText}
74058
73838
  createTableBorderBar(editor, tableBlock);
74059
73839
  }
74060
73840
  function hideTableBorderBar(editor, tableBlock) {
73841
+ var _a, _b;
74061
73842
  assert(logger$14, isTableBlock(tableBlock), "invalid table block");
74062
- const tools = getTableTools(editor, tableBlock);
73843
+ const tools = (_a = getBlockContent(tableBlock).querySelector("div[data-type=table-content]")) == null ? void 0 : _a.querySelector(":scope >div[data-type=table-tools]");
74063
73844
  const blockTools = getBlockTools(tableBlock);
74064
- const topTableBorderBar = tools.querySelectorAll(".table-border-bar-container");
73845
+ const topTableBorderBar = (_b = tools == null ? void 0 : tools.querySelectorAll(".table-border-bar-container")) != null ? _b : [];
74065
73846
  const leftTableBorderBar = blockTools.querySelectorAll(".table-border-bar-container");
74066
73847
  topTableBorderBar.forEach((elem) => {
74067
73848
  editor.domEvents.removeEventListener(elem, "click", handleBorderBarClicked);
@@ -96924,13 +96705,14 @@ ${JSON.stringify(error2, null, 2)}`);
96924
96705
  __publicField(this, "toolbar");
96925
96706
  __publicField(this, "toolbarFullScreen");
96926
96707
  __publicField(this, "root");
96927
- __publicField(this, "cancelFocus");
96928
96708
  __publicField(this, "handleClick", (bar2, item) => {
96929
96709
  const command = item;
96930
96710
  if (command.onClick) {
96931
96711
  command.onClick(this.editor, command, bar2);
96932
96712
  this.handleSelectionChanged();
96933
- this.restoreFocus();
96713
+ setTimeout(() => {
96714
+ this.editor.focus();
96715
+ });
96934
96716
  return;
96935
96717
  }
96936
96718
  const findParent = (item2, id) => {
@@ -96976,7 +96758,9 @@ ${JSON.stringify(error2, null, 2)}`);
96976
96758
  id: "main-toolbar"
96977
96759
  });
96978
96760
  this.toolbar.addListener("closing", () => {
96979
- this.restoreFocus(100);
96761
+ setTimeout(() => {
96762
+ editor.focus();
96763
+ }, 100);
96980
96764
  return true;
96981
96765
  });
96982
96766
  this.toolbar.addListener("click", this.handleClick);
@@ -97007,18 +96791,11 @@ ${JSON.stringify(error2, null, 2)}`);
97007
96791
  });
97008
96792
  }
97009
96793
  }
97010
- restoreFocus(delay = 0) {
97011
- var _a;
97012
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
97013
- this.cancelFocus = requestEditorFocus(this.editor, delay);
97014
- }
97015
96794
  destroy() {
97016
- var _a, _b, _c;
97017
- (_a = this.cancelFocus) == null ? void 0 : _a.call(this);
96795
+ var _a;
97018
96796
  this.toolbar.destroy();
97019
96797
  this.editor.removeListener("selectionChanged", this.handleSelectionChanged);
97020
- (_b = this.toolbarFullScreen) == null ? void 0 : _b.destroy();
97021
- (_c = this.cancelFocus) == null ? void 0 : _c.call(this);
96798
+ (_a = this.toolbarFullScreen) == null ? void 0 : _a.destroy();
97022
96799
  this.root.remove();
97023
96800
  }
97024
96801
  setItems(items) {
@@ -97611,7 +97388,7 @@ ${JSON.stringify(error2, null, 2)}`);
97611
97388
  }
97612
97389
  }
97613
97390
  });
97614
- editor.version = "3.1.7-beta.ONES22302172.5";
97391
+ editor.version = "3.1.7-beta.ONES22303310.1";
97615
97392
  return editor;
97616
97393
  }
97617
97394
  function isDoc(doc2) {
@@ -97752,7 +97529,7 @@ ${JSON.stringify(error2, null, 2)}`);
97752
97529
  OnesEditorDropTarget.register(editor);
97753
97530
  OnesEditorTocProvider.register(editor);
97754
97531
  OnesEditorExclusiveBlock.register(editor);
97755
- editor.version = "3.1.7-beta.ONES22302172.5";
97532
+ editor.version = "3.1.7-beta.ONES22303310.1";
97756
97533
  return editor;
97757
97534
  } catch (error2) {
97758
97535
  if (editorForCleanup) {
@@ -143655,7 +143432,6 @@ ${JSON.stringify(error2, null, 2)}`);
143655
143432
  exports2.FindReplaceItem = FindReplaceItem;
143656
143433
  exports2.FitIcon = FitIcon;
143657
143434
  exports2.FixedToolbar = FixedToolbar;
143658
- exports2.FocusRestoration = FocusRestoration;
143659
143435
  exports2.FontBoldItem = FontBoldItem;
143660
143436
  exports2.FontItalicItem = FontItalicItem;
143661
143437
  exports2.FontStrikethroughItem = FontStrikethroughItem;
@@ -143851,7 +143627,6 @@ ${JSON.stringify(error2, null, 2)}`);
143851
143627
  exports2.YoukuIcon = YoukuIcon;
143852
143628
  exports2.ZERO_WIDTH_SPACE_CHAR = ZERO_WIDTH_SPACE_CHAR;
143853
143629
  exports2.abbreviation = abbreviation;
143854
- exports2.acquireEditorFocus = acquireEditorFocus;
143855
143630
  exports2.activeComment = activeComment;
143856
143631
  exports2.addAttribute = addAttribute;
143857
143632
  exports2.addClass = addClass;
@@ -144335,8 +144110,6 @@ ${JSON.stringify(error2, null, 2)}`);
144335
144110
  exports2.replaceAllText = replaceAllText;
144336
144111
  exports2.replaceText = replaceText;
144337
144112
  exports2.requestDownload = requestDownload;
144338
- exports2.requestEditorFocus = requestEditorFocus;
144339
- exports2.requestInputFocus = requestInputFocus;
144340
144113
  exports2.resetListStart = resetListStart;
144341
144114
  exports2.saveAs = saveAs$1;
144342
144115
  exports2.scrollBarIntoView = scrollBarIntoView;