From ac1a072bf9e1c7b818365c661eeaa6d8bc7f720a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Sat, 13 Nov 2021 23:38:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=92=A4=E9=94=80=E9=87=8D=E5=81=9A?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=91=BD=E4=BB=A4=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/core/command/Command.ts | 8 ++++---- src/main.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/editor/core/command/Command.ts b/src/editor/core/command/Command.ts index 17f47f5..e57765c 100644 --- a/src/editor/core/command/Command.ts +++ b/src/editor/core/command/Command.ts @@ -7,16 +7,16 @@ export class Command { constructor(draw: Draw) { const historyManager = draw.getHistoryManager() - this.undo = historyManager.undo - this.redo = historyManager.redo + this.undo = historyManager.undo.bind(historyManager) + this.redo = historyManager.redo.bind(historyManager) } public executeUndo() { - return this.undo + return this.undo() } public executeRedo() { - return this.redo + return this.redo() } } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 4980919..e6e486f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import './style.css' import Editor from './editor' window.onload = function () { + const canvas = document.querySelector('canvas') if (!canvas) return const text = `\n主诉:\n发热三天,咳嗽五天。\n现病史:\n发病前14天内有病历报告社区的旅行时或居住史;发病前14天内与新型冠状病毒感染的患者或无症状感染者有接触史;发病前14天内解除过来自病历报告社区的发热或有呼吸道症状的患者;聚集性发病,2周内在小范围如家庭、办公室、学校班级等场所,出现2例及以上发热或呼吸道症状的病例。\n既往史:\n有糖尿病10年,有高血压2年,有传染性疾病1年。\n体格检查:\nT:36.5℃,P:80bpm,R:20次/分,BP:120/80mmHg;\n辅助检查:\n2020年6月10日,普放:血细胞比容36.50%(偏低)40~50;单核细胞绝对值0.75*10^9/L(偏高)参考值:0.1~0.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] }) console.log('编辑器实例: ', instance) + + // 事件注册 + document.querySelector('.menu-item__undo')!.onclick = function () { + console.log('undo') + instance.command.executeUndo() + } + document.querySelector('.menu-item__redo')!.onclick = function () { + console.log('redo') + instance.command.executeRedo() + } + } \ No newline at end of file