import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";

// The webview's own context menu offers Reload, Back and Inspect — page
// actions in something that is not meant to read as a page. Text fields keep
// theirs so copy and paste stay reachable.
document.addEventListener("contextmenu", (e) => {
  const el = e.target as HTMLElement | null;
  const editable =
    el?.closest("input, textarea, [contenteditable='true']") !== null &&
    el?.closest("input, textarea, [contenteditable='true']") !== undefined;
  if (!editable) e.preventDefault();
});

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);
