@ones-editor/editor 2.6.8 → 2.7.0

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.
Files changed (46) hide show
  1. package/@ones-editor/server-tools/package.json +22 -0
  2. package/@ones-editor/server-tools/src/fake-browser.d.ts +1 -0
  3. package/@ones-editor/server-tools/src/from-markdown/index.d.ts +1 -0
  4. package/@ones-editor/server-tools/src/index.d.ts +2 -0
  5. package/@ones-editor/server-tools/src/to-markdown/blocks/code.d.ts +3 -0
  6. package/@ones-editor/server-tools/src/to-markdown/blocks/index.d.ts +12 -0
  7. package/@ones-editor/server-tools/src/to-markdown/blocks/list.d.ts +14 -0
  8. package/@ones-editor/server-tools/src/to-markdown/blocks/table.d.ts +3 -0
  9. package/@ones-editor/server-tools/src/to-markdown/blocks/text.d.ts +4 -0
  10. package/@ones-editor/server-tools/src/to-markdown/boxes/br.d.ts +1 -0
  11. package/@ones-editor/server-tools/src/to-markdown/boxes/date.d.ts +2 -0
  12. package/@ones-editor/server-tools/src/to-markdown/boxes/file.d.ts +11 -0
  13. package/@ones-editor/server-tools/src/to-markdown/boxes/image.d.ts +5 -0
  14. package/@ones-editor/server-tools/src/to-markdown/boxes/index.d.ts +18 -0
  15. package/@ones-editor/server-tools/src/to-markdown/boxes/known-link.d.ts +11 -0
  16. package/@ones-editor/server-tools/src/to-markdown/boxes/mathjax.d.ts +2 -0
  17. package/@ones-editor/server-tools/src/to-markdown/boxes/mention.d.ts +7 -0
  18. package/@ones-editor/server-tools/src/to-markdown/boxes/task-link.d.ts +2 -0
  19. package/@ones-editor/server-tools/src/to-markdown/convert-block.d.ts +3 -0
  20. package/@ones-editor/server-tools/src/to-markdown/convert-box.d.ts +3 -0
  21. package/@ones-editor/server-tools/src/to-markdown/embeds/drawio.d.ts +2 -0
  22. package/@ones-editor/server-tools/src/to-markdown/embeds/file-list.d.ts +5 -0
  23. package/@ones-editor/server-tools/src/to-markdown/embeds/file.d.ts +2 -0
  24. package/@ones-editor/server-tools/src/to-markdown/embeds/flowchart.d.ts +2 -0
  25. package/@ones-editor/server-tools/src/to-markdown/embeds/hr.d.ts +1 -0
  26. package/@ones-editor/server-tools/src/to-markdown/embeds/image.d.ts +18 -0
  27. package/@ones-editor/server-tools/src/to-markdown/embeds/index.d.ts +3 -0
  28. package/@ones-editor/server-tools/src/to-markdown/embeds/mathjax.d.ts +2 -0
  29. package/@ones-editor/server-tools/src/to-markdown/embeds/media.d.ts +2 -0
  30. package/@ones-editor/server-tools/src/to-markdown/embeds/mermaid.d.ts +2 -0
  31. package/@ones-editor/server-tools/src/to-markdown/embeds/plantuml.d.ts +2 -0
  32. package/@ones-editor/server-tools/src/to-markdown/embeds/plugin.d.ts +2 -0
  33. package/@ones-editor/server-tools/src/to-markdown/embeds/sub-pages.d.ts +2 -0
  34. package/@ones-editor/server-tools/src/to-markdown/embeds/task-list.d.ts +7 -0
  35. package/@ones-editor/server-tools/src/to-markdown/embeds/toc.d.ts +2 -0
  36. package/@ones-editor/server-tools/src/to-markdown/embeds/webpage.d.ts +5 -0
  37. package/@ones-editor/server-tools/src/to-markdown/embeds/xmind.d.ts +8 -0
  38. package/@ones-editor/server-tools/src/to-markdown/index.d.ts +1 -0
  39. package/@ones-editor/server-tools/src/to-markdown/types.d.ts +7 -0
  40. package/@ones-editor/server-tools/src/tools.d.ts +1 -0
  41. package/@ones-editor/server-tools/src/utils/editor-doc.d.ts +22 -0
  42. package/@ones-editor/server-tools/src/utils/is-binary.d.ts +14 -0
  43. package/@ones-editor/server-tools/src/utils/object.d.ts +1 -0
  44. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  45. package/dist/index.js +84 -23
  46. package/package.json +9 -1
package/dist/index.js CHANGED
@@ -10910,22 +10910,29 @@ var __publicField = (obj, key, value) => {
10910
10910
  return elementFont;
10911
10911
  }
10912
10912
  function getTextWidth(text2, font) {
10913
- const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
10914
- const context = canvas.getContext("2d");
10915
- if (!context) {
10916
- return 200;
10917
- }
10918
- if (typeof font === "string") {
10919
- if (!font) {
10920
- context.font = getStyleFont(window.getComputedStyle(document.body));
10921
- } else {
10922
- context.font = font;
10913
+ try {
10914
+ if (window.fakebrowser) {
10915
+ return 200;
10916
+ }
10917
+ const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
10918
+ const context = canvas.getContext("2d");
10919
+ if (!context) {
10920
+ return 200;
10923
10921
  }
10924
- } else if (font instanceof Element) {
10925
- context.font = getStyleFont(window.getComputedStyle(font));
10922
+ if (typeof font === "string") {
10923
+ if (!font) {
10924
+ context.font = getStyleFont(window.getComputedStyle(document.body));
10925
+ } else {
10926
+ context.font = font;
10927
+ }
10928
+ } else if (font instanceof Element) {
10929
+ context.font = getStyleFont(window.getComputedStyle(font));
10930
+ }
10931
+ const metrics = context.measureText(text2);
10932
+ return metrics.width + 4;
10933
+ } catch (err) {
10934
+ return 200;
10926
10935
  }
10927
- const metrics = context.measureText(text2);
10928
- return metrics.width + 4;
10929
10936
  }
10930
10937
  const logger$4N = getLogger("editor-clipboard");
10931
10938
  async function setClipboardDataByEvent(items, event) {
@@ -74032,12 +74039,16 @@ ${codeText}
74032
74039
  });
74033
74040
  }
74034
74041
  const StyleTags = {
74042
+ i: "style-italic",
74043
+ b: "style-bold",
74035
74044
  u: "style-underline",
74036
74045
  strong: "style-bold",
74037
74046
  em: "style-italic",
74038
74047
  del: "style-strikethrough",
74039
74048
  superscript: "style-superscript",
74040
- subscript: "style-subscript"
74049
+ sup: "style-superscript",
74050
+ subscript: "style-subscript",
74051
+ sub: "style-subscript"
74041
74052
  };
74042
74053
  function applyHtmlToText(htm, attributes) {
74043
74054
  const html = htm.toLowerCase();
@@ -74185,6 +74196,18 @@ ${codeText}
74185
74196
  }
74186
74197
  if (token.type === "html") {
74187
74198
  const html = token.text;
74199
+ const testBr = html.trim().toLowerCase();
74200
+ if (testBr === "<br>" || testBr === "<br/>" || testBr === "<br />") {
74201
+ return [{
74202
+ insert: " ",
74203
+ attributes: {
74204
+ id: genId(),
74205
+ created: Date.now(),
74206
+ box: true,
74207
+ type: "br"
74208
+ }
74209
+ }];
74210
+ }
74188
74211
  applyHtmlToText(html, attributes);
74189
74212
  applyColorTagToText(html, attributes);
74190
74213
  applyFontSizeTagToText(html, attributes);
@@ -74219,6 +74242,22 @@ ${codeText}
74219
74242
  }
74220
74243
  }];
74221
74244
  }
74245
+ if (token.type === "image") {
74246
+ const href = token.href || "";
74247
+ if (href) {
74248
+ const boxData = {
74249
+ id: genId(),
74250
+ created: Date.now(),
74251
+ box: true,
74252
+ type: "image",
74253
+ src: href
74254
+ };
74255
+ return [{
74256
+ insert: " ",
74257
+ attributes: boxData
74258
+ }];
74259
+ }
74260
+ }
74222
74261
  logger$Q.warn(`unknown token in text: ${JSON.stringify(token)}`);
74223
74262
  return [];
74224
74263
  });
@@ -74235,6 +74274,15 @@ ${codeText}
74235
74274
  }
74236
74275
  function paragraphToBlocks(token, options) {
74237
74276
  const { text: text2, children } = options.tokensToTextWithChildren(token.tokens, options);
74277
+ if (text2.length > 0 && toPlainText(text2).trim().toUpperCase() === "[TOC]") {
74278
+ const tocBlock = {
74279
+ id: genId(),
74280
+ type: "embed",
74281
+ embedType: "toc",
74282
+ embedData: {}
74283
+ };
74284
+ return [tocBlock];
74285
+ }
74238
74286
  const blocks = [];
74239
74287
  if (text2.length > 0) {
74240
74288
  blocks.push({
@@ -74560,15 +74608,24 @@ ${codeText}
74560
74608
  children: []
74561
74609
  };
74562
74610
  const groups = groupTokens(tokens);
74563
- groups.forEach((tokens2, index2) => {
74564
- const token = tokens2[0];
74611
+ groups.forEach((childTokens, index2) => {
74565
74612
  if (index2 === 0) {
74613
+ const token = childTokens[0];
74566
74614
  if (isInlineToken(token)) {
74567
- ret.text = tokensToText(tokens2, {}, options);
74615
+ ret.text = tokensToText(childTokens, {}, options);
74568
74616
  return;
74569
74617
  }
74570
74618
  }
74571
- ret.children.push(...tokensToBlocks(tokens2, options));
74619
+ if (childTokens.every((token) => isInlineToken(token))) {
74620
+ const blockText = tokensToText(childTokens, {}, options);
74621
+ ret.children.push({
74622
+ id: genId(),
74623
+ type: "text",
74624
+ text: blockText
74625
+ });
74626
+ return;
74627
+ }
74628
+ ret.children.push(...tokensToBlocks(childTokens, options));
74572
74629
  });
74573
74630
  return ret;
74574
74631
  }
@@ -74619,7 +74676,11 @@ ${codeText}
74619
74676
  };
74620
74677
  const rootBlocks = tokensToBlocks(tokens, tokenToBlockOptions);
74621
74678
  if (rootBlocks.length === 0) {
74622
- return null;
74679
+ rootBlocks.push({
74680
+ id: genId(),
74681
+ type: "text",
74682
+ text: []
74683
+ });
74623
74684
  }
74624
74685
  doc2.blocks.root.push(...rootBlocks);
74625
74686
  return doc2;
@@ -75881,8 +75942,8 @@ ${content}
75881
75942
  const container = document.createElement("div");
75882
75943
  container.classList.add("highlight-text-wizdoc");
75883
75944
  const code = document.createElement("pre");
75945
+ code.textContent = base64;
75884
75946
  container.appendChild(code);
75885
- code.innerText = base64;
75886
75947
  node.insertAdjacentElement("beforebegin", container);
75887
75948
  node.remove();
75888
75949
  return;
@@ -92478,7 +92539,7 @@ ${data2.plantumlText}
92478
92539
  }
92479
92540
  }
92480
92541
  });
92481
- editor.version = "2.6.8";
92542
+ editor.version = "2.7.0";
92482
92543
  return editor;
92483
92544
  }
92484
92545
  function isDoc(doc2) {
@@ -92591,7 +92652,7 @@ ${data2.plantumlText}
92591
92652
  }
92592
92653
  });
92593
92654
  OnesEditorToolbar.register(editor);
92594
- editor.version = "2.6.8";
92655
+ editor.version = "2.7.0";
92595
92656
  return editor;
92596
92657
  }
92597
92658
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,26 +1,34 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.6.8",
3
+ "version": "2.7.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {
7
7
  "@better-scroll/core": "^2.5.0",
8
8
  "@excalidraw/excalidraw": "0.15.3",
9
9
  "@guyplusplus/turndown-plugin-gfm": "^1.0.7",
10
+ "@types/jsdom": "^21.1.1",
11
+ "@types/lodash.clonedeep": "^4.5.7",
10
12
  "@types/lodash.findlastindex": "^4.6.7",
13
+ "@types/node": "^18.15.11",
11
14
  "axios": "^1.2.6",
12
15
  "blueimp-md5": "^2.19.0",
13
16
  "buffer": "^6.0.3",
17
+ "chardet": "^2.0.0",
18
+ "commander": "9.0.0",
14
19
  "css-color-converter": "^2.0.0",
15
20
  "docx": "^7.2.0",
16
21
  "dom-to-image": "^2.6.0",
17
22
  "events": "^3.3.0",
18
23
  "fast-sha256": "^1.3.0",
19
24
  "flowchart.js": "^1.17.1",
25
+ "fs-extra": "^11.2.0",
20
26
  "graphemer": "^1.4.0",
21
27
  "html-entities": "^2.0.6",
28
+ "iconv-lite": "^0.6.3",
22
29
  "image-size": "^1.0.0",
23
30
  "js-base64": "*",
31
+ "jsdom": "^22.0.0",
24
32
  "kiwi-intl": "^1.2.6-beta.0",
25
33
  "lodash": "^4.0.8",
26
34
  "lodash-es": "4.17.21",