@@ -13,6 +13,7 @@ import {
1313 type ImagePasteMethod ,
1414 setGlobalMermaidDefaultMode ,
1515} from " @/core" ;
16+ import { undo , redo } from " prosemirror-history" ;
1617import { uploadImage } from " @/renderer/services/api" ;
1718import { AIService } from " @/renderer/services/ai" ;
1819import { useAIConfig } from " @/renderer/hooks/useAIConfig" ;
@@ -278,6 +279,8 @@ onUnmounted(() => {
278279 emitter .off (" sourceView:toggle" , handleSourceViewToggle );
279280 emitter .off (" outline:scrollTo" , handleOutlineScrollTo );
280281 emitter .off (" editor:reload" , handleEditorReload );
282+ window .electronAPI .removeListener ?.(" editor:undo" , handleMenuUndo );
283+ window .electronAPI .removeListener ?.(" editor:redo" , handleMenuRedo );
281284});
282285
283286// 处理源码模式切换事件(仅活跃编辑器响应)
@@ -302,6 +305,20 @@ function handleOutlineScrollTo(pos: unknown) {
302305}
303306emitter .on (" outline:scrollTo" , handleOutlineScrollTo );
304307
308+ // 处理菜单栏的撤销/重做(仅活跃编辑器响应)
309+ function handleMenuUndo() {
310+ if (! props .isActive || ! editor ) return ;
311+ const view = editor .view ;
312+ undo (view .state , view .dispatch .bind (view ));
313+ }
314+ function handleMenuRedo() {
315+ if (! props .isActive || ! editor ) return ;
316+ const view = editor .view ;
317+ redo (view .state , view .dispatch .bind (view ));
318+ }
319+ window .electronAPI .on ?.(" editor:undo" , handleMenuUndo );
320+ window .electronAPI .on ?.(" editor:redo" , handleMenuRedo );
321+
305322// 处理编辑器重载事件(仅活跃编辑器响应)
306323function handleEditorReload() {
307324 if (! props .isActive || ! containerRef .value ) return ;
0 commit comments