Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Sep 13, 2024
1 parent bb44e59 commit 99ecf94
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
18 changes: 9 additions & 9 deletions src/DocumentContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DocumentContext extends EventEmitter {
}
}

resetMarginXTopParent () {
resetMarginXTopParent() {
this.marginXTopParent = null;
}

Expand Down Expand Up @@ -75,7 +75,7 @@ class DocumentContext extends EventEmitter {
markEnding(endingCell, originalXOffset, discountY) {
this.page = endingCell._columnEndingContext.page;
this.x = endingCell._columnEndingContext.x + originalXOffset;
this.y = endingCell._columnEndingContext.y - discountY;
this.y = endingCell._columnEndingContext.y - discountY;
this.availableWidth = endingCell._columnEndingContext.availableWidth;
this.availableHeight = endingCell._columnEndingContext.availableHeight;
this.lastColumnWidth = endingCell._columnEndingContext.lastColumnWidth;
Expand Down Expand Up @@ -135,7 +135,7 @@ class DocumentContext extends EventEmitter {
initializePage() {
this.y = this.pageMargins.top;
this.availableHeight = this.getCurrentPage().pageSize.height - this.pageMargins.top - this.pageMargins.bottom;
const {pageCtx, isSnapshot} = this.pageSnapshot();
const { pageCtx, isSnapshot } = this.pageSnapshot();
pageCtx.availableWidth = this.getCurrentPage().pageSize.width - this.pageMargins.left - this.pageMargins.right;
if (isSnapshot && this.marginXTopParent) {
pageCtx.availableWidth -= this.marginXTopParent[0];
Expand All @@ -144,12 +144,12 @@ class DocumentContext extends EventEmitter {
}

pageSnapshot() {
if (this.snapshots[0]) {
return {pageCtx: this.snapshots[0], isSnapshot: true};
} else {
return {pageCtx: this, isSnapshot: false};
}
}
if (this.snapshots[0]) {
return { pageCtx: this.snapshots[0], isSnapshot: true };
} else {
return { pageCtx: this, isSnapshot: false };
}
}

moveTo(x, y) {
if (x !== undefined && x !== null) {
Expand Down
26 changes: 13 additions & 13 deletions src/LayoutBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,20 +541,20 @@ class LayoutBuilder {

findStartingSpanCell(arr, i) {
let requiredColspan = 1;
for (let index = i - 1; index >= 0; index--) {
if (!arr[index]._span) {
if (arr[index].rowSpan > 1 && (arr[index].colSpan || 1) === requiredColspan) {
return arr[index];
} else {
return null;
}
}
requiredColspan++;
}
return null;
for (let index = i - 1; index >= 0; index--) {
if (!arr[index]._span) {
if (arr[index].rowSpan > 1 && (arr[index].colSpan || 1) === requiredColspan) {
return arr[index];
} else {
return null;
}
}
requiredColspan++;
}
return null;
}

processRow({marginX = [0, 0], dontBreakRows = false, rowsWithoutPageBreak = 0, cells, widths, gaps, tableBody, rowIndex, height}) {
processRow({ marginX = [0, 0], dontBreakRows = false, rowsWithoutPageBreak = 0, cells, widths, gaps, tableBody, rowIndex, height }) {
const updatePageBreakData = (page, prevY) => {
let pageDesc;
// Find page break data for this row and page
Expand Down Expand Up @@ -671,7 +671,7 @@ class LayoutBuilder {
// Previous column cell has a rowspan
if (lastColumn._endingCell) {
endingSpanCell = lastColumn._endingCell;
// Previous column cell is part of a span
// Previous column cell is part of a span
} else if (lastColumn._span === true) {
// We get the cell that started the span where we set a reference to the ending cell
const startingSpanCell = this.findStartingSpanCell(cells, cells.length);
Expand Down
4 changes: 2 additions & 2 deletions src/TableProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TableProcessor {
const headerRows = tableNode.table.headerRows;

if (isPositiveInteger(headerRows)) {
this.headerRows = headerRows;
this.headerRows = headerRows;

if (this.headerRows > tableNode.table.body.length) {
throw new Error(`Too few rows in the table. Property headerRows requires at least ${this.headerRows}, contains only ${tableNode.table.body.length}`);
Expand All @@ -119,7 +119,7 @@ class TableProcessor {
const keepWithHeaderRows = tableNode.table.keepWithHeaderRows;

if (isPositiveInteger(keepWithHeaderRows)) {
this.rowsWithoutPageBreak += keepWithHeaderRows;
this.rowsWithoutPageBreak += keepWithHeaderRows;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/browser-extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import configurator from 'core-js/configurator';

// core-js: Polyfills will be used only if natives completely unavailable.
configurator({
useNative: ['Promise']
useNative: ['Promise']
});

let defaultClientFonts = {
Expand Down
24 changes: 12 additions & 12 deletions src/columnCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ function buildColumnWidths(columns, availableWidth, offsetTotal = 0, tableNode)
// In tables we have to take into consideration the reserved width for paddings and borders
let reservedWidth = 0;
if (tableNode) {
const paddingLeft = tableNode._layout.paddingLeft(colIndex, tableNode);
const paddingRight = tableNode._layout.paddingRight(colIndex, tableNode);
const borderLeft = tableNode._layout.vLineWidth (colIndex, tableNode);
const borderRight = tableNode._layout.vLineWidth (colIndex + 1, tableNode);
if (colIndex === 0) {
// first column assumes whole borderLeft and half of border right
const paddingLeft = tableNode._layout.paddingLeft(colIndex, tableNode);
const paddingRight = tableNode._layout.paddingRight(colIndex, tableNode);
const borderLeft = tableNode._layout.vLineWidth(colIndex, tableNode);
const borderRight = tableNode._layout.vLineWidth(colIndex + 1, tableNode);
if (colIndex === 0) {
// first column assumes whole borderLeft and half of border right
reservedWidth = paddingLeft + paddingRight + borderLeft + (borderRight / 2);

} else if (colIndex === fixedColumns.length - 1) {
// last column assumes whole borderRight and half of border left
} else if (colIndex === fixedColumns.length - 1) {
// last column assumes whole borderRight and half of border left
reservedWidth = paddingLeft + paddingRight + (borderLeft / 2) + borderRight;

} else {
// Columns in the middle assume half of each border
} else {
// Columns in the middle assume half of each border
reservedWidth = paddingLeft + paddingRight + (borderLeft / 2) + (borderRight / 2);
}
}
}
const totalAvailableWidth = initial_availableWidth + offsetTotal;
col.width = (parseFloat(col.width) * totalAvailableWidth / 100) - reservedWidth;
col.width = (parseFloat(col.width) * totalAvailableWidth / 100) - reservedWidth;
}
if (col.width < (col._minWidth) && col.elasticWidth) {
col._calcWidth = col._minWidth;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/variableType.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function isNumber(variable) {
*/
export function isPositiveInteger(variable) {
if (!isNumber(variable) || !Number.isInteger(variable) || variable <= 0) {
return false;
return false;
}
return true;
}
Expand Down

0 comments on commit 99ecf94

Please sign in to comment.