@harbour-enterprises/superdoc 0.18.0-next.9 → 0.18.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 (31) hide show
  1. package/dist/chunks/{PdfViewer-Dq63yg58.cjs → PdfViewer-DaCVS3a7.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BJhrCot5.es.js → PdfViewer-nEK0Vfg8.es.js} +1 -1
  3. package/dist/chunks/{index-BN78x3pO.es.js → index-C5Pduo01.es.js} +3 -3
  4. package/dist/chunks/{index-CJZL4fJB.cjs → index-liKutwiS.cjs} +3 -3
  5. package/dist/chunks/{super-editor.es-wdh3sSj4.es.js → super-editor.es-BJ3WXpls.es.js} +117 -20
  6. package/dist/chunks/{super-editor.es-By4UqJbm.cjs → super-editor.es-C6AwTfxt.cjs} +117 -20
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-B1DscbBQ.js → converter-CYyQ8x__.js} +138 -74
  10. package/dist/super-editor/chunks/{docx-zipper-X8EwoXbC.js → docx-zipper-Bp08RJ7s.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-BbzNzl_2.js → editor-l8pXp1qF.js} +40 -6
  12. package/dist/super-editor/chunks/{toolbar-NTW8zQ0r.js → toolbar-VazJjXhB.js} +2 -2
  13. package/dist/super-editor/converter.es.js +2 -2
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/src/core/commands/insertContent.d.ts +4 -4
  18. package/dist/super-editor/src/core/helpers/contentProcessor.d.ts +13 -0
  19. package/dist/super-editor/src/core/helpers/htmlSanitizer.d.ts +8 -0
  20. package/dist/super-editor/src/core/helpers/importHtml.d.ts +3 -2
  21. package/dist/super-editor/src/core/helpers/importMarkdown.d.ts +2 -1
  22. package/dist/super-editor/src/core/helpers/index.d.ts +1 -0
  23. package/dist/super-editor/super-editor.es.js +18 -18
  24. package/dist/super-editor/toolbar.es.js +2 -2
  25. package/dist/super-editor.cjs +1 -1
  26. package/dist/super-editor.es.js +1 -1
  27. package/dist/superdoc.cjs +2 -2
  28. package/dist/superdoc.es.js +2 -2
  29. package/dist/superdoc.umd.js +118 -21
  30. package/dist/superdoc.umd.js.map +1 -1
  31. package/package.json +1 -1
@@ -29535,11 +29535,48 @@
29535
29535
  }
29536
29536
  return false;
29537
29537
  };
29538
- function createDocFromHTML(content, schema) {
29538
+ function stripHtmlStyles(html) {
29539
+ if (!html) return "";
29540
+ const parser = new DOMParser();
29541
+ const doc2 = parser.parseFromString(html, "text/html");
29542
+ const SEMANTIC_ATTRS = [
29543
+ "href",
29544
+ "src",
29545
+ "alt",
29546
+ "title",
29547
+ "colspan",
29548
+ "rowspan",
29549
+ "headers",
29550
+ "scope",
29551
+ "lang",
29552
+ "dir",
29553
+ "cite",
29554
+ "start",
29555
+ "type"
29556
+ // for lists
29557
+ ];
29558
+ const cleanNode = (node2) => {
29559
+ if (node2.nodeType !== Node.ELEMENT_NODE) return;
29560
+ [...node2.attributes].forEach((attr) => {
29561
+ if (!SEMANTIC_ATTRS.includes(attr.name.toLowerCase())) {
29562
+ node2.removeAttribute(attr.name);
29563
+ }
29564
+ });
29565
+ [...node2.children].forEach(cleanNode);
29566
+ };
29567
+ cleanNode(doc2.body);
29568
+ return doc2.body.innerHTML;
29569
+ }
29570
+ function createDocFromHTML(content, schema, options = {}) {
29571
+ const { isImport = false } = options;
29539
29572
  let parsedContent;
29540
29573
  if (typeof content === "string") {
29574
+ const cleanHtml = stripHtmlStyles(content);
29541
29575
  const tempDiv = document.createElement("div");
29542
- tempDiv.innerHTML = content;
29576
+ if (isImport) {
29577
+ tempDiv.dataset.superdocImport = "true";
29578
+ }
29579
+ tempDiv.innerHTML = cleanHtml;
29543
29580
  parsedContent = tempDiv;
29544
29581
  } else {
29545
29582
  parsedContent = content;
@@ -30623,14 +30660,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30623
30660
  gfm: true
30624
30661
  // GitHub Flavored Markdown support
30625
30662
  });
30626
- function createDocFromMarkdown(markdown, schema) {
30663
+ function createDocFromMarkdown(markdown, schema, options = {}) {
30627
30664
  const html = convertMarkdownToHTML(markdown);
30628
- return createDocFromHTML(html, schema);
30665
+ return createDocFromHTML(html, schema, options);
30629
30666
  }
30630
30667
  function convertMarkdownToHTML(markdown) {
30631
30668
  let html = d.parse(markdown, { async: false });
30632
30669
  return html.replace(/<\/p>\n<ul>/g, "</p>\n<p>&nbsp;</p>\n<ul>").replace(/<\/p>\n<ol>/g, "</p>\n<p>&nbsp;</p>\n<ol>").replace(/<\/ul>\n<h/g, "</ul>\n<p>&nbsp;</p>\n<h").replace(/<\/ol>\n<h/g, "</ol>\n<p>&nbsp;</p>\n<h");
30633
30670
  }
30671
+ function processContent({ content, type: type2, schema }) {
30672
+ let doc2;
30673
+ switch (type2) {
30674
+ case "html":
30675
+ doc2 = createDocFromHTML(content, schema, { isImport: true });
30676
+ break;
30677
+ case "markdown":
30678
+ doc2 = createDocFromMarkdown(content, schema, { isImport: true });
30679
+ break;
30680
+ case "text":
30681
+ const wrapper = document.createElement("div");
30682
+ wrapper.dataset.superdocImport = "true";
30683
+ const para = document.createElement("p");
30684
+ para.textContent = content;
30685
+ wrapper.appendChild(para);
30686
+ doc2 = DOMParser$1.fromSchema(schema).parse(wrapper);
30687
+ break;
30688
+ case "schema":
30689
+ doc2 = schema.nodeFromJSON(content);
30690
+ break;
30691
+ default:
30692
+ throw new Error(`Unknown content type: ${type2}`);
30693
+ }
30694
+ return doc2;
30695
+ }
30634
30696
  const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
30635
30697
  __proto__: null,
30636
30698
  chainableEditorState,
@@ -30662,7 +30724,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30662
30724
  isMarkActive,
30663
30725
  isNodeActive,
30664
30726
  isTextSelection,
30665
- posToDOMRect
30727
+ posToDOMRect,
30728
+ processContent
30666
30729
  }, Symbol.toStringTag, { value: "Module" }));
30667
30730
  const generateNewListDefinition = ({ numId, listType, level, start: start2, text, fmt, editor }) => {
30668
30731
  if (typeof listType === "string") listType = editor.schema.nodes[listType];
@@ -38372,7 +38435,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38372
38435
  return;
38373
38436
  }
38374
38437
  }
38375
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.1") {
38438
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.17.3") {
38376
38439
  const customLocation = "docProps/custom.xml";
38377
38440
  if (!docx[customLocation]) {
38378
38441
  docx[customLocation] = generateCustomXml();
@@ -38854,7 +38917,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38854
38917
  function generateCustomXml() {
38855
38918
  return DEFAULT_CUSTOM_XML;
38856
38919
  }
38857
- function generateSuperdocVersion(pid = 2, version2 = "0.17.1") {
38920
+ function generateSuperdocVersion(pid = 2, version2 = "0.17.3") {
38858
38921
  return {
38859
38922
  type: "element",
38860
38923
  name: "property",
@@ -43332,7 +43395,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
43332
43395
  const selectNodeForward = () => ({ state: state2, dispatch }) => selectNodeForward$1(state2, dispatch);
43333
43396
  const selectTextblockStart = () => ({ state: state2, dispatch }) => selectTextblockStart$1(state2, dispatch);
43334
43397
  const selectTextblockEnd = () => ({ state: state2, dispatch }) => selectTextblockEnd$1(state2, dispatch);
43335
- const insertContent = (value, options) => ({ tr, commands: commands2 }) => {
43398
+ const insertContent = (value, options = {}) => ({ tr, state: state2, commands: commands2, editor }) => {
43399
+ if (options.contentType) {
43400
+ const validTypes = ["html", "markdown", "text", "schema"];
43401
+ if (!validTypes.includes(options.contentType)) {
43402
+ console.error(`[insertContent] Invalid contentType: "${options.contentType}". Use: ${validTypes.join(", ")}`);
43403
+ return false;
43404
+ }
43405
+ try {
43406
+ const processedDoc = processContent({
43407
+ content: value,
43408
+ type: options.contentType,
43409
+ schema: state2.schema
43410
+ });
43411
+ const jsonContent = processedDoc.toJSON();
43412
+ const ok = commands2.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, jsonContent, options);
43413
+ if (ok && (options.contentType === "html" || options.contentType === "markdown")) {
43414
+ Promise.resolve().then(() => editor.migrateListsToV2?.());
43415
+ }
43416
+ return ok;
43417
+ } catch (error) {
43418
+ console.error(`[insertContent] Failed to process ${options.contentType}:`, error);
43419
+ return false;
43420
+ }
43421
+ }
43336
43422
  return commands2.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);
43337
43423
  };
43338
43424
  const removeWhitespaces = (node2) => {
@@ -55733,7 +55819,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
55733
55819
  * @returns {Object | void} Migration results
55734
55820
  */
55735
55821
  processCollaborationMigrations() {
55736
- console.debug("[checkVersionMigrations] Current editor version", "0.17.1");
55822
+ console.debug("[checkVersionMigrations] Current editor version", "0.17.3");
55737
55823
  if (!this.options.ydoc) return;
55738
55824
  const metaMap = this.options.ydoc.getMap("meta");
55739
55825
  let docVersion = metaMap.get("version");
@@ -56090,8 +56176,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
56090
56176
  doc2 = createDocument(this.converter, this.schema, this);
56091
56177
  doc2 = __privateMethod$1(this, _Editor_instances, prepareDocumentForImport_fn).call(this, doc2);
56092
56178
  if (this.options.markdown) {
56093
- doc2 = createDocFromMarkdown(this.options.markdown, this.schema);
56094
- } else if (this.options.html) doc2 = createDocFromHTML(this.options.html, this.schema);
56179
+ doc2 = createDocFromMarkdown(this.options.markdown, this.schema, { isImport: true });
56180
+ } else if (this.options.html) doc2 = createDocFromHTML(this.options.html, this.schema, { isImport: true });
56095
56181
  else if (this.options.jsonOverride) doc2 = this.schema.nodeFromJSON(this.options.jsonOverride);
56096
56182
  if (fragment) doc2 = yXmlFragmentToProseMirrorRootNode(fragment, this.schema);
56097
56183
  }
@@ -59411,6 +59497,17 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59411
59497
  rsidDel: { rendered: false },
59412
59498
  spacing: {
59413
59499
  default: getDefaultSpacing(),
59500
+ parseDOM: (element) => {
59501
+ if (element && element.closest("[data-superdoc-import]")) {
59502
+ return {
59503
+ lineSpaceAfter: 11,
59504
+ lineSpaceBefore: 0,
59505
+ line: 1.15,
59506
+ lineRule: "auto"
59507
+ };
59508
+ }
59509
+ return void 0;
59510
+ },
59414
59511
  renderDOM: (attrs) => {
59415
59512
  const { spacing } = attrs;
59416
59513
  if (!spacing) return {};
@@ -84162,7 +84259,7 @@ ${style2}
84162
84259
  if (listeners.fn) return 1;
84163
84260
  return listeners.length;
84164
84261
  };
84165
- EventEmitter2.prototype.emit = function emit2(event, a12, a2, a3, a42, a5) {
84262
+ EventEmitter2.prototype.emit = function emit2(event, a1, a22, a3, a4, a52) {
84166
84263
  var evt = prefix2 ? prefix2 + event : event;
84167
84264
  if (!this._events[evt]) return false;
84168
84265
  var listeners = this._events[evt], len2 = arguments.length, args, i2;
@@ -84172,15 +84269,15 @@ ${style2}
84172
84269
  case 1:
84173
84270
  return listeners.fn.call(listeners.context), true;
84174
84271
  case 2:
84175
- return listeners.fn.call(listeners.context, a12), true;
84272
+ return listeners.fn.call(listeners.context, a1), true;
84176
84273
  case 3:
84177
- return listeners.fn.call(listeners.context, a12, a2), true;
84274
+ return listeners.fn.call(listeners.context, a1, a22), true;
84178
84275
  case 4:
84179
- return listeners.fn.call(listeners.context, a12, a2, a3), true;
84276
+ return listeners.fn.call(listeners.context, a1, a22, a3), true;
84180
84277
  case 5:
84181
- return listeners.fn.call(listeners.context, a12, a2, a3, a42), true;
84278
+ return listeners.fn.call(listeners.context, a1, a22, a3, a4), true;
84182
84279
  case 6:
84183
- return listeners.fn.call(listeners.context, a12, a2, a3, a42, a5), true;
84280
+ return listeners.fn.call(listeners.context, a1, a22, a3, a4, a52), true;
84184
84281
  }
84185
84282
  for (i2 = 1, args = new Array(len2 - 1); i2 < len2; i2++) {
84186
84283
  args[i2 - 1] = arguments[i2];
@@ -84195,13 +84292,13 @@ ${style2}
84195
84292
  listeners[i2].fn.call(listeners[i2].context);
84196
84293
  break;
84197
84294
  case 2:
84198
- listeners[i2].fn.call(listeners[i2].context, a12);
84295
+ listeners[i2].fn.call(listeners[i2].context, a1);
84199
84296
  break;
84200
84297
  case 3:
84201
- listeners[i2].fn.call(listeners[i2].context, a12, a2);
84298
+ listeners[i2].fn.call(listeners[i2].context, a1, a22);
84202
84299
  break;
84203
84300
  case 4:
84204
- listeners[i2].fn.call(listeners[i2].context, a12, a2, a3);
84301
+ listeners[i2].fn.call(listeners[i2].context, a1, a22, a3);
84205
84302
  break;
84206
84303
  default:
84207
84304
  if (!args) for (j2 = 1, args = new Array(len2 - 1); j2 < len2; j2++) {
@@ -105782,7 +105879,7 @@ ${style2}
105782
105879
  this.config.colors = shuffleArray(this.config.colors);
105783
105880
  this.userColorMap = /* @__PURE__ */ new Map();
105784
105881
  this.colorIndex = 0;
105785
- this.version = "0.17.1";
105882
+ this.version = "0.17.3";
105786
105883
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
105787
105884
  this.superdocId = config2.superdocId || v4();
105788
105885
  this.colors = this.config.colors;