feat:add paper size select

This commit is contained in:
黄云飞
2022-08-31 17:08:54 +08:00
parent 905fdbc929
commit f58060bd7f
7 changed files with 89 additions and 8 deletions
+7 -1
View File
@@ -66,6 +66,7 @@ export class Command {
private static pageScaleRecovery: CommandAdapt['pageScaleRecovery']
private static pageScaleMinus: CommandAdapt['pageScaleMinus']
private static pageScaleAdd: CommandAdapt['pageScaleAdd']
private static paperSize: CommandAdapt['paperSize']
private static insertElementList: CommandAdapt['insertElementList']
private static removeControl: CommandAdapt['removeControl']
@@ -128,6 +129,7 @@ export class Command {
Command.pageScaleRecovery = adapt.pageScaleRecovery.bind(adapt)
Command.pageScaleMinus = adapt.pageScaleMinus.bind(adapt)
Command.pageScaleAdd = adapt.pageScaleAdd.bind(adapt)
Command.paperSize = adapt.paperSize.bind(adapt)
Command.insertElementList = adapt.insertElementList.bind(adapt)
Command.removeControl = adapt.removeControl.bind(adapt)
}
@@ -352,7 +354,7 @@ export class Command {
return Command.getWordCount()
}
// 页面模式、页面缩放
// 页面模式、页面缩放、纸张大小
public executePageMode(payload: PageMode) {
return Command.pageMode(payload)
}
@@ -369,6 +371,10 @@ export class Command {
return Command.pageScaleAdd()
}
public executePaperSize(width: number, height: number) {
return Command.paperSize(width, height)
}
// 通用
public executeInsertElementList(payload: IElement[]) {
return Command.insertElementList(payload)
+4
View File
@@ -1394,6 +1394,10 @@ export class CommandAdapt {
}
}
public paperSize(width: number, height: number) {
this.draw.setPaperSize(width, height)
}
public insertElementList(payload: IElement[]) {
if (!payload.length) return
const isReadonly = this.draw.isReadonly()
+24 -2
View File
@@ -440,7 +440,10 @@ export class Draw {
canvas.style.height = `${height}px`
canvas.height = height * dpr
}
this.render({ isSubmitHistory: false, isSetCursor: false })
this.render({
isSubmitHistory: false,
isSetCursor: false
})
// 回调
setTimeout(() => {
if (this.listener.pageModeChange) {
@@ -461,12 +464,31 @@ export class Draw {
p.style.height = `${height}px`
p.style.marginBottom = `${this.getPageGap()}px`
})
this.render({ isSubmitHistory: false, isSetCursor: false })
this.render({
isSubmitHistory: false,
isSetCursor: false
})
if (this.listener.pageScaleChange) {
this.listener.pageScaleChange(payload)
}
}
public setPaperSize(width: number, height: number) {
this.options.width = width
this.options.height = height
this.container.style.width = `${width}px`
this.pageList.forEach(p => {
p.width = width
p.height = height
p.style.width = `${width}px`
p.style.height = `${height}px`
})
this.render({
isSubmitHistory: false,
isSetCursor: false
})
}
public getValue(): IEditorResult {
// 配置
const { width, height, margins, watermark } = this.options