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.
This commit is contained in:
@@ -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/.
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
+9
-417
@@ -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";
|
||||
|
||||
@@ -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}<p class="editor-notice" role="alert">{error}<button onclick={() => { error = ""; }}>{$t("Dismiss")}</button></p>{/if}
|
||||
|
||||
<style>
|
||||
.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; }
|
||||
.live-writer, .source-editor { position: absolute; inset: 0; }
|
||||
.live-writer :global(.cm-editor), .source-editor :global(.cm-editor) { height: 100%; color: var(--rs-text); background: transparent; }
|
||||
.live-writer :global(.cm-editor.cm-focused), .source-editor :global(.cm-editor.cm-focused) { outline: none; }
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/* Image frames, image actions, and the image viewer, from imageControls.ts. */
|
||||
.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; }
|
||||
@@ -0,0 +1,9 @@
|
||||
/* The note title of Write, from noteTitle.ts. */
|
||||
.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; }
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Table editing in Write: cell editors, cell selection, and row and column drag. */
|
||||
.table-edit-help { font: inherit; color: var(--rs-text-dim); }
|
||||
.reading .ProseMirror {
|
||||
outline: none;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.reading .ProseMirror:focus,
|
||||
.reading .ProseMirror:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
.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; } }
|
||||
.table-add .action-icon { width: 20px; height: 20px; margin: 2px; }
|
||||
.writer-table .md-inline-comment { display: inline; color: var(--rs-text-dim); background: var(--rs-bg-active); }
|
||||
@@ -0,0 +1,18 @@
|
||||
/* Table formula results and help below a table. */
|
||||
.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; }
|
||||
@@ -19,7 +19,7 @@
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { confirm } from "@tauri-apps/plugin-dialog";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { Documents } from "$lib/workspace/documents";
|
||||
import { Documents } from "$lib/workspace/documents.svelte";
|
||||
import { documentSessionKey, parseDocumentSession, restoreDocumentSession, type DocumentSession } from "$lib/workspace/documentSession";
|
||||
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
|
||||
import { orderWorkbenchTabs, type WorkbenchTab } from "$lib/workspace/workbenchTabs";
|
||||
@@ -37,6 +37,7 @@
|
||||
import { TAB_TRANSFER_ID, cancelTabTransfer, finishTabTransfer, offerTabTransfer, onTabTransferAccepted, parseTabTransfer, takeTabTransfer } from "$lib/workspace/tabTransfer";
|
||||
import { DEFAULT_WORKBENCH_LAYOUT, WORKBENCH_LAYOUT_KEY, parseWorkbenchLayout, saveWorkbenchLayout, type WorkbenchLayout } from "$lib/workspace/workbenchLayout";
|
||||
import FileTree from "./FileTree.svelte";
|
||||
import { preferenceKeys, workbenchCommand, type WorkbenchCommand } from "./workbenchKeys";
|
||||
import EditorPane from "./EditorPane.svelte";
|
||||
import TabBar from "./TabBar.svelte";
|
||||
import OutlinePane from "./OutlinePane.svelte";
|
||||
@@ -67,7 +68,6 @@
|
||||
import { detectChrome } from "$lib/workspace/chrome";
|
||||
import { planRename, planMarkdownTitleRename, planDocumentTitleRename, renameSelection } from "$lib/workspace/renamePath";
|
||||
import { attachmentRel, isImagePath, isMarkdownPath } from "$lib/workspace/media";
|
||||
import { linkCandidates } from "$lib/workspace/markdownLinks";
|
||||
import { headingLinkLine, linkFragment } from "$lib/workspace/headingLinks";
|
||||
import type { Chrome, OpenBuffer, TreeEntry, WorkspaceInfo } from "$lib/workspace/types";
|
||||
|
||||
@@ -88,8 +88,10 @@
|
||||
let workspaceAnchor: HTMLDivElement | undefined = $state();
|
||||
const desktop = isTauri();
|
||||
const transferredWindow = /^[0-9a-f-]{36}$/i.test(new URLSearchParams(location.search).get("tabTransfer") ?? "");
|
||||
let tabs = $state<OpenBuffer[]>([]);
|
||||
let activePath = $state<string | null>(null);
|
||||
// The documents of the open workspace. Their buffers are reactive, so the tabs read them directly.
|
||||
let documents = $state.raw<Documents | null>(null);
|
||||
const tabs = $derived<OpenBuffer[]>(documents?.buffers ?? []);
|
||||
const activePath = $derived(documents?.activePath ?? null);
|
||||
const buffer = $derived(tabs.find((tab) => tab.relPath === activePath) ?? null);
|
||||
let status = $state($t("Open a workspace folder"));
|
||||
let error = $state<string | null>(null);
|
||||
@@ -183,7 +185,6 @@
|
||||
let saving = $state(false);
|
||||
let switching = false;
|
||||
let workbenchReady = $state(false);
|
||||
let documents: Documents | null = null;
|
||||
let paneComponents = $state<Record<string, EditorPane | undefined>>({});
|
||||
let pluginPaneComponents = $state<Record<string, PluginEditor | undefined>>({});
|
||||
function activeEditor() { return paneComponents[documentPanes.active]; }
|
||||
@@ -198,8 +199,6 @@
|
||||
kind: path => isImagePath(path) ? "image" : "text", chrome: detectChrome,
|
||||
}, () => {
|
||||
if (documents !== next) return;
|
||||
tabs = next.buffers.map(tab => ({ ...tab }));
|
||||
activePath = next.activePath;
|
||||
const selected = next.active;
|
||||
documentPanes = syncDocumentPanes(documentPanes, next.buffers.map(tab => tab.id), selected?.id ?? null);
|
||||
if (selected) view = selected.chromeOverride ?? selected.chrome;
|
||||
@@ -843,22 +842,39 @@
|
||||
window.addEventListener("pointerdown", outside);
|
||||
}
|
||||
|
||||
function onPreferencesKeydown(event: KeyboardEvent) {
|
||||
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
|
||||
if (event.ctrlKey && !event.altKey && !event.metaKey && event.key === "Tab" && workingTabs.length) {
|
||||
event.preventDefault(); event.stopPropagation();
|
||||
/** Run a shortcut command. Returns false when the command does not apply now, so the key keeps its default. */
|
||||
function runCommand(command: WorkbenchCommand): boolean {
|
||||
switch (command) {
|
||||
case "next-tab": case "previous-tab": {
|
||||
if (!workingTabs.length) return false;
|
||||
const index = workingTabs.findIndex(tab => tab.relPath === activeTabPath);
|
||||
const next = (index + (event.shiftKey ? -1 : 1) + workingTabs.length) % workingTabs.length;
|
||||
const next = (index + (command === "previous-tab" ? -1 : 1) + workingTabs.length) % workingTabs.length;
|
||||
selectWorkingTab(workingTabs[next].relPath);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
case "settings": void openSettings(); return true;
|
||||
case "help": preferences = "help"; return true;
|
||||
case "quick-open": if (workspace) quickOpen = true; return true;
|
||||
case "new-tab": newTab(); return true;
|
||||
case "search-workspace": if (!transferredWindow) { leftOpen = true; leftView = "search"; } return true;
|
||||
case "save": if (!editorPluginVisible) void save(); return true;
|
||||
case "open-workspace": void chooseWorkspace(); return true;
|
||||
case "new-file": void newFile(); return true;
|
||||
case "toggle-layout": if (!editorPluginVisible) toggleChrome(); return true;
|
||||
case "toggle-terminal": if (!terminalEnabled) return false; toggleTerminal(); return true;
|
||||
case "close-tab":
|
||||
if (editorPluginVisible) { if (activeTabPath) void closeTab(activeTabPath); }
|
||||
else if (activePath) closeTab(activePath);
|
||||
return true;
|
||||
case "toggle-sidebar": if (!transferredWindow) leftOpen = !leftOpen; return true;
|
||||
case "rename": if (!editorPluginVisible && !(leftOpen && leftView === "files")) void renameActive(); return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey && event.key === ",") {
|
||||
event.preventDefault(); event.stopPropagation(); void openSettings();
|
||||
}
|
||||
if (event.key === "F1" && !event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey) {
|
||||
event.preventDefault(); event.stopPropagation(); preferences = "help";
|
||||
}
|
||||
function onPreferencesKeydown(event: KeyboardEvent) {
|
||||
if (event.target instanceof Element && event.target.closest("dialog, [role=dialog], [role=menu]")) return;
|
||||
const command = workbenchCommand(event, preferenceKeys);
|
||||
if (command && runCommand(command)) { event.preventDefault(); event.stopPropagation(); }
|
||||
}
|
||||
|
||||
function onKeydown(event: KeyboardEvent) {
|
||||
@@ -879,56 +895,8 @@
|
||||
// Let shells and terminal applications own their control keys.
|
||||
if (event.target instanceof Element && event.target.closest(".xterm") && event.key !== "`") return;
|
||||
if (event.target instanceof Element && event.target.closest("dialog")) return;
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "p") {
|
||||
event.preventDefault(); if (workspace) quickOpen = true; return;
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey && event.key.toLowerCase() === "t") {
|
||||
event.preventDefault(); newTab(); return;
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.key.toLowerCase() === "f") {
|
||||
event.preventDefault(); if (!transferredWindow) { leftOpen = true; leftView = "search"; } return;
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "s") {
|
||||
event.preventDefault();
|
||||
if (!editorPluginVisible) void save();
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "o") {
|
||||
event.preventDefault();
|
||||
void chooseWorkspace();
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "n") {
|
||||
event.preventDefault();
|
||||
void newFile();
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "e") {
|
||||
event.preventDefault();
|
||||
if (!editorPluginVisible) toggleChrome();
|
||||
}
|
||||
if (terminalEnabled && (event.ctrlKey || event.metaKey) && event.key === "`") {
|
||||
event.preventDefault();
|
||||
toggleTerminal();
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "w") {
|
||||
event.preventDefault();
|
||||
if (editorPluginVisible) {
|
||||
if (activeTabPath) void closeTab(activeTabPath);
|
||||
} else if (activePath) {
|
||||
closeTab(activePath);
|
||||
}
|
||||
}
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "b") {
|
||||
event.preventDefault();
|
||||
if (!transferredWindow) leftOpen = !leftOpen;
|
||||
}
|
||||
if (event.key === "F2" && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
||||
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
if (!editorPluginVisible && !(leftOpen && leftView === "files")) {
|
||||
void renameActive();
|
||||
}
|
||||
}
|
||||
const command = workbenchCommand(event);
|
||||
if (command && runCommand(command)) event.preventDefault();
|
||||
}
|
||||
|
||||
async function renameNoteTitle(id: string, title: string) {
|
||||
@@ -976,11 +944,9 @@
|
||||
const current = documents, currentWorkspace = workspace;
|
||||
const valid = () => documents === current && workspace === currentWorkspace && !!currentWorkspace;
|
||||
const entry = async () => {
|
||||
await session.indexReady;
|
||||
const resolution = session.index.resolve(origin, link.target, link.kind);
|
||||
if (resolution.status === "ambiguous") throw new Error($t("More than one note matches {path}. Use its workspace path: {candidates}", { path: link.target, candidates: resolution.candidates.join(", ") }));
|
||||
const paths = resolution.status === "resolved" ? [resolution.path] : link.kind === "wiki" ? [] : linkCandidates(origin, link.target, link.kind);
|
||||
for (const path of paths) {
|
||||
const targets = await session.linkTargets(origin, link.target, link.kind);
|
||||
if ("ambiguous" in targets) throw new Error($t("More than one note matches {path}. Use its workspace path: {candidates}", { path: link.target, candidates: targets.ambiguous.join(", ") }));
|
||||
for (const path of targets.paths) {
|
||||
if (!valid()) throw new Error("The workspace changed. Open the link menu again.");
|
||||
const parent = path.split("/").slice(0, -1).join("/");
|
||||
let files: TreeEntry[];
|
||||
@@ -1043,14 +1009,13 @@
|
||||
return;
|
||||
}
|
||||
const current = documents, root = workspace?.root;
|
||||
await session.indexReady;
|
||||
const targets = await session.linkTargets(origin, target, kind);
|
||||
if (documents !== current || workspace?.root !== root) return;
|
||||
const resolution = session.index.resolve(origin, target, kind);
|
||||
if (resolution.status === "ambiguous") {
|
||||
error = $t("More than one note matches {path}. Use its workspace path: {candidates}", { path: target, candidates: resolution.candidates.join(", ") });
|
||||
if ("ambiguous" in targets) {
|
||||
error = $t("More than one note matches {path}. Use its workspace path: {candidates}", { path: target, candidates: targets.ambiguous.join(", ") });
|
||||
return;
|
||||
}
|
||||
const rels = resolution.status === "resolved" ? [resolution.path] : kind === "wiki" ? [] : linkCandidates(origin, target, kind);
|
||||
const rels = targets.paths;
|
||||
const fragment = linkFragment(target);
|
||||
focusDocumentPane(paneId);
|
||||
for (const rel of rels) {
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/* Rendered Markdown. Read, the Write previews, and table widgets use these rules. */
|
||||
.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; }
|
||||
.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; }
|
||||
.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; }
|
||||
.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 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; }
|
||||
.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; }
|
||||
@@ -0,0 +1,60 @@
|
||||
/** The commands of the workbench shortcuts. Workbench.svelte runs them. */
|
||||
export type WorkbenchCommand =
|
||||
| "quick-open" | "new-tab" | "search-workspace" | "save" | "open-workspace" | "new-file" | "toggle-layout"
|
||||
| "toggle-terminal" | "close-tab" | "toggle-sidebar" | "rename" | "next-tab" | "previous-tab" | "settings" | "help";
|
||||
|
||||
/**
|
||||
* One shortcut. `mod` is Ctrl, or Cmd on macOS. `ctrl` is Ctrl only.
|
||||
* `shift` and `alt` must match when they are set. A missing value accepts both states.
|
||||
* `outsideFields` ignores the key in text inputs, where it has its own meaning.
|
||||
*/
|
||||
export type WorkbenchKey = {
|
||||
key: string;
|
||||
command: WorkbenchCommand;
|
||||
mod?: boolean;
|
||||
ctrl?: boolean;
|
||||
shift?: boolean;
|
||||
alt?: boolean;
|
||||
outsideFields?: boolean;
|
||||
};
|
||||
|
||||
/** Shortcuts of the main window. The first match wins. */
|
||||
export const workbenchKeys: WorkbenchKey[] = [
|
||||
{ key: "p", mod: true, command: "quick-open" },
|
||||
{ key: "t", mod: true, shift: false, alt: false, command: "new-tab" },
|
||||
{ key: "f", mod: true, shift: true, command: "search-workspace" },
|
||||
{ key: "s", mod: true, command: "save" },
|
||||
{ key: "o", mod: true, command: "open-workspace" },
|
||||
{ key: "n", mod: true, command: "new-file" },
|
||||
{ key: "e", mod: true, command: "toggle-layout" },
|
||||
{ key: "`", mod: true, command: "toggle-terminal" },
|
||||
{ key: "w", mod: true, command: "close-tab" },
|
||||
{ key: "b", mod: true, command: "toggle-sidebar" },
|
||||
{ key: "F2", mod: false, alt: false, outsideFields: true, command: "rename" },
|
||||
];
|
||||
|
||||
/** Shortcuts that also work in the Settings dialog. They run before the editor gets the key. */
|
||||
export const preferenceKeys: WorkbenchKey[] = [
|
||||
{ key: "Tab", ctrl: true, shift: true, alt: false, command: "previous-tab" },
|
||||
{ key: "Tab", ctrl: true, shift: false, alt: false, command: "next-tab" },
|
||||
{ key: ",", mod: true, shift: false, alt: false, command: "settings" },
|
||||
{ key: "F1", mod: false, shift: false, alt: false, command: "help" },
|
||||
];
|
||||
|
||||
type KeyEvent = Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey" | "shiftKey" | "altKey" | "target">;
|
||||
|
||||
function matches(binding: WorkbenchKey, event: KeyEvent): boolean {
|
||||
const key = binding.key.length === 1 ? event.key.toLowerCase() : event.key;
|
||||
if (key !== binding.key) return false;
|
||||
if (binding.mod !== undefined && (event.ctrlKey || event.metaKey) !== binding.mod) return false;
|
||||
if (binding.ctrl && (!event.ctrlKey || event.metaKey)) return false;
|
||||
if (binding.shift !== undefined && event.shiftKey !== binding.shift) return false;
|
||||
if (binding.alt !== undefined && event.altKey !== binding.alt) return false;
|
||||
const field = typeof HTMLInputElement !== "undefined" && (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement);
|
||||
return !(binding.outsideFields && field);
|
||||
}
|
||||
|
||||
/** The command of a key event, or null when no shortcut matches. */
|
||||
export function workbenchCommand(event: KeyEvent, keys: readonly WorkbenchKey[] = workbenchKeys): WorkbenchCommand | null {
|
||||
return keys.find(binding => matches(binding, event))?.command ?? null;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* Element defaults for the whole app. */
|
||||
*,
|
||||
*::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);
|
||||
}
|
||||
::-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);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Icons and labels of action rows, from actionIcons.ts. */
|
||||
.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); }
|
||||
@@ -0,0 +1,16 @@
|
||||
/* Tooltips from tooltip.ts. */
|
||||
.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;
|
||||
}
|
||||
@@ -10,8 +10,8 @@ export type DocumentIO = {
|
||||
|
||||
/** One workspace's documents. UI components never own the saved baseline. */
|
||||
export class Documents {
|
||||
buffers: OpenBuffer[] = [];
|
||||
activePath: string | null = null;
|
||||
buffers = $state<OpenBuffer[]>([]);
|
||||
activePath = $state<string | null>(null);
|
||||
private opening = new Map<string, Promise<void>>();
|
||||
private saving = new Map<string, Promise<void>>();
|
||||
private selection = 0;
|
||||
@@ -1,5 +1,6 @@
|
||||
import { workspaceList, workspaceRead, workspaceReadMany, workspaceRename } from "./api";
|
||||
import { MARKS_PATH, type Marks } from "./marks";
|
||||
import { linkCandidates } from "./markdownLinks";
|
||||
import { MarksStore } from "./marksStore.svelte";
|
||||
import { WorkspaceNoteIndex, type NoteIndexIO } from "./noteIndex";
|
||||
import { moveMarks } from "./treeMoveHistory";
|
||||
@@ -65,8 +66,6 @@ export class WorkspaceSession {
|
||||
this.#emit({ type: "opened", root });
|
||||
}
|
||||
|
||||
/** A promise that settles when the current index build ends. */
|
||||
get indexReady(): Promise<void> { return this.#indexReady; }
|
||||
|
||||
/** Build the index from all files. The Rebuild command and a new workspace use it. */
|
||||
rebuildIndex(): Promise<void> {
|
||||
@@ -97,6 +96,18 @@ export class WorkspaceSession {
|
||||
} catch (reason) { if (this.root === root) this.indexError = String(reason); }
|
||||
}
|
||||
|
||||
/**
|
||||
* The workspace paths that a link can open, in the order to try them. The index answers first.
|
||||
* A Markdown link then falls back to the paths relative to the note and to the workspace.
|
||||
* A wiki name that matches more than one note gives its candidates instead.
|
||||
*/
|
||||
async linkTargets(origin: string, target: string, kind: "md" | "wiki"): Promise<{ paths: string[] } | { ambiguous: string[] }> {
|
||||
await this.#indexReady;
|
||||
const resolution = this.index.resolve(origin, target, kind);
|
||||
if (resolution.status === "ambiguous") return { ambiguous: resolution.candidates };
|
||||
return { paths: resolution.status === "resolved" ? [resolution.path] : kind === "wiki" ? [] : linkCandidates(origin, target, kind) };
|
||||
}
|
||||
|
||||
/** Show the unsaved text of open notes in backlinks. A draft that closes is read again from disk. */
|
||||
setDrafts(drafts: ReadonlyMap<string, string>) {
|
||||
const removed = [...this.#drafts.keys()].filter(path => !drafts.has(path));
|
||||
|
||||
@@ -370,7 +370,7 @@ await runSmoke("layout/workbench", async ({ page }) => {
|
||||
assert.equal(await table.locator('tbody tr').count(), 2);
|
||||
assert.equal(await table.locator('br').count(), 4);
|
||||
assert.ok(!(await table.innerText()).includes('<br>'));
|
||||
// Columns keep the 3rem minimum width (src/app.css:289; reduced from 8rem in 909894b).
|
||||
// Columns keep the 3rem minimum width (`.reading th, .reading td` in src/lib/layout/reading.css; reduced from 8rem in 909894b).
|
||||
assert.ok(await table.locator('th').evaluateAll(cells => {
|
||||
const minimum = 3 * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
return cells.every(cell => cell.getBoundingClientRect().width >= minimum - 0.5);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Node module hooks for the unit tests. A `.svelte.ts` module uses Svelte runes, so the
|
||||
// Svelte compiler compiles it after Node strips its types. The server output keeps the
|
||||
// logic of `$state` fields as plain values, which is enough for tests without a DOM.
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { stripTypeScriptTypes } from "node:module";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { compileModule } from "svelte/compiler";
|
||||
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (!url.startsWith("file:") || !url.endsWith(".svelte.ts")) return nextLoad(url, context);
|
||||
const filename = fileURLToPath(url);
|
||||
const source = stripTypeScriptTypes(await readFile(filename, "utf8"), { mode: "strip" });
|
||||
const { js } = compileModule(source, { filename, generate: "server" });
|
||||
return { format: "module", source: js.code, shortCircuit: true };
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Load with `node --import`, so the unit tests can import `.svelte.ts` modules.
|
||||
import { register } from "node:module";
|
||||
|
||||
register("./hooks.mjs", import.meta.url);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { tabsToClose } from "../../../src/lib/workspace/tabActions.ts";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.ts";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.svelte.ts";
|
||||
|
||||
function setup() {
|
||||
return new Documents({
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { preferenceKeys, workbenchCommand } from "../../../src/lib/layout/workbenchKeys.ts";
|
||||
|
||||
const press = (key: string, modifiers: { ctrl?: boolean; meta?: boolean; shift?: boolean; alt?: boolean } = {}) =>
|
||||
({ key, ctrlKey: !!modifiers.ctrl, metaKey: !!modifiers.meta, shiftKey: !!modifiers.shift, altKey: !!modifiers.alt, target: null });
|
||||
|
||||
test("main shortcuts accept Ctrl and Cmd and keep their shift rules", () => {
|
||||
assert.equal(workbenchCommand(press("p", { ctrl: true })), "quick-open");
|
||||
assert.equal(workbenchCommand(press("P", { meta: true, shift: true })), "quick-open");
|
||||
assert.equal(workbenchCommand(press("t", { ctrl: true })), "new-tab");
|
||||
assert.equal(workbenchCommand(press("T", { ctrl: true, shift: true })), null);
|
||||
assert.equal(workbenchCommand(press("F", { ctrl: true, shift: true })), "search-workspace");
|
||||
assert.equal(workbenchCommand(press("f", { ctrl: true })), null, "Ctrl+F belongs to the document");
|
||||
assert.equal(workbenchCommand(press("`", { ctrl: true })), "toggle-terminal");
|
||||
});
|
||||
|
||||
test("F2 renames outside text fields only", () => {
|
||||
assert.equal(workbenchCommand(press("F2")), "rename");
|
||||
assert.equal(workbenchCommand(press("F2", { alt: true })), null);
|
||||
assert.equal(workbenchCommand(press("F2", { ctrl: true })), null);
|
||||
});
|
||||
|
||||
test("preference shortcuts switch tabs with Ctrl only and open Settings and Help", () => {
|
||||
assert.equal(workbenchCommand(press("Tab", { ctrl: true }), preferenceKeys), "next-tab");
|
||||
assert.equal(workbenchCommand(press("Tab", { ctrl: true, shift: true }), preferenceKeys), "previous-tab");
|
||||
assert.equal(workbenchCommand(press("Tab", { meta: true }), preferenceKeys), null);
|
||||
assert.equal(workbenchCommand(press(",", { meta: true }), preferenceKeys), "settings");
|
||||
assert.equal(workbenchCommand(press("F1"), preferenceKeys), "help");
|
||||
assert.equal(workbenchCommand(press("F1", { shift: true }), preferenceKeys), null);
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { orderWorkbenchTabs } from "../../../src/lib/workspace/workbenchTabs.ts";
|
||||
import { tabsToClose } from "../../../src/lib/workspace/tabActions.ts";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.ts";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.svelte.ts";
|
||||
|
||||
test("mixed tabs retain their positions through title changes, closes, and new tabs", () => {
|
||||
const tabs = [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.ts";
|
||||
import { Documents } from "../../../src/lib/workspace/documents.svelte.ts";
|
||||
|
||||
function deferred<T>() {
|
||||
let resolve!: (value: T) => void;
|
||||
|
||||
Reference in New Issue
Block a user