@harbour-enterprises/superdoc 0.6.53 → 0.6.54

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-cuyJYVt1.js} +33 -26
  2. package/dist/chunks/super-editor.es-cuyJYVt1.js.map +1 -0
  3. package/dist/super-editor/chunks/{converter-R9v6ADEr.js → converter-C1BQrpaR.js} +32 -25
  4. package/dist/super-editor/chunks/{converter-R9v6ADEr.js.map → converter-C1BQrpaR.js.map} +1 -1
  5. package/dist/super-editor/chunks/{docx-zipper-CxrMu_LD.js → docx-zipper-Cqzm3XQw.js} +2 -2
  6. package/dist/super-editor/chunks/{docx-zipper-CxrMu_LD.js.map → docx-zipper-Cqzm3XQw.js.map} +1 -1
  7. package/dist/super-editor/chunks/{editor-Ckk2UTqU.js → editor-D5hBMEbc.js} +4 -4
  8. package/dist/super-editor/chunks/{editor-Ckk2UTqU.js.map → editor-D5hBMEbc.js.map} +1 -1
  9. package/dist/super-editor/chunks/{toolbar-qFyxvVMW.js → toolbar-CIkvzA64.js} +3 -3
  10. package/dist/super-editor/chunks/{toolbar-qFyxvVMW.js.map → toolbar-CIkvzA64.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
@@ -18517,33 +18517,35 @@ class DocxExporter {
18517
18517
  __privateAdd(this, _DocxExporter_instances);
18518
18518
  this.converter = converter;
18519
18519
  }
18520
- schemaToXml(data) {
18520
+ schemaToXml(data, debug = false) {
18521
18521
  console.debug("[SuperConverter] schemaToXml:", data);
18522
- const result = __privateMethod(this, _DocxExporter_instances, generate_xml_as_list_fn).call(this, data);
18522
+ const result = __privateMethod(this, _DocxExporter_instances, generate_xml_as_list_fn).call(this, data, debug);
18523
18523
  return result.join("");
18524
18524
  }
18525
18525
  }
18526
18526
  _DocxExporter_instances = new WeakSet();
18527
- generate_xml_as_list_fn = function(data) {
18527
+ generate_xml_as_list_fn = function(data, debug = falase) {
18528
18528
  const json = JSON.parse(JSON.stringify(data));
18529
18529
  const declaration = this.converter.declaration.attributes;
18530
18530
  const xmlTag = `<?xml${Object.entries(declaration).map(([key, value]) => ` ${key}="${value}"`).join("")}?>`;
18531
- const result = __privateMethod(this, _DocxExporter_instances, generateXml_fn).call(this, json);
18531
+ const result = __privateMethod(this, _DocxExporter_instances, generateXml_fn).call(this, json, debug);
18532
18532
  const final = [xmlTag, ...result];
18533
18533
  return final;
18534
18534
  };
18535
18535
  replaceSpecialCharacters_fn = function(text) {
18536
18536
  if (!text) return;
18537
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
18537
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
18538
18538
  };
18539
- generateXml_fn = function(node2) {
18539
+ generateXml_fn = function(node2, debug = false) {
18540
18540
  if (!node2) return null;
18541
- const { name, elements, attributes } = node2;
18541
+ let { name } = node2;
18542
+ const { elements, attributes } = node2;
18542
18543
  let tag = `<${name}`;
18543
18544
  for (let attr in attributes) {
18544
- tag += ` ${attr}="${attributes[attr]}"`;
18545
+ const parsedAttrName = typeof attributes[attr] === "string" ? __privateMethod(this, _DocxExporter_instances, replaceSpecialCharacters_fn).call(this, attributes[attr]) : attributes[attr];
18546
+ tag += ` ${attr}="${parsedAttrName}"`;
18545
18547
  }
18546
- const selfClosing = !elements || !elements.length;
18548
+ const selfClosing = name && (!elements || !elements.length);
18547
18549
  if (selfClosing) tag += " />";
18548
18550
  else tag += ">";
18549
18551
  let tags = [tag];
@@ -18557,7 +18559,10 @@ generateXml_fn = function(node2) {
18557
18559
  for (let child of elements) {
18558
18560
  const newElements = __privateMethod(this, _DocxExporter_instances, generateXml_fn).call(this, child);
18559
18561
  if (!newElements) continue;
18560
- tags.push(...newElements);
18562
+ const removeUndefined = newElements.filter((el) => {
18563
+ return el !== "<undefined>" && el !== "</undefined>";
18564
+ });
18565
+ tags.push(...removeUndefined);
18561
18566
  }
18562
18567
  }
18563
18568
  }
@@ -20583,14 +20588,14 @@ const _SuperConverter = class _SuperConverter {
20583
20588
  if (!properties.elements) return;
20584
20589
  const superdocVersion = properties.elements.find((el) => el.name === "property" && el.attributes.name === "SuperdocVersion");
20585
20590
  if (!superdocVersion) return;
20586
- const version = superdocVersion.elements[0].elements[0].elements[0].text;
20591
+ const version = superdocVersion.elements[0].elements[0].text;
20587
20592
  return version;
20588
20593
  } catch (e) {
20589
20594
  console.warn("Error getting Superdoc version", e);
20590
20595
  return;
20591
20596
  }
20592
20597
  }
20593
- static updateDocumentVersion(docx = this.convertedXml, version = "0.6.53") {
20598
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.6.54") {
20594
20599
  const customLocation = "docProps/custom.xml";
20595
20600
  if (!docx[customLocation]) {
20596
20601
  docx[customLocation] = generateCustomXml();
@@ -20698,9 +20703,9 @@ const _SuperConverter = class _SuperConverter {
20698
20703
  return null;
20699
20704
  }
20700
20705
  }
20701
- schemaToXml(data) {
20706
+ schemaToXml(data, debug = false) {
20702
20707
  const exporter = new DocxExporter(this);
20703
- return exporter.schemaToXml(data);
20708
+ return exporter.schemaToXml(data, debug);
20704
20709
  }
20705
20710
  async exportToDocx(jsonData, editorSchema, documentMedia, isFinalDoc = false, commentsExportType, comments = []) {
20706
20711
  const bodyNode = this.savedTagsToRestore.find((el) => el.name === "w:body");
@@ -20845,32 +20850,34 @@ function storeSuperdocVersion(docx) {
20845
20850
  const properties = customXml.elements.find((el) => el.name === "Properties");
20846
20851
  if (!properties.elements) properties.elements = [];
20847
20852
  const elements = properties.elements;
20848
- elements.push(generateSuperdocVersion());
20853
+ let pid = 2;
20854
+ try {
20855
+ pid = elements.length ? Math.max(...elements.map((el) => el.attributes.pid)) + 1 : 2;
20856
+ } catch (error) {
20857
+ }
20858
+ elements.push(pid, generateSuperdocVersion());
20849
20859
  return docx;
20850
20860
  }
20851
20861
  function generateCustomXml() {
20852
20862
  return DEFAULT_CUSTOM_XML;
20853
20863
  }
20854
- function generateSuperdocVersion(version = "0.6.53") {
20864
+ function generateSuperdocVersion(pid = 2, version = "0.6.54") {
20855
20865
  return {
20856
20866
  type: "element",
20857
20867
  name: "property",
20858
20868
  attributes: {
20859
20869
  name: "SuperdocVersion",
20860
- formatId: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
20861
- pid: "2"
20870
+ fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
20871
+ pid
20862
20872
  },
20863
20873
  elements: [
20864
20874
  {
20865
20875
  type: "element",
20866
- name: "vt:superdoc",
20876
+ name: "vt:lpwstr",
20867
20877
  elements: [
20868
20878
  {
20869
- name: "w:t",
20870
- elements: [{
20871
- type: "text",
20872
- text: version
20873
- }]
20879
+ type: "text",
20880
+ text: version
20874
20881
  }
20875
20882
  ]
20876
20883
  }
@@ -20925,4 +20932,4 @@ export {
20925
20932
  twipsToLines as y,
20926
20933
  pixelsToTwips as z
20927
20934
  };
20928
- //# sourceMappingURL=converter-R9v6ADEr.js.map
20935
+ //# sourceMappingURL=converter-C1BQrpaR.js.map