feat: get context content width

This commit is contained in:
Hufe921
2024-08-18 17:43:30 +08:00
parent c3754663ce
commit 187498ed3d
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -789,7 +789,7 @@ export class CommandAdapt {
const row = rowList[rowIndex]
offsetX = row?.offsetX || 0
}
const innerWidth = this.draw.getOriginalInnerWidth() - offsetX
const innerWidth = this.draw.getContextInnerWidth() - offsetX
// colgroup
const colgroup: IColgroup[] = []
const colWidth = innerWidth / col
+12
View File
@@ -390,6 +390,18 @@ export class Draw {
return width - margins[1] - margins[3]
}
public getContextInnerWidth(): number {
const positionContext = this.position.getPositionContext()
if (positionContext.isTable) {
const { index, trIndex, tdIndex } = positionContext
const elementList = this.getOriginalElementList()
const td = elementList[index!].trList![trIndex!].tdList[tdIndex!]
const tdPadding = this.getTdPadding()
return td!.width! - tdPadding[1] - tdPadding[3]
}
return this.getOriginalInnerWidth()
}
public getMargins(): IMargin {
return <IMargin>this.getOriginalMargins().map(m => m * this.options.scale)
}