This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 43309 - HTML editor wraps text on paste with html tags
Summary: HTML editor wraps text on paste with html tags
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P2 blocker with 2 votes (vote)
Assignee: Martin Roskanin
URL:
Keywords:
: 49698 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-14 23:36 UTC by zacjacobson
Modified: 2009-05-18 10:46 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screen shot of html paste behaviour I'm comlaining about (39.33 KB, image/gif)
2004-09-22 22:51 UTC, zacjacobson
Details
screen shot of html paste behaviour I'm comlaining about (39.33 KB, image/gif)
2004-09-22 22:52 UTC, zacjacobson
Details
convetor the deletes the text/html flavor (1.15 KB, text/plain)
2005-01-28 20:17 UTC, Pavel Buzek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zacjacobson 2004-05-14 23:36:57 UTC
After having copied HTML source from a Mozilla 1.6
"view source" window, the HTML editor changes the
text that is pasted. It adds html, body, pre, and
span tags, and changes all the angle-brackets into
HTML escape sequences.

I can see how this might be useful, but it also
has to be possible to get around it. Pasting with
Ctrl+V(paste) or Ctrl+Shift+V(paste-formatted)
give the same result.

Perhaps only do the munging if the document is
empty, or having one of the paste methods paste it
as is (strip the formatting) is a better solution.
Comment 1 Petr Pisl 2004-09-22 16:46:49 UTC
I'm not able reproduce this. If you have still this problem now,
please reopen the bug. 
Comment 2 zacjacobson 2004-09-22 22:51:39 UTC
Created attachment 17821 [details]
screen shot of html paste behaviour I'm comlaining about
Comment 3 zacjacobson 2004-09-22 22:52:04 UTC
Created attachment 17822 [details]
screen shot of html paste behaviour I'm comlaining about
Comment 4 zacjacobson 2004-09-22 22:56:30 UTC
I'm still seeing this behaviour.. see attached screenshot (Sorry about
the double submit on the attachment; Issuezilla is slow today, my
connection timed out.)
Comment 5 zacjacobson 2004-09-22 23:05:01 UTC
I'm on Mozilla 1.7 now, and I see the same behaviour. I don't see this
behavour with copied text out of input boxes on a web page, just where
the text has some layout: from web pages apart from input boxes; and
from the source viewer, as shown in my attachment.
Comment 6 Petr Pisl 2004-09-23 11:51:42 UTC
Thanks for the screenshot. Now I understand correctly. 
Comment 7 zikmund 2004-09-29 17:42:25 UTC
*** Issue 49698 has been marked as a duplicate of this issue. ***
Comment 8 Petr Pisl 2004-10-13 13:49:31 UTC
I think this is Windows specific issue. I'm not able to reproduce it
on  linux, but on the windows yes. 

Comment 9 Petr Pisl 2004-10-13 14:46:37 UTC
The application can put a text to the clipboard with different content
types. When you copy something from Mozilla then windows clipboard
includes  these as well:

text/html(text/html; class=java.nio.CharBuffer; charset=Unicode) : 
<html><body>
<!--StartFragment -->
<pre id="line28">&lt;<span class="start-tag">INPUT</span><span
class="attribute-name"> TYPE</span>=<span
class="attribute-value">HIDDEN </span><span
class="attribute-name">NAME</span>=<span
class="attribute-value">"delta_ts" </span><span
class="attribute-name">VALUE</span>=<span
class="attribute-value">"20040830202042"</span>&gt;</pre>
<!--EndFragment-->
</body>
</html>

text/plain(text/plain; class=java.nio.CharBuffer; charset=Unicode) : 
<INPUT TYPE=HIDDEN NAME="delta_ts" VALUE="20040830202042">


Because the html document in the netbeans has text/html content type,
the JTextComponent chooses from the clipboard the text/html part.
Comment 10 zacjacobson 2004-10-14 00:40:12 UTC
Are you suggesting this is a Mozilla bug?

Perhaps they should not be further marking-up text taken from the
"View Source".
Comment 11 zacjacobson 2004-10-14 00:55:30 UTC
I am editing HTML _source_ in this case; shouldn't the type be
text/plain? If I was pasting into a WYSIWYG HTML editor, then I could
understand it taking text/html from the clipboard.
Comment 12 Petr Pisl 2004-10-14 09:24:09 UTC
I don't think, this is Mozilla bug. I think this is netbeans bug. But
I don't have an idea how to fix. Maybe hack the paste action. I am
going to look at this. 
Comment 13 Petr Pisl 2004-10-19 15:51:54 UTC
I'm not sure, whether I will be able to fix this into NB 4.0 release.
Comment 14 Jiri Kovalsky 2005-01-27 15:02:16 UTC
Can you please Peter explain why you think this is only P4 ? I
personally face it at least once a week and to tell the truth I really
hate to:
1. CTRL+C in Mozilla
2. CTRL+V in Notepad
3. CTRL+A in Notepad
4. CTRL+C in Notepad and finally ...
5. CTRL+V in NetBeans editor ... :-(
Comment 15 Pavel Buzek 2005-01-28 05:28:31 UTC
I encountered this bug earlier and used the notepad workaround but
this is not usable if you use the IDE as your primary html editor
(which I am trying to do). 

I am raising to P2 based on:
http://qa.netbeans.org/processes/bug_priority_guidelines.html
because I think this is a serious usability problem and the workaround
is impractical to use -- copy/paste is used too often.

(BTW, this is the 3rd open issue with most votes in IZ)

What do notepad or other editors do that they do not add the wrapping
text? I think if you remove the wrapper text when pasting into html
source editor then that is not 'hacking', that is how it is supposed
to be.
Comment 16 Petr Pisl 2005-01-28 08:48:18 UTC
Pavel I agree with you. It's irritating issue in Windows. 

Whole problem is, that mozilla and some other application includes
into clipboard more "versions" of the selected text. Every version is
marked by flavour. The application which want to paste a text from
clipboard, choose the text with the appropriate flavour. The flavour
in this case is very similar to the content type.

So  when you copy a selected text from mozilla, then mozilla includes
to the clipboard text with flower "text/plain", "text/html" and other
with "binary" .... Unfortunately the swing components choose the text
with the flavour which is the same as content type. The html editor
has content type  text/html => the text with "text/html" flavour is
chosen.

Why fix it?

1) Change the content type of the html editor to text/plain
2) Rewrite the paste action

The first solution has a lot of consequences for other editors such as
jsp editor. So this solution we have to refuse.

The second solution looks like good idea. The problem is, that
Netbeans already rewrites the paste action in the core. I need more
time to find out how to fix this in the core, or how to rewrite the
paste action, which is in the core.
Comment 17 Petr Pisl 2005-01-28 08:50:00 UTC
I'm sorry, there shouldn't be Why fix it? but How fix it in my
previous comment:)
Comment 18 Pavel Buzek 2005-01-28 20:17:43 UTC
Created attachment 20048 [details]
convetor the deletes the text/html flavor
Comment 19 Pavel Buzek 2005-01-28 20:24:15 UTC
The experiment shows that a writing a convertor that simply removes
the text/html flavor helps. (It also needs to be registered in lookup,
add 
META-INF.services/org.openide.util.datatransfer.ExClipboard$Convertor
with org.netbeans.modules.html.HtmlClipboardConvertor in it). The
problem is ExClipboard.Convertor says you should not generally remove
flavors. I did not have time to try to try doing something with
PasteType instead of removing DataFlavors but it should be possible,
javadoc for ExClipboard shows something similar (though with nodes).
Comment 20 Martin Roskanin 2005-02-21 15:35:44 UTC
fixed in [maintrunk]

/cvs/html/editor/src/org/netbeans/modules/editor/html/HTMLKit.java,v 
<--  HTMLKit.java
new revision: 1.4; previous revision: 1.3

Comment 21 Martin Roskanin 2005-02-21 15:45:24 UTC
+ adding forgotten //NOI18N comments:

/cvs/html/editor/src/org/netbeans/modules/editor/html/HTMLKit.java,v 
<--  HTMLKit.java
new revision: 1.6; previous revision: 1.5

and [REWRITE_PLACE] fix info:

/cvs/html/editor/src/org/netbeans/modules/editor/html/HTMLKit.java,v 
<--  HTMLKit.java
new revision: 1.5; previous revision: 1.4

Complete diff from 1.3 - 1.6

Comment 22 zikmund 2005-02-22 09:34:47 UTC
Verified in trunk, Martine could you please merge it to
release41_beta? Thanks.
Comment 23 Martin Roskanin 2005-02-22 13:48:06 UTC
fixed in [release41_beta]

/cvs/html/editor/src/org/netbeans/modules/editor/html/HTMLKit.java,v 
<--  HTMLKit.java
new revision: 1.3.6.1; previous revision: 1.3
Comment 24 zikmund 2005-03-31 18:54:49 UTC
Verified.
Comment 25 zacjacobson 2005-05-12 21:19:25 UTC
Just downloaded v4.1, and it's fixed!

Thanks everyone who worked on it,
Zac