wordinweb 0.1.6 → 0.1.7

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.
package/dist/index.js CHANGED
@@ -15876,28 +15876,30 @@ function resizeTableColumn(doc, tblEl, boundary, deltaPx, renderedWidths) {
15876
15876
  setWidth(right, rw - d);
15877
15877
  }
15878
15878
  }
15879
- if (!hasSpans(tblEl)) {
15880
- for (const tr of rowsOf(tblEl)) {
15881
- const cells = cellsOf(tr);
15882
- cells.forEach((tc, i) => {
15883
- if (!cols[i]) return;
15884
- const w = prefixOf4(tc);
15885
- let tcPr = child(tc, "tcPr");
15886
- if (!tcPr) {
15887
- tcPr = { name: `${w}tcPr`, attrs: {}, children: [], text: "" };
15888
- tc.children.unshift(tcPr);
15889
- }
15890
- let tcW = child(tcPr, "tcW");
15891
- if (!tcW) {
15892
- tcW = { name: `${w}tcW`, attrs: { [`${w}type`]: "dxa" }, children: [], text: "" };
15893
- tcPr.children.unshift(tcW);
15894
- }
15895
- const typeKey = Object.keys(tcW.attrs).find((k) => localName(k) === "type");
15896
- if (!typeKey || tcW.attrs[typeKey] === "dxa") {
15897
- const wKey = Object.keys(tcW.attrs).find((k) => localName(k) === "w") ?? prefixOf4(tcW) + "w";
15898
- tcW.attrs[wKey] = String(widthOf2(cols[i]));
15899
- }
15900
- });
15879
+ for (const tr of rowsOf(tblEl)) {
15880
+ let col = 0;
15881
+ for (const tc of cellsOf(tr)) {
15882
+ const w = prefixOf4(tc);
15883
+ let tcPr = child(tc, "tcPr");
15884
+ if (!tcPr) {
15885
+ tcPr = { name: `${w}tcPr`, attrs: {}, children: [], text: "" };
15886
+ tc.children.unshift(tcPr);
15887
+ }
15888
+ const gs = child(tcPr, "gridSpan");
15889
+ const gsKey = gs && Object.keys(gs.attrs).find((k) => localName(k) === "val");
15890
+ const span = gs && gsKey ? Math.max(1, parseInt(gs.attrs[gsKey], 10) || 1) : 1;
15891
+ const total = cols.slice(col, col + span).reduce((a, c) => a + widthOf2(c), 0);
15892
+ col += span;
15893
+ if (!total) continue;
15894
+ let tcW = child(tcPr, "tcW");
15895
+ if (!tcW) {
15896
+ tcW = { name: `${w}tcW`, attrs: {}, children: [], text: "" };
15897
+ tcPr.children.unshift(tcW);
15898
+ }
15899
+ const typeKey = Object.keys(tcW.attrs).find((k) => localName(k) === "type") ?? `${w}type`;
15900
+ const wKey = Object.keys(tcW.attrs).find((k) => localName(k) === "w") ?? `${w}w`;
15901
+ tcW.attrs[typeKey] = "dxa";
15902
+ tcW.attrs[wKey] = String(total);
15901
15903
  }
15902
15904
  }
15903
15905
  doc.refresh();