PHPStorm Drag to Insert Images

According to the Blog, 2016.2 EAP added the following functionality:

"Drag images, JavaScript or CSS files into the HTML file in the editor to automatically generate img, script or tags for them."

But whenever I drag an image into the editor, it open the image in a new tab. I have looked through all the settings, and I may be missing something obvious, but I haven't been able to resolve this.

Any help is appreciated.

10 comments
Comment actions Permalink

Hi there,

That is correct -- just checked in latest EAP and it works as advertised (for images).

What's your IDE build exactly? In what kind of file you were dragging those images?

0
Comment actions Permalink

Thanks Andriy

I am currently on the latest EAP build but the problem was apparent on the build before also.

PhpStorm 2016.2 EAP
Build #PS-162.844.9, built on June 8, 2016
PhpStorm EAP User
Expiration date: July 8, 2016
JRE: 1.8.0_77-b03 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

The image type is JPG or PNG inserting into PHP or HTML files.

Whilst dragging the image, it looks like it is going to work. The cursor shows '1 item' and the caret moves within the code to allow placement but as soon as I release the left mouse button, the image opens in a new tab and there is no image tag inserted.

I have also tried linking JS files in this way but the results are the same.

0
Comment actions Permalink

It seems to work just fine for me with both JS and image files (I've tried with only 1 files at a time though).

I'm on Windows 7 x64 using 32-bit PhpStorm (32-bit custom (JetBrains-made) Java comes bundled with IDE).

PhpStorm 2016.2 EAP
Build #PS-162.844.9, built on June 8, 2016
PhpStorm EAP User
Expiration date: July 8, 2016
JRE: 1.8.0_76-release-b216 x86
JVM: OpenJDK Server VM by JetBrains s.r.o

I've also tried 64-bit PhpStorm (using standard 64-bit JDK directly from Oracle) -- same results (it works):

PhpStorm 2016.2 EAP
Build #PS-162.844.9, built on June 8, 2016
PhpStorm EAP User
Expiration date: July 8, 2016
JRE: 1.8.0_92-b14 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

No idea what to suggest here -- maybe check idea.log file and see if there will be anything interesting there...

0
Comment actions Permalink

That gives a clue but I have no idea what it means. Every time I try to insert an image, I get 8 lines in the idea.log:

2016-06-14 22:19:16,842 [ 655854]   WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here. 
2016-06-14 22:19:16,842 [ 655854] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
2016-06-14 22:19:16,842 [ 655854] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
2016-06-14 22:19:16,843 [ 655855] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
2016-06-14 22:19:16,843 [ 655855] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
2016-06-14 22:19:16,843 [ 655855] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
2016-06-14 22:19:16,843 [ 655855] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
2016-06-14 22:19:16,843 [ 655855] WARN - codeglance.EditorPanelInjector - I07: Injection skipped. Looks like we have already injected something here.
0
Comment actions Permalink

No ideas....

But can you show a screenshot of your html file (ideally it should be small file (brand new?) so it fits the screen)? Please also use either Default or Darcula editor color schema.

0
Comment actions Permalink

The problem occurs even on a brand new project and absolutely basic files.

0
Comment actions Permalink

Thanks.

You seem to have unneeded injection (most likely created by mistake/accidentally) that somehow affects such drag-and-drop from functioning correctly.

Please show screenshot of your "Settings/Preferences | Editor | Language Injections".

0
Comment actions Permalink

Sorry if you mean the green injection area, that was added by me whilst testing the issue. I thought I had removed it before doing the screenshot. Language injection setting shown below anyway.

0
Comment actions Permalink

Language Injection may not be the issue here. You have only 1 custom injection rule ... and I'm not sure for what tag it is (the "h1" rule name does not tell much .. and does not look like it would be causing such highlighting like shown on your screenshot -- need to see actual rule definition).

Anyway -- I was able to reproduce the issue.

Thing is -- you are trying to work with .html file .. but from IDE point of view it is a .php file (look at file icon from your previous screenshot). It looks that this new drag-and-drop functionality only works with files associated with "HTML" File Type. I've tried this with .php, .twig and .blade file and got the same behaviour as you.

I'd only suggest to clarify this moment with actual developers -- if this is an expected behaviour or a bug. Original tickets:

 You may either ask there .. or create new ticket.

0
Comment actions Permalink

Ah, I had not noticed the file association was showing PHP. I had wondered if the feature only worked in HTML files, which is why I tested it in that way, but I failed to notice it was still being treated as PHP.

It would seem this is expected behaviour, although I imagine quite few would like the feature available in PHP files.

Thanks for your efforts.

0

Please sign in to leave a comment.