2

Is there a way to remove only the last snapshot in the CKEditor undo stack or can i replace it with another.Should i implement it on my own?

Example:

Step 1

Step 2 --should be removed and replaced with step 3 (On given situation)

Step 3 -- should become step 2

This feature should be available only if special event occurs.

Jose Luis
  • 3,307
  • 3
  • 36
  • 53
radpet
  • 701
  • 1
  • 5
  • 16

1 Answers1

3

If your undo snapshots are a result of user actions, following this way:

  1. Step 1.
  2. Step 2.
  3. CKEDITOR.instances.editor.fire( 'lockSnapshot' )
  4. Step 3.
  5. CKEDITOR.instances.editor.fire( 'unlockSnapshot' )

Of course, you have to detect what's going on and fire the right event at the right time.

If changes to the content are done from code, editor#updateSnapshot event would even be better:

function() {
    editor.fire( 'saveSnapshot' );
    editor.document.body.append(...);
    // Makes new changes following the last undo snapshot a part of it.
    editor.fire( 'updateSnapshot' );
    ..
}
oleq
  • 15,697
  • 1
  • 38
  • 65
  • But what if i will have an image taken and want to pop it (remove). I cannot detect when to lock the snapshot? – radpet Apr 02 '15 at 09:07
  • 1
    You can't pop it. You can override it using `editor#updateSnapshot`. But we don't know enough about what you want to achieve (the broader picture), so it's hard to say whether this is the right option. Maybe you need to do something very different. – Reinmar Apr 02 '15 at 14:58
  • Could you provide some extended sample? I.e. HTML corresponding with each step. – oleq Apr 02 '15 at 14:59
  • Right, so i am building the plugin from that post http://stackoverflow.com/questions/29322028/why-ckeditor-ignores-empty-div-or-is-it-something-else and i what to workaround the bug with the feature to delete the whole column, for example : if there are 3 columns and one is empty , i will just replace it with two columns grid, but i want the undo manager to save the state when there was content in the third column, in ordert to prevent the bug from the post to be shown. – radpet Apr 02 '15 at 15:51