From 73b73540218ed67974014ad7449fbc911c5f3893 Mon Sep 17 00:00:00 2001 From: Wang Zhi Date: Wed, 6 Mar 2024 17:09:08 +0800 Subject: [PATCH] feat: add `canUndo()` and `canRedo()`. (#155) --- packages/history/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/history/index.ts b/packages/history/index.ts index ea5b992..1311993 100644 --- a/packages/history/index.ts +++ b/packages/history/index.ts @@ -143,6 +143,10 @@ class History { } } + canRedo() { + return this.stack.redo.length > 0; + } + redo() { this.change('redo', 'undo'); } @@ -152,6 +156,10 @@ class History { transformStack(this.stack.redo, op); } + canUndo() { + return this.stack.undo.length > 0; + } + undo() { this.change('undo', 'redo'); }