From 3e6bc5f088eb0ae34a55bea506bea10e5e22254b Mon Sep 17 00:00:00 2001 From: Knotty Wyvern Date: Wed, 28 Oct 2026 11:50:33 -0700 Subject: [PATCH] Move global CSS beside its code and make Documents reactive Phase 4e. - app.css holds only imports. Its rules moved into files beside their code, in the original cascade order. Dead rules of the deleted TipTap Writer are gone. - workbenchKeys.ts is one table of the workbench shortcuts. Workbench runs the commands. - session.linkTargets is the one link resolution for the link menu and for link opening. - Documents is a rune module (documents.svelte.ts). Workbench reads the tabs and the active path from it, without a copy of all buffers on each change. The editor mount effect now copies the buffer inside untrack, so an edit does not remount the editor. - Unit tests can import .svelte.ts modules through a Node module hook that compiles them with the Svelte compiler. pnpm check, pnpm test (350 of 350), and the full smoke suite pass, except tables/linkCaret, which failed one time under load and passed on retry and 3 of 3 times alone. --- docs/design-decisions.md | 4 +- package.json | 2 +- src/app.css | 426 +----------------- src/lib/editor/DocumentEditor.svelte | 11 +- src/lib/editor/imageControls.css | 25 + src/lib/editor/noteTitle.css | 9 + src/lib/editor/tableControls.css | 52 +++ src/lib/formulas/formulas.css | 18 + src/lib/layout/Workbench.svelte | 127 ++---- src/lib/layout/reading.css | 163 +++++++ src/lib/layout/workbenchKeys.ts | 60 +++ src/lib/theme/base.css | 67 +++ src/lib/ui/actionIcons.css | 4 + src/lib/ui/tooltip.css | 16 + .../{documents.ts => documents.svelte.ts} | 4 +- src/lib/workspace/session.svelte.ts | 15 +- tests/smoke/layout/workbench.smoke.mjs | 2 +- tests/unit/_svelte/hooks.mjs | 15 + tests/unit/_svelte/register.mjs | 4 + tests/unit/layout/tabActions.spec.ts | 2 +- tests/unit/layout/workbenchKeys.spec.ts | 31 ++ tests/unit/layout/workbenchTabs.spec.ts | 2 +- tests/unit/workspace/documents.spec.ts | 2 +- 23 files changed, 549 insertions(+), 512 deletions(-) create mode 100644 src/lib/editor/imageControls.css create mode 100644 src/lib/editor/noteTitle.css create mode 100644 src/lib/editor/tableControls.css create mode 100644 src/lib/formulas/formulas.css create mode 100644 src/lib/layout/reading.css create mode 100644 src/lib/layout/workbenchKeys.ts create mode 100644 src/lib/theme/base.css create mode 100644 src/lib/ui/actionIcons.css create mode 100644 src/lib/ui/tooltip.css rename src/lib/workspace/{documents.ts => documents.svelte.ts} (99%) create mode 100644 tests/unit/_svelte/hooks.mjs create mode 100644 tests/unit/_svelte/register.mjs create mode 100644 tests/unit/layout/workbenchKeys.spec.ts diff --git a/docs/design-decisions.md b/docs/design-decisions.md index ccfc767..0e63bf8 100644 --- a/docs/design-decisions.md +++ b/docs/design-decisions.md @@ -118,7 +118,7 @@ This log records interface rule changes, recurring problems, and exceptions for - New rule: Use spacing between headings and sections without separator lines. - Reason: Keep attention on the document text. - Scope: Writer and Reader headings. -- Shared implementation: src/app.css heading rules. +- Shared implementation: the heading rules in src/lib/layout/reading.css. - Exceptions: None. - Evidence: Editor browser checks passed in both themes. Screenshots are in output/editor-october12. - Replaces: None. @@ -767,7 +767,7 @@ Native shell, background image, and desktop acceptance remain open. - New rule: Write and Source are two configurations of one CodeMirror state. They share the undo history. - Reason: Lists behave as in common word processors. One editor removes the Monaco model bridge and its timers. - Scope: Markdown documents in Write and Source, and all source files. -- Shared implementation: DocumentEditor.svelte, markdownLists.ts, liveMarkdown.ts, sourceView.ts, codeLanguages.ts, editorStates.ts, and the `.reading ol ol` styles in app.css. +- Shared implementation: DocumentEditor.svelte, markdownLists.ts, liveMarkdown.ts, sourceView.ts, codeLanguages.ts, editorStates.ts, and the `.reading ol ol` styles in reading.css. - Exceptions: An empty nested item cannot start a list inside a paragraph in CommonMark. Write labels it, and Read shows it as text until the item has text. - Evidence: editor/listNesting.smoke.mjs covers Tab, Shift+Tab, labels, Read letters, the shared history, and the 4-space indent in both themes at 1440 and 600 pixels. - Evidence files: output/smoke/editor/listNesting/. diff --git a/package.json b/package.json index 3028a9b..2018e38 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "check:menus": "node scripts/menuSurfaceAudit.mjs", "tauri": "tauri", - "test": "node --experimental-strip-types --test \"tests/unit/**/*.spec.ts\"", + "test": "node --experimental-strip-types --import ./tests/unit/_svelte/register.mjs --test \"tests/unit/**/*.spec.ts\"", "smoke": "node scripts/smoke.mjs", "browser:check": "npm --prefix browser-runtime run check", "browser:test": "npm --prefix browser-runtime test", diff --git a/src/app.css b/src/app.css index 690e8b2..457b4bb 100644 --- a/src/app.css +++ b/src/app.css @@ -1,419 +1,11 @@ +/* Global styles. Each file lives beside the code that uses it. The order of the imports is the cascade order. */ @import "./lib/theme/tokens.css"; @import "./lib/ui/menu.css"; - -*, -*::before, -*::after { - box-sizing: border-box; -} - -html, -body { - margin: 0; - padding: 0; - height: 100%; - overflow: hidden; - background: var(--rs-bg); - color: var(--rs-text-strong); - font-family: var(--rs-font-ui); - font-size: 13px; - font-weight: var(--rs-font-weight); - line-height: 1.4; -} - -h1, h2, h3, h4, h5, h6 { font-family: var(--rs-font-heading); } - -button, -input, -textarea, -select { - font-family: inherit; - font-size: inherit; - color: inherit; -} - -button { - cursor: pointer; -} - -button:disabled { - cursor: default; - opacity: 0.5; -} - -:focus-visible { - outline: 1px solid var(--rs-accent); - outline-offset: -1px; -} - -::selection { - background: var(--rs-selection); - color: var(--rs-selection-text); -} - -.rs-tooltip { - position: fixed; - inset: auto; - margin: 0; - max-width: min(280px, calc(100vw - 16px)); - padding: var(--rs-tooltip-padding); - border: 1px solid var(--rs-border); - border-radius: var(--rs-control-radius); - background: var(--rs-tooltip-bg); - color: var(--rs-tooltip-text); - box-shadow: var(--rs-tooltip-shadow); - font: var(--rs-tooltip-font-size)/1.5 var(--rs-font-ui); - white-space: pre-line; - pointer-events: none; -} - -::-webkit-scrollbar { - width: 10px; - height: 10px; -} - -::-webkit-scrollbar-track { - background: var(--rs-bg); -} - -::-webkit-scrollbar-thumb { - background: var(--rs-border); - border-radius: 8px; -} - -::-webkit-scrollbar-thumb:hover { - background: var(--rs-accent-deep); -} - -.rs-md-images { - display: flex; - flex-direction: column; - gap: 8px; - margin: 8px 0 16px; - padding: 0 36px 0 0; -} - -.rs-md-image { - max-width: 100%; - max-height: 28rem; - display: block; - border: 1px solid var(--rs-border); - background: var(--rs-bg-elevated); -} - -/* Writing, Read and Split use the same document typography. */ -.md-edit-block { display: contents; cursor: text; } -.md-edit-block:focus-visible > :first-child { outline: 1px solid var(--rs-accent-deep); outline-offset: 4px; } -.md-edit-block:empty { display: block; min-height: 3em; } -.md-mermaid { margin: 1.4em 0; } -.md-diagram { overflow: auto; text-align: center; } -.md-diagram svg { display: block; max-width: 100%; height: auto; margin: 0 auto; } -.md-diagram-source { margin-top: 10px; color: var(--rs-text-dim); font: 12px/1.5 var(--rs-font-ui); } -.md-diagram-source summary { cursor: pointer; } -.md-diagram-source pre { text-align: left; } -.reading { - max-width: 740px; - min-width: 0; - margin: 0 auto; - color: var(--rs-text); - font: var(--rs-font-weight) var(--rs-prose-size)/var(--rs-prose-line) var(--rs-font-prose); - overflow-wrap: anywhere; -} - -.reading h1, .reading h2, .reading h3, -.reading h4, .reading h5, .reading h6, .live-writer .writer-heading { - color: var(--rs-text-strong); - font-family: var(--rs-font-heading); - font-weight: var(--rs-heading-weight); - line-height: 1.4; - letter-spacing: -0.02em; - margin: 1.6em 0 .55em; - scroll-margin-top: 24px; -} -.reading h1, .live-writer .writer-h1 { font-size: 1.6em; } -.reading h2, .live-writer .writer-h2 { font-size: 1.35em; } -.reading h3, .live-writer .writer-h3 { font-size: 1.15em; } -.reading h4, .live-writer .writer-h4 { font-size: 1.05em; } -.reading h5, .reading h6, .live-writer .writer-h5, .live-writer .writer-h6 { font-size: 1em; color: var(--rs-text-dim); } -.live-writer .writer-heading { margin: 0; padding-top: .7em; padding-bottom: .3em; } -.document-title, .reading .document-title { margin: 0 0 .85em; color: var(--rs-text-strong); font: var(--rs-heading-weight) 1.8em/1.3 var(--rs-font-heading); overflow-wrap: anywhere; } -.note-title-button { position: relative; display: inline-flex; align-items: center; gap: 12px; max-width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; overflow-wrap: anywhere; cursor: text; } -.note-title-button .action-icon { opacity: .45; } -.note-title-button:hover .action-icon, .note-title-button:focus-visible .action-icon { opacity: 1; color: var(--rs-accent); } -.note-title-button:focus-visible { outline: 1px solid var(--rs-accent); outline-offset: 4px; border-radius: 3px; } -.note-title-input { box-sizing: border-box; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 2px; outline: 1px solid var(--rs-accent); outline-offset: 4px; background: transparent; color: inherit; font: inherit; } -.note-title-input[aria-invalid] { outline-color: var(--rs-danger, #e57878); } -.note-title-error { margin: -.8em 0 1em; color: var(--rs-danger, #e57878); font: 13px/1.5 var(--rs-font-ui); } -.note-title-button[hidden], .note-title-input[hidden], .note-title-error[hidden] { display: none; } -.reading > :first-child { margin-top: 0; } -.reading p { margin: 0 0 .75em; white-space: pre-line; } -.reading strong { font-weight: 600; color: var(--rs-text-strong); } -.reading a { color: var(--rs-accent); text-decoration-thickness: 1px; text-underline-offset: 3px; } -.reading a:hover { color: var(--rs-accent-2); } -.reading hr { border: 0; border-top: 1px solid var(--rs-border); margin: 2em 0; } - -.reading ul, .reading ol { padding-left: 1.6em; margin: 0 0 .75em; } -.reading li { padding-left: 0.25em; margin: .1em 0; } -.reading li::marker { color: var(--rs-text-dim); } -.reading li > p { margin-bottom: 0.6em; } -.reading li > ul, .reading li > ol { margin: 0.35em 0 0.5em; } -/* Nested ordered lists use letters, then Roman numerals. Write labels its markers the same way. */ -.reading ol ol { list-style-type: lower-alpha; } -.reading ol ol ol { list-style-type: lower-roman; } -.reading ol ol ol ol { list-style-type: decimal; } -.reading ol ol ol ol ol { list-style-type: lower-alpha; } -.reading ol ol ol ol ol ol { list-style-type: lower-roman; } -.reading .task-list-item { list-style: none; position: relative; } -.reading .task-list-item > input, -.reading .task-list-item > p > input { - position: absolute; - left: -1.3em; - top: 0.4em; - margin: 0; - width: 15px; - height: 15px; - accent-color: var(--rs-accent); - pointer-events: none; -} -.reading .is-checked { color: var(--rs-text-dim); text-decoration: line-through; } -.reading s, .reading del { color: var(--rs-text-dim); } - -.reading blockquote { - margin: 1.4em 0; - padding: 0.75em 1.2em; - border-left: 3px solid var(--rs-accent-deep); - background: var(--rs-line-highlight); - border-radius: 0 6px 6px 0; - color: var(--rs-text-dim); -} -.reading blockquote > :last-child { margin-bottom: 0; } -.reading .md-callout { --callout-color: var(--rs-accent); color: var(--rs-text); border-color: var(--callout-color); } -.reading .md-callout[data-callout="warning"], -.reading .md-callout[data-callout="important"] { --callout-color: var(--rs-warn); } -.reading .md-callout[data-callout="danger"] { --callout-color: var(--rs-error); } -.reading .md-callout[data-callout="success"], -.reading .md-callout[data-callout="tip"] { --callout-color: var(--rs-ok); } -.reading .md-callout-title { display: block; color: var(--callout-color); margin-bottom: 0.3em; } - -.reading code { - font-family: var(--rs-font-mono); - font-size: 0.85em; - color: var(--rs-accent-2); - background: var(--rs-bg-active); - padding: 0.15em 0.35em; - border-radius: 4px; -} -.reading pre { - position: relative; - background: var(--rs-code-block-bg); - border: 1px solid var(--rs-border); - border-radius: 8px; - padding: 18px 20px; - overflow: auto; - margin: 1.4em 0; - font: 13px/1.65 var(--rs-font-mono); - tab-size: 4; -} -.reading pre.md-code { padding-top: 44px; } - -.reading pre code { - background: transparent; - padding: 0; - font-size: inherit; - color: var(--rs-text); - display: block; - white-space: pre; - overflow-wrap: normal; -} -.reading pre[data-lang]::before { - content: attr(data-lang); - position: absolute; - top: 10px; - left: 20px; - color: var(--rs-text-dim); - font: 11px/1.6 var(--rs-font-ui); -} -.rs-fence-copy { - position: absolute; - top: 6px; - right: 8px; - display: grid; - place-items: center; - width: 28px; - height: 28px; - padding: 5px; - border: 0; - border-radius: 5px; - background: transparent; - color: var(--rs-text-dim); -} -.rs-fence-copy svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; } -.rs-fence-copy:hover { color: var(--rs-text-strong); background: var(--rs-bg-active); } -.rs-fence-copy[data-copied] { color: var(--rs-ok); } - -.reading .md-table-scroll { width: fit-content; max-width: 100%; overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--rs-border); border-radius: 0; } -.md-table-formula { color: var(--rs-accent); font-variant-numeric: tabular-nums; } -.md-table-formula.is-error { color: var(--rs-danger, #ed8796); text-decoration: underline dotted; } -.table-footer { display: grid; gap: 8px; margin: 0 26px 1.4em; min-width: 0; font: 12px/1.5 var(--rs-font-ui); color: var(--rs-text-dim); white-space: normal; overflow-wrap: anywhere; } -.table-formula-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; min-width: 0; } -.table-formula-help { min-width: 0; } -.table-formula-help summary { display: flex; align-items: center; gap: 5px; cursor: pointer; min-height: 28px; border-radius: 4px; } -.table-formula-help summary:hover, .table-formula-help summary:focus-visible { color: var(--rs-accent); } -.table-formula-help summary:focus-visible { outline: 1px solid var(--rs-accent); outline-offset: 2px; } -.table-formula-help[open] { flex-basis: 100%; } -.table-formula-instructions { display: grid; gap: 12px; max-width: 680px; padding: 12px; border: 1px solid var(--rs-border); border-radius: 6px; line-height: 1.7; color: var(--rs-text); background: var(--rs-bg-elevated); } -.table-formula-instructions p, .table-formula-instructions dl, .table-formula-instructions dd { margin: 0; } -.table-formula-instructions dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 8px 16px; } -.table-formula-instructions dt { min-width: 0; } -.table-formula-instructions code { white-space: normal; overflow-wrap: anywhere; } -.table-formula-status { overflow-wrap: anywhere; } -.table-formula-hint { padding: 8px 10px; border-left: 2px solid var(--rs-accent); background: var(--rs-bg-elevated); color: var(--rs-text); } -.table-formula-hint[hidden] { display: none; } -.table-edit-help { font: inherit; color: var(--rs-text-dim); } -.reading table { border-collapse: collapse; width: auto; max-width: 100%; font-size: 0.95em; line-height: var(--rs-table-line-height); overflow-wrap: normal; word-break: normal; } -.reading th, .reading td { padding: var(--rs-table-cell-padding); text-align: left; vertical-align: top; border-bottom: 1px solid var(--rs-border); min-width: 3rem; max-width: 26rem; white-space: normal; overflow-wrap: break-word; } -.reading :is(th, td):empty::before, -.reading :is(th, td) > p:empty::before { content: "\200b"; } -.reading :is(th, td) > p { margin: 0; } -.reading th { background: var(--rs-bg-active); font-weight: 600; color: var(--rs-text-strong); } -.reading tbody tr:nth-child(even) { background: var(--rs-line-highlight); } -.reading tbody tr:last-child td { border-bottom: 0; } -.reading th + th, .reading td + td { border-left: 1px solid var(--rs-border); } -.reading img { max-width: 100%; height: auto; display: block; margin: 1.4em 0; border-radius: 6px; } -.md-image-frame { display: block; position: relative; width: fit-content; max-width: 100%; margin: 1.4em 0; } -.md-image-frame.is-selected, .md-image-frame:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: 3px; border-radius: 6px; } -.md-image-frame.is-selected .md-image-actions { opacity: 1; } -.md-image-frame[data-error]::after { content: attr(data-error); display: block; padding: 8px; color: var(--rs-text); background: var(--rs-bg-elevated); font: 12px/1.5 var(--rs-font-ui); } -.writer-image-inline { display: inline-block; vertical-align: middle; max-width: 100%; } -.writer-image-inline .md-image-frame { margin: .5em 0; } -.image-drop-target { outline: 2px solid var(--rs-accent); outline-offset: -3px; } -.reading .md-image-frame img { margin: 0; } -.md-image-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; padding: 3px; border-radius: 6px; background: var(--rs-bg-elevated); box-shadow: 0 2px 8px #0005; opacity: 0; transition: opacity 100ms; } -.md-image-frame:hover .md-image-actions, .md-image-frame:focus-within .md-image-actions { opacity: 1; } -.image-action { position: relative; display: inline-grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; padding: 6px; color: var(--rs-text); border: 0; border-radius: 4px; background: transparent; cursor: pointer; } -.image-action:hover, .image-action:focus-visible { background: var(--rs-bg-active); color: var(--rs-text-strong); } -.image-action:focus-visible { outline: 2px solid var(--rs-accent); outline-offset: 1px; } -.image-action:disabled { opacity: .4; cursor: default; } -.image-lightbox { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #090a0de8; color: var(--rs-text); } -.image-lightbox[open] { display: flex; flex-direction: column; } -.image-lightbox::backdrop { background: #0009; } -.image-lightbox-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--rs-bg-elevated); z-index: 1; } -.image-lightbox-name { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.image-lightbox-scale { min-width: 44px; text-align: center; font-size: 12px; } -.image-lightbox-viewport { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; } -.image-lightbox-viewport img { display: block; flex-shrink: 0; max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; } -.image-lightbox-viewport.is-zoomed { display: block; } -.image-lightbox-viewport.is-zoomed img { max-width: none; max-height: none; height: auto; } -.reading .missing-image { display: inline-block; padding: 8px 12px; border: 1px dashed var(--rs-border); border-radius: 6px; color: var(--rs-text-dim); font-size: 13px; } -.reading .md-properties { margin: 0 0 2em; border: 1px solid var(--rs-border); border-radius: 6px; font: 12px/1.5 var(--rs-font-ui); color: var(--rs-text-dim); } -.reading .md-properties summary { padding: 9px 12px; cursor: pointer; } -.reading .md-properties summary:hover { color: var(--rs-text-strong); } -.reading .md-properties pre { margin: 0; padding: 12px; border: 0; border-top: 1px solid var(--rs-border); border-radius: 0 0 6px 6px; white-space: pre-wrap; } - -.reading .ProseMirror { - outline: none; - min-height: 100%; -} - -.reading .ProseMirror:focus, -.reading .ProseMirror:focus-visible { - outline: none; -} - -.reading.writer-doc { - height: 100%; - overflow: auto; - padding: 8px 36px 48px; -} - -.reading.writer-doc h1.is-editing::before, -.reading.writer-doc h2.is-editing::before, -.reading.writer-doc h3.is-editing::before, -.reading.writer-doc h4.is-editing::before, -.reading.writer-doc h5.is-editing::before, -.reading.writer-doc h6.is-editing::before { - content: attr(data-heading-marks) " "; - color: var(--rs-text-dim); - font-weight: 500; - font-family: var(--rs-font-mono); - margin-right: 0.15em; -} - -.reading.writer-doc .is-editing-ticks::before, -.reading.writer-doc .is-editing-ticks::after { - content: "`"; - color: var(--rs-text-dim); - font-family: var(--rs-font-mono); -} - -.reading.writer-doc pre.is-editing::before { - content: attr(data-fence-open); - display: block; - color: var(--rs-text-dim); - font-family: var(--rs-font-mono); - font-size: 12px; - margin-bottom: 0.35em; -} - -.reading.writer-doc pre.is-editing::after, -.reading.writer-doc pre.is-editing[data-lang]::after { - content: "```"; - position: static; - display: block; - color: var(--rs-text-dim); - font-family: var(--rs-font-mono); - font-size: 12px; - margin-top: 0.35em; -} -.writer-table :is(th, td):is(.is-editing, .is-cell-selected) { - background: var(--rs-item-selection-bg); - box-shadow: - inset 0 var(--cell-selection-top, 0px) 0 var(--rs-item-selection-border), - inset 0 calc(-1 * var(--cell-selection-bottom, 0px)) 0 var(--rs-item-selection-border), - inset var(--cell-selection-left, 0px) 0 0 var(--rs-item-selection-border), - inset calc(-1 * var(--cell-selection-right, 0px)) 0 0 var(--rs-item-selection-border); - outline: none; -} -.writer-table .is-editing { - --cell-selection-top: var(--rs-item-selection-width); - --cell-selection-bottom: var(--rs-item-selection-width); - --cell-selection-left: var(--rs-item-selection-width); - --cell-selection-right: var(--rs-item-selection-width); -} -.writer-table [data-selection-edges~="top"] { --cell-selection-top: var(--rs-item-selection-width); } -.writer-table [data-selection-edges~="bottom"] { --cell-selection-bottom: var(--rs-item-selection-width); } -.writer-table [data-selection-edges~="left"] { --cell-selection-left: var(--rs-item-selection-width); } -.writer-table [data-selection-edges~="right"] { --cell-selection-right: var(--rs-item-selection-width); } -.writer-table.has-cell-selection { outline: none; } -.writer-table.has-cell-selection .md-table-scroll { user-select: none; } -.table-drag-layer { position: absolute; inset: 0; overflow: clip; pointer-events: none; } -.table-drag-handle { position: absolute; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 4px; color: var(--rs-text-dim); background: transparent; cursor: grab; touch-action: none; opacity: 0; pointer-events: auto; transition: opacity 100ms; } -.table-drag-handle[hidden], .table-drop-indicator[hidden] { display: none; } -.table-drag-handle .action-icon { width: 18px; height: 18px; pointer-events: none; } -.table-drag-column .action-icon { transform: rotate(90deg); } -.table-drag-handle:hover, .table-drag-handle:focus-visible:not([data-pointer-focus]) { opacity: 1; color: var(--rs-text); background: var(--rs-bg-active); outline: 2px solid var(--rs-accent); outline-offset: -2px; z-index: 2; } -.writer-table.is-table-dragging, .writer-table.is-table-dragging * { cursor: grabbing !important; user-select: none; } -.writer-table.is-table-dragging .table-drag-handle::after { display: none; } -.table-drop-indicator { position: absolute; z-index: 3; border-radius: 2px; background: var(--rs-accent); pointer-events: none; } -.table-drag-preview { position: fixed; top: 0; left: 0; z-index: 1100; margin: 0; padding: 0; max-width: calc(100vw - 24px); border: 1px solid var(--rs-accent); border-radius: 6px; background: var(--rs-bg-elevated); color: var(--rs-text); box-shadow: 0 8px 28px #0006; opacity: .92; pointer-events: none; user-select: none; will-change: transform; animation: table-drag-lift 100ms ease-out; } -.table-drag-preview.is-invalid-drop { opacity: .6; } -.table-drag-preview-label { padding: 5px 10px; border-bottom: 1px solid var(--rs-border); color: var(--rs-accent); font: 12px/1.4 var(--rs-font-ui); } -.table-drag-preview-content { max-height: min(260px, 35vh); overflow: hidden; border-radius: 0 0 6px 6px; } -.table-drag-preview table { width: 100%; table-layout: fixed; margin: 0; } -.table-drag-preview :is(th, td) { min-width: 0; max-width: none; padding: 7px 10px; overflow-wrap: anywhere; } -.table-drag-preview p { margin: 0; } -@keyframes table-drag-lift { from { opacity: 0; } to { opacity: .92; } } -@media (prefers-reduced-motion: reduce) { .table-drag-handle { transition: none; } .table-drag-preview { animation: none; } } -.editor-notice { position: absolute; bottom: 12px; left: 12px; right: 12px; z-index: 20; margin: 0; padding: 10px 14px; border: 1px solid var(--rs-border); border-radius: 6px; background: var(--rs-bg-elevated); color: var(--rs-text); } -.editor-notice button { margin-left: 12px; } -.action-icon { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; } -.action-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.action-chevron { width: 13px; height: 13px; flex-basis: 13px; color: var(--rs-text-dim); } -.table-add .action-icon { width: 20px; height: 20px; margin: 2px; } -.reading mark { background: color-mix(in srgb, #edc65b 30%, transparent); color: inherit; border-radius: 2px; } -.reading .md-inline-math { font-family: var(--rs-font-mono); font-style: italic; } -.reading .md-inline-comment { display: none; } -.writer-table .md-inline-comment { display: inline; color: var(--rs-text-dim); background: var(--rs-bg-active); } - -.reading:not(.cm-content) :is(p, h1, h2, h3, h4, h5, h6):not(td *, th *) { position: relative; } -.reading:not(.cm-content) :is(p, h1, h2, h3, h4, h5, h6):not(td *, th *):hover::before { content: ""; position: absolute; left: -14px; top: 2px; bottom: 2px; width: 3px; border-radius: var(--rs-control-radius); background: var(--rs-text-dim); opacity: .5; pointer-events: none; } +@import "./lib/theme/base.css"; +@import "./lib/ui/tooltip.css"; +@import "./lib/layout/reading.css"; +@import "./lib/editor/noteTitle.css"; +@import "./lib/formulas/formulas.css"; +@import "./lib/editor/imageControls.css"; +@import "./lib/editor/tableControls.css"; +@import "./lib/ui/actionIcons.css"; diff --git a/src/lib/editor/DocumentEditor.svelte b/src/lib/editor/DocumentEditor.svelte index af03ff7..acd2b01 100644 --- a/src/lib/editor/DocumentEditor.svelte +++ b/src/lib/editor/DocumentEditor.svelte @@ -150,7 +150,8 @@ } function writeExtensions(lists: KeyBinding[]): Extension { - const current = untrack(() => buffer); + // A plain copy: the buffer is reactive, and this code must not track its later edits. + const current = untrack(() => ({ ...buffer })); return [ headingFolding, tableNavigation, @@ -198,7 +199,8 @@ } function configuration(): Extension[] { - const current = untrack(() => buffer); + // A plain copy: the buffer is reactive, and this code must not track its later edits. + const current = untrack(() => ({ ...buffer })); shown = requested(); return [ completionExtension(current.id, () => ({ kind: isMarkdownPath(buffer.relPath) ? "prose" : "code", language: languageFor(buffer.relPath) })), @@ -289,7 +291,8 @@ let releaseSelection: (() => void) | undefined; let releaseDrop: (() => void) | undefined; let releaseScroll: (() => void) | undefined; - const current = untrack(() => buffer); + // A plain copy: the buffer is reactive, and this code must not track its later edits. + const current = untrack(() => ({ ...buffer })); void (async () => { lastValue = current.contents; const saved = savedEditor(current.id); @@ -434,6 +437,8 @@ {#if error}{/if}