feat:增加打印功能

This commit is contained in:
黄云飞
2021-11-15 19:47:36 +08:00
parent 9462ba06fb
commit 0df6619cc3
6 changed files with 53 additions and 15 deletions
+17 -6
View File
@@ -1,22 +1,33 @@
import { printImageBase64 } from "../../utils/print"
import { Draw } from "../draw/Draw"
export class Command {
private undo: Function
private redo: Function
private static undo: Function
private static redo: Function
private static getDataURL: Function
constructor(draw: Draw) {
const historyManager = draw.getHistoryManager()
this.undo = historyManager.undo.bind(historyManager)
this.redo = historyManager.redo.bind(historyManager)
Command.undo = historyManager.undo.bind(historyManager)
Command.redo = historyManager.redo.bind(historyManager)
Command.getDataURL = draw.getDataURL.bind(draw)
}
// 撤销、重做、格式刷、清除格式
public executeUndo() {
return this.undo()
return Command.undo()
}
public executeRedo() {
return this.redo()
return Command.redo()
}
// 字体变大、字体变小、加粗、斜体、下划线、删除线、字体颜色、背景色
// 搜索、打印
public executePrint() {
return printImageBase64(Command.getDataURL())
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
import { ZERO } from "../../dataset/constant/Common"
import { KeyMap } from "../../dataset/enum/Keymap"
import { IElement } from "../../interface/Element"
import { writeText } from "../../utils"
import { writeText } from "../../utils/clipboard"
import { Cursor } from "../cursor/Cursor"
import { Draw } from "../draw/Draw"
import { HistoryManager } from "../history/HistoryManager"