@ones-editor/editor 3.1.2-beta.ONES22301271.1 → 3.1.2-beta.h1432.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
@@ -27250,9 +27250,16 @@ var __publicField = (obj, key, value) => {
27250
27250
  const logger$3I = getLogger("delete-block");
27251
27251
  function getAllChildContainers(editor, blockData, containerIds) {
27252
27252
  if (blockData.children) {
27253
- containerIds.push(...blockData.children);
27254
27253
  blockData.children.forEach((childContainerId) => {
27255
- const childBlocks = editor.getChildContainerData(childContainerId);
27254
+ if (containerIds.has(childContainerId)) {
27255
+ return;
27256
+ }
27257
+ const childBlocks = editor.doc.findContainerBlocks(childContainerId);
27258
+ if (!Array.isArray(childBlocks)) {
27259
+ logger$3I.warn(`skip invalid child container while deleting: parentBlock=${blockData.id}, container=${childContainerId}`);
27260
+ return;
27261
+ }
27262
+ containerIds.add(childContainerId);
27256
27263
  childBlocks.forEach((childBlock) => {
27257
27264
  getAllChildContainers(editor, childBlock, containerIds);
27258
27265
  });
@@ -27284,31 +27291,31 @@ var __publicField = (obj, key, value) => {
27284
27291
  }
27285
27292
  }
27286
27293
  const blockData = editorDeleteBlockWithoutChildren(editor, block, newRange);
27287
- const childContainerIds = [];
27294
+ const childContainerIds = /* @__PURE__ */ new Set();
27288
27295
  getAllChildContainers(editor, blockData, childContainerIds);
27289
- if (childContainerIds.length > 0) {
27290
- editor.doc.localDeleteChildContainers(childContainerIds);
27296
+ if (childContainerIds.size > 0) {
27297
+ editor.doc.localDeleteChildContainers(Array.from(childContainerIds));
27291
27298
  }
27292
27299
  return blockData;
27293
27300
  });
27294
27301
  }
27295
27302
  function editorDeleteChildContainer(editor, containerId) {
27296
- const containerIds = [containerId];
27303
+ const containerIds = /* @__PURE__ */ new Set([containerId]);
27297
27304
  const childBlocks = editor.doc.getContainerBlocks(containerId);
27298
27305
  childBlocks.forEach((childBlock) => {
27299
27306
  getAllChildContainers(editor, childBlock, containerIds);
27300
27307
  });
27301
- editor.doc.localDeleteChildContainers(containerIds);
27308
+ editor.doc.localDeleteChildContainers(Array.from(containerIds));
27302
27309
  }
27303
27310
  function editorDeleteChildContainers(editor, childContainerIds) {
27304
- const containerIds = [...childContainerIds];
27311
+ const containerIds = new Set(childContainerIds);
27305
27312
  childContainerIds.forEach((containerId) => {
27306
27313
  const childBlocks = editor.doc.getContainerBlocks(containerId);
27307
27314
  childBlocks.forEach((childBlock) => {
27308
27315
  getAllChildContainers(editor, childBlock, containerIds);
27309
27316
  });
27310
27317
  });
27311
- editor.doc.localDeleteChildContainers(containerIds);
27318
+ editor.doc.localDeleteChildContainers(Array.from(containerIds));
27312
27319
  }
27313
27320
  const logger$3H = getLogger("merge-text-block");
27314
27321
  function editorMergeTextBlock(editor, block1, block2) {
@@ -97093,7 +97100,7 @@ ${JSON.stringify(error2, null, 2)}`);
97093
97100
  }
97094
97101
  }
97095
97102
  });
97096
- editor.version = "3.1.2-beta.ONES22301271.1";
97103
+ editor.version = "3.1.2-beta.h1432.1";
97097
97104
  return editor;
97098
97105
  }
97099
97106
  function isDoc(doc2) {
@@ -97112,31 +97119,36 @@ ${JSON.stringify(error2, null, 2)}`);
97112
97119
  const enableComments = options == null ? void 0 : options.enableComments;
97113
97120
  const quickMenu = (_c = (_b = options.componentsOptions) == null ? void 0 : _b.quickMenu) != null ? _c : { id: "quick-menu", trigger: ["/"], commandProviders: [] };
97114
97121
  (_d = quickMenu.commandProviders) == null ? void 0 : _d.push(new GraphCommandProvider());
97115
- const editor = createEditor(root2, doc2, {
97116
- id: options.id,
97117
- readonly: options.readonly,
97118
- scrollContainer: options == null ? void 0 : options.scrollContainer,
97119
- enableResolveComments: options == null ? void 0 : options.enableResolveComments,
97120
- enableComments,
97121
- dateTimeFormatter: options.dateTimeFormatter,
97122
- components: {
97123
- blocks: [...StandardBlocks, ...(_f = (_e = options.components) == null ? void 0 : _e.blocks) != null ? _f : []],
97124
- commandProviders: [new TableBlockCommandProvider()],
97125
- decorators: [new CodeTextDecorator(), new RemoteCaretsDecorator()],
97126
- embeds: [...StandardEmbeds, ...((_g = options.components) == null ? void 0 : _g.embeds) || []],
97127
- boxes: [MathjaxBox, MentionBox, FileBox, StatusBox, ...((_h = options.components) == null ? void 0 : _h.boxes) || []],
97128
- insertions: [RemoteCaretsInsertion],
97129
- blockHooks: [...((_i = options.components) == null ? void 0 : _i.blockHooks) || []],
97130
- textRenders: [
97131
- enableComments && new OnesEditorCommentsRender(),
97132
- new BlockPaddingRender(),
97133
- ...((_j = options.components) == null ? void 0 : _j.textRenders) || []
97134
- ].filter(Boolean),
97135
- options: { ...options.componentsOptions, quickMenu }
97136
- },
97137
- shortcuts: [TableShortcuts, FindReplaceShortcuts, TextStyleShortcuts, DefaultShortcuts]
97138
- });
97122
+ let editorForCleanup;
97139
97123
  try {
97124
+ const editor = createEditor(root2, doc2, {
97125
+ id: options.id,
97126
+ readonly: options.readonly,
97127
+ scrollContainer: options == null ? void 0 : options.scrollContainer,
97128
+ enableResolveComments: options == null ? void 0 : options.enableResolveComments,
97129
+ enableComments,
97130
+ dateTimeFormatter: options.dateTimeFormatter,
97131
+ components: {
97132
+ blocks: [...StandardBlocks, ...(_f = (_e = options.components) == null ? void 0 : _e.blocks) != null ? _f : []],
97133
+ commandProviders: [new TableBlockCommandProvider()],
97134
+ decorators: [new CodeTextDecorator(), new RemoteCaretsDecorator()],
97135
+ embeds: [...StandardEmbeds, ...((_g = options.components) == null ? void 0 : _g.embeds) || []],
97136
+ boxes: [MathjaxBox, MentionBox, FileBox, StatusBox, ...((_h = options.components) == null ? void 0 : _h.boxes) || []],
97137
+ insertions: [RemoteCaretsInsertion],
97138
+ blockHooks: [...((_i = options.components) == null ? void 0 : _i.blockHooks) || []],
97139
+ textRenders: [
97140
+ enableComments && new OnesEditorCommentsRender(),
97141
+ new BlockPaddingRender(),
97142
+ ...((_j = options.components) == null ? void 0 : _j.textRenders) || []
97143
+ ].filter(Boolean),
97144
+ options: { ...options.componentsOptions, quickMenu }
97145
+ },
97146
+ shortcuts: [TableShortcuts, FindReplaceShortcuts, TextStyleShortcuts, DefaultShortcuts]
97147
+ });
97148
+ editorForCleanup = editor;
97149
+ if (options.readonly) {
97150
+ editor.readonly = true;
97151
+ }
97140
97152
  if (options.compact) {
97141
97153
  addClass(editor.rootElement, "compact");
97142
97154
  if (options.headingButton === false)
@@ -97229,14 +97241,19 @@ ${JSON.stringify(error2, null, 2)}`);
97229
97241
  OnesEditorDropTarget.register(editor);
97230
97242
  OnesEditorTocProvider.register(editor);
97231
97243
  OnesEditorExclusiveBlock.register(editor);
97232
- editor.version = "3.1.2-beta.ONES22301271.1";
97244
+ editor.version = "3.1.2-beta.h1432.1";
97233
97245
  return editor;
97234
97246
  } catch (error2) {
97235
- try {
97236
- editor.destroy();
97237
- } catch (destroyError) {
97238
- logger.error(`failed to rollback local editor: ${destroyError.message}`);
97247
+ if (editorForCleanup) {
97248
+ try {
97249
+ editorForCleanup.destroy();
97250
+ } catch (destroyError) {
97251
+ logger.error(destroyError);
97252
+ }
97253
+ } else {
97254
+ doc2.destroy();
97239
97255
  }
97256
+ root2.replaceChildren();
97240
97257
  throw error2;
97241
97258
  }
97242
97259
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.1.2-beta.ONES22301271.1",
3
+ "version": "3.1.2-beta.h1432.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {