You are not logged in.
I have a button defined which wraps highlighted text in a span:
Some text of which <span id="myhighlight" title="Marked for special processing">this phrase is highlighted</span> by the CSS.
If I copy the word "phrase" then paste it elsewhere, Xinha picks up the background colour which the CSS uses and places it into a <font> statement:
The pasted word <font bgcolor="#FFFF00">phrase</font> should be plain.
Is this defined behaviour, and if so WHY? Can I turn if off somewhere so I get a plain copy?
It confuses my users as they now see two places which are highlighted, yet only one will be processed.
Offline
Are you using IE or FF (or something else), Cut, Copy n' paste in Firefox are a pain due to the tighter security which FF has in this area.
On IE I have some code which forces 'everything' to be pasted as plain text only. It does this by overriding the paste command (use the onpaste event) and requesting that the clipboard return the information in text format - clipboardData.getData("Text").
Does that sound like the sort of thing you require? I could try to make it into a small plugin.
Offline
Just got back from vacation :-))
I though this was a Xinha behaviour, but you are saying it comes from Windows?
So I need to modify IE (or rather the clipboard behaviour) on every desktop? Sounds kind of drastic.
Offline
No, he's just saying you have to modify htmlarea.js, which will then be served by your server to everyone visiting your pages where Xinha is embedded.
BTW, a lot of Xinha funtionality comes from inbuilt 'editor' functionality of the browser--that's why things work (very) slightly differently on different browsers.
Offline
Exactly,
I've written a plugin to force plain text paste. It's 180 lines long so I was going to attach it as a file to a ticket or put it somewhere - I can't see how to do that - any guidance on how to do that would be appreciated.
Offline
steveo125: Login to Xinha trac (upper right corner) using guest / guest account.
Then you have a button on the right 'New Ticket'. Write a ticket description first, then attach the file (after submitting a ticket). You can enter your email address in appropriate field (replace 'guest').
Cheers,
Krzysztof Kotowicz
Offline
steveo125,
Excellent!
Offline
Cheers Koto - I didn't realise you had to submit the ticket before you could attach the file.
It's ticket #814, file Plain Text
- Watch out, it's the first plugin I've created - comments, assistance or advice welcome.
Offline
Hello, there is a problem with this version, the HTMLArea.prototype.execCommand is totally recoded when only the case where cmdID == 'paste' is changed from original code.
I think you better should do something like this (cant tell if it's working, my computer is broken and so cant test ) :
1) save a reference to the core execCommand function in PlainText constructor
function PlainText(editor) {
this.editor = editor;
editor.config.htmlareaPaste = true;
PlainText.coreExecCommand = HTMLArea.prototype.execCommand;
}
2) call the coreExecCommand reference when the cmdID is not 'paste'
// the execCommand function (intercepts some commands and replaces them with
// our own implementation)
HTMLArea.prototype.execCommand = function(cmdID, UI, param)
{
if ( cmdID == 'paste' )
{
try
{
//this._doc.execCommand(cmdID, UI, param);
var pastehtml=clipboardData.getData("Text"); //paste everything in IE as plain text!
this.insertHTML(pastehtml);
if ( this.config.killWordOnPaste )
{
this._wordClean();
}
}
catch (ex)
{
if ( HTMLArea.is_gecko )
{
this.pasteArea();
}
}
this.updateToolbar();
}
else
{
PlainText.coreExecCommand.call(this, cmdID, UI, param);
}
return false;
};
Offline
I have the same problem, and came here looking for a solution. However, it doesn't look like the plugin has been updated since it was first uploaded. Is it actually usable as-is, or does it need to be fixed? I am new to xinha and not exactly a pro with Javascript, so it would be difficult for me to fix it myself.
Offline
Not been around for a long while.
Yes the plugin works as uploaded. So it can be used.
However mokhet is right to suggest a better way of writing it so that it doesn't effect any other future improvements to the function in question.
Offline
Thanks, Steve!
FYI, there is an add-on to Firefox that fixes the problem, and that's what I ended up using. It's called Copy Plain Text, found at https://addons.mozilla.org/firefox/134.
Unfortunately the author hasn't updated it to 2.0 yet. Some people have patched it to install, but I found that copying a URL from the location box doesn't work with the extension enabled. So I leave it off most of the time and turn it on when I need the feature, not the best situation. But it does work.
Offline
I found a way to stop this behaviour that does not involve a plugin or otherwise manipulating Javascript.
In the CSS I did have:
background-color: ffff00;
Copy/Paste was picking this up as a <font> etc
I now have:
background: url("/site/image/yellow.gif") repeat center;
Copy/paste now only grabs the text.
Thanks to everyone who worked on this!
Offline