@ones-editor/editor 3.1.1 → 3.1.2-beta.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
@@ -64316,6 +64316,10 @@ $$${mathData.mathjaxText}$$
64316
64316
  }
64317
64317
  children.forEach((childContainerId) => {
64318
64318
  const childBlocks = doc2.blocks[childContainerId];
64319
+ if (!Array.isArray(childBlocks)) {
64320
+ logger$1H.error(`skip invalid comment child container: parent=${block.id}, container=${childContainerId}`);
64321
+ return;
64322
+ }
64319
64323
  childBlocks.forEach((subBlock) => {
64320
64324
  addBlockComments$1(doc2, subBlock, result, resultSet);
64321
64325
  });
@@ -97071,7 +97075,7 @@ ${JSON.stringify(error2, null, 2)}`);
97071
97075
  }
97072
97076
  }
97073
97077
  });
97074
- editor.version = "3.1.1";
97078
+ editor.version = "3.1.2-beta.1";
97075
97079
  return editor;
97076
97080
  }
97077
97081
  function isDoc(doc2) {
@@ -97113,100 +97117,112 @@ ${JSON.stringify(error2, null, 2)}`);
97113
97117
  },
97114
97118
  shortcuts: [TableShortcuts, FindReplaceShortcuts, TextStyleShortcuts, DefaultShortcuts]
97115
97119
  });
97116
- if (options.compact) {
97117
- addClass(editor.rootElement, "compact");
97118
- if (options.headingButton === false)
97119
- addClass(editor.rootElement, "no-heading-collapse");
97120
- if (options.blockMenuButton === false)
97121
- addClass(editor.rootElement, "no-block-menu");
97122
- }
97123
- editor.input.addHandler(new MarkdownInputHandler());
97124
- const contentPlaceholder = options.blockMenuButton !== false ? i18n$1.t("placeholder.common.content") : i18n$1.t("placeholder.common.contentInContainer");
97125
- editor.input.addHandler(
97126
- new EnforceWithDocumentTitleHandler(editor, {
97127
- hideTitle: options.hideTitle,
97128
- headingLevel: 1,
97129
- titlePlaceholder: clientType.isMobile ? i18n$1.t("placeholder.common.mobileTitle") : i18n$1.t("placeholder.common.title"),
97130
- contentPlaceholder: clientType.isMobile ? "" : contentPlaceholder,
97131
- readonlyTitlePlaceholder: i18n$1.t("placeholder.local.readonlyTitle"),
97132
- addPlaceholderToAllCurrentEmptyBlock: true
97133
- })
97134
- );
97135
- editor.input.addHandler(new PasteSpecialHandler(editor));
97136
- editor.input.addHandler(new OnesEditorPasteHandler(editor));
97137
- editor.input.addHandler(new BlockLockerPasteHandler());
97138
- editor.input.addHandler(new ListPasteHandler());
97139
- editor.doc.registerCallback(new HeadingBlockDocEvents(editor));
97140
- editor.addCustom(
97141
- "editor-image-preview",
97142
- () => new ImagePreviewHandler(editor, (editor2, img) => {
97143
- var _a2, _b2;
97144
- (_b2 = (_a2 = options.events) == null ? void 0 : _a2.onPreviewImage) == null ? void 0 : _b2.call(_a2, editor2, img);
97145
- })
97146
- );
97147
- if (options.blockMenuButton !== false && !clientType.isMobile) {
97148
- editor.addCustom("block-menu", (editor2) => new OnesEditorBlockMenuButtons(editor2));
97120
+ if (options.readonly) {
97121
+ editor.readonly = true;
97149
97122
  }
97150
- if (!clientType.isMobile) {
97151
- editor.addCustom("editor-quick-menu", () => {
97152
- var _a2;
97153
- return new OnesEditorQuickMenu(editor, (_a2 = options.componentsOptions) == null ? void 0 : _a2.quickMenu);
97154
- });
97155
- editor.editorCommandProviders.registerCommandProvider(
97156
- new TextCommandProvider(editor, { scriptDropDown: true, isFilter: true })
97123
+ try {
97124
+ if (options.compact) {
97125
+ addClass(editor.rootElement, "compact");
97126
+ if (options.headingButton === false)
97127
+ addClass(editor.rootElement, "no-heading-collapse");
97128
+ if (options.blockMenuButton === false)
97129
+ addClass(editor.rootElement, "no-block-menu");
97130
+ }
97131
+ editor.input.addHandler(new MarkdownInputHandler());
97132
+ const contentPlaceholder = options.blockMenuButton !== false ? i18n$1.t("placeholder.common.content") : i18n$1.t("placeholder.common.contentInContainer");
97133
+ editor.input.addHandler(
97134
+ new EnforceWithDocumentTitleHandler(editor, {
97135
+ hideTitle: options.hideTitle,
97136
+ headingLevel: 1,
97137
+ titlePlaceholder: clientType.isMobile ? i18n$1.t("placeholder.common.mobileTitle") : i18n$1.t("placeholder.common.title"),
97138
+ contentPlaceholder: clientType.isMobile ? "" : contentPlaceholder,
97139
+ readonlyTitlePlaceholder: i18n$1.t("placeholder.local.readonlyTitle"),
97140
+ addPlaceholderToAllCurrentEmptyBlock: true
97141
+ })
97157
97142
  );
97158
- editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
97159
- (_k = editor.findCustom("editor-quick-menu")) == null ? void 0 : _k.addFilter("layout-quick-menu-filter", LayoutQuickMenuItemFilter.init(editor));
97160
- (_l = editor.findCustom("editor-block-menu")) == null ? void 0 : _l.addFilter("layout-quick-menu-filter", LayoutQuickMenuItemFilter.init(editor));
97161
- } else {
97162
- editor.addCustom("mobile-helper", () => new OnesEditorMobileHelper(editor));
97163
- }
97164
- editor.addCustom("drawio-paste-handler", () => new DrawioPasteHandler(editor));
97165
- editor.addCustom("image-paste-handler", () => new ImagePasteHandler(editor));
97166
- if (enableComments) {
97143
+ editor.input.addHandler(new PasteSpecialHandler(editor));
97144
+ editor.input.addHandler(new OnesEditorPasteHandler(editor));
97145
+ editor.input.addHandler(new BlockLockerPasteHandler());
97146
+ editor.input.addHandler(new ListPasteHandler());
97147
+ editor.doc.registerCallback(new HeadingBlockDocEvents(editor));
97167
97148
  editor.addCustom(
97168
- "editor-comments",
97169
- (editor2) => new OnesEditorComments(editor2, new LocalDocCommentsProvider(editor2, doc2))
97149
+ "editor-image-preview",
97150
+ () => new ImagePreviewHandler(editor, (editor2, img) => {
97151
+ var _a2, _b2;
97152
+ (_b2 = (_a2 = options.events) == null ? void 0 : _a2.onPreviewImage) == null ? void 0 : _b2.call(_a2, editor2, img);
97153
+ })
97170
97154
  );
97171
- }
97172
- if (options.enableContextMenu !== false) {
97173
- editor.addCustom("editor-context-menu", (editor2) => new OnesEditorContextMenu(editor2));
97174
- }
97175
- editor.addCustom("create-options", () => new OnesEditorCustomDataWrapper(editor, options));
97176
- editor.addCustom("drop-target", () => new OnesEditorDropTarget(editor));
97177
- editor.addCustom("list-to-mindmap", () => new OnesEditorListMindmap(editor));
97178
- editor.addCustom("list-to-mention", () => new OnesEditorBlockMention(editor));
97179
- editor.addCustom("code-caret", () => new OnesEditorCodeCaret(editor));
97180
- editor.addCustom("layout-paste-handler", () => new LayoutBlockCaptionInputHandler(editor, true));
97181
- if ((_m = options.componentsOptions) == null ? void 0 : _m.mention) {
97182
- const mentionOptions = options.componentsOptions.mention;
97183
- editor.addCustom("mention", () => new OnesEditorMention(editor, mentionOptions));
97184
- }
97185
- if (options.headingButton !== false) {
97186
- editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
97187
- }
97188
- if (options.autoNewLine) {
97189
- editor.addCustom("auto-new-line", () => new AutoNewLine(editor));
97190
- }
97191
- editor.addListener("clickLink", (editor2, event, link2) => {
97192
- var _a2;
97193
- if ((_a2 = options == null ? void 0 : options.events) == null ? void 0 : _a2.onClickLink) {
97194
- options.events.onClickLink(editor2, event, link2);
97195
- return;
97155
+ if (options.blockMenuButton !== false && !clientType.isMobile) {
97156
+ editor.addCustom("block-menu", (editor2) => new OnesEditorBlockMenuButtons(editor2));
97196
97157
  }
97197
- const href = link2.getAttribute("link") || link2.getAttribute("href");
97198
- if (href) {
97199
- if (editor2.readonly || event.ctrlKey || event.metaKey || !getParentBlock(link2)) {
97200
- window.open(href, "_blank");
97158
+ if (!clientType.isMobile) {
97159
+ editor.addCustom("editor-quick-menu", () => {
97160
+ var _a2;
97161
+ return new OnesEditorQuickMenu(editor, (_a2 = options.componentsOptions) == null ? void 0 : _a2.quickMenu);
97162
+ });
97163
+ editor.editorCommandProviders.registerCommandProvider(
97164
+ new TextCommandProvider(editor, { scriptDropDown: true, isFilter: true })
97165
+ );
97166
+ editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
97167
+ (_k = editor.findCustom("editor-quick-menu")) == null ? void 0 : _k.addFilter("layout-quick-menu-filter", LayoutQuickMenuItemFilter.init(editor));
97168
+ (_l = editor.findCustom("editor-block-menu")) == null ? void 0 : _l.addFilter("layout-quick-menu-filter", LayoutQuickMenuItemFilter.init(editor));
97169
+ } else {
97170
+ editor.addCustom("mobile-helper", () => new OnesEditorMobileHelper(editor));
97171
+ }
97172
+ editor.addCustom("drawio-paste-handler", () => new DrawioPasteHandler(editor));
97173
+ editor.addCustom("image-paste-handler", () => new ImagePasteHandler(editor));
97174
+ if (enableComments) {
97175
+ editor.addCustom(
97176
+ "editor-comments",
97177
+ (editor2) => new OnesEditorComments(editor2, new LocalDocCommentsProvider(editor2, doc2))
97178
+ );
97179
+ }
97180
+ if (options.enableContextMenu !== false) {
97181
+ editor.addCustom("editor-context-menu", (editor2) => new OnesEditorContextMenu(editor2));
97182
+ }
97183
+ editor.addCustom("create-options", () => new OnesEditorCustomDataWrapper(editor, options));
97184
+ editor.addCustom("drop-target", () => new OnesEditorDropTarget(editor));
97185
+ editor.addCustom("list-to-mindmap", () => new OnesEditorListMindmap(editor));
97186
+ editor.addCustom("list-to-mention", () => new OnesEditorBlockMention(editor));
97187
+ editor.addCustom("code-caret", () => new OnesEditorCodeCaret(editor));
97188
+ editor.addCustom("layout-paste-handler", () => new LayoutBlockCaptionInputHandler(editor, true));
97189
+ if ((_m = options.componentsOptions) == null ? void 0 : _m.mention) {
97190
+ const mentionOptions = options.componentsOptions.mention;
97191
+ editor.addCustom("mention", () => new OnesEditorMention(editor, mentionOptions));
97192
+ }
97193
+ if (options.headingButton !== false) {
97194
+ editor.addCustom("heading-collapse", () => new HeadingBlockCollapseButton(editor));
97195
+ }
97196
+ if (options.autoNewLine) {
97197
+ editor.addCustom("auto-new-line", () => new AutoNewLine(editor));
97198
+ }
97199
+ editor.addListener("clickLink", (editor2, event, link2) => {
97200
+ var _a2;
97201
+ if ((_a2 = options == null ? void 0 : options.events) == null ? void 0 : _a2.onClickLink) {
97202
+ options.events.onClickLink(editor2, event, link2);
97203
+ return;
97201
97204
  }
97205
+ const href = link2.getAttribute("link") || link2.getAttribute("href");
97206
+ if (href) {
97207
+ if (editor2.readonly || event.ctrlKey || event.metaKey || !getParentBlock(link2)) {
97208
+ window.open(href, "_blank");
97209
+ }
97210
+ }
97211
+ });
97212
+ OnesEditorToolbar.register(editor);
97213
+ OnesEditorDropTarget.register(editor);
97214
+ OnesEditorTocProvider.register(editor);
97215
+ OnesEditorExclusiveBlock.register(editor);
97216
+ editor.version = "3.1.2-beta.1";
97217
+ return editor;
97218
+ } catch (error2) {
97219
+ try {
97220
+ editor.destroy();
97221
+ } catch (destroyError) {
97222
+ logger.error(destroyError);
97202
97223
  }
97203
- });
97204
- OnesEditorToolbar.register(editor);
97205
- OnesEditorDropTarget.register(editor);
97206
- OnesEditorTocProvider.register(editor);
97207
- OnesEditorExclusiveBlock.register(editor);
97208
- editor.version = "3.1.1";
97209
- return editor;
97224
+ throw error2;
97225
+ }
97210
97226
  }
97211
97227
  async function showDocVersions(editor, options, serverUrl) {
97212
97228
  var _a;
package/dist/types.d.ts CHANGED
@@ -114,6 +114,7 @@ export interface CreateOnesEditorOptions {
114
114
  }
115
115
  export interface CreateLocalEditorOptions {
116
116
  id?: string;
117
+ readonly?: boolean;
117
118
  lang?: i18n.LANGS;
118
119
  logLevel?: LogLevel;
119
120
  scrollContainer?: HTMLElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.1.1",
3
+ "version": "3.1.2-beta.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {