I am currently preparing for developing an IDEA plugin involving webview containing some information. Since I have developed a VSCode extension of similar functionalities and it uses many webviews, I plan to migrate those HTML to IDEA's plugin by JECF.
However, the functionalities require some interaction with the extension/plugin, as in VSCode I could click some elements of the webview and insert some texts into the editor by acquireVsCodeApi provided by VSCode itself. And I am not quite sure if such communication could be performed by using JCEF in the plugin of IDEA? (I am quite new to Jetbrain's plugin development and JAVA)
Great thanks for any suggestions.
CodePudding user response:
Yes, this is possible. One way to do this is to separate your plugin into three separate modules:
- A module containing the IDE-side plugin code.
- A module that contains the JCEF browser code.
- A module that acts as a message passing interface. This module will enable communication between the first two modules.
See the IntelliJ PDF Viewer plugin for a good example, in particular the kotlinjs-migrate
branch. Another good place to start - and to keep an eye on while you figure out how the pdf viewer plugin works - is the IntelliJ documentation page about JCEF. The section about the JBCefClient might especially be of interest to you, though it is rather minimal.