fix: copy highlight element #193

This commit is contained in:
Hufe921
2023-06-06 22:22:25 +08:00
parent e4ea580263
commit 88ebfd2f74
2 changed files with 19 additions and 16 deletions
+11 -11
View File
@@ -1178,6 +1178,17 @@ export class Draw {
leftTop: [x, y]
}
} = positionList[curRow.startIndex + j]
const preElement = curRow.elementList[j - 1]
// 元素高亮记录
if (element.highlight) {
// 高亮元素相连需立即绘制,并记录下一元素坐标
if (preElement && preElement.highlight && preElement.highlight !== element.highlight) {
this.highlight.render(ctx)
}
this.highlight.recordFillInfo(ctx, x, y, metrics.width, curRow.height, element.highlight)
} else if (preElement?.highlight) {
this.highlight.render(ctx)
}
// 元素绘制
if (element.type === ElementType.IMAGE) {
this._drawRichText(ctx)
@@ -1228,7 +1239,6 @@ export class Draw {
} else {
this.textParticle.record(ctx, element, x, y + offsetY)
}
const preElement = curRow.elementList[j - 1]
// 下划线记录
if (element.underline) {
this.underline.recordFillInfo(ctx, x, y + curRow.height, metrics.width, 0, element.color)
@@ -1241,16 +1251,6 @@ export class Draw {
} else if (preElement?.strikeout) {
this.strikeout.render(ctx)
}
// 元素高亮记录
if (element.highlight) {
// 高亮元素相连需立即绘制,并记录下一元素坐标
if (preElement && preElement.highlight && preElement.highlight !== element.highlight) {
this.highlight.render(ctx)
}
this.highlight.recordFillInfo(ctx, x, y, metrics.width, curRow.height, element.highlight)
} else if (preElement?.highlight) {
this.highlight.render(ctx)
}
// 选区记录
const { zone: currentZone, startIndex, endIndex } = this.range.getRange()
if (currentZone === zone && startIndex !== endIndex && startIndex <= index && index <= endIndex) {