refactor: date element renderer #460
This commit is contained in:
@@ -1640,8 +1640,16 @@ export class Draw {
|
||||
this._drawRichText(ctx)
|
||||
this.hyperlinkParticle.render(ctx, element, x, y + offsetY)
|
||||
} else if (element.type === ElementType.DATE) {
|
||||
const nextElement = curRow.elementList[j + 1]
|
||||
// 释放之前的
|
||||
if (!preElement || preElement.dateId !== element.dateId) {
|
||||
this._drawRichText(ctx)
|
||||
this.dateParticle.render(ctx, element, x, y + offsetY)
|
||||
}
|
||||
this.textParticle.record(ctx, element, x, y + offsetY)
|
||||
if (!nextElement || nextElement.dateId !== element.dateId) {
|
||||
// 手动触发渲染
|
||||
this._drawRichText(ctx)
|
||||
}
|
||||
} else if (element.type === ElementType.SUPERSCRIPT) {
|
||||
this._drawRichText(ctx)
|
||||
this.superscriptParticle.render(ctx, element, x, y + offsetY)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ElementType } from '../../../../dataset/enum/Element'
|
||||
import { IElement, IElementPosition } from '../../../../interface/Element'
|
||||
import { IRowElement } from '../../../../interface/Row'
|
||||
import { formatElementContext } from '../../../../utils/element'
|
||||
import { RangeManager } from '../../../range/RangeManager'
|
||||
import { Draw } from '../../Draw'
|
||||
@@ -130,19 +129,4 @@ export class DateParticle {
|
||||
startTop
|
||||
})
|
||||
}
|
||||
|
||||
public render(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
element: IRowElement,
|
||||
x: number,
|
||||
y: number
|
||||
) {
|
||||
ctx.save()
|
||||
ctx.font = element.style
|
||||
if (element.color) {
|
||||
ctx.fillStyle = element.color
|
||||
}
|
||||
ctx.fillText(element.value, x, y)
|
||||
ctx.restore()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user