editorjs-undo icon indicating copy to clipboard operation
editorjs-undo copied to clipboard

Random bug when undoing

Open Jean-PhilippeD opened this issue 1 year ago • 7 comments

Precheck

  • [x] Do a quick search and make sure the bug has not been reported yet.
  • [ ] Please disclose security vulnerabilities privately at [email protected].
  • [x] Finally, be nice and have fun!.

Description

I use undo (and dragDrop which doesn't work by the way) and when I want to rollback some text with ctrl+Z sometimes it's working fine, sometimes it does erase whole blocks, append new empty block at the beginning, duplicates some other blocks...

I have no idea what's happening...

Environment

  • Editor.js version: 2.28.2
  • Plugins you use with their versions: editorjs-undo: 2.0.26
  • Device, Browser, OS: Windows + Bravebrowser even Firefox

Current behavior

Here is the behavior :

bug-undo

I initialize editorJs like this :

editorRef.current = new EditorJS({
    holder: 'editorjs-container',
    autofocus: false,
    onReady: () => {
          const editor = editorRef.current;
          const undo = new Undo({ editor });
          undo.initialize(props.defaultValue);
    },
    tools: editorTools,
    data: props.defaultValue,
    readOnly: props.readOnly
});

Expected behavior

Undo to works fine :)

Jean-PhilippeD avatar Jan 07 '24 11:01 Jean-PhilippeD

Hello I am having this same issue as well. It makes the plugin effectively unusable in practice. Would really appreciate if someone can work on this one. Thank you!!

ARH3 avatar Apr 21 '24 12:04 ARH3

Hello @Jean-PhilippeD, thanks for reporting the issue, we were checking and now with version 2.0.27 it is not occurring, please try with the latest version and let us know if it works for you.

juliandsg0222 avatar Apr 24 '24 21:04 juliandsg0222

Hello @juliandsg0222 . I have the same problem as @Jean-PhilippeD.

editorJS.current = new EditorJS({
        holder: "something",
        data: defaultBlock,
        ...
        onReady() {
          if (!!editorJS.current) {
            new Undo({
              editor: editorJS.current,
              maxLength: 20,
              config: {
                debounceTimer: 100,
                shortcuts: {
                  undo: 'CMD+Z',
                  redo: 'CMD+SHIFT+Z',
                },
              },
            });
            ...
          }
        },
     〜〜
     <div id="something"/>

**If Undo is performed immediately after the block data is mounted with the default value (defaultBlock), all block data will be lost. A subsequent Redo will restore the original data.

It seems to me that this could be avoided by determining if this is not the initial state before attempting to perform Undo, can this be fixed?**

n2-freevas avatar Apr 25 '24 07:04 n2-freevas

Hello @n2-freevas, thanks for the report, could you tell us which versions of editorjs and editorjs-undo you are using?

juliandsg0222 avatar Apr 25 '24 19:04 juliandsg0222

Hi @juliandsg0222 I continue to have the same issue on 2.0.27. Here is a loom video where I walk through the issue.

ARH3 avatar Apr 26 '24 01:04 ARH3

@juliandsg0222 I've been using 2.0.27

n2-freevas avatar May 02 '24 11:05 n2-freevas

Hello everyone 👋 @n2-freevas, @ARH3, @Jean-PhilippeD, We are currently working to fix these issues, at the moment to fix the problem of @ARH3 you can try preserving blank space in a paragraph, this problem had arisen a long time ago, you can check the discussion here https://github.com/codex-team/editor.js/discussions/1868#discussioncomment-1983196

keliumJU avatar May 30 '24 21:05 keliumJU