@quillmark/svelte 0.43.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -24
- package/THEMING.md +5 -16
- package/dist/core/codec/table-view.js +1 -1
- package/dist/core/index.js +1 -5
- package/dist/core/lifecycle.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -3
- package/dist/preset/index.css +1 -2
- package/dist/preset/recipes.css +2 -2
- package/dist/preset/shell.css +3 -4
- package/dist/preview/index.d.ts +3 -0
- package/dist/preview/index.js +4 -2
- package/dist/preview/strings.js +1 -1
- package/dist/visual/diagnostics.d.ts +1 -1
- package/dist/visual/index.js +4 -5
- package/dist/workspace/index.d.ts +2 -0
- package/dist/workspace/index.js +4 -0
- package/dist/workspace/trap.d.ts +8 -0
- package/dist/workspace/trap.js +20 -0
- package/dist/workspace/workspace.d.ts +107 -0
- package/dist/workspace/workspace.js +346 -0
- package/package.json +1 -11
- package/dist/preset/app.css +0 -71
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @quillmark/svelte
|
|
2
2
|
|
|
3
|
-
Editor + live-preview components for [
|
|
3
|
+
Editor + live-preview components for [quillmark](https://github.com/birdorbs/quillmark) WASM consumers. A WYSIWYG **VisualEditor**, and a canvas **Preview** that paints the compiled document and round-trips clicks to the editor, over one `@quillmark/wasm` session. Vanilla-TS cores with thin Svelte 5 wrappers.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
quillmark is pre-1.0. Its [stability statement](https://github.com/birdorbs/quillmark#status) says what any release can change and what every release keeps.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -12,17 +12,17 @@ npm install @quillmark/svelte
|
|
|
12
12
|
|
|
13
13
|
`svelte@^5.33` and `@quillmark/wasm` are peer dependencies: the session's handles cross the package boundary, so the consumer supplies the one copy both sides mint them from.
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Entries
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
A page imports from the root. `/preview` imports less where less is the point, and the preset is a stylesheet.
|
|
18
18
|
|
|
19
|
-
| Import |
|
|
20
|
-
| --------------------------- |
|
|
21
|
-
| `@quillmark/svelte
|
|
22
|
-
| `@quillmark/svelte/preview` |
|
|
23
|
-
| `@quillmark/svelte/
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
| Import | What it is |
|
|
20
|
+
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
21
|
+
| `@quillmark/svelte` | Everything a page mounts: `<VisualEditor>`, `<Preview>` and `createPreview`, review and wording, `init`, the `DocPath`/`Place` address vocabulary and `EditorError` channel the surfaces share, and `createWorkspace` for a shell. |
|
|
22
|
+
| `@quillmark/svelte/preview` | `createPreview` and `<Preview>`, with `init` and the shared address and error types, for a page that only displays a document. It reaches nothing editor-side, so the page ships no ProseMirror. |
|
|
23
|
+
| `@quillmark/svelte/preset` | The opt-in stylesheet for the page around a surface ([THEMING.md](THEMING.md)). |
|
|
24
|
+
|
|
25
|
+
Code with no page, a worker or a plain Node server, mounts no surface, so it imports `init` from `@quillmark/wasm` directly: this package's entries reach the surfaces' stylesheets. Tree-shaking the root is no substitute for `/preview`: the package is `sideEffects: true`, since its components import stylesheets, so a bundler keeps what the root reaches.
|
|
26
26
|
|
|
27
27
|
## Open a session
|
|
28
28
|
|
|
@@ -30,7 +30,7 @@ The **consumer** owns the session and the handles, and drives every edit; the su
|
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
32
|
import { Engine } from '@quillmark/wasm';
|
|
33
|
-
import { init } from '@quillmark/svelte
|
|
33
|
+
import { init } from '@quillmark/svelte';
|
|
34
34
|
|
|
35
35
|
// Quill and Document are exported only through init().
|
|
36
36
|
const { Quill, Document } = await init();
|
|
@@ -41,7 +41,7 @@ const quill = Quill.fromTree(tree); // tree: Map<string, Uint8Array> of the quil
|
|
|
41
41
|
const doc = quill.seedDocument();
|
|
42
42
|
|
|
43
43
|
// An EXISTING document: parsed back from what you stored.
|
|
44
|
-
const doc = Document.parse(markdown); // canonical
|
|
44
|
+
const doc = Document.parse(markdown); // canonical quillmark markdown
|
|
45
45
|
const doc = Document.fromStored(json); // the versioned storage DTO (`doc.toStored()`)
|
|
46
46
|
|
|
47
47
|
const session = await new Engine().open(quill, doc);
|
|
@@ -50,6 +50,74 @@ const session = await new Engine().open(quill, doc);
|
|
|
50
50
|
|
|
51
51
|
`<VisualEditor>` needs no session, and the first `open` loads the render build, so a host that mounts the editor over `doc` and `quill` first shows it without waiting on that load. The session opens behind it: `await engine.load(quill)`, then `engine.open(quill, doc)`, so its first compile reads what was typed meanwhile ([INVARIANTS.md](prose/INVARIANTS.md#hosting)).
|
|
52
52
|
|
|
53
|
+
## A shell on the workspace
|
|
54
|
+
|
|
55
|
+
`createWorkspace` is the glue a shell over the two surfaces writes, packaged as one opt-in policy: it opens the session behind the editor, compiles each edit (a structure op at once, prose and field edits once 120 ms pass without another), merges the diagnostics for the editor, compiles an open review's projection for the preview ([Review](#review)), bridges the caret both ways, latches a backend trap, and tears down in order. The surfaces keep their own contracts under it, and a shell that wants another policy wires them itself ([Recompiling](#recompiling), [The caret bridge](#the-caret-bridge)). One workspace is one document, and it frees only the session it opened. This is the whole of a shell:
|
|
56
|
+
|
|
57
|
+
```svelte
|
|
58
|
+
<script lang="ts">
|
|
59
|
+
import { onDestroy, tick, untrack } from 'svelte';
|
|
60
|
+
import type { Document, Engine, Quill } from '@quillmark/wasm';
|
|
61
|
+
import { createWorkspace, Preview, VisualEditor } from '@quillmark/svelte';
|
|
62
|
+
|
|
63
|
+
interface Props {
|
|
64
|
+
engine: Engine | Promise<Engine>;
|
|
65
|
+
quill: Quill;
|
|
66
|
+
/** Handed over: the shell frees it once the workspace has freed its session. */
|
|
67
|
+
doc: Document;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { engine, quill, doc }: Props = $props();
|
|
71
|
+
|
|
72
|
+
let editor = $state.raw<ReturnType<typeof VisualEditor>>();
|
|
73
|
+
let preview = $state.raw<ReturnType<typeof Preview>>();
|
|
74
|
+
|
|
75
|
+
// One workspace per document: a parent swaps documents with `{#key doc}`.
|
|
76
|
+
const ws = untrack(() =>
|
|
77
|
+
createWorkspace({
|
|
78
|
+
engine,
|
|
79
|
+
quill,
|
|
80
|
+
doc,
|
|
81
|
+
editor: () => editor,
|
|
82
|
+
preview: () => preview,
|
|
83
|
+
onState: (next) => (now = next)
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
let now = $state.raw(ws.state);
|
|
87
|
+
|
|
88
|
+
onDestroy(() => void ws.dispose(tick).then(() => doc.free()));
|
|
89
|
+
|
|
90
|
+
async function download(): Promise<void> {
|
|
91
|
+
const file = await ws.render('pdf');
|
|
92
|
+
if (!file) return;
|
|
93
|
+
const a = document.createElement('a');
|
|
94
|
+
a.href = URL.createObjectURL(new Blob([file.bytes as BlobPart], { type: file.mimeType }));
|
|
95
|
+
a.download = 'document.pdf';
|
|
96
|
+
a.click();
|
|
97
|
+
URL.revokeObjectURL(a.href);
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<button type="button" onclick={download}>Download PDF</button>
|
|
102
|
+
{#if now.status === 'refused'}
|
|
103
|
+
<p role="alert">{now.refused[0]?.message}</p>
|
|
104
|
+
{/if}
|
|
105
|
+
<VisualEditor bind:this={editor} {doc} {quill} diagnostics={now.diagnostics} {...ws.editor} />
|
|
106
|
+
{#if now.session}
|
|
107
|
+
<Preview bind:this={preview} session={now.session} {...ws.preview} />
|
|
108
|
+
{/if}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
A host that opens several documents keys this shell on the document and guards its own open with a counter, so a load that lands after a later one frees its document rather than mounting it.
|
|
112
|
+
|
|
113
|
+
`ws.editor` and `ws.preview` are handler objects: spread them, or call one from a handler of the shell's own, as one that also saves each edit does with `onChange={(change) => { save(); ws.editor.onChange(change); }}`. The surfaces are read through getters because a preview mounts only once a session stands, so its ref arrives late. `onState` hands over a new `state` on every change: the `session` to mount the preview over, `diagnostics` for the editor, `formats` the backend emits, `review`, which is `none`, `shown` (the preview compiles the open review's projection) or `failed` (the projection did not compile, so the preview shows the document), and `status`, which is `opening`, `ready`, `refused` (the engine refused the last open or compile with `refused`; a session that stands still paints its last good compile, and the next edit after a refused open opens again), `paint-failed` (until the next edit) or `trapped`. `diagnostics` takes the shell's own as a getter, merged once each at every compile.
|
|
114
|
+
|
|
115
|
+
`trapped` is terminal: the render build trapped (`runtime::backend_trapped`), so its state is undefined, the session is dropped for the preview to unmount and then freed, and nothing compiles or opens again until the page reloads; editing continues, on the core build. The render build is one per process, so a workspace created after a trap starts `trapped`.
|
|
116
|
+
|
|
117
|
+
`ws.wrote(structural)` is the door for a write the shell made to the document itself: `true` compiles at once, as a card operation does, and otherwise the compile debounces as a keystroke's. `ws.flush()` runs a pending compile now and resolves once the page is current, for a shell that marks the page. `ws.render(format)` compiles a pending edit, waits on the open, and resolves `undefined` where the document does not compile, so a download is the document in hand, never a proposal the reader has not accepted, even while the preview shows one. `ws.doc` and `ws.quill` are the handles the editor mounts over. `ws.dispose(unmounted)` hands `onState` a state with no session, awaits `unmounted` so the surfaces go first, then frees the session.
|
|
118
|
+
|
|
119
|
+
Storage, choosing the quill, switching documents, the review list and collaboration stay the shell's.
|
|
120
|
+
|
|
53
121
|
## The quill resolves from the document
|
|
54
122
|
|
|
55
123
|
A stored document carries none of its quill's bytes, only a reference: `doc.quillRef` is `name@version`, persisted in the markdown itself. Resolution is **host code**: read the ref, map it to a `Quill`, open. No surface resolves, so one resolution per document holds by construction.
|
|
@@ -75,7 +143,7 @@ What stays yours is the text edge and the ref. The markdown is the host's at bot
|
|
|
75
143
|
`createPreview` supplies the layer the session omits: viewport, DOM, DPR, click mapping. It is a pure view: it never calls `session.apply`; you drive the edit and hand it the resulting `ChangeSet`.
|
|
76
144
|
|
|
77
145
|
```ts
|
|
78
|
-
import { createPreview } from '@quillmark/svelte
|
|
146
|
+
import { createPreview } from '@quillmark/svelte';
|
|
79
147
|
|
|
80
148
|
const preview = createPreview(session, {
|
|
81
149
|
container: document.querySelector('#preview')!,
|
|
@@ -101,7 +169,7 @@ In Svelte, `<Preview {session} onPick={…} />` exposes the same verbs (`refresh
|
|
|
101
169
|
|
|
102
170
|
```svelte
|
|
103
171
|
<script lang="ts">
|
|
104
|
-
import { VisualEditor } from '@quillmark/svelte
|
|
172
|
+
import { VisualEditor } from '@quillmark/svelte';
|
|
105
173
|
</script>
|
|
106
174
|
|
|
107
175
|
<VisualEditor
|
|
@@ -198,7 +266,7 @@ type ReviewItem =
|
|
|
198
266
|
- **A proposal for a place inside a field** names it by its path, `main.contact.email` or `main.signature_block[2]`, and is drawn in the control of that place as a field's is: a record's cell, a list's row, ringed and struck where the member goes, or for a member past the last, a row after the list's last in the controls it would have, holding the proposed value under the review tint and taking no input. A choice with variants takes its discriminant at `main.distribution.value` and each cell of its world beside it, and a checklist each member at `main.checks.figures`, drawn on its tick, and each cell inside one. Where no control of its own is drawn, inside a closed row, it marks the nearest one. Accept writes the field's whole value with that place alone changed, down the lane an edit of the place takes. In a list, `after` absent takes the member out, and an index past the last appends one. A member's `before` finds it: where the member at the index no longer holds it, the nearest that does and that no other open proposal of the list has found, so taking one member out does not move the next proposal onto the wrong row. One whose `before` nothing holds is outdated. An item in a closed group marks the group's header, and stepping to it opens the group.
|
|
199
267
|
- **A proposed card** is drawn where it would stand: `add` as a preview of the card, its title, each field it fills by name and the start of its body, after the card at index `after` (before the first card without one), and `remove` as a ring round the card at that index, its values struck and _Proposed removal_ in its header. Accept writes it as the reader's own card operation, the added card under the `$id` it carries, and `onChange` reports it as a `structure` change; ⌘Z takes it back. Cards added after the same card stand in the list's order.
|
|
200
268
|
|
|
201
|
-
`proposalsBetween(quill, base, answer)`, from `@quillmark/svelte
|
|
269
|
+
`proposalsBetween(quill, base, answer)`, from `@quillmark/svelte`, makes the list from an assistant's answer. `base` is the document as the assistant read it, a snapshot taken when it was asked, and `answer` a copy of it the assistant edited; neither is the live document, which the editor compares each item with as it draws, so what the reader typed meanwhile is theirs and a place both changed is `outdated`. It returns `{ items }`, with `before` filled in: one `replace` per block the answer rewrote or took out and one `insert` per run of blocks it added, an item per record cell and list member that changed elsewhere, at the paths of `base`, and an item per card it added, after the card of `base` it follows, and per card it took out. An item names its card one of two ways. `card` beside a `field`, `card` on a removal and `afterCard` on an added card name it by its `$id`, wherever it stands when the item is drawn, and `proposalsBetween` fills them in for every card of `base` that has one: the list holds over a live document whose cards were added, removed or moved since the snapshot. Without one, the path's index, `remove` and `after` name the card by index, read against the cards as they stood when the list was set, and a card added, removed or moved between the snapshot and then is not carried. Either way the editor keeps each item on its card through every card added, removed or moved while the list stands, by `applyCardOps`, by the reader or by an accepted card item. An item whose card is gone goes `undrawn` as `field`, a removal whose card is gone as `applied`, and a card added after one that is gone stands last.
|
|
202
270
|
|
|
203
271
|
```ts
|
|
204
272
|
const base = doc.clone(); // when the assistant is asked
|
|
@@ -229,6 +297,8 @@ The host sets the list once and clears it once. It sets it when an answer arrive
|
|
|
229
297
|
|
|
230
298
|
The verbs complete it. `answerReview(ids | 'all' | { group }, 'accept' | 'dismiss')` answers items as the answer card would, in document order, and returns the ids answered: `onReview` hears each, an item that cannot be answered stands, `'all'` or `{ group }` with `'accept'` leaves every outdated item open, and neither the focus nor the caret moves; answering the current item moves on as the card does. `stepReview(1 | -1)` brings the next or previous drawn item to the reader, round from either end, with the caret in it or the focus in its field (`{ focus: false }` only lights it, and `{ group }` passes over every item of another group), and resolves its id; it scrolls the item's own scroller only as far as it must to show it, so an editor in a pane that scrolls on its own steps within that pane. `revealReview(id)` brings one item to the reader: it opens the group holding the item, scrolls it to the middle of the pane and lights it, and resolves `false` for an item the editor does not draw; `{ focus: true }` also puts the caret in it.
|
|
231
299
|
|
|
300
|
+
While items are open, a preview shows the page as it would read with every open proposal taken, compiled from a copy and never from the document: `projectReview(copy)` writes each one into a clone the host hands in, as its Accept would, and returns `{ ids, toProjection, toLive }`, the proposals written and the map between the document's places and the copy's. The host compiles the copy for its preview alone and frees it, falls back to the document where the copy does not compile, compiles again on each `onReviewDrawn` whose `open` changed, and routes both bridge hops through the map, a pick on a card or paragraph only the copy holds naming the item that adds it for `revealReview`. Everything that saves, shares or prints reads the document. [The workspace](#a-shell-on-the-workspace) does all of this for a shell built on it.
|
|
301
|
+
|
|
232
302
|
The **answer card** floats on the current item, below the paragraph or block it stands in, beside that paragraph's last line where the line ends short of it, centred on the line of a one-line field so it stands inside the field rather than over the next field's label, or above it where there is no room, so it covers none of the item's own paragraph, with **Dismiss** and **Accept** and their keys, and the item's `note` above them on one line. It scrolls with the item and is clipped at the pane's edge as the text is. It keeps clear of `reviewInset`, the px the host's chrome takes at the foot of the pane, while the item shows, steps aside while the reader types, and never takes the focus: a press on it leaves the focus where it was, and Alt+F10 puts the keyboard on it, Escape handing the focus back. Under a finger, or on a screen with no hover, it drops the key hints and its buttons are tap-sized.
|
|
233
303
|
|
|
234
304
|
While a review is open, `REVIEW_KEYS` answer the current item from anywhere on the page but another editor or a text box outside this one: ⌘/Ctrl+Enter accepts it, ⌘/Ctrl+⌥/Alt+Backspace dismisses it, and ⌘/Ctrl+⌥/Alt+↓ and ↑ step to the next and previous item, moving the caret along when pressed in the editor. The two answer keys are the card's, so they answer an item the card stands on in view: with the item scrolled out of the pane, or the card aside while the reader types, the first press brings it back and the next answers it. No leaf binds a review key: ⌘/Ctrl+Enter is the review's alone, and Alt+Enter ticks a task item, takes a sibling from a list element of several lines and leaves a code block. A proposal that only adds blocks is current from anywhere in the paragraph it adds after; where a proposal also rewrites that paragraph, the caret names the rewrite, and `revealReview(id, { focus: true })` puts it in the one asked for. Every word the review draws is a `strings` key, and its one hue is `--qm-review` ([THEMING.md](THEMING.md)).
|
|
@@ -270,11 +340,11 @@ const engine = new Engine({ fonts: [carlito] });
|
|
|
270
340
|
<VisualEditor {doc} {quill} {fonts} />
|
|
271
341
|
```
|
|
272
342
|
|
|
273
|
-
[`@quillmark/fonts`](../fonts) is the library every
|
|
343
|
+
[`@quillmark/fonts`](../fonts) is the library every quillmark client builds its engine over, so a family a document names sets the same way in each; a host's own files go after it. `fontFaces` loads the render build, as `open` does, so mount the editor first and let the faces arrive behind it. A family the document already sets edits with no library at all, and the picker offers it so it can be cleared.
|
|
274
344
|
|
|
275
345
|
### Recompiling
|
|
276
346
|
|
|
277
|
-
`onChange` is the signal to recompile, and it covers **all three lanes**: a prose keystroke, a scalar write, a card operation. `onCaretMove` is a _selection_ signal, not a change signal: it fires on a bare arrow key, so a recompile hung off it recompiles on every one.
|
|
347
|
+
`createWorkspace` is the packaged form of what follows ([A shell on the workspace](#a-shell-on-the-workspace)). `onChange` is the signal to recompile, and it covers **all three lanes**: a prose keystroke, a scalar write, a card operation. `onCaretMove` is a _selection_ signal, not a change signal: it fires on a bare arrow key, so a recompile hung off it recompiles on every one.
|
|
278
348
|
|
|
279
349
|
```ts
|
|
280
350
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -300,11 +370,11 @@ function recompileNow() {
|
|
|
300
370
|
|
|
301
371
|
`session.warnings` is a **getter on a handle Svelte does not track**: pull it per apply, or the editor shows the previous compile's errors.
|
|
302
372
|
|
|
303
|
-
The schedule is host policy,
|
|
373
|
+
The surfaces ship no scheduler: the schedule is host policy, and [the workspace](#a-shell-on-the-workspace) is one such policy, packaged. A host wiring the surfaces itself keeps three obligations: an edit of your own (an import, an undo, a direct `doc` write) recompiles by the same calls, since nothing polls the document; a compile re-reads the diagnostics; and teardown clears the timer **before** freeing the handles.
|
|
304
374
|
|
|
305
375
|
## The caret bridge
|
|
306
376
|
|
|
307
|
-
The bridge lives at the **consumer** layer and is opt-in; the editor is unaware of the preview, the preview unaware of the editor.
|
|
377
|
+
`createWorkspace` wires both directions as `ws.editor` and `ws.preview`, through the review projection's map while one is shown ([A shell on the workspace](#a-shell-on-the-workspace), [Review](#review)). The bridge lives at the **consumer** layer and is opt-in; the editor is unaware of the preview, the preview unaware of the editor. With no review projection shown, both hops are pass-throughs: the two surfaces already speak one address grammar, the canonical `DocPath`.
|
|
308
378
|
|
|
309
379
|
```ts
|
|
310
380
|
// preview → editor: a click resolved to an address lands in the field it names.
|
|
@@ -320,7 +390,7 @@ Both editor→preview hops or neither. A control reports its focus and no caret
|
|
|
320
390
|
|
|
321
391
|
A pick carries a caret where the compile tracks the content under the point, and the field alone where it tracks only the placement — a scalar the plate prints without tracking. `setCaret` takes both: an absent `pos` reveals and focuses the field, which is the whole of what a click on plate-placed ink can mean. The address may name an array element (`main.keywords[0]`), which lands on that row.
|
|
322
392
|
|
|
323
|
-
A consumer holding an `Addr` of its own maps it with the Document's `pathFor`. The playground
|
|
393
|
+
A consumer holding an `Addr` of its own maps it with the Document's `pathFor`. The playground's split-pane route takes both directions from the workspace, through a review projection and under a collaboration room; its landing page mounts the surfaces on their own verbs, with no workspace under them.
|
|
324
394
|
|
|
325
395
|
## Errors
|
|
326
396
|
|
|
@@ -339,15 +409,70 @@ This is not the diagnostics channel. A `Diagnostic` is about the **document** an
|
|
|
339
409
|
|
|
340
410
|
## Canonical markdown
|
|
341
411
|
|
|
342
|
-
`doc.toMarkdown()` returns the document's canonical
|
|
412
|
+
`doc.toMarkdown()` returns the document's canonical quillmark markdown, which re-parses to an equal `Document`. A read-only mirror is that call in a `<pre>`, re-run after each edit lands, so it needs no surface from this package:
|
|
343
413
|
|
|
344
414
|
```ts
|
|
345
415
|
el.textContent = doc.toMarkdown();
|
|
346
416
|
```
|
|
347
417
|
|
|
348
|
-
##
|
|
418
|
+
## Customizing
|
|
419
|
+
|
|
420
|
+
What you can change about quillmark's editor and preview without forking either, and what is closed on purpose. How the surfaces look, from the ten `--qm-*` dials to the opt-in preset, is [`THEMING.md`](THEMING.md); this section says which depth a change belongs to and where each depth stops.
|
|
421
|
+
|
|
422
|
+
### The two depths
|
|
423
|
+
|
|
424
|
+
Start at the shallowest one that holds your change.
|
|
425
|
+
|
|
426
|
+
| | You write | You can change |
|
|
427
|
+
| ------------------------------- | ---------------------------------- | ----------------------------------------------------------------------- |
|
|
428
|
+
| **Theme and word the surfaces** | props and CSS in your own page | how `<VisualEditor>` and `<Preview>` look and what they say |
|
|
429
|
+
| **Write your own shell** | a Svelte file on `createWorkspace` | what the page does: its actions, its storage, where documents come from |
|
|
430
|
+
|
|
431
|
+
#### Theme and word the surfaces
|
|
432
|
+
|
|
433
|
+
In a page of your own you mount `<VisualEditor>` and `<Preview>` yourself and reach everything below.
|
|
434
|
+
|
|
435
|
+
| Handle | What it changes |
|
|
436
|
+
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
437
|
+
| the ten `--qm-*` dials | colour, type, corner and spacing across both surfaces ([THEMING §"The dials"](THEMING.md#the-dials)) |
|
|
438
|
+
| `color-scheme` | light or dark, read off your page or set on one mount with `style` ([THEMING §"The surface follows your colour scheme"](THEMING.md#the-surface-follows-your-colour-scheme)) |
|
|
439
|
+
| `.qm-editor`, `.qm-preview`, `.qm-pane` | placing and sizing each surface from your own stylesheet; `class` and `style` props land on the same root |
|
|
440
|
+
| `[data-qm-card="<kind>"]` | the cards of one kind, `main` for the main card ([THEMING §"What a stylesheet may aim at"](THEMING.md#what-a-stylesheet-may-aim-at)) |
|
|
441
|
+
| `strings`, on each surface | every word it says, keyed and partial, the value-inserting ones included ([§Wording](#wording)) |
|
|
442
|
+
| `formatDiagnostic` | the text of a validation or edit diagnostic under its field |
|
|
443
|
+
| `enumOptionAllowed`, `enumDisallowed` | which options of an enum a deployment offers, and whether a refused one is hidden or greyed |
|
|
444
|
+
| `fonts`, `fontLabels` | the font families the format popover offers, and the names it shows them by ([§Fonts](#fonts)) |
|
|
445
|
+
| the quill's `ui` hints | layout from the schema: `ui.compact` to share a row, `ui.layout: table` for an array, `ui.blank_title` for an enum's blank |
|
|
446
|
+
| `review` | another writer's proposals, drawn where each sits and answered on the page ([§Review](#review)) |
|
|
447
|
+
|
|
448
|
+
#### Write your own shell
|
|
449
|
+
|
|
450
|
+
Any change of behaviour, rather than of look or wording, is a shell of your own: a submit button, saving to your server, sign-in, a document opened prefilled. `createWorkspace` is the glue between the two surfaces packaged, so the shell is a short file of your wiring that takes each npm release as it comes rather than a copy of ours that drifts ([§"A shell on the workspace"](#a-shell-on-the-workspace)).
|
|
451
|
+
|
|
452
|
+
The shell holds the `Document`, so where it comes from and where it goes is yours: parse it from markdown your server sends, seed it from the quill, write it back on every `onChange` or on a press. Storage, choosing the quill, switching documents, the review list and collaboration are the shell's.
|
|
453
|
+
|
|
454
|
+
### What is closed, and why
|
|
455
|
+
|
|
456
|
+
Closed means no prop or promised class reaches it. Each is closed for the reason beside it.
|
|
457
|
+
|
|
458
|
+
| Closed | Why |
|
|
459
|
+
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
460
|
+
| the DOM and classes inside a surface | a class contract over the interior would freeze the DOM the surfaces are free to re-cut; the dials and the root classes already reach what a restyle wants |
|
|
461
|
+
| the control drawn for each field type | per-control render slots are declined: they would hand reconciliation to your code |
|
|
462
|
+
| what the slash menu and the format popover offer | the slash menu offers the constructs the caret can make, each asked whether it would fire there, and its pointer door is declined; the format popover's buttons are fixed and the fonts it offers are yours (`fonts`) |
|
|
463
|
+
| the icons | a closed set drawn against one frame, so no glyph strokes differently from its neighbours; a glyph takes its control's colour, which the dials reach |
|
|
464
|
+
| keyboard shortcuts | each binding and the shortcut list are read off one table, so a list and a key cannot drift; `editorShortcuts()` and `REVIEW_KEYS` read them, and nothing rebinds them |
|
|
465
|
+
| the undo model | undo is per prose field and per list, never one stack for the document, and a removed card has its own step back |
|
|
466
|
+
| image authoring | declined: there is no asset story |
|
|
467
|
+
| touch-first editing | declined: touch is not a target, and neither is an accessory bar |
|
|
468
|
+
|
|
469
|
+
The reasons are recorded with the designs they rejected in [this package's INVARIANTS](prose/INVARIANTS.md). Each package's exported names are held against a committed snapshot, `api.json`, which `check:api` compares on every build of this repository, so nothing becomes open or closed by an export appearing, vanishing or moving between entries without a reviewed diff.
|
|
470
|
+
|
|
471
|
+
### When something you need is missing
|
|
472
|
+
|
|
473
|
+
A dial appears when a real consumer needs one, and every dial is one more thing a reader has to hold. So before forking, [open an issue](https://github.com/birdorbs/quillmark-js/issues) describing what you are building and what stopped you: the need, not the patch.
|
|
349
474
|
|
|
350
|
-
|
|
475
|
+
Meanwhile the supported escape route is a custom shell on the published packages, not a fork: a shell takes each release as an npm update, where a fork takes one only by a merge.
|
|
351
476
|
|
|
352
477
|
## Development
|
|
353
478
|
|
package/THEMING.md
CHANGED
|
@@ -10,6 +10,8 @@ There are three depths to that. An app mounting into an unstyled page stops at t
|
|
|
10
10
|
| **Make it yours** | ten custom properties | the whole surface rescaled and recolored to your brand |
|
|
11
11
|
| **Match ours** | one CSS import | the page around the surface, drawn the way we draw ours |
|
|
12
12
|
|
|
13
|
+
Theming is one part of what you can change without forking: [README §Customizing](README.md#customizing) maps the rest, and what is closed.
|
|
14
|
+
|
|
13
15
|
## Drop it in
|
|
14
16
|
|
|
15
17
|
```svelte
|
|
@@ -130,7 +132,7 @@ import '@quillmark/svelte/preset';
|
|
|
130
132
|
</body>
|
|
131
133
|
```
|
|
132
134
|
|
|
133
|
-
This is the stylesheet our own apps import: the playground
|
|
135
|
+
This is the stylesheet our own apps import: the playground and studio draw with these rules and nothing else, so what you get is what we ship, not a reduction of it.
|
|
134
136
|
|
|
135
137
|
It carries a `--qmh-*` scale for the page, derived from the same ten dials and calibrated against the surfaces' own steps, so a plate of yours and a card of ours agree about which way "raised" goes. Turning a dial moves both.
|
|
136
138
|
|
|
@@ -180,11 +182,11 @@ An app that mounts an editor beside a preview over one session needs a screen to
|
|
|
180
182
|
|
|
181
183
|
The narrow shape is one mount at a time, not two of them stacked: half a narrow viewport is under the width either surface reads at. The track you are not showing is `display: none`, so it leaves the tab order, hit-testing and the accessibility tree together: you need no `inert` on it, and no breakpoint in your JS, since the only state you hold is which of the two you last asked for. Keep both mounted: the hidden pane keeps its pixels, its caret and its scroll, and comes back to them — it rasters nothing at a box it has none of, and repaints only where it returns to a box that draws its pages at another scale. A preview scroll asked for while it was hidden is held and run on the way back, so it opens at the caret rather than several edits behind it. A click that lands in the hidden pane is the one thing the shape adds to your wiring, so send the caret and reveal the track together, or the hit goes somewhere the reader cannot see.
|
|
182
184
|
|
|
183
|
-
Every rule behind the five is wrapped in `:where()`, so it computes at specificity zero: a rule of yours on the same element wins at any specificity and in any sheet order, which is what lets a stylesheet written by someone other than the app's author
|
|
185
|
+
Every rule behind the five is wrapped in `:where()`, so it computes at specificity zero: a rule of yours on the same element wins at any specificity and in any sheet order, which is what lets a stylesheet written by someone other than the app's author restyle a band without knowing which shell rules set it.
|
|
184
186
|
|
|
185
187
|
The shape is shared; the look of a band is not. Your wordmark, your nav and the depth of your head are the most app-specific things on the screen, and a preset that drew them would hand every tool built on this the same face, so they read `--qmh-*` like everything else and you write the rules. `.qm-split`'s gap is a default rather than a fact about splitting: close it to `0` and carry a hairline on one pane if you want the two mounts to meet instead of stand apart.
|
|
186
188
|
|
|
187
|
-
It is **unlayered**, and nothing in it outranks a rule of yours aimed at the same element: the page, type, status and control recipes compute at ordinary specificity, so your own rules beat them by ordinary precedence, and the shell
|
|
189
|
+
It is **unlayered**, and nothing in it outranks a rule of yours aimed at the same element: the page, type, status and control recipes compute at ordinary specificity, so your own rules beat them by ordinary precedence, and the shell computes at specificity zero, as the surfaces do. It is also opt-in and side-effect free until imported: nothing that styles your document arrives with a component.
|
|
188
190
|
|
|
189
191
|
One rule in it earns its place regardless of whether you take the rest, and you want it if you draw a focus ring of your own — cut the mounted surfaces out of the blanket:
|
|
190
192
|
|
|
@@ -196,19 +198,6 @@ One rule in it earns its place regardless of whether you take the rest, and you
|
|
|
196
198
|
|
|
197
199
|
A blanket `:focus-visible` of yours outranks ours, including on the controls that already draw one, so a ring written for the controls that draw none repaints the ones that do. The cut-out leaves yours everywhere else, and `:not(:where(…))` contributes no specificity, so your rule ranks exactly as it would without it.
|
|
198
200
|
|
|
199
|
-
### The app chrome
|
|
200
|
-
|
|
201
|
-
A tool's bands are yours, since a tool's head is the most app-specific thing on its screen. An app whose whole page is one form to fill in has less to say there: a name, the action the page leads to, and a line signing it. Four classes draw that much, quillkit's app client wears them, and a host of its own takes them the same way:
|
|
202
|
-
|
|
203
|
-
| Class | What it is |
|
|
204
|
-
| ----------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
205
|
-
| `.qm-app-header` | The band naming the app: a plate, a gutter and a hairline under it. Put it beside `.qm-bar`. |
|
|
206
|
-
| `.qm-app-title` | What the app is called, at the title rung: the one line on the screen read as a name. |
|
|
207
|
-
| `.qm-app-footer` | The line signing the app, in meta type on the head's plate under a hairline; its links take the line's own ink. |
|
|
208
|
-
| `.qm-app-primary` | The one action the page leads to: the control wearing `--qm-accent`, standing at the touch floor. |
|
|
209
|
-
|
|
210
|
-
They compute at specificity zero, as the shell does, so `.qm-app-header { background: #00308f; color: #fff; }` is the whole of rebranding the head.
|
|
211
|
-
|
|
212
201
|
## What a stylesheet may aim at
|
|
213
202
|
|
|
214
203
|
A stylesheet you write against a mounted surface, or one an author writes over an app someone else built, may aim at these and nothing else:
|
|
@@ -51,7 +51,7 @@ export const DEFAULT_TABLE_STRINGS = {
|
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* The grip's glyph as path data: this chrome's own set, since it is built without Svelte and
|
|
54
|
-
*
|
|
54
|
+
* `core/` reaches no surface module. Same 24×24 frame as `visual/icons/nodes.ts`, off an earlier
|
|
55
55
|
* release; `NOTICE` carries both notices. The dots are zero-length strokes under a round cap.
|
|
56
56
|
*/
|
|
57
57
|
const GRIP = {
|
package/dist/core/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// What this package owns at the substrate seam, which the root re-exports.
|
|
2
2
|
//
|
|
3
3
|
// The `@quillmark/wasm` API is not re-exported: import it from the peer dependency. What earns a
|
|
4
4
|
// line here is what more than one surface speaks and no other package declares: the address
|
|
5
5
|
// vocabulary, the error channel, and the WASM init gate.
|
|
6
|
-
//
|
|
7
|
-
// No stylesheet: a host reaches this entry where there is no document (a worker, a server), and a
|
|
8
|
-
// dev server serves a side-effect sheet as a module that writes a `<style>` into one. The surface
|
|
9
|
-
// barrels carry the theme; `check:deps` holds it.
|
|
10
6
|
export { init } from './lifecycle.js';
|
package/dist/core/lifecycle.js
CHANGED
|
@@ -30,7 +30,7 @@ export function init() {
|
|
|
30
30
|
*/
|
|
31
31
|
export function core() {
|
|
32
32
|
if (!latched) {
|
|
33
|
-
throw new Error('@quillmark/svelte: the WASM core is not initialized. Await `init()` from `@quillmark/svelte
|
|
33
|
+
throw new Error('@quillmark/svelte: the WASM core is not initialized. Await `init()` from `@quillmark/svelte` before mounting a surface or calling a boundary verb.');
|
|
34
34
|
}
|
|
35
35
|
return latched;
|
|
36
36
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// `@quillmark/svelte
|
|
2
|
-
//
|
|
3
|
-
// wants one import for the substrate.
|
|
1
|
+
// `@quillmark/svelte`: everything a page mounts. `init` here latches the surface for the
|
|
2
|
+
// package's synchronous internals; code that mounts no surface calls `@quillmark/wasm`'s directly.
|
|
4
3
|
export * from './core/index.js';
|
|
4
|
+
export * from './visual/index.js';
|
|
5
|
+
export * from './preview/index.js';
|
|
6
|
+
export * from './workspace/index.js';
|
package/dist/preset/index.css
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* `@quillmark/svelte/preset`, the package's one CSS entry point: the endorsed look for the page a
|
|
3
3
|
* surface is mounted on. Opt-in: the surface barrels pull `core/theme.css` and never this, because
|
|
4
4
|
* this styles the document. `scale.css` is where the literals are minted; the rest read them.
|
|
5
|
-
* `recipes.css` ranks at ordinary specificity, `shell.css`
|
|
5
|
+
* `recipes.css` ranks at ordinary specificity, `shell.css` at zero.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
@import './scale.css';
|
|
9
9
|
@import './recipes.css';
|
|
10
10
|
@import './shell.css';
|
|
11
|
-
@import './app.css';
|
package/dist/preset/recipes.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* The endorsed look: the rules a host draws around a mounted surface, as classes it puts on its
|
|
3
|
-
* own elements. The shell is `shell.css
|
|
4
|
-
*
|
|
3
|
+
* own elements. The shell is `shell.css`; the rungs in `scale.css` are the invisible half. This
|
|
4
|
+
* file mints nothing; `check:style` runs its axes here.
|
|
5
5
|
*
|
|
6
6
|
* These are host classes: they land on the consumer's DOM, never on a mounted root, so they freeze
|
|
7
7
|
* nothing about the surfaces' interior.
|
package/dist/preset/shell.css
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
surface sits on; this is what it is mounted in, a tool where `.qm-page` is a document.
|
|
4
4
|
|
|
5
5
|
Every selector here computes at specificity zero, as the surfaces' own do: a host's
|
|
6
|
-
rule on the same element wins whatever order the sheets land in, and
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
the rank. This file mints nothing. */
|
|
6
|
+
rule on the same element wins whatever order the sheets land in, and a stylesheet
|
|
7
|
+
someone other than the app's author writes needs no knowledge of which of these the
|
|
8
|
+
app happened to set. `check:style` holds the rank. This file mints nothing. */
|
|
10
9
|
|
|
11
10
|
/* Pinned to the viewport rather than sized to it: a page-height box still leaves the
|
|
12
11
|
root scroller counting the overflow its panes clip, and a wheel over the chrome drags
|
package/dist/preview/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { init } from '../core/lifecycle.js';
|
|
2
|
+
export type { DocPath, Landing, Place } from '../core/address.js';
|
|
3
|
+
export type { EditorError, EditorErrorCode, EditorErrorHandler } from '../core/errors.js';
|
|
1
4
|
export { createPreview } from './controller.js';
|
|
2
5
|
export type { PreviewOptions, PreviewController } from './controller.js';
|
|
3
6
|
export { default as Preview } from './Preview.svelte';
|
package/dist/preview/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// `@quillmark/svelte/preview`: the live-preview surface. Imports no editor-side code; it may reach
|
|
2
|
-
//
|
|
2
|
+
// modules in `core/` and nothing else (`check:deps`).
|
|
3
3
|
// The theme derivation the page slots read through `var()`; a subpath import reaches `core/`
|
|
4
|
-
// modules, never its
|
|
4
|
+
// modules, never its barrel, which carries no sheet.
|
|
5
5
|
import '../core/theme.css';
|
|
6
|
+
// What a preview-only page needs beside the surface, so it opens a session without the root.
|
|
7
|
+
export { init } from '../core/lifecycle.js';
|
|
6
8
|
export { createPreview } from './controller.js';
|
|
7
9
|
export { default as Preview } from './Preview.svelte';
|
package/dist/preview/strings.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Separate from the visual surface's strings: `/preview` reaches
|
|
1
|
+
// Separate from the visual surface's strings: `/preview` reaches `core/` and nothing editor-side.
|
|
2
2
|
/** The package's English. */
|
|
3
3
|
export const DEFAULT_PREVIEW_STRINGS = {
|
|
4
4
|
renderFailed: 'Preview failed to render.',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Diagnostic, PathStep } from '@quillmark/wasm';
|
|
2
|
-
/** A field's routing address, and
|
|
2
|
+
/** A field's routing address, and `core/`'s `Addr` structurally: an `Addr` is a
|
|
3
3
|
* positional `FieldKey`, so `nearestAddrForFieldPath` is the path→key walk and
|
|
4
4
|
* routing carries no second copy of the grammar. `card` is `undefined` for the main
|
|
5
5
|
* card; a composable card slot is a stable session id (the editor's own bookkeeping)
|
package/dist/visual/index.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
//
|
|
1
|
+
// The WYSIWYG surface, which the root entry re-exports.
|
|
2
2
|
//
|
|
3
3
|
// The federated VisualEditor: a thin Svelte composition over many small editors.
|
|
4
4
|
// Each content leaf is the codec's prose leaf; scalar fields are form controls;
|
|
5
|
-
// structure/cards are the editor's own. Depends on
|
|
5
|
+
// structure/cards are the editor's own. Depends on `core/` and the
|
|
6
6
|
// codec. Relative imports (not `$lib`): svelte-package ships this as-is.
|
|
7
7
|
//
|
|
8
8
|
// The barrel carries what a consumer story wants, and nothing else: a symbol
|
|
9
9
|
// earns its line when a caller outside the package needs it, and grows one when
|
|
10
10
|
// that caller arrives, not before.
|
|
11
11
|
// The theme derivation, which every control on this surface reads through `var()`.
|
|
12
|
-
// Imported at the barrel because
|
|
13
|
-
// reaches modules inside `core/` and never its
|
|
14
|
-
// `check:deps` holds the reach.
|
|
12
|
+
// Imported at the barrel because an entry is what a consumer gets: this surface
|
|
13
|
+
// reaches modules inside `core/` and never its barrel, which carries no sheet.
|
|
15
14
|
import '../core/theme.css';
|
|
16
15
|
export { default as VisualEditor } from './VisualEditor.svelte';
|
|
17
16
|
// The prose leaf's shortcuts, for a host's shortcut list: read off the keymaps' own tables and
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const TRAPPED = "runtime::backend_trapped";
|
|
2
|
+
/** Whether the render build has trapped in this process: its state is undefined from then, so
|
|
3
|
+
* nothing compiles, opens or paints on it again until the page reloads. */
|
|
4
|
+
export declare function backendTrapped(): boolean;
|
|
5
|
+
/** Whether `err` is the engine's trap. */
|
|
6
|
+
export declare function isBackendTrap(err: unknown): boolean;
|
|
7
|
+
export declare function latch(): void;
|
|
8
|
+
export declare function unlatch(): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The render build is one instance per process, so a trap in it is one latch for every
|
|
2
|
+
// workspace in the process. `unlatch` is the tests' door.
|
|
3
|
+
import { isQuillmarkError } from '@quillmark/wasm';
|
|
4
|
+
export const TRAPPED = 'runtime::backend_trapped';
|
|
5
|
+
let latched = false;
|
|
6
|
+
/** Whether the render build has trapped in this process: its state is undefined from then, so
|
|
7
|
+
* nothing compiles, opens or paints on it again until the page reloads. */
|
|
8
|
+
export function backendTrapped() {
|
|
9
|
+
return latched;
|
|
10
|
+
}
|
|
11
|
+
/** Whether `err` is the engine's trap. */
|
|
12
|
+
export function isBackendTrap(err) {
|
|
13
|
+
return isQuillmarkError(err) && err.diagnostics.some((d) => d.code === TRAPPED);
|
|
14
|
+
}
|
|
15
|
+
export function latch() {
|
|
16
|
+
latched = true;
|
|
17
|
+
}
|
|
18
|
+
export function unlatch() {
|
|
19
|
+
latched = false;
|
|
20
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type Artifact, type ChangeSet, type Diagnostic, type Document, type Engine, type LiveSession, type OutputFormat, type Quill } from '@quillmark/wasm';
|
|
2
|
+
import type { Landing, Place } from '../core/address.js';
|
|
3
|
+
import { type EditorError } from '../core/errors.js';
|
|
4
|
+
import type { ReviewDrawn, ReviewProjection } from '../visual/review.js';
|
|
5
|
+
import type { ActiveLeaf, EditorChange } from '../visual/signals.js';
|
|
6
|
+
/** The editor verbs the workspace calls: a mounted `<VisualEditor>` carries them. */
|
|
7
|
+
export interface WorkspaceEditor {
|
|
8
|
+
setCaret(at: Landing): unknown;
|
|
9
|
+
/** Writes the open review into a copy for the preview to compile. Without it, the preview
|
|
10
|
+
* compiles the document whatever the review holds. */
|
|
11
|
+
projectReview?(target: Document): ReviewProjection;
|
|
12
|
+
/** Brings a review item to the reader, for a pick on what only the projection holds. */
|
|
13
|
+
revealReview?(id: string): unknown;
|
|
14
|
+
}
|
|
15
|
+
/** The preview verbs the workspace calls: a mounted `<Preview>` and a `PreviewController` carry
|
|
16
|
+
* them. */
|
|
17
|
+
export interface WorkspacePreview {
|
|
18
|
+
refresh(change: ChangeSet): void;
|
|
19
|
+
focusPosition(at: Place): void;
|
|
20
|
+
endFollow(): void;
|
|
21
|
+
}
|
|
22
|
+
export interface WorkspaceOptions {
|
|
23
|
+
/** The engine the session opens on. A promise is awaited by the open, so the editor need not
|
|
24
|
+
* wait on it. */
|
|
25
|
+
engine: Engine | Promise<Engine>;
|
|
26
|
+
/** Borrowed: the workspace frees neither the quill nor the document. */
|
|
27
|
+
quill: Quill;
|
|
28
|
+
doc: Document;
|
|
29
|
+
/** The mounted editor, or `undefined` while none is. */
|
|
30
|
+
editor: () => WorkspaceEditor | undefined;
|
|
31
|
+
/** The mounted preview, or `undefined` while none is: a preview mounts once a session
|
|
32
|
+
* stands. */
|
|
33
|
+
preview: () => WorkspacePreview | undefined;
|
|
34
|
+
/** The host's own diagnostics, merged into {@link WorkspaceState.diagnostics} at each state
|
|
35
|
+
* change. Re-read on the next one, so a host whose list changes outside an edit calls
|
|
36
|
+
* `wrote(true)`. */
|
|
37
|
+
diagnostics?: () => readonly Diagnostic[];
|
|
38
|
+
/** Called with the new state on every change. Not called at creation: read `state` then. */
|
|
39
|
+
onState?: (state: WorkspaceState) => void;
|
|
40
|
+
}
|
|
41
|
+
export type WorkspaceStatus =
|
|
42
|
+
/** No session yet: the open is in flight. */
|
|
43
|
+
'opening'
|
|
44
|
+
/** The session stands and the last compile took the document. */
|
|
45
|
+
| 'ready'
|
|
46
|
+
/** The engine refused the last open or compile; `refused` says with what. A session that
|
|
47
|
+
* stands still paints its last good compile. */
|
|
48
|
+
| 'refused'
|
|
49
|
+
/** The preview could not paint a page, until the next edit. */
|
|
50
|
+
| 'paint-failed'
|
|
51
|
+
/** The render build trapped, in this workspace or another in the process: there is no session
|
|
52
|
+
* and nothing compiles again until the page reloads. Editing continues. */
|
|
53
|
+
| 'trapped';
|
|
54
|
+
export interface WorkspaceState {
|
|
55
|
+
/** The session this workspace opened, until it is disposed. Mount the preview over it. */
|
|
56
|
+
session: LiveSession | undefined;
|
|
57
|
+
status: WorkspaceStatus;
|
|
58
|
+
/** Every producer's diagnostics, deduplicated, for the editor's `diagnostics` prop: what was
|
|
59
|
+
* refused, the schema's verdict, the compile's warnings, then the host's own. */
|
|
60
|
+
diagnostics: Diagnostic[];
|
|
61
|
+
/** What the engine refused the last open or compile with; empty while it compiles. */
|
|
62
|
+
refused: Diagnostic[];
|
|
63
|
+
/** What the quill's backend emits, once the engine is in hand. */
|
|
64
|
+
formats: OutputFormat[];
|
|
65
|
+
/** What the preview shows of the editor's open review: `none` open, the projection with every
|
|
66
|
+
* open proposal taken (`shown`), or the document because the projection did not compile
|
|
67
|
+
* (`failed`). */
|
|
68
|
+
review: 'none' | 'shown' | 'failed';
|
|
69
|
+
}
|
|
70
|
+
export interface Workspace {
|
|
71
|
+
readonly state: WorkspaceState;
|
|
72
|
+
/** What the editor mounts over: the options' own handles. */
|
|
73
|
+
readonly quill: Quill;
|
|
74
|
+
readonly doc: Document;
|
|
75
|
+
/** Handlers for `<VisualEditor>`, to spread onto it or call from the host's own. */
|
|
76
|
+
readonly editor: {
|
|
77
|
+
readonly onChange: (change: EditorChange) => void;
|
|
78
|
+
readonly onCaretMove: (at: Place) => void;
|
|
79
|
+
readonly onActiveLeafChange: (active?: ActiveLeaf) => void;
|
|
80
|
+
readonly onReviewDrawn: (drawn: ReviewDrawn) => void;
|
|
81
|
+
};
|
|
82
|
+
/** Handlers for `<Preview>`, to spread onto it or call from the host's own. */
|
|
83
|
+
readonly preview: {
|
|
84
|
+
readonly onPick: (at: Landing) => void;
|
|
85
|
+
readonly onError: (err: EditorError) => void;
|
|
86
|
+
};
|
|
87
|
+
/** The host wrote to the document itself: `structural` compiles at once, as a card operation
|
|
88
|
+
* does, and otherwise the compile debounces as a keystroke's. */
|
|
89
|
+
wrote(structural?: boolean): void;
|
|
90
|
+
/** Run the pending compile now; with none pending, nothing. Resolves once the page is
|
|
91
|
+
* current, the open in flight included. */
|
|
92
|
+
flush(): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* The document in hand as a file, never an unaccepted proposal, once the pending compile has
|
|
95
|
+
* run and the open in flight landed. `undefined` where the document does not compile, which
|
|
96
|
+
* `state` says why, or the workspace is disposed or trapped. A render the engine refuses
|
|
97
|
+
* throws.
|
|
98
|
+
*/
|
|
99
|
+
render(format: OutputFormat): Promise<Artifact | undefined>;
|
|
100
|
+
/**
|
|
101
|
+
* Cancel the pending compile, hand `onState` a state with no session, await `unmounted` so the
|
|
102
|
+
* host's surfaces go first, then free the session this workspace opened. Every call after is a
|
|
103
|
+
* no-op.
|
|
104
|
+
*/
|
|
105
|
+
dispose(unmounted?: () => Promise<void>): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
export declare function createWorkspace(opts: WorkspaceOptions): Workspace;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// The glue every shell over the two surfaces writes, packaged as one opt-in policy over one
|
|
2
|
+
// document. Framework-free: the surfaces are reached through getters, and the host renders
|
|
3
|
+
// from the state it is handed.
|
|
4
|
+
import { isQuillmarkError } from '@quillmark/wasm';
|
|
5
|
+
import { errorMessage, reportError } from '../core/errors.js';
|
|
6
|
+
import { backendTrapped, isBackendTrap, latch } from './trap.js';
|
|
7
|
+
const SETTLE_MS = 120;
|
|
8
|
+
/** What makes two diagnostics the same one: one message at two lines of a plate is two. */
|
|
9
|
+
const keyOf = (d) => [
|
|
10
|
+
d.severity,
|
|
11
|
+
d.code ?? '',
|
|
12
|
+
d.path ?? '',
|
|
13
|
+
d.location ? `${d.location.file}:${d.location.line}:${d.location.column}` : '',
|
|
14
|
+
d.message
|
|
15
|
+
].join(' ');
|
|
16
|
+
function merge(sources) {
|
|
17
|
+
const seen = new Map();
|
|
18
|
+
for (const diags of sources)
|
|
19
|
+
for (const diag of diags) {
|
|
20
|
+
const k = keyOf(diag);
|
|
21
|
+
if (!seen.has(k))
|
|
22
|
+
seen.set(k, diag);
|
|
23
|
+
}
|
|
24
|
+
return [...seen.values()];
|
|
25
|
+
}
|
|
26
|
+
function diagnosticsOf(err) {
|
|
27
|
+
if (isQuillmarkError(err) && err.diagnostics.length > 0)
|
|
28
|
+
return err.diagnostics;
|
|
29
|
+
return [{ severity: 'error', message: errorMessage(err) }];
|
|
30
|
+
}
|
|
31
|
+
function freeQuietly(session) {
|
|
32
|
+
try {
|
|
33
|
+
session?.free();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// A trapped build may refuse the free; the reload reclaims it.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const SAME = { ids: [], toProjection: (at) => at, toLive: (at) => at };
|
|
40
|
+
export function createWorkspace(opts) {
|
|
41
|
+
const { quill, doc } = opts;
|
|
42
|
+
let session;
|
|
43
|
+
let refused = [];
|
|
44
|
+
let formats = [];
|
|
45
|
+
let paintFailed = false;
|
|
46
|
+
let trapped = backendTrapped();
|
|
47
|
+
let disposed = false;
|
|
48
|
+
let timer;
|
|
49
|
+
let opening;
|
|
50
|
+
/** Whether an edit landed after the open in flight read the document. */
|
|
51
|
+
let behind = false;
|
|
52
|
+
/** The open review items as one key, so a report that changes none compiles nothing. */
|
|
53
|
+
let reviewing = '';
|
|
54
|
+
/** The map between the document's places and those of what the session last compiled. */
|
|
55
|
+
let projection = SAME;
|
|
56
|
+
let review = 'none';
|
|
57
|
+
const warnings = () => (session?.warnings ?? []).flatMap((d) => {
|
|
58
|
+
if (!d.path)
|
|
59
|
+
return [d];
|
|
60
|
+
const path = projection.toLive(d.path);
|
|
61
|
+
return typeof path === 'string' ? [{ ...d, path }] : [];
|
|
62
|
+
});
|
|
63
|
+
const snapshot = () => ({
|
|
64
|
+
session,
|
|
65
|
+
status: trapped
|
|
66
|
+
? 'trapped'
|
|
67
|
+
: refused.length
|
|
68
|
+
? 'refused'
|
|
69
|
+
: paintFailed
|
|
70
|
+
? 'paint-failed'
|
|
71
|
+
: session
|
|
72
|
+
? 'ready'
|
|
73
|
+
: 'opening',
|
|
74
|
+
diagnostics: merge([refused, quill.validate(doc), warnings(), opts.diagnostics?.() ?? []]),
|
|
75
|
+
refused,
|
|
76
|
+
formats,
|
|
77
|
+
review
|
|
78
|
+
});
|
|
79
|
+
let state = snapshot();
|
|
80
|
+
function emit() {
|
|
81
|
+
state = snapshot();
|
|
82
|
+
opts.onState?.(state);
|
|
83
|
+
}
|
|
84
|
+
function stop() {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
timer = undefined;
|
|
87
|
+
}
|
|
88
|
+
/** The render build is gone: drop the session for the surfaces to unmount, then free it. */
|
|
89
|
+
function trap(err) {
|
|
90
|
+
if (trapped)
|
|
91
|
+
return;
|
|
92
|
+
latch();
|
|
93
|
+
trapped = true;
|
|
94
|
+
stop();
|
|
95
|
+
if (err !== undefined)
|
|
96
|
+
console.error('[quillmark/ui] the render build trapped', err);
|
|
97
|
+
const lost = session;
|
|
98
|
+
session = undefined;
|
|
99
|
+
refused = [];
|
|
100
|
+
paintFailed = false;
|
|
101
|
+
projection = SAME;
|
|
102
|
+
review = 'none';
|
|
103
|
+
if (!disposed)
|
|
104
|
+
emit();
|
|
105
|
+
setTimeout(() => freeQuietly(lost), 0);
|
|
106
|
+
}
|
|
107
|
+
/** Whether this workspace is trapped, taking up a trap another one in the process latched. */
|
|
108
|
+
function struck() {
|
|
109
|
+
if (!trapped && backendTrapped())
|
|
110
|
+
trap();
|
|
111
|
+
return trapped;
|
|
112
|
+
}
|
|
113
|
+
function open() {
|
|
114
|
+
behind = false;
|
|
115
|
+
const run = (async () => {
|
|
116
|
+
try {
|
|
117
|
+
const engine = await opts.engine;
|
|
118
|
+
formats = await engine.supportedFormats(quill);
|
|
119
|
+
if (struck())
|
|
120
|
+
return;
|
|
121
|
+
const opened = await engine.open(quill, doc);
|
|
122
|
+
if (disposed || struck())
|
|
123
|
+
return freeQuietly(opened);
|
|
124
|
+
session = opened;
|
|
125
|
+
refused = [];
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (disposed)
|
|
129
|
+
return;
|
|
130
|
+
if (isBackendTrap(err))
|
|
131
|
+
return trap(err);
|
|
132
|
+
refused = diagnosticsOf(err);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
opening = undefined;
|
|
136
|
+
}
|
|
137
|
+
if (behind || (reviewing && opts.editor()?.projectReview))
|
|
138
|
+
return compile();
|
|
139
|
+
emit();
|
|
140
|
+
})();
|
|
141
|
+
opening = run;
|
|
142
|
+
return run;
|
|
143
|
+
}
|
|
144
|
+
/** Compile the open review into a copy of the document, freed in every path. */
|
|
145
|
+
function project(live) {
|
|
146
|
+
const editor = opts.editor();
|
|
147
|
+
if (!editor?.projectReview)
|
|
148
|
+
return 'none';
|
|
149
|
+
const copy = doc.clone();
|
|
150
|
+
let change;
|
|
151
|
+
try {
|
|
152
|
+
const projected = editor.projectReview(copy);
|
|
153
|
+
if (!projected.ids.length)
|
|
154
|
+
return 'none';
|
|
155
|
+
change = live.update(copy);
|
|
156
|
+
projection = projected;
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
if (!isBackendTrap(err))
|
|
160
|
+
return 'failed';
|
|
161
|
+
trap(err);
|
|
162
|
+
return 'trapped';
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
copy.free();
|
|
166
|
+
}
|
|
167
|
+
review = 'shown';
|
|
168
|
+
refused = [];
|
|
169
|
+
opts.preview()?.refresh(change);
|
|
170
|
+
emit();
|
|
171
|
+
return 'shown';
|
|
172
|
+
}
|
|
173
|
+
function compile() {
|
|
174
|
+
stop();
|
|
175
|
+
if (disposed || struck())
|
|
176
|
+
return Promise.resolve();
|
|
177
|
+
if (!session) {
|
|
178
|
+
if (!opening)
|
|
179
|
+
return open();
|
|
180
|
+
behind = true;
|
|
181
|
+
return opening;
|
|
182
|
+
}
|
|
183
|
+
const projected = reviewing ? project(session) : 'none';
|
|
184
|
+
if (projected === 'shown' || projected === 'trapped')
|
|
185
|
+
return Promise.resolve();
|
|
186
|
+
projection = SAME;
|
|
187
|
+
review = projected;
|
|
188
|
+
let change;
|
|
189
|
+
try {
|
|
190
|
+
change = session.update(doc);
|
|
191
|
+
refused = [];
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
if (isBackendTrap(err)) {
|
|
195
|
+
trap(err);
|
|
196
|
+
return Promise.resolve();
|
|
197
|
+
}
|
|
198
|
+
refused = diagnosticsOf(err);
|
|
199
|
+
}
|
|
200
|
+
if (change)
|
|
201
|
+
opts.preview()?.refresh(change);
|
|
202
|
+
emit();
|
|
203
|
+
return Promise.resolve();
|
|
204
|
+
}
|
|
205
|
+
function wrote(structural = false) {
|
|
206
|
+
if (disposed || trapped)
|
|
207
|
+
return;
|
|
208
|
+
if (paintFailed) {
|
|
209
|
+
paintFailed = false;
|
|
210
|
+
emit();
|
|
211
|
+
}
|
|
212
|
+
if (structural)
|
|
213
|
+
void compile();
|
|
214
|
+
else {
|
|
215
|
+
clearTimeout(timer);
|
|
216
|
+
timer = setTimeout(() => void compile(), SETTLE_MS);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async function flush() {
|
|
220
|
+
if (timer !== undefined)
|
|
221
|
+
await compile();
|
|
222
|
+
await opening;
|
|
223
|
+
}
|
|
224
|
+
function renderOf(live, format) {
|
|
225
|
+
let artifact;
|
|
226
|
+
try {
|
|
227
|
+
[artifact] = live.render({ format }).artifacts;
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
if (!isBackendTrap(err))
|
|
231
|
+
throw err;
|
|
232
|
+
trap(err);
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
if (!artifact)
|
|
236
|
+
throw new Error(`the ${quill.backendId} backend emitted no ${format}`);
|
|
237
|
+
return artifact;
|
|
238
|
+
}
|
|
239
|
+
/** The session holds the projection: compile the document for the file, then the projection
|
|
240
|
+
* again for the preview. A document that does not compile leaves the projection painted. */
|
|
241
|
+
function renderDocument(live, format) {
|
|
242
|
+
try {
|
|
243
|
+
live.update(doc);
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
if (isBackendTrap(err))
|
|
247
|
+
trap(err);
|
|
248
|
+
else {
|
|
249
|
+
refused = diagnosticsOf(err);
|
|
250
|
+
emit();
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
return renderOf(live, format);
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
void compile();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (!trapped)
|
|
262
|
+
void open();
|
|
263
|
+
return {
|
|
264
|
+
get state() {
|
|
265
|
+
return state;
|
|
266
|
+
},
|
|
267
|
+
quill,
|
|
268
|
+
doc,
|
|
269
|
+
editor: {
|
|
270
|
+
onChange(change) {
|
|
271
|
+
wrote(change.source === 'structure');
|
|
272
|
+
},
|
|
273
|
+
onCaretMove(at) {
|
|
274
|
+
if (disposed)
|
|
275
|
+
return;
|
|
276
|
+
const shown = projection.toProjection(at);
|
|
277
|
+
if (shown)
|
|
278
|
+
opts.preview()?.focusPosition(shown);
|
|
279
|
+
},
|
|
280
|
+
onActiveLeafChange() {
|
|
281
|
+
if (!disposed)
|
|
282
|
+
opts.preview()?.endFollow();
|
|
283
|
+
},
|
|
284
|
+
onReviewDrawn(drawn) {
|
|
285
|
+
const key = drawn.open.join('\n');
|
|
286
|
+
if (disposed || key === reviewing)
|
|
287
|
+
return;
|
|
288
|
+
reviewing = key;
|
|
289
|
+
if (opts.editor()?.projectReview || review !== 'none')
|
|
290
|
+
void compile();
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
preview: {
|
|
294
|
+
onPick(at) {
|
|
295
|
+
if (disposed)
|
|
296
|
+
return;
|
|
297
|
+
const editor = opts.editor();
|
|
298
|
+
const live = projection.toLive(at);
|
|
299
|
+
if (!editor || !live)
|
|
300
|
+
return;
|
|
301
|
+
if ('review' in live)
|
|
302
|
+
void editor.revealReview?.(live.review);
|
|
303
|
+
else
|
|
304
|
+
void editor.setCaret(live);
|
|
305
|
+
},
|
|
306
|
+
onError(err) {
|
|
307
|
+
if (err.code !== 'paint-failed')
|
|
308
|
+
return reportError(undefined, err);
|
|
309
|
+
if (disposed || trapped)
|
|
310
|
+
return;
|
|
311
|
+
if (isBackendTrap(err.cause))
|
|
312
|
+
return trap(err.cause);
|
|
313
|
+
if (paintFailed)
|
|
314
|
+
return;
|
|
315
|
+
paintFailed = true;
|
|
316
|
+
emit();
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
wrote,
|
|
320
|
+
flush,
|
|
321
|
+
async render(format) {
|
|
322
|
+
if (disposed)
|
|
323
|
+
return undefined;
|
|
324
|
+
await flush();
|
|
325
|
+
if (disposed || struck() || !session)
|
|
326
|
+
return undefined;
|
|
327
|
+
if (review === 'shown')
|
|
328
|
+
return renderDocument(session, format);
|
|
329
|
+
if (refused.length)
|
|
330
|
+
return undefined;
|
|
331
|
+
return renderOf(session, format);
|
|
332
|
+
},
|
|
333
|
+
async dispose(unmounted) {
|
|
334
|
+
if (disposed)
|
|
335
|
+
return;
|
|
336
|
+
disposed = true;
|
|
337
|
+
stop();
|
|
338
|
+
const opened = session;
|
|
339
|
+
session = undefined;
|
|
340
|
+
state = { ...state, session: undefined };
|
|
341
|
+
opts.onState?.(state);
|
|
342
|
+
await unmounted?.();
|
|
343
|
+
opened?.free();
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillmark/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,21 +33,11 @@
|
|
|
33
33
|
"svelte": "./dist/index.js",
|
|
34
34
|
"default": "./dist/index.js"
|
|
35
35
|
},
|
|
36
|
-
"./core": {
|
|
37
|
-
"types": "./dist/core/index.d.ts",
|
|
38
|
-
"svelte": "./dist/core/index.js",
|
|
39
|
-
"default": "./dist/core/index.js"
|
|
40
|
-
},
|
|
41
36
|
"./preview": {
|
|
42
37
|
"types": "./dist/preview/index.d.ts",
|
|
43
38
|
"svelte": "./dist/preview/index.js",
|
|
44
39
|
"default": "./dist/preview/index.js"
|
|
45
40
|
},
|
|
46
|
-
"./visual": {
|
|
47
|
-
"types": "./dist/visual/index.d.ts",
|
|
48
|
-
"svelte": "./dist/visual/index.js",
|
|
49
|
-
"default": "./dist/visual/index.js"
|
|
50
|
-
},
|
|
51
41
|
"./preset": {
|
|
52
42
|
"types": "./dist/preset/index.d.ts",
|
|
53
43
|
"default": "./dist/preset/index.css"
|
package/dist/preset/app.css
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/* An app's own chrome: the band that names it, the line that signs it, and the one
|
|
2
|
-
action it exists for. The shell gives a band its row; these give the app's bands their
|
|
3
|
-
look, for a host whose page is one form rather than a workroom. quillkit's app client
|
|
4
|
-
wears them, and an author's `app.css` restyles them (THEMING §"The app chrome").
|
|
5
|
-
|
|
6
|
-
Specificity zero throughout, as the shell's: a rule of the host's own on the same
|
|
7
|
-
element wins at any specificity and in any sheet order. `check:style` holds the rank.
|
|
8
|
-
This file mints nothing. */
|
|
9
|
-
|
|
10
|
-
/* The head: the plate the title stands on, a hairline under it, and the ink everything on
|
|
11
|
-
it takes, so a host recolouring the band recolours its name with it. */
|
|
12
|
-
:where(.qm-app-header) {
|
|
13
|
-
padding: var(--qmh-space-2) var(--qmh-space-4);
|
|
14
|
-
color: var(--qmh-ink);
|
|
15
|
-
background: var(--qmh-surface);
|
|
16
|
-
border-block-end: var(--qmh-border-width) solid var(--qmh-border);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* What the app is called. Display type rather than chrome type: it is the one line on
|
|
20
|
-
the screen a reader reads as a name. */
|
|
21
|
-
:where(.qm-app-title) {
|
|
22
|
-
margin: 0;
|
|
23
|
-
font-size: var(--qmh-text-title);
|
|
24
|
-
font-weight: var(--qmh-weight-strong);
|
|
25
|
-
line-height: var(--qmh-leading-tight);
|
|
26
|
-
color: inherit;
|
|
27
|
-
overflow-wrap: anywhere;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* The foot: a line of meta type on the head's plate under a hairline, its links in the
|
|
31
|
-
line's own ink. The two bands framing the panes stand on one plate. */
|
|
32
|
-
:where(.qm-app-footer) {
|
|
33
|
-
padding: var(--qmh-space-2) var(--qmh-space-4);
|
|
34
|
-
background: var(--qmh-surface);
|
|
35
|
-
border-block-start: var(--qmh-border-width) solid var(--qmh-border);
|
|
36
|
-
font-size: var(--qmh-text-meta);
|
|
37
|
-
line-height: var(--qmh-leading-tight);
|
|
38
|
-
color: var(--qmh-ink-meta);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:where(.qm-app-footer a) {
|
|
42
|
-
color: inherit;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* The primary action: the one control on the screen that wears the accent, at the touch
|
|
46
|
-
floor, since it is the press the whole page leads to. */
|
|
47
|
-
:where(.qm-app-primary) {
|
|
48
|
-
font: inherit;
|
|
49
|
-
font-size: var(--qmh-text-label);
|
|
50
|
-
font-weight: var(--qmh-weight-strong);
|
|
51
|
-
line-height: var(--qmh-leading-tight);
|
|
52
|
-
min-height: var(--qmh-tap);
|
|
53
|
-
padding: var(--qmh-space-2) var(--qmh-space-4);
|
|
54
|
-
color: var(--qmh-on-accent);
|
|
55
|
-
background: var(--qmh-accent);
|
|
56
|
-
border: var(--qmh-border-width) solid var(--qmh-accent);
|
|
57
|
-
border-radius: var(--qmh-radius-inner);
|
|
58
|
-
cursor: pointer;
|
|
59
|
-
transition: background-color var(--qmh-duration) var(--qmh-ease-reverse);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
:where(.qm-app-primary:hover) {
|
|
63
|
-
background: var(--qmh-accent-hover);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
:where(.qm-app-primary:disabled) {
|
|
67
|
-
color: var(--qmh-ink-meta);
|
|
68
|
-
background: var(--qmh-surface-hover);
|
|
69
|
-
border-color: var(--qmh-border);
|
|
70
|
-
cursor: default;
|
|
71
|
-
}
|