Bug 17926 - Unformat deletes images
Summary: Unformat deletes images
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://rtef.info/demo.htm
Keywords: NeedsReduction
Depends on: 43017
Blocks:
  Show dependency treegraph
 
Reported: 2008-03-18 16:41 PDT by Anders Jenbo
Modified: 2010-10-25 15:19 PDT (History)
6 users (show)

See Also:


Attachments
Patch (2.78 KB, patch)
2010-10-25 14:02 PDT, Ryosuke Niwa
ojan: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Jenbo 2008-03-18 16:41:40 PDT
Go to
http://rtef.info/demo.htm
Switch to HTML mode

Insert this code

Please don't kill my brother, <img src="http://www.dcs.dk/imgNewDesign/frontBrother.gif" alt="Brother" />

Switch to RichText mode

Select all content (button 1 or how ever you do it), hit unformat (button 2)
Comment 1 Anders Jenbo 2008-03-18 16:51:51 PDT
Probably should mention that unfromat calls "rteCommand('RemoveFormat')
rteCommand('JustifyNone') and rteCommand('FormatBlock', '<p>') on the selected contnet.
Comment 2 Jeff 2009-01-09 18:54:43 PST
I have the same issue when executing :

document.execCommand('RemoveFormat',false,null);

on a mix text / img, img are deleted. I avoid selection
on img by adding "-khtml-user-select:none" on them same problem.

another thing the text lost class inherit properties
<div id='editor' class='textclass'> .... my text ...  </div>
When apply "RemoveFormat" the text CSS class might be 'textclass' !

Same problem on Chrome

Regards

Jeff






Comment 3 Ryosuke Niwa 2010-10-25 14:02:24 PDT
Created attachment 71792 [details]
Patch
Comment 4 Ryosuke Niwa 2010-10-25 14:03:31 PDT
This bug has been fixed since http://trac.webkit.org/changeset/70283.  I'm adding two more tests to make sure we're not removing any images.
Comment 5 Ojan Vafai 2010-10-25 14:25:55 PDT
Comment on attachment 71792 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=71792&action=review

> LayoutTests/editing/execCommand/remove-format-image.html:2
> +<html>

Don't need this tag. It just adds clutter. The doctype is useful because it forces standards mode though.

> LayoutTests/editing/execCommand/remove-format-image.html:3
> +<body onload="runTests();">

Do you need to run this onload? Can't you just run the script inline? If you do that, you won't need the body tag in the test.

> LayoutTests/editing/execCommand/remove-format-image.html:5
> +<div id="test1" contenteditable><storng>hello</strong> <img src="../resources/abe.png"> world</div>

typo:storng
Comment 6 Ryosuke Niwa 2010-10-25 14:43:33 PDT
(In reply to comment #5)
> > LayoutTests/editing/execCommand/remove-format-image.html:2
> > +<html>
> 
> Don't need this tag. It just adds clutter. The doctype is useful because it forces standards mode though.

I don't think having <html> adds that much of cluttering.  I think most of tests that do have DOCTYPE also has html, and I'd rather conform to that trend.  Are you strongly inclined to remove this before landing?

> > LayoutTests/editing/execCommand/remove-format-image.html:3
> > +<body onload="runTests();">
> 
> Do you need to run this onload? Can't you just run the script inline? If you do that, you won't need the body tag in the test.

Yes.  Images aren't necessarily loaded by the time the script is ran, and we get a different result when that happens.  Or otherwise we'll make this test flaky.

> > LayoutTests/editing/execCommand/remove-format-image.html:5
> > +<div id="test1" contenteditable><storng>hello</strong> <img src="../resources/abe.png"> world</div>
> 
> typo:storng

Oops, thanks.  Will fix.
Comment 7 Ojan Vafai 2010-10-25 15:08:34 PDT
(In reply to comment #6)
> (In reply to comment #5)
> > > LayoutTests/editing/execCommand/remove-format-image.html:2
> > > +<html>
> > 
> > Don't need this tag. It just adds clutter. The doctype is useful because it forces standards mode though.
> 
> I don't think having <html> adds that much of cluttering.  I think most of tests that do have DOCTYPE also has html, and I'd rather conform to that trend.  Are you strongly inclined to remove this before landing?

No. Either way is fine. While I agree that many tests have the html tag, I don't personally like it. The smaller a test is, the easier it is to make sense of and maintain.
Comment 8 Ryosuke Niwa 2010-10-25 15:18:00 PDT
Committed r70493: <http://trac.webkit.org/changeset/70493>
Comment 9 Ryosuke Niwa 2010-10-25 15:19:08 PDT
Thanks for the review, Ojan.