Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Redo" button not working #436

Open
krsaulitis opened this issue Jul 22, 2024 · 7 comments
Open

"Redo" button not working #436

krsaulitis opened this issue Jul 22, 2024 · 7 comments
Labels
bug in dependency bug Something isn't working

Comments

@krsaulitis
Copy link

Filament Version

v3.2.95

Plugin Version

v3.4.5

PHP Version

PHP 8.3.8

Problem description

The "redo" button or shortcut is not working in editor, nothing happens.

Screen.Recording.2024-07-22.at.13.39.25.mov

Expected behavior

The "redo" button reverts the changes after pressing undo.

Steps to reproduce

  • Create a clean Laravel + FilamentPHP + TipTap Editor project
  • Add TiptapEditor block to form schema
  • Write some text into the editor, press undo, then redo

Reproduction repository

No response

Relevant log output

No response

@krsaulitis krsaulitis added the bug Something isn't working label Jul 22, 2024
@awcodes
Copy link
Owner

awcodes commented Jul 29, 2024

ueberdosis/tiptap#4821

@tlaverdure
Copy link

Hey there, it looks like there is some sort of recursion in this code which is causing the issue:

  • User types in editor...
  • onUpdate() sets this.state to editor.getJSON():
    onUpdate({editor}) {
    _this.updatedAt = Date.now();
    _this.state = editor.isEmpty ? null : editor.getJSON();
    },
  • Watch the state for changes:
    this.$watch('state', (newState, oldState) => {
    if (typeof newState !== "undefined") {
    if (!isEqual(oldState, Alpine.raw(newState))) {
    this.updateEditorContent(newState)
    }
    }
    });
    },
  • updateEditorContent() with current state:
    updateEditorContent(content) {
    if (editor.isEditable) {
    const {from, to} = editor.state.selection;
    editor.commands.setContent(content, true);
    editor.chain().focus().setTextSelection({from, to}).run();
    }
    },

I'm not really sure what the intent of updateEditorContent() is since it is called several times in various contexts, but if you comment editor.commands.setContent(content, true) the redo button works.

@awcodes
Copy link
Owner

awcodes commented Nov 1, 2024

hmm. Thanks for digging into the issue.

updateEditorContent is used to update the editor from outside of it, ie, through a livewire event or similar.

You may be right about the recursion though.

I'll have to give it some thought.

@awcodes
Copy link
Owner

awcodes commented Nov 18, 2024

Investigated this further. The issue is still in the Tiptap package itself. 'Redo' is not firing the 'onUpdate' event in Tiptap itself, meaning that the state of the allpine component is not getting updated.

While removing the setter in 'onUpdate' makes it work in the editor itself, it doesn't update the state in alpine, so saving the form wouldn't have the updated state of the redo.

@awcodes
Copy link
Owner

awcodes commented Nov 18, 2024

This is still a bug in the dependency, but I have a work around working in another version of the plugin I'm working on. Will try to get it back ported into this plugin if I can.

@yafkari
Copy link

yafkari commented Feb 5, 2025

Hey, came across this issue ueberdosis/tiptap#4821 then here, any update on this?

@awcodes
Copy link
Owner

awcodes commented Feb 5, 2025

Was working on this the other day. Still working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in dependency bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants