Skip to content

Commit

Permalink
fix: disable highlight style in print mode #893
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Nov 18, 2024
1 parent e5480a3 commit 49360fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 17 additions & 10 deletions src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,7 @@ export class Draw {
lineNumber,
pageBorder
} = this.options
const isPrintMode = this.mode === EditorMode.PRINT
const innerWidth = this.getInnerWidth()
const ctx = this.ctxList[pageNo]
// 判断当前激活区域-非正文区域时元素透明度降低
Expand All @@ -2393,9 +2394,11 @@ export class Draw {
// 绘制背景
this.background.render(ctx, pageNo)
// 绘制区域
this.area.render(ctx, pageNo)
if (!isPrintMode) {
this.area.render(ctx, pageNo)
}
// 绘制页边距
if (this.mode !== EditorMode.PRINT) {
if (!isPrintMode) {
this.margin.render(ctx, pageNo)
}
// 渲染衬于文字下方元素
Expand All @@ -2404,7 +2407,9 @@ export class Draw {
imgDisplays: [ImageDisplay.FLOAT_BOTTOM]
})
// 控件高亮
this.control.renderHighlightList(ctx, pageNo)
if (!isPrintMode) {
this.control.renderHighlightList(ctx, pageNo)
}
// 渲染元素
const index = rowList[0]?.startIndex
this.drawRow(ctx, {
Expand Down Expand Up @@ -2436,7 +2441,7 @@ export class Draw {
imgDisplays: [ImageDisplay.FLOAT_TOP, ImageDisplay.SURROUND]
})
// 搜索匹配绘制
if (this.search.getSearchKeyword()) {
if (!isPrintMode && this.search.getSearchKeyword()) {
this.search.render(ctx, pageNo)
}
// 绘制水印
Expand Down Expand Up @@ -2550,13 +2555,15 @@ export class Draw {
this.position.computePositionList()
// 区域信息
this.area.compute()
// 搜索信息
const searchKeyword = this.search.getSearchKeyword()
if (searchKeyword) {
this.search.compute(searchKeyword)
if (this.mode !== EditorMode.PRINT) {
// 搜索信息
const searchKeyword = this.search.getSearchKeyword()
if (searchKeyword) {
this.search.compute(searchKeyword)
}
// 控件关键词高亮
this.control.computeHighlightList()
}
// 控件关键词高亮
this.control.computeHighlightList()
}
// 清除光标等副作用
this.imageObserver.clearAll()
Expand Down
4 changes: 1 addition & 3 deletions src/editor/core/draw/interactive/Area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IInsertAreaOption,
ISetAreaPropertiesOption
} from '../../../interface/Area'
import { EditorMode, EditorZone } from '../../../dataset/enum/Editor'
import { EditorZone } from '../../../dataset/enum/Editor'
import { LocationPosition } from '../../../dataset/enum/Common'
import { RangeManager } from '../../range/RangeManager'
import { Zone } from '../../zone/Zone'
Expand Down Expand Up @@ -92,8 +92,6 @@ export class Area {

public render(ctx: CanvasRenderingContext2D, pageNo: number) {
if (!this.areaInfoMap.size) return
const mode = this.draw.getMode()
if (mode === EditorMode.CLEAN || mode === EditorMode.PRINT) return
ctx.save()
const margins = this.draw.getMargins()
const width = this.draw.getInnerWidth()
Expand Down

0 comments on commit 49360fd

Please sign in to comment.