@quillmark/svelte 0.26.2 → 0.28.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/NOTICE +4 -4
- package/README.md +26 -8
- package/THEMING.md +40 -4
- package/dist/core/address.d.ts +35 -64
- package/dist/core/address.js +35 -55
- package/dist/core/bloom.d.ts +4 -10
- package/dist/core/bloom.js +14 -27
- package/dist/core/codec/blocks.d.ts +41 -43
- package/dist/core/codec/blocks.js +97 -130
- package/dist/core/codec/code.d.ts +7 -10
- package/dist/core/codec/code.js +37 -46
- package/dist/core/codec/decode.d.ts +19 -23
- package/dist/core/codec/decode.js +76 -111
- package/dist/core/codec/encode.d.ts +11 -15
- package/dist/core/codec/encode.js +60 -67
- package/dist/core/codec/field.d.ts +62 -95
- package/dist/core/codec/field.js +107 -179
- package/dist/core/codec/islands.d.ts +33 -41
- package/dist/core/codec/islands.js +76 -86
- package/dist/core/codec/lists.d.ts +17 -26
- package/dist/core/codec/lists.js +117 -157
- package/dist/core/codec/marks.d.ts +4 -3
- package/dist/core/codec/marks.js +8 -3
- package/dist/core/codec/prose.css +84 -46
- package/dist/core/codec/schema.d.ts +18 -23
- package/dist/core/codec/schema.js +84 -76
- package/dist/core/codec/slash.d.ts +42 -48
- package/dist/core/codec/slash.js +0 -0
- package/dist/core/codec/table-copy.d.ts +4 -3
- package/dist/core/codec/table-copy.js +25 -7
- package/dist/core/codec/table-view.d.ts +12 -12
- package/dist/core/codec/table-view.js +460 -383
- package/dist/core/codec/table.d.ts +94 -61
- package/dist/core/codec/table.js +331 -83
- package/dist/core/codec/tasks.d.ts +6 -0
- package/dist/core/codec/tasks.js +30 -3
- package/dist/core/errors.d.ts +15 -30
- package/dist/core/errors.js +2 -6
- package/dist/core/index.js +7 -12
- package/dist/core/lifecycle.d.ts +7 -16
- package/dist/core/lifecycle.js +10 -21
- package/dist/core/rebind.svelte.d.ts +10 -20
- package/dist/core/rebind.svelte.js +15 -27
- package/dist/core/rungs.d.ts +14 -11
- package/dist/core/rungs.js +17 -19
- package/dist/core/teardown.d.ts +4 -6
- package/dist/core/teardown.js +7 -10
- package/dist/core/theme.css +74 -54
- package/dist/index.js +3 -8
- package/dist/preset/app.css +71 -0
- package/dist/preset/index.css +8 -7
- package/dist/preset/recipes.css +19 -164
- package/dist/preset/scale.css +28 -18
- package/dist/preset/shell.css +157 -0
- package/dist/preview/Preview.svelte +8 -0
- package/dist/preview/bridge.d.ts +18 -22
- package/dist/preview/bridge.js +29 -58
- package/dist/preview/controller.d.ts +21 -29
- package/dist/preview/controller.js +14 -39
- package/dist/preview/geometry.d.ts +13 -34
- package/dist/preview/geometry.js +13 -34
- package/dist/preview/index.js +4 -16
- package/dist/preview/paint.d.ts +3 -3
- package/dist/preview/paint.js +28 -68
- package/dist/preview/strings.d.ts +1 -1
- package/dist/preview/strings.js +2 -14
- package/dist/preview/viewport.js +20 -15
- package/dist/preview/zoom.d.ts +21 -22
- package/dist/preview/zoom.js +53 -30
- package/dist/visual/ArrayField.svelte +77 -16
- package/dist/visual/BooleanField.svelte +28 -15
- package/dist/visual/Card.svelte +66 -51
- package/dist/visual/CardControls.svelte +5 -11
- package/dist/visual/DateField.svelte +20 -4
- package/dist/visual/EnumField.svelte +3 -0
- package/dist/visual/FieldHint.svelte +2 -1
- package/dist/visual/FormatPopover.svelte +82 -15
- package/dist/visual/FormatPopover.svelte.d.ts +4 -0
- package/dist/visual/MatrixAdd.svelte +30 -12
- package/dist/visual/MatrixField.svelte +24 -16
- package/dist/visual/NumberField.svelte +7 -0
- package/dist/visual/ObjectField.svelte +4 -4
- package/dist/visual/ProseField.svelte +0 -5
- package/dist/visual/TipsCard.svelte +11 -10
- package/dist/visual/VariantField.svelte +3 -1
- package/dist/visual/VisualEditorInner.svelte +19 -3
- package/dist/visual/controls.css +7 -2
- package/dist/visual/fonts.d.ts +18 -0
- package/dist/visual/fonts.js +59 -0
- package/dist/visual/icons/nodes.d.ts +0 -5
- package/dist/visual/icons/nodes.js +0 -4
- package/dist/visual/props.d.ts +14 -1
- package/dist/visual/strings.d.ts +7 -0
- package/dist/visual/strings.js +5 -2
- package/dist/visual/structure.d.ts +43 -87
- package/dist/visual/structure.js +42 -83
- package/package.json +2 -2
|
@@ -1,83 +1,77 @@
|
|
|
1
1
|
import { EditorState, Plugin, type Command } from 'prosemirror-state';
|
|
2
2
|
import { type EditorView } from 'prosemirror-view';
|
|
3
3
|
import { type RangeAnchor } from './anchor.js';
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
* the last match narrow back into one. */
|
|
4
|
+
/**
|
|
5
|
+
* The menu as the chrome sees it: the command names the query matched, the keyboard's cursor, and
|
|
6
|
+
* the trigger's anchor to hang off. `undefined` is a closed menu. An empty `items` is a live
|
|
7
|
+
* trigger with nothing to offer, drawn as nothing: the run is the shape of the text and the menu
|
|
8
|
+
* the shape of the match, so a query typed past the last match can narrow back into one.
|
|
9
|
+
*/
|
|
11
10
|
export interface SlashState {
|
|
12
11
|
items: string[];
|
|
13
12
|
index: number;
|
|
14
13
|
query: string;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
14
|
+
/**
|
|
15
|
+
* The trigger's caret to hang off, live rather than measured (`anchor.ts`): an open menu
|
|
16
|
+
* outlives any one scroll position.
|
|
17
|
+
*/
|
|
17
18
|
anchor: RangeAnchor;
|
|
18
19
|
}
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
20
|
+
/**
|
|
21
|
+
* The menu's wording: its accessible name and the empty line's hint. Offers are command names,
|
|
22
|
+
* which are not translated.
|
|
23
|
+
*/
|
|
21
24
|
export interface SlashStrings {
|
|
22
25
|
slashLabel: string;
|
|
23
|
-
/** Drawn on the empty line a focused caret holds, naming the key that opens the
|
|
24
|
-
* menu there. */
|
|
26
|
+
/** Drawn on the empty line a focused caret holds, naming the key that opens the menu. */
|
|
25
27
|
slashHint: string;
|
|
26
28
|
}
|
|
27
|
-
/** The package's English, beside the surface that draws it
|
|
28
|
-
* chrome's wording follows, and the visual `strings` set extends both. */
|
|
29
|
+
/** The package's English, beside the surface that draws it; the visual `strings` set extends it. */
|
|
29
30
|
export declare const DEFAULT_SLASH_STRINGS: SlashStrings;
|
|
30
31
|
/**
|
|
31
|
-
* The vocabulary a caret can run, in menu order
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* moves: the lists and the island alone mid-paragraph, and at an item's head only the
|
|
36
|
-
* list of the other kind, which retypes the item's list.
|
|
32
|
+
* The vocabulary a caret can run, in menu order, each name asked whether it would fire here: a row
|
|
33
|
+
* that declines when picked is worse than an absent one, and asking the command keeps the menu from
|
|
34
|
+
* drifting off what a pick does. So the offers narrow as the caret moves (the lists and the island
|
|
35
|
+
* alone mid-paragraph; at an item's head only the list of the other kind).
|
|
37
36
|
*
|
|
38
|
-
* `state` is the state a pick leaves behind
|
|
39
|
-
* the caret every command answers for (`blocks.ts`).
|
|
37
|
+
* `state` is the state a pick leaves behind, the run already consumed (`blocks.ts`).
|
|
40
38
|
*/
|
|
41
39
|
export declare function slashItems(state: EditorState): string[];
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The query filter: a case-insensitive prefix of the name or of any of its words, so `/list` offers
|
|
42
|
+
* both lists. A prefix and not a substring (`note` is inside `footnote` and completes nothing). An
|
|
43
|
+
* empty query offers everything in the vocabulary's order.
|
|
44
|
+
*/
|
|
47
45
|
export declare function filterItems(items: string[], query: string): string[];
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
46
|
+
/**
|
|
47
|
+
* The live trigger: where the `/` sits, what has been typed after it, and which offer the keyboard
|
|
48
|
+
* is on.
|
|
49
|
+
*/
|
|
50
50
|
interface SlashRun {
|
|
51
51
|
from: number;
|
|
52
52
|
query: string;
|
|
53
53
|
index: number;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* The trigger plugin. It holds the run in PM state, so
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* text; only a pick does, and it consumes exactly the run.
|
|
56
|
+
* The trigger plugin. It holds the run in PM state, so a caret move out of it, an undo or a
|
|
57
|
+
* re-hydrate fail the recompute and close the menu without a listener. A dismissal edits no text;
|
|
58
|
+
* only a pick does, consuming exactly the run.
|
|
60
59
|
*/
|
|
61
60
|
export declare function slashPlugin(onState: (state: SlashState | undefined) => void, hint?: () => string | undefined): Plugin<SlashRun | null>;
|
|
62
61
|
/**
|
|
63
|
-
* The menu's keys, the innermost link of the leaf's chain (`keymap.ts`). Every one
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* Escape is the contended key: a table gives it three claimants (this menu, the
|
|
69
|
-
* format popover, an island selection). Innermost first, and this is the innermost
|
|
70
|
-
* of the three that can be open over a caret in text.
|
|
62
|
+
* The menu's keys, the innermost link of the leaf's chain (`keymap.ts`). Every one declines on an
|
|
63
|
+
* empty offer list rather than a dead run (§`SlashState`), so a body with no menu on screen keeps
|
|
64
|
+
* Enter, Escape and the arrows as it had them. Escape has three claimants over a table (this menu,
|
|
65
|
+
* the format popover, an island selection); this is the innermost that can be open over a caret in
|
|
66
|
+
* text.
|
|
71
67
|
*/
|
|
72
68
|
export declare function slashKeymap(): Record<string, Command>;
|
|
73
|
-
/** Move the keyboard cursor onto `name
|
|
74
|
-
* highlight has one lane rather than a hover painting a second one. */
|
|
69
|
+
/** Move the keyboard cursor onto `name` (a pointer entering an item): one highlight lane. */
|
|
75
70
|
export declare function focusSlashItem(view: EditorView, name: string): void;
|
|
76
71
|
/**
|
|
77
|
-
* Run a command: one transaction that deletes the trigger run and applies the command's
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* can.
|
|
72
|
+
* Run a command: one transaction that deletes the trigger run and applies the command's edit
|
|
73
|
+
* (`blocks.ts` §`consuming`). A command that declines consumes nothing. The menu only offers what
|
|
74
|
+
* would run; `slashPick` is a public seam and can pick any.
|
|
81
75
|
*/
|
|
82
76
|
export declare function runSlashItem(view: EditorView, name: string): void;
|
|
83
77
|
export {};
|
package/dist/core/codec/slash.js
CHANGED
|
Binary file
|
|
@@ -7,9 +7,10 @@ export interface CellRange {
|
|
|
7
7
|
r1: number;
|
|
8
8
|
c1: number;
|
|
9
9
|
}
|
|
10
|
-
/** The cells of `range` as a `<table>`, the header
|
|
11
|
-
* holds
|
|
12
|
-
* of the table's layout.
|
|
10
|
+
/** The cells of `range` as a `<table>`, the header rows in a `<thead>` where the range
|
|
11
|
+
* holds them. The cells carry their marks, breaks and spans, a span cut to the range,
|
|
12
|
+
* and nothing else of the table's layout. A slot a merged cell in the range covers
|
|
13
|
+
* draws nothing; one whose cell starts outside the range draws empty. */
|
|
13
14
|
export declare function tableElement(props: TableProps, range?: CellRange): HTMLTableElement;
|
|
14
15
|
/** The cells of `range` as tab-separated text, a line a row. */
|
|
15
16
|
export declare function tableText(props: TableProps, range?: CellRange): string;
|
|
@@ -8,7 +8,7 @@ import { Plugin } from 'prosemirror-state';
|
|
|
8
8
|
import { decode } from './decode.js';
|
|
9
9
|
import { tablePropsOfNode } from './islands.js';
|
|
10
10
|
import { blockSchema, cellSchema } from './schema.js';
|
|
11
|
-
import { cellAt, cellContent, columnCount, rowCount } from './table.js';
|
|
11
|
+
import { anchorAt, cellAt, cellContent, columnCount, headRows, rowCount, spanGrid } from './table.js';
|
|
12
12
|
const whole = (props) => ({
|
|
13
13
|
r0: 0,
|
|
14
14
|
c0: 0,
|
|
@@ -23,18 +23,36 @@ function cellDOM(tag, cell) {
|
|
|
23
23
|
dom.append(cellSerializer.serializeFragment(paragraph.content));
|
|
24
24
|
return dom;
|
|
25
25
|
}
|
|
26
|
-
/** The cells of `range` as a `<table>`, the header
|
|
27
|
-
* holds
|
|
28
|
-
* of the table's layout.
|
|
26
|
+
/** The cells of `range` as a `<table>`, the header rows in a `<thead>` where the range
|
|
27
|
+
* holds them. The cells carry their marks, breaks and spans, a span cut to the range,
|
|
28
|
+
* and nothing else of the table's layout. A slot a merged cell in the range covers
|
|
29
|
+
* draws nothing; one whose cell starts outside the range draws empty. */
|
|
29
30
|
export function tableElement(props, range = whole(props)) {
|
|
30
31
|
const table = document.createElement('table');
|
|
32
|
+
const grid = spanGrid(props);
|
|
31
33
|
let body;
|
|
32
34
|
for (let r = range.r0; r <= range.r1; r++) {
|
|
33
|
-
const head = r
|
|
35
|
+
const head = r < headRows(props);
|
|
34
36
|
const section = head ? table.createTHead() : (body ??= table.createTBody());
|
|
35
37
|
const tr = section.insertRow();
|
|
36
|
-
for (let c = range.c0; c <= range.c1; c++)
|
|
37
|
-
|
|
38
|
+
for (let c = range.c0; c <= range.c1; c++) {
|
|
39
|
+
const tag = head ? 'th' : 'td';
|
|
40
|
+
const at = anchorAt(grid, r, c);
|
|
41
|
+
if (at.r < range.r0 || at.c < range.c0) {
|
|
42
|
+
tr.append(cellDOM(tag, { text: '', marks: [] }));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (at.r !== r || at.c !== c)
|
|
46
|
+
continue;
|
|
47
|
+
const dom = cellDOM(tag, cellAt(props, r, c));
|
|
48
|
+
const colspan = Math.min(at.span.colspan, range.c1 - c + 1);
|
|
49
|
+
const rowspan = Math.min(at.span.rowspan, range.r1 - r + 1);
|
|
50
|
+
if (colspan > 1)
|
|
51
|
+
dom.setAttribute('colspan', String(colspan));
|
|
52
|
+
if (rowspan > 1)
|
|
53
|
+
dom.setAttribute('rowspan', String(rowspan));
|
|
54
|
+
tr.append(dom);
|
|
55
|
+
}
|
|
38
56
|
}
|
|
39
57
|
return table;
|
|
40
58
|
}
|
|
@@ -27,28 +27,28 @@ export interface TableChromeStrings {
|
|
|
27
27
|
tableAlignRight: string;
|
|
28
28
|
/** The held first row's toggle, pressed while the row draws as the header. */
|
|
29
29
|
tableHeaderToggle: string;
|
|
30
|
+
/** The held cells' cluster: one cell from the block, and the merged cells in it back
|
|
31
|
+
* to the cells under them. */
|
|
32
|
+
tableMergeCells: string;
|
|
33
|
+
tableSplitCell: string;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
|
-
* The package's English for the island chrome. It lives
|
|
33
|
-
*
|
|
34
|
-
* chrome and a consumer reaching `createField` directly gets wording with it. The
|
|
35
|
-
* visual `strings` set extends this one, so a consumer overrides these keys beside
|
|
36
|
-
* every other key and there is still one English list.
|
|
36
|
+
* The package's English for the island chrome. It lives beside the surface that draws it so a
|
|
37
|
+
* consumer reaching `createField` directly gets wording; the visual `strings` set extends it.
|
|
37
38
|
*/
|
|
38
39
|
export declare const DEFAULT_TABLE_STRINGS: TableChromeStrings;
|
|
39
40
|
/** What the field hands each island view: its wording (read live, so a locale swap
|
|
40
41
|
* re-renders) and the callbacks that keep a nested view visible to the leaf. */
|
|
41
42
|
export interface TableViewDeps {
|
|
42
43
|
strings: () => TableChromeStrings;
|
|
43
|
-
/** Register a mounted cell view; the returned function unregisters it.
|
|
44
|
-
* needs the set to answer "which view holds the caret" for the format popover. */
|
|
44
|
+
/** Register a mounted cell view; the returned function unregisters it. */
|
|
45
45
|
register: (view: EditorView) => () => void;
|
|
46
|
-
/** A cell took focus
|
|
47
|
-
* event does not bubble), so the active address would not follow the caret. */
|
|
46
|
+
/** A cell took focus; a focus event does not bubble to the leaf's own handler. */
|
|
48
47
|
onCellFocus: () => void;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
/**
|
|
49
|
+
* The clearance a revealed caret keeps; `undefined` where the derivation is out of reach
|
|
50
|
+
* (jsdom).
|
|
51
|
+
*/
|
|
52
52
|
clearance: number | undefined;
|
|
53
53
|
}
|
|
54
54
|
/** The table island mounted at `pos` in `view`, which a caret can step into; `undefined`
|