@ones-editor/editor 3.1.2-beta.2 → 3.1.2-beta.ONES22301271.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
@@ -32135,7 +32135,7 @@ ${codeText}
32135
32135
  const logger$3a = getLogger("editor");
32136
32136
  class Editor extends tinyTypedEmitter.TypedEmitter {
32137
32137
  constructor(parent, doc2, optionalOptions) {
32138
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
32138
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
32139
32139
  super();
32140
32140
  __publicField(this, "parent");
32141
32141
  __publicField(this, "rootElement");
@@ -32180,22 +32180,27 @@ ${codeText}
32180
32180
  this.setMaxListeners(100);
32181
32181
  this.options = {
32182
32182
  colors: (_a = optionalOptions == null ? void 0 : optionalOptions.colors) != null ? _a : ["#B21B57", "#008796", "#7241CC", "#CC4C08", "#5D8F00", "#BD2C1C", "#D17D00"],
32183
- componentsOptions: (_c = (_b = optionalOptions == null ? void 0 : optionalOptions.components) == null ? void 0 : _b.options) != null ? _c : {},
32183
+ readonly: (_b = optionalOptions == null ? void 0 : optionalOptions.readonly) != null ? _b : false,
32184
+ componentsOptions: (_d = (_c = optionalOptions == null ? void 0 : optionalOptions.components) == null ? void 0 : _c.options) != null ? _d : {},
32184
32185
  scrollContainer: optionalOptions == null ? void 0 : optionalOptions.scrollContainer,
32185
- enableComments: (_d = optionalOptions == null ? void 0 : optionalOptions.enableComments) != null ? _d : true,
32186
- enableResolveComments: (_e = optionalOptions == null ? void 0 : optionalOptions.enableResolveComments) != null ? _e : true,
32187
- enableContextMenu: (_f = optionalOptions == null ? void 0 : optionalOptions.enableContextMenu) != null ? _f : true,
32188
- dateTimeFormatter: (_g = optionalOptions == null ? void 0 : optionalOptions.dateTimeFormatter) != null ? _g : (v) => v.toLocaleString()
32186
+ enableComments: (_e = optionalOptions == null ? void 0 : optionalOptions.enableComments) != null ? _e : true,
32187
+ enableResolveComments: (_f = optionalOptions == null ? void 0 : optionalOptions.enableResolveComments) != null ? _f : true,
32188
+ enableContextMenu: (_g = optionalOptions == null ? void 0 : optionalOptions.enableContextMenu) != null ? _g : true,
32189
+ dateTimeFormatter: (_h = optionalOptions == null ? void 0 : optionalOptions.dateTimeFormatter) != null ? _h : (v) => v.toLocaleString()
32189
32190
  };
32190
- this.settingsProvider = (_h = optionalOptions == null ? void 0 : optionalOptions.settingsProvider) != null ? _h : new DefaultSettingsProvider(this);
32191
+ this._readonly = this.options.readonly;
32192
+ this.settingsProvider = (_i = optionalOptions == null ? void 0 : optionalOptions.settingsProvider) != null ? _i : new DefaultSettingsProvider(this);
32191
32193
  registerComponents(this, optionalOptions == null ? void 0 : optionalOptions.components);
32192
- this.blockHooks.push(...(_j = (_i = optionalOptions == null ? void 0 : optionalOptions.components) == null ? void 0 : _i.blockHooks) != null ? _j : []);
32193
- this.id = (_k = optionalOptions == null ? void 0 : optionalOptions.id) != null ? _k : genId();
32194
+ this.blockHooks.push(...(_k = (_j = optionalOptions == null ? void 0 : optionalOptions.components) == null ? void 0 : _j.blockHooks) != null ? _k : []);
32195
+ this.id = (_l = optionalOptions == null ? void 0 : optionalOptions.id) != null ? _l : genId();
32194
32196
  this.clientId = genId();
32195
32197
  this.undoManager = new UndoManager(this);
32196
32198
  this.doc = new EditorDoc(this, doc2, this.undoManager);
32197
32199
  this.parent = parent;
32198
32200
  this.rootElement = createElement("div", ["editor-root"], this.parent);
32201
+ if (this._readonly) {
32202
+ addClass(this.rootElement, "readonly");
32203
+ }
32199
32204
  this.rootElement.setAttribute("data-editor-client-id", this.clientId);
32200
32205
  this.contentElement = createElement("div", ["editor-content"], this.rootElement);
32201
32206
  this.rootContainerObject = createRootContainer(this);
@@ -32213,7 +32218,7 @@ ${codeText}
32213
32218
  addClass(this.rootElement, "safari");
32214
32219
  }
32215
32220
  if (this._readonly) {
32216
- addClass(this.rootElement, "readonly");
32221
+ this.readonly = true;
32217
32222
  }
32218
32223
  this.emit("load", this, false);
32219
32224
  }
@@ -64281,7 +64286,7 @@ $$${mathData.mathjaxText}$$
64281
64286
  return attributes.filter((attribute) => attribute.startsWith("comment-")).map((attribute) => attribute.replace("comment-", ""));
64282
64287
  }
64283
64288
  const logger$1I = getLogger("doc-comments");
64284
- function addBlockComments$1(doc2, block, result, resultSet) {
64289
+ function addBlockComments$1(doc2, block, result, resultSet, invalidContainers) {
64285
64290
  if (block.comments) {
64286
64291
  const blockComments = block.comments;
64287
64292
  if (Array.isArray(blockComments)) {
@@ -64317,19 +64322,23 @@ $$${mathData.mathjaxText}$$
64317
64322
  children.forEach((childContainerId) => {
64318
64323
  const childBlocks = doc2.blocks[childContainerId];
64319
64324
  if (!Array.isArray(childBlocks)) {
64320
- logger$1I.error(`skip invalid comment child container: parent=${block.id}, container=${childContainerId}`);
64325
+ if (!invalidContainers.has(childContainerId)) {
64326
+ invalidContainers.add(childContainerId);
64327
+ logger$1I.warn(`skip invalid comment child container: parentBlock=${block.id}, container=${childContainerId}`);
64328
+ }
64321
64329
  return;
64322
64330
  }
64323
64331
  childBlocks.forEach((subBlock) => {
64324
- addBlockComments$1(doc2, subBlock, result, resultSet);
64332
+ addBlockComments$1(doc2, subBlock, result, resultSet, invalidContainers);
64325
64333
  });
64326
64334
  });
64327
64335
  }
64328
64336
  function getCommentsFromDoc(doc2) {
64329
64337
  const result = [];
64330
64338
  const resultSet = /* @__PURE__ */ new Set();
64339
+ const invalidContainers = /* @__PURE__ */ new Set();
64331
64340
  doc2.blocks.root.forEach((block) => {
64332
- addBlockComments$1(doc2, block, result, resultSet);
64341
+ addBlockComments$1(doc2, block, result, resultSet, invalidContainers);
64333
64342
  });
64334
64343
  const resultMap = /* @__PURE__ */ new Map();
64335
64344
  result.forEach((commentId, index2) => resultMap.set(commentId, index2));
@@ -71511,7 +71520,7 @@ ${codeText}
71511
71520
  }
71512
71521
  }
71513
71522
  const logger$1f = getLogger("block-comments");
71514
- function addBlockComments(doc2, block, resultMap) {
71523
+ function addBlockComments(doc2, block, resultMap, invalidContainers) {
71515
71524
  if (block.comments) {
71516
71525
  const blockComments = block.comments;
71517
71526
  if (Array.isArray(blockComments)) {
@@ -71551,18 +71560,22 @@ ${codeText}
71551
71560
  children.forEach((childContainerId) => {
71552
71561
  const childBlocks = doc2.blocks[childContainerId];
71553
71562
  if (!Array.isArray(childBlocks)) {
71554
- logger$1f.error(`skip invalid comment child container: parent=${block.id}, container=${childContainerId}`);
71563
+ if (!invalidContainers.has(childContainerId)) {
71564
+ invalidContainers.add(childContainerId);
71565
+ logger$1f.warn(`skip invalid comment child container: parentBlock=${block.id}, container=${childContainerId}`);
71566
+ }
71555
71567
  return;
71556
71568
  }
71557
71569
  childBlocks.forEach((subBlock) => {
71558
- addBlockComments(doc2, subBlock, resultMap);
71570
+ addBlockComments(doc2, subBlock, resultMap, invalidContainers);
71559
71571
  });
71560
71572
  });
71561
71573
  }
71562
71574
  function getBlockCommentsFromDoc(doc2) {
71563
71575
  const resultMap = /* @__PURE__ */ new Map();
71576
+ const invalidContainers = /* @__PURE__ */ new Set();
71564
71577
  doc2.blocks.root.forEach((block) => {
71565
- addBlockComments(doc2, block, resultMap);
71578
+ addBlockComments(doc2, block, resultMap, invalidContainers);
71566
71579
  });
71567
71580
  return resultMap;
71568
71581
  }
@@ -97080,7 +97093,7 @@ ${JSON.stringify(error2, null, 2)}`);
97080
97093
  }
97081
97094
  }
97082
97095
  });
97083
- editor.version = "3.1.2-beta.2";
97096
+ editor.version = "3.1.2-beta.ONES22301271.1";
97084
97097
  return editor;
97085
97098
  }
97086
97099
  function isDoc(doc2) {
@@ -97099,35 +97112,31 @@ ${JSON.stringify(error2, null, 2)}`);
97099
97112
  const enableComments = options == null ? void 0 : options.enableComments;
97100
97113
  const quickMenu = (_c = (_b = options.componentsOptions) == null ? void 0 : _b.quickMenu) != null ? _c : { id: "quick-menu", trigger: ["/"], commandProviders: [] };
97101
97114
  (_d = quickMenu.commandProviders) == null ? void 0 : _d.push(new GraphCommandProvider());
97102
- let editorForCleanup;
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
+ });
97103
97139
  try {
97104
- const editor = createEditor(root2, doc2, {
97105
- id: options.id,
97106
- scrollContainer: options == null ? void 0 : options.scrollContainer,
97107
- enableResolveComments: options == null ? void 0 : options.enableResolveComments,
97108
- enableComments,
97109
- dateTimeFormatter: options.dateTimeFormatter,
97110
- components: {
97111
- blocks: [...StandardBlocks, ...(_f = (_e = options.components) == null ? void 0 : _e.blocks) != null ? _f : []],
97112
- commandProviders: [new TableBlockCommandProvider()],
97113
- decorators: [new CodeTextDecorator(), new RemoteCaretsDecorator()],
97114
- embeds: [...StandardEmbeds, ...((_g = options.components) == null ? void 0 : _g.embeds) || []],
97115
- boxes: [MathjaxBox, MentionBox, FileBox, StatusBox, ...((_h = options.components) == null ? void 0 : _h.boxes) || []],
97116
- insertions: [RemoteCaretsInsertion],
97117
- blockHooks: [...((_i = options.components) == null ? void 0 : _i.blockHooks) || []],
97118
- textRenders: [
97119
- enableComments && new OnesEditorCommentsRender(),
97120
- new BlockPaddingRender(),
97121
- ...((_j = options.components) == null ? void 0 : _j.textRenders) || []
97122
- ].filter(Boolean),
97123
- options: { ...options.componentsOptions, quickMenu }
97124
- },
97125
- shortcuts: [TableShortcuts, FindReplaceShortcuts, TextStyleShortcuts, DefaultShortcuts]
97126
- });
97127
- editorForCleanup = editor;
97128
- if (options.readonly) {
97129
- editor.readonly = true;
97130
- }
97131
97140
  if (options.compact) {
97132
97141
  addClass(editor.rootElement, "compact");
97133
97142
  if (options.headingButton === false)
@@ -97220,19 +97229,14 @@ ${JSON.stringify(error2, null, 2)}`);
97220
97229
  OnesEditorDropTarget.register(editor);
97221
97230
  OnesEditorTocProvider.register(editor);
97222
97231
  OnesEditorExclusiveBlock.register(editor);
97223
- editor.version = "3.1.2-beta.2";
97232
+ editor.version = "3.1.2-beta.ONES22301271.1";
97224
97233
  return editor;
97225
97234
  } catch (error2) {
97226
- if (editorForCleanup) {
97227
- try {
97228
- editorForCleanup.destroy();
97229
- } catch (destroyError) {
97230
- logger.error(destroyError);
97231
- }
97232
- } else {
97233
- doc2.destroy();
97235
+ try {
97236
+ editor.destroy();
97237
+ } catch (destroyError) {
97238
+ logger.error(`failed to rollback local editor: ${destroyError.message}`);
97234
97239
  }
97235
- root2.replaceChildren();
97236
97240
  throw error2;
97237
97241
  }
97238
97242
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.1.2-beta.2",
3
+ "version": "3.1.2-beta.ONES22301271.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {