feat:撤销重做按钮命令注册

pr675
黄云飞 4 years ago
parent 6dae6084df
commit ac1a072bf9

@ -7,16 +7,16 @@ export class Command {
constructor(draw: Draw) { constructor(draw: Draw) {
const historyManager = draw.getHistoryManager() const historyManager = draw.getHistoryManager()
this.undo = historyManager.undo this.undo = historyManager.undo.bind(historyManager)
this.redo = historyManager.redo this.redo = historyManager.redo.bind(historyManager)
} }
public executeUndo() { public executeUndo() {
return this.undo return this.undo()
} }
public executeRedo() { public executeRedo() {
return this.redo return this.redo()
} }
} }

@ -2,6 +2,7 @@ import './style.css'
import Editor from './editor' import Editor from './editor'
window.onload = function () { window.onload = function () {
const canvas = document.querySelector<HTMLCanvasElement>('canvas') const canvas = document.querySelector<HTMLCanvasElement>('canvas')
if (!canvas) return if (!canvas) return
const text = `\n主诉\n发热三天咳嗽五天。\n现病史\n发病前14天内有病历报告社区的旅行时或居住史发病前14天内与新型冠状病毒感染的患者或无症状感染者有接触史发病前14天内解除过来自病历报告社区的发热或有呼吸道症状的患者聚集性发病2周内在小范围如家庭、办公室、学校班级等场所出现2例及以上发热或呼吸道症状的病例。\n既往史\n有糖尿病10年有高血压2年有传染性疾病1年。\n体格检查\nT36.5℃P80bpmR20次/分BP120/80mmHg\n辅助检查\n2020年6月10日普放血细胞比容36.50%偏低4050单核细胞绝对值0.75*10^9/L偏高参考值0.10.6\n门诊诊断\n1.高血压\n处置治疗\n1.超声引导下甲状腺细针穿刺术;\n2.乙型肝炎表面抗体测定;\n3.膜式病变细胞采集术、后颈皮下肤层;\n4.氯化钠注射液 250ml/袋、1袋\n5.七叶皂苷钠片欧开、30mg/片*24/盒、1片、口服、BID每日两次、1天` const text = `\n主诉\n发热三天咳嗽五天。\n现病史\n发病前14天内有病历报告社区的旅行时或居住史发病前14天内与新型冠状病毒感染的患者或无症状感染者有接触史发病前14天内解除过来自病历报告社区的发热或有呼吸道症状的患者聚集性发病2周内在小范围如家庭、办公室、学校班级等场所出现2例及以上发热或呼吸道症状的病例。\n既往史\n有糖尿病10年有高血压2年有传染性疾病1年。\n体格检查\nT36.5℃P80bpmR20次/分BP120/80mmHg\n辅助检查\n2020年6月10日普放血细胞比容36.50%偏低4050单核细胞绝对值0.75*10^9/L偏高参考值0.10.6\n门诊诊断\n1.高血压\n处置治疗\n1.超声引导下甲状腺细针穿刺术;\n2.乙型肝炎表面抗体测定;\n3.膜式病变细胞采集术、后颈皮下肤层;\n4.氯化钠注射液 250ml/袋、1袋\n5.七叶皂苷钠片欧开、30mg/片*24/盒、1片、口服、BID每日两次、1天`
@ -43,4 +44,15 @@ window.onload = function () {
margins: [120, 120, 200, 120] margins: [120, 120, 200, 120]
}) })
console.log('编辑器实例: ', instance) console.log('编辑器实例: ', instance)
// 事件注册
document.querySelector<HTMLDivElement>('.menu-item__undo')!.onclick = function () {
console.log('undo')
instance.command.executeUndo()
}
document.querySelector<HTMLDivElement>('.menu-item__redo')!.onclick = function () {
console.log('redo')
instance.command.executeRedo()
}
} }
Loading…
Cancel
Save