My apologies if there is a doc somewhere for this but i cannot find one.
My company wants to be able to filter all information that is pasted into the editor. At this point I'm assuming there are 3 events that users can trigger to paste into the editor.
Events
-----------------------
1. From the File/Edit menu, select Edit --> Paste
2. Right clicking on the editor and selecting 'Paste'
3. Using the keys Ctrl-V.
I can't imagine I'm the only one out there who intends to need this sort of control over their users content submission. Can anyone explain to me the steps to making this work in 3.x . I am aware that there is some option regarding 'Paste From Word' but i'm really not sure if that applies here. My hope is that there is a chunk of code that already exists in the editor that is triggered on every paste that I can modify.
Can anyone help here ?
My company wants to be able to filter all information that is pasted into the editor. At this point I'm assuming there are 3 events that users can trigger to paste into the editor.
Events
-----------------------
1. From the File/Edit menu, select Edit --> Paste
2. Right clicking on the editor and selecting 'Paste'
3. Using the keys Ctrl-V.
I can't imagine I'm the only one out there who intends to need this sort of control over their users content submission. Can anyone explain to me the steps to making this work in 3.x . I am aware that there is some option regarding 'Paste From Word' but i'm really not sure if that applies here. My hope is that there is a chunk of code that already exists in the editor that is triggered on every paste that I can modify.
Can anyone help here ?
Re: Paste Filter for 3.x
I want to filter all pasted information with wordFilter or just make an insertation as plain text.
But the most important thing is to filter out the word's tags.
So the first step: Redefine the simple paste form command:
Put these code into the config.js
CKEDITOR.on('instanceReady', function(ev)
{
ev.editor._.commands.paste = ev.editor._.commands.pastetext;
});
Second step assign your own keystrokes like this (See CTRL+V and SHIFT+INS):
CKEDITOR.editorConfig = function( config ) {
config.keystrokes =
[
[ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
[ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],
[ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],
[ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],
[ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],
[ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],
[ CKEDITOR.CTRL + 76 /*L*/, 'link' ],
[ CKEDITOR.CTRL + 66 /*B*/, 'bold' ],
[ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],
[ CKEDITOR.CTRL + 85 /*U*/, 'underline' ],
[ CKEDITOR.CTRL + 86 /*V*/, 'pastefromword' ],
[ CKEDITOR.SHIFT + 45 /*INS*/, 'pastefromword' ],
[ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ]
];
};
I hope, I helped to you
Best regards
G-Lex
Re: Paste Filter for 3.x
Wow.
That might very well get me to where I need to be. Few questions for ya.
1. What does the underscore do in your code?
ev.editor._.commands.paste = ev.editor._.commands.pastetext;
2. You said to place this snippet of code in the config.js file What is it doing exactly?
Re: Paste Filter for 3.x
2. When an CKE instance initialized it fires the instanceReady event. In the event handler I've got the object of the current instance so I can overdefine the assigned functions.
3. Yes, you need to place the second snippet into the config.js too.
4. The first parameter is the keycode. The second parameter is the executed command name.
in the source of pastefromword plugin you can see this line:
This line creates the pastefromword command.
5. You can create new plugin from the source of the paste from word plugin.
Create new filters, new commands, and overdefine the already defined keystroke commands with your own commands.
Re: Paste Filter for 3.x
Re: Paste Filter for 3.x
I basically want to grab CTRL+V data and add few text to it and then add it to the editor.
I have looked around but have not found a definitive answer.
Thanks a lot in advance.
Re: Paste Filter for 3.x
Hope it helps!
Re: Paste Filter for 3.x
Re: Paste Filter for 3.x
Not tested it in IE8 and Safari.
Any ideas?