之前的状态我在编写ckeditor插件时遇到撤消问题。 我正在使用editor.insertHtml
将具有某个类的div添加到文档中。如果我从一个空白文档开始,撤消和重做都不会被点亮。当我执行该命令时,撤消将亮起。如果我按撤消,两者都会亮起。 “撤消”不会恢复文档内容。撤销不会将文档内容恢复到editor.insertHtml
为什么不呢?
CKEDITOR.plugins.add('plugin_name',
{
init: function(editor)
{
editor.ui.addButton('Button_name',
{
label: 'some text',
command: 'Command_name',
icon: this.path + 'images/icon.png'
});
editor.addCommand('Command_name', { canUndo: true, exec: function()
{
editor.fire('saveSnapshot');
editor.insertHtml("<div contenteditable='false' class='foobar'></div>\r\n");
editor.fire('saveSnapshot');
}});
}
});
我也弄不明白,为什么之前和HTML插入后需要快照的节省,但那是另一回事。
将'canUndo'设置为_false_并移除这些'editor.fire('saveSnapshot');'做了诡计! – 2015-03-26 08:32:13