xles / hyphenator

Automatically exported from code.google.com/p/hyphenator
GNU General Public License v3.0
0 stars 0 forks source link

registerOnCopy copies text with font-size:0px #156

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Copy some text that has been hyphenated
2. Paste into rich text editor
3. Text will not appear

What is the expected output? What do you see instead?

Expect to see the pasted text, instead see nothing

Please provide any additional information below.

When copying text that's been hyphenated by Hyphenator 4.0, it will copy the 
following style along with it: 
"color: transparent; font-size: 0px;"

This is due to registerOnCopy doing the following:

shadow.style.color = window.getComputedStyle ? 
targetWindow.getComputedStyle(body).backgroundColor : '#FFFFFF';
shadow.style.fontSize = '0px';

So it seems that the shadow text is being copied with this style, which then of 
course doesn't show up when you paste it into a rich text editor somewhere else.

Will probably have to discontinue use of Hyphenator until this is fixed.

Original issue reported on code.google.com by george.g...@okb.no on 3 Feb 2012 at 4:03

GoogleCodeExporter commented 9 years ago
I can reproduce the issue when copying text from FF to Word.
Safari to Word works fine, so does FF to TextEdit.

Need a better solution!

Original comment by mathiasn...@gmail.com on 29 Apr 2012 at 10:15

GoogleCodeExporter commented 9 years ago
I can reproduce the issue when copying text from FF to Word.
Safari to Word works fine, so does FF to TextEdit.

Need a better solution!

Original comment by mathiasn...@gmail.com on 29 Apr 2012 at 10:15

GoogleCodeExporter commented 9 years ago
I can reproduce this on Windows 7 (64 bit) with Firefox 14 Beta, Chrome 19 and 
Safari 5.1.7. Opera 11.64 works fine.

I inspected the raw clipboard data. Firefox, Chrome and Safari save the copied 
text in HTML, Text, and Unicode Text format with a surrounding div/span with 
the style attribute 'font-size: 0px'.
Opera only saves the copied text in Text and Unicode Text format and therefore 
has no issues.

Original comment by andreas....@outlook.com on 8 Jun 2012 at 9:57

GoogleCodeExporter commented 9 years ago
This seems to be a side effect of a workaround for IE9.

From the oncopyHandler in Hyphenator.js:

//create a hidden shadow element
shadow = currDoc.createElement('div');
//Moving the element out of the screen doesn't work for IE9 
(https://connect.microsoft.com/IE/feedback/details/663981/)
//shadow.style.overflow = 'hidden';
//shadow.style.position = 'absolute';
//shadow.style.top = '-5000px';
//shadow.style.height = '1px';
//doing this instead:
shadow.style.color = window.getComputedStyle ? 
targetWindow.getComputedStyle(body, null).backgroundColor : '#FFFFFF';
shadow.style.fontSize = '0px';
body.appendChild(shadow);

A shadow element is created to put the text without hyphenation. The contents 
of that element are then selected so it overrides what gets copied to the 
clipboard. After that, the original selection is restored. The problem is that 
the fontSize of the shadow element is set to 0px to avoid an out of the screen 
positioning. I uncommented the original code to test it in a fresh install of 
IE9 (on Win7 64 bits) and it worked fine, so maybe that workaround isn't 
necessary (I removed it actually).

Also, IE has scrolling issues when copying text (with hyphenation). When 
content is selected using javascript it will scroll to the position of that 
content, and although the original selection is restored, the original scroll 
position is not. It will even scroll content from within an element with 
overflow set to hidden, depending on the selection (this one didn't happen on 
IE9 but did on IE8). This is another issue altogether anyway, I guess.

Original comment by mariano....@gmail.com on 14 Jul 2012 at 7:06

GoogleCodeExporter commented 9 years ago
This issue is still present in the actual version of hyphenator. Is there any 
fix coming in the near future?

btw: in word for mac it will show transparent and with a size of 1 (guess 0 is 
not working in this word version).

Original comment by land...@gmail.com on 5 Jun 2013 at 5:08

GoogleCodeExporter commented 9 years ago
This cannot be solved in Hyphenator

Original comment by mathiasn...@gmail.com on 25 Sep 2014 at 2:51