Skip to content

Commit

Permalink
fix: add support for different units for column width and row height
Browse files Browse the repository at this point in the history
  • Loading branch information
privateOmega committed Nov 17, 2022
1 parent 678d6ad commit 6286870
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/helpers/xml-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import {
pixelToTWIP,
pixelToEIP,
pointToEIP,
cmToTWIP,
cmRegex,
inchRegex,
inchToTWIP,
} from '../utils/unit-conversion';
// FIXME: remove the cyclic dependency
// eslint-disable-next-line import/no-cycle
Expand Down Expand Up @@ -248,6 +252,12 @@ const fixupRowHeight = (rowHeightString) => {
const matchedParts = rowHeightString.match(pixelRegex);
// convert pixels to half point
return pixelToTWIP(matchedParts[1]);
} else if (cmRegex.test(rowHeightString)) {
const matchedParts = rowHeightString.match(cmRegex);
return cmToTWIP(matchedParts[1]);
} else if (inchRegex.test(rowHeightString)) {
const matchedParts = rowHeightString.match(inchRegex);
return inchToTWIP(matchedParts[1]);
}
};

Expand All @@ -259,6 +269,12 @@ const fixupColumnWidth = (columnWidthString) => {
} else if (pixelRegex.test(columnWidthString)) {
const matchedParts = columnWidthString.match(pixelRegex);
return pixelToTWIP(matchedParts[1]);
} else if (cmRegex.test(columnWidthString)) {
const matchedParts = columnWidthString.match(cmRegex);
return cmToTWIP(matchedParts[1]);
} else if (inchRegex.test(columnWidthString)) {
const matchedParts = columnWidthString.match(inchRegex);
return inchToTWIP(matchedParts[1]);
}
};

Expand Down

0 comments on commit 6286870

Please sign in to comment.