fix: scaling table and separator elements error #326
This commit is contained in:
@@ -199,7 +199,7 @@ export class Draw {
|
|||||||
this.footer = new Footer(this, data.footer)
|
this.footer = new Footer(this, data.footer)
|
||||||
this.hyperlinkParticle = new HyperlinkParticle(this)
|
this.hyperlinkParticle = new HyperlinkParticle(this)
|
||||||
this.dateParticle = new DateParticle(this)
|
this.dateParticle = new DateParticle(this)
|
||||||
this.separatorParticle = new SeparatorParticle()
|
this.separatorParticle = new SeparatorParticle(this)
|
||||||
this.pageBreakParticle = new PageBreakParticle(this)
|
this.pageBreakParticle = new PageBreakParticle(this)
|
||||||
this.superscriptParticle = new SuperscriptParticle()
|
this.superscriptParticle = new SuperscriptParticle()
|
||||||
this.subscriptParticle = new SubscriptParticle()
|
this.subscriptParticle = new SubscriptParticle()
|
||||||
@@ -1128,7 +1128,7 @@ export class Draw {
|
|||||||
const rowHeight = rowList.reduce((pre, cur) => pre + cur.height, 0)
|
const rowHeight = rowList.reduce((pre, cur) => pre + cur.height, 0)
|
||||||
td.rowList = rowList
|
td.rowList = rowList
|
||||||
// 移除缩放导致的行高变化-渲染时会进行缩放调整
|
// 移除缩放导致的行高变化-渲染时会进行缩放调整
|
||||||
const curTdHeight = (rowHeight + tdPaddingHeight) / scale
|
const curTdHeight = rowHeight / scale + tdPaddingHeight
|
||||||
// 内容高度大于当前单元格高度需增加
|
// 内容高度大于当前单元格高度需增加
|
||||||
if (td.height! < curTdHeight) {
|
if (td.height! < curTdHeight) {
|
||||||
const extraHeight = curTdHeight - td.height!
|
const extraHeight = curTdHeight - td.height!
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export class CheckboxParticle {
|
|||||||
} = this.options
|
} = this.options
|
||||||
const { metrics, checkbox } = element
|
const { metrics, checkbox } = element
|
||||||
// left top 四舍五入避免1像素问题
|
// left top 四舍五入避免1像素问题
|
||||||
const left = Math.round(x + gap)
|
const left = Math.round(x + gap * scale)
|
||||||
const top = Math.round(y - metrics.height + lineWidth)
|
const top = Math.round(y - metrics.height + lineWidth)
|
||||||
const width = metrics.width - gap * 2 * scale
|
const width = metrics.width - gap * 2 * scale
|
||||||
const height = metrics.height
|
const height = metrics.height
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
|
import { DeepRequired } from '../../../interface/Common'
|
||||||
|
import { IEditorOption } from '../../../interface/Editor'
|
||||||
import { IRowElement } from '../../../interface/Row'
|
import { IRowElement } from '../../../interface/Row'
|
||||||
|
import { Draw } from '../Draw'
|
||||||
export class SeparatorParticle {
|
export class SeparatorParticle {
|
||||||
|
private options: DeepRequired<IEditorOption>
|
||||||
|
|
||||||
|
constructor(draw: Draw) {
|
||||||
|
this.options = draw.getOptions()
|
||||||
|
}
|
||||||
|
|
||||||
public render(
|
public render(
|
||||||
ctx: CanvasRenderingContext2D,
|
ctx: CanvasRenderingContext2D,
|
||||||
element: IRowElement,
|
element: IRowElement,
|
||||||
@@ -7,6 +16,7 @@ export class SeparatorParticle {
|
|||||||
y: number
|
y: number
|
||||||
) {
|
) {
|
||||||
ctx.save()
|
ctx.save()
|
||||||
|
ctx.lineWidth = this.options.scale
|
||||||
if (element.color) {
|
if (element.color) {
|
||||||
ctx.strokeStyle = element.color
|
ctx.strokeStyle = element.color
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ export class TableParticle {
|
|||||||
// 仅外边框
|
// 仅外边框
|
||||||
const isExternalBorderType = borderType === TableBorder.EXTERNAL
|
const isExternalBorderType = borderType === TableBorder.EXTERNAL
|
||||||
ctx.save()
|
ctx.save()
|
||||||
|
ctx.lineWidth = scale
|
||||||
// 渲染边框
|
// 渲染边框
|
||||||
if (!isEmptyBorderType) {
|
if (!isEmptyBorderType) {
|
||||||
this._drawOuterBorder({
|
this._drawOuterBorder({
|
||||||
|
|||||||
Reference in New Issue
Block a user