radpet
radpet

Reputation: 731

How to discard only the last element of CKEditor undo stack?

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.

Upvotes: 2

Views: 1516

Answers (1)

oleq
oleq

Reputation: 15895

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' );
    ..
}

Upvotes: 3

Related Questions