You are not logged in.
#1 2005-12-08 00:20:09
- IPN
- Member
- Registered: 2005-03-14
- Posts: 27
Remove format from copy & paste
Hello,
I would like to remove all the formatting from when I copy and paste an article, lets say from yahoo.com
I don't want any pics, any hyperlinks, any special formatting such as BOLD, ITALIC, UNDERLINE, H1 etc.
How can I do this?
Thanks.
Offline
#3 2005-12-08 22:22:57
- Muramasa
- Member
- Registered: 2005-12-08
- Posts: 5
Re: Remove format from copy & paste
spocke wrote:
paste as plain text in the paste plugin.
But how do you force a plain text paste? If user doesn't use the paste as plain text icon and uses Ctrl-V then it pastes with all the html formating. How do you force a plain text with Ctrl-V? I did not find any options related to this.
Offline
#4 2005-12-08 22:43:28
- IPN
- Member
- Registered: 2005-03-14
- Posts: 27
Re: Remove format from copy & paste
Yes, if there is some way to default all the text pasted as "plain text" that would be great! In my app, there is not an option for pasting as plain text.
Offline
#5 2005-12-09 10:58:11
- sandersa
- Member
- Registered: 2005-12-06
- Posts: 10
Re: Remove format from copy & paste
First, you need to have the paste plugin enabled.
Then, you need to add an event handler for CTRL+V. This is done in TinyMCE.prototype.handle function. Find the cases for "keyup" and "keydown", and add the following to the end (before the break. In my case it's line numer 1134):
Code:
if (e.ctrlKey && e.keyCode == 86 && e.type != "keyup") {
tinyMCE.execInstanceCommand(e.target.editorId, "mcePasteText", true);
tinyMCE.cancelEvent(e);
return false;
}This did the trick for me.
If you use the contextmenu plugin, you have to configure this as well. I did it by adding the following lines to the ContextMenu.prototype.addItem function (at line 246 for me):
Code:
if (command == "Paste") {
onMouseDown = 'tinyMCE.execCommand(\'mcePasteText\', true);return false;';
}Offline
#6 2005-12-09 14:11:03
- IPN
- Member
- Registered: 2005-03-14
- Posts: 27
Re: Remove format from copy & paste
How do I enable the plugin? I tried going to here:
To use a plugin, you need to use the advanced theme and add the plugin name in the "plugin" comma seperated line. You also need to add the button to the interface, read more about the advanced plugin to configure this.
But the "plugin" has a broken link...http://tinymce.moxiecode.com/tinymce/docs/option_plugin.html
Thanks.
Offline
#7 2005-12-09 14:25:40
- sandersa
- Member
- Registered: 2005-12-06
- Posts: 10
Re: Remove format from copy & paste
In your tinyMCE.init section, you should have a line that lists the plugins you want to use. Just add paste to that list.
Code:
plugins : "[...],paste"
Offline
#8 2005-12-09 14:50:29
- IPN
- Member
- Registered: 2005-03-14
- Posts: 27
Re: Remove format from copy & paste
Sandersa,
Thanks, I'll look for this and will let you know how it goes.
Offline
#9 2005-12-10 00:00:24
- Muramasa
- Member
- Registered: 2005-12-08
- Posts: 5
Re: Remove format from copy & paste
Hmm, did not work out for me and I made sure I was editing the correct file. Maybe IPN had better luck?
Offline
#10 2005-12-10 01:36:04
- IPN
- Member
- Registered: 2005-03-14
- Posts: 27
Re: Remove format from copy & paste
It worked for me great! ![]()
Offline
#11 2005-12-10 23:58:29
- sandersa
- Member
- Registered: 2005-12-06
- Posts: 10
Re: Remove format from copy & paste
IPN: Good for you!
Muramasa: Are you sure you added the code correctly? Also, if you edited the _src file, like me, remember to set your script to call that file, not the compressed one.
Below is my code in a slightly larger context than I posted above.
Code:
case "keyup":
case "keydown":
[...]
if (tinyMCE.isMSIE && e.ctrlKey)
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
// CTRL + V - use plugin "paste" to paste as plain text
if (e.ctrlKey && e.keyCode == 86 && e.type != "keyup") {
tinyMCE.execInstanceCommand(e.target.editorId, "mcePasteText", true);
tinyMCE.cancelEvent(e);
return false;
}
break;Offline
#12 2006-03-01 03:04:08
- cridgwell
- Member
- Registered: 2006-02-26
- Posts: 6
Re: Remove format from copy & paste
Hi - i've managed to get this to work correctly on IE, but it doesn't seem to work on Firefox. Anyone have any ideas on how to modify it so that it would?
Offline
#13 2006-03-04 11:49:25
- Stuckish
- Member
- Registered: 2006-02-12
- Posts: 13
Re: Remove format from copy & paste
I have the same problem. It works great in IE, but in firefox it get pasted into the editor and then the paste as plain text appear .. anyone have any solutions?
Offline
#14 2006-03-04 11:52:41
- Stuckish
- Member
- Registered: 2006-02-12
- Posts: 13
Re: Remove format from copy & paste
It also doesn't work if you choose to paste from the menu in the browser =/ .. Would be great if anyone have a solution for this .. i think FCKEditor had some good way to solve this .. but that one was bad in many other areas ![]()
Offline
#15 2006-04-14 22:23:45
- Oputres
- Member
- Registered: 2006-03-17
- Posts: 25
Re: Remove format from copy & paste
Did anyone came up with a solution on how to make this work with Firefox? I have the same problem.
Offline
#16 2006-05-15 21:06:34
- gshellyl
- Member
- Registered: 2006-05-11
- Posts: 4
Re: Remove format from copy & paste
Oputres wrote:
Did anyone came up with a solution on how to make this work with Firefox? I have the same problem.
Dag, we really need this too - trying to prevent XSS problems from people pasting stuff in.
I'm frankly surprised to not see more on this issue. Do people basically just accept that using a WYSIWYG editor like TinyMCE will open the door to XSS problems, and just accept it?
Offline
#17 2006-05-16 08:29:40
- seade
- Member
- From: Sydney, Australia
- Registered: 2005-08-05
- Posts: 113
Re: Remove format from copy & paste
gshellyl wrote:
Dag, we really need this too - trying to prevent XSS problems from people pasting stuff in.
I'm frankly surprised to not see more on this issue. Do people basically just accept that using a WYSIWYG editor like TinyMCE will open the door to XSS problems, and just accept it?
While you could attempt to deal with this in with TinyMCE it would still be trivial for someone to muck about with the submitted data outside of the editor. The net result is that there isn't really much point handling this with TinyMCE since you are going to have to repeat the processing on the back end anyway.
Scott
(a.k.a. monkeybrain)
Offline
#18 2006-05-16 18:00:17
- gshellyl
- Member
- Registered: 2006-05-11
- Posts: 4
Re: Remove format from copy & paste
seade wrote:
While you could attempt to deal with this in with TinyMCE it would still be trivial for someone to muck about with the submitted data outside of the editor. The net result is that there isn't really much point handling this with TinyMCE since you are going to have to repeat the processing on the back end anyway.
Scott
By "mucking about", do you mean creating your own copy of the form, with whatever (malicious) data in the field you want and submitting it to the same location, thereby getting your malicious text submitted?
I had been hoping that our JSP session security would prevent that - that a person couldn't simply submit a form without the authentication that comes with the session (and that wouldn't exist for some random form submission). But perhaps this is a naive/false hope.
Are there additional ways to maliciously muck with submitted data outside the editor?
Offline
#19 2006-05-17 08:33:25
- seade
- Member
- From: Sydney, Australia
- Registered: 2005-08-05
- Posts: 113
Re: Remove format from copy & paste
gshellyl wrote:
By "mucking about", do you mean creating your own copy of the form, with whatever (malicious) data in the field you want and submitting it to the same location, thereby getting your malicious text submitted?
I had been hoping that our JSP session security would prevent that - that a person couldn't simply submit a form without the authentication that comes with the session (and that wouldn't exist for some random form submission). But perhaps this is a naive/false hope.
Are there additional ways to maliciously muck with submitted data outside the editor?
Various plugins allow users to change things "on the fly". For FireFox there is FireBug, Greasemonkey, et al, for IE you can probably do something with Fiddler (see the link at the top of this very page).
Scott
(a.k.a. monkeybrain)
Offline
#20 2006-09-19 07:38:18
- Dr.Death
- Member
- Registered: 2006-09-19
- Posts: 5
Re: Remove format from copy & paste
Ok, after long search for the insert section of the editor_plugin it works like a flaw in the internet explorer.
But.... on Firefox i have a problem:
By hitting CTRL + V, the tinyMCE inserts my "formated" clipboard text and after that it opens the popup for the unformated paste :-(
This code seems to work only with MS IE:
Code:
// CTRL + V - use plugin "paste" to paste as plain text
if (e.ctrlKey && e.keyCode == 86 && e.type != "keyup") {
tinyMCE.execInstanceCommand(e.target.editorId, "mcePasteText", true);
tinyMCE.cancelEvent(e);
return false;
}What i must change/add to work on IE AND Firefox ?
Offline
#21 2006-09-19 16:08:34
- jgodwin
- Member
- Registered: 2006-05-10
- Posts: 1
Re: Remove format from copy & paste
This script has worked for me in both Firefox and IE. It is the same script mentioned above but it only fires when the browser is IE.
function myHandleEvent(e) {
if (navigator.appName == "Microsoft Internet Explorer"){
// CTRL + V - use plugin "paste" to paste as plain text
if (e.ctrlKey && e.keyCode == 86 && e.type != "keyup") {
tinyMCE.execInstanceCommand(e.target.editorId, "mcePasteText", true);
tinyMCE.cancelEvent(e);
return true;
}}}
Offline
#22 2006-09-19 20:44:18
- mikebridge
- Member
- Registered: 2006-09-05
- Posts: 37
Re: Remove format from copy & paste
This is slightly off-topic, but I was wondering about this phrase: "works like a flaw". But I only see one reference in Google from someone in Switzerland. Is it a saying, or did you come up with it yourself? Or is it a typo? (Anyway, I liked it.)
Dr.Death wrote:
works like a flaw in the internet explorer.
Offline
#23 2006-09-20 07:36:32
- Dr.Death
- Member
- Registered: 2006-09-19
- Posts: 5
Re: Remove format from copy & paste
Sorry, was a translation error..... should mean: "it works like a charm" in IE :-)
But i'm hanging on the Firefox problem....
It should insert the "unformated text" by hitting CTRL+V without opening the popup window.
It works in IE ( paste_use_dialog : false, ) , but in Firefox the paste script is fired up, the text is inserted ( with format ), the popup windows open.....weird.
Last edited by Dr.Death (2006-09-20 07:37:41)
Offline
#24 2006-09-20 18:41:23
- mikebridge
- Member
- Registered: 2006-09-05
- Posts: 37
Re: Remove format from copy & paste
I'm implementing a MSWord-stripper without the default plugin by capturing the "paste" keypress in my handle_event_callback, then doing an AJAX callback to run the tag-cleanup routine on the server side. I haven't connected the pieces yet, but it seems like it will work. I don't know how to capture non-keyboard paste events yet, but I will funnel it through AJAX on the form submission in any case, and maybe during the onchange event too so that the interface is updated.
I figure that since I need to clean up XSS problems on the server-side anyway, there's no point in duplicating the effort by configuring this on the client side as well.
I think "works like a flaw" is better than "works like a charm". I'm going to casually work it into conversation and see if it spreads. ![]()
Offline
#25 2006-12-16 19:52:49
- onyx
- Member
- Registered: 2005-06-20
- Posts: 39
Re: Remove format from copy & paste
I came up with a fix for the Firefox paste problem stated above. Replace the above suggested code with this one:
if (e.ctrlKey && e.keyCode == 86 && e.type != "keyup") {
if (e.preventDefault) {
e.preventDefault(); // DOM style
setTimeout('tinyMCE.execInstanceCommand(\"'+e.target.editorId+'\", \"mcePasteText\", true)',1);
} else {
tinyMCE.execInstanceCommand(e.target.editorId, "mcePasteText", true);
tinyMCE.cancelEvent(e);
return false; // IE style
}
}
Now you don't get FF pasting on Ctrl V.
Offline
© 2003-2010