2

我在 CKEDITOR 集成(内联模式)中遇到事件排序问题。

基本上,当 CKEDITOR 为 UNDO 管理器保存快照时,我需要运行一些自定义代码。目前我正在使用 event saveSnapshot

正如您从下面的示例中看到的那样saveSnapshot,之前会触发两次instanceReady

我想知道:

  • 为什么事件saveSnapshot会触发两次?从文档来看,它应该仅在编辑器即将保存撤消快照时触发。
  • 如何解决?还是替代事件的替代品?

https://jsbin.com/riginoxipe/edit?html,控制台,输出

this.ckDisable.call(this);
 this.target = document.getElementById(this.targetId);
 this.target.contentEditable = true;
 this.target.focus();
 this.ckEditor = CKEDITOR.inline(this.target.id);

 this.ckEditor.on('instanceReady', function(event) {
     console.log('instanceReady');
 }.bind(this));

 this.ckEditor.on('change', function(event) {
     console.log('change');
 }.bind(this));

 this.ckEditor.on('afterCommandExec', function(event) {
     console.log('saveSnapshot');
 }.bind(this));

 this.ckEditor.on('saveSnapshot', function(event) {
     console.log('saveSnapshot');
 }.bind(this));
4

0 回答 0