@ones-editor/editor 3.0.8-beta.1 → 3.0.9-beta.2

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.d.ts CHANGED
@@ -30,6 +30,7 @@ export * from '../@ones-editor/layout-block';
30
30
  export * from '../@ones-editor/markdown-to-doc';
31
31
  export * from '../@ones-editor/html-to-doc';
32
32
  export * from '../@ones-editor/main-toolbar';
33
+ export * from '../@ones-editor/mention';
33
34
  export { Popup, ManualMenu, OnesEditorAutoSuggest, tippy, ManualToolbar, ManualCloseDialog, TextColorItem, shouldFocusToEditor, FixedToolbar, } from '../@ones-editor/ui-base';
34
35
  export * from '../@ones-editor/drawio-embed';
35
36
  export * from '../@ones-editor/block-resizer';
@@ -108,3 +109,4 @@ export interface ShowDocVersionsOptions2 {
108
109
  editorOptions?: CreateOnesEditorOptions;
109
110
  }
110
111
  export declare function showDocVersions2(parent: HTMLElement, options: ShowDocVersionsOptions2): Promise<OnesEditorVersionsDialog>;
112
+ export declare function createSimpleInput(root: HTMLElement, docData: DocObject | OnesEditorDoc, options: CreateLocalEditorOptions): Promise<OnesEditor>;
package/dist/index.js CHANGED
@@ -25212,20 +25212,20 @@ var __publicField = (obj, key, value) => {
25212
25212
  function textBlockToMarkdown(editor, blockData, doc2) {
25213
25213
  const richText2 = blockData.text || [];
25214
25214
  const text2 = textToMarkdownText(editor, richText2, doc2);
25215
- let markdown = text2;
25215
+ let markdown2 = text2;
25216
25216
  if (blockData.heading) {
25217
25217
  const heading = blockData.heading;
25218
25218
  const prefix = "#".repeat(heading);
25219
- markdown = `${prefix} ${markdown}`;
25219
+ markdown2 = `${prefix} ${markdown2}`;
25220
25220
  }
25221
25221
  if (blockData.quoted) {
25222
- markdown = `> ${markdown}`;
25222
+ markdown2 = `> ${markdown2}`;
25223
25223
  }
25224
25224
  if (blockData.type === "text") {
25225
- markdown = `${markdown}
25225
+ markdown2 = `${markdown2}
25226
25226
  `;
25227
25227
  }
25228
- return markdown;
25228
+ return markdown2;
25229
25229
  }
25230
25230
  function styleColorToColor$1(color) {
25231
25231
  switch (color) {
@@ -26890,8 +26890,8 @@ var __publicField = (obj, key, value) => {
26890
26890
  function docToMarkdown(editor, doc2) {
26891
26891
  const lines = doc2.blocks.root.map((b, index2) => blockToMarkdown(editor, b, doc2, [{ containerId: "root", blockIndex: index2 }]));
26892
26892
  lines[lines.length - 1] = lines[lines.length - 1].trimEnd();
26893
- const markdown = lines.join("\n");
26894
- return markdown;
26893
+ const markdown2 = lines.join("\n");
26894
+ return markdown2;
26895
26895
  }
26896
26896
  const logger$3O = getLogger("get-text-position");
26897
26897
  function editorGetTextPosition(editor, insertPos) {
@@ -29888,13 +29888,13 @@ ${codeText}
29888
29888
  addMetaToDoc(editor, doc2);
29889
29889
  const htmlFragment = docToHtmlFragment(editor, doc2);
29890
29890
  injectDocToHtmlFragment(htmlFragment, doc2);
29891
- let markdown = "";
29891
+ let markdown2 = "";
29892
29892
  if (isSelectedCodeTextBlock(editor)) {
29893
29893
  const selectBlock = editor.selection.range.getSelectedBlocks()[0];
29894
29894
  const container = getParentContainer(selectBlock.block);
29895
29895
  const codeBlock2 = getParentBlock(container);
29896
29896
  if (codeBlock2) {
29897
- markdown = getSelectedCodeBlockMarkdown(editor, docToText(editor, doc2));
29897
+ markdown2 = getSelectedCodeBlockMarkdown(editor, docToText(editor, doc2));
29898
29898
  }
29899
29899
  } else {
29900
29900
  const lines = [];
@@ -29902,11 +29902,11 @@ ${codeText}
29902
29902
  lines.push(blockToMarkdown(editor, b, doc2, [{ containerId: "root", blockIndex: index2 }]));
29903
29903
  });
29904
29904
  lines[lines.length - 1] = lines[lines.length - 1].trimEnd();
29905
- markdown = lines.join("\n");
29905
+ markdown2 = lines.join("\n");
29906
29906
  }
29907
29907
  setClipboardData([{
29908
29908
  type: "text/plain",
29909
- data: new Blob([markdown], { type: "text/plain" })
29909
+ data: new Blob([markdown2], { type: "text/plain" })
29910
29910
  }]);
29911
29911
  return true;
29912
29912
  }
@@ -42688,6 +42688,9 @@ ${codeText}
42688
42688
  function initMenuItem$1(item, elem) {
42689
42689
  var _a, _b;
42690
42690
  addClass(elem, "menu-item");
42691
+ if (item.className) {
42692
+ addClass(elem, ...item.className.split(" "));
42693
+ }
42691
42694
  if (item.element) {
42692
42695
  return;
42693
42696
  }
@@ -42763,6 +42766,9 @@ ${codeText}
42763
42766
  });
42764
42767
  }
42765
42768
  function initToolbarItem(item, elem, options) {
42769
+ if (item.className) {
42770
+ addClass(elem, ...item.className.split(" "));
42771
+ }
42766
42772
  elem.setAttribute("data-button-id", item.id);
42767
42773
  if (options.tooltipId && item.name && !item.disableTooltip) {
42768
42774
  elem.setAttribute(`data-editor-tooltip-${options.tooltipId}`, item.name);
@@ -67178,9 +67184,11 @@ ${codeText}
67178
67184
  });
67179
67185
  return true;
67180
67186
  }
67181
- function matchBlockStyle(editor, containerId, blockIndex, offset) {
67182
- if (matchHeading(editor, containerId, blockIndex, offset)) {
67183
- return true;
67187
+ function matchBlockStyle(editor, containerId, blockIndex, offset, options) {
67188
+ if ((options == null ? void 0 : options.disableHeadingShortcuts) !== true) {
67189
+ if (matchHeading(editor, containerId, blockIndex, offset)) {
67190
+ return true;
67191
+ }
67184
67192
  }
67185
67193
  if (matchBlockQuote(editor, containerId, blockIndex, offset)) {
67186
67194
  return true;
@@ -67285,6 +67293,9 @@ ${codeText}
67285
67293
  return false;
67286
67294
  }
67287
67295
  class MarkdownInputHandler {
67296
+ constructor(options) {
67297
+ this.options = options;
67298
+ }
67288
67299
  handleAfterInsertText(editor, containerId, blockIndex, offset, text2) {
67289
67300
  const block = editor.getBlockByIndex(containerId, blockIndex);
67290
67301
  if (isTitleBlock$2(block)) {
@@ -67294,7 +67305,7 @@ ${codeText}
67294
67305
  if (converterIntercept(editor, containerId)) {
67295
67306
  return false;
67296
67307
  }
67297
- if (matchBlockStyle(editor, containerId, blockIndex, offset)) {
67308
+ if (matchBlockStyle(editor, containerId, blockIndex, offset, this.options)) {
67298
67309
  return true;
67299
67310
  }
67300
67311
  if (matchTextStyle(editor, containerId, blockIndex, offset)) {
@@ -69834,8 +69845,8 @@ ${codeText}
69834
69845
  return images.map((image) => `<img data-embed-type="image" data-uuid="image:${image.src}" src="${editor.doc.buildResourceUrl(image.src, { withToken: true })}">`).join("");
69835
69846
  }
69836
69847
  if (type === "markdown") {
69837
- const markdown = images.map((image) => `![img](${editor.doc.buildResourceUrl(image.src, { withToken: true })})`).join("\n");
69838
- return `${markdown}
69848
+ const markdown2 = images.map((image) => `![img](${editor.doc.buildResourceUrl(image.src, { withToken: true })})`).join("\n");
69849
+ return `${markdown2}
69839
69850
  `;
69840
69851
  }
69841
69852
  return "";
@@ -75260,8 +75271,8 @@ ${codeText}
75260
75271
  }
75261
75272
  lines.push(rowText);
75262
75273
  }
75263
- const markdown = lines.join("\n");
75264
- return `${markdown}
75274
+ const markdown2 = lines.join("\n");
75275
+ return `${markdown2}
75265
75276
  `;
75266
75277
  }
75267
75278
  if (type === "html") {
@@ -76304,6 +76315,11 @@ ${codeText}
76304
76315
  }
76305
76316
  const logger$S = getLogger("custom-tag-to-text");
76306
76317
  function customTagToText(token, attributes, options) {
76318
+ var _a;
76319
+ const processed = (_a = options.customTagProcess) == null ? void 0 : _a.call(options, token, attributes);
76320
+ if (processed) {
76321
+ return processed;
76322
+ }
76307
76323
  const content = token.content;
76308
76324
  try {
76309
76325
  const base64 = content;
@@ -76516,7 +76532,7 @@ ${codeText}
76516
76532
  return createTextWithReplaceSoftReturn(htmlDecode(token.text), attributes);
76517
76533
  }
76518
76534
  if (token.type === "custom-tag") {
76519
- return customTagToText(token, attributes);
76535
+ return customTagToText(token, attributes, options);
76520
76536
  }
76521
76537
  if (token.type === "latex") {
76522
76538
  return [{
@@ -76979,9 +76995,9 @@ ${codeText}
76979
76995
  });
76980
76996
  marked.marked.use(extendedCustomTag());
76981
76997
  marked.marked.use(confluenceTextTag());
76982
- function markdownToDoc(markdown, options) {
76998
+ function markdownToDoc(markdown2, options) {
76983
76999
  const lexer = new marked.marked.Lexer();
76984
- const tokens = lexer.lex(markdown);
77000
+ const tokens = lexer.lex(markdown2);
76985
77001
  const doc2 = {
76986
77002
  blocks: {
76987
77003
  root: []
@@ -76996,7 +77012,8 @@ ${codeText}
76996
77012
  tokensToBlocks,
76997
77013
  tokensToTextWithChildren,
76998
77014
  htmlToDoc: options == null ? void 0 : options.htmlToDoc,
76999
- listLevel: 1
77015
+ listLevel: 1,
77016
+ customTagProcess: options == null ? void 0 : options.customTagProcess
77000
77017
  };
77001
77018
  const rootBlocks = tokensToBlocks(tokens, tokenToBlockOptions);
77002
77019
  if (rootBlocks.length === 0) {
@@ -77009,6 +77026,13 @@ ${codeText}
77009
77026
  doc2.blocks.root.push(...rootBlocks);
77010
77027
  return doc2;
77011
77028
  }
77029
+ const markdown = `
77030
+ [[cursor]]
77031
+ `;
77032
+ setTimeout(() => {
77033
+ const doc2 = markdownToDoc(markdown);
77034
+ console.log(doc2);
77035
+ }, 100);
77012
77036
  function extend(destination) {
77013
77037
  for (let i = 1; i < arguments.length; i++) {
77014
77038
  const source = arguments[i];
@@ -78574,9 +78598,9 @@ ${docStr}
78574
78598
  htmlFragment = html.substring(start + "<!--StartFragment-->".length, end);
78575
78599
  }
78576
78600
  }
78577
- const markdown = turndownService.turndown(htmlFragment);
78578
- logger$P.debug(`markdown: ${markdown}`);
78579
- return markdownToDoc(markdown, {
78601
+ const markdown2 = turndownService.turndown(htmlFragment);
78602
+ logger$P.debug(`markdown: ${markdown2}`);
78603
+ return markdownToDoc(markdown2, {
78580
78604
  htmlToDoc: (html2) => {
78581
78605
  const doc2 = htmlToDocByMarkdown(html2, options);
78582
78606
  return doc2;
@@ -96310,9 +96334,8 @@ ${JSON.stringify(error2, null, 2)}`);
96310
96334
  }
96311
96335
  const elem = node;
96312
96336
  const refId = elem.getAttribute("data-ref-id");
96313
- const refType = elem.getAttribute("data-ref-type");
96314
96337
  const uuid = elem.getAttribute("data-uuid");
96315
- return Boolean(refType === "task" && refId && uuid);
96338
+ return Boolean(refId && uuid);
96316
96339
  },
96317
96340
  replacement: (content, node) => {
96318
96341
  const refType = node.getAttribute("data-ref-type");
@@ -96850,7 +96873,7 @@ ${JSON.stringify(error2, null, 2)}`);
96850
96873
  }
96851
96874
  }
96852
96875
  });
96853
- editor.version = "3.0.8-beta.1";
96876
+ editor.version = "3.0.9-beta.2";
96854
96877
  return editor;
96855
96878
  }
96856
96879
  function isDoc(doc2) {
@@ -96984,7 +97007,7 @@ ${JSON.stringify(error2, null, 2)}`);
96984
97007
  OnesEditorDropTarget.register(editor);
96985
97008
  OnesEditorTocProvider.register(editor);
96986
97009
  OnesEditorExclusiveBlock.register(editor);
96987
- editor.version = "3.0.8-beta.1";
97010
+ editor.version = "3.0.9-beta.2";
96988
97011
  return editor;
96989
97012
  }
96990
97013
  async function showDocVersions(editor, options, serverUrl) {
@@ -97051,6 +97074,77 @@ ${JSON.stringify(error2, null, 2)}`);
97051
97074
  dialog.show(dialogOptions);
97052
97075
  return dialog;
97053
97076
  }
97077
+ async function createSimpleInput(root2, docData, options) {
97078
+ var _a, _b, _c, _d, _e, _f, _g, _h;
97079
+ assert(logger, root2, "app does not exists");
97080
+ const doc2 = isDoc(docData) ? docData : new LocalDoc(docData, {
97081
+ serverUrl: options.serverUrl || ""
97082
+ });
97083
+ if (options.lang) {
97084
+ i18n$1.setLang(options.lang);
97085
+ }
97086
+ Logger$2.level = (_a = options.logLevel) != null ? _a : LogLevel.DEBUG;
97087
+ const editor = createEditor(root2, doc2, {
97088
+ id: options.id,
97089
+ scrollContainer: options == null ? void 0 : options.scrollContainer,
97090
+ enableResolveComments: false,
97091
+ enableComments: false,
97092
+ dateTimeFormatter: options.dateTimeFormatter,
97093
+ components: {
97094
+ blocks: [ListBlock, ...(_c = (_b = options.components) == null ? void 0 : _b.blocks) != null ? _c : []],
97095
+ commandProviders: [],
97096
+ decorators: [],
97097
+ embeds: [...((_d = options.components) == null ? void 0 : _d.embeds) || []],
97098
+ boxes: [...((_e = options.components) == null ? void 0 : _e.boxes) || []],
97099
+ insertions: [],
97100
+ blockHooks: [...((_f = options.components) == null ? void 0 : _f.blockHooks) || []],
97101
+ textRenders: [
97102
+ ...((_g = options.components) == null ? void 0 : _g.textRenders) || []
97103
+ ].filter(Boolean),
97104
+ options: { ...options.componentsOptions }
97105
+ },
97106
+ shortcuts: [TextStyleShortcuts, DefaultShortcuts]
97107
+ });
97108
+ if (options.compact) {
97109
+ addClass(editor.rootElement, "compact");
97110
+ if (options.headingButton === false)
97111
+ addClass(editor.rootElement, "no-heading-collapse");
97112
+ if (options.blockMenuButton === false)
97113
+ addClass(editor.rootElement, "no-block-menu");
97114
+ }
97115
+ editor.input.addHandler(new MarkdownInputHandler({
97116
+ disableHeadingShortcuts: true
97117
+ }));
97118
+ editor.input.addHandler(new OnesEditorPasteHandler(editor));
97119
+ editor.input.addHandler(new ListPasteHandler());
97120
+ editor.doc.registerCallback(new HeadingBlockDocEvents(editor));
97121
+ if (!clientType.isMobile) {
97122
+ editor.addCustom("editor-tooltip", () => new OnesEditorTooltip(editor));
97123
+ }
97124
+ editor.addCustom("create-options", () => new OnesEditorCustomDataWrapper(editor, options));
97125
+ if ((_h = options.componentsOptions) == null ? void 0 : _h.mention) {
97126
+ const mentionOptions = options.componentsOptions.mention;
97127
+ editor.addCustom("mention", () => new OnesEditorMention(editor, mentionOptions));
97128
+ }
97129
+ if (options.autoNewLine) {
97130
+ editor.addCustom("auto-new-line", () => new AutoNewLine(editor));
97131
+ }
97132
+ editor.addListener("clickLink", (editor2, event, link2) => {
97133
+ var _a2;
97134
+ if ((_a2 = options == null ? void 0 : options.events) == null ? void 0 : _a2.onClickLink) {
97135
+ options.events.onClickLink(editor2, event, link2);
97136
+ return;
97137
+ }
97138
+ const href = link2.getAttribute("link") || link2.getAttribute("href");
97139
+ if (href) {
97140
+ if (editor2.readonly || event.ctrlKey || event.metaKey || !getParentBlock(link2)) {
97141
+ window.open(href, "_blank");
97142
+ }
97143
+ }
97144
+ });
97145
+ editor.version = "3.0.9-beta.2";
97146
+ return editor;
97147
+ }
97054
97148
  const emojis$1 = {
97055
97149
  smileysAndPeople: [
97056
97150
  "\u{1F600}",
@@ -142954,6 +143048,7 @@ ${JSON.stringify(error2, null, 2)}`);
142954
143048
  exports2.MathMenuIcon = MathMenuIcon;
142955
143049
  exports2.MaxUserError = MaxUserError;
142956
143050
  exports2.Mention2Icon = Mention2Icon;
143051
+ exports2.MentionBox = MentionBox;
142957
143052
  exports2.MentionIcon = MentionIcon;
142958
143053
  exports2.MergeCellIcon = MergeCellIcon;
142959
143054
  exports2.Mindmap = Mindmap;
@@ -142966,12 +143061,14 @@ ${JSON.stringify(error2, null, 2)}`);
142966
143061
  exports2.MoreItem = MoreItem;
142967
143062
  exports2.NextIcon = NextIcon;
142968
143063
  exports2.OnesEditorAutoSuggest = OnesEditorAutoSuggest;
143064
+ exports2.OnesEditorBlockMention = OnesEditorBlockMention;
142969
143065
  exports2.OnesEditorComments = OnesEditorComments;
142970
143066
  exports2.OnesEditorCommentsRender = OnesEditorCommentsRender;
142971
143067
  exports2.OnesEditorCustomDataWrapper = OnesEditorCustomDataWrapper;
142972
143068
  exports2.OnesEditorExclusiveBlock = OnesEditorExclusiveBlock;
142973
143069
  exports2.OnesEditorHoveringBlock = OnesEditorHoveringBlock;
142974
143070
  exports2.OnesEditorIcons = index$f;
143071
+ exports2.OnesEditorMention = OnesEditorMention;
142975
143072
  exports2.OnesEditorQuickMenu = OnesEditorQuickMenu;
142976
143073
  exports2.OnesEditorToc = OnesEditorToc;
142977
143074
  exports2.OnesEditorTocProvider = OnesEditorTocProvider;
@@ -143169,6 +143266,7 @@ ${JSON.stringify(error2, null, 2)}`);
143169
143266
  exports2.createSeparator = createSeparator;
143170
143267
  exports2.createSimpleBlockPosition = createSimpleBlockPosition;
143171
143268
  exports2.createSimpleDocPos = createSimpleDocPos;
143269
+ exports2.createSimpleInput = createSimpleInput;
143172
143270
  exports2.createTextBlockData = createTextBlockData;
143173
143271
  exports2.createTextButton = createTextButton;
143174
143272
  exports2.createTextOp = createTextOp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.0.8-beta.1",
3
+ "version": "3.0.9-beta.2",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {