/** * The IDEA-style shell (Islands): title bar, tool window stripes and island * panels around the editor area on the frame background, status bar, and the * overlay layer. Without an open project the welcome view replaces the frame, * or, editing loose files (LightEdit), a frame with the editor only. */ import { useSyncExternalStore } from "react"; import { useEditorRegistry } from "@/editor/api"; import { Breadcrumbs } from "@/editor/core"; import { basename, useProject } from "@/platform/project"; import { isUntitledUri, untitledTitle } from "@/platform/virtualDocs"; import { useT } from "@/platform/i18n"; import { ProgressBar } from "@/ui"; import projectMark from "../../src-tauri/icons/source/openidea-mark.svg"; import { useDistractionFree } from "./distractionFree"; import { EditorArea } from "./EditorArea"; import { OverlayHost } from "./OverlayHost"; import { subscribeTabColors, tabColorOverride, tabColorVars, tabColorsVersion } from "./tabColors"; import { StatusBar } from "./StatusBar"; import { TitleBar } from "./TitleBar"; import { WindowGroupTabs } from "./WindowGroupTabs"; import { useApplyTheme } from "./theme"; import { ToolWindowLayout } from "./toolwindows/ToolWindows"; import { Welcome } from "./Welcome"; import { WindowResizeHandles } from "./WindowResizeHandles"; import { useContributions, useStandaloneEditor } from "./contributions"; import styles from "./Workbench.module.css"; /** View › Appearance switches (`appearance.showMainToolbar`, `appearance.showStatusBar`), shown by default. */ function useAppearanceFlag(key: "showMainToolbar" | "showStatusBar"): boolean { return useProject((s) => s.settings?.appearance?.[key] !== false); } /** Where View › Appearance › Navigation Bar puts the file path breadcrumbs. */ type NavigationBarPosition = "top" | "statusBar" | "hidden"; function useNavigationBarPosition(): NavigationBarPosition { const position = useProject((s) => s.settings?.appearance?.navigationBar); // Nothing loaded yet, or a malformed value: match the backend default (`statusBar`). return position === "top" || position === "statusBar" || position === "hidden" ? position : "statusBar"; } /** LightEdit: editor tabs only; no tool windows, toolbar widgets or project status items. */ function LightEditFrame({ title }: { title?: string }) { const path = useEditorRegistry((s) => s.active?.ctx.path); const distractionFree = useDistractionFree((s) => s.active); const statusBar = useAppearanceFlag("showStatusBar"); const name = path ? (isUntitledUri(path) ? untitledTitle(path) : basename(path)) : "LightEdit"; return ( <>
{!distractionFree && statusBar && } ); } function ProjectOpening({ path }: { path: string }) { const t = useT(); const label = t("app.project.opening", { name: basename(path) || path }); return (
{label}
{path}
); } export function Workbench() { useApplyTheme(); useSyncExternalStore(subscribeTabColors, tabColorsVersion); const banners = useContributions((s) => s.workbenchBanners); const project = useProject((s) => s.project); const lightEdit = useProject((s) => s.lightEdit); const standaloneTitle = useStandaloneEditor((s) => s.title); const openingPath = useProject((s) => s.openingPath); const root = project?.root ?? null; const distractionFree = useDistractionFree((s) => s.active); const mainToolbar = useAppearanceFlag("showMainToolbar"); const statusBar = useAppearanceFlag("showStatusBar"); const navBarPosition = useNavigationBarPosition(); const frame = project ? styles.framed : lightEdit || standaloneTitle ? styles.lightEditFrame : undefined; const tintName = openingPath ? basename(openingPath) || openingPath : project?.name; const tintRoot = openingPath ?? root; return (
{project ? ( <> {!distractionFree && navBarPosition === "top" && } {!distractionFree && } {[...banners.values()].map(({ id, component: Banner }) => ( ))} } /> {!distractionFree && statusBar && } ) : lightEdit || standaloneTitle ? ( ) : ( )}
{openingPath && }
); }