@ones-editor/editor 2.0.7-beta.16 → 2.0.7-beta.18

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
@@ -23883,17 +23883,21 @@ var __publicField = (obj, key, value) => {
23883
23883
  const isInDisableScrollMask = this.isInDisableScrollMask(target);
23884
23884
  if (target && (isInDisableScrollMask || rootContainer.contains(target))) {
23885
23885
  if (!isInDisableScrollMask && !isInBlockTools(target)) {
23886
- this.editor.emit("focus", this.editor);
23887
- this.callbacks.onFocus();
23888
- this.editor.input.focus();
23886
+ setTimeout(() => {
23887
+ this.editor.emit("focus", this.editor);
23888
+ this.callbacks.onFocus();
23889
+ this.editor.input.focus();
23890
+ });
23889
23891
  }
23890
23892
  return;
23891
23893
  }
23892
23894
  if (this.isInCommandBar(target)) {
23893
23895
  return;
23894
23896
  }
23895
- this.editor.emit("blur", this.editor);
23896
- this.callbacks.onBlur();
23897
+ setTimeout(() => {
23898
+ this.editor.emit("blur", this.editor);
23899
+ this.callbacks.onBlur();
23900
+ });
23897
23901
  });
23898
23902
  __publicField(this, "handleDocumentSelectionChange", () => {
23899
23903
  setTimeout(() => {
@@ -24010,7 +24014,7 @@ var __publicField = (obj, key, value) => {
24010
24014
  input2.addEventListener("compositionstart", this.handleCompositionstart);
24011
24015
  input2.addEventListener("compositionend", this.handleCompositionend);
24012
24016
  this.inputElement = input2;
24013
- document.addEventListener("click", this.handleDocumentClick);
24017
+ document.addEventListener("click", this.handleDocumentClick, { capture: true });
24014
24018
  document.addEventListener("selectionchange", this.handleDocumentSelectionChange);
24015
24019
  this.editor.addListener("selectionChanged", this.handleEditorSelectionChanged);
24016
24020
  this.editor.addListener("readonlyChanged", this.handleReadonlyChanged);
@@ -24029,7 +24033,7 @@ var __publicField = (obj, key, value) => {
24029
24033
  }
24030
24034
  destroy() {
24031
24035
  this.callbacks.destroy();
24032
- document.removeEventListener("click", this.handleDocumentClick);
24036
+ document.removeEventListener("click", this.handleDocumentClick, { capture: true });
24033
24037
  document.removeEventListener("selectionchange", this.handleDocumentSelectionChange);
24034
24038
  this.editor.removeListener("selectionChanged", this.handleEditorSelectionChanged);
24035
24039
  this.editor.removeListener("readonlyChanged", this.handleReadonlyChanged);
@@ -55035,13 +55039,23 @@ $$${mathData.mathjaxText}$$
55035
55039
  }
55036
55040
  const rect = rects[0];
55037
55041
  const anchor2 = createBlockAnchor(editor, block, "quick-menu-inline-link", rect);
55042
+ const start = range.start.offset;
55043
+ const end = range.end.offset;
55038
55044
  const onFinished = (linkText, linkUrl) => {
55039
55045
  editor.undoManager.runInGroup(() => {
55040
55046
  try {
55041
- const text2 = editor.getBlockText(block);
55042
- const newText = insertText(text2, range.start.offset, linkText, { link: linkUrl });
55047
+ const isCollapsed = editor.selection.range.isCollapsed();
55048
+ let newText;
55049
+ if (isCollapsed) {
55050
+ newText = insertText(editor.getBlockText(block), end, linkText, { link: linkUrl });
55051
+ editor.setBlockText(block, newText);
55052
+ editor.focus();
55053
+ return;
55054
+ }
55055
+ newText = replaceText(editor.getBlockText(block), start, end, linkText);
55056
+ newText = rangeAddAttribute(start, linkText.length, newText, "link", linkUrl);
55043
55057
  editor.setBlockText(block, newText);
55044
- editor.selection.selectBlock(block, range.start.offset + linkText.length);
55058
+ editor.selection.selectBlock(block, start + linkText.length);
55045
55059
  editor.focus();
55046
55060
  } catch (error2) {
55047
55061
  logger$1K.error(error2);
@@ -82301,7 +82315,7 @@ ${data2.flowchartText}
82301
82315
  }
82302
82316
  }
82303
82317
  });
82304
- editor.version = "2.0.7-beta.16";
82318
+ editor.version = "2.0.7-beta.18";
82305
82319
  if (Logger$2.level === LogLevel.DEBUG) {
82306
82320
  window.setReauthFail = (fail) => {
82307
82321
  window.isReauthError = fail;
@@ -82395,7 +82409,7 @@ ${data2.flowchartText}
82395
82409
  if (!clientType.isMobile) {
82396
82410
  OnesEditorToolbar.register(editor);
82397
82411
  }
82398
- editor.version = "2.0.7-beta.16";
82412
+ editor.version = "2.0.7-beta.18";
82399
82413
  return editor;
82400
82414
  }
82401
82415
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.0.7-beta.16",
3
+ "version": "2.0.7-beta.18",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",