Closed Bug 1610219 Opened 5 years ago Closed 5 years ago

Dropping image file onto `contenteditable` causes inserting `<img>` element but not show the image set to `src` attribute as data URI

Categories

(Core :: DOM: Editor, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: masayuki, Unassigned)

References

Details

STR:

  1. Open data:text/html,<div contenteditable><br></div>.
  2. Drag an image file from desktop or the filer.
  3. Drop it onto the contenteditable.

ER:
<img> element should show the image with data URI.

AR:
<img> file is inserted, but the data URI isn't loaded as image.

Oddly, loading the data URI in new tab works fine. Does Gecko have some limitation about <img src="data:image/...">?

Note that Chrome always load the image file as new document. (I.e., their editor does not handle file drop.) And Safari does nothing if file is dropped onto contenteditable. So, it might be better to stop HTMLEditor handling file drop (I mean that HTMLEditor should just dispatch beforeinput event but does nothing) on web content.

WDYT, Makoto-san and Smaug?

Flags: needinfo?(m_kato)
Flags: needinfo?(bugs)

On Thunderbird's composer, the <img> element loads the data URI as expected.

If this feature is required only by comm-central and BlueGriffon, it may be better that they handle beforeinput event whose inputType is insertFromDrop, insertFromPaste and insertFromPasteAsQuotation by themselves. If so, we could drop a lot of code from HTMLEditorDataTransfer.cpp.

Thank you, Jorg, that's really good news for us!

On Windows, open https://www-archive.mozilla.org/editor/midasdemo/ and drop an image. Then check the source box. I see a data: URL as expected. What's the bug? Edit: Using FF 68.4.1 ESR.

As Web based editor, it is better to use drag&drop API to insert image. So I think that WebKit's behavior is simple. Should we need telemetry data to know whether user uses this feature?

Flags: needinfo?(m_kato)

(In reply to Jorg K (GMT+1) (PTO to 26th Jan 2020, sporadically reading bugmail) from comment #4)

On Windows, open https://www-archive.mozilla.org/editor/midasdemo/ and drop an image. Then check the source box. I see a data: URL as expected. What's the bug? Edit: Using FF 68.4.1 ESR.

Ah, sorry, I was tested on my testsite, but I realized that the data URI is blocked by its "Content-Security-Policy". So, this should be marked as INVA.

(In reply to Makoto Kato [:m_kato] from comment #5)

As Web based editor, it is better to use drag&drop API to insert image. So I think that WebKit's behavior is simple. Should we need telemetry data to know whether user uses this feature?

Yeah, I'm still thinking that we can drop these complicated code from m-c since the other browsers don't support this, and Thunderbird supports it by itself. I'll file a bug to collect the telemetry.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID

(Looks like I can clear the needinfo :) )

Flags: needinfo?(bugs)
You need to log in before you can comment on or make changes to this bug.