如何仅丢弃CKEditor撤消堆栈的最后一个元素? [英] How to discard only the last element of CKEditor undo stack?
问题描述
是否可以仅删除CKEditor撤消堆栈中的最后一个快照,或者可以将其替换为另一个快照.我应该自己实现吗?
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?
示例:
第1步
第2步-应该删除并替换为第3步(在给定情况下)
Step 2 --should be removed and replaced with step 3 (On given situation)
第3步-应该成为第2步
Step 3 -- should become step 2
仅当发生特殊事件时,此功能才可用.
This feature should be available only if special event occurs.
推荐答案
如果您的撤消快照是用户操作的结果,请按照以下方式操作:
If your undo snapshots are a result of user actions, following this way:
- 第1步.
- 第2步.
-
CKEDITOR.instances.editor.fire( 'lockSnapshot' )
- 第3步.
-
CKEDITOR.instances.editor.fire( 'unlockSnapshot' )
当然,您必须检测正在发生的事情并在正确的时间触发正确的事件.
Of course, you have to detect what's going on and fire the right event at the right time.
如果对内容的更改是通过代码完成的,则 editor#updateSnapshot
事件会更好:
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' );
..
}
这篇关于如何仅丢弃CKEditor撤消堆栈的最后一个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!