Skip to content

How to add async command to Tiptap editor #4825

Closed Answered by nperez0111
piszczu4 asked this question in Questions & Help
Discussion options

You must be logged in to vote

Tiptap does not support async commands, since the transform they build via chaining is expected to be executed synchronously. If you need to do something async, you have that in your function, just cannot return the promise, only return true to indicate that it actually executed whatever action.

Example:

      pasteHTML: () => ({ dispatch }) => {

      if (dispatch) {
        (async () => {
           let text: string = '';
           text = await window.navigator.clipboard.readText();
           this.editor
            .chain()
            .focus()
            .command(({ view }) => {
               view.pasteHTML(text);
               return true;
             });
        })()
        r…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@nperez0111
Comment options

Answer selected by nperez0111
Comment options

You must be logged in to vote
1 reply
@nperez0111
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants