@quillmark/svelte 0.29.2 → 0.29.3
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 +1 -0
- package/THEMING.md +8 -6
- package/dist/core/bloom.d.ts +3 -2
- package/dist/core/bloom.js +6 -7
- package/dist/core/codec/field.js +2 -4
- package/dist/core/codec/index.d.ts +0 -3
- package/dist/core/codec/inputrules.d.ts +0 -3
- package/dist/core/codec/inputrules.js +1 -1
- package/dist/core/codec/islands.d.ts +0 -10
- package/dist/core/codec/islands.js +1 -1
- package/dist/core/codec/list-move.d.ts +0 -3
- package/dist/core/codec/list-move.js +2 -2
- package/dist/core/codec/list-node.d.ts +2 -0
- package/dist/core/codec/list-node.js +1 -0
- package/dist/core/codec/list-paste.js +1 -1
- package/dist/core/codec/markdown-paste.d.ts +0 -9
- package/dist/core/codec/markdown-paste.js +1 -1
- package/dist/core/codec/nesting.d.ts +0 -4
- package/dist/core/codec/nesting.js +1 -1
- package/dist/core/codec/prose.css +1 -1
- package/dist/core/codec/reveal.d.ts +14 -0
- package/dist/core/codec/reveal.js +40 -0
- package/dist/core/codec/slash.js +0 -0
- package/dist/core/codec/table-view.js +3 -3
- package/dist/core/codec/table.d.ts +0 -6
- package/dist/core/codec/table.js +1 -1
- package/dist/core/codec/touching.d.ts +0 -2
- package/dist/core/codec/touching.js +1 -11
- package/dist/preview/Preview.svelte +20 -1
- package/dist/preview/Preview.svelte.d.ts +1 -0
- package/dist/preview/controller.d.ts +5 -0
- package/dist/preview/controller.js +6 -0
- package/dist/preview/viewport.js +19 -1
- package/dist/preview/wash.d.ts +9 -0
- package/dist/preview/wash.js +38 -0
- package/dist/visual/ArrayField.svelte +17 -114
- package/dist/visual/MatrixField.svelte +15 -19
- package/dist/visual/ObjectField.svelte +10 -13
- package/dist/visual/guidance.d.ts +0 -12
- package/dist/visual/guidance.js +2 -2
- package/dist/visual/props.d.ts +2 -2
- package/dist/visual/rowdrag.svelte.d.ts +21 -0
- package/dist/visual/rowdrag.svelte.js +118 -0
- package/dist/visual/structure.d.ts +6 -6
- package/dist/visual/structure.js +17 -11
- package/package.json +2 -2
- package/dist/visual/checklists.d.ts +0 -3
- package/dist/visual/checklists.js +0 -7
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Each subpath is its own module root; a bundler pulls only what the entry you imp
|
|
|
20
20
|
| `@quillmark/svelte/preview` | The live preview: `createPreview` + `<Preview>`. Reaches nothing editor-side. |
|
|
21
21
|
| `@quillmark/svelte/visual` | The federated WYSIWYG: `<VisualEditor>`, the codec's `createField` prose leaf. |
|
|
22
22
|
| `@quillmark/svelte` | Re-exports `/core`. |
|
|
23
|
+
| `@quillmark/svelte/preset` | The opt-in stylesheet for the page around a surface ([THEMING.md](THEMING.md)). |
|
|
23
24
|
|
|
24
25
|
## Open a session
|
|
25
26
|
|
package/THEMING.md
CHANGED
|
@@ -22,6 +22,8 @@ Nothing to import and nothing to set. The package pulls its own stylesheet, and
|
|
|
22
22
|
|
|
23
23
|
`.qm-pane` is opt-in on the editor rather than the default because the editor is what its own popovers portal into, and a scroll container clips them. In a pane you would have had that clipping from your own scrolling frame anyway; in a page you should not have it at all.
|
|
24
24
|
|
|
25
|
+
**Something drawn over the bottom of the pane**: set `scroll-padding-block-end` on the `.qm-pane` element to the height it covers. A caret revealed in a rich-text field, by typing or by a landing, keeps its line of clearance above that inset, as the browser's own focus scroll does for a form control. `scroll-padding-block-start` does the same at the top.
|
|
26
|
+
|
|
25
27
|
**Placing and sizing**: each surface carries a stable root class (`.qm-editor`, `.qm-preview`), so you can place it from your own stylesheet without a wrapper. Each also takes a `class` prop that merges onto the same element, which is the better handle when you have one to give.
|
|
26
28
|
|
|
27
29
|
A surface's width is the one you give it. Each contains its own inline size, so what a document holds — a table is as wide as its columns — scrolls inside the mount rather than widening the column the mount stands in.
|
|
@@ -145,21 +147,21 @@ It carries a `--qmh-*` scale for the page, derived from the same nine dials and
|
|
|
145
147
|
|
|
146
148
|
An app that mounts an editor beside a preview over one session needs a screen to put them in, and the shape of that screen is the same every time. Five more classes are that shape, so what you write is the wiring rather than the grid:
|
|
147
149
|
|
|
148
|
-
```
|
|
150
|
+
```svelte
|
|
149
151
|
<div class="qm-workspace">
|
|
150
152
|
<header class="qm-bar site-head">
|
|
151
153
|
<span class="site-mark">acme<span class="site-slash">/</span>studio</span>
|
|
152
154
|
</header>
|
|
153
155
|
<div class="site-body">
|
|
154
156
|
<div class="qm-switch" role="group" aria-label="Visible pane">
|
|
155
|
-
<button class="qm-control" aria-pressed=
|
|
156
|
-
|
|
157
|
+
<button class="qm-control" aria-pressed={shown === 1} onclick={() => (shown = 1)}>
|
|
158
|
+
Editor
|
|
157
159
|
</button>
|
|
158
|
-
<button class="qm-control" aria-pressed=
|
|
159
|
-
|
|
160
|
+
<button class="qm-control" aria-pressed={shown === 2} onclick={() => (shown = 2)}>
|
|
161
|
+
Preview
|
|
160
162
|
</button>
|
|
161
163
|
</div>
|
|
162
|
-
<div class="qm-split" data-qm-show=
|
|
164
|
+
<div class="qm-split" data-qm-show={shown}>
|
|
163
165
|
<section class="qm-frame"><!-- <VisualEditor class="qm-pane" /> --></section>
|
|
164
166
|
<section class="qm-frame"><!-- <Preview /> --></section>
|
|
165
167
|
</div>
|
package/dist/core/bloom.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Run one wash over `host`, a `.qm-wash` box, resolving the dwell off its root so the number is
|
|
3
3
|
* single-sourced in CSS (`core/rungs.ts`). `--_qm-bloom-dwell` already shortens under
|
|
4
4
|
* `prefers-reduced-motion`, so `matchMedia` here only picks the frame list. A run in flight on the
|
|
5
|
-
* same host is cancelled first, so two quick landings do not stack alphas.
|
|
5
|
+
* same host is cancelled first, so two quick landings do not stack alphas. Answers the run, or
|
|
6
|
+
* `undefined` where there is no animation to play it.
|
|
6
7
|
*/
|
|
7
|
-
export declare function bloom(host: HTMLElement):
|
|
8
|
+
export declare function bloom(host: HTMLElement): Animation | undefined;
|
package/dist/core/bloom.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Opacity is the animated property, never the colour: the wash's alpha is a peak fixed by
|
|
6
6
|
// `--_qm-accent-wash`, so the scale stays in CSS where `color-mix` resolves. The wash is the host's
|
|
7
7
|
// `::after` (`.qm-wash`, controls.css); this module plays it and adds nothing to the tree.
|
|
8
|
-
import { rungStyle } from './rungs.js';
|
|
8
|
+
import { rungMs, rungStyle } from './rungs.js';
|
|
9
9
|
const WASH = '::after';
|
|
10
10
|
/** The dwell used when the derivation is out of reach (an unstyled root, or jsdom). */
|
|
11
11
|
const FALLBACK_MS = 1100;
|
|
@@ -23,19 +23,18 @@ const FRAMES_REDUCED = [{ opacity: 1 }, { opacity: 1 }];
|
|
|
23
23
|
* Run one wash over `host`, a `.qm-wash` box, resolving the dwell off its root so the number is
|
|
24
24
|
* single-sourced in CSS (`core/rungs.ts`). `--_qm-bloom-dwell` already shortens under
|
|
25
25
|
* `prefers-reduced-motion`, so `matchMedia` here only picks the frame list. A run in flight on the
|
|
26
|
-
* same host is cancelled first, so two quick landings do not stack alphas.
|
|
26
|
+
* same host is cancelled first, so two quick landings do not stack alphas. Answers the run, or
|
|
27
|
+
* `undefined` where there is no animation to play it.
|
|
27
28
|
*/
|
|
28
29
|
export function bloom(host) {
|
|
29
30
|
if (typeof host.animate !== 'function')
|
|
30
|
-
return;
|
|
31
|
+
return undefined;
|
|
31
32
|
for (const a of host.getAnimations({ subtree: true })) {
|
|
32
33
|
const effect = a.effect;
|
|
33
34
|
if (effect?.target === host && effect.pseudoElement === WASH)
|
|
34
35
|
a.cancel();
|
|
35
36
|
}
|
|
36
37
|
const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const duration = !Number.isFinite(n) ? FALLBACK_MS : raw.endsWith('ms') ? n : n * 1000;
|
|
40
|
-
host.animate(reduced ? FRAMES_REDUCED : FRAMES, { duration, pseudoElement: WASH });
|
|
38
|
+
const duration = rungMs(rungStyle(host), '--_qm-bloom-dwell') ?? FALLBACK_MS;
|
|
39
|
+
return host.animate(reduced ? FRAMES_REDUCED : FRAMES, { duration, pseudoElement: WASH });
|
|
41
40
|
}
|
package/dist/core/codec/field.js
CHANGED
|
@@ -14,6 +14,7 @@ import { keymap } from 'prosemirror-keymap';
|
|
|
14
14
|
import { Fragment, Slice } from 'prosemirror-model';
|
|
15
15
|
import { EditorState, NodeSelection, Plugin, PluginKey, Selection, TextSelection } from 'prosemirror-state';
|
|
16
16
|
import { Decoration, DecorationSet, EditorView } from 'prosemirror-view';
|
|
17
|
+
import { revealProps } from './reveal.js';
|
|
17
18
|
import { core } from '../lifecycle.js';
|
|
18
19
|
import { reportError, errorMessage } from '../errors.js';
|
|
19
20
|
import { decode, fitsLeaf } from './decode.js';
|
|
@@ -175,10 +176,7 @@ export function createField(opts) {
|
|
|
175
176
|
state,
|
|
176
177
|
editable: () => !held,
|
|
177
178
|
attributes: () => (held ? heldNamed : defaulted ? defaultNamed : named),
|
|
178
|
-
|
|
179
|
-
// (`scrollThreshold`) and what it leaves at the edge (`scrollMargin`).
|
|
180
|
-
scrollThreshold: clearance,
|
|
181
|
-
scrollMargin: clearance,
|
|
179
|
+
...revealProps(clearance),
|
|
182
180
|
// Islands are block-schema only, so any other leaf mounts no node view at all.
|
|
183
181
|
nodeViews: block
|
|
184
182
|
? {
|
|
@@ -13,11 +13,8 @@ export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, ha
|
|
|
13
13
|
export { rendersHref, storableUrl } from './urls.js';
|
|
14
14
|
export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
|
|
15
15
|
export { pmToContent, contentEdit, lower } from './encode.js';
|
|
16
|
-
export type { ContentEdit } from './encode.js';
|
|
17
16
|
export { usvToPM, pmToUsv, buildLineIndex } from './positions.js';
|
|
18
|
-
export type { LineIndex } from './positions.js';
|
|
19
17
|
export { createReconciler, contentEqual, valueEqual } from './reconcile.js';
|
|
20
|
-
export type { Reconciler } from './reconcile.js';
|
|
21
18
|
export { inputRulesPlugin } from './inputrules.js';
|
|
22
19
|
export { bodyKeymap } from './keymap.js';
|
|
23
20
|
export { listKeymap } from './lists.js';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { InputRule } from 'prosemirror-inputrules';
|
|
2
1
|
import type { Schema } from 'prosemirror-model';
|
|
3
2
|
import type { Plugin } from 'prosemirror-state';
|
|
4
|
-
/** The full markdown-shorthand rule set for a block schema. */
|
|
5
|
-
export declare function markdownInputRules(schema: Schema): InputRule[];
|
|
6
3
|
/** The input-rules plugin the field mounts by default (opt-out via createField). */
|
|
7
4
|
export declare function inputRulesPlugin(schema: Schema): Plugin;
|
|
8
5
|
/** Backspace on the press right after a rule fired takes the rule back and leaves the
|
|
@@ -77,7 +77,7 @@ function blockRule(regexp, command) {
|
|
|
77
77
|
return new InputRule(regexp, (state, match, start, end) => consuming(state, start, end, command(match))?.tr.scrollIntoView() ?? null);
|
|
78
78
|
}
|
|
79
79
|
/** The full markdown-shorthand rule set for a block schema. */
|
|
80
|
-
|
|
80
|
+
function markdownInputRules(schema) {
|
|
81
81
|
const rules = [];
|
|
82
82
|
const m = schema.marks;
|
|
83
83
|
// Inline marks. Non-greedy capture between matching delimiters. Built only where the
|
|
@@ -33,16 +33,6 @@ export declare function islandEntryFromNode(attrs: IslandNodeAttrs): ContentIsla
|
|
|
33
33
|
* placeholder for `undefined` (`table-view.ts` §`render`).
|
|
34
34
|
*/
|
|
35
35
|
export declare function tablePropsOfNode(node: PMNode): TableProps | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* A minter over one document: the positional `isl-{n}` sequence continued past the highest id the
|
|
38
|
-
* field holds, so a caller placing several islands keeps one minter. A minted id is part of the
|
|
39
|
-
* document's canonical bytes (CODEC §Islands): a counter over the projection in hand, never a UUID
|
|
40
|
-
* or clock reading, and never a re-numbering of existing ids.
|
|
41
|
-
*
|
|
42
|
-
* Reads the PM doc rather than stored content because that is what the caller holds and the commit
|
|
43
|
-
* will project; a stale content could collide with an id the same transaction places.
|
|
44
|
-
*/
|
|
45
|
-
export declare function islandMinter(doc: PMNode): () => string;
|
|
46
36
|
/** The next island id for a field: one draw from {@link islandMinter}. */
|
|
47
37
|
export declare function mintIslandId(doc: PMNode): string;
|
|
48
38
|
/**
|
|
@@ -161,7 +161,7 @@ export function tablePropsOfNode(node) {
|
|
|
161
161
|
* Reads the PM doc rather than stored content because that is what the caller holds and the commit
|
|
162
162
|
* will project; a stale content could collide with an id the same transaction places.
|
|
163
163
|
*/
|
|
164
|
-
|
|
164
|
+
function islandMinter(doc) {
|
|
165
165
|
return islandState(doc).mint;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { Schema } from 'prosemirror-model';
|
|
2
2
|
import type { Command } from 'prosemirror-state';
|
|
3
|
-
/** The items the selection stands in, in the innermost list holding all of them, moved
|
|
4
|
-
* one place up (`-1`) or down (`1`). */
|
|
5
|
-
export declare function moveItems(dir: -1 | 1): Command;
|
|
6
3
|
export declare function listMoveKeymap(schema: Schema): Record<string, Command>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { isList } from './list-node.js';
|
|
2
2
|
/** The items the selection stands in, in the innermost list holding all of them, moved
|
|
3
3
|
* one place up (`-1`) or down (`1`). */
|
|
4
|
-
|
|
4
|
+
function moveItems(dir) {
|
|
5
5
|
return (state, dispatch) => {
|
|
6
6
|
const { $from, $to } = state.selection;
|
|
7
7
|
const range = $from.blockRange($to, isList);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isList = (node) => !!node && (node.type.name === 'ordered_list' || node.type.name === 'bullet_list');
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// out of, and paragraphs pasted into a numbered line are numbered lines.
|
|
12
12
|
import { Fragment, Slice } from 'prosemirror-model';
|
|
13
13
|
import { Plugin, Selection } from 'prosemirror-state';
|
|
14
|
-
|
|
14
|
+
import { isList } from './list-node.js';
|
|
15
15
|
/** The one list a slice is, if it is one: whole, or open where a run of its items was
|
|
16
16
|
* copied. */
|
|
17
17
|
function soleList(slice) {
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
|
-
/**
|
|
3
|
-
* `text` with every item line spelled as markdown, where some line marks its item as
|
|
4
|
-
* markdown does not; otherwise `text` as it stands. A line's level is the open one of its
|
|
5
|
-
* kind at its indent, give or take a column, the levels below it closing; a marker no open
|
|
6
|
-
* level holds opens one beneath the deepest. Markdown nests by indent alone, so each line
|
|
7
|
-
* is indented past the markers of the levels above it. A letter's ordinal is its place in
|
|
8
|
-
* the alphabet. Lines in a fence and lines opening no item stand as they are.
|
|
9
|
-
*/
|
|
10
|
-
export declare function plainTextList(text: string): string;
|
|
11
2
|
/**
|
|
12
3
|
* A block leaf's markdown paste, consulted after the table paste: ProseMirror hands text
|
|
13
4
|
* over only where the clipboard holds no HTML, whose DOM parse reads the source's own
|
|
@@ -40,7 +40,7 @@ const BLOCK_HEAD = new RegExp([
|
|
|
40
40
|
* is indented past the markers of the levels above it. A letter's ordinal is its place in
|
|
41
41
|
* the alphabet. Lines in a fence and lines opening no item stand as they are.
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
function plainTextList(text) {
|
|
44
44
|
if (!LOOSE_ITEM.test(text))
|
|
45
45
|
return text;
|
|
46
46
|
const levels = [];
|
|
@@ -3,10 +3,6 @@ import { Plugin, type Transaction } from 'prosemirror-state';
|
|
|
3
3
|
/** The store's bound on the containers around one line: a commit nesting past it is
|
|
4
4
|
* refused, and `@quillmark/wasm` exports no constant to read it from. */
|
|
5
5
|
export declare const MAX_NESTING_DEPTH = 12;
|
|
6
|
-
/** The most containers any block in `doc` stands inside, counted as the store counts
|
|
7
|
-
* them: a `list_item` or a `blockquote` is one, the list around an item none, and no
|
|
8
|
-
* node holds an element (`decode.ts`). */
|
|
9
|
-
export declare function nestingDepth(doc: PMNode): number;
|
|
10
6
|
/** Whether `doc` nests within {@link MAX_NESTING_DEPTH}: what a command that nests asks
|
|
11
7
|
* of the doc it would dispatch. */
|
|
12
8
|
export declare function withinNesting(doc: PMNode): boolean;
|
|
@@ -7,7 +7,7 @@ export const MAX_NESTING_DEPTH = 12;
|
|
|
7
7
|
/** The most containers any block in `doc` stands inside, counted as the store counts
|
|
8
8
|
* them: a `list_item` or a `blockquote` is one, the list around an item none, and no
|
|
9
9
|
* node holds an element (`decode.ts`). */
|
|
10
|
-
|
|
10
|
+
function nestingDepth(doc) {
|
|
11
11
|
const walk = (node, depth) => {
|
|
12
12
|
let deepest = depth;
|
|
13
13
|
node.forEach((child) => {
|
|
@@ -68,7 +68,7 @@ li.ProseMirror-selectednode::after {
|
|
|
68
68
|
blank line that doubles the leading and makes a short document read as a list of
|
|
69
69
|
fragments. */
|
|
70
70
|
.ProseMirror > * + *,
|
|
71
|
-
.ProseMirror
|
|
71
|
+
.ProseMirror blockquote > * + * {
|
|
72
72
|
margin-top: var(--_qm-space-3);
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorView } from 'prosemirror-view';
|
|
2
|
+
type Sides = {
|
|
3
|
+
top: number;
|
|
4
|
+
right: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
left: number;
|
|
7
|
+
};
|
|
8
|
+
export interface RevealProps {
|
|
9
|
+
scrollThreshold: Sides;
|
|
10
|
+
scrollMargin: Sides;
|
|
11
|
+
handleScrollToSelection: (view: EditorView) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function revealProps(clearance: number | undefined): RevealProps;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function padding(value, extent) {
|
|
2
|
+
const n = Number.parseFloat(value);
|
|
3
|
+
if (!Number.isFinite(n))
|
|
4
|
+
return 0;
|
|
5
|
+
return value.endsWith('%') ? (n / 100) * extent : n;
|
|
6
|
+
}
|
|
7
|
+
function scrollInset(dom) {
|
|
8
|
+
const inset = { top: 0, bottom: 0 };
|
|
9
|
+
const view = dom.ownerDocument.defaultView;
|
|
10
|
+
if (!view)
|
|
11
|
+
return inset;
|
|
12
|
+
for (let el = dom.parentElement; el; el = el.parentElement) {
|
|
13
|
+
const style = view.getComputedStyle(el);
|
|
14
|
+
const extent = el === dom.ownerDocument.documentElement ? view.innerHeight : el.clientHeight;
|
|
15
|
+
inset.top = Math.max(inset.top, padding(style.scrollPaddingTop, extent));
|
|
16
|
+
inset.bottom = Math.max(inset.bottom, padding(style.scrollPaddingBottom, extent));
|
|
17
|
+
}
|
|
18
|
+
return inset;
|
|
19
|
+
}
|
|
20
|
+
export function revealProps(clearance) {
|
|
21
|
+
let inset = { top: 0, bottom: 0 };
|
|
22
|
+
const sides = (base) => ({
|
|
23
|
+
get top() {
|
|
24
|
+
return base + inset.top;
|
|
25
|
+
},
|
|
26
|
+
right: base,
|
|
27
|
+
get bottom() {
|
|
28
|
+
return base + inset.bottom;
|
|
29
|
+
},
|
|
30
|
+
left: base
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
scrollThreshold: sides(clearance ?? 0),
|
|
34
|
+
scrollMargin: sides(clearance ?? 5),
|
|
35
|
+
handleScrollToSelection: (view) => {
|
|
36
|
+
inset = scrollInset(view.dom);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
package/dist/core/codec/slash.js
CHANGED
|
Binary file
|
|
@@ -21,6 +21,7 @@ import { tablePropsOfNode } from './islands.js';
|
|
|
21
21
|
import { tableElement, tableText } from './table-copy.js';
|
|
22
22
|
import { breakKeymap } from './breaks.js';
|
|
23
23
|
import { cellSchema } from './schema.js';
|
|
24
|
+
import { revealProps } from './reveal.js';
|
|
24
25
|
import { ALIGNS, canMerge, cellAt, closeBlock, cellContent, cellEqual, cellFromDoc, clearCells, columnCount, deleteColumn, deleteRow, insertColumn, insertRow, mergeCells, moveColumn, moveRow, normalizeTable, rowCells, rowCount, rowEmpty, setAlign, setHead, headRows, columnShares, setWidths, shapeEqual, spanGrid, splitCell, withCell } from './table.js';
|
|
25
26
|
/**
|
|
26
27
|
* The package's English for the island chrome. It lives beside the surface that draws it so a
|
|
@@ -1327,9 +1328,8 @@ class TableIslandView {
|
|
|
1327
1328
|
}),
|
|
1328
1329
|
attributes: { 'aria-label': name, class: 'qm-table-cell-editor' },
|
|
1329
1330
|
// A cell is one of the leaf's lines, so a reveal keeps the leaf's clearance, not PM's
|
|
1330
|
-
// 5px default (`
|
|
1331
|
-
|
|
1332
|
-
scrollMargin: this.deps.clearance,
|
|
1331
|
+
// 5px default, and the same scroll padding (`reveal.ts`).
|
|
1332
|
+
...revealProps(this.deps.clearance),
|
|
1333
1333
|
dispatchTransaction: (tr) => {
|
|
1334
1334
|
const from = { r, c, head: view.state.selection.head };
|
|
1335
1335
|
const next = view.state.apply(tr);
|
|
@@ -48,12 +48,6 @@ export declare function anchorAt(grid: (Span | null)[][], r: number, c: number):
|
|
|
48
48
|
c: number;
|
|
49
49
|
span: Span;
|
|
50
50
|
};
|
|
51
|
-
/**
|
|
52
|
-
* The rows as one list, header first: the space a row op works in, so move and delete treat every
|
|
53
|
-
* row alike. `header` is a separate field because a table always has one; {@link fromRows} splits
|
|
54
|
-
* it back.
|
|
55
|
-
*/
|
|
56
|
-
export declare function allRows(props: TableProps): TableCell[][];
|
|
57
51
|
/** A fresh table: a header plus `bodyRows` empty rows, every column unaligned. */
|
|
58
52
|
export declare function newTable(cols?: number, bodyRows?: number): TableProps;
|
|
59
53
|
/** `props` with the cell at `(r, c)` replaced. */
|
package/dist/core/codec/table.js
CHANGED
|
@@ -163,7 +163,7 @@ function respan(rows, r, c, span) {
|
|
|
163
163
|
* row alike. `header` is a separate field because a table always has one; {@link fromRows} splits
|
|
164
164
|
* it back.
|
|
165
165
|
*/
|
|
166
|
-
|
|
166
|
+
function allRows(props) {
|
|
167
167
|
return [props.header, ...props.rows];
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
@@ -5,8 +5,6 @@ export declare function touching(doc: PMNode, pos: number): boolean;
|
|
|
5
5
|
/** Join the two lists of one kind meeting at `pos`, the first's `start` counting for
|
|
6
6
|
* both. */
|
|
7
7
|
export declare function joinLists(tr: Transaction, pos: number): boolean;
|
|
8
|
-
/** Join the list at `pos` to a list of its kind touching it on either side. */
|
|
9
|
-
export declare function joinAround(tr: Transaction, pos: number): void;
|
|
10
8
|
/** Join at every seam of `seams` that two lists of one kind meet at, the last first so
|
|
11
9
|
* each join leaves the positions before it standing. */
|
|
12
10
|
export declare function joinAll(tr: Transaction, seams: Iterable<number>): void;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { canJoin } from 'prosemirror-transform';
|
|
2
|
-
|
|
3
|
-
return node.firstChild?.type === node.type.schema.nodes.list_item;
|
|
4
|
-
}
|
|
2
|
+
import { isList } from './list-node.js';
|
|
5
3
|
/** Whether two lists of one kind meet at `pos`. */
|
|
6
4
|
export function touching(doc, pos) {
|
|
7
5
|
const $pos = doc.resolve(pos);
|
|
@@ -17,14 +15,6 @@ export function joinLists(tr, pos) {
|
|
|
17
15
|
tr.join(pos);
|
|
18
16
|
return true;
|
|
19
17
|
}
|
|
20
|
-
/** Join the list at `pos` to a list of its kind touching it on either side. */
|
|
21
|
-
export function joinAround(tr, pos) {
|
|
22
|
-
const node = tr.doc.nodeAt(pos);
|
|
23
|
-
if (!node)
|
|
24
|
-
return;
|
|
25
|
-
joinLists(tr, pos + node.nodeSize);
|
|
26
|
-
joinLists(tr, pos);
|
|
27
|
-
}
|
|
28
18
|
/** Join at every seam of `seams` that two lists of one kind meet at, the last first so
|
|
29
19
|
* each join leaves the positions before it standing. */
|
|
30
20
|
export function joinAll(tr, seams) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
container div on mount and tears it down on unmount. No logic beyond wiring;
|
|
4
4
|
paint.ts/bridge.ts/controller.ts own the behavior. Exposes the
|
|
5
5
|
`PreviewController` verbs as instance methods (`bind:this`) for a consumer
|
|
6
|
-
that drives `refresh`/`scrollToField`/`focusPosition`/`endFollow`/`setZoom`
|
|
6
|
+
that drives `refresh`/`scrollToField`/`focusPosition`/`washField`/`endFollow`/`setZoom`
|
|
7
7
|
imperatively (e.g. after `session.apply` elsewhere).
|
|
8
8
|
-->
|
|
9
9
|
<script lang="ts">
|
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
export function focusPosition(at: Place): void {
|
|
74
74
|
controller?.focusPosition(at);
|
|
75
75
|
}
|
|
76
|
+
/** `false` when this compile places nothing at `field` ({@link PreviewController}). */
|
|
77
|
+
export function washField(field: DocPath): boolean {
|
|
78
|
+
return controller?.washField(field) ?? false;
|
|
79
|
+
}
|
|
76
80
|
/** The follow ends on a focus change ({@link PreviewController}), and the editor's
|
|
77
81
|
* own signal is one: `onActiveLeafChange={preview.endFollow}`. */
|
|
78
82
|
export function endFollow(): void {
|
|
@@ -126,6 +130,21 @@
|
|
|
126
130
|
background: var(--_qm-surface-sunken);
|
|
127
131
|
}
|
|
128
132
|
|
|
133
|
+
/* The arrival wash on the page (`wash.ts`): a plane at a field's box, its tone the editor's,
|
|
134
|
+
reaching a hair past the ink's tight box and rounded, as a control's wash is a box's own. Over
|
|
135
|
+
the canvas by tree order, the canvas being a slot's first child. */
|
|
136
|
+
:global(:where(.qm-preview-wash)) {
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
}
|
|
139
|
+
:global(:where(.qm-preview-wash))::after {
|
|
140
|
+
content: '';
|
|
141
|
+
position: absolute;
|
|
142
|
+
inset: calc(-1 * var(--_qm-space-half));
|
|
143
|
+
border-radius: var(--_qm-radius-inner);
|
|
144
|
+
background: var(--_qm-accent-wash);
|
|
145
|
+
opacity: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
129
148
|
/* Sticky to the pane's bottom edge and stretched across it, so the pill's corner is
|
|
130
149
|
the pane's however the pages scroll; zero height, so it displaces nothing. */
|
|
131
150
|
:global(:where(.qm-preview-dock)) {
|
|
@@ -32,6 +32,7 @@ declare const Preview: import("svelte").Component<Props, {
|
|
|
32
32
|
refresh: (change: ChangeSet) => void;
|
|
33
33
|
scrollToField: (field: DocPath) => boolean;
|
|
34
34
|
focusPosition: (at: Place) => void;
|
|
35
|
+
washField: (field: DocPath) => boolean;
|
|
35
36
|
endFollow: () => void;
|
|
36
37
|
setZoom: (zoom: number | undefined) => void;
|
|
37
38
|
}, "">;
|
|
@@ -36,6 +36,11 @@ export interface PreviewController {
|
|
|
36
36
|
* Takes the editor's `onCaretMove` payload, so `onCaretMove={preview.focusPosition}` wires it.
|
|
37
37
|
*/
|
|
38
38
|
focusPosition(at: Place): void;
|
|
39
|
+
/**
|
|
40
|
+
* Play the arrival wash over every box this compile places at `field`, and move nothing: no
|
|
41
|
+
* scroll, and the follow stands. `false` when this compile places nothing at that address.
|
|
42
|
+
*/
|
|
43
|
+
washField(field: DocPath): boolean;
|
|
39
44
|
/**
|
|
40
45
|
* End the follow: the pane stays where the user left it until the next `focusPosition`. Wire
|
|
41
46
|
* `onActiveLeafChange={preview.endFollow}`; a form control reports no caret, so unwired the
|
|
@@ -2,6 +2,7 @@ import { reportError, errorMessage } from '../core/errors.js';
|
|
|
2
2
|
import { createPaintLoop } from './paint.js';
|
|
3
3
|
import { createBridge } from './bridge.js';
|
|
4
4
|
import { createViewport } from './viewport.js';
|
|
5
|
+
import { cutWashes, washField } from './wash.js';
|
|
5
6
|
import { mergePreviewStrings } from './strings.js';
|
|
6
7
|
const CONTAINER_CLASS = 'qm-preview';
|
|
7
8
|
const MESSAGE_CLASS = 'qm-preview-message';
|
|
@@ -77,6 +78,8 @@ export function createPreview(session, opts) {
|
|
|
77
78
|
let followed;
|
|
78
79
|
return {
|
|
79
80
|
refresh(change) {
|
|
81
|
+
// A plane is laid at the layout it washed; a recompile may have moved the ink under it.
|
|
82
|
+
cutWashes(paintLoop.slots);
|
|
80
83
|
render(change.pageCount, change.dirtyPages);
|
|
81
84
|
viewport.update();
|
|
82
85
|
if (followed)
|
|
@@ -94,6 +97,9 @@ export function createPreview(session, opts) {
|
|
|
94
97
|
followed = at;
|
|
95
98
|
bridge?.focusPosition(at.field, at.pos);
|
|
96
99
|
},
|
|
100
|
+
washField(field) {
|
|
101
|
+
return washField(session, paintLoop.slots, field);
|
|
102
|
+
},
|
|
97
103
|
endFollow() {
|
|
98
104
|
followed = undefined;
|
|
99
105
|
},
|
package/dist/preview/viewport.js
CHANGED
|
@@ -155,12 +155,30 @@ export function createViewport(container, slots, setScale, resetLabel) {
|
|
|
155
155
|
// `deltaY = -100 ln(scale)`, in deltas smaller than a notch's: those track the fingers.
|
|
156
156
|
function onWheel(e) {
|
|
157
157
|
if (!(e.ctrlKey || e.metaKey))
|
|
158
|
-
return;
|
|
158
|
+
return pan(e);
|
|
159
159
|
e.preventDefault();
|
|
160
160
|
const pinched = e.deltaMode === 0 && Math.abs(e.deltaY) < PINCH_DELTA;
|
|
161
161
|
const factor = Math.exp(-e.deltaY * (pinched ? PINCH_RATE : WHEEL_RATE[e.deltaMode]));
|
|
162
162
|
glideTo((g) => g.raw * factor, e.clientX, e.clientY);
|
|
163
163
|
}
|
|
164
|
+
// A trackpad pan over pages that overflow both ways, scrolled here: on macOS the
|
|
165
|
+
// browser rails a scroll not near enough a diagonal to the axis it leans on, which
|
|
166
|
+
// over a zoomed page is the wrong axis as often as not. A delta on one axis is left
|
|
167
|
+
// to the browser, so a mouse wheel keeps its smooth notch, and one at an edge
|
|
168
|
+
// chains on.
|
|
169
|
+
function pan(e) {
|
|
170
|
+
if (e.deltaMode !== 0 || !e.deltaX || !e.deltaY)
|
|
171
|
+
return;
|
|
172
|
+
const { scrollWidth, scrollHeight, clientWidth, clientHeight } = container;
|
|
173
|
+
if (scrollWidth <= clientWidth || scrollHeight <= clientHeight)
|
|
174
|
+
return;
|
|
175
|
+
const { scrollLeft, scrollTop } = container;
|
|
176
|
+
container.scrollLeft += e.deltaX;
|
|
177
|
+
container.scrollTop += e.deltaY;
|
|
178
|
+
if (container.scrollLeft !== scrollLeft || container.scrollTop !== scrollTop) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
164
182
|
// The keys are the focused pane's alone: elsewhere they are the browser's own zoom,
|
|
165
183
|
// the pointer over the pane notwithstanding. A key a host's own handler took is left
|
|
166
184
|
// to it.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LiveSession } from '@quillmark/wasm';
|
|
2
|
+
import type { PageSlot } from './paint.js';
|
|
3
|
+
/** Cut every plane still playing on `field`, or on any field when `field` is unset. */
|
|
4
|
+
export declare function cutWashes(slots: readonly PageSlot[], field?: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Wash every box this compile places at `field`; `false` when it places none. A wash still playing
|
|
7
|
+
* on the same address is cut first, so two quick washes do not stack alphas.
|
|
8
|
+
*/
|
|
9
|
+
export declare function washField(session: LiveSession, slots: readonly PageSlot[], field: string): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { bloom } from '../core/bloom.js';
|
|
2
|
+
import { applyPercentRect, boxesForField, rectToPercent } from './geometry.js';
|
|
3
|
+
const WASH_CLASS = 'qm-preview-wash';
|
|
4
|
+
/** Cut every plane still playing on `field`, or on any field when `field` is unset. */
|
|
5
|
+
export function cutWashes(slots, field) {
|
|
6
|
+
for (const { el } of slots) {
|
|
7
|
+
for (const plane of el.querySelectorAll(`.${WASH_CLASS}`)) {
|
|
8
|
+
if (field === undefined || plane.dataset.field === field)
|
|
9
|
+
plane.remove();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wash every box this compile places at `field`; `false` when it places none. A wash still playing
|
|
15
|
+
* on the same address is cut first, so two quick washes do not stack alphas.
|
|
16
|
+
*/
|
|
17
|
+
export function washField(session, slots, field) {
|
|
18
|
+
const boxes = boxesForField(field, session.fieldBoxes(field), () => session.regions());
|
|
19
|
+
cutWashes(slots, field);
|
|
20
|
+
let placed = false;
|
|
21
|
+
for (const box of boxes) {
|
|
22
|
+
const slot = slots[box.page];
|
|
23
|
+
if (!slot)
|
|
24
|
+
continue;
|
|
25
|
+
placed = true;
|
|
26
|
+
const plane = document.createElement('div');
|
|
27
|
+
plane.className = WASH_CLASS;
|
|
28
|
+
plane.dataset.field = field;
|
|
29
|
+
applyPercentRect(plane, rectToPercent(box.rect, slot.size));
|
|
30
|
+
slot.el.appendChild(plane);
|
|
31
|
+
const run = bloom(plane);
|
|
32
|
+
if (run)
|
|
33
|
+
run.onfinish = run.oncancel = () => plane.remove();
|
|
34
|
+
else
|
|
35
|
+
plane.remove();
|
|
36
|
+
}
|
|
37
|
+
return placed;
|
|
38
|
+
}
|