Skip to content

Commit

Permalink
Merge pull request #132 from grobenek/fix(table-text-rotation)-rotati…
Browse files Browse the repository at this point in the history
…ng-text-in-tables-is-correctly-parsed

fix(table-text-rotation): rotated text in table cell is correctly rendered
  • Loading branch information
VolodymyrBaydalka authored Nov 6, 2024
2 parents 0be4219 + 1ea114f commit 9c5ac37
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/document-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,34 @@ export class DocumentParser {

return true;
});

this.parseTableCellVerticalText(elem, cell);
}

parseTableCellVerticalText(elem: Element, cell: WmlTableCell) {
const directionMap = {
"btLr": {
writingMode: "vertical-rl",
transform: "rotate(180deg)"
},
"lrTb": {
writingMode: "vertical-lr",
transform: "none"
},
"tbRl": {
writingMode: "vertical-rl",
transform: "none"
}
};

xmlUtil.foreach(elem, c => {
if (c.localName === "textDirection") {
const direction = xml.attr(c, "val");
const style = directionMap[direction] || {writingMode: "horizontal-tb"};
cell.cssStyle["writing-mode"] = style.writingMode;
cell.cssStyle["transform"] = style.transform;
}
});
}

parseDefaultProperties(elem: Element, style: Record<string, string> = null, childStyle: Record<string, string> = null, handler: (prop: Element) => boolean = null): Record<string, string> {
Expand Down

0 comments on commit 9c5ac37

Please sign in to comment.