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:
Knotty Wyvern
2026-10-28 19:45:08 -07:00
parent ebacdb8164
commit 9cf82503d0
64 changed files with 675 additions and 590 deletions
+4 -5
View File
@@ -1,6 +1,6 @@
// Writer text menu on empty and whitespace lines: submenus, disabled actions, links, the file picker, keyboard focus, both themes, a narrow window, and the IDE.
// Writer text menu on empty and whitespace lines: submenus, disabled actions, links, the file picker, keyboard focus, both themes, a narrow window, and the Source.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/emptyMenu", async ({ page }) => {
await mockTauri(page, {
@@ -95,8 +95,7 @@ await runSmoke("editor/emptyMenu", async ({ page }) => {
await page.setViewportSize({width:1440,height:1000});
await page.getByRole('button',{name:'Show outline',exact:true}).click();
}
await page.getByRole('group',{name:'Editor layout'}).hover();
await page.getByRole('button',{name:'IDE',exact:true}).click();
await chooseView(page, 'Source');
await page.locator('.source-editor .cm-content').waitFor();
await page.locator('.source-editor .cm-content').focus();
await page.keyboard.press('Shift+F10');
@@ -112,5 +111,5 @@ await runSmoke("editor/emptyMenu", async ({ page }) => {
await page.keyboard.press('Enter');
await page.getByRole('dialog').waitFor({state:'detached'});
await page.screenshot({path:`${output}/ide-links.png`});
console.log('PASS: empty and whitespace Writer menus, full submenus, disabled actions, links, picker, selection, keyboard focus, two themes, narrow viewport and IDE.');
console.log('PASS: empty and whitespace Writer menus, full submenus, disabled actions, links, picker, selection, keyboard focus, two themes, narrow viewport and Source.');
});
+3 -5
View File
@@ -1,6 +1,6 @@
// Footnotes and heading folds: the footnote menu, Reader numbering and backlinks, nested folding, keyboard toggles, and source preservation.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/footnotes", async ({ page }) => {
await mockTauri(page, {
@@ -95,8 +95,7 @@ await runSmoke("editor/footnotes", async ({ page }) => {
const borders = await page.locator(".writer-heading").evaluateAll(headings => headings.map(heading => getComputedStyle(heading).borderBottomWidth));
assert.ok(borders.every(border => border === "0px"));
assert.ok(await page.locator(".writer-heading").first().evaluate(heading => parseFloat(getComputedStyle(heading).paddingTop) > 8));
await page.getByRole("group", { name: "Document view" }).hover();
await page.getByRole("button", { name: "Read", exact: true }).click();
await chooseView(page, "Read");
await page.locator(".md-footnotes").waitFor();
assert.equal(await page.locator(".md-footnote-ref").count(), 2);
assert.equal(await page.locator(".md-footnotes li").count(), 1);
@@ -117,8 +116,7 @@ await runSmoke("editor/footnotes", async ({ page }) => {
assert.equal(await page.locator(".md-footnotes").isVisible(), true);
await page.locator(".md-footnote-back").first().click();
assert.equal(await page.evaluate(() => document.activeElement?.id), "rs-fnref-1-1");
await page.getByRole("group", { name: "Document view" }).hover();
await page.getByRole("button", { name: "Edit", exact: true }).click();
await chooseView(page, "Write");
await page.getByRole("textbox", { name: "Writing editor", exact: true }).waitFor();
await editor();
}
+2 -4
View File
@@ -1,6 +1,6 @@
// Images dragged from the file tree: hidden source, selection, image menu actions, cancel, and source mode.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/imageNavigation", async ({ page }) => {
await mockTauri(page, {
@@ -143,9 +143,7 @@ await runSmoke("editor/imageNavigation", async ({ page }) => {
await page.keyboard.press("Escape");
assert.equal(await page.locator(".cm-line").filter({ hasText: "![Reference]" }).count(), 0);
// The same navigator drag works in the source editor.
// The layout switcher names its buttons by mode (src/lib/layout/EditorPane.svelte:200-208, src/lib/ui/ModeSwitcher.svelte:96).
await page.getByRole("group", { name: "Editor layout", exact: true }).hover();
await page.getByRole("button", { name: "IDE", exact: true }).click();
await chooseView(page, "Source");
await page.locator(".source-editor .cm-content").waitFor();
await dragFromTree(".source-editor .cm-content");
await page.keyboard.press("Control+s");
+4 -4
View File
@@ -138,15 +138,15 @@ await runSmoke("editor/images", async ({ page }) => {
}, "../attachments/typed.svg");
await page.locator('img[alt="Wiki image"]').waitFor();
await save();
await page.getByRole("group", { name: "Document view" }).getByRole("button", { name: "Edit", exact: true }).focus();
await page.keyboard.press("ArrowRight");
await page.getByRole("radiogroup", { name: "View" }).getByRole("radio", { name: "Write", exact: true }).focus();
await page.keyboard.press("End");
await page.locator(".md-page .md-image-frame").first().hover();
await page.locator(".md-page").getByRole("button", { name: "Zoom in", exact: true }).first().click();
await page.getByRole("dialog", { name: "Image zoom" }).waitFor();
await page.keyboard.press("Escape");
// Source mode uses the same drop flow; the batch is one undo step.
await page.getByRole("group", { name: "Document view" }).getByRole("button", { name: "Read", exact: true }).focus();
// Source uses the same drop flow. The batch is one undo step.
await page.getByRole("radiogroup", { name: "View" }).getByRole("radio", { name: "Read", exact: true }).focus();
await page.keyboard.press("Home");
await page.keyboard.press("Control+e");
await page.locator(".source-editor .cm-content").waitFor();
+4 -6
View File
@@ -1,6 +1,6 @@
// Writer interactions: code selection and copy, caret and scroll restore, Ctrl+click links, shared heading typography, and spelling targets.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/interactions", async ({ page }) => {
await page.context().grantPermissions(["clipboard-read", "clipboard-write"]);
@@ -93,7 +93,7 @@ await runSmoke("editor/interactions", async ({ page }) => {
}, linkPoint);
await page.keyboard.down("Control"); await page.mouse.click(point.x, point.y); await page.keyboard.up("Control");
await page.waitForFunction(() => document.querySelector('[role="tab"][aria-selected="true"]')?.textContent.includes("other.md"));
console.log("PASS: Writer and IDE Ctrl+click open workspace links while retaining the source tab");
console.log("PASS: Writer and Source Ctrl+click open workspace links while retaining the source tab");
await page.getByRole("tab", { name: "note.md", exact: true }).click();
await page.keyboard.press("Control+e");
@@ -106,13 +106,11 @@ await runSmoke("editor/interactions", async ({ page }) => {
}, theme);
const writing = await page.locator(".writer-h1").first().evaluate(node => { const style = getComputedStyle(node); return { size: style.fontSize, line: style.lineHeight, family: style.fontFamily, weight: style.fontWeight }; });
await page.screenshot({ path: `${output}/editor-typography-${theme}.png` });
await page.getByRole("group", { name: "Document view", exact: true }).hover();
await page.getByRole("button", { name: "Read", exact: true }).click();
await chooseView(page, "Read");
const reading = await page.locator(".reading h1:not(.document-title)").first().evaluate(node => { const style = getComputedStyle(node); return { size: style.fontSize, line: style.lineHeight, family: style.fontFamily, weight: style.fontWeight }; });
assert.deepEqual(writing, reading);
await page.screenshot({ path: `${output}/reader-typography-${theme}.png` });
await page.getByRole("group", { name: "Document view", exact: true }).hover();
await page.getByRole("button", { name: "Edit", exact: true }).click();
await chooseView(page, "Write");
await top();
}
await page.setViewportSize({ width: 640, height: 750 });
+4 -6
View File
@@ -1,6 +1,6 @@
// List nesting: Tab and Shift+Tab in Write, nested labels in Write and Read, one undo history in Write and Source, and the 4-space indent in Source.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/listNesting", async ({ page }) => {
await mockTauri(page, {
@@ -68,21 +68,19 @@ await runSmoke("editor/listNesting", async ({ page }) => {
await page.keyboard.press("Tab");
assert.equal(await doc(), "# Requirements\n\n1. Topic\n 1. Sub item\n 2. Second\n2. A\n", "The first item stays in place");
await page.getByRole("group", { name: "Document view" }).hover();
await page.getByRole("button", { name: "Read", exact: true }).click();
await chooseView(page, "Read");
await page.locator(".md-page ol ol").waitFor();
assert.equal(await page.locator(".md-page ol ol").evaluate(list => getComputedStyle(list).listStyleType), "lower-alpha");
assert.equal(await page.locator(".md-page > .reading > ol, .md-page ol").first().evaluate(list => getComputedStyle(list).listStyleType), "decimal");
await page.locator(".md-page").screenshot({ path: `${output}/reader.png` });
await page.getByRole("group", { name: "Document view" }).hover();
await page.getByRole("button", { name: "Edit", exact: true }).click();
await chooseView(page, "Write");
await page.getByRole("textbox", { name: "Writing editor", exact: true }).waitFor();
// Write and Source share the undo history of the document.
await caretAt("2. A");
await page.keyboard.type(" more");
await page.keyboard.press("Control+e");
await page.locator('.source-editor[data-chrome="Ide"] .cm-gutters').waitFor();
await page.locator('.source-editor[data-chrome="Source"] .cm-gutters').waitFor();
assert.equal(await page.locator(".source-editor .cm-content").getAttribute("data-language"), "markdown");
await page.locator(".source-editor .cm-content").focus();
await page.keyboard.press("Control+z");
+4 -2
View File
@@ -31,7 +31,8 @@ await runSmoke("editor/markdownMenu", async ({ page }) => {
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
await page.getByRole("dialog").getByRole("button").filter({ hasText: name }).first().click();
await page.getByRole("tab", { selected: true }).click({ button: "right" });
await page.getByRole("menuitem", { name: "Source mode", exact: true }).click();
await page.getByRole("menuitem", { name: "View", exact: true }).click();
await page.getByRole("menuitemradio", { name: "Source", exact: true }).click();
await page.locator(".source-editor .cm-content").waitFor();
}
async function waitForText(text) {
@@ -56,7 +57,8 @@ await runSmoke("editor/markdownMenu", async ({ page }) => {
await waitForText("**First** paragraph.\n\nSecond paragraph.\n");
await page.keyboard.press("Control+z"); await waitForText(source);
await page.getByRole("tab", { selected: true }).click({ button: "right" });
await page.getByRole("menuitem", { name: "Writing mode", exact: true }).click();
await page.getByRole("menuitem", { name: "View", exact: true }).click();
await page.getByRole("menuitemradio", { name: "Write", exact: true }).click();
const writer = page.getByRole("textbox", { name: "Writing editor", exact: true });
await writer.click(); await page.keyboard.press("Control+Home");
await page.keyboard.press("Control+Shift+ArrowRight");
@@ -1,19 +0,0 @@
// The document mode switcher expands within 500 ms when the pointer hovers it.
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/modeSwitcherHover", async ({ page }) => {
await mockTauri(page, {
commands: test => ({
...test.workspace({ root: "C:\\mode-switcher", files: { "a.md": "# Alpha\n\nTemplate body.\n" } }),
plugins_snapshot: () => ({ plugins: [], issues: [] }),
spelling_menu_install: () => null,
}),
});
await page.goto(smokeUrl);
await page.locator('[data-tree-rel="a.md"]').click();
await page.locator(".cm-content").waitFor();
await page.locator(".mode-switcher").first().hover();
await page.waitForFunction(() => document.querySelector(".mode-switcher")?.classList.contains("expanded"), null, { timeout: 500 });
await page.mouse.move(500, 400);
console.log("PASS: the mode switcher expands on hover");
}, { timeout: 15000 });
+2 -2
View File
@@ -1,4 +1,4 @@
// Repeated copy and paste of formatted Markdown stays exact across saves, tab switches, IDE switches, and line endings.
// Repeated copy and paste of formatted Markdown stays exact across saves, tab switches, Source switches, and line endings.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
@@ -94,5 +94,5 @@ await runSmoke("editor/pasteRepeat", async ({ page }) => {
});
assert.equal(synchronized, true, 'Writer and saved source agree');
}
console.log('PASS: formatted Markdown copied across notes stays exact through 12 paste/delete cycles, saves, tab reopen, IDE reopen, and LF/CRLF/CR clipboard replacement');
console.log('PASS: formatted Markdown copied across notes stays exact through 12 paste/delete cycles, saves, tab reopen, Source reopen, and LF/CRLF/CR clipboard replacement');
});
+3 -5
View File
@@ -1,6 +1,6 @@
// Front matter properties: first open, editing, undo, the saved selection, and both themes.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/properties", async ({ page }) => {
await mockTauri(page, {
@@ -47,11 +47,9 @@ await runSmoke("editor/properties", async ({ page }) => {
await page.evaluate(() => window.__CM__.dispatch({ selection: { anchor: window.__CM__.state.doc.length } }));
await page.locator('.md-properties').waitFor();
await page.evaluate(() => { window.__CM__.dispatch({ selection: { anchor: 11 } }); window.__CM__.focus(); });
await page.getByRole('group', { name: 'Document view' }).hover();
await page.getByRole('button', { name: 'Read', exact: true }).click();
await chooseView(page, 'Read');
await page.locator('.reading .md-properties').waitFor();
await page.getByRole('group', { name: 'Document view' }).hover();
await page.getByRole('button', { name: 'Edit', exact: true }).click();
await chooseView(page, 'Write');
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
assert.equal(await page.locator('.writer-preview .md-properties').count(), 0);
console.log('Properties first-open, editing, undo, saved selection, and both themes passed.');
+2 -3
View File
@@ -1,7 +1,7 @@
// Text selection uses --rs-selection in Writer (native and CodeMirror layers) and in Read view, in both themes.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const name = "editor/selectionColor";
await runSmoke(name, async ({ browser }) => {
@@ -36,8 +36,7 @@ await runSmoke(name, async ({ browser }) => {
assert.equal(colors.native, colors.expected);
assert.equal(colors.layer, colors.expected);
await page.screenshot({ path: path.join(output, `${theme}-writer-selection.png`) });
await page.getByRole("group", { name: "Document view", exact: true }).hover();
await page.getByRole("button", { name: "Read", exact: true }).click();
await chooseView(page, "Read");
const reader = page.locator(".reading");
await reader.waitFor();
assert.equal(await reader.evaluate(node => getComputedStyle(node, "::selection").backgroundColor), colors.expected);
+8 -12
View File
@@ -1,6 +1,6 @@
// Editor menu surfaces: Writer, spelling, IDE, and code menus share the file menu styles; and the code tint match in both themes.
// Editor menu surfaces: Writer, spelling, Source, and code menus share the file menu styles; and the code tint match in both themes.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
import { chooseView, mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/surfaces", async ({ page }) => {
await mockTauri(page, {
@@ -85,22 +85,19 @@ await runSmoke("editor/surfaces", async ({ page }) => {
const tint = await page.locator('.writer-code-line').first().evaluate(node => getComputedStyle(node).backgroundColor);
assert.ok(tint.includes('/ 0.82') || /rgba\(.+, 0\.82\)/.test(tint), `Writer code tint: ${tint}`);
await page.screenshot({ path: `${output}/writer-code-${theme}.png` });
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
await page.getByRole('button', { name: 'Read', exact: true }).click();
await chooseView(page, 'Read');
const readingTint = await page.locator('pre.md-code').evaluate(node => getComputedStyle(node).backgroundColor);
assert.equal(readingTint, tint, 'Reader and Writer use the same code tint');
await page.screenshot({ path: `${output}/reader-code-${theme}.png` });
await page.getByRole('button', { name: 'Edit', exact: true }).click();
await page.getByRole('group', { name: 'Editor layout', exact: true }).hover();
await page.getByRole('button', { name: 'IDE', exact: true }).click();
await chooseView(page, 'Source');
await page.locator('.source-editor .cm-content').waitFor();
await page.locator('.source-editor').click({ button: 'right', position: { x: 500, y: 400 } });
assert.deepEqual(await styles(writer), reference, 'Markdown IDE retains the same menu');
assert.deepEqual(await styles(writer), reference, 'Markdown Source retains the same menu');
await dismiss();
await page.locator('[data-tree-rel="sample.txt"]').click();
await page.locator('.source-editor').click({ button: 'right', position: { x: 500, y: 400 } });
const code = menu('Code text actions');
assert.deepEqual(await styles(code), reference, 'Code IDE uses the host menu');
assert.deepEqual(await styles(code), reference, 'Code Source uses the host menu');
// The host menu is the only menu. The editor adds no menu of its own.
assert.equal(await page.getByRole('menu').count(), 1);
assert.equal(await code.getByRole('menuitem', { name: 'Command palette F1', exact: true }).count(), 0);
@@ -128,9 +125,8 @@ await runSmoke("editor/surfaces", async ({ page }) => {
await page.getByRole('button', { name: 'Files', exact: true }).click();
await page.getByRole('button', { name: 'Show outline', exact: true }).click();
await page.locator('[data-tree-rel="a.md"]').click();
await page.getByRole('group', { name: 'Editor layout', exact: true }).hover();
await page.getByRole('button', { name: 'Writer', exact: true }).click();
report.push({ theme, passed: ['word and blank menu parity', 'spelling correction and undo', 'Writer/IDE parity', 'undo menu action', 'code menu host styles', 'transparent code in Writer/Reader', 'narrow keyboard menu'], nativeDesktop: 'not tested' });
await chooseView(page, 'Write');
report.push({ theme, passed: ['word and blank menu parity', 'spelling correction and undo', 'Writer/Source parity', 'undo menu action', 'code menu host styles', 'transparent code in Writer/Reader', 'narrow keyboard menu'], nativeDesktop: 'not tested' });
}
console.log(JSON.stringify(report, null, 2));
}, { timeout: 15000 });
+3 -3
View File
@@ -1,4 +1,4 @@
// Undo history survives tab switches, window focus, IDE edits, and table cell edits.
// Undo history survives tab switches, window focus, Source edits, and table cell edits.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
@@ -77,7 +77,7 @@ await runSmoke("editor/undoHistory", async ({ page }) => {
window.__IDE__ = view;
});
await page.keyboard.type(' second edit');
assert.equal(await page.evaluate(() => window.__IDE__.dom.isConnected), true, 'Typing keeps the same IDE editor mounted');
assert.equal(await page.evaluate(() => window.__IDE__.dom.isConnected), true, 'Typing keeps the same Source editor mounted');
assert.equal(await page.evaluate(() => window.__IDE__.state.doc.toString()), original + ' first edit second edit');
await page.keyboard.press('Control+e');
await expectWriter(original + ' first edit second edit');
@@ -91,7 +91,7 @@ await runSmoke("editor/undoHistory", async ({ page }) => {
await expectWriter(original + ' first edit');
await page.keyboard.press('Control+y');
await expectWriter(original + ' first edit second edit');
console.log('PASS: Writer undo includes edits from IDE mode');
console.log('PASS: Writer undo includes edits from Source mode');
const tableSource = '# Table\n\n| A | B |\n| --- | --- |\n| One | Two |\n\nTail.\n';
await page.evaluate(source => {
window.__TEST__.files.set('table.md', source);