Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix undo/redo buttons in editor

Ammar Ahmed1e837f2a9c3f
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index ba6ec512f..41b167d36 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -78,7 +78,15 @@ const Tiptap = ({
const isFocusedRef = useRef<boolean>(false);
const [undo, setUndo] = useState(false);
const [redo, setRedo] = useState(false);
+ const valueRef = useRef({
+ undo,
+ redo
+ });
tabRef.current = tab;
+ valueRef.current = {
+ undo,
+ redo
+ };
function restoreNoteSelection(state?: NoteState) {
try {
@@ -127,8 +135,14 @@ const Tiptap = ({
editor as Editor,
transaction.getMeta("ignoreEdit")
);
- },
+ if (valueRef.current.undo !== editor.can().undo()) {
+ setUndo(editor.can().undo());
+ }
+ if (valueRef.current.redo !== editor.can().redo()) {
+ setRedo(editor.can().redo());
+ }
+ },
openAttachmentPicker: (type) => {
globalThis.editorControllers[tab.id]?.openFilePicker(type);
return true;