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
+3 -3
View File
@@ -1,4 +1,4 @@
// File tree drags into Writer and the IDE: documents become escaped links, images embed, and undo restores the source.
// File tree drags into Writer and the Source: documents become escaped links, images embed, and undo restores the source.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
@@ -73,9 +73,9 @@ await runSmoke("links/fileDragLinks", async ({ page }) => {
assert.equal(await page.evaluate(() => window.dragSource.hasFocus), true);
await page.keyboard.press("Control+z");
await page.waitForFunction(expected => window.dragSource.state.doc.toString() === expected, originalIde, { timeout: 3000 });
assert.equal(await ideSource(), originalIde, "IDE undo restores the exact source");
assert.equal(await ideSource(), originalIde, "Source undo restores the exact source");
await drag("images/diagram (#1).svg", ".source-editor .cm-content");
assert.ok((await ideSource()).includes("![](../images/diagram%20%28%231%29.svg)"));
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(call => ["workspace_rename", "workspace_write_bytes"].includes(call.command)).length), 0);
console.log("PASS: IDE drags insert escaped document links and image embeds, undo restores the source, and no file moves");
console.log("PASS: Source drags insert escaped document links and image embeds, undo restores the source, and no file moves");
}, { timeout: 15000 });
+9 -11
View File
@@ -1,6 +1,6 @@
// Link context menus in the Writer, Reading, IDE, and table cells: browser and workspace actions, Edit link with undo, keyboard use, narrow windows, bookmarks, rename, and move.
// Link context menus in the Writer, Reading, Source, and table cells: browser and workspace actions, Edit link with undo, keyboard use, narrow windows, bookmarks, rename, and move.
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("links/linkMenus", async ({ page }) => {
const output = await outputDir("links/linkMenus");
@@ -79,7 +79,7 @@ await runSmoke("links/linkMenus", async ({ page }) => {
await writerMenu('Workspace note'); await item('Show in system explorer').click(); await page.waitForFunction(() => window.__TEST__.revealed === 'b.md');
await writerMenu('Workspace note'); await item('Reveal file in navigation').click();
await page.waitForFunction(() => document.activeElement?.getAttribute('data-tree-rel') === 'b.md');
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 = page.locator('.reading');
await reading.getByText('Selected reading text.',{exact:true}).evaluate(node => { const range = document.createRange(); range.selectNodeContents(node); const s = getSelection(); s.removeAllRanges(); s.addRange(range); node.closest('.reading').focus(); });
await page.keyboard.press('Shift+F10');
@@ -105,15 +105,13 @@ await runSmoke("links/linkMenus", async ({ page }) => {
await page.setViewportSize({width:1440,height:1000});
await page.getByRole('button', { name: 'Files', exact: true }).click();
await page.getByRole('button', { name: 'Show outline', exact: true }).click();
await page.getByRole('group', { name: 'Document view', exact: true }).hover();
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.evaluate(async () => { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); const view=EditorView.findFromDOM(document.querySelector('.source-editor .cm-content')); view.dispatch({selection:{anchor:view.state.doc.toString().indexOf('Web label')+2}}); view.focus(); });
await page.keyboard.press('Shift+F10'); await item('Edit link').click();
assert.equal(await page.evaluate(async () => { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); const {state}=EditorView.findFromDOM(document.querySelector('.source-editor .cm-content')); return state.sliceDoc(state.selection.main.from,state.selection.main.to); }), 'https://example.com/path');
await page.screenshot({ path: `${output}/ide-edit-url-${theme}.png` });
await page.getByRole('group', { name:'Editor layout',exact:true }).hover(); await page.getByRole('button',{name:'Writer',exact:true}).click();
await chooseView(page, 'Write');
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
const cellLink = page.locator('.writer-table a').filter({hasText:'Cell web'});
await cellLink.click({button:'right'});
@@ -156,7 +154,7 @@ await runSmoke("links/linkMenus", async ({ page }) => {
await page.setViewportSize({width:1440,height:1000});
await page.getByRole('button',{name:'Files',exact:true}).click(); await page.getByRole('button',{name:'Show outline',exact:true}).click();
await page.locator('.cm-content').getByText('Selected reading text.', {exact:true}).click();
report.push({theme,passed:['Writer and IDE edit URL selection','browser destinations','workspace file actions','Reader copy/search/link actions','inline table web/wiki link edits and undo','table source Escape and keyboard menu','keyboard focus return','narrow viewport'],nativeDesktop:'not tested'});
report.push({theme,passed:['Writer and Source edit URL selection','browser destinations','workspace file actions','Reader copy/search/link actions','inline table web/wiki link edits and undo','table source Escape and keyboard menu','keyboard focus return','narrow viewport'],nativeDesktop:'not tested'});
}
await writerMenu('Workspace note'); await item('Open in new window').click();
await page.waitForFunction(() => window.__TEST__.windows.length === 1);
@@ -167,7 +165,7 @@ await runSmoke("links/linkMenus", async ({ page }) => {
await page.waitForFunction(() => JSON.parse(window.__TEST__.files.get('.runestone/marks.json') || '{}').bookmarks?.includes('b.md'));
await writerMenu('Workspace note'); await item('Copy path').focus(); await page.keyboard.press('ArrowRight'); await item('System path').click();
await page.waitForFunction(() => window.__TEST__.clipboard.endsWith('\\b.md'));
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Read', exact:true }).click();
await chooseView(page, 'Read');
const readerWorkspaceMenu = async () => { await page.locator('.reading').getByRole('link',{name:'Workspace note'}).click({button:'right'}); };
await readerWorkspaceMenu(); await item('Open in default app').click();
await page.waitForFunction(() => window.__TEST__.app === 'b.md');
@@ -175,9 +173,9 @@ await runSmoke("links/linkMenus", async ({ page }) => {
await page.getByLabel('New file name').fill('renamed.md'); await page.getByRole('button',{name:'Continue',exact:true}).click();
await page.waitForFunction(() => window.__TEST__.files.has('renamed.md') && !window.__TEST__.files.has('b.md'));
assert.equal(await page.evaluate(() => JSON.parse(window.__TEST__.files.get('.runestone/marks.json')).bookmarks.includes('renamed.md')),true);
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Edit', exact:true }).click();
await chooseView(page, 'Write');
await page.locator('.cm-content').evaluate(async node => { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); const view=EditorView.findFromDOM(node); const from=view.state.doc.toString().indexOf('b.md'); view.dispatch({changes:{from,to:from+4,insert:'renamed.md'}}); });
await page.getByRole('group', { name: 'Document view', exact: true }).hover(); await page.getByRole('button', { name:'Read', exact:true }).click();
await chooseView(page, 'Read');
await readerWorkspaceMenu(); await item('Move file to…').click();
await page.getByLabel('Move file to (workspace path, including filename)').fill('notes/moved.md'); await page.getByRole('button',{name:'Continue',exact:true}).click();
await page.waitForFunction(() => window.__TEST__.files.has('notes/moved.md') && !window.__TEST__.files.has('renamed.md'));
+9 -14
View File
@@ -1,6 +1,6 @@
// Section links: heading anchors in the Writer, Reading, Split, and IDE views, an encoded duplicate heading in another file, a missing section, and folded headings, in both themes.
// Section links: heading anchors in the Writer, Reading, Split, and Source views, an encoded duplicate heading in another file, a missing section, and folded headings, 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("links/sectionLinks", async ({ page }) => {
const output = await outputDir("links/sectionLinks");
@@ -27,11 +27,6 @@ await runSmoke("links/sectionLinks", async ({ page }) => {
const filler = Array.from({ length: 50 }, (_, i) => `Paragraph ${i}. Some text before the destination.\n`).join('\n');
const source = '# Install and start\n\nChoose [Windows setup](#windows-installer), [macOS setup](#macos-installer-apple-silicon), or [Linux setup](#linux-intelamd-64-bit).\n\n[Other document](other.md#caf%C3%A9-setup-1)\n\n[Missing section](#no-such-section)\n\n' + filler + '\n## Windows installer\n\nWindows instructions.\n\n' + filler + '\n## macOS installer (Apple Silicon)\n\nMac instructions.\n\n' + filler + '\n## Linux (Intel/AMD 64-bit)\n\nLinux instructions.\n';
const other = '# Other\n\n## Café setup\n\nFirst.\n\n' + filler + '\n## Café setup\n\nSecond.\n';
async function choose(group, value) {
const control = page.getByRole('group', { name: group, exact: true });
await control.hover();
await control.locator(`[data-value="${value}"]`).click();
}
async function writerJump(label, line) {
const link = page.locator('.cm-content .writer-link').filter({ hasText: label }).first();
await link.click({ modifiers: ['Control'] });
@@ -99,24 +94,24 @@ await runSmoke("links/sectionLinks", async ({ page }) => {
assert.equal(await page.getByRole('tab', { name:'a.md', exact:true }).count(), 1);
await page.getByRole('tab', { name:'a.md', exact:true }).click();
await top();
await choose('Document view', 'read');
await chooseView(page, 'Read');
await readerJump('Windows setup', 'Windows installer');
await page.screenshot({ path:`${output}/reading-${theme}-${width}.png` });
await page.locator('.md-page').evaluate(node => { node.scrollTop = 0; });
await readerJump('macOS setup', 'macOS installer (Apple Silicon)');
await page.locator('.md-page').evaluate(node => { node.scrollTop = 0; });
await readerJump('Linux setup', 'Linux (Intel/AMD 64-bit)');
await choose('Document view', 'split');
await chooseView(page, 'Split');
await page.locator('.md-page').evaluate(node => { node.scrollTop = 0; });
await readerJump('Windows setup', 'Windows installer');
await page.screenshot({ path:`${output}/split-${theme}-${width}.png` });
await choose('Document view', 'edit');
await choose('Editor layout', 'Ide');
await chooseView(page, 'Split');
await chooseView(page, 'Source');
await page.locator('.source-editor .cm-content').waitFor();
await choose('Document view', 'read');
await chooseView(page, 'Read');
await page.locator('.md-page').evaluate(node => { node.scrollTop = 0; });
await readerJump('Linux setup', 'Linux (Intel/AMD 64-bit)');
await choose('Document view', 'edit');
await chooseView(page, 'Source');
await page.waitForFunction(() => {
const node = document.querySelector('.source-editor .cm-content');
return node?.textContent.includes('Linux');
@@ -135,7 +130,7 @@ await runSmoke("links/sectionLinks", async ({ page }) => {
await writerJump('Jump to nested', folded.slice(0, folded.indexOf('## Nested')).split('\n').length);
await top();
await writerJump('Wiki section', folded.slice(0, folded.indexOf('## Nested')).split('\n').length);
await choose('Document view', 'read');
await chooseView(page, 'Read');
await page.locator('.md-page').evaluate(node => { node.scrollTop = 0; });
await page.getByRole('button', { name:'Collapse Parent', exact:true }).last().click();
await readerJump('Jump to nested', 'Nested');
+4 -4
View File
@@ -47,7 +47,7 @@ await runSmoke("links/workspaceLinks", async ({ page }) => {
assert.equal(await page.getByRole('tab',{name:'source.md',exact:true}).count(),1);
await page.screenshot({path:path.join(output, 'workspace-links-dark.png')});
await backlink('projects/source.md').click();
await page.waitForFunction(()=>document.querySelector('.breadcrumb')?.textContent==='projects/source.md');
await page.waitForFunction(()=>document.querySelector('.breadcrumb')?.title==='projects/source.md');
const writer=page.getByRole('textbox',{name:'Writing editor',exact:true});
await writer.focus(); await page.keyboard.press('Control+Home'); await page.keyboard.press('Control+a'); await page.keyboard.type('# Source\n\nNo links now.');
await page.getByRole('tab',{name:'Target.md',exact:true}).click();
@@ -60,7 +60,7 @@ await runSmoke("links/workspaceLinks", async ({ page }) => {
await page.waitForTimeout(350);
await openNote('other.md');
await page.locator('.cm-content .writer-link').filter({hasText:'Target'}).click({modifiers:['Control']});
await page.waitForFunction(()=>document.querySelector('.breadcrumb')?.textContent==='archive/deep/Target.md');
await page.waitForFunction(()=>document.querySelector('.breadcrumb')?.title==='archive/deep/Target.md');
await page.evaluate(()=>{
window.__TEST__.files.set('wiki.md','# Wiki\n\n[[Target]]\n');
window.__TEST__.emit('workspace-event',{root:window.__TEST__.root,kind:'create',paths:['wiki.md']});
@@ -68,14 +68,14 @@ await runSmoke("links/workspaceLinks", async ({ page }) => {
await openNote('wiki.md');
await page.locator('.cm-content .writer-link').filter({hasText:'Target'}).click({modifiers:['Control']});
await page.locator('.status').filter({hasText:'More than one note matches Target'}).waitFor();
assert.equal(await page.locator('.breadcrumb').textContent(),'wiki.md');
assert.equal(await page.locator('.breadcrumb').getAttribute('title'),'wiki.md');
await page.evaluate(()=>{
window.__TEST__.files.delete('duplicates/Target.md');
window.__TEST__.emit('workspace-event',{root:window.__TEST__.root,kind:'remove',paths:['duplicates/Target.md']});
});
await page.waitForTimeout(350);
await page.locator('.cm-content .writer-link').filter({hasText:'Target'}).click({modifiers:['Control']});
await page.waitForFunction(()=>document.querySelector('.breadcrumb')?.textContent==='archive/deep/Target.md');
await page.waitForFunction(()=>document.querySelector('.breadcrumb')?.title==='archive/deep/Target.md');
await backlink('wiki.md').waitFor();
await page.evaluate(()=>{
const {files,emit,root}=window.__TEST__;