givanz / VvvebJs

Drag and drop page builder library written in vanilla javascript without dependencies or build tools.
https://www.vvveb.com/vvvebjs/editor.html
Apache License 2.0
7.07k stars 1.62k forks source link

The logic of adding mutation is incorrect #238

Open tuanla8793 opened 2 years ago

tuanla8793 commented 2 years ago

File: libs\builder\undo.js Current code

    addMutation : function(mutation) {
        /*
            this.mutations.push(mutation);
            this.undoIndex++;
        */
        Vvveb.Builder.frameBody.trigger("vvveb.undo.add");
        this.mutations.splice(++this.undoIndex, 0, mutation);
     },

I updated so undo and redo work correctly

    addMutation : function(mutation) {
        /*
            this.mutations.push(mutation);
            this.undoIndex++;
        */
        Vvveb.Builder.frameBody.trigger("vvveb.undo.add");
        this.mutations.splice(++this.undoIndex, this.mutations.length - this.undoIndex, mutation);
     },

Please check and update the repository source.

givanz commented 2 years ago

Thanks for the fix, I included it in the last commit.