|
|
|
@ -37,6 +37,8 @@ import { Watermark } from './frame/Watermark'
|
|
|
|
import { EditorMode } from '../../dataset/enum/Editor'
|
|
|
|
import { EditorMode } from '../../dataset/enum/Editor'
|
|
|
|
import { Control } from './control/Control'
|
|
|
|
import { Control } from './control/Control'
|
|
|
|
import { zipElementList } from '../../utils/element'
|
|
|
|
import { zipElementList } from '../../utils/element'
|
|
|
|
|
|
|
|
import { CheckboxParticle } from './particle/CheckboxParticle'
|
|
|
|
|
|
|
|
import { DeepRequired } from '../../interface/Common'
|
|
|
|
|
|
|
|
|
|
|
|
export class Draw {
|
|
|
|
export class Draw {
|
|
|
|
|
|
|
|
|
|
|
|
@ -46,7 +48,7 @@ export class Draw {
|
|
|
|
private ctxList: CanvasRenderingContext2D[]
|
|
|
|
private ctxList: CanvasRenderingContext2D[]
|
|
|
|
private pageNo: number
|
|
|
|
private pageNo: number
|
|
|
|
private mode: EditorMode
|
|
|
|
private mode: EditorMode
|
|
|
|
private options: Required<IEditorOption>
|
|
|
|
private options: DeepRequired<IEditorOption>
|
|
|
|
private position: Position
|
|
|
|
private position: Position
|
|
|
|
private elementList: IElement[]
|
|
|
|
private elementList: IElement[]
|
|
|
|
private listener: Listener
|
|
|
|
private listener: Listener
|
|
|
|
@ -73,6 +75,7 @@ export class Draw {
|
|
|
|
private pageBreakParticle: PageBreakParticle
|
|
|
|
private pageBreakParticle: PageBreakParticle
|
|
|
|
private superscriptParticle: SuperscriptParticle
|
|
|
|
private superscriptParticle: SuperscriptParticle
|
|
|
|
private subscriptParticle: SubscriptParticle
|
|
|
|
private subscriptParticle: SubscriptParticle
|
|
|
|
|
|
|
|
private checkboxParticle: CheckboxParticle
|
|
|
|
private control: Control
|
|
|
|
private control: Control
|
|
|
|
|
|
|
|
|
|
|
|
private rowList: IRow[]
|
|
|
|
private rowList: IRow[]
|
|
|
|
@ -83,7 +86,7 @@ export class Draw {
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
container: HTMLDivElement,
|
|
|
|
container: HTMLDivElement,
|
|
|
|
options: Required<IEditorOption>,
|
|
|
|
options: DeepRequired<IEditorOption>,
|
|
|
|
elementList: IElement[],
|
|
|
|
elementList: IElement[],
|
|
|
|
listener: Listener
|
|
|
|
listener: Listener
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
@ -120,6 +123,7 @@ export class Draw {
|
|
|
|
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()
|
|
|
|
|
|
|
|
this.checkboxParticle = new CheckboxParticle(this)
|
|
|
|
this.control = new Control(this)
|
|
|
|
this.control = new Control(this)
|
|
|
|
|
|
|
|
|
|
|
|
new ScrollObserver(this)
|
|
|
|
new ScrollObserver(this)
|
|
|
|
@ -249,7 +253,7 @@ export class Draw {
|
|
|
|
return this.ctxList[this.pageNo]
|
|
|
|
return this.ctxList[this.pageNo]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getOptions(): Required<IEditorOption> {
|
|
|
|
public getOptions(): DeepRequired<IEditorOption> {
|
|
|
|
return this.options
|
|
|
|
return this.options
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -563,6 +567,12 @@ export class Draw {
|
|
|
|
element.width = innerWidth
|
|
|
|
element.width = innerWidth
|
|
|
|
metrics.width = innerWidth
|
|
|
|
metrics.width = innerWidth
|
|
|
|
metrics.height = this.options.defaultSize
|
|
|
|
metrics.height = this.options.defaultSize
|
|
|
|
|
|
|
|
} else if (element.type === ElementType.CHECKBOX) {
|
|
|
|
|
|
|
|
const { width, height, gap } = this.options.checkbox
|
|
|
|
|
|
|
|
const elementWidth = (width + gap * 2) * scale
|
|
|
|
|
|
|
|
element.width = elementWidth
|
|
|
|
|
|
|
|
metrics.width = elementWidth
|
|
|
|
|
|
|
|
metrics.height = height * scale
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 设置上下标真实字体尺寸
|
|
|
|
// 设置上下标真实字体尺寸
|
|
|
|
const size = element.size || this.options.defaultSize
|
|
|
|
const size = element.size || this.options.defaultSize
|
|
|
|
@ -697,6 +707,9 @@ export class Draw {
|
|
|
|
if (this.mode !== EditorMode.CLEAN) {
|
|
|
|
if (this.mode !== EditorMode.CLEAN) {
|
|
|
|
this.pageBreakParticle.render(ctx, element, x, y)
|
|
|
|
this.pageBreakParticle.render(ctx, element, x, y)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (element.type === ElementType.CHECKBOX) {
|
|
|
|
|
|
|
|
this.textParticle.complete()
|
|
|
|
|
|
|
|
this.checkboxParticle.render(ctx, element, x, y + offsetY)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.textParticle.record(ctx, element, x, y + offsetY)
|
|
|
|
this.textParticle.record(ctx, element, x, y + offsetY)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|