From 99ecf940b6799d9ca6cc07965880cbf41bc29a82 Mon Sep 17 00:00:00 2001 From: "Libor M." Date: Fri, 13 Sep 2024 16:41:42 +0200 Subject: [PATCH] reformat --- src/DocumentContext.js | 18 +++++++++--------- src/LayoutBuilder.js | 26 +++++++++++++------------- src/TableProcessor.js | 4 ++-- src/browser-extensions/index.js | 2 +- src/columnCalculator.js | 24 ++++++++++++------------ src/helpers/variableType.js | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/DocumentContext.js b/src/DocumentContext.js index 439797f1a..94e5d3bee 100644 --- a/src/DocumentContext.js +++ b/src/DocumentContext.js @@ -46,7 +46,7 @@ class DocumentContext extends EventEmitter { } } - resetMarginXTopParent () { + resetMarginXTopParent() { this.marginXTopParent = null; } @@ -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; @@ -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]; @@ -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) { diff --git a/src/LayoutBuilder.js b/src/LayoutBuilder.js index ba595a4df..a06592559 100644 --- a/src/LayoutBuilder.js +++ b/src/LayoutBuilder.js @@ -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 @@ -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); diff --git a/src/TableProcessor.js b/src/TableProcessor.js index e1efef703..840bf4010 100644 --- a/src/TableProcessor.js +++ b/src/TableProcessor.js @@ -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}`); @@ -119,7 +119,7 @@ class TableProcessor { const keepWithHeaderRows = tableNode.table.keepWithHeaderRows; if (isPositiveInteger(keepWithHeaderRows)) { - this.rowsWithoutPageBreak += keepWithHeaderRows; + this.rowsWithoutPageBreak += keepWithHeaderRows; } } diff --git a/src/browser-extensions/index.js b/src/browser-extensions/index.js index 13cd4e471..e484c82cc 100644 --- a/src/browser-extensions/index.js +++ b/src/browser-extensions/index.js @@ -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 = { diff --git a/src/columnCalculator.js b/src/columnCalculator.js index 710b2e973..fc5676c03 100644 --- a/src/columnCalculator.js +++ b/src/columnCalculator.js @@ -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; diff --git a/src/helpers/variableType.js b/src/helpers/variableType.js index b29d1158d..0f03ed321 100644 --- a/src/helpers/variableType.js +++ b/src/helpers/variableType.js @@ -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; }