Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2006-05-31 11:25:37

Random Bits
Xinha Community Member
Registered: 2005-10-24
Posts: 19

Strange Copy/Paste behaviour from within <span>

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

#2 2006-06-01 12:31:50

steveo125
Xinha Community Member
Registered: 2006-04-04
Posts: 24

Re: Strange Copy/Paste behaviour from within <span>

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

#3 2006-06-19 10:46:19

Random Bits
Xinha Community Member
Registered: 2005-10-24
Posts: 19

Re: Strange Copy/Paste behaviour from within <span>

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

#4 2006-06-19 11:43:22

junkwarrior
Xinha Community Member
Registered: 2006-03-12
Posts: 14

Re: Strange Copy/Paste behaviour from within <span>

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

#5 2006-06-20 04:57:24

steveo125
Xinha Community Member
Registered: 2006-04-04
Posts: 24

Re: Strange Copy/Paste behaviour from within <span>

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

#6 2006-06-20 06:11:56

koto
Xinha Pro
Registered: 2006-01-09
Posts: 58

Re: Strange Copy/Paste behaviour from within <span>

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

#7 2006-06-20 18:48:35

Random Bits
Xinha Community Member
Registered: 2005-10-24
Posts: 19

Re: Strange Copy/Paste behaviour from within <span>

steveo125,

Excellent!

Offline

#8 2006-06-22 03:47:27

steveo125
Xinha Community Member
Registered: 2006-04-04
Posts: 24

Re: Strange Copy/Paste behaviour from within <span>

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

#9 2006-06-22 14:35:43

mokhet
Xinha Authority
From: Paris, France
Registered: 2005-04-03
Posts: 105
Website

Re: Strange Copy/Paste behaviour from within <span>

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

#10 2006-10-20 11:53:42

janiner
New member
Registered: 2006-10-20
Posts: 2

Re: Strange Copy/Paste behaviour from within <span>

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

#11 2006-11-09 17:54:25

steveo125
Xinha Community Member
Registered: 2006-04-04
Posts: 24

Re: Strange Copy/Paste behaviour from within <span>

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

#12 2006-11-10 21:48:23

janiner
New member
Registered: 2006-10-20
Posts: 2

Re: Strange Copy/Paste behaviour from within <span>

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

#13 2007-04-11 11:14:07

Random Bits
Xinha Community Member
Registered: 2005-10-24
Posts: 19

Re: Strange Copy/Paste behaviour from within <span>

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

Board footer

Powered by FluxBB