superdoc 0.31.0-next.4 → 0.31.0-next.6

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 (42) hide show
  1. package/dist/chunks/{PdfViewer-CMqo3BcJ.cjs → PdfViewer-BSud7RY4.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-mTeXBeGP.es.js → PdfViewer-DK93vPf1.es.js} +1 -1
  3. package/dist/chunks/{index-INrjzFwK.es.js → index-Bz2Q2Xq2.es.js} +3 -3
  4. package/dist/chunks/{index-BtYu5_4F.cjs → index-Crequs_q.cjs} +3 -3
  5. package/dist/chunks/{index-BmNdb0G--hU1qknba.es.js → index-DAES86tg-BDL6WVta.es.js} +1 -1
  6. package/dist/chunks/{index-BmNdb0G--CqIBE8k-.cjs → index-DAES86tg-Cjexh3WM.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-DUqAKtdo.es.js → super-editor.es-BWeMHRHm.es.js} +228 -239
  8. package/dist/chunks/{super-editor.es-_Mo5sfTs.cjs → super-editor.es-D8NdQdlk.cjs} +228 -239
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-BsxkbtGe.js → converter-DEQxlCAJ.js} +194 -235
  11. package/dist/super-editor/chunks/{docx-zipper-DzOHQzzj.js → docx-zipper-C6VMEIY_.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-o3FNUBVU.js → editor-D0zFmUwx.js} +36 -6
  13. package/dist/super-editor/chunks/{index-BmNdb0G-.js → index-DAES86tg.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-CbCPJP6P.js → toolbar-Cwx5bBDV.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor/src/core/super-converter/exporter.d.ts +0 -48
  20. package/dist/super-editor/super-editor/src/core/super-converter/exporter.d.ts.map +1 -1
  21. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/generate-paragraph-properties.d.ts +8 -0
  22. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/generate-paragraph-properties.d.ts.map +1 -0
  23. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/translate-paragraph-node.d.ts +8 -0
  24. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/translate-paragraph-node.d.ts.map +1 -0
  25. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/convert-sdt-content-to-runs.d.ts +7 -0
  26. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/convert-sdt-content-to-runs.d.ts.map +1 -0
  27. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-field-annotation.d.ts.map +1 -1
  28. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/t/helpers/translate-text-node.d.ts +5 -0
  29. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/t/helpers/translate-text-node.d.ts.map +1 -0
  30. package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts +1 -0
  31. package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts.map +1 -1
  32. package/dist/super-editor/super-editor/src/extensions/linked-styles/plugin.d.ts.map +1 -1
  33. package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts.map +1 -1
  34. package/dist/super-editor/super-editor.es.js +6 -6
  35. package/dist/super-editor/toolbar.es.js +2 -2
  36. package/dist/super-editor.cjs +1 -1
  37. package/dist/super-editor.es.js +1 -1
  38. package/dist/superdoc.cjs +2 -2
  39. package/dist/superdoc.es.js +2 -2
  40. package/dist/superdoc.umd.js +230 -241
  41. package/dist/superdoc.umd.js.map +1 -1
  42. package/package.json +1 -1
@@ -15427,19 +15427,6 @@
15427
15427
  if (element2.className?.split(" ")?.indexOf(classname) >= 0) return true;
15428
15428
  return element2.parentNode && hasSomeParentWithClass(element2.parentNode, classname);
15429
15429
  };
15430
- function generateDocxRandomId(length2 = 8) {
15431
- const max2 = 2147483647;
15432
- const value = Math.floor(Math.random() * (max2 + 1));
15433
- return value.toString(16).padStart(length2, "0").slice(0, length2);
15434
- }
15435
- function generateRandomSigned32BitIntStrId() {
15436
- const val = Math.floor(Math.random() * 2147483647);
15437
- return val.toString();
15438
- }
15439
- function generateRandom32BitHex() {
15440
- const val = Math.floor(Math.random() * 2147483647);
15441
- return val.toString(16).toUpperCase().padStart(8, "0");
15442
- }
15443
15430
  const DEFAULT_DOCX_DEFS = {
15444
15431
  "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
15445
15432
  "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
@@ -16645,15 +16632,6 @@
16645
16632
  DOCUMENT_RELS_XML_DEF,
16646
16633
  CONTENT_TYPES
16647
16634
  };
16648
- const carbonCopy = (obj) => {
16649
- if (!obj) return void 0;
16650
- try {
16651
- return JSON.parse(JSON.stringify(obj));
16652
- } catch (e) {
16653
- console.error("Error in carbonCopy", obj, e);
16654
- return void 0;
16655
- }
16656
- };
16657
16635
  function translateChildNodes(params2) {
16658
16636
  const { content: nodes } = params2.node;
16659
16637
  if (!nodes) return [];
@@ -18261,6 +18239,15 @@
18261
18239
  attributes: validXmlAttributes$h
18262
18240
  };
18263
18241
  const translator$21 = NodeTranslator.from(config$n);
18242
+ const carbonCopy = (obj) => {
18243
+ if (!obj) return void 0;
18244
+ try {
18245
+ return JSON.parse(JSON.stringify(obj));
18246
+ } catch (e) {
18247
+ console.error("Error in carbonCopy", obj, e);
18248
+ return void 0;
18249
+ }
18250
+ };
18264
18251
  const mergeTextNodes = (nodes) => {
18265
18252
  if (!nodes || !Array.isArray(nodes)) {
18266
18253
  return nodes;
@@ -20094,6 +20081,56 @@
20094
20081
  }
20095
20082
  return schemaNode;
20096
20083
  };
20084
+ function generateParagraphProperties(params2) {
20085
+ const { node: node2 } = params2;
20086
+ const { attrs = {} } = node2;
20087
+ const paragraphProperties = carbonCopy(attrs.paragraphProperties || {});
20088
+ if (attrs.styleId !== paragraphProperties.styleId) {
20089
+ paragraphProperties.styleId = attrs.styleId;
20090
+ }
20091
+ ["borders", "styleId", "indent", "textAlign", "keepLines", "keepNext", "spacing", "tabStops"].forEach((key2) => {
20092
+ let propKey = key2 === "textAlign" ? "justification" : key2;
20093
+ if (JSON.stringify(paragraphProperties[propKey]) !== JSON.stringify(attrs[key2])) {
20094
+ paragraphProperties[propKey] = attrs[key2];
20095
+ }
20096
+ });
20097
+ const framePr = attrs.dropcap;
20098
+ if (framePr) {
20099
+ framePr.dropCap = framePr.type;
20100
+ delete framePr.type;
20101
+ }
20102
+ if (JSON.stringify(paragraphProperties.framePr) !== JSON.stringify(framePr)) {
20103
+ paragraphProperties.framePr = framePr;
20104
+ }
20105
+ const marksProps = decodeRPrFromMarks(attrs.marksAttrs || []);
20106
+ const finalRunProps = combineRunProperties([paragraphProperties.runProperties || {}, marksProps]);
20107
+ paragraphProperties.runProperties = finalRunProps;
20108
+ const pPr = translator$12.decode({ node: { ...node2, attrs: { paragraphProperties } } });
20109
+ const sectPr = node2.attrs?.paragraphProperties?.sectPr;
20110
+ if (sectPr) {
20111
+ pPr.elements.push(sectPr);
20112
+ }
20113
+ return pPr;
20114
+ }
20115
+ function translateParagraphNode(params2) {
20116
+ const elements = translateChildNodes(params2);
20117
+ const htmlAnnotationChild = elements.find((element2) => element2.name === "htmlAnnotation");
20118
+ if (htmlAnnotationChild) {
20119
+ return htmlAnnotationChild.elements;
20120
+ }
20121
+ const pPr = generateParagraphProperties(params2);
20122
+ if (pPr) elements.unshift(pPr);
20123
+ let attributes = {};
20124
+ if (params2.node.attrs?.rsidRDefault) {
20125
+ attributes["w:rsidRDefault"] = params2.node.attrs.rsidRDefault;
20126
+ }
20127
+ const result = {
20128
+ name: "w:p",
20129
+ elements,
20130
+ attributes
20131
+ };
20132
+ return result;
20133
+ }
20097
20134
  const encode$A = (attributes) => {
20098
20135
  return attributes["w:rsidDel"];
20099
20136
  };
@@ -20373,6 +20410,19 @@
20373
20410
  }
20374
20411
  return runs2;
20375
20412
  };
20413
+ function generateDocxRandomId(length2 = 8) {
20414
+ const max2 = 2147483647;
20415
+ const value = Math.floor(Math.random() * (max2 + 1));
20416
+ return value.toString(16).padStart(length2, "0").slice(0, length2);
20417
+ }
20418
+ function generateRandomSigned32BitIntStrId() {
20419
+ const val = Math.floor(Math.random() * 2147483647);
20420
+ return val.toString();
20421
+ }
20422
+ function generateRandom32BitHex() {
20423
+ const val = Math.floor(Math.random() * 2147483647);
20424
+ return val.toString(16).toUpperCase().padStart(8, "0");
20425
+ }
20376
20426
  const XML_NODE_NAME$j = "w:hyperlink";
20377
20427
  const SD_NODE_NAME$g = "link";
20378
20428
  const _createAttributeHandler = (xmlName, sdName) => ({
@@ -20469,13 +20519,13 @@
20469
20519
  type: "element",
20470
20520
  name: "Relationship",
20471
20521
  attributes: {
20472
- Id: id,
20522
+ Id: `rId${id}`,
20473
20523
  Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
20474
20524
  Target: link2,
20475
20525
  TargetMode: "External"
20476
20526
  }
20477
20527
  });
20478
- return id;
20528
+ return `rId${id}`;
20479
20529
  }
20480
20530
  const config$i = {
20481
20531
  xmlName: XML_NODE_NAME$j,
@@ -30489,6 +30539,59 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30489
30539
  attributes: validXmlAttributes$6
30490
30540
  };
30491
30541
  const translator$s = NodeTranslator.from(config$c);
30542
+ function getTextNodeForExport(text2, marks, params2) {
30543
+ const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text2);
30544
+ const space = hasLeadingOrTrailingSpace ? "preserve" : null;
30545
+ const nodeAttrs = space ? { "xml:space": space } : null;
30546
+ const textNodes = [];
30547
+ const textRunProperties = decodeRPrFromMarks(marks || []);
30548
+ const parentRunProperties = params2.extraParams?.runProperties || {};
30549
+ const combinedRunProperties = combineRunProperties([parentRunProperties, textRunProperties]);
30550
+ const rPrNode = translator$1N.decode({ node: { attrs: { runProperties: combinedRunProperties } } });
30551
+ textNodes.push({
30552
+ name: "w:t",
30553
+ elements: [{ text: text2, type: "text" }],
30554
+ attributes: nodeAttrs
30555
+ });
30556
+ if (params2) {
30557
+ const { editor } = params2;
30558
+ const customMarks = editor.extensionService.extensions.filter((e) => e.isExternal === true);
30559
+ marks.forEach((mark2) => {
30560
+ const isCustomMark = customMarks.some((customMark) => {
30561
+ const customMarkName = customMark.name;
30562
+ return mark2.type === customMarkName;
30563
+ });
30564
+ if (!isCustomMark) return;
30565
+ let attrsString = "";
30566
+ Object.entries(mark2.attrs).forEach(([key2, value]) => {
30567
+ if (value) {
30568
+ attrsString += `${key2}=${value};`;
30569
+ }
30570
+ });
30571
+ if (isCustomMark) {
30572
+ textNodes.unshift({
30573
+ type: "element",
30574
+ name: "w:bookmarkStart",
30575
+ attributes: {
30576
+ "w:id": "5000",
30577
+ "w:name": mark2.type + ";" + attrsString
30578
+ }
30579
+ });
30580
+ textNodes.push({
30581
+ type: "element",
30582
+ name: "w:bookmarkEnd",
30583
+ attributes: {
30584
+ "w:id": "5000"
30585
+ }
30586
+ });
30587
+ }
30588
+ });
30589
+ }
30590
+ return {
30591
+ name: "w:r",
30592
+ elements: rPrNode ? [rPrNode, ...textNodes] : textNodes
30593
+ };
30594
+ }
30492
30595
  var he$2 = { exports: {} };
30493
30596
  /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
30494
30597
  var he$1 = he$2.exports;
@@ -30895,18 +30998,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
30895
30998
  node: { attrs = {}, marks = [] }
30896
30999
  } = params2;
30897
31000
  if (!attrs.linkUrl) return prepareTextAnnotation(params2);
30898
- const newId = addNewLinkRelationship(params2, attrs.linkUrl);
30899
- const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params2);
30900
- const contentNode = processLinkContentNode(linkTextNode);
30901
- return {
30902
- name: "w:hyperlink",
30903
- type: "element",
30904
- attributes: {
30905
- "r:id": newId,
30906
- "w:history": 1
30907
- },
30908
- elements: [contentNode]
31001
+ const linkTextNode = {
31002
+ type: "text",
31003
+ text: attrs.linkUrl,
31004
+ marks: [
31005
+ ...marks,
31006
+ {
31007
+ type: "link",
31008
+ attrs: {
31009
+ href: attrs.linkUrl,
31010
+ history: true,
31011
+ text: attrs.linkUrl
31012
+ }
31013
+ },
31014
+ {
31015
+ type: "textStyle",
31016
+ attrs: {
31017
+ color: "#467886"
31018
+ }
31019
+ }
31020
+ ]
30909
31021
  };
31022
+ return translator$10.decode({
31023
+ ...params2,
31024
+ node: linkTextNode
31025
+ });
30910
31026
  }
30911
31027
  function translateFieldAttrsToMarks(attrs = {}) {
30912
31028
  const { fontFamily: fontFamily2, fontSize: fontSize2, bold, underline, italic, textColor, textHighlight } = attrs;
@@ -31099,6 +31215,46 @@ Please report this to https://github.com/markedjs/marked.`, e) {
31099
31215
  };
31100
31216
  return result;
31101
31217
  }
31218
+ const RUN_LEVEL_WRAPPERS = /* @__PURE__ */ new Set(["w:hyperlink", "w:ins", "w:del"]);
31219
+ function convertSdtContentToRuns(elements) {
31220
+ const normalized = Array.isArray(elements) ? elements : [elements];
31221
+ const runs2 = [];
31222
+ normalized.forEach((element2) => {
31223
+ if (!element2) return;
31224
+ if (element2.name === "w:sdtPr") {
31225
+ return;
31226
+ }
31227
+ if (element2.name === "w:r") {
31228
+ runs2.push(element2);
31229
+ return;
31230
+ }
31231
+ if (element2.name === "w:sdt") {
31232
+ const sdtContent = (element2.elements || []).find((child) => child?.name === "w:sdtContent");
31233
+ if (sdtContent?.elements) {
31234
+ runs2.push(...convertSdtContentToRuns(sdtContent.elements));
31235
+ }
31236
+ return;
31237
+ }
31238
+ if (RUN_LEVEL_WRAPPERS.has(element2.name)) {
31239
+ const wrapperElements = convertSdtContentToRuns(element2.elements || []);
31240
+ if (wrapperElements.length) {
31241
+ runs2.push({
31242
+ ...element2,
31243
+ elements: wrapperElements
31244
+ });
31245
+ }
31246
+ return;
31247
+ }
31248
+ if (element2.name) {
31249
+ runs2.push({
31250
+ name: "w:r",
31251
+ type: "element",
31252
+ elements: element2.elements || [element2]
31253
+ });
31254
+ }
31255
+ });
31256
+ return runs2.filter((run2) => Array.isArray(run2.elements) && run2.elements.length > 0);
31257
+ }
31102
31258
  function translateStructuredContent(params2) {
31103
31259
  const { node: node2, isFinalDoc } = params2;
31104
31260
  const childContent = translateChildNodes({ ...params2, node: node2 });
@@ -34346,7 +34502,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34346
34502
  attributes: validXmlAttributes
34347
34503
  };
34348
34504
  const translator = NodeTranslator.from(config);
34349
- const RUN_LEVEL_WRAPPERS = /* @__PURE__ */ new Set(["w:hyperlink", "w:ins", "w:del"]);
34350
34505
  const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
34351
34506
  pageSize: Object.freeze({ width: "12240", height: "15840" }),
34352
34507
  pageMargins: Object.freeze({
@@ -34404,45 +34559,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34404
34559
  });
34405
34560
  return sectPr;
34406
34561
  };
34407
- function convertSdtContentToRuns(elements) {
34408
- const normalized = Array.isArray(elements) ? elements : [elements];
34409
- const runs2 = [];
34410
- normalized.forEach((element2) => {
34411
- if (!element2) return;
34412
- if (element2.name === "w:sdtPr") {
34413
- return;
34414
- }
34415
- if (element2.name === "w:r") {
34416
- runs2.push(element2);
34417
- return;
34418
- }
34419
- if (element2.name === "w:sdt") {
34420
- const sdtContent = (element2.elements || []).find((child) => child?.name === "w:sdtContent");
34421
- if (sdtContent?.elements) {
34422
- runs2.push(...convertSdtContentToRuns(sdtContent.elements));
34423
- }
34424
- return;
34425
- }
34426
- if (RUN_LEVEL_WRAPPERS.has(element2.name)) {
34427
- const wrapperElements = convertSdtContentToRuns(element2.elements || []);
34428
- if (wrapperElements.length) {
34429
- runs2.push({
34430
- ...element2,
34431
- elements: wrapperElements
34432
- });
34433
- }
34434
- return;
34435
- }
34436
- if (element2.name) {
34437
- runs2.push({
34438
- name: "w:r",
34439
- type: "element",
34440
- elements: element2.elements || [element2]
34441
- });
34442
- }
34443
- });
34444
- return runs2.filter((run2) => Array.isArray(run2.elements) && run2.elements.length > 0);
34445
- }
34446
34562
  function exportSchemaToJson(params2) {
34447
34563
  const { type: type2 } = params2.node || {};
34448
34564
  const router = {
@@ -34549,57 +34665,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34549
34665
  // Maps to Heading1, Heading2, etc. in Word
34550
34666
  }
34551
34667
  };
34552
- return translateParagraphNode({ ...params2, node: paragraphNode });
34553
- }
34554
- function translateParagraphNode(params2) {
34555
- const elements = translateChildNodes(params2);
34556
- const htmlAnnotationChild = elements.find((element2) => element2.name === "htmlAnnotation");
34557
- if (htmlAnnotationChild) {
34558
- return htmlAnnotationChild.elements;
34559
- }
34560
- const pPr = generateParagraphProperties(params2);
34561
- if (pPr) elements.unshift(pPr);
34562
- let attributes = {};
34563
- if (params2.node.attrs?.rsidRDefault) {
34564
- attributes["w:rsidRDefault"] = params2.node.attrs.rsidRDefault;
34565
- }
34566
- const result = {
34567
- name: "w:p",
34568
- elements,
34569
- attributes
34570
- };
34571
- return result;
34572
- }
34573
- function generateParagraphProperties(params2) {
34574
- const { node: node2 } = params2;
34575
- const { attrs = {} } = node2;
34576
- const paragraphProperties = carbonCopy(attrs.paragraphProperties || {});
34577
- if (attrs.styleId !== paragraphProperties.styleId) {
34578
- paragraphProperties.styleId = attrs.styleId;
34579
- }
34580
- ["borders", "styleId", "indent", "textAlign", "keepLines", "keepNext", "spacing", "tabStops"].forEach((key2) => {
34581
- let propKey = key2 === "textAlign" ? "justification" : key2;
34582
- if (JSON.stringify(paragraphProperties[propKey]) !== JSON.stringify(attrs[key2])) {
34583
- paragraphProperties[key2] = attrs[key2];
34584
- }
34585
- });
34586
- const framePr = attrs.dropcap;
34587
- if (framePr) {
34588
- framePr.dropCap = framePr.type;
34589
- delete framePr.type;
34590
- }
34591
- if (JSON.stringify(paragraphProperties.framePr) !== JSON.stringify(framePr)) {
34592
- paragraphProperties.framePr = framePr;
34593
- }
34594
- const marksProps = decodeRPrFromMarks(attrs.marksAttrs || []);
34595
- const finalRunProps = combineRunProperties([paragraphProperties.runProperties || {}, marksProps]);
34596
- paragraphProperties.runProperties = finalRunProps;
34597
- const pPr = translator$12.decode({ node: { ...node2, attrs: { paragraphProperties } } });
34598
- const sectPr = node2.attrs?.paragraphProperties?.sectPr;
34599
- if (sectPr) {
34600
- pPr.elements.push(sectPr);
34601
- }
34602
- return pPr;
34668
+ return translator$11.decode({ ...params2, node: paragraphNode });
34603
34669
  }
34604
34670
  function translateDocumentNode(params2) {
34605
34671
  const bodyNode = {
@@ -34614,59 +34680,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34614
34680
  };
34615
34681
  return [node2, params2];
34616
34682
  }
34617
- function getTextNodeForExport(text2, marks, params2) {
34618
- const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text2);
34619
- const space = hasLeadingOrTrailingSpace ? "preserve" : null;
34620
- const nodeAttrs = space ? { "xml:space": space } : null;
34621
- const textNodes = [];
34622
- const textRunProperties = decodeRPrFromMarks(marks || []);
34623
- const parentRunProperties = params2.extraParams?.runProperties || {};
34624
- const combinedRunProperties = combineRunProperties([parentRunProperties, textRunProperties]);
34625
- const rPrNode = translator$1N.decode({ node: { attrs: { runProperties: combinedRunProperties } } });
34626
- textNodes.push({
34627
- name: "w:t",
34628
- elements: [{ text: text2, type: "text" }],
34629
- attributes: nodeAttrs
34630
- });
34631
- if (params2) {
34632
- const { editor } = params2;
34633
- const customMarks = editor.extensionService.extensions.filter((e) => e.isExternal === true);
34634
- marks.forEach((mark2) => {
34635
- const isCustomMark = customMarks.some((customMark) => {
34636
- const customMarkName = customMark.name;
34637
- return mark2.type === customMarkName;
34638
- });
34639
- if (!isCustomMark) return;
34640
- let attrsString = "";
34641
- Object.entries(mark2.attrs).forEach(([key2, value]) => {
34642
- if (value) {
34643
- attrsString += `${key2}=${value};`;
34644
- }
34645
- });
34646
- if (isCustomMark) {
34647
- textNodes.unshift({
34648
- type: "element",
34649
- name: "w:bookmarkStart",
34650
- attributes: {
34651
- "w:id": "5000",
34652
- "w:name": mark2.type + ";" + attrsString
34653
- }
34654
- });
34655
- textNodes.push({
34656
- type: "element",
34657
- name: "w:bookmarkEnd",
34658
- attributes: {
34659
- "w:id": "5000"
34660
- }
34661
- });
34662
- }
34663
- });
34664
- }
34665
- return {
34666
- name: "w:r",
34667
- elements: rPrNode ? [rPrNode, ...textNodes] : textNodes
34668
- };
34669
- }
34670
34683
  function wrapTextInRun(nodeOrNodes, marks) {
34671
34684
  let elements = [];
34672
34685
  if (Array.isArray(nodeOrNodes)) elements = nodeOrNodes;
@@ -34695,60 +34708,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34695
34708
  }
34696
34709
  });
34697
34710
  }
34698
- function processLinkContentNode(node2) {
34699
- if (!node2) return node2;
34700
- const contentNode = carbonCopy(node2);
34701
- if (!contentNode) return contentNode;
34702
- const hyperlinkStyle = {
34703
- name: "w:rStyle",
34704
- attributes: { "w:val": "Hyperlink" }
34705
- };
34706
- const color2 = {
34707
- name: "w:color",
34708
- attributes: { "w:val": "467886" }
34709
- };
34710
- const underline = {
34711
- name: "w:u",
34712
- attributes: {
34713
- "w:val": "none"
34714
- }
34715
- };
34716
- if (contentNode.name === "w:r") {
34717
- const runProps = contentNode.elements.find((el) => el.name === "w:rPr");
34718
- if (runProps) {
34719
- const foundColor = runProps.elements.find((el) => el.name === "w:color");
34720
- const foundHyperlinkStyle = runProps.elements.find((el) => el.name === "w:rStyle");
34721
- const underlineMark = runProps.elements.find((el) => el.name === "w:u");
34722
- if (!foundColor) runProps.elements.unshift(color2);
34723
- if (!foundHyperlinkStyle) runProps.elements.unshift(hyperlinkStyle);
34724
- if (!underlineMark) runProps.elements.unshift(underline);
34725
- } else {
34726
- const runProps2 = {
34727
- name: "w:rPr",
34728
- elements: [hyperlinkStyle, color2]
34729
- };
34730
- contentNode.elements.unshift(runProps2);
34731
- }
34732
- }
34733
- return contentNode;
34734
- }
34735
- function addNewLinkRelationship(params2, link2) {
34736
- const newId = "rId" + generateDocxRandomId();
34737
- if (!params2.relationships || !Array.isArray(params2.relationships)) {
34738
- params2.relationships = [];
34739
- }
34740
- params2.relationships.push({
34741
- type: "element",
34742
- name: "Relationship",
34743
- attributes: {
34744
- Id: newId,
34745
- Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
34746
- Target: link2,
34747
- TargetMode: "External"
34748
- }
34749
- });
34750
- return newId;
34751
- }
34752
34711
  function translateMark(mark2) {
34753
34712
  const xmlMark = SuperConverter.markTypes.find((m2) => m2.type === mark2.type);
34754
34713
  if (!xmlMark) {
@@ -34929,7 +34888,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34929
34888
  return newComment;
34930
34889
  };
34931
34890
  const getCommentDefinition = (comment2, commentId, allComments, editor) => {
34932
- const translatedText = translateParagraphNode({ editor, node: comment2.commentJSON });
34891
+ const translatedText = translator$11.decode({ editor, node: comment2.commentJSON });
34933
34892
  const attributes = {
34934
34893
  "w:id": String(commentId),
34935
34894
  "w:author": comment2.creatorName || comment2.importedAuthor?.name,
@@ -35344,7 +35303,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35344
35303
  static getStoredSuperdocVersion(docx) {
35345
35304
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35346
35305
  }
35347
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.4") {
35306
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.6") {
35348
35307
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35349
35308
  }
35350
35309
  /**
@@ -60345,7 +60304,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60345
60304
  { default: remarkStringify2 },
60346
60305
  { default: remarkGfm2 }
60347
60306
  ] = await Promise.all([
60348
- Promise.resolve().then(() => indexBmNdb0G_),
60307
+ Promise.resolve().then(() => indexDAES86tg),
60349
60308
  Promise.resolve().then(() => indexDRCvimau),
60350
60309
  Promise.resolve().then(() => indexC_x_N6Uh),
60351
60310
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -60546,7 +60505,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60546
60505
  * Process collaboration migrations
60547
60506
  */
60548
60507
  processCollaborationMigrations() {
60549
- console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.4");
60508
+ console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.6");
60550
60509
  if (!this.options.ydoc) return;
60551
60510
  const metaMap = this.options.ydoc.getMap("meta");
60552
60511
  let docVersion = metaMap.get("version");
@@ -64365,7 +64324,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64365
64324
  let selection = tr.selection;
64366
64325
  const state2 = editor.state;
64367
64326
  const focusState = CustomSelectionPluginKey.getState(state2);
64368
- if (selection.empty && focusState?.preservedSelection) {
64327
+ if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
64369
64328
  selection = focusState.preservedSelection;
64370
64329
  tr.setSelection(selection);
64371
64330
  } else if (selection.empty && editor.options.lastSelection) {
@@ -64432,6 +64391,31 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64432
64391
  });
64433
64392
  return true;
64434
64393
  };
64394
+ const stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step, stepIndex) => {
64395
+ if (!step.slice || step.slice.size === 0 || typeof step.from !== "number") {
64396
+ return false;
64397
+ }
64398
+ let insertsText = false;
64399
+ step.slice.content.descendants((node2) => {
64400
+ if (node2.type?.name === "text" && node2.text?.length) {
64401
+ insertsText = true;
64402
+ return false;
64403
+ }
64404
+ return true;
64405
+ });
64406
+ if (!insertsText) return false;
64407
+ const docBeforeStep = tr.docs?.[stepIndex] || oldEditorState.doc;
64408
+ if (!docBeforeStep) return false;
64409
+ const resolvedPos = Math.min(step.from, docBeforeStep.content.size);
64410
+ const $pos = docBeforeStep.resolve(resolvedPos);
64411
+ for (let depth = $pos.depth; depth >= 0; depth--) {
64412
+ const node2 = $pos.node(depth);
64413
+ if (node2?.type?.name === "paragraph") {
64414
+ return Boolean(node2.attrs?.styleId);
64415
+ }
64416
+ }
64417
+ return false;
64418
+ };
64435
64419
  const LinkedStylesPluginKey = new PluginKey("linkedStyles");
64436
64420
  const createLinkedStylesPlugin = (editor) => {
64437
64421
  return new Plugin({
@@ -64465,7 +64449,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64465
64449
  if (tr.docChanged) {
64466
64450
  let mightAffectStyles = false;
64467
64451
  const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
64468
- tr.steps.forEach((step) => {
64452
+ tr.steps.forEach((step, index2) => {
64469
64453
  if (step.slice) {
64470
64454
  step.slice.content.descendants((node2) => {
64471
64455
  if (node2.attrs?.styleId) {
@@ -64486,6 +64470,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64486
64470
  mightAffectStyles = true;
64487
64471
  }
64488
64472
  }
64473
+ if (!mightAffectStyles && stepInsertsTextIntoStyledParagraph(tr, oldEditorState, step, index2)) {
64474
+ mightAffectStyles = true;
64475
+ }
64489
64476
  });
64490
64477
  if (mightAffectStyles) {
64491
64478
  const styles = LinkedStylesPluginKey.getState(editor.state).styles;
@@ -65836,6 +65823,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65836
65823
  }
65837
65824
  },
65838
65825
  styleId: {
65826
+ default: null,
65827
+ keepOnSplit: false,
65839
65828
  renderDOM: (attrs) => {
65840
65829
  if (!attrs.styleId) return {};
65841
65830
  return { styleid: attrs.styleId };
@@ -116671,7 +116660,7 @@ ${style2}
116671
116660
  this.config.colors = shuffleArray(this.config.colors);
116672
116661
  this.userColorMap = /* @__PURE__ */ new Map();
116673
116662
  this.colorIndex = 0;
116674
- this.version = "0.31.0-next.4";
116663
+ this.version = "0.31.0-next.6";
116675
116664
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
116676
116665
  this.superdocId = config2.superdocId || v4();
116677
116666
  this.colors = this.config.colors;
@@ -119071,7 +119060,7 @@ ${style2}
119071
119060
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
119072
119061
  );
119073
119062
  }
119074
- const indexBmNdb0G_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119063
+ const indexDAES86tg = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119075
119064
  __proto__: null,
119076
119065
  unified
119077
119066
  }, Symbol.toStringTag, { value: "Module" }));