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:
@@ -23,6 +23,7 @@
|
||||
import { liveMarkdown, refreshImages } from "./liveMarkdown";
|
||||
import { imageDrops, trackImageDrop, clearImageDrop } from "./imageDrop";
|
||||
import { noteTitle } from "./noteTitle";
|
||||
import { fileTitleVisible } from "./fileTitle";
|
||||
import type { TableContextActions } from "./tableCellActions";
|
||||
import { markdownMenu } from "./markdownMenu";
|
||||
import { codeMenu } from "./codeMenu";
|
||||
@@ -178,11 +179,16 @@
|
||||
},
|
||||
report: message => { error = message; },
|
||||
}),
|
||||
title.of(noteTitle(markdownTitle(current.relPath), onRenameTitle ? renameTitle : undefined)),
|
||||
title.of(fileTitle(current.relPath)),
|
||||
EditorView.contentAttributes.of({ role: "textbox", "aria-label": $t("Writing editor"), "aria-multiline": "true", spellcheck: "true" }),
|
||||
];
|
||||
}
|
||||
|
||||
// The file name title, or nothing when the setting hides it.
|
||||
function fileTitle(path: string): Extension {
|
||||
return untrack(() => $fileTitleVisible) ? noteTitle(markdownTitle(path), onRenameTitle ? renameTitle : undefined) : [];
|
||||
}
|
||||
|
||||
function modeExtensions(next: NonNullable<typeof shown>): Extension {
|
||||
// Tab in a Markdown list item makes a nested item in Write and in Source.
|
||||
const lists: KeyBinding[] = next.markdown ? [{ key: "Tab", run: indentListItem, shift: outdentListItem }] : [];
|
||||
@@ -382,16 +388,19 @@
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
const name = markdownTitle(buffer.relPath);
|
||||
const path = buffer.relPath;
|
||||
void $fileTitleVisible;
|
||||
const view = editor;
|
||||
if (view && shown?.mode === "write") view.dispatch({ effects: title.reconfigure(noteTitle(name, onRenameTitle ? renameTitle : undefined)) });
|
||||
if (view && shown?.mode === "write") view.dispatch({ effects: title.reconfigure(fileTitle(path)) });
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!focusTitle || !editor || shown?.mode !== "write") return;
|
||||
const button = editor.dom.querySelector<HTMLButtonElement>(".note-title-button");
|
||||
if (!button) return;
|
||||
button.click();
|
||||
// Without the title, a new note starts with the cursor in the text.
|
||||
if (button) button.click();
|
||||
else if (!$fileTitleVisible) editor.focus();
|
||||
else return;
|
||||
onTitleFocused?.();
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// The `showFileTitle` general setting shows the file name as a title above a Markdown note in Write and Read.
|
||||
import { writable } from "svelte/store";
|
||||
import { onSettingsChange } from "../settings/store.ts";
|
||||
import { DEFAULT_SETTINGS, readSettings } from "../workspace/settings.ts";
|
||||
|
||||
const visible = writable(DEFAULT_SETTINGS.showFileTitle);
|
||||
/** A store with the current state of the setting. */
|
||||
export const fileTitleVisible = { subscribe: visible.subscribe };
|
||||
|
||||
/** Apply the saved setting now and after each change in any window. Returns a function that stops it. */
|
||||
export function syncFileTitle() {
|
||||
const read = () => {
|
||||
try { visible.set(readSettings().showFileTitle); }
|
||||
catch { visible.set(DEFAULT_SETTINGS.showFileTitle); }
|
||||
};
|
||||
read();
|
||||
return onSettingsChange("general", read);
|
||||
}
|
||||
Reference in New Issue
Block a user