Hi every body, I want to remove the format of paste content on paste event.
I tried this code but it is not working. please help me!
CKEDITOR.on('instanceReady', function (e) {
editor = e.editor;
editor.on('paste', function (e) {
editor.focus();
editor.document.$.execCommand('SelectAll', false, null );
editor.execCommand('RemoveFormat', editor.getSelection().getNative());
editor.insertHtml('additional content');
});
});
I tried this code but it is not working. please help me!
CKEDITOR.on('instanceReady', function (e) {
editor = e.editor;
editor.on('paste', function (e) {
editor.focus();
editor.document.$.execCommand('SelectAll', false, null );
editor.execCommand('RemoveFormat', editor.getSelection().getNative());
editor.insertHtml('additional content');
});
});

Re: Please help me remove the content on paste event
http://docs.cksource.com/ckeditor_api/s ... sPlainText
http://dev.ckeditor.com/ticket/9306
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Please help me remove the content on paste event
I only want to remove the style but keep the tag (.e.g. <div>, <p>, <br> ...) so CKEDITOR.config.forcePasteAsPlainText is not suitable for me.
I tried to add setTimeout, so, the format action will be excuted after on-paste 1s, i can see the editor SelectAll the content after 1s but the RemoveFormat command not work, i guess that editor.getSelection().getNative() is wrong, but i don't understand how ckeditor's selection work, please help me!
CKEDITOR.on('instanceReady', function(e){
var editor = e.editor;
editor.on('paste', function(e){
setTimeout(function(){
editor.focus();
editor.document.$.execCommand('SelectAll', false, null ); // work
editor.document.$.execCommand('RemoveFormat', editor.getSelection().getNative()); // not work
}, 1000);
});
});
Re: Please help me remove the content on paste event
CKEDITOR.on('instanceReady', function(e){
var editor = e.editor;
editor.on('paste', function(e){
setTimeout(function(){
$('body').append("<div id='tmpCt'>"+ editor.getData() +"</div>");
$('#tmpCt div, #tmpCt p, #tmpCt a, #tmpCt span').removeAttr("style");
$('#requiredDescription').val($('#tmpCt').html());
$('#tmpCt').remove();
}, 100);
});
});
hope that ckeditor dev team will take my case to make removeFormat reusable, it must be better!
Re: Please help me remove the content on paste event