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
+17 -7
View File
@@ -7,6 +7,7 @@
import type { Documents } from "$lib/workspace/documents.svelte";
import type { OpenBuffer } from "$lib/workspace/types";
import EditorPane from "./EditorPane.svelte";
import Icon from "$lib/ui/Icon.svelte";
import type { ViewMode } from "./ViewModes.svelte";
import TabBar from "./TabBar.svelte";
@@ -42,11 +43,12 @@
linkActions: (pane: DocumentView) => EditorProps["linkActions"];
onView: (pane: DocumentView, view: ViewMode) => void;
onSplitView: (pane: DocumentView, split: boolean) => void;
onCursor: (pane: DocumentView, line: number, column: number) => void;
onOpenLink: (pane: DocumentView, kind: "md" | "wiki", target: string) => void;
};
let { editorPluginVisible, split, pluginBounds, tabBar, pluginPaneComponents = $bindable(), documentViews, activePane, paneComponents = $bindable(),
documents, tabs, hasWorkspace, browserOpening, focusLine, onFocusPane, onCloseSplit, onSaveCopy, onOpenWorkspace, onNewFile, onNewNote,
onQuickOpen, onOpenBrowser, onChange, onInsertImage, onRenameTitle, tableActions, linkActions, onView, onSplitView, onOpenLink }: Props = $props();
onQuickOpen, onOpenBrowser, onChange, onInsertImage, onRenameTitle, tableActions, linkActions, onView, onSplitView, onCursor, onOpenLink }: Props = $props();
</script>
<main class="center">
@@ -76,13 +78,15 @@
onpointerdowncapture={() => onFocusPane(pane.id)}
onfocusin={() => onFocusPane(pane.id)}>
{#if pane.buffer?.diskError}
<div class="conflict" role="alert"><span>{pane.buffer.diskError}</span><button onclick={() => onSaveCopy(pane.buffer)}>{$t("Save a copy")}</button><button onclick={() => void documents?.refresh()}>{$t("Retry")}</button></div>
<div class="conflict" role="alert"><Icon icon="alert" /><span>{pane.buffer.diskError}</span><button class="primary" onclick={() => void documents?.refresh()}>{$t("Retry")}</button><button onclick={() => onSaveCopy(pane.buffer)}>{$t("Save a copy")}</button></div>
{:else if pane.buffer?.diskContents != null}
<div class="conflict" role="alert">
<!-- The safe choice comes first. The choice that discards your edits comes last, in the error color. -->
<Icon icon="alert" />
<span>{$t("This file changed on disk. Your edits are preserved. Review both versions before saving.")}</span>
<button onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, true); }}>{$t("Use disk version")}</button>
<button onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, false); }}>{$t("Keep my edits")}</button>
<button class="primary" onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, false); }}>{$t("Keep my edits")}</button>
<button onclick={() => onSaveCopy(pane.buffer)}>{$t("Save a copy")}</button>
<button class="danger" onclick={() => { if (pane.buffer) documents?.resolve(pane.buffer.id, true); }}>{$t("Use disk version")}</button>
</div>
<details class="disk-review"><summary>{$t("View disk version")}</summary><pre>{pane.buffer.diskContents}</pre></details>
{/if}
@@ -110,6 +114,7 @@
linkActions={linkActions(pane)}
onView={view => onView(pane, view)}
onSplit={next => onSplitView(pane, next)}
onCursor={(line, column) => onCursor(pane, line, column)}
onOpenLink={(kind, target) => onOpenLink(pane, kind, target)}
/>
</div>
@@ -130,9 +135,14 @@
background: transparent;
}
.conflict { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; background: var(--rs-bg-active); border-bottom: 1px solid var(--rs-warn); }
.conflict span { flex: 1 1 300px; }
.conflict button { border: 1px solid var(--rs-border); background: var(--rs-bg); padding: 4px 8px; }
/* The conflict banner uses the warning status color and icon. Its text and buttons wrap in a narrow pane. */
.conflict { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; background: color-mix(in srgb, var(--rs-warn) 14%, var(--rs-bg)); border-bottom: 2px solid var(--rs-warn); color: var(--rs-text-strong); }
.conflict > :global(svg) { width: 18px; height: 18px; flex-shrink: 0; color: var(--rs-warn); }
.conflict span { flex: 1 1 220px; min-width: 0; }
.conflict button { min-height: 28px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); padding: 4px 10px; }
.conflict button:hover { background: var(--rs-bg-active); }
.conflict button.primary { border-color: var(--rs-accent); background: var(--rs-accent); color: var(--rs-on-accent); }
.conflict button.danger { border-color: var(--rs-error); color: var(--rs-error); }
.disk-review { padding: 8px 12px; max-height: 35vh; overflow: auto; flex: 0 0 auto; }
.disk-review pre { white-space: pre-wrap; user-select: text; }