我嘗試將div標籤轉換成我可以在CKEditor中拖放的東西(如另一個問題所述)。 你知道我怎麼能觸發事件當有人開關之間源視圖和所見即所得模式?CKEditor鉤子/事件觸發切換到/從源視圖
感謝,
-lony
我嘗試將div標籤轉換成我可以在CKEditor中拖放的東西(如另一個問題所述)。 你知道我怎麼能觸發事件當有人開關之間源視圖和所見即所得模式?CKEditor鉤子/事件觸發切換到/從源視圖
感謝,
-lony
我認爲這是你在找什麼:
CKEDITOR.on('instanceCreated', function(e) {
e.editor.on('mode', function(e){
// Do your stuff here
alert(e.editor.mode);
});
});
如果你的意思,你想捕捉源模式的變化,那麼你可以嘗試這樣的事:
//add this to your CKeditor’s config.js
$('textarea.cke_source').live('keyup', function() {
$(this)
.closest('.cke_wrapper')
.parent()
.parent()
.prev()
.ckeditorGet()
.fire('change');
});
這種討論可能有所幫助:ckEditor 希望它有幫助
我想你應該寫一個插件來製作wysiwyg視圖的假元素。
Ckeditor能夠識別需要用fake-elements
替換的元素。
我爲你一個開始:)
(function() {
CKEDITOR.plugins.add('myPlugin', {
requires : [ 'fakeobjects' ],
init: function(editor) {
var me = this;
var pluginName = 'myPlugin';
editor.addCommand(pluginName, new CKEDITOR.dialogCommand(pluginName));
editor.addCss(// your custom css for your placeholder here
'div.myPluginElement' +
'{' +
'border: 1px solid #a9a9a9;' +
'width: 70px;' +
'height: 50px;' +
'}'
);
},
afterInit : function(editor) {
var dataProcessor = editor.dataProcessor,
dataFilter = dataProcessor && dataProcessor.dataFilter;
if (dataFilter) {
dataFilter.addRules({
elements : {
div : function(element) {
if (typeof element.attributes['class'] !== 'undefined' && element.attributes['class'].indexOf('myPluginElement') != -1)
return editor.createFakeParserElement(element, 'myPluginElement', 'div', false);
else return;
}
}
});
}
}
});
})(;
對不起,也許我有點不莊重。當用戶切換視圖時,我不想「做些什麼」。應將標籤'
'轉換爲可以調整大小並移動的圖像,例如iFrame。爲此,我需要知道在哪裏「入侵」。 – lony 2012-03-16 11:35:13