2010-09-26 73 views
0

我正在構建一個需要用戶將html元素拖放到CKeditor實例上的應用程序。我需要監聽放置事件,以便我可以採取措施移除放入編輯器的元素。我看到有一個'粘貼'事件,但它不是由放置引發的。如何在CKeditor中監聽拖放事件?

這裏是我的簡單測試,使用jQuery的CKEDITOR適配器:

// set up instance 
$('#editor1').ckeditor(); 
var editor = $('#editor1').ckeditorGet(); 

// this gets a list of all events that you can listen for 
console.log(editor._.events); 

// here's how you listen for an event 
editor.on("someEvent", function(e) { 
    console.log(e); 
}); 

我不能找到文檔中任何對這個線索。

任何想法?

+0

你有這個運氣好的話,最近拖動的元素?我現在正在嘗試做同樣的事情。 – joshs 2011-01-15 05:57:18

+0

不,沒有運氣。我走了一條不同的道路。 – ScottE 2011-01-15 13:18:45

回答

0

如果可能的話,分配一個唯一的屬性,你下降到編輯器中的項目,然後聽一聽是selectionChange

editor.on('selectionChange', hookNewObjects); 

請您已在所有對象的登記下降並只對新的採取行動。

您可以訪問使用

ev.editor.getSelection().getStartElement().$