@ones-editor/editor 2.2.14-beta.10 → 2.2.14-beta.11

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
@@ -81404,6 +81404,12 @@ ${content}
81404
81404
  textarea2.style.height = `${textarea2.scrollHeight}px`;
81405
81405
  });
81406
81406
  };
81407
+ const getCodeEditor = (block) => {
81408
+ const textarea2 = block.querySelector(".embed-code-editor-textarea");
81409
+ assert(logger$m, textarea2, "Can not find textarea in block");
81410
+ assert(logger$m, textarea2 instanceof HTMLTextAreaElement, "Textarea is not HTMLTextAreaElement");
81411
+ return textarea2;
81412
+ };
81407
81413
  const logger$l = getLogger("graph-dom/view-select");
81408
81414
  var ViewId = /* @__PURE__ */ ((ViewId2) => {
81409
81415
  ViewId2["Both"] = "both";
@@ -81552,6 +81558,32 @@ ${content}
81552
81558
  return exclusiveBlock2;
81553
81559
  }
81554
81560
  }
81561
+ const enhanceAsync = (asyncFunction) => {
81562
+ const proCache = [];
81563
+ const clearCache = (pro) => {
81564
+ const index2 = proCache.findIndex((p) => p === pro);
81565
+ proCache.splice(index2, 1);
81566
+ };
81567
+ return async function(...args) {
81568
+ const promiseHelper = {
81569
+ isEarlyExecute: () => false
81570
+ };
81571
+ const pro = asyncFunction.apply(this, [promiseHelper, ...args]);
81572
+ proCache.push(pro);
81573
+ promiseHelper.isEarlyExecute = () => {
81574
+ const index2 = proCache.findIndex((p) => p === pro);
81575
+ return index2 > 0;
81576
+ };
81577
+ try {
81578
+ const ret = await pro;
81579
+ clearCache(pro);
81580
+ return ret;
81581
+ } catch (error2) {
81582
+ clearCache(pro);
81583
+ throw error2;
81584
+ }
81585
+ };
81586
+ };
81555
81587
  const logger$k = getLogger("graph-embed-base");
81556
81588
  class GraphBase {
81557
81589
  constructor(editor) {
@@ -81656,7 +81688,7 @@ ${content}
81656
81688
  break;
81657
81689
  }
81658
81690
  });
81659
- __publicField(this, "updateDraw", async (src, code) => {
81691
+ __publicField(this, "updateDraw", enhanceAsync(async (promiseHelper, src, code) => {
81660
81692
  var _a, _b, _c, _d;
81661
81693
  if (!src && !code) {
81662
81694
  (_a = this.drawHandler) == null ? void 0 : _a.createEmptyContent();
@@ -81665,8 +81697,14 @@ ${content}
81665
81697
  if (!src) {
81666
81698
  try {
81667
81699
  const imgSrc2 = await this.code2ObjectUrl(code);
81700
+ if (promiseHelper.isEarlyExecute()) {
81701
+ return;
81702
+ }
81668
81703
  (_b = this.drawHandler) == null ? void 0 : _b.updateDraw(imgSrc2);
81669
81704
  } catch (err) {
81705
+ if (promiseHelper.isEarlyExecute()) {
81706
+ return;
81707
+ }
81670
81708
  (_c = this.drawHandler) == null ? void 0 : _c.createErrorContent();
81671
81709
  }
81672
81710
  return;
@@ -81686,7 +81724,7 @@ ${content}
81686
81724
  }
81687
81725
  });
81688
81726
  (_d = this.drawHandler) == null ? void 0 : _d.updateDraw(imgSrc);
81689
- });
81727
+ }));
81690
81728
  this.editor = editor;
81691
81729
  this.editor.addListener("readonlyChanged", this.handleReadonlyChanged);
81692
81730
  GraphExclusiveHandler.get(editor).addListener("onExclusiveBlock", this.handleExclusiveBlock);
@@ -81728,8 +81766,8 @@ ${content}
81728
81766
  this.viewSelect.setSelectedView(realView);
81729
81767
  this.updateLayout(realView, flex);
81730
81768
  this.updateHeight(content, height);
81769
+ this.updateDraw(src, code);
81731
81770
  setTimeout(() => {
81732
- this.updateDraw(src, code);
81733
81771
  if (clientType.isMobile) {
81734
81772
  return;
81735
81773
  }
@@ -81749,6 +81787,10 @@ ${content}
81749
81787
  if (((_a = this.viewSelect) == null ? void 0 : _a.selectedView) !== realView) {
81750
81788
  (_b = this.viewSelect) == null ? void 0 : _b.setSelectedView(realView);
81751
81789
  }
81790
+ if (realView !== ViewId.Draw) {
81791
+ const textarea2 = getCodeEditor(blockElement);
81792
+ textarea2.value = code;
81793
+ }
81752
81794
  this.updateLayout(realView, flex);
81753
81795
  this.updateDraw(src, code);
81754
81796
  this.updateHeight(content, height);
@@ -88912,7 +88954,7 @@ ${data2.plantumlText}
88912
88954
  }
88913
88955
  }
88914
88956
  });
88915
- editor.version = "2.2.14-beta.10";
88957
+ editor.version = "2.2.14-beta.11";
88916
88958
  return editor;
88917
88959
  }
88918
88960
  function isDoc(doc2) {
@@ -89013,7 +89055,7 @@ ${data2.plantumlText}
89013
89055
  });
89014
89056
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
89015
89057
  OnesEditorToolbar.register(editor);
89016
- editor.version = "2.2.14-beta.10";
89058
+ editor.version = "2.2.14-beta.11";
89017
89059
  return editor;
89018
89060
  }
89019
89061
  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.2.14-beta.10",
3
+ "version": "2.2.14-beta.11",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {