@harbour-enterprises/superdoc 0.6.58 → 0.6.59

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 (25) hide show
  1. package/dist/chunks/{super-editor.es-CxaXuB9M.js → super-editor.es-BTUN8d83.js} +26 -6
  2. package/dist/chunks/super-editor.es-BTUN8d83.js.map +1 -0
  3. package/dist/style.css +4 -0
  4. package/dist/super-editor/chunks/{converter-D282NY8r.js → converter-nOJHdmJj.js} +25 -5
  5. package/dist/super-editor/chunks/{converter-D282NY8r.js.map → converter-nOJHdmJj.js.map} +1 -1
  6. package/dist/super-editor/chunks/{docx-zipper-WZZlbYit.js → docx-zipper-BeV2FW8a.js} +2 -2
  7. package/dist/super-editor/chunks/{docx-zipper-WZZlbYit.js.map → docx-zipper-BeV2FW8a.js.map} +1 -1
  8. package/dist/super-editor/chunks/{editor-vsdjRqhM.js → editor-Cf_PsMeV.js} +4 -4
  9. package/dist/super-editor/chunks/{editor-vsdjRqhM.js.map → editor-Cf_PsMeV.js.map} +1 -1
  10. package/dist/super-editor/chunks/{toolbar-BBVqB0GY.js → toolbar-4aMIAPz2.js} +3 -3
  11. package/dist/super-editor/chunks/{toolbar-BBVqB0GY.js.map → toolbar-4aMIAPz2.js.map} +1 -1
  12. package/dist/super-editor/converter.es.js +1 -1
  13. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  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/style.css +4 -0
  18. package/dist/super-editor/super-editor.es.js +6 -6
  19. package/dist/super-editor/toolbar.es.js +2 -2
  20. package/dist/super-editor.es.js +1 -1
  21. package/dist/superdoc.es.js +3 -3
  22. package/dist/superdoc.umd.js +26 -6
  23. package/dist/superdoc.umd.js.map +1 -1
  24. package/package.json +1 -1
  25. package/dist/chunks/super-editor.es-CxaXuB9M.js.map +0 -1
package/dist/style.css CHANGED
@@ -446,6 +446,10 @@ li.ProseMirror-selectednode:after {
446
446
  border: 2px solid #8cf;
447
447
  pointer-events: none;
448
448
  }
449
+ .ProseMirror img {
450
+ height: auto;
451
+ max-width: 100%;
452
+ }
449
453
  /* Protect against generic img rules */
450
454
  img.ProseMirror-separator {
451
455
  display: inline !important;
@@ -17977,7 +17977,10 @@ function generateTableRowProperties(node2) {
17977
17977
  };
17978
17978
  }
17979
17979
  function translateTableCell(params) {
17980
- const elements = translateChildNodes(params);
17980
+ const elements = translateChildNodes({
17981
+ ...params,
17982
+ tableCell: params.node
17983
+ });
17981
17984
  const cellProps = generateTableCellProperties(params.node);
17982
17985
  elements.unshift(cellProps);
17983
17986
  return {
@@ -18173,7 +18176,8 @@ function getScaledSize(originalWidth, originalHeight, maxWidth, maxHeight) {
18173
18176
  }
18174
18177
  function translateImageNode(params, imageSize) {
18175
18178
  const {
18176
- node: { attrs = {}, marks = [] }
18179
+ node: { attrs = {}, marks = [] },
18180
+ tableCell
18177
18181
  } = params;
18178
18182
  let imageId = attrs.rId;
18179
18183
  const src = attrs.src || attrs.imageSrc;
@@ -18191,6 +18195,14 @@ function translateImageNode(params, imageSize) {
18191
18195
  h: pixelsToEmu(scaledHeight)
18192
18196
  };
18193
18197
  }
18198
+ if (tableCell) {
18199
+ const colwidthSum = tableCell.attrs.colwidth.reduce((acc, curr) => acc + curr, 0);
18200
+ const leftMargin = tableCell.attrs.cellMargins?.left || 8;
18201
+ const rightMargin = tableCell.attrs.cellMargins?.right || 8;
18202
+ const maxWidthEmu = pixelsToEmu(colwidthSum - (leftMargin + rightMargin));
18203
+ const { width: w, height: h } = resizeKeepAspectRatio(size.w, size.h, maxWidthEmu);
18204
+ if (w && h) size = { w, h };
18205
+ }
18194
18206
  if (params.node.type === "image" && !imageId) {
18195
18207
  const path = src?.split("word/")[1];
18196
18208
  imageId = addNewImageRelationship(params, path);
@@ -18569,6 +18581,14 @@ generateXml_fn = function(node2, debug = false) {
18569
18581
  if (!selfClosing) tags.push(`</${name}>`);
18570
18582
  return tags;
18571
18583
  };
18584
+ function resizeKeepAspectRatio(width, height, maxWidth) {
18585
+ if (width > maxWidth) {
18586
+ let scale = maxWidth / width;
18587
+ let newHeight = Math.round(height * scale);
18588
+ return { width: maxWidth, height: newHeight };
18589
+ }
18590
+ return { width, height };
18591
+ }
18572
18592
  const defaultInitialXml = `<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14"><w:body></w:body></w:document>`;
18573
18593
  const parseXmlToJson = (xml) => {
18574
18594
  return JSON.parse(xmljs.xml2json(xml, null, 2));
@@ -20595,7 +20615,7 @@ const _SuperConverter = class _SuperConverter {
20595
20615
  return;
20596
20616
  }
20597
20617
  }
20598
- static updateDocumentVersion(docx = this.convertedXml, version = "0.6.58") {
20618
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.6.59") {
20599
20619
  const customLocation = "docProps/custom.xml";
20600
20620
  if (!docx[customLocation]) {
20601
20621
  docx[customLocation] = generateCustomXml();
@@ -20861,7 +20881,7 @@ function storeSuperdocVersion(docx) {
20861
20881
  function generateCustomXml() {
20862
20882
  return DEFAULT_CUSTOM_XML;
20863
20883
  }
20864
- function generateSuperdocVersion(pid = 2, version = "0.6.58") {
20884
+ function generateSuperdocVersion(pid = 2, version = "0.6.59") {
20865
20885
  return {
20866
20886
  type: "element",
20867
20887
  name: "property",
@@ -20932,4 +20952,4 @@ export {
20932
20952
  twipsToLines as y,
20933
20953
  pixelsToTwips as z
20934
20954
  };
20935
- //# sourceMappingURL=converter-D282NY8r.js.map
20955
+ //# sourceMappingURL=converter-nOJHdmJj.js.map