@Nullable
  private static DocRenderer.EditorInlineHtmlPane redispatchEvent(@NotNull EditorMouseEvent event,
                                                                  // we need a separately passed eventId because EditorImpl dispatches MOUSE_RELEASED
                                                                  // events to both 'mouseReleased' and 'mouseClicked' methods in listeners
                                                                  int eventId,
                                                                  @Nullable DocRenderer.EditorInlineHtmlPane targetPane) {
    MouseEvent mouseEvent = event.getMouseEvent();
    Point mousePoint = mouseEvent.getPoint();
    Editor editor = event.getEditor();
    FoldRegion foldRegion = event.getCollapsedFoldRegion();
    if (foldRegion instanceof CustomFoldRegion cfr) {
      CustomFoldRegionRenderer r = cfr.getRenderer();
      if (r instanceof DocRenderer renderer) {
        Rectangle relativeBounds = renderer.getEditorPaneBoundsWithinRenderer(cfr.getWidthInPixels(), cfr.getHeightInPixels());
        Point location = cfr.getLocation();
        assert location != null;
        int x = mousePoint.x - location.x - relativeBounds.x;
        int y = mousePoint.y - location.y - relativeBounds.y;
        if (x >= 0 && x < relativeBounds.width && y >= 0 && y < relativeBounds.height) {
          DocRenderer.EditorInlineHtmlPane editorInlineHtmlPane = renderer.getRendererComponent(editor, relativeBounds.width, null);
          if (eventId != MouseEvent.MOUSE_DRAGGED || targetPane == editorInlineHtmlPane) {
            int button = mouseEvent.getButton();
            dispatchEvent(editorInlineHtmlPane, new MouseEvent(editorInlineHtmlPane, eventId, 0, mouseEvent.getModifiersEx(), x, y,
                                                               mouseEvent.getClickCount(), false,
                                                               // hack to process middle-button clicks (JEditorPane ignores them)
                                                               button == MouseEvent.BUTTON2 ? MouseEvent.BUTTON1 : button));
            return editorInlineHtmlPane;
          }
        }
      }
    }
    return null;
  }
@Nullable
  private static DocRenderer.EditorInlineHtmlPane redispatchEvent(@NotNull EditorMouseEvent event,
                                                                  // we need a separately passed eventId because EditorImpl dispatches MOUSE_RELEASED
                                                                  // events to both 'mouseReleased' and 'mouseClicked' methods in listeners
                                                                  int eventId,
                                                                  @Nullable DocRenderer.EditorInlineHtmlPane targetPane)