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:
@@ -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); }
|
||||
Reference in New Issue
Block a user