From d1abefab02af6a8a024d1326b6a18c497ba346f8 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 2 Dec 2025 22:58:29 +0800 Subject: [PATCH] enhance(ux): add undo/redo on mobile --- .../mobile/components/editor_toolbar.cljs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/mobile/components/editor_toolbar.cljs b/src/main/mobile/components/editor_toolbar.cljs index d95939decb..8f1901b8b7 100644 --- a/src/main/mobile/components/editor_toolbar.cljs +++ b/src/main/mobile/components/editor_toolbar.cljs @@ -3,6 +3,7 @@ (:require [frontend.colors :as colors] [frontend.commands :as commands] [frontend.handler.editor :as editor-handler] + [frontend.handler.history :as history] [frontend.mobile.camera :as mobile-camera] [frontend.mobile.haptics :as haptics] [frontend.mobile.util :as mobile-util] @@ -67,6 +68,26 @@ (blur-if-compositing) (editor-handler/indent-outdent indent?))}) +(defn- undo-action + [] + {:id "undo" + :title "Undo" + :system-icon "arrow.uturn.backward" + :event? true + :handler (fn [] + (blur-if-compositing) + (history/undo!))}) + +(defn- redo-action + [] + {:id "redo" + :title "Redo" + :system-icon "arrow.uturn.forward" + :event? true + :handler (fn [] + (blur-if-compositing) + (history/redo!))}) + (defn- todo-action [] {:id "todo" @@ -143,20 +164,24 @@ (let [audio (audio-action) keyboard (keyboard-action) main-actions (if quick-add? - [(todo-action) + [(undo-action) + (todo-action) audio (camera-action) (tag-action) (page-ref-action) (indent-outdent-action false) - (indent-outdent-action true)] - [(todo-action) + (indent-outdent-action true) + (redo-action)] + [(undo-action) + (todo-action) (indent-outdent-action false) (indent-outdent-action true) (tag-action) (camera-action) (page-ref-action) - (slash-action)])] + (slash-action) + (redo-action)])] {:main main-actions :trailing (if quick-add? (capture-action) keyboard)}))