@ones-editor/editor 2.8.19 → 2.8.21

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.
@@ -1 +1,2 @@
1
1
  export * from './break-text-block';
2
+ export * from './update-graph-block';
@@ -0,0 +1,2 @@
1
+ import { CloneBlockResultInfo, OnesEditor } from '../../@ones-editor/core';
2
+ export declare function updateGraphBlockSrc(editor: OnesEditor, cloneDocResult: CloneBlockResultInfo): void;
package/dist/index.js CHANGED
@@ -53442,6 +53442,11 @@ ${codeText}
53442
53442
  linkElement.href = getLinkHref(child);
53443
53443
  linkElement.target = "_blank";
53444
53444
  linkElement.rel = "noopener noreferrer";
53445
+ linkElement.onclick = (event) => {
53446
+ event.preventDefault();
53447
+ event.stopPropagation();
53448
+ editor.emit("clickLink", editor, event, linkElement);
53449
+ };
53445
53450
  commands = [{
53446
53451
  id: "link-text",
53447
53452
  name: getLinkHref(child),
@@ -84461,6 +84466,24 @@ ${docStr}
84461
84466
  EmbedBlockResizer.register(this.editor, blockElement, { maxHeight: GRAPH_MAX_HEIGHT, minHeight: GRAPH_MIN_HEIGHT });
84462
84467
  });
84463
84468
  }
84469
+ async updateImageSrc(options) {
84470
+ const blockData = this.editor.getBlockData(this.block);
84471
+ const { src, code } = this.getGraphData(blockData);
84472
+ if (!src && !code) {
84473
+ return;
84474
+ }
84475
+ if (src && !(options == null ? void 0 : options.force)) {
84476
+ return;
84477
+ }
84478
+ const codeValue = code;
84479
+ try {
84480
+ const resourceId = await this.code2ResourceId(codeValue);
84481
+ const newData = this.createGraphEmbedData(this.block, { code: codeValue, src: resourceId });
84482
+ this.editor.updateEmbedData(this.block, newData);
84483
+ } catch (err) {
84484
+ logger$l.error(err);
84485
+ }
84486
+ }
84464
84487
  async updateEmbedContent(content, block) {
84465
84488
  var _a, _b;
84466
84489
  const { code, src, view, flex = DEFAULT_FLEX, height } = this.getGraphData(block);
@@ -92817,6 +92840,27 @@ ${data2.plantumlText}
92817
92840
  }
92818
92841
  return editorBreakTextBlock(editor, block, offset, options);
92819
92842
  }
92843
+ function updateGraphBlockSrc(editor, cloneDocResult) {
92844
+ const blockIds = cloneDocResult.blockIdMap.values();
92845
+ Array.from(blockIds).forEach((blockId) => {
92846
+ const block = editor.findBlockById(blockId);
92847
+ if (block && isEmbedBlock(block)) {
92848
+ const blockData = editor.getBlockData(block);
92849
+ const embedType = blockData.embedType;
92850
+ const embedData = blockData.embedData;
92851
+ if (embedData.src) {
92852
+ return;
92853
+ }
92854
+ const types2 = ["mermaid", "flowchart", "plantuml"];
92855
+ if (types2.includes(embedType)) {
92856
+ const instance = editor.findCustom(`${embedType}_${blockId}`);
92857
+ if (instance) {
92858
+ instance.updateImageSrc();
92859
+ }
92860
+ }
92861
+ }
92862
+ });
92863
+ }
92820
92864
  const logger = getLogger("create-editor");
92821
92865
  function getDefaultOnesEditorOptions(options) {
92822
92866
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -93064,7 +93108,7 @@ ${data2.plantumlText}
93064
93108
  }
93065
93109
  }
93066
93110
  });
93067
- editor.version = "2.8.19";
93111
+ editor.version = "2.8.21";
93068
93112
  return editor;
93069
93113
  }
93070
93114
  function isDoc(doc2) {
@@ -93177,7 +93221,7 @@ ${data2.plantumlText}
93177
93221
  }
93178
93222
  });
93179
93223
  OnesEditorToolbar.register(editor);
93180
- editor.version = "2.8.19";
93224
+ editor.version = "2.8.21";
93181
93225
  return editor;
93182
93226
  }
93183
93227
  async function showDocVersions(editor, options, serverUrl) {
@@ -139759,6 +139803,7 @@ ${data2.plantumlText}
139759
139803
  exports2.unicodeLength = unicodeLength;
139760
139804
  exports2.unicodeSubstr = unicodeSubstr;
139761
139805
  exports2.updateBlockSelection = updateBlockSelection;
139806
+ exports2.updateGraphBlockSrc = updateGraphBlockSrc;
139762
139807
  exports2.updateOpAttributes = updateOpAttributes;
139763
139808
  exports2.updateTextBlockContent = updateTextBlockContent;
139764
139809
  exports2.updateUrl = updateUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.8.19",
3
+ "version": "2.8.21",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {