CKEditor capture / event activated when switching to / from source view
4 answers
If you mean you want to commit the source mode changes, then you can try something like this:
//add this to your CKeditorβs config.js
$('textarea.cke_source').live('keyup', function() {
$(this)
.closest('.cke_wrapper')
.parent()
.parent()
.prev()
.ckeditorGet()
.fire('change');
});
This discussion might help as well: ckEditor Hope it helps.
0
source to share
I think you should write a plugin to create a fake element for the wysiwyg-view.
Ckeditor can recognize items that need to be replaced with fake-elements
.
I started for you:
( 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;
}
}
});
}
}
} );
}) ();
0
source to share