diff --git a/docs/en/guide/editor.mdx b/docs/en/guide/editor.mdx index 294d27e0e6..3f53f2fb67 100644 --- a/docs/en/guide/editor.mdx +++ b/docs/en/guide/editor.mdx @@ -145,6 +145,8 @@ Tab placement, the tab limit and what happens when it is reached, the preview ta With tabs placed left or right, the tab column is as wide as its longest name, up to a limit. Drag the column's inner edge (or focus it and press `←` / `→`) to change the limit; it applies to every editor group and is remembered. +Double-click a tab, or the empty part of the tab strip, to maximize the editor: all tool windows are hidden, and doing it again brings them back. Double-clicking a preview tab keeps it open as a regular tab instead. + ## Split editors | Action | macOS | Windows / Linux | diff --git a/docs/zh/guide/editor.mdx b/docs/zh/guide/editor.mdx index d292cc19a2..da721ae6ac 100644 --- a/docs/zh/guide/editor.mdx +++ b/docs/zh/guide/editor.mdx @@ -143,6 +143,8 @@ description: "多光标与选区、行编辑、剪贴板历史、代码折叠、 标签页放在左侧或右侧时,标签页列的宽度随最长的名称变化,但不超过一个上限。拖动该列靠近编辑器的边缘(或聚焦后按 `←` / `→`)可以调整上限;调整对所有编辑器组生效,并会被记住。 +双击标签页或标签页栏的空白处可以最大化编辑器:隐藏所有工具窗口,再双击一次即恢复。双击预览标签页则会把它转为常规标签页。 + ## 拆分编辑器 | 操作 | macOS | Windows / Linux | diff --git a/src/editor/core/view/EditorArea.tsx b/src/editor/core/view/EditorArea.tsx index 08fa0a23b1..2a917b01d0 100644 --- a/src/editor/core/view/EditorArea.tsx +++ b/src/editor/core/view/EditorArea.tsx @@ -399,6 +399,8 @@ function PaneView({ paneId }: { paneId: string }) { onCloseOthers={(id) => void ctrl.closeOthers(paneId, id)} onTogglePin={(id) => ctrl.togglePin(paneId, id)} closeOnShiftClick + // IDEA: a double click on the strip's empty part maximizes the editor, as on a tab. + onBlankDoubleClick={() => void executeAction("toolwindow.hideAll")} onDoubleClick={(id) => { // IDEA: a preview tab becomes a regular one; any other tab maximizes the editor. if (pane.tabs.find((t) => t.id === id)?.preview) ctrl.keepTab(paneId, id); diff --git a/src/ui/Tabs.test.tsx b/src/ui/Tabs.test.tsx index d5ebc4d1c4..56f5d7501c 100644 --- a/src/ui/Tabs.test.tsx +++ b/src/ui/Tabs.test.tsx @@ -103,6 +103,16 @@ describe("Tabs interactions", () => { expect(onClose).toHaveBeenCalledWith("b"); }); + it("double click on the empty strip calls onBlankDoubleClick, not on a tab", () => { + const onBlank = vi.fn(); + const { container } = render( {}} onBlankDoubleClick={onBlank} />); + fireEvent.doubleClick(screen.getByRole("tab", { name: "A" })); + expect(onBlank).not.toHaveBeenCalled(); + fireEvent.doubleClick(screen.getByRole("tablist")); + fireEvent.doubleClick(container.firstElementChild!); + expect(onBlank).toHaveBeenCalledTimes(2); + }); + it("Shift+left-click closes an editor tab without selecting it", () => { const onClose = vi.fn(); const onSelect = vi.fn(); diff --git a/src/ui/Tabs.tsx b/src/ui/Tabs.tsx index 57368298fa..2c6d8b1787 100644 --- a/src/ui/Tabs.tsx +++ b/src/ui/Tabs.tsx @@ -136,6 +136,8 @@ export interface TabsProps { /** Shift+left-click a tab closes it (editor tabs; plain clicks still select). */ closeOnShiftClick?: boolean; onDoubleClick?: (id: string) => void; + /** Double click on the empty part of the strip (not on a tab or button), e.g. to maximize the editor. */ + onBlankDoubleClick?: () => void; onContextMenu?: (id: string, e: MouseEvent) => void; /** `editor`: 30px with separators (editor tabs); `compact`: 28px plain (popups, tool window sub-tabs). */ variant?: "editor" | "compact"; @@ -176,6 +178,7 @@ export function Tabs({ onTogglePin, closeOnShiftClick, onDoubleClick, + onBlankDoubleClick, onContextMenu, variant = "editor", trailing, @@ -397,7 +400,18 @@ export function Tabs({ ); return ( -
+
{ + // Only the strip's own background counts: tabs, buttons and trailing content handle their own clicks. + if (e.target === e.currentTarget || e.target === scrollRef.current) onBlankDoubleClick(); + } + : undefined + } + > {vertical && trailing &&
{trailing}
}