@quillmark/svelte 0.44.0 → 0.46.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 +64 -18
- package/THEMING.md +4 -17
- package/dist/preset/index.css +1 -2
- package/dist/preset/recipes.css +2 -2
- package/dist/preset/shell.css +3 -4
- package/dist/workspace/index.d.ts +0 -3
- package/dist/workspace/index.js +0 -3
- package/dist/workspace/trap.d.ts +2 -6
- package/dist/workspace/trap.js +2 -15
- package/dist/workspace/workspace.js +7 -15
- package/package.json +2 -3
- package/CUSTOMIZING.md +0 -78
- package/dist/preset/app.css +0 -71
- package/dist/workspace/print.d.ts +0 -13
- package/dist/workspace/print.js +0 -67
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@ npm install @quillmark/svelte
|
|
|
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 | 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`
|
|
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)).
|
|
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
24
|
|
|
25
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
|
|
|
@@ -112,16 +112,9 @@ A host that opens several documents keys this shell on the document and guards i
|
|
|
112
112
|
|
|
113
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
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
|
|
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 engine latches the trap for its build, so a workspace standing beside the one that trapped, or created after it, meets the trap at its next call and ends `trapped` too, as does one whose host met the trap outside it.
|
|
116
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
|
-
```ts
|
|
120
|
-
const printing = beginPrint();
|
|
121
|
-
const pdf = await ws.render('pdf');
|
|
122
|
-
if (!pdf) printing.cancel();
|
|
123
|
-
else if (!printing.print(pdf.bytes)) refusal = 'This browser blocked printing.';
|
|
124
|
-
```
|
|
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.
|
|
125
118
|
|
|
126
119
|
Storage, choosing the quill, switching documents, the review list and collaboration stay the shell's.
|
|
127
120
|
|
|
@@ -397,7 +390,7 @@ Both editor→preview hops or neither. A control reports its focus and no caret
|
|
|
397
390
|
|
|
398
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.
|
|
399
392
|
|
|
400
|
-
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
|
|
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 `/surfaces` route mounts the surfaces on their own verbs, with no workspace under them.
|
|
401
394
|
|
|
402
395
|
## Errors
|
|
403
396
|
|
|
@@ -422,11 +415,64 @@ This is not the diagnostics channel. A `Diagnostic` is about the **document** an
|
|
|
422
415
|
el.textContent = doc.toMarkdown();
|
|
423
416
|
```
|
|
424
417
|
|
|
425
|
-
##
|
|
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
|
|
426
472
|
|
|
427
|
-
|
|
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.
|
|
428
474
|
|
|
429
|
-
|
|
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.
|
|
430
476
|
|
|
431
477
|
## Development
|
|
432
478
|
|
package/THEMING.md
CHANGED
|
@@ -10,7 +10,7 @@ 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: [
|
|
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
14
|
|
|
15
15
|
## Drop it in
|
|
16
16
|
|
|
@@ -132,7 +132,7 @@ import '@quillmark/svelte/preset';
|
|
|
132
132
|
</body>
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
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.
|
|
136
136
|
|
|
137
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.
|
|
138
138
|
|
|
@@ -182,11 +182,11 @@ An app that mounts an editor beside a preview over one session needs a screen to
|
|
|
182
182
|
|
|
183
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.
|
|
184
184
|
|
|
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
|
|
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.
|
|
186
186
|
|
|
187
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.
|
|
188
188
|
|
|
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
|
|
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.
|
|
190
190
|
|
|
191
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:
|
|
192
192
|
|
|
@@ -198,19 +198,6 @@ One rule in it earns its place regardless of whether you take the rest, and you
|
|
|
198
198
|
|
|
199
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.
|
|
200
200
|
|
|
201
|
-
### The app chrome
|
|
202
|
-
|
|
203
|
-
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:
|
|
204
|
-
|
|
205
|
-
| Class | What it is |
|
|
206
|
-
| ----------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
207
|
-
| `.qm-app-header` | The band naming the app: a plate, a gutter and a hairline under it. Put it beside `.qm-bar`. |
|
|
208
|
-
| `.qm-app-title` | What the app is called, at the title rung: the one line on the screen read as a name. |
|
|
209
|
-
| `.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. |
|
|
210
|
-
| `.qm-app-primary` | The one action the page leads to: the control wearing `--qm-accent`, standing at the touch floor. |
|
|
211
|
-
|
|
212
|
-
They compute at specificity zero, as the shell does, so `.qm-app-header { background: #00308f; color: #fff; }` is the whole of rebranding the head.
|
|
213
|
-
|
|
214
201
|
## What a stylesheet may aim at
|
|
215
202
|
|
|
216
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:
|
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
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
export { createWorkspace } from './workspace.js';
|
|
2
|
-
export { backendTrapped } from './trap.js';
|
|
3
2
|
export type { Workspace, WorkspaceEditor, WorkspaceOptions, WorkspacePreview, WorkspaceState, WorkspaceStatus } from './workspace.js';
|
|
4
|
-
export { beginPrint } from './print.js';
|
|
5
|
-
export type { Printing } from './print.js';
|
package/dist/workspace/index.js
CHANGED
|
@@ -2,6 +2,3 @@
|
|
|
2
2
|
// bridge over the two surfaces, an opt-in layer the root re-exports. Neither surface imports it
|
|
3
3
|
// (`check:deps`).
|
|
4
4
|
export { createWorkspace } from './workspace.js';
|
|
5
|
-
export { backendTrapped } from './trap.js';
|
|
6
|
-
// The browser door a shell prints a file through.
|
|
7
|
-
export { beginPrint } from './print.js';
|
package/dist/workspace/trap.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export declare const TRAPPED = "runtime::backend_trapped";
|
|
2
|
-
/** Whether the
|
|
3
|
-
*
|
|
4
|
-
export declare function backendTrapped(): boolean;
|
|
5
|
-
/** Whether `err` is the engine's trap. */
|
|
2
|
+
/** Whether `err` is the engine's trap. The engine latches it, so every later call into the trapped
|
|
3
|
+
* build rejects with it. */
|
|
6
4
|
export declare function isBackendTrap(err: unknown): boolean;
|
|
7
|
-
export declare function latch(): void;
|
|
8
|
-
export declare function unlatch(): void;
|
package/dist/workspace/trap.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
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 and is not exported from the root.
|
|
3
1
|
import { isQuillmarkError } from '@quillmark/wasm';
|
|
4
2
|
export const TRAPPED = 'runtime::backend_trapped';
|
|
5
|
-
|
|
6
|
-
|
|
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. */
|
|
3
|
+
/** Whether `err` is the engine's trap. The engine latches it, so every later call into the trapped
|
|
4
|
+
* build rejects with it. */
|
|
12
5
|
export function isBackendTrap(err) {
|
|
13
6
|
return isQuillmarkError(err) && err.diagnostics.some((d) => d.code === TRAPPED);
|
|
14
7
|
}
|
|
15
|
-
export function latch() {
|
|
16
|
-
latched = true;
|
|
17
|
-
}
|
|
18
|
-
export function unlatch() {
|
|
19
|
-
latched = false;
|
|
20
|
-
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// from the state it is handed.
|
|
4
4
|
import { isQuillmarkError } from '@quillmark/wasm';
|
|
5
5
|
import { errorMessage, reportError } from '../core/errors.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isBackendTrap } from './trap.js';
|
|
7
7
|
const SETTLE_MS = 120;
|
|
8
8
|
/** What makes two diagnostics the same one: one message at two lines of a plate is two. */
|
|
9
9
|
const keyOf = (d) => [
|
|
@@ -43,7 +43,7 @@ export function createWorkspace(opts) {
|
|
|
43
43
|
let refused = [];
|
|
44
44
|
let formats = [];
|
|
45
45
|
let paintFailed = false;
|
|
46
|
-
let trapped =
|
|
46
|
+
let trapped = false;
|
|
47
47
|
let disposed = false;
|
|
48
48
|
let timer;
|
|
49
49
|
let opening;
|
|
@@ -89,7 +89,6 @@ export function createWorkspace(opts) {
|
|
|
89
89
|
function trap(err) {
|
|
90
90
|
if (trapped)
|
|
91
91
|
return;
|
|
92
|
-
latch();
|
|
93
92
|
trapped = true;
|
|
94
93
|
stop();
|
|
95
94
|
if (err !== undefined)
|
|
@@ -104,22 +103,16 @@ export function createWorkspace(opts) {
|
|
|
104
103
|
emit();
|
|
105
104
|
setTimeout(() => freeQuietly(lost), 0);
|
|
106
105
|
}
|
|
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
106
|
function open() {
|
|
114
107
|
behind = false;
|
|
115
108
|
const run = (async () => {
|
|
116
109
|
try {
|
|
117
110
|
const engine = await opts.engine;
|
|
118
111
|
formats = await engine.supportedFormats(quill);
|
|
119
|
-
if (
|
|
112
|
+
if (trapped)
|
|
120
113
|
return;
|
|
121
114
|
const opened = await engine.open(quill, doc);
|
|
122
|
-
if (disposed ||
|
|
115
|
+
if (disposed || trapped)
|
|
123
116
|
return freeQuietly(opened);
|
|
124
117
|
session = opened;
|
|
125
118
|
refused = [];
|
|
@@ -172,7 +165,7 @@ export function createWorkspace(opts) {
|
|
|
172
165
|
}
|
|
173
166
|
function compile() {
|
|
174
167
|
stop();
|
|
175
|
-
if (disposed ||
|
|
168
|
+
if (disposed || trapped)
|
|
176
169
|
return Promise.resolve();
|
|
177
170
|
if (!session) {
|
|
178
171
|
if (!opening)
|
|
@@ -258,8 +251,7 @@ export function createWorkspace(opts) {
|
|
|
258
251
|
void compile();
|
|
259
252
|
}
|
|
260
253
|
}
|
|
261
|
-
|
|
262
|
-
void open();
|
|
254
|
+
void open();
|
|
263
255
|
return {
|
|
264
256
|
get state() {
|
|
265
257
|
return state;
|
|
@@ -322,7 +314,7 @@ export function createWorkspace(opts) {
|
|
|
322
314
|
if (disposed)
|
|
323
315
|
return undefined;
|
|
324
316
|
await flush();
|
|
325
|
-
if (disposed ||
|
|
317
|
+
if (disposed || trapped || !session)
|
|
326
318
|
return undefined;
|
|
327
319
|
if (review === 'shown')
|
|
328
320
|
return renderDocument(session, format);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillmark/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"files": [
|
|
47
47
|
"dist",
|
|
48
48
|
"THEMING.md",
|
|
49
|
-
"CUSTOMIZING.md",
|
|
50
49
|
"NOTICE"
|
|
51
50
|
],
|
|
52
51
|
"sideEffects": true,
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
63
|
-
"@quillmark/wasm": ">=0.142.
|
|
62
|
+
"@quillmark/wasm": ">=0.142.1-0",
|
|
64
63
|
"svelte": "^5.33.0"
|
|
65
64
|
},
|
|
66
65
|
"dependencies": {
|
package/CUSTOMIZING.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Customizing
|
|
2
|
-
|
|
3
|
-
What you can change about Quillmark's editor, preview and the quillkit app without forking any of it, and what is closed on purpose. The CSS detail is [THEMING.md](THEMING.md); this page says which depth a change belongs to and where each depth stops.
|
|
4
|
-
|
|
5
|
-
## The three depths
|
|
6
|
-
|
|
7
|
-
Start at the shallowest one that holds your change.
|
|
8
|
-
|
|
9
|
-
| | You write | You can change |
|
|
10
|
-
| ------------------------------- | ---------------------------------- | ----------------------------------------------------------------------- |
|
|
11
|
-
| **Configure the quillkit app** | files beside your quiver, no code | the app's name, icon and look |
|
|
12
|
-
| **Theme and word the surfaces** | props and CSS in your own page | how `<VisualEditor>` and `<Preview>` look and what they say |
|
|
13
|
-
| **Write your own shell** | a Svelte file on `createWorkspace` | what the page does: its actions, its storage, where documents come from |
|
|
14
|
-
|
|
15
|
-
### Configure the quillkit app
|
|
16
|
-
|
|
17
|
-
`quillkit build app` turns a quiver into a standalone app for the people filling its forms in. You configure it with files found by name beside `Quiver.yaml`, all optional ([quillkit's README](../quillkit/README.md#the-app)):
|
|
18
|
-
|
|
19
|
-
| File | What it sets |
|
|
20
|
-
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
21
|
-
| `App.yaml` | `title` and `description` |
|
|
22
|
-
| `icon.svg` or `icon.png` | the icon in the header and on the tab |
|
|
23
|
-
| `app.css` | the look: the `--qm-*` dials, the surface roots, the app chrome classes and `[data-qm-card="<kind>"]`, linked after the app's own styles |
|
|
24
|
-
|
|
25
|
-
Which forms appear is whatever the quiver holds: every quill in it, at its latest version, drafts only under `--drafts`. A different set of forms is a different quiver.
|
|
26
|
-
|
|
27
|
-
`check` and `build app` refuse an `App.yaml` key the app does not have and warn on an `app.css` selector the theming contract does not promise, so a key or a selector a release moves fails or warns where you build rather than going quiet.
|
|
28
|
-
|
|
29
|
-
### Theme and word the surfaces
|
|
30
|
-
|
|
31
|
-
In a page of your own you mount `<VisualEditor>` and `<Preview>` yourself and reach everything below.
|
|
32
|
-
|
|
33
|
-
| Handle | What it changes |
|
|
34
|
-
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
-
| the ten `--qm-*` dials | colour, type, corner and spacing across both surfaces ([THEMING §"The dials"](THEMING.md#the-dials)) |
|
|
36
|
-
| `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)) |
|
|
37
|
-
| `.qm-editor`, `.qm-preview`, `.qm-pane` | placing and sizing each surface from your own stylesheet; `class` and `style` props land on the same root |
|
|
38
|
-
| `[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)) |
|
|
39
|
-
| `strings`, on each surface | every word it says, keyed and partial, the value-inserting ones included ([README §Wording](README.md#wording)) |
|
|
40
|
-
| `formatDiagnostic` | the text of a validation or edit diagnostic under its field |
|
|
41
|
-
| `enumOptionAllowed`, `enumDisallowed` | which options of an enum a deployment offers, and whether a refused one is hidden or greyed |
|
|
42
|
-
| `fonts`, `fontLabels` | the font families the format popover offers, and the names it shows them by ([README §Fonts](README.md#fonts)) |
|
|
43
|
-
| 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 |
|
|
44
|
-
| `review` | another writer's proposals, drawn where each sits and answered on the page ([README §Review](README.md#review)) |
|
|
45
|
-
|
|
46
|
-
### Write your own shell
|
|
47
|
-
|
|
48
|
-
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 ([README §"A shell on the workspace"](README.md#a-shell-on-the-workspace)). The quillkit app is one such shell.
|
|
49
|
-
|
|
50
|
-
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.
|
|
51
|
-
|
|
52
|
-
## What is closed, and why
|
|
53
|
-
|
|
54
|
-
Closed means no prop, promised class or file reaches it. Each is closed for the reason beside it.
|
|
55
|
-
|
|
56
|
-
| Closed | Why |
|
|
57
|
-
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
-
| 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 |
|
|
59
|
-
| the control drawn for each field type | per-control render slots are declined: they would hand reconciliation to your code |
|
|
60
|
-
| 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`) |
|
|
61
|
-
| 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 |
|
|
62
|
-
| 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 |
|
|
63
|
-
| 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 |
|
|
64
|
-
| image authoring | declined: there is no asset story |
|
|
65
|
-
| touch-first editing | declined: touch is not a target, and neither is an accessory bar |
|
|
66
|
-
| in the quillkit app: where documents are stored | in this browser only, one database per app, and the app says so; a server is a shell's |
|
|
67
|
-
| in the quillkit app: the actions offered | `App.yaml` holds what the app says, not what it does: keys that compose into behaviour are a program, and a program belongs in a real language, the custom shell |
|
|
68
|
-
| in the quillkit app: the layout | where the app puts its parts is its client's; `app.css` restyles the chrome through the promised classes, and anything past them is warned, since a release may re-cut it |
|
|
69
|
-
| in the quillkit app: the version a new document opens on | the latest the quiver holds, at `0.1.0` or above unless built with `--drafts`; a document reopens on the version it was made on and offers an update, so a release never moves a half-filled form under its reader |
|
|
70
|
-
| in the quillkit app: the wording and the language | English and fixed: plain text in `App.yaml` cannot set a string that inserts a value, so a translation there stays part English; a shell sets every string through `strings` |
|
|
71
|
-
|
|
72
|
-
The reasons are recorded with the designs they rejected in [this package's INVARIANTS](prose/INVARIANTS.md) and [quillkit's](../quillkit/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.
|
|
73
|
-
|
|
74
|
-
## When something you need is missing
|
|
75
|
-
|
|
76
|
-
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.
|
|
77
|
-
|
|
78
|
-
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.
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** A print begun on a press, finished once the PDF is in hand. */
|
|
2
|
-
export interface Printing {
|
|
3
|
-
/** Print `pdf`. Returns false where the browser refused every way in. */
|
|
4
|
-
print(pdf: Uint8Array): boolean;
|
|
5
|
-
/** Drop a print that has nothing to print. */
|
|
6
|
-
cancel(): void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Begin a print on the press itself, then hand the PDF to `print` once it is rendered, or call
|
|
10
|
-
* `cancel` where there is none. The tab a fallback prints from is opened here, while the press
|
|
11
|
-
* still counts as one, since a tab opened after the render's await is a popup the browser blocks.
|
|
12
|
-
*/
|
|
13
|
-
export declare function beginPrint(): Printing;
|
package/dist/workspace/print.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Whether this browser prints a PDF from a hidden frame. A browser without an inline PDF
|
|
3
|
-
* viewer (every phone) has nothing to print there, and Safari's frame prints blank or the
|
|
4
|
-
* page around it, so both are handed a tab of the PDF instead, printed from its viewer.
|
|
5
|
-
*/
|
|
6
|
-
function framePrints() {
|
|
7
|
-
if (navigator.pdfViewerEnabled === false)
|
|
8
|
-
return false;
|
|
9
|
-
const ua = navigator.userAgent;
|
|
10
|
-
return !(/AppleWebKit\//.test(ua) && !/(Chrome|Chromium)\//.test(ua));
|
|
11
|
-
}
|
|
12
|
-
/** The frame the last print loaded. A frame's print returns before its viewer is done
|
|
13
|
-
* with the PDF, so a frame stands until the next print replaces it. */
|
|
14
|
-
let frame;
|
|
15
|
-
function blobOf(pdf) {
|
|
16
|
-
// `BlobPart` takes an `ArrayBuffer`-backed view; wasm output is one.
|
|
17
|
-
return URL.createObjectURL(new Blob([pdf], { type: 'application/pdf' }));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Begin a print on the press itself, then hand the PDF to `print` once it is rendered, or call
|
|
21
|
-
* `cancel` where there is none. The tab a fallback prints from is opened here, while the press
|
|
22
|
-
* still counts as one, since a tab opened after the render's await is a popup the browser blocks.
|
|
23
|
-
*/
|
|
24
|
-
export function beginPrint() {
|
|
25
|
-
const tab = framePrints() ? null : window.open('', '_blank');
|
|
26
|
-
const viaTab = (pdf) => {
|
|
27
|
-
const target = tab ?? window.open('', '_blank');
|
|
28
|
-
if (!target)
|
|
29
|
-
return false;
|
|
30
|
-
// Not revoked: the tab's viewer can read the URL again for as long as it stands.
|
|
31
|
-
target.location.href = blobOf(pdf);
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
print(pdf) {
|
|
36
|
-
if (!framePrints())
|
|
37
|
-
return viaTab(pdf);
|
|
38
|
-
if (frame) {
|
|
39
|
-
frame.el.remove();
|
|
40
|
-
URL.revokeObjectURL(frame.url);
|
|
41
|
-
}
|
|
42
|
-
const url = blobOf(pdf);
|
|
43
|
-
const el = document.createElement('iframe');
|
|
44
|
-
el.setAttribute('aria-hidden', 'true');
|
|
45
|
-
el.tabIndex = -1;
|
|
46
|
-
// Laid out and off screen: a frame under `display: none` loads no viewer to print.
|
|
47
|
-
el.style.cssText =
|
|
48
|
-
'position:fixed;inset-inline-start:-10000px;top:0;width:1px;height:1px;border:0';
|
|
49
|
-
el.addEventListener('load', () => {
|
|
50
|
-
try {
|
|
51
|
-
el.contentWindow?.focus();
|
|
52
|
-
el.contentWindow?.print();
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
viaTab(pdf);
|
|
56
|
-
}
|
|
57
|
-
}, { once: true });
|
|
58
|
-
el.src = url;
|
|
59
|
-
document.body.append(el);
|
|
60
|
-
frame = { el, url };
|
|
61
|
-
return true;
|
|
62
|
-
},
|
|
63
|
-
cancel() {
|
|
64
|
-
tab?.close();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|