feat: get context content width

main
Hufe921 2 years ago
parent c3754663ce
commit 187498ed3d

@ -789,7 +789,7 @@ export class CommandAdapt {
const row = rowList[rowIndex] const row = rowList[rowIndex]
offsetX = row?.offsetX || 0 offsetX = row?.offsetX || 0
} }
const innerWidth = this.draw.getOriginalInnerWidth() - offsetX const innerWidth = this.draw.getContextInnerWidth() - offsetX
// colgroup // colgroup
const colgroup: IColgroup[] = [] const colgroup: IColgroup[] = []
const colWidth = innerWidth / col const colWidth = innerWidth / col

@ -390,6 +390,18 @@ export class Draw {
return width - margins[1] - margins[3] 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 { public getMargins(): IMargin {
return <IMargin>this.getOriginalMargins().map(m => m * this.options.scale) return <IMargin>this.getOriginalMargins().map(m => m * this.options.scale)
} }

Loading…
Cancel
Save