Ask Save or Don't save, and show useful status facts

Phase 5-7.

- A changed tab asks Save, Don't save, or Cancel through the native
  dialog, instead of OK and Cancel to discard.
- The conflict banner uses --rs-warn with a warning icon. Keep my
  edits is the primary choice and comes first. Use disk version comes
  last, in the error color. The banner wraps in a narrow pane.
- The status bar shows the save state, the line and column, the word
  count, the line endings, and the view. It shows the watch mode only
  when it polls a network folder.
- The outline and the document facts follow the active tab. A tab
  without a document has no outline and no document facts.
- Tables: only formula cells have a hover hint, so no hint covers the
  next cell. The table adds no gap above its control area. The add
  controls show while a cell has focus.
- The plugin review marks Install and enable as the primary action. The
  other choice is Install, keep disabled.
- Read follows CommonMark soft breaks. Settings, General, Keep line
  breaks shows each source line break. The table preview and cell
  editors of Write keep their line breaks, because their editing
  depends on them.
- Catalog rows in French, Japanese, and Simplified Chinese.
- Docs: UI-053, the user guide, and plugins.md.

Tests: the new layout/plainFixes, the keepLineBreaks cases in the
settings unit tests, and the new install button name.
This commit is contained in:
Knotty Wyvern
2026-10-28 22:06:13 -07:00
parent 0fdc991b2e
commit eeddd880e1
24 changed files with 294 additions and 70 deletions
+13 -4
View File
@@ -50,7 +50,8 @@
onOpenLink?: (kind: "md" | "wiki", target: string) => void;
onInsertImage?: (file: File) => Promise<string | null>;
focusLine?: number | null;
onSelectionLine?: (line: number) => void;
/** The line and the column of the cursor, from 1. */
onSelectionLine?: (line: number, column: number) => void;
tableActions?: TableContextActions;
linkActions?: DocumentLinkActions;
shouldFocusOnMount?: () => boolean;
@@ -189,6 +190,11 @@
return untrack(() => $fileTitleVisible) ? noteTitle(markdownTitle(path), onRenameTitle ? renameTitle : undefined) : [];
}
function reportCursor(state: EditorState) {
const head = state.selection.main.head, line = state.doc.lineAt(head);
onSelectionLine?.(line.number, head - line.from + 1);
}
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 }] : [];
@@ -221,7 +227,7 @@
EditorView.updateListener.of(update => {
if (update.docChanged || update.selectionSet) {
menu?.close(false);
onSelectionLine?.(update.state.doc.lineAt(update.state.selection.main.head).number);
reportCursor(update.state);
}
if (!update.docChanged) return;
scroll = scroll?.map(update.changes);
@@ -314,7 +320,7 @@
// Restore through CodeMirror's layout pass, once its viewport is measured.
const view = new EditorView({ state, parent: el, scrollTo: restore?.scroll });
editor = view;
onSelectionLine?.(view.state.doc.lineAt(view.state.selection.main.head).number);
reportCursor(view.state);
scroll = restore?.scroll ?? view.scrollSnapshot();
// Svelte may detach the old tab before effect cleanup runs, at which point
// DOM scroll offsets read as zero. Capture while the view is still mounted.
@@ -502,12 +508,15 @@
.live-writer :global(.writer-preview) { display: flow-root; max-width: none; margin: 0; white-space: normal; }
.live-writer :global(.writer-preview > :last-child) { margin-bottom: 0; }
.live-writer :global(.writer-preview img) { max-width: 100%; }
.live-writer :global(.writer-table) { position: relative; width: fit-content; max-width: 100%; margin: 1.4em 0 0; padding: 26px; }
/* The padding holds the drag and add controls. The table adds no extra gap above it. */
.live-writer :global(.writer-table) { position: relative; width: fit-content; max-width: 100%; margin: 0; padding: 26px; }
.live-writer :global(.writer-table .md-table-scroll) { margin: 0; border-radius: 0; }
.live-writer :global(.writer-table td), .live-writer :global(.writer-table th) { cursor: text; }
.live-writer :global(.writer-cell-editor) { outline: none; min-height: 1lh; white-space: pre-wrap; overflow-wrap: break-word; }
.live-writer :global(.writer-table p) { margin: 0; }
.live-writer :global(.table-add) { position: absolute; display: block; padding: 0; opacity: 0; border: 1px solid var(--rs-border); background: var(--rs-bg-elevated); color: var(--rs-text-dim); cursor: pointer; transition: opacity 100ms; }
/* The add controls show, in dim color, while a cell of the table has focus. */
.live-writer :global(.writer-table:focus-within .table-add) { opacity: 1; }
.live-writer :global(.table-add:hover), .live-writer :global(.table-add:focus-visible) { opacity: 1; color: var(--rs-accent); border-color: var(--rs-accent-deep); outline: none; }
.live-writer :global(.table-add-column) { right: 0; top: 26px; bottom: 26px; width: 26px; border-radius: 0 4px 4px 0; }
.live-writer :global(.table-add-row) { left: 26px; right: 26px; bottom: 0; height: 26px; border-radius: 0 0 4px 4px; }
+8 -4
View File
@@ -1,4 +1,5 @@
// The `showFileTitle` general setting shows the file name as a title above a Markdown note in Write and Read.
// The document settings of the general section. `showFileTitle` shows the file name as a title above a Markdown note
// in Write and Read. `keepLineBreaks` keeps each line break of the source in Read.
import { writable } from "svelte/store";
import { onSettingsChange } from "../settings/store.ts";
import { DEFAULT_SETTINGS, readSettings } from "../workspace/settings.ts";
@@ -7,11 +8,14 @@ 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. */
/** Apply the saved settings 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); }
let settings = DEFAULT_SETTINGS;
try { settings = readSettings(); } catch { /* The defaults apply. */ }
visible.set(settings.showFileTitle);
// The `keepLineBreaks` setting: Read shows each source line break (src/lib/layout/reading.css).
document.documentElement.toggleAttribute("data-keep-line-breaks", settings.keepLineBreaks);
};
read();
return onSettingsChange("general", read);
+4 -2
View File
@@ -92,7 +92,9 @@ export function tableControls(root: HTMLElement, view: EditorView, initialSource
for (const row of table!.rows) for (const cell of row.cells) {
const result = results[row.rowIndex]?.[cell.cellIndex];
const address = formulas.cellAddress(row.rowIndex, cell.cellIndex);
cell.dataset.cellHint = `${address}${result?.formula ? ` · ${result.formula}` : ""}`;
// Only a formula cell has a hover hint. The footer shows the address of each cell, so no hint covers the next cell.
if (result?.formula) cell.dataset.cellHint = `${address} · ${result.formula}`;
else delete cell.dataset.cellHint;
cell.removeAttribute("title");
if (result && cell !== active) cell.innerHTML = formulas.tableFormulaHtml(result);
if (cell === active) {
@@ -453,6 +455,6 @@ export function tableControls(root: HTMLElement, view: EditorView, initialSource
});
refreshFormulas();
for (const row of table.rows) for (const cell of row.cells) {
tooltipCleanup.push(attachTooltip(cell, () => cell.dataset.cellHint || cell.getAttribute("aria-label") || ""));
tooltipCleanup.push(attachTooltip(cell, () => cell.dataset.cellHint || ""));
}
}