@quillmark/svelte 0.35.1 → 0.37.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 +30 -18
- package/THEMING.md +1 -1
- package/dist/core/address.d.ts +5 -0
- package/dist/core/address.js +14 -0
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +42 -16
- package/dist/core/codec/field.js +97 -28
- package/dist/core/codec/index.d.ts +8 -5
- package/dist/core/codec/index.js +4 -5
- package/dist/core/codec/prose.css +25 -81
- package/dist/core/codec/review.d.ts +31 -26
- package/dist/core/codec/review.js +93 -169
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +5 -4
- package/dist/core/codec/shortcuts.js +9 -8
- package/dist/core/codec/table-view.js +15 -3
- package/dist/core/codec/value-diff.d.ts +21 -0
- package/dist/core/codec/value-diff.js +83 -0
- package/dist/core/codec/value-plan.d.ts +29 -0
- package/dist/core/codec/value-plan.js +157 -0
- package/dist/core/theme.css +46 -15
- package/dist/core/tooltip.css +49 -0
- package/dist/core/tooltip.d.ts +6 -0
- package/dist/core/tooltip.js +176 -0
- package/dist/preview/Preview.svelte +22 -1
- package/dist/preview/controller.js +38 -0
- package/dist/preview/strings.d.ts +2 -0
- package/dist/preview/strings.js +1 -0
- package/dist/visual/ArrayField.svelte +374 -96
- package/dist/visual/Card.svelte +33 -12
- package/dist/visual/Card.svelte.d.ts +3 -0
- package/dist/visual/CardControls.svelte +3 -3
- package/dist/visual/DateField.svelte +47 -5
- package/dist/visual/DiagnosticList.svelte +3 -2
- package/dist/visual/EnumField.svelte +20 -5
- package/dist/visual/EnumField.svelte.d.ts +5 -0
- package/dist/visual/Field.svelte +56 -47
- package/dist/visual/FieldHint.svelte +20 -8
- package/dist/visual/FormatPopover.svelte +54 -20
- package/dist/visual/MatrixField.svelte +48 -6
- package/dist/visual/MatrixField.svelte.d.ts +5 -0
- package/dist/visual/NumberField.svelte +131 -6
- package/dist/visual/NumberField.svelte.d.ts +5 -0
- package/dist/visual/ObjectField.svelte +60 -18
- package/dist/visual/ProseField.svelte +21 -5
- package/dist/visual/ProseField.svelte.d.ts +5 -1
- package/dist/visual/ProseValue.svelte +49 -8
- package/dist/visual/ProseValue.svelte.d.ts +7 -1
- package/dist/visual/ReviewCard.svelte +400 -0
- package/dist/visual/ReviewCard.svelte.d.ts +20 -0
- package/dist/visual/ReviewProposal.svelte +98 -138
- package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
- package/dist/visual/ReviewRows.svelte +6 -25
- package/dist/visual/ReviewRows.svelte.d.ts +1 -3
- package/dist/visual/SlashMenu.svelte +1 -0
- package/dist/visual/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +45 -4
- package/dist/visual/VariantField.svelte.d.ts +5 -0
- package/dist/visual/VisualEditor.svelte +24 -9
- package/dist/visual/VisualEditor.svelte.d.ts +8 -1
- package/dist/visual/VisualEditorInner.svelte +917 -280
- package/dist/visual/VisualEditorInner.svelte.d.ts +8 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +25 -24
- package/dist/visual/proposals.js +92 -32
- package/dist/visual/props.d.ts +18 -18
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +94 -3
- package/dist/visual/review.js +37 -2
- package/dist/visual/review.svelte.d.ts +77 -20
- package/dist/visual/review.svelte.js +306 -49
- package/dist/visual/strings.d.ts +59 -25
- package/dist/visual/strings.js +90 -29
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/dist/visual/undo.svelte.d.ts +3 -1
- package/dist/visual/undo.svelte.js +7 -3
- package/package.json +2 -2
package/dist/visual/strings.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import type { Diagnostic } from '@quillmark/wasm';
|
|
2
|
-
import { type LeaveStrings, type
|
|
2
|
+
import { type LeaveStrings, type ShortcutStrings, type SlashStrings, type TableChromeStrings } from '../core/codec/index.js';
|
|
3
3
|
import type { BodyPlaceholder } from './structure.js';
|
|
4
4
|
/**
|
|
5
|
-
* The island, the insert menu, the shortcut list and the
|
|
5
|
+
* The island, the insert menu, the shortcut list and the leave hint's keys come from the
|
|
6
6
|
* codec, which owns all four models (a NodeView inside the leaf, the trigger the leaf's keymap
|
|
7
|
-
* drives, the keymaps' own tables, and the
|
|
7
|
+
* drives, the keymaps' own tables, and the plugin that names the way out). Extending
|
|
8
8
|
* rather than restating them is what keeps one English list: a consumer overrides an
|
|
9
9
|
* island handle's name beside the card controls' and the codec still has a default
|
|
10
10
|
* for a leaf mounted directly.
|
|
11
11
|
*/
|
|
12
|
-
export interface VisualStrings extends TableChromeStrings, SlashStrings, ShortcutStrings, LeaveStrings
|
|
12
|
+
export interface VisualStrings extends TableChromeStrings, SlashStrings, ShortcutStrings, LeaveStrings {
|
|
13
13
|
cardMoveUp: string;
|
|
14
14
|
cardMoveDown: string;
|
|
15
15
|
cardDelete: string;
|
|
16
|
-
/** The card-title input's accessible name
|
|
16
|
+
/** The card-title input's own word in its accessible name, which {@link cardAction}
|
|
17
|
+
* completes with the card's title: `Card title, Findings`. */
|
|
17
18
|
cardTitle: string;
|
|
18
19
|
/**
|
|
19
|
-
* A card control's accessible name, the
|
|
20
|
-
* the header shows: `Delete card, Findings`.
|
|
21
|
-
* Parametric, so word order stays the translator's.
|
|
20
|
+
* A card control's accessible name, the control's own word and the card it is on, by
|
|
21
|
+
* the title the header shows: `Delete card, Findings`. An action alone stays the
|
|
22
|
+
* tooltip. Parametric, so word order stays the translator's.
|
|
22
23
|
*/
|
|
23
24
|
cardAction: (action: string, card: string) => string;
|
|
24
25
|
/** A closed panel's header, spoken after its name (`Layout, has an issue`) when a field
|
|
@@ -26,10 +27,27 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
26
27
|
groupFlagged: string;
|
|
27
28
|
/** The same header where a field inside holds an item of review. */
|
|
28
29
|
groupReviewed: string;
|
|
29
|
-
/** The
|
|
30
|
-
|
|
30
|
+
/** The answer card's two buttons. */
|
|
31
|
+
reviewAccept: string;
|
|
32
|
+
reviewDismiss: string;
|
|
33
|
+
/** The answer card's accessible name. */
|
|
34
|
+
reviewProposal: string;
|
|
35
|
+
/** The answer card's note on a change whose place no longer holds what its writer read. */
|
|
36
|
+
reviewOutdated: string;
|
|
37
|
+
/** Where the current change stands in the review and what it is to, for a screen reader:
|
|
38
|
+
* `Change 2 of 5, Subtitle`. `name` is the field's label, the body's, or the card's title
|
|
39
|
+
* after its tag, and empty where nothing names it. */
|
|
40
|
+
reviewPosition: (at: number, of: number, name: string) => string;
|
|
41
|
+
/** The tag on a card proposed new, and the mark on one proposed taken out. */
|
|
42
|
+
reviewNewCard: string;
|
|
43
|
+
reviewRemoveCard: string;
|
|
31
44
|
/** A value that was, or would be, nothing. */
|
|
32
45
|
reviewEmpty: string;
|
|
46
|
+
/** Where a proposal adds a list member past the last, on the answer card. */
|
|
47
|
+
reviewNewItem: string;
|
|
48
|
+
/** A control under a proposal, described to assistive tech beside its name: the value it
|
|
49
|
+
* shows is the proposed one, and `current` the value the field holds now. */
|
|
50
|
+
reviewCurrently: (current: string) => string;
|
|
33
51
|
/** A switch's two values, as a row words them. */
|
|
34
52
|
reviewOn: string;
|
|
35
53
|
reviewOff: string;
|
|
@@ -39,15 +57,16 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
39
57
|
undoAction: string;
|
|
40
58
|
/** The standing control that puts a removed card back, named for it: `Restore Findings`. */
|
|
41
59
|
undoRestore: (what: string) => string;
|
|
42
|
-
/** The trailing strip's visible words
|
|
43
|
-
*
|
|
60
|
+
/** The trailing strip's visible words and every strip's accessible name. Words alone,
|
|
61
|
+
* as every add control's string is: the control draws its own `+`. One string over
|
|
44
62
|
* one kind and many: the trigger seeds a card, and which kind is the menu's word
|
|
45
63
|
* to say or the schema's to have already settled. */
|
|
46
64
|
addCard: string;
|
|
65
|
+
/** A list's add chip: its words after the `+` the chip draws, and its accessible name. */
|
|
47
66
|
arrayAdd: string;
|
|
48
67
|
arrayRemove: string;
|
|
49
|
-
/** The drag handle on an `object` row: its tooltip, which
|
|
50
|
-
*
|
|
68
|
+
/** The drag handle on an `object` row: its tooltip, which draws the keys that move the
|
|
69
|
+
* row beside it. */
|
|
51
70
|
arrayDrag: string;
|
|
52
71
|
/** What a list's standing row ghosts, the row that is not an element yet: the words
|
|
53
72
|
* say what typing there does. */
|
|
@@ -84,6 +103,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
84
103
|
diagTypeMismatch: (expected: string) => string;
|
|
85
104
|
/** `validation::format_violation`: the value misses a string format (`args.format`). */
|
|
86
105
|
diagFormatViolation: (format: string) => string;
|
|
106
|
+
/** What a screen reader hears once the errors the fields draw have changed and come to
|
|
107
|
+
* rest: each error's field label and its text, in the page's order, and none once the
|
|
108
|
+
* last has cleared. */
|
|
109
|
+
diagAnnounced: (issues: readonly {
|
|
110
|
+
field: string;
|
|
111
|
+
message: string;
|
|
112
|
+
}[]) => string;
|
|
87
113
|
/** The tag on a field whose `default:` is what prints. */
|
|
88
114
|
fieldDefault: string;
|
|
89
115
|
/** The button that unsets a field written over its `default:`; its accessible name
|
|
@@ -115,7 +141,13 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
115
141
|
* an island in a one-line leaf, an island in any subform cell), which it draws
|
|
116
142
|
* read-only rather than lose. */
|
|
117
143
|
proseHeld: string;
|
|
144
|
+
/** A field's guidance marker, named for the field it is about: `Subject guidance`.
|
|
145
|
+
* Parametric, so word order stays the translator's. */
|
|
146
|
+
fieldGuidance: (label: string) => string;
|
|
118
147
|
formatGroup: string;
|
|
148
|
+
/** A mark or list button's name: its accessible name and its tooltip. The name alone:
|
|
149
|
+
* the button's shortcut is read off its binding, drawn beside the name in the tooltip
|
|
150
|
+
* and stated to assistive tech as `aria-keyshortcuts`. */
|
|
119
151
|
formatBold: string;
|
|
120
152
|
formatEmphasis: string;
|
|
121
153
|
formatUnderline: string;
|
|
@@ -131,11 +163,10 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
131
163
|
fontDefault: string;
|
|
132
164
|
/** What the picker reads over a selection setting more than one family. */
|
|
133
165
|
fontMixed: string;
|
|
134
|
-
/** The anchor button's
|
|
135
|
-
* nothing draws this or the title below. */
|
|
166
|
+
/** The anchor button's name. The popover withholds the button, so nothing draws this. */
|
|
136
167
|
formatAnchor: string;
|
|
137
|
-
/**
|
|
138
|
-
|
|
168
|
+
/** The link prompt's address input: its accessible name. */
|
|
169
|
+
linkAddress: string;
|
|
139
170
|
linkPlaceholder: string;
|
|
140
171
|
linkApply: string;
|
|
141
172
|
/** Drawn only where the selection carries a link. */
|
|
@@ -196,14 +227,17 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
196
227
|
*/
|
|
197
228
|
export type FormatDiagnostic = (d: Diagnostic) => string | undefined;
|
|
198
229
|
/**
|
|
199
|
-
* A
|
|
200
|
-
*
|
|
201
|
-
* `
|
|
230
|
+
* A binding as the writer's platform prints it, for the hint beside a control's name:
|
|
231
|
+
* `Mod-b` is `⌘B` on Apple's and `Ctrl+B` elsewhere, `Mod-Shift-7` is `⇧⌘7` or
|
|
232
|
+
* `Ctrl+Shift+7`, `Alt-ArrowUp` is `⌥↑` or `Alt+↑`.
|
|
202
233
|
*/
|
|
203
|
-
export declare function
|
|
204
|
-
/**
|
|
205
|
-
*
|
|
206
|
-
|
|
234
|
+
export declare function keycap(binding: string, platform?: string): string;
|
|
235
|
+
/**
|
|
236
|
+
* The same binding as `aria-keyshortcuts` spells it, which is where a control states its
|
|
237
|
+
* shortcut to assistive tech, its name staying its name: `Mod-b` is `Meta+B` on Apple's
|
|
238
|
+
* and `Control+B` elsewhere.
|
|
239
|
+
*/
|
|
240
|
+
export declare function keyshortcut(binding: string, platform?: string): string;
|
|
207
241
|
/** The package's English. Every key, so the merge below is total. */
|
|
208
242
|
export declare const DEFAULT_VISUAL_STRINGS: VisualStrings;
|
|
209
243
|
/** A consumer's wording: any subset, the rest the package's. */
|
package/dist/visual/strings.js
CHANGED
|
@@ -18,24 +18,69 @@
|
|
|
18
18
|
// would put a `strings` prop on every component between the root and each leaf,
|
|
19
19
|
// which is a prop that means nothing to any of them.
|
|
20
20
|
import { getContext, setContext } from 'svelte';
|
|
21
|
-
import { DEFAULT_LEAVE_STRINGS,
|
|
21
|
+
import { DEFAULT_LEAVE_STRINGS, DEFAULT_SHORTCUT_STRINGS, DEFAULT_SLASH_STRINGS, DEFAULT_TABLE_STRINGS } from '../core/codec/index.js';
|
|
22
|
+
/** The platform test `prosemirror-keymap` resolves `Mod` by, so what is printed is what
|
|
23
|
+
* the keymap binds. */
|
|
24
|
+
const APPLE = /Mac|iP(hone|[oa]d)/;
|
|
25
|
+
const platformHere = () => (typeof navigator === 'undefined' ? '' : navigator.platform);
|
|
26
|
+
/** A binding in `prosemirror-keymap` notation, apart: its modifiers and its key, a letter
|
|
27
|
+
* in capitals as a keycap and `aria-keyshortcuts` both spell it. */
|
|
28
|
+
function parseBinding(binding) {
|
|
29
|
+
const parts = binding.split('-');
|
|
30
|
+
const key = parts.pop() ?? '';
|
|
31
|
+
return { mods: new Set(parts), key: /^[a-z]$/.test(key) ? key.toUpperCase() : key };
|
|
32
|
+
}
|
|
33
|
+
/** What a named key prints as. */
|
|
34
|
+
const KEY_GLYPH = {
|
|
35
|
+
ArrowUp: '↑',
|
|
36
|
+
ArrowDown: '↓',
|
|
37
|
+
ArrowLeft: '←',
|
|
38
|
+
ArrowRight: '→',
|
|
39
|
+
Enter: '↵',
|
|
40
|
+
Backspace: '⌫'
|
|
41
|
+
};
|
|
42
|
+
/** Apple's marks for the modifiers, in the order its menus print them. */
|
|
43
|
+
const APPLE_MODS = [
|
|
44
|
+
['Ctrl', '⌃'],
|
|
45
|
+
['Alt', '⌥'],
|
|
46
|
+
['Shift', '⇧'],
|
|
47
|
+
['Mod', '⌘']
|
|
48
|
+
];
|
|
22
49
|
/**
|
|
23
|
-
* A
|
|
24
|
-
*
|
|
25
|
-
* `
|
|
50
|
+
* A binding as the writer's platform prints it, for the hint beside a control's name:
|
|
51
|
+
* `Mod-b` is `⌘B` on Apple's and `Ctrl+B` elsewhere, `Mod-Shift-7` is `⇧⌘7` or
|
|
52
|
+
* `Ctrl+Shift+7`, `Alt-ArrowUp` is `⌥↑` or `Alt+↑`.
|
|
26
53
|
*/
|
|
27
|
-
export function
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
return
|
|
32
|
-
|
|
54
|
+
export function keycap(binding, platform = platformHere()) {
|
|
55
|
+
const { mods, key } = parseBinding(binding);
|
|
56
|
+
const cap = KEY_GLYPH[key] ?? key;
|
|
57
|
+
if (APPLE.test(platform))
|
|
58
|
+
return APPLE_MODS.map(([mod, mark]) => (mods.has(mod) ? mark : '')).join('') + cap;
|
|
59
|
+
const names = [
|
|
60
|
+
mods.has('Mod') || mods.has('Ctrl') ? 'Ctrl' : '',
|
|
61
|
+
mods.has('Alt') ? 'Alt' : '',
|
|
62
|
+
mods.has('Shift') ? 'Shift' : ''
|
|
63
|
+
];
|
|
64
|
+
return [...names.filter(Boolean), cap].join('+');
|
|
33
65
|
}
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
/**
|
|
67
|
+
* The same binding as `aria-keyshortcuts` spells it, which is where a control states its
|
|
68
|
+
* shortcut to assistive tech, its name staying its name: `Mod-b` is `Meta+B` on Apple's
|
|
69
|
+
* and `Control+B` elsewhere.
|
|
70
|
+
*/
|
|
71
|
+
export function keyshortcut(binding, platform = platformHere()) {
|
|
72
|
+
const { mods, key } = parseBinding(binding);
|
|
73
|
+
const names = [
|
|
74
|
+
mods.has('Mod') ? (APPLE.test(platform) ? 'Meta' : 'Control') : '',
|
|
75
|
+
mods.has('Ctrl') ? 'Control' : '',
|
|
76
|
+
mods.has('Alt') ? 'Alt' : '',
|
|
77
|
+
mods.has('Shift') ? 'Shift' : ''
|
|
78
|
+
];
|
|
79
|
+
return [...names.filter(Boolean), key].join('+');
|
|
38
80
|
}
|
|
81
|
+
/** How many fields `diagAnnounced` names before it counts the rest, so a host's batch over
|
|
82
|
+
* a whole document is still one sentence. */
|
|
83
|
+
const FIELDS_NAMED = 3;
|
|
39
84
|
/** The package's English. Every key, so the merge below is total. */
|
|
40
85
|
export const DEFAULT_VISUAL_STRINGS = {
|
|
41
86
|
...DEFAULT_TABLE_STRINGS,
|
|
@@ -49,20 +94,25 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
49
94
|
cardAction: (action, card) => `${action}, ${card}`,
|
|
50
95
|
groupFlagged: ', has an issue',
|
|
51
96
|
groupReviewed: ', has changes to review',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
97
|
+
reviewAccept: 'Accept',
|
|
98
|
+
reviewDismiss: 'Dismiss',
|
|
99
|
+
reviewProposal: 'Proposed change',
|
|
100
|
+
reviewOutdated: 'Changed since proposed',
|
|
101
|
+
reviewPosition: (at, of, name) => `Change ${at} of ${of}${name ? `, ${name}` : ''}`,
|
|
102
|
+
reviewNewCard: 'New card',
|
|
103
|
+
reviewRemoveCard: 'Proposed removal',
|
|
56
104
|
reviewEmpty: 'Empty',
|
|
105
|
+
reviewNewItem: 'New item',
|
|
106
|
+
reviewCurrently: (current) => `Proposed change, currently ${current}`,
|
|
57
107
|
reviewOn: 'On',
|
|
58
108
|
reviewOff: 'Off',
|
|
59
109
|
undoRemoved: (what) => `${what} removed`,
|
|
60
110
|
undoAction: 'Undo',
|
|
61
111
|
undoRestore: (what) => `Restore ${what}`,
|
|
62
112
|
addCard: 'Add card',
|
|
63
|
-
arrayAdd: '
|
|
113
|
+
arrayAdd: 'Add',
|
|
64
114
|
arrayRemove: 'Remove',
|
|
65
|
-
arrayDrag:
|
|
115
|
+
arrayDrag: 'Drag to move',
|
|
66
116
|
arrayStanding: 'Add an item…',
|
|
67
117
|
arrayRowAction: (action, row) => `${action} ${row}`,
|
|
68
118
|
arrayCount: (count, max) => `${count} / ${max}`,
|
|
@@ -81,6 +131,16 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
81
131
|
: format === 'datetime'
|
|
82
132
|
? 'Not a real date and time. Check the day, month and time.'
|
|
83
133
|
: `Doesn't match the ${format} format.`,
|
|
134
|
+
diagAnnounced: (issues) => {
|
|
135
|
+
if (issues.length === 0)
|
|
136
|
+
return 'No issues.';
|
|
137
|
+
if (issues.length === 1)
|
|
138
|
+
return `${issues[0].field}: ${issues[0].message}`;
|
|
139
|
+
const fields = [...new Set(issues.map((issue) => issue.field))];
|
|
140
|
+
const named = fields.slice(0, FIELDS_NAMED).join(', ');
|
|
141
|
+
const rest = fields.length - FIELDS_NAMED;
|
|
142
|
+
return `${issues.length} issues: ${named}${rest > 0 ? `, and ${rest} more` : ''}.`;
|
|
143
|
+
},
|
|
84
144
|
fieldDefault: 'Default',
|
|
85
145
|
fieldReset: 'Reset',
|
|
86
146
|
enumUnsetTag: 'Default',
|
|
@@ -93,20 +153,21 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
93
153
|
dateToday: 'Today',
|
|
94
154
|
optionalGhost: 'None',
|
|
95
155
|
proseHeld: "This field has formatting it can't edit here. It is kept as it is.",
|
|
156
|
+
fieldGuidance: (label) => `${label} guidance`,
|
|
96
157
|
formatGroup: 'Formatting',
|
|
97
|
-
formatBold:
|
|
98
|
-
formatEmphasis:
|
|
99
|
-
formatUnderline:
|
|
100
|
-
formatStrikethrough:
|
|
101
|
-
formatCode:
|
|
102
|
-
formatLink:
|
|
103
|
-
formatNumberedList:
|
|
104
|
-
formatBulletedList:
|
|
158
|
+
formatBold: 'Bold',
|
|
159
|
+
formatEmphasis: 'Italic',
|
|
160
|
+
formatUnderline: 'Underline',
|
|
161
|
+
formatStrikethrough: 'Strikethrough',
|
|
162
|
+
formatCode: 'Code',
|
|
163
|
+
formatLink: 'Link',
|
|
164
|
+
formatNumberedList: 'Numbered list',
|
|
165
|
+
formatBulletedList: 'Bulleted list',
|
|
105
166
|
formatFont: 'Font',
|
|
106
167
|
fontDefault: 'Default font',
|
|
107
168
|
fontMixed: 'Mixed fonts',
|
|
108
169
|
formatAnchor: 'Anchor',
|
|
109
|
-
|
|
170
|
+
linkAddress: 'Link address',
|
|
110
171
|
linkPlaceholder: 'https://…',
|
|
111
172
|
linkApply: 'Apply',
|
|
112
173
|
linkRemove: 'Remove',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Content, type PathStep, type PayloadItem, type QuillCardSchema, type QuillFieldSchema, type QuillFieldType, type ResolvedField, type Resolved } from '@quillmark/wasm';
|
|
1
|
+
import { type Card, type Content, type Document, type PathStep, type PayloadItem, type QuillCardSchema, type QuillFieldSchema, type QuillFieldType, type ResolvedField, type Resolved } from '@quillmark/wasm';
|
|
2
2
|
import type { TextCap } from '../core/codec/index.js';
|
|
3
3
|
/** The control a field type maps to (INVARIANTS §"Structure mirrors the schema"). */
|
|
4
4
|
export type ControlKind = 'prose' | 'text' | 'enum' | 'variant' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'matrix';
|
|
@@ -18,9 +18,10 @@ export interface FieldModel {
|
|
|
18
18
|
label: string;
|
|
19
19
|
/** Chrome-only; never gates. */
|
|
20
20
|
description: string | undefined;
|
|
21
|
-
/** Prose-leaf flags: {@link oneLine} and {@link
|
|
21
|
+
/** Prose-leaf flags: {@link oneLine}, {@link literalText} and {@link linesOnly}. */
|
|
22
22
|
inline: boolean;
|
|
23
23
|
plaintext: boolean;
|
|
24
|
+
paragraphs: boolean;
|
|
24
25
|
}
|
|
25
26
|
/** A panel section, a top-level `object`'s or a legacy `ui.group`'s: its label and the
|
|
26
27
|
* fields (declaration order) inside it. */
|
|
@@ -141,8 +142,10 @@ export declare function optionalCell(f: QuillFieldSchema): boolean;
|
|
|
141
142
|
*/
|
|
142
143
|
export declare function baseType(f: QuillFieldSchema): QuillFieldType;
|
|
143
144
|
/** Whether a content field is one line: one paragraph, no container, no island. A `text`
|
|
144
|
-
* or `richtext` field is one line unless it declares `
|
|
145
|
+
* or `richtext` field is one line unless it declares a `shape`. */
|
|
145
146
|
export declare function oneLine(f: QuillFieldSchema): boolean;
|
|
147
|
+
/** Whether a `richtext` field holds formatted lines and no block: `shape: lines`. */
|
|
148
|
+
export declare function linesOnly(f: QuillFieldSchema): boolean;
|
|
146
149
|
/** Whether a content field's codec is the literal one: `text`. */
|
|
147
150
|
export declare function literalText(f: QuillFieldSchema): boolean;
|
|
148
151
|
/** The character cap a content field's `max:` declares, `undefined` on any other. */
|
|
@@ -248,6 +251,13 @@ export declare function matrixMemberSchema(matrix: QuillFieldSchema, id: string)
|
|
|
248
251
|
* before it asks the mounted tree for it (INVARIANTS §Surface).
|
|
249
252
|
*/
|
|
250
253
|
export declare function schemaAt(field: QuillFieldSchema, steps: readonly PathStep[]): QuillFieldSchema | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Where the place at `steps` under `field` is drawn among the places inside the field, a number
|
|
256
|
+
* for each step: a list's member by its index, a record's cell by its declared order, a matrix's
|
|
257
|
+
* member by the roster's and one `value` adds after them, a variant's discriminant ahead of its
|
|
258
|
+
* cells. A step the schema does not declare is last.
|
|
259
|
+
*/
|
|
260
|
+
export declare function rankAt(field: QuillFieldSchema, steps: readonly PathStep[], value?: unknown): number[];
|
|
251
261
|
/**
|
|
252
262
|
* Whether a cell is one line tall by declaration: what a table column can hold.
|
|
253
263
|
*/
|
|
@@ -373,3 +383,7 @@ export declare class IdSeq {
|
|
|
373
383
|
/** `count` fresh ids, in order. */
|
|
374
384
|
take(count: number): string[];
|
|
375
385
|
}
|
|
386
|
+
/** Write `card` into `target` at `at`, under its `$id` where no card there holds that one and
|
|
387
|
+
* the document takes it, else under one the document mints. Throws where the card cannot be
|
|
388
|
+
* written. */
|
|
389
|
+
export declare function placeCardInto(target: Document, card: Card, at: number): void;
|
package/dist/visual/structure.js
CHANGED
|
@@ -70,9 +70,13 @@ export function baseType(f) {
|
|
|
70
70
|
return (optionalCell(f) ? f.type.slice(0, -1) : f.type);
|
|
71
71
|
}
|
|
72
72
|
/** Whether a content field is one line: one paragraph, no container, no island. A `text`
|
|
73
|
-
* or `richtext` field is one line unless it declares `
|
|
73
|
+
* or `richtext` field is one line unless it declares a `shape`. */
|
|
74
74
|
export function oneLine(f) {
|
|
75
|
-
return f.
|
|
75
|
+
return f.shape === undefined;
|
|
76
|
+
}
|
|
77
|
+
/** Whether a `richtext` field holds formatted lines and no block: `shape: lines`. */
|
|
78
|
+
export function linesOnly(f) {
|
|
79
|
+
return baseType(f) === 'richtext' && f.shape === 'lines';
|
|
76
80
|
}
|
|
77
81
|
/** Whether a content field's codec is the literal one: `text`. */
|
|
78
82
|
export function literalText(f) {
|
|
@@ -117,10 +121,10 @@ export function mountKey(name, f) {
|
|
|
117
121
|
return [
|
|
118
122
|
name,
|
|
119
123
|
f.type,
|
|
120
|
-
|
|
124
|
+
f.shape ?? '',
|
|
121
125
|
f.max ?? '',
|
|
122
126
|
items?.type ?? '',
|
|
123
|
-
items
|
|
127
|
+
items?.shape ?? '',
|
|
124
128
|
items?.max ?? ''
|
|
125
129
|
].join('\u0000');
|
|
126
130
|
}
|
|
@@ -361,6 +365,51 @@ function stepInto(schema, step) {
|
|
|
361
365
|
return undefined;
|
|
362
366
|
}
|
|
363
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Where the place at `steps` under `field` is drawn among the places inside the field, a number
|
|
370
|
+
* for each step: a list's member by its index, a record's cell by its declared order, a matrix's
|
|
371
|
+
* member by the roster's and one `value` adds after them, a variant's discriminant ahead of its
|
|
372
|
+
* cells. A step the schema does not declare is last.
|
|
373
|
+
*/
|
|
374
|
+
export function rankAt(field, steps, value) {
|
|
375
|
+
const out = [];
|
|
376
|
+
let cursor = field;
|
|
377
|
+
let held = value;
|
|
378
|
+
const among = (keys, step) => {
|
|
379
|
+
const at = keys.indexOf(String(step));
|
|
380
|
+
return at < 0 ? Number.MAX_SAFE_INTEGER : at;
|
|
381
|
+
};
|
|
382
|
+
for (const step of steps) {
|
|
383
|
+
if (!cursor) {
|
|
384
|
+
out.push(Number.MAX_SAFE_INTEGER);
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
switch (controlKind(cursor)) {
|
|
388
|
+
case 'array':
|
|
389
|
+
out.push(typeof step === 'number' ? step : Number.MAX_SAFE_INTEGER);
|
|
390
|
+
break;
|
|
391
|
+
case 'object':
|
|
392
|
+
out.push(among(Object.keys(cursor.properties ?? {}), step));
|
|
393
|
+
break;
|
|
394
|
+
case 'matrix': {
|
|
395
|
+
const map = held && typeof held === 'object' ? held : undefined;
|
|
396
|
+
const drawn = [...matrixMembers(cursor.members), ...addedItems(cursor, map)];
|
|
397
|
+
out.push(among(drawn.map((m) => m.id), step));
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
case 'variant': {
|
|
401
|
+
const world = Object.values(cursor.variants ?? {}).find((cells) => Object.hasOwn(cells, String(step)));
|
|
402
|
+
out.push(step === VARIANT_DISCRIMINANT ? 0 : 1 + among(Object.keys(world ?? {}), step));
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
default:
|
|
406
|
+
out.push(Number.MAX_SAFE_INTEGER);
|
|
407
|
+
}
|
|
408
|
+
cursor = stepInto(cursor, step);
|
|
409
|
+
held = held && typeof held === 'object' ? held[step] : undefined;
|
|
410
|
+
}
|
|
411
|
+
return out;
|
|
412
|
+
}
|
|
364
413
|
// ── Short cells and layouts ──────────────────────────────────────────────────
|
|
365
414
|
/**
|
|
366
415
|
* Whether a cell is one line tall by declaration: what a table column can hold.
|
|
@@ -460,7 +509,8 @@ export function fieldModels(cardSchema) {
|
|
|
460
509
|
label: fieldTitle(name, schema),
|
|
461
510
|
description: schema.description,
|
|
462
511
|
inline: oneLine(schema),
|
|
463
|
-
plaintext: literalText(schema)
|
|
512
|
+
plaintext: literalText(schema),
|
|
513
|
+
paragraphs: linesOnly(schema)
|
|
464
514
|
};
|
|
465
515
|
});
|
|
466
516
|
}
|
|
@@ -676,3 +726,19 @@ export class IdSeq {
|
|
|
676
726
|
return Array.from({ length: count }, () => this.next());
|
|
677
727
|
}
|
|
678
728
|
}
|
|
729
|
+
/** Write `card` into `target` at `at`, under its `$id` where no card there holds that one and
|
|
730
|
+
* the document takes it, else under one the document mints. Throws where the card cannot be
|
|
731
|
+
* written. */
|
|
732
|
+
export function placeCardInto(target, card, at) {
|
|
733
|
+
const { id, ...bare } = card;
|
|
734
|
+
const free = id !== undefined &&
|
|
735
|
+
!Array.from({ length: target.cardCount }, (_, k) => target.card(k).id).includes(id);
|
|
736
|
+
try {
|
|
737
|
+
target.unchecked.insertCard(free ? card : bare, at);
|
|
738
|
+
}
|
|
739
|
+
catch (e) {
|
|
740
|
+
if (!free)
|
|
741
|
+
throw e;
|
|
742
|
+
target.unchecked.insertCard(bare, at);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
@@ -46,7 +46,9 @@ export interface StructuralUndo {
|
|
|
46
46
|
* edit has landed since, and the target is the page's body, where a removal under the
|
|
47
47
|
* pointer leaves the focus, when this editor offered last on the page; the handed
|
|
48
48
|
* control; or a control under `root` that keeps no history of its own. A text control
|
|
49
|
-
* that is not the handed one keeps its key from a removal and gives it to a standing step.
|
|
49
|
+
* that is not the handed one keeps its key from a removal and gives it to a standing step.
|
|
50
|
+
* The answers' step is the key's too at any target outside `root` but a text control, when
|
|
51
|
+
* this editor offered last. */
|
|
50
52
|
accepts(target: EventTarget | null, root: Element | undefined): boolean;
|
|
51
53
|
/** Hold the lapse while the toast is under the pointer or the focus, and let it run again. */
|
|
52
54
|
pause(): void;
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
//
|
|
29
29
|
// The key listens on the document, not on the surface: a removal by the pointer takes the
|
|
30
30
|
// pressed button with it and leaves the focus on the page's body, which no keydown on the
|
|
31
|
-
// surface hears.
|
|
31
|
+
// surface hears. An answer is given from wherever the focus is, a host's panel beside the
|
|
32
|
+
// editor included, so the answers' step is the key's from anywhere on the page but a text
|
|
33
|
+
// control outside the editor, which keeps its own.
|
|
32
34
|
import { getContext, setContext } from 'svelte';
|
|
33
35
|
/** How long an offer stands, in ms. Long enough to read the toast and reach its button;
|
|
34
36
|
* short enough that the toast is gone before the user has moved on to something else. */
|
|
@@ -84,7 +86,7 @@ export function createStructuralUndo() {
|
|
|
84
86
|
if (keptAs !== undefined)
|
|
85
87
|
kept = [...kept, { label: keptAs, restore }];
|
|
86
88
|
if (standing || keptAs !== undefined)
|
|
87
|
-
last = { offer, standing, under };
|
|
89
|
+
last = { offer, standing, answer, under };
|
|
88
90
|
latest = self;
|
|
89
91
|
if (quiet)
|
|
90
92
|
return offer;
|
|
@@ -118,7 +120,9 @@ export function createStructuralUndo() {
|
|
|
118
120
|
return latest === self;
|
|
119
121
|
if (target === handed)
|
|
120
122
|
return true;
|
|
121
|
-
|
|
123
|
+
if (root?.contains(target))
|
|
124
|
+
return !!last?.standing || !target.closest(EDITABLE);
|
|
125
|
+
return (!!last?.answer && last.offer === live() && latest === self && !target.closest(EDITABLE));
|
|
122
126
|
},
|
|
123
127
|
pause() {
|
|
124
128
|
if (!current || paused)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillmark/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Editor, live-preview and source surfaces over a Quillmark WASM session.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@quillmark/wasm": ">=0.
|
|
72
|
+
"@quillmark/wasm": ">=0.138.0-0",
|
|
73
73
|
"svelte": "^5.33.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|