@ones-editor/editor 2.2.9 → 2.2.10-beta.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.
@@ -56,4 +56,5 @@ export default abstract class CommandBar extends TypedEmitter<CommandBarEvents>
56
56
  static registerManualCommandBar(type: string, creator: CreateManualCommandBarFunction): void;
57
57
  static createSubCommandBar(item: CommandItem, closeable: Closeable, options?: CommandBarOptions): AbstractManualCommandBar;
58
58
  static hasExistsCommandBar(): boolean;
59
+ static hideAll(): void;
59
60
  }
package/dist/index.js CHANGED
@@ -11559,7 +11559,7 @@ var __publicField = (obj, key, value) => {
11559
11559
  }
11560
11560
  this.editor.selectionHandler.handleMouseDown(event, { autoScroll: true });
11561
11561
  }
11562
- this.editor.input.focus();
11562
+ this.editor.input.focus({ preventScroll: true });
11563
11563
  });
11564
11564
  __publicField(this, "handleMouseMove", (event) => {
11565
11565
  assert(logger$4p, this.mouseDownEvent, "no mouse down event");
@@ -13107,7 +13107,8 @@ var __publicField = (obj, key, value) => {
13107
13107
  if (pointX < rect.left) {
13108
13108
  x = rect.left;
13109
13109
  } else if (pointX > rect.right) {
13110
- x = rect.right - 50;
13110
+ const offset = targetBlock && isTextKindBlock(editor, targetBlock) ? 3 : 50;
13111
+ x = rect.right - offset;
13111
13112
  }
13112
13113
  }
13113
13114
  for (let i = 0; i < yOffsets.length; i++) {
@@ -14456,10 +14457,6 @@ var __publicField = (obj, key, value) => {
14456
14457
  }
14457
14458
  if (isTextBlockContentBoxChild(child)) {
14458
14459
  const boxChild = child;
14459
- const nextChild = children[i + 1];
14460
- if (!nextChild) {
14461
- break;
14462
- }
14463
14460
  const prevChild = children[i - 1];
14464
14461
  if (prevChild) {
14465
14462
  if (endAtNewLine(prevChild, boxChild)) {
@@ -14476,6 +14473,10 @@ var __publicField = (obj, key, value) => {
14476
14473
  });
14477
14474
  }
14478
14475
  }
14476
+ const nextChild = children[i + 1];
14477
+ if (!nextChild) {
14478
+ break;
14479
+ }
14479
14480
  if (nextChildStartsNewLine(boxChild, nextChild)) {
14480
14481
  offset += 1;
14481
14482
  lineBreaks.push({
@@ -39899,17 +39900,23 @@ ${codeText}
39899
39900
  return true;
39900
39901
  }
39901
39902
  if (event.key === "ArrowUp") {
39902
- const prev = this.getPrevItemIndex(this.getSelectedItemIndex());
39903
- this.startPauseMouseEnter();
39904
- this.selectItem(this.items[prev].id);
39905
- event.preventDefault();
39906
- event.stopPropagation();
39903
+ const curr = this.getSelectedItemIndex();
39904
+ const prev = this.getPrevItemIndex(curr);
39905
+ if (curr !== prev) {
39906
+ this.startPauseMouseEnter();
39907
+ this.selectItem(this.items[prev].id);
39908
+ event.preventDefault();
39909
+ event.stopPropagation();
39910
+ }
39907
39911
  } else if (event.key === "ArrowDown") {
39908
- const next2 = this.getNextItemIndex(this.getSelectedItemIndex());
39909
- this.startPauseMouseEnter();
39910
- this.selectItem(this.items[next2].id);
39911
- event.preventDefault();
39912
- event.stopPropagation();
39912
+ const curr = this.getSelectedItemIndex();
39913
+ const next2 = this.getNextItemIndex(curr);
39914
+ if (curr !== next2) {
39915
+ this.startPauseMouseEnter();
39916
+ this.selectItem(this.items[next2].id);
39917
+ event.preventDefault();
39918
+ event.stopPropagation();
39919
+ }
39913
39920
  } else if (event.key === "ArrowRight") {
39914
39921
  const item = this.getSelectedItem();
39915
39922
  if (item && item.children) {
@@ -40481,6 +40488,9 @@ ${codeText}
40481
40488
  static hasExistsCommandBar() {
40482
40489
  return !!document.querySelector("[data-command-bar-id]");
40483
40490
  }
40491
+ static hideAll() {
40492
+ tippy$1.hideAll();
40493
+ }
40484
40494
  };
40485
40495
  let CommandBar = _CommandBar;
40486
40496
  __publicField(CommandBar, "commandBarCreators", /* @__PURE__ */ new Map());
@@ -52278,6 +52288,7 @@ ${codeText}
52278
52288
  __publicField(this, "editMathjaxPopup", null);
52279
52289
  __publicField(this, "onChange", null);
52280
52290
  __publicField(this, "tex", "");
52291
+ __publicField(this, "oldTex", "");
52281
52292
  __publicField(this, "observer", null);
52282
52293
  __publicField(this, "handleClose", (commandBar2) => {
52283
52294
  var _a;
@@ -52301,6 +52312,10 @@ ${codeText}
52301
52312
  });
52302
52313
  __publicField(this, "handleChange", debounce__default.default((text2) => {
52303
52314
  var _a;
52315
+ if (text2 === this.oldTex) {
52316
+ return;
52317
+ }
52318
+ this.oldTex = text2;
52304
52319
  (_a = this.onChange) == null ? void 0 : _a.call(this, text2, false);
52305
52320
  }, 300));
52306
52321
  }
@@ -52313,6 +52328,7 @@ ${codeText}
52313
52328
  const textarea2 = this.getTextarea();
52314
52329
  textarea2.value = tex;
52315
52330
  }
52331
+ this.oldTex = tex;
52316
52332
  this.tex = tex;
52317
52333
  this.editMathjaxPopup.manualShow(elem, { theme: "light", placement: options == null ? void 0 : options.placement });
52318
52334
  this.editMathjaxPopup.removeAllListeners("close");
@@ -52608,7 +52624,7 @@ ${codeText}
52608
52624
  }
52609
52625
  const data2 = editor.getBlockData(block);
52610
52626
  const embedData = data2.embedData;
52611
- editMathjax(editor, elem, embedData.mathjaxText, async (tex) => {
52627
+ editMathjax(editor, block, embedData.mathjaxText, async (tex) => {
52612
52628
  const { resourceId: src, width, height } = await convertAndUploadMathjaxForEmbed(editor, tex);
52613
52629
  const newData = {
52614
52630
  mathjaxText: tex,
@@ -60866,7 +60882,6 @@ $$${mathData.mathjaxText}$$
60866
60882
  editor.selection.setSelection(anchor2, void 0, { noScroll: direction === "next" });
60867
60883
  }
60868
60884
  }
60869
- editor.focus();
60870
60885
  if (direction === "next") {
60871
60886
  const targetElementRect = targetElement.getBoundingClientRect();
60872
60887
  const clientHeight = editor.scrollContainer.clientHeight;
@@ -62904,6 +62919,7 @@ $$${mathData.mathjaxText}$$
62904
62919
  dropdown2.setSelectedId(codeData.language);
62905
62920
  selectCodeBlock(editor2, block, { focusToEditor: false });
62906
62921
  setTimeout(() => {
62922
+ CommandBar.hideAll();
62907
62923
  dropdown2.show(select2);
62908
62924
  });
62909
62925
  addClass(codeBlock2, "editing-language");
@@ -88068,20 +88084,30 @@ ${data2.flowchartText}
88068
88084
  return docx.Packer.toBlob(doc2);
88069
88085
  }
88070
88086
  }
88087
+ class ExportImageError extends Error {
88088
+ constructor(message) {
88089
+ super(message);
88090
+ this.name = this.constructor.name;
88091
+ }
88092
+ }
88071
88093
  const logger$1 = getLogger("editor-to-docx");
88072
88094
  async function readImage(editor, _appId, _docId, _src) {
88073
- const url = editor.doc.buildResourceUrl(_src, { withToken: true });
88074
- let file2 = await downloadImageToFile$1(url);
88075
- if (!file2)
88076
- return [void 0, url];
88077
- if (file2.type.indexOf("/svg") !== -1) {
88078
- const pngFile = await convertImageFileToPng(file2);
88079
- if (pngFile) {
88080
- file2 = new File([pngFile], file2.name);
88081
- }
88095
+ try {
88096
+ const url = editor.doc.buildResourceUrl(_src, { withToken: true });
88097
+ let file2 = await downloadImageToFile$1(url);
88098
+ if (!file2)
88099
+ return [void 0, url];
88100
+ if (file2.type.indexOf("/svg") !== -1) {
88101
+ const pngFile = await convertImageFileToPng(file2);
88102
+ if (pngFile) {
88103
+ file2 = new File([pngFile], file2.name);
88104
+ }
88105
+ }
88106
+ const arrayBuffer = await file2.arrayBuffer();
88107
+ return [arrayBuffer, url];
88108
+ } catch (error2) {
88109
+ throw new ExportImageError(error2.message || "read image error");
88082
88110
  }
88083
- const arrayBuffer = await file2.arrayBuffer();
88084
- return [arrayBuffer, url];
88085
88111
  }
88086
88112
  async function getDocByBlock(editor, doc2, block) {
88087
88113
  const blockClass = editor.editorBlocks.getBlockClass(block.type);
@@ -88315,7 +88341,7 @@ ${data2.flowchartText}
88315
88341
  }
88316
88342
  }
88317
88343
  });
88318
- editor.version = "2.2.9";
88344
+ editor.version = "2.2.10-beta.2";
88319
88345
  if (Logger$2.level === LogLevel.DEBUG) {
88320
88346
  window.setReauthFail = (fail) => {
88321
88347
  window.isReauthError = fail;
@@ -88416,7 +88442,7 @@ ${data2.flowchartText}
88416
88442
  });
88417
88443
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
88418
88444
  OnesEditorToolbar.register(editor);
88419
- editor.version = "2.2.9";
88445
+ editor.version = "2.2.10-beta.2";
88420
88446
  return editor;
88421
88447
  }
88422
88448
  async function showDocVersions(editor, options, serverUrl) {
@@ -134195,6 +134221,7 @@ ${data2.flowchartText}
134195
134221
  exports2.EmbedBlockResizer = EmbedBlockResizer;
134196
134222
  exports2.EnforceWithDocumentTitleHandler = EnforceWithDocumentTitleHandler;
134197
134223
  exports2.EventCallbacks = EventCallbacks;
134224
+ exports2.ExportImageError = ExportImageError;
134198
134225
  exports2.FILL_CHAR = FILL_CHAR;
134199
134226
  exports2.FileExtError = FileExtError;
134200
134227
  exports2.FixedToolbar = FixedToolbar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.2.9",
3
+ "version": "2.2.10-beta.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -31,6 +31,7 @@
31
31
  "lodash.findlastindex": "^4.6.0",
32
32
  "lodash.intersection": "^4.4.0",
33
33
  "lodash.isequal": "^4.5.0",
34
+ "lodash.memoize": "^4.1.2",
34
35
  "lodash.merge": "^4.6.2",
35
36
  "lodash.pick": "^4.4.0",
36
37
  "lodash.throttle": "^4.1.1",