Hi All,
I just wanted to know if there is a way of binding to a copy event when text is copied from the editor, either by the copy button or ctrl+c. The reason why i would like to do this is so i can add a tag to the start of the copied text so i know that when the clipboard data is pasted, that it has been copied from the editor and therefor i can keep all the formatting, and if the tag dosn't exists then i know that its been copied from else where and should have all formatting tags removed.
Any help would be great!
I just wanted to know if there is a way of binding to a copy event when text is copied from the editor, either by the copy button or ctrl+c. The reason why i would like to do this is so i can add a tag to the start of the copied text so i know that when the clipboard data is pasted, that it has been copied from the editor and therefor i can keep all the formatting, and if the tag dosn't exists then i know that its been copied from else where and should have all formatting tags removed.
Any help would be great!
Re: CKEditor ON COPY Event
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: CKEditor ON COPY Event
Re: CKEditor ON COPY Event
1. Listen on native copy&cut events (if they work...) and ctrl+c/x if needed.
2. Fire custom copy/cut event on editor allowing listeners to modify the stringified editor's data.
3. Create hidden contenteditable element and set its content to the modified editor's data.
4. Move focus and selection there.
5. Wait few milliseconds (dunno how long) for browser to let it copy the data from hidden contenteditable.
6. Move focus and selection back to the original place and remove the selected content if that was 'cut'.
7. Pray.
There are maaaany additional things you've got to take care of :). E.g. copybin (we named the hidden contenteditable grabbing the pasted data the "pastebin") must be placed in currently visible place to avoid scroll jumps. You may check the clipboard plugin which handles paste event quite well.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+