package org.jetbrains.plugins.ipnb.editor.panels.code;

import com.intellij.ui.components.JBLabel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ipnb.editor.IpnbEditorUtil;
import org.jetbrains.plugins.ipnb.format.cells.output.IpnbHtmlOutputCell;

import javax.swing.*;

public class IpnbHtmlPanel extends IpnbCodeOutputPanel<IpnbHtmlOutputCell> {
  public IpnbHtmlPanel(@NotNull final IpnbHtmlOutputCell cell) {
    super(cell);
  }

  @Override
  protected JComponent createViewPanel() {
    final StringBuilder text = new StringBuilder("<html>");
    for (String html : myCell.getHtmls()) {
      html = html.replace("\"", "'");
      text.append(html);
    }
    text.append("</html>");
    final JBLabel label = new JBLabel(text.toString());
    label.setBackground(IpnbEditorUtil.getBackground());
    label.setOpaque(true);
    return label;
  }
}

@@ -60,140 +60,211 @@
 ort 
-com.intellij.ui.components.JBLabel;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.plugins.ipnb.editor.IpnbEditorUti
+javafx.application.Platform;%0Aimport javafx.embed.swing.JFXPanel;%0Aimport javafx.scene.Scene;%0Aimport javafx.scene.layout.BorderPane;%0Aimport javafx.scene.web.WebView;%0Aimport org.jetbrains.annotations.NotNul
 l;%0Ai
@@ -575,24 +575,73 @@
 ewPanel() %7B%0A
+    final JFXPanel javafxPanel = new JFXPanel();%0A
     final St
@@ -837,41 +837,227 @@
     
-final JBLabel label = new JBLabel
+Platform.runLater(new Runnable() %7B%0A      @Override%0A      public void run() %7B%0A%0A        BorderPane borderPane = new BorderPane();%0A        WebView webComponent = new WebView();%0A%0A        webComponent.getEngine().loadContent
 (tex
@@ -1075,106 +1075,182 @@
 ));%0A
+%0A
     
-label.setBackground(IpnbEditorUtil.getBackground());%0A    label.setOpaque(true);%0A    return lab
+    borderPane.setCenter(webComponent);%0A        Scene scene = new Scene(borderPane, 450, 450);%0A        javafxPanel.setScene(scene);%0A      %7D%0A    %7D);%0A%0A    return javafxPan
 el;%0A

use JFXPanel to render html