Socket
Socket
Sign inDemoInstall

docx

Package Overview
Dependencies
20
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.1 to 5.2.2

2

package.json
{
"name": "docx",
"version": "5.2.1",
"version": "5.2.2",
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -73,2 +73,5 @@ // http://officeopenxml.com/WPtableGrid.php

this.properties.addVerticalMerge(options.verticalMerge);
} else if (options.rowSpan && options.rowSpan > 1) {
// if cell already have a `verticalMerge`, don't handle `rowSpan`
this.properties.addVerticalMerge(VerticalMergeType.RESTART);
}

@@ -88,6 +91,2 @@

if (options.rowSpan && options.rowSpan > 1) {
this.properties.addVerticalMerge(VerticalMergeType.RESTART);
}
if (options.width) {

@@ -94,0 +93,0 @@ this.properties.setWidth(options.width.size, options.width.type);

@@ -274,5 +274,6 @@ import { expect } from "chai";

expect(tableRow.columnIndexToRootIndex(8, true)).to.equal(5);
expect(() => tableRow.columnIndexToRootIndex(9, true)).to.throw(`cell 'columnIndex' should not great than 8`);
// for column 10, just place the new cell at the end of row
expect(tableRow.columnIndexToRootIndex(10, true)).to.equal(5);
});
});
});

@@ -86,6 +86,10 @@ import { HeightRule } from "file/table/table-row/table-row-height";

let rootIdx = 1;
const endRootIndex = allowEndNewCell ? this.root.length : this.root.length - 1;
while (colIdx <= columnIndex) {
if (rootIdx > endRootIndex) {
throw new Error(`cell 'columnIndex' should not great than ${colIdx - 1}`);
if (rootIdx >= this.root.length) {
if (allowEndNewCell) {
// for inserting verticalMerge CONTINUE cell at end of row
return this.root.length;
} else {
throw new Error(`cell 'columnIndex' should not great than ${colIdx - 1}`);
}
}

@@ -92,0 +96,0 @@ const cell = this.root[rootIdx] as TableCell;

@@ -82,21 +82,22 @@ // http://officeopenxml.com/WPtableGrid.php

rows.forEach((row, rowIndex) => {
row.cells.forEach((cell, cellIndex) => {
if (rowIndex === rows.length - 1) {
// don't process the end row
return;
}
let columnIndex = 0;
row.cells.forEach((cell) => {
// Row Span has to be added in this method and not the constructor because it needs to know information about the column which happens after Table Cell construction
// Row Span of 1 will crash word as it will add RESTART and not a corresponding CONTINUE
if (cell.options.rowSpan && cell.options.rowSpan > 1) {
const columnIndex = row.rootIndexToColumnIndex(cellIndex + 1);
const startRowIndex = rowIndex + 1;
const endRowIndex = rowIndex + (cell.options.rowSpan - 1);
for (let i = startRowIndex; i <= endRowIndex; i++) {
rows[i].addCellToColumnIndex(
new TableCell({
columnSpan: cell.options.columnSpan,
borders: cell.options.borders,
children: [],
verticalMerge: VerticalMergeType.CONTINUE,
}),
columnIndex,
);
}
const continueCell = new TableCell({
// the inserted CONTINUE cell has rowSpan, and will be handled when process the next row
rowSpan: cell.options.rowSpan - 1,
columnSpan: cell.options.columnSpan,
borders: cell.options.borders,
children: [],
verticalMerge: VerticalMergeType.CONTINUE,
});
rows[rowIndex + 1].addCellToColumnIndex(continueCell, columnIndex);
}
columnIndex += cell.options.columnSpan || 1;
});

@@ -103,0 +104,0 @@ });

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc