Show one view control and name the file once
Phase 5-3. - One radio group shows Write, Source, and Read at all times, with an icon and a name. Narrow panes show only the icons. The arrow keys move the choice, and the group has one Tab stop. The current choice gets the selection fill and an accent bar. Hover gets only a fill. - A Split toggle shows Read beside Write or Source. Each document pane keeps a split flag beside its reading flag. Read ends Split. - Ctrl+Shift+E switches between Read and the editor. Ctrl+E still switches between Write and Source. - "IDE" becomes "Source" in the Chrome type, the tab menu (a View submenu), the status bar, the catalog, the tests, and the docs. - Settings, General, File name title hides the title in Write and Read. It is on by default. - The breadcrumb shows only the folder of the file. The status bar shows the view, not the path. - ModeSwitcher.svelte and its hover test are gone. The new test layout/viewModes covers the control. - The command palette from 5-2 gets its row in docs/menu-surfaces.json. - The user guide Format table is whole again. The 5-2 edit had put the Paragraph and Insert rows under the shortcut table. - 8 new catalog rows and 10 removed rows, in French, Japanese, and Simplified Chinese. - Docs: UI-049, the user guide, ui-design.md, document-tools.md, development.md, and the README feature list. Tests: the new layout/viewModes, new cases in documentPanes.spec.ts and settings.spec.ts, and the chooseView harness helper. 21 smoke tests use the new control. Tests that read the full path from the breadcrumb now read its tooltip.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { paneBounds, removePane, splitPane, type SplitLayout } from "./splitLayout.ts";
|
||||
|
||||
export type DocumentPane = { id: string; documentId: string | null; reading: boolean };
|
||||
/** `reading` shows only the Read view. `split` shows the Read view beside the editor. A pane never has both. */
|
||||
export type DocumentPane = { id: string; documentId: string | null; reading: boolean; split: boolean };
|
||||
export type DocumentPanes = { layout: SplitLayout; panes: DocumentPane[]; active: string };
|
||||
|
||||
export function initialDocumentPanes(): DocumentPanes {
|
||||
return { layout: "document-main", panes: [{ id: "document-main", documentId: null, reading: false }], active: "document-main" };
|
||||
return { layout: "document-main", panes: [{ id: "document-main", documentId: null, reading: false, split: false }], active: "document-main" };
|
||||
}
|
||||
|
||||
export function selectPane(state: DocumentPanes, id: string): DocumentPanes {
|
||||
@@ -14,7 +15,7 @@ export function selectPane(state: DocumentPanes, id: string): DocumentPanes {
|
||||
/** Tabs own documents. Panes keep only a reference and local viewing state. */
|
||||
export function syncDocumentPanes(state: DocumentPanes, live: readonly string[], selected: string | null): DocumentPanes {
|
||||
const ids = new Set(live);
|
||||
let panes = state.panes.map(pane => pane.documentId && !ids.has(pane.documentId) ? { ...pane, documentId: null, reading: false } : pane);
|
||||
let panes = state.panes.map(pane => pane.documentId && !ids.has(pane.documentId) ? { ...pane, documentId: null, reading: false, split: false } : pane);
|
||||
let active = state.active;
|
||||
if (selected && ids.has(selected)) {
|
||||
const existing = panes.find(pane => pane.documentId === selected);
|
||||
@@ -39,7 +40,7 @@ export function splitDocumentPane(state: DocumentPanes, source: string, document
|
||||
if (!state.panes.some(pane => pane.id === source) || state.panes.some(pane => pane.id === paneId)) return state;
|
||||
return {
|
||||
layout: splitPane(state.layout, source, paneId, "right"),
|
||||
panes: [...state.panes, { id: paneId, documentId, reading: false }], active: paneId,
|
||||
panes: [...state.panes, { id: paneId, documentId, reading: false, split: false }], active: paneId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,5 +55,10 @@ export function closeDocumentPane(state: DocumentPanes, id: string): DocumentPan
|
||||
}
|
||||
|
||||
export function readDocumentPane(state: DocumentPanes, id: string, reading: boolean): DocumentPanes {
|
||||
return { ...state, panes: state.panes.map(pane => pane.id === id ? { ...pane, reading } : pane) };
|
||||
return { ...state, panes: state.panes.map(pane => pane.id === id ? { ...pane, reading, split: reading ? false : pane.split } : pane) };
|
||||
}
|
||||
|
||||
/** Show or hide the Read view beside the editor. Split ends the Read-only view. */
|
||||
export function splitDocumentView(state: DocumentPanes, id: string, split: boolean): DocumentPanes {
|
||||
return { ...state, panes: state.panes.map(pane => pane.id === id ? { ...pane, split, reading: split ? false : pane.reading } : pane) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user