Skip to content
Advertisement

Is there API of IDEA communicating with JCEF’s webview when developing IDEA’s plugin?

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.

Advertisement

Answer

Yes, this is possible. One way to do this is to separate your plugin into three separate modules:

  1. A module containing the IDE-side plugin code.
  2. A module that contains the JCEF browser code.
  3. 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.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement