@harbour-enterprises/superdoc 0.6.53 → 0.6.55

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 (26) hide show
  1. package/dist/chunks/{super-editor.es-C8f8z8z9.js → super-editor.es-DSFu-hXs.js} +33 -26
  2. package/dist/chunks/super-editor.es-DSFu-hXs.js.map +1 -0
  3. package/dist/super-editor/chunks/{converter-R9v6ADEr.js → converter-CQ_scj-f.js} +32 -25
  4. package/dist/super-editor/chunks/{converter-R9v6ADEr.js.map → converter-CQ_scj-f.js.map} +1 -1
  5. package/dist/super-editor/chunks/{docx-zipper-CxrMu_LD.js → docx-zipper-cx7QcVQ3.js} +2 -2
  6. package/dist/super-editor/chunks/{docx-zipper-CxrMu_LD.js.map → docx-zipper-cx7QcVQ3.js.map} +1 -1
  7. package/dist/super-editor/chunks/{editor-Ckk2UTqU.js → editor-0DMMgCTH.js} +4 -4
  8. package/dist/super-editor/chunks/{editor-Ckk2UTqU.js.map → editor-0DMMgCTH.js.map} +1 -1
  9. package/dist/super-editor/chunks/{toolbar-qFyxvVMW.js → toolbar-DNy2nqmX.js} +3 -3
  10. package/dist/super-editor/chunks/{toolbar-qFyxvVMW.js.map → toolbar-DNy2nqmX.js.map} +1 -1
  11. package/dist/super-editor/converter.es.js +1 -1
  12. package/dist/super-editor/core/super-converter/SuperConverter.d.ts +1 -1
  13. package/dist/super-editor/core/super-converter/SuperConverter.d.ts.map +1 -1
  14. package/dist/super-editor/core/super-converter/exporter.d.ts +1 -1
  15. package/dist/super-editor/core/super-converter/exporter.d.ts.map +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.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.es.js +1 -1
  22. package/dist/superdoc.es.js +3 -3
  23. package/dist/superdoc.umd.js +33 -26
  24. package/dist/superdoc.umd.js.map +1 -1
  25. package/package.json +1 -1
  26. package/dist/chunks/super-editor.es-C8f8z8z9.js.map +0 -1
@@ -18498,33 +18498,35 @@ class DocxExporter {
18498
18498
  __privateAdd$2(this, _DocxExporter_instances);
18499
18499
  this.converter = converter;
18500
18500
  }
18501
- schemaToXml(data) {
18501
+ schemaToXml(data, debug = false) {
18502
18502
  console.debug("[SuperConverter] schemaToXml:", data);
18503
- const result = __privateMethod$2(this, _DocxExporter_instances, generate_xml_as_list_fn).call(this, data);
18503
+ const result = __privateMethod$2(this, _DocxExporter_instances, generate_xml_as_list_fn).call(this, data, debug);
18504
18504
  return result.join("");
18505
18505
  }
18506
18506
  }
18507
18507
  _DocxExporter_instances = /* @__PURE__ */ new WeakSet();
18508
- generate_xml_as_list_fn = function(data) {
18508
+ generate_xml_as_list_fn = function(data, debug = falase) {
18509
18509
  const json = JSON.parse(JSON.stringify(data));
18510
18510
  const declaration = this.converter.declaration.attributes;
18511
18511
  const xmlTag = `<?xml${Object.entries(declaration).map(([key, value]) => ` ${key}="${value}"`).join("")}?>`;
18512
- const result = __privateMethod$2(this, _DocxExporter_instances, generateXml_fn).call(this, json);
18512
+ const result = __privateMethod$2(this, _DocxExporter_instances, generateXml_fn).call(this, json, debug);
18513
18513
  const final = [xmlTag, ...result];
18514
18514
  return final;
18515
18515
  };
18516
18516
  replaceSpecialCharacters_fn = function(text) {
18517
18517
  if (!text) return;
18518
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
18518
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
18519
18519
  };
18520
- generateXml_fn = function(node2) {
18520
+ generateXml_fn = function(node2, debug = false) {
18521
18521
  if (!node2) return null;
18522
- const { name, elements, attributes } = node2;
18522
+ let { name } = node2;
18523
+ const { elements, attributes } = node2;
18523
18524
  let tag = `<${name}`;
18524
18525
  for (let attr in attributes) {
18525
- tag += ` ${attr}="${attributes[attr]}"`;
18526
+ const parsedAttrName = typeof attributes[attr] === "string" ? __privateMethod$2(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, attributes[attr]) : attributes[attr];
18527
+ tag += ` ${attr}="${parsedAttrName}"`;
18526
18528
  }
18527
- const selfClosing = !elements || !elements.length;
18529
+ const selfClosing = name && (!elements || !elements.length);
18528
18530
  if (selfClosing) tag += " />";
18529
18531
  else tag += ">";
18530
18532
  let tags = [tag];
@@ -18538,7 +18540,10 @@ generateXml_fn = function(node2) {
18538
18540
  for (let child of elements) {
18539
18541
  const newElements = __privateMethod$2(this, _DocxExporter_instances, generateXml_fn).call(this, child);
18540
18542
  if (!newElements) continue;
18541
- tags.push(...newElements);
18543
+ const removeUndefined = newElements.filter((el) => {
18544
+ return el !== "<undefined>" && el !== "</undefined>";
18545
+ });
18546
+ tags.push(...removeUndefined);
18542
18547
  }
18543
18548
  }
18544
18549
  }
@@ -20564,14 +20569,14 @@ const _SuperConverter = class _SuperConverter2 {
20564
20569
  if (!properties.elements) return;
20565
20570
  const superdocVersion = properties.elements.find((el) => el.name === "property" && el.attributes.name === "SuperdocVersion");
20566
20571
  if (!superdocVersion) return;
20567
- const version = superdocVersion.elements[0].elements[0].elements[0].text;
20572
+ const version = superdocVersion.elements[0].elements[0].text;
20568
20573
  return version;
20569
20574
  } catch (e) {
20570
20575
  console.warn("Error getting Superdoc version", e);
20571
20576
  return;
20572
20577
  }
20573
20578
  }
20574
- static updateDocumentVersion(docx = this.convertedXml, version = "0.6.53") {
20579
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.6.55") {
20575
20580
  const customLocation = "docProps/custom.xml";
20576
20581
  if (!docx[customLocation]) {
20577
20582
  docx[customLocation] = generateCustomXml();
@@ -20679,9 +20684,9 @@ const _SuperConverter = class _SuperConverter2 {
20679
20684
  return null;
20680
20685
  }
20681
20686
  }
20682
- schemaToXml(data) {
20687
+ schemaToXml(data, debug = false) {
20683
20688
  const exporter = new DocxExporter(this);
20684
- return exporter.schemaToXml(data);
20689
+ return exporter.schemaToXml(data, debug);
20685
20690
  }
20686
20691
  async exportToDocx(jsonData, editorSchema, documentMedia, isFinalDoc = false, commentsExportType, comments = []) {
20687
20692
  const bodyNode = this.savedTagsToRestore.find((el) => el.name === "w:body");
@@ -20823,32 +20828,34 @@ function storeSuperdocVersion(docx) {
20823
20828
  const properties = customXml.elements.find((el) => el.name === "Properties");
20824
20829
  if (!properties.elements) properties.elements = [];
20825
20830
  const elements = properties.elements;
20826
- elements.push(generateSuperdocVersion());
20831
+ let pid = 2;
20832
+ try {
20833
+ pid = elements.length ? Math.max(...elements.map((el) => el.attributes.pid)) + 1 : 2;
20834
+ } catch (error) {
20835
+ }
20836
+ elements.push(pid, generateSuperdocVersion());
20827
20837
  return docx;
20828
20838
  }
20829
20839
  function generateCustomXml() {
20830
20840
  return DEFAULT_CUSTOM_XML;
20831
20841
  }
20832
- function generateSuperdocVersion(version = "0.6.53") {
20842
+ function generateSuperdocVersion(pid = 2, version = "0.6.55") {
20833
20843
  return {
20834
20844
  type: "element",
20835
20845
  name: "property",
20836
20846
  attributes: {
20837
20847
  name: "SuperdocVersion",
20838
- formatId: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
20839
- pid: "2"
20848
+ fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
20849
+ pid
20840
20850
  },
20841
20851
  elements: [
20842
20852
  {
20843
20853
  type: "element",
20844
- name: "vt:superdoc",
20854
+ name: "vt:lpwstr",
20845
20855
  elements: [
20846
20856
  {
20847
- name: "w:t",
20848
- elements: [{
20849
- type: "text",
20850
- text: version
20851
- }]
20857
+ type: "text",
20858
+ text: version
20852
20859
  }
20853
20860
  ]
20854
20861
  }
@@ -34858,7 +34865,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
34858
34865
  * @returns {Y.Doc | undefined} Updated Y.Doc if any, otherwise undefined
34859
34866
  */
34860
34867
  processCollaborationMigrations() {
34861
- console.debug("[checkVersionMigrations] Current editor version", "0.6.53");
34868
+ console.debug("[checkVersionMigrations] Current editor version", "0.6.55");
34862
34869
  if (!this.options.ydoc) return;
34863
34870
  const metaMap = this.options.ydoc.getMap("meta");
34864
34871
  let docVersion = metaMap.get("version");
@@ -58318,4 +58325,4 @@ export {
58318
58325
  helpers as k,
58319
58326
  index as l
58320
58327
  };
58321
- //# sourceMappingURL=super-editor.es-C8f8z8z9.js.map
58328
+ //# sourceMappingURL=super-editor.es-DSFu-hXs.js.map