3Di wrote: ↑Thu Jan 10, 2019 1:08 pm
Back on my idea, this one should be
natively IMHO implemented in the core code and not as an extension.
If you're taking comments from the peanut gallery, I wholeheartedly agree with that, too. Both in terms of how "passive" and "light weight" the implementation needed is, and also because it deserves to live along side the drag-n-drop support that is implemented as native to phpBB as well. It is an "ease of use" story that can be readily supported for the platforms that will expose image data through the Javascript clipboard event.
I would agree with a reduction in value if that limitation were true, too. But I think the stackoverflow.com discussion cited is conflating two different things, and is the subject of a similar clarification
that was mentioned in the discussion thread Senky referenced as well.
This new extension implements the ability to retrieve
image data from the clipboard. This works -- and by definition of Windows clipboard standards must work -- regardless of whom was responsible for putting the image data into the clipboard. It cannot "only work for images copied from other pages is the browser."
Only if an application cannot or is not willing to render a compatible image format (e.g. device independent bitmap) as part of the clipboard image formats it offers would "an image" not be available to paste. But it would not be available to paste in more circumstances than just this phpBB extension, an in more circumstances than just web browser-related use cases.
My expectation is that stackoverflow.com description cited is from someone who actually attempted to copy & paste
a file from their desktop, not withstanding that they legitimately describe this operation as
"copy an image from the desktop." Meaning, same as you can select a file on your desktop (image or otherwise), perform a Copy or Cut operation, and then Paste that file into a different folder -- they tried to make the Javascript clipboard event the target of the Paste operation in that scenario.
But this scenario does not put
image data into the clipboard, which is why image data is then subsequently not available for Paste.
What is in your clipboard at that point is a file path reference, similar to a file drag-n-drop operation, which is usable essentially only to SHELL32 / Windows Explorer or applications able to support inserting "a link to a file" (not it's content). There isn't even a plain text rendering of the file path available from the clipboard, which you can prove by trying to Paste that "file" into Notepad. You'll get neither the path to the file currently in the clipboard, nor (in the case of it being a text file) the contents of that file, either.
So the fact that "copy a image file from my desktop, and then try to paste it into my web browser where clipboard image data is supported" ultimately doesn't work is expected for that scenario. That doesn't represent a case where
image data will be in the clipboard, and won't work in
any case where image data was expected from the clipboard. Not just here with this extension, and not just with Javascript browser support in general, either.
But if you do want to use
a file instead of image data to create an attachment in phpBB, you can either drag it to phpBB, or use the phpBB "Attach" button.
Putting
image data into the clipboard -- from any application, not just a web browser -- is what Senky's new extension successfully enabled. e.g. You can be viewing or editing an image in Photoshop, or in MSPaint, or from an open Word document, or simply creating a screen shot of your current screen -- or yes, from an image you're looking at in a browser window, too -- and then just copy and paste that image into a phpBB message. Without ever saving that image "as a file", and without it ever existing "as a file."