0

I'm using CKEDITOR's Inline toolbar to edit text. The plugin does a lot of DOM changes and I'm fine with that.

What I want to do is to remove all attributes, elements, classes, ids, and everything that CKEDITOR added to my DOM. I can simply find all the changes and remove them individually but I want to know if there is an easier way. Also I want to be able to undo these changes on button click.

UserDy
  • 327
  • 5
  • 22

2 Answers2

0

The closest that you can get using the API is by calling editor.destroy(); but I think that some people stated that it still leaves some artifacts in inline editing.

AlfonsoML
  • 12,634
  • 2
  • 46
  • 53
0

You need to look into getData and setData methods here

What you can do is to save the old state in a variable and then you can replace it using the setData method

var old = CKEDITOR.instances.editor1.getData();
$('#undo').click(function(e){
    e.preventDefault();
    CKEDITOR.instances.editor1.setData(old);
});

EXAMPLE

Khawer Zeshan
  • 9,470
  • 6
  • 40
  • 63