From 65453b5a3ab942dfebbe6c14598ed4c84970098d Mon Sep 17 00:00:00 2001 From: ShawnPhang Date: Wed, 12 Feb 2025 18:53:50 +0800 Subject: [PATCH] fix: Text-editing undo bug --- src/mixins/methods/dealWithCtrl.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/mixins/methods/dealWithCtrl.ts b/src/mixins/methods/dealWithCtrl.ts index 46ff46f..01481ce 100644 --- a/src/mixins/methods/dealWithCtrl.ts +++ b/src/mixins/methods/dealWithCtrl.ts @@ -3,7 +3,7 @@ * @Date: 2022-03-09 16:29:54 * @Description: 处理和ctrl建相关的操作 * @LastEditors: ShawnPhang - * @LastEditTime: 2024-04-18 17:35:57 + * @LastEditTime: 2025-02-12 18:52:35 */ // import store from '@/store' import handlePaste from './handlePaste' @@ -84,15 +84,12 @@ function paste() { * 撤销 */ function undo(shiftKey: any) { + const widgetStore = useWidgetStore() const historyStore = useHistoryStore() - shiftKey ? historyStore.handleHistory("redo") : historyStore.handleHistory('undo') - - // if (shiftKey) { - // if (!(historyStore.dHistoryParams.index === historyStore.dHistoryParams.length - 1)) { - // historyStore.handleHistory("redo") - // } - // } else if (historyStore.dHistoryParams.index !== -1) { - // // this.handleHistory('undo') - // historyStore.handleHistory('undo') - // } + + const { type, editable }: any = widgetStore.dActiveElement + if (type === 'w-text') { + // 不在编辑状态则执行撤销操作 + !editable && (shiftKey ? historyStore.handleHistory('redo') : historyStore.handleHistory('undo')) + } else shiftKey ? historyStore.handleHistory('redo') : historyStore.handleHistory('undo') }