Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanValverdeU committed Oct 2, 2024
1 parent 71b4151 commit e7bd52c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export const tableProcessor: ElementProcessor<HTMLTableElement> = (

if (needCalcHeight) {
rowPositions[rowEnd] =
rowPositions[row] + rect.height / zoomScale;
rowPositions[row] +
(rect.height - getPaddingInCell(td)) / zoomScale;
}
}
}
Expand Down Expand Up @@ -340,3 +341,17 @@ function processColGroup(

return hasColGroup;
}

function getPaddingInCell(td: HTMLTableCellElement) {
let result = 0;

if (!td.style.paddingTop?.endsWith('%')) {
result += parseInt(td.style.paddingTop) || 0;
}

if (!td.style.paddingBottom?.endsWith('%')) {
result += parseInt(td.style.paddingBottom) || 0;
}

return result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export const tableSpacingFormatHandler: FormatHandler<SpacingFormat> = {
}

if (format.cellSpacing) {
const cellSpacing = format.cellSpacing.concat(
format.cellSpacing.endsWith('%') ? '' : 'px'
);
element.style.borderSpacing = cellSpacing;
element.setAttribute(CellSpacing, format.cellSpacing);

// const cellSpacing = format.cellSpacing.concat(
// format.cellSpacing.endsWith('%') ? '' : 'px'
// );
// element.style.borderSpacing = cellSpacing;
}

if (format.cellPadding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ describe('tableSpacingFormatHandler.apply', () => {
it('Set cellspacing attribute', () => {
format.cellSpacing = '5';
tableSpacingFormatHandler.apply(format, div, context);
expect(div.outerHTML).toEqual('<div style="border-spacing: 5px;"></div>');
expect(div.outerHTML).toEqual('<div cellspacing="5"></div>');
});
});

0 comments on commit e7bd52c

Please sign in to comment.