feat: 完成 DOCX 通用结构映射与严格收口
This commit is contained in:
@@ -378,7 +378,10 @@ function applyTokenParagraphStyle(
|
||||
if (token.alignment !== undefined) {
|
||||
removeDirectChildren(parent, WORD_NAMESPACE, "jc");
|
||||
appendElement(parent, WORD_NAMESPACE, "w:jc", {
|
||||
"w:val": token.alignment
|
||||
"w:val":
|
||||
token.alignment === "justify"
|
||||
? "both"
|
||||
: token.alignment
|
||||
});
|
||||
}
|
||||
if (token.backgroundColor !== undefined) {
|
||||
@@ -709,7 +712,13 @@ function applyTableAndCaption(
|
||||
WORD_NAMESPACE,
|
||||
"w:tblPr"
|
||||
);
|
||||
removeDirectChildren(tblPr, WORD_NAMESPACE, "tblCellMar", "tblBorders");
|
||||
removeDirectChildren(
|
||||
tblPr,
|
||||
WORD_NAMESPACE,
|
||||
"tblW",
|
||||
"tblCellMar",
|
||||
"tblBorders"
|
||||
);
|
||||
const margins = appendElement(
|
||||
tblPr,
|
||||
WORD_NAMESPACE,
|
||||
@@ -863,15 +872,7 @@ function applyTableTokenStyles(
|
||||
WORD_NAMESPACE,
|
||||
"w:tblPr"
|
||||
);
|
||||
if (tableToken?.widthPercent !== undefined) {
|
||||
removeDirectChildren(tblPr, WORD_NAMESPACE, "tblW");
|
||||
appendElement(tblPr, WORD_NAMESPACE, "w:tblW", {
|
||||
"w:w": String(
|
||||
Math.round(tableToken.widthPercent * 50)
|
||||
),
|
||||
"w:type": "pct"
|
||||
});
|
||||
}
|
||||
removeDirectChildren(tblPr, WORD_NAMESPACE, "tblW");
|
||||
const padding = cellToken?.paddingPt ?? tableToken?.paddingPt;
|
||||
if (padding) {
|
||||
removeDirectChildren(tblPr, WORD_NAMESPACE, "tblCellMar");
|
||||
|
||||
Reference in New Issue
Block a user