@ones-editor/editor 4.0.5 → 4.0.6-beta.ONES22303077.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
@@ -29895,7 +29895,7 @@ var __publicField = (obj, key, value) => {
29895
29895
  });
29896
29896
  return true;
29897
29897
  }
29898
- function defaultGetResourceFromBlock(editor, doc2, block, resources) {
29898
+ function defaultGetResourceFromBlock(editor, block, resources) {
29899
29899
  if (block.type === "embed") {
29900
29900
  const embedData = block.embedData;
29901
29901
  const src = embedData.src;
@@ -29932,43 +29932,23 @@ var __publicField = (obj, key, value) => {
29932
29932
  }
29933
29933
  });
29934
29934
  }
29935
- const children = block.children;
29936
- if (children) {
29937
- children.forEach((childContainerId) => {
29938
- const blocks = doc2.blocks[childContainerId];
29939
- blocks.forEach((b) => {
29940
- defaultGetResourceFromBlock(editor, doc2, b, resources);
29941
- });
29942
- });
29935
+ }
29936
+ function getResourcesFromBlock(editor, doc2, block, resources) {
29937
+ var _a, _b;
29938
+ const blockClass = editor.editorBlocks.getBlockClass(block.type);
29939
+ const declaredResources = (_a = blockClass.getResources) == null ? void 0 : _a.call(blockClass, editor, block);
29940
+ if (declaredResources) {
29941
+ declaredResources.forEach((resource) => resources.add(resource));
29942
+ } else {
29943
+ defaultGetResourceFromBlock(editor, block, resources);
29943
29944
  }
29945
+ (_b = block.children) == null ? void 0 : _b.forEach((containerId) => {
29946
+ doc2.blocks[containerId].forEach((child) => getResourcesFromBlock(editor, doc2, child, resources));
29947
+ });
29944
29948
  }
29945
29949
  function getAllResourcesFromDoc(editor, doc2) {
29946
29950
  const resources = /* @__PURE__ */ new Set();
29947
- const blocks = doc2.blocks.root;
29948
- blocks.forEach((block) => {
29949
- const blockClass = editor.editorBlocks.getBlockClass(block.type);
29950
- if (blockClass.getResources) {
29951
- const ret = blockClass.getResources(editor, block);
29952
- if (ret) {
29953
- ret.forEach((resource) => {
29954
- resources.add(resource);
29955
- });
29956
- const children = block.children;
29957
- if (children) {
29958
- children.forEach((childContainerId) => {
29959
- const blocks2 = doc2.blocks[childContainerId];
29960
- blocks2.forEach((b) => {
29961
- defaultGetResourceFromBlock(editor, doc2, b, resources);
29962
- });
29963
- });
29964
- }
29965
- } else {
29966
- defaultGetResourceFromBlock(editor, doc2, block, resources);
29967
- }
29968
- } else {
29969
- defaultGetResourceFromBlock(editor, doc2, block, resources);
29970
- }
29971
- });
29951
+ doc2.blocks.root.forEach((block) => getResourcesFromBlock(editor, doc2, block, resources));
29972
29952
  return Array.from(resources);
29973
29953
  }
29974
29954
  function injectDocToHtmlFragment(htmlFragment, doc2) {
@@ -30281,8 +30261,14 @@ ${codeText}
30281
30261
  }
30282
30262
  return true;
30283
30263
  }
30284
- function defaultReplaceBlockResources(doc2, block, resources) {
30264
+ function defaultReplaceBlockResources(editor, doc2, block, resources) {
30265
+ var _a;
30285
30266
  if (block.type === "embed") {
30267
+ const blockClass = editor.editorBlocks.getBlockClass(block.type);
30268
+ const declaredResources = (_a = blockClass.getResources) == null ? void 0 : _a.call(blockClass, editor, block);
30269
+ if (declaredResources && declaredResources.length === 0) {
30270
+ return;
30271
+ }
30286
30272
  const embedData = block.embedData;
30287
30273
  const src = embedData.src;
30288
30274
  if (src && typeof src === "string") {
@@ -30323,23 +30309,26 @@ ${codeText}
30323
30309
  children.forEach((childContainerId) => {
30324
30310
  const blocks = doc2.blocks[childContainerId];
30325
30311
  blocks.forEach((b) => {
30326
- defaultReplaceBlockResources(doc2, b, resources);
30312
+ replaceBlockResources(editor, doc2, b, resources);
30327
30313
  });
30328
30314
  });
30329
30315
  }
30330
30316
  }
30317
+ function replaceBlockResources(editor, doc2, block, resources) {
30318
+ const blockClass = editor.editorBlocks.getBlockClass(block.type);
30319
+ if (blockClass.replaceResources) {
30320
+ blockClass.replaceResources(block, resources);
30321
+ } else {
30322
+ defaultReplaceBlockResources(editor, doc2, block, resources);
30323
+ }
30324
+ }
30331
30325
  function replaceDocResources(editor, doc2, resources) {
30332
30326
  if (resources.size === 0) {
30333
30327
  return;
30334
30328
  }
30335
30329
  const blocks = doc2.blocks.root;
30336
30330
  blocks.forEach((block) => {
30337
- const blockClass = editor.editorBlocks.getBlockClass(block.type);
30338
- if (blockClass.replaceResources) {
30339
- blockClass.replaceResources(block, resources);
30340
- } else {
30341
- defaultReplaceBlockResources(doc2, block, resources);
30342
- }
30331
+ replaceBlockResources(editor, doc2, block, resources);
30343
30332
  });
30344
30333
  }
30345
30334
  async function addLocalResourcesToDoc(editor, resources) {
@@ -97543,7 +97532,7 @@ ${JSON.stringify(error2, null, 2)}`);
97543
97532
  }
97544
97533
  }
97545
97534
  });
97546
- editor.version = "4.0.5";
97535
+ editor.version = "4.0.6-beta.ONES22303077.1";
97547
97536
  return editor;
97548
97537
  }
97549
97538
  function isDoc(doc2) {
@@ -97679,7 +97668,7 @@ ${JSON.stringify(error2, null, 2)}`);
97679
97668
  OnesEditorDropTarget.register(editor);
97680
97669
  OnesEditorTocProvider.register(editor);
97681
97670
  OnesEditorExclusiveBlock.register(editor);
97682
- editor.version = "4.0.5";
97671
+ editor.version = "4.0.6-beta.ONES22303077.1";
97683
97672
  return editor;
97684
97673
  } catch (error2) {
97685
97674
  try {
@@ -97822,7 +97811,7 @@ ${JSON.stringify(error2, null, 2)}`);
97822
97811
  }
97823
97812
  }
97824
97813
  });
97825
- editor.version = "4.0.5";
97814
+ editor.version = "4.0.6-beta.ONES22303077.1";
97826
97815
  return editor;
97827
97816
  }
97828
97817
  const emojis$1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "4.0.5",
3
+ "version": "4.0.6-beta.ONES22303077.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {