@quillmark/svelte 0.31.0 → 0.32.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 +3 -3
- package/dist/core/address.d.ts +1 -1
- package/dist/core/address.js +1 -1
- package/dist/core/codec/atoms.js +1 -1
- package/dist/core/codec/breaks.js +3 -2
- package/dist/core/codec/decode.d.ts +1 -1
- package/dist/core/codec/decode.js +2 -2
- package/dist/core/codec/field.d.ts +3 -3
- package/dist/core/codec/field.js +21 -20
- package/dist/core/codec/index.d.ts +2 -0
- package/dist/core/codec/index.js +5 -1
- package/dist/core/codec/inputrules.js +3 -3
- package/dist/core/codec/islands.d.ts +1 -1
- package/dist/core/codec/islands.js +3 -3
- package/dist/core/codec/keymap.d.ts +1 -1
- package/dist/core/codec/keymap.js +3 -2
- package/dist/core/codec/list-move.js +2 -1
- package/dist/core/codec/list-paste.js +1 -1
- package/dist/core/codec/lists.d.ts +1 -1
- package/dist/core/codec/lists.js +7 -6
- package/dist/core/codec/markdown-paste.js +2 -2
- package/dist/core/codec/prose.css +3 -3
- package/dist/core/codec/schema.d.ts +1 -1
- package/dist/core/codec/schema.js +3 -3
- package/dist/core/codec/shortcuts.d.ts +91 -0
- package/dist/core/codec/shortcuts.js +135 -0
- package/dist/core/codec/table-paste.js +1 -1
- package/dist/core/codec/table-view.d.ts +1 -1
- package/dist/core/codec/table-view.js +27 -37
- package/dist/core/codec/tasks.js +1 -1
- package/dist/core/theme.css +2 -2
- package/dist/preset/scale.css +1 -1
- package/dist/preview/Preview.svelte +2 -3
- package/dist/preview/bridge.js +2 -2
- package/dist/preview/geometry.d.ts +2 -2
- package/dist/preview/geometry.js +2 -2
- package/dist/preview/paint.js +1 -1
- package/dist/visual/ArrayField.svelte +5 -5
- package/dist/visual/BooleanField.svelte +1 -1
- package/dist/visual/Card.svelte +4 -4
- package/dist/visual/CardControls.svelte +1 -1
- package/dist/visual/DateField.svelte +1 -1
- package/dist/visual/DiagnosticList.svelte +1 -1
- package/dist/visual/EnumField.svelte +1 -1
- package/dist/visual/Field.svelte +3 -3
- package/dist/visual/FormatPopover.svelte +9 -3
- package/dist/visual/MatrixAdd.svelte +1 -1
- package/dist/visual/MatrixField.svelte +1 -1
- package/dist/visual/NumberField.svelte +2 -3
- package/dist/visual/ObjectField.svelte +2 -2
- package/dist/visual/ProseField.svelte +2 -2
- package/dist/visual/TextField.svelte +1 -1
- package/dist/visual/VariantField.svelte +1 -1
- package/dist/visual/VisualEditorInner.svelte +15 -15
- package/dist/visual/controls.css +2 -2
- package/dist/visual/diagnostics.d.ts +2 -2
- package/dist/visual/diagnostics.js +2 -2
- package/dist/visual/index.d.ts +2 -0
- package/dist/visual/index.js +3 -0
- package/dist/visual/leaves.js +1 -1
- package/dist/visual/props.d.ts +2 -2
- package/dist/visual/strings.d.ts +6 -5
- package/dist/visual/strings.js +2 -1
- package/dist/visual/structure.d.ts +10 -9
- package/dist/visual/structure.js +13 -12
- package/dist/visual/tips.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ const session = await new Engine().open(quill, doc);
|
|
|
46
46
|
// free() on teardown the handles you MINTED: this quill, this doc, this session.
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
`<VisualEditor>` needs no session, and the first `open` loads the render build, so a host that mounts the editor over `doc` and `quill` first shows it without waiting on that load. The session opens behind it: `await engine.load(quill)`, then `engine.open(quill, doc)`, so its first compile reads what was typed meanwhile ([
|
|
49
|
+
`<VisualEditor>` needs no session, and the first `open` loads the render build, so a host that mounts the editor over `doc` and `quill` first shows it without waiting on that load. The session opens behind it: `await engine.load(quill)`, then `engine.open(quill, doc)`, so its first compile reads what was typed meanwhile ([INVARIANTS.md](prose/INVARIANTS.md#hosting)).
|
|
50
50
|
|
|
51
51
|
## The quill resolves from the document
|
|
52
52
|
|
|
@@ -164,7 +164,7 @@ The package ships English and a seam to replace it. `strings` is keyed and **par
|
|
|
164
164
|
/>
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
`formatDiagnostic` gets the whole `Diagnostic` and returns `undefined` to take its own message. Validation and edit diagnostics re-word from `code`, `path` and `args`; parse errors and render warnings carry their detail inside English text and stand as they are ([
|
|
167
|
+
`formatDiagnostic` gets the whole `Diagnostic` and returns `undefined` to take its own message. Validation and edit diagnostics re-word from `code`, `path` and `args`; parse errors and render warnings carry their detail inside English text and stand as they are ([INVARIANTS.md](prose/INVARIANTS.md#diagnostics)).
|
|
168
168
|
|
|
169
169
|
### Fonts
|
|
170
170
|
|
|
@@ -265,7 +265,7 @@ The surfaces carry the behavior against a neutral, overridable visual baseline:
|
|
|
265
265
|
|
|
266
266
|
## Development
|
|
267
267
|
|
|
268
|
-
This package is one workspace of [`quillmark-js`](../..); the gates are the root's, and the
|
|
268
|
+
This package is one workspace of [`quillmark-js`](../..); the gates are the root's, and the rules a change must keep live in [`prose/INVARIANTS.md`](prose/INVARIANTS.md).
|
|
269
269
|
|
|
270
270
|
```sh
|
|
271
271
|
npm run build -w packages/svelte # svelte-package → dist/
|
package/dist/core/address.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare function addrForFieldPath(path: DocPath): Addr | undefined;
|
|
|
63
63
|
* The nearest ancestor a commit address can name: {@link addrForFieldPath} where the path has one,
|
|
64
64
|
* else the root and its first field (`main.contact.email` and `main.keywords[0]` land on their
|
|
65
65
|
* field). `undefined` for a field-rooted (config-space) or malformed path. An `Addr` reaches a root
|
|
66
|
-
* and one field, so the truncation is a consumer's to make (
|
|
66
|
+
* and one field, so the truncation is a consumer's to make (INVARIANTS §Diagnostics).
|
|
67
67
|
*/
|
|
68
68
|
export declare function nearestAddrForFieldPath(path: DocPath): Addr | undefined;
|
|
69
69
|
/**
|
package/dist/core/address.js
CHANGED
|
@@ -51,7 +51,7 @@ export function addrForFieldPath(path) {
|
|
|
51
51
|
* The nearest ancestor a commit address can name: {@link addrForFieldPath} where the path has one,
|
|
52
52
|
* else the root and its first field (`main.contact.email` and `main.keywords[0]` land on their
|
|
53
53
|
* field). `undefined` for a field-rooted (config-space) or malformed path. An `Addr` reaches a root
|
|
54
|
-
* and one field, so the truncation is a consumer's to make (
|
|
54
|
+
* and one field, so the truncation is a consumer's to make (INVARIANTS §Diagnostics).
|
|
55
55
|
*/
|
|
56
56
|
export function nearestAddrForFieldPath(path) {
|
|
57
57
|
const segs = segsOf(path);
|
package/dist/core/codec/atoms.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// delete against one edits nothing (§`againstAtom`).
|
|
5
5
|
//
|
|
6
6
|
// This is the neighbour half of the rule the leaf already holds for a key typed over a
|
|
7
|
-
// selection (
|
|
7
|
+
// selection (INVARIANTS §"The table island"): a selection is the subject of the next
|
|
8
8
|
// command, never a thing armed for replacement. Without it the base keymap's
|
|
9
9
|
// `joinBackward` / `joinForward` reach their "the neighbour is an atom, delete it" arm
|
|
10
10
|
// and a table goes in one keystroke, from the paragraph a table insert parks the caret
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
2
2
|
import { takesLineBreak } from './schema.js';
|
|
3
|
+
import { BODY_KEYS } from './shortcuts.js';
|
|
3
4
|
/**
|
|
4
5
|
* Rewrite every `\n` a transaction leaves in a non-`code` textblock: to a `hard_break`
|
|
5
6
|
* where the block takes one, to a space where it does not.
|
|
@@ -60,7 +61,7 @@ export function linebreakPlugin(schema) {
|
|
|
60
61
|
*
|
|
61
62
|
* The break takes no marks and the caret keeps them: `decode` mints an unmarked break,
|
|
62
63
|
* so an inherited mark would leave the leaf holding a shape a re-hydrate swaps out
|
|
63
|
-
* (
|
|
64
|
+
* (INVARIANTS §Encode, one spelling of each shape), while dropping the marks from the
|
|
64
65
|
* *caret* would end a bold run at a line break the author only meant to wrap at.
|
|
65
66
|
*/
|
|
66
67
|
function insertBreak(schema) {
|
|
@@ -90,5 +91,5 @@ function insertBreak(schema) {
|
|
|
90
91
|
export function breakKeymap(schema) {
|
|
91
92
|
if (!schema.nodes.hard_break)
|
|
92
93
|
return {};
|
|
93
|
-
return {
|
|
94
|
+
return { [BODY_KEYS.lineBreak]: insertBreak(schema) };
|
|
94
95
|
}
|
|
@@ -19,7 +19,7 @@ export declare function decode(rt: Content, schema: Schema): PMNode;
|
|
|
19
19
|
export declare function fitsInline(rt: Content): boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Whether `rt` decodes under `plainSchema` losing nothing but its marks, which the next commit
|
|
22
|
-
* heals (
|
|
22
|
+
* heals (INVARIANTS §"Inline mode"): upstream's `isPlain` with marks set aside.
|
|
23
23
|
*/
|
|
24
24
|
export declare function fitsPlain(rt: Content): boolean;
|
|
25
25
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Decode: content → PM, a pure function (
|
|
1
|
+
// Decode: content → PM, a pure function (INVARIANTS §Decode). Each `\n`-separated segment is one
|
|
2
2
|
// block, its record's `kind` selecting the node; blocks nest by the containers their paths name,
|
|
3
3
|
// a run of blocks sharing a container id being that container; a `U+2028` is a break inside a
|
|
4
4
|
// block; marks apply over their `[start,end)` ranges; island slots lower to leaf nodes. Anchors are
|
|
@@ -69,7 +69,7 @@ export function fitsInline(rt) {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Whether `rt` decodes under `plainSchema` losing nothing but its marks, which the next commit
|
|
72
|
-
* heals (
|
|
72
|
+
* heals (INVARIANTS §"Inline mode"): upstream's `isPlain` with marks set aside.
|
|
73
73
|
*/
|
|
74
74
|
export function fitsPlain(rt) {
|
|
75
75
|
return core().isPlain({ ...rt, marks: [] });
|
|
@@ -29,7 +29,7 @@ export interface CreateFieldOpts {
|
|
|
29
29
|
* Fired when the leaf holds or releases, and at mount when it mounts held. A one-line or `text`
|
|
30
30
|
* leaf is held over a value its schema cannot hold (`fitsLeaf`): the decode would join lines
|
|
31
31
|
* and drop containers and islands. Any leaf is held over what is read and not edited: a font
|
|
32
|
-
* family, a footnote, an equation (
|
|
32
|
+
* family, a footnote, an equation (INVARIANTS §Decode). A held leaf draws on the block schema,
|
|
33
33
|
* read-only, and commits nothing. Judged on each mount and re-hydrate ({@link
|
|
34
34
|
* FieldController.applyExternal}).
|
|
35
35
|
*/
|
|
@@ -93,7 +93,7 @@ export interface CreateFieldOpts {
|
|
|
93
93
|
/** Recovered failures on the commit path ({@link EditorErrorHandler}). */
|
|
94
94
|
onError?: EditorErrorHandler;
|
|
95
95
|
}
|
|
96
|
-
/** The prose-leaf handle (
|
|
96
|
+
/** The prose-leaf handle (INVARIANTS §Surface). */
|
|
97
97
|
export interface FieldController {
|
|
98
98
|
/** The mounted `container`: the leaf's element, for a caller that has to reach the
|
|
99
99
|
* DOM the view sits in (the arrival wash, `core/bloom.ts`) rather than re-find it. */
|
|
@@ -180,7 +180,7 @@ export declare function heldAttributes(opts: {
|
|
|
180
180
|
}, noteId: string | undefined): Record<string, string>;
|
|
181
181
|
export declare function createField(opts: CreateFieldOpts): FieldController;
|
|
182
182
|
/**
|
|
183
|
-
* The prose-leaf plugin stack (
|
|
183
|
+
* The prose-leaf plugin stack (INVARIANTS §Surface), shared by {@link createField} and
|
|
184
184
|
* `ProseValue` so the two never fork the plugin ordering. History first with the step-splitting
|
|
185
185
|
* plugin (`undo.ts`), then `afterHistory` plugins (the addressed leaf's anchor plugin), {@link
|
|
186
186
|
* linebreakPlugin}, the markdown-shorthand input rules and their Backspace, the field keymap over
|
package/dist/core/codec/field.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The prose leaf: `createField` (
|
|
1
|
+
// The prose leaf: `createField` (INVARIANTS §Surface). One content field, one PM view wired to
|
|
2
2
|
// the WASM edit surface.
|
|
3
3
|
//
|
|
4
4
|
// `dispatchTransaction` applies the transaction optimistically, lowers it to a `Change` (or
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// committed and `onCaretMove`. A throw keeps the optimistic PM state and reports through `onError`.
|
|
8
8
|
// An external change re-hydrates through `applyExternal`, gated by `reconcile` except where the
|
|
9
9
|
// hold it re-evaluates flips.
|
|
10
|
-
import { baseKeymap
|
|
10
|
+
import { baseKeymap } from 'prosemirror-commands';
|
|
11
11
|
import { gapCursor } from 'prosemirror-gapcursor';
|
|
12
12
|
import { history, isHistoryTransaction, redo, undo } from 'prosemirror-history';
|
|
13
13
|
import { keymap } from 'prosemirror-keymap';
|
|
@@ -27,6 +27,7 @@ import { contentEqual, createReconciler } from './reconcile.js';
|
|
|
27
27
|
import { inputRulesPlugin, undoRuleKeymap } from './inputrules.js';
|
|
28
28
|
import { linebreakPlugin } from './breaks.js';
|
|
29
29
|
import { bodyKeymap } from './keymap.js';
|
|
30
|
+
import { FIELD_KEYS, markKeymap } from './shortcuts.js';
|
|
30
31
|
import { remoteKey } from './remote.js';
|
|
31
32
|
import { blockSchema, isBlockSchema, isInlineSchema, leafSchema, plainSchema } from './schema.js';
|
|
32
33
|
import { linkPastePlugin } from './link-paste.js';
|
|
@@ -48,7 +49,8 @@ const GHOSTS = 100;
|
|
|
48
49
|
* AnchorEdit} meta. The store's rule, so the commit has nothing to reconcile: a range keeps its
|
|
49
50
|
* edges, text typed at either landing outside it, and a point stays left of text typed at it. A
|
|
50
51
|
* range whose text is wholly deleted goes, and comes back with its text when history puts the
|
|
51
|
-
* deleted slice back ({@link Ghost}); a point never goes.
|
|
52
|
+
* deleted slice back ({@link Ghost}); a point never goes. A range draws as a span carrying
|
|
53
|
+
* `data-qm-anchor`, its id, for a host to style and measure; a point draws nothing.
|
|
52
54
|
*/
|
|
53
55
|
function anchorPlugin(seed) {
|
|
54
56
|
return new Plugin({
|
|
@@ -73,6 +75,14 @@ function anchorPlugin(seed) {
|
|
|
73
75
|
anchors = edit.anchors;
|
|
74
76
|
return { anchors, ghosts: ghosts.slice(-GHOSTS) };
|
|
75
77
|
}
|
|
78
|
+
},
|
|
79
|
+
props: {
|
|
80
|
+
decorations: (state) => {
|
|
81
|
+
const ranged = anchorKey.getState(state)?.anchors.filter((a) => a.end > a.start) ?? [];
|
|
82
|
+
return ranged.length
|
|
83
|
+
? DecorationSet.create(state.doc, ranged.map((a) => Decoration.inline(a.start, a.end, { 'data-qm-anchor': a.id }, { id: a.id })))
|
|
84
|
+
: DecorationSet.empty;
|
|
85
|
+
}
|
|
76
86
|
}
|
|
77
87
|
});
|
|
78
88
|
}
|
|
@@ -147,7 +157,7 @@ function toPM(index, a) {
|
|
|
147
157
|
return { id: a.id, start: offsetToPM(index, a.start), end: offsetToPM(index, a.end) };
|
|
148
158
|
}
|
|
149
159
|
/**
|
|
150
|
-
* Read the leaf's `Content` for `addr` through `reader.getContent` (
|
|
160
|
+
* Read the leaf's `Content` for `addr` through `reader.getContent` (INVARIANTS §"A content field is read through the schema"): the body when
|
|
151
161
|
* `addr.field` is absent. Bound by the declared type rather than a verbatim read, since a string a
|
|
152
162
|
* markdown parse left means markdown for `richtext` and literal text for `text`; reading one as the
|
|
153
163
|
* other eats every `*` the author typed. An absent field (a default-only richtext field before its
|
|
@@ -401,7 +411,7 @@ export function createField(opts) {
|
|
|
401
411
|
}
|
|
402
412
|
/**
|
|
403
413
|
* A `text` leaf's commit: its whole text through the typed writer, resting the field as that
|
|
404
|
-
* literal string (
|
|
414
|
+
* literal string (INVARIANTS §"Inline mode"). The content-object rest form would emit markdown
|
|
405
415
|
* (escaped `*`, backslash breaks) and read back changed. A refusal lands nothing and has no
|
|
406
416
|
* fallback; the next edit writes the whole text again.
|
|
407
417
|
*/
|
|
@@ -615,7 +625,7 @@ export function createField(opts) {
|
|
|
615
625
|
return controller;
|
|
616
626
|
}
|
|
617
627
|
/**
|
|
618
|
-
* The prose-leaf plugin stack (
|
|
628
|
+
* The prose-leaf plugin stack (INVARIANTS §Surface), shared by {@link createField} and
|
|
619
629
|
* `ProseValue` so the two never fork the plugin ordering. History first with the step-splitting
|
|
620
630
|
* plugin (`undo.ts`), then `afterHistory` plugins (the addressed leaf's anchor plugin), {@link
|
|
621
631
|
* linebreakPlugin}, the markdown-shorthand input rules and their Backspace, the field keymap over
|
|
@@ -764,25 +774,16 @@ function ghostPlugin(opts) {
|
|
|
764
774
|
* body's structural keys; Enter suppressed inline.
|
|
765
775
|
*
|
|
766
776
|
* Tab forks on the leaf's role: a one-line or `text` leaf is a form field, Tab unbound so field
|
|
767
|
-
* navigation is open for a shell keymap (
|
|
777
|
+
* navigation is open for a shell keymap (INVARIANTS §Chrome); a block-schema body
|
|
768
778
|
* takes Tab structurally, a chain each nested surface prepends to (`keymap.ts`).
|
|
769
779
|
*/
|
|
770
780
|
function editorKeymap(schema, inline, slash) {
|
|
771
781
|
const map = {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
782
|
+
[FIELD_KEYS.undo]: undo,
|
|
783
|
+
[FIELD_KEYS.redo]: redo,
|
|
784
|
+
[FIELD_KEYS.redoAlt]: redo,
|
|
785
|
+
...markKeymap(schema)
|
|
775
786
|
};
|
|
776
|
-
if (schema.marks.strong)
|
|
777
|
-
map['Mod-b'] = toggleMark(schema.marks.strong);
|
|
778
|
-
if (schema.marks.em)
|
|
779
|
-
map['Mod-i'] = toggleMark(schema.marks.em);
|
|
780
|
-
if (schema.marks.underline)
|
|
781
|
-
map['Mod-u'] = toggleMark(schema.marks.underline);
|
|
782
|
-
if (schema.marks.strike)
|
|
783
|
-
map['Mod-Shift-x'] = toggleMark(schema.marks.strike);
|
|
784
|
-
if (schema.marks.code)
|
|
785
|
-
map['Mod-e'] = toggleMark(schema.marks.code);
|
|
786
787
|
if (inline) {
|
|
787
788
|
// One textblock only: swallow Enter, and Shift-Enter with it (the schema declares no break
|
|
788
789
|
// node; a declined key is the browser's native `<br>`).
|
|
@@ -9,6 +9,8 @@ export { DEFAULT_TABLE_STRINGS } from './table-view.js';
|
|
|
9
9
|
export type { TableChromeStrings } from './table-view.js';
|
|
10
10
|
export { DEFAULT_SLASH_STRINGS } from './slash.js';
|
|
11
11
|
export type { SlashState, SlashStrings } from './slash.js';
|
|
12
|
+
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, editorShortcuts } from './shortcuts.js';
|
|
13
|
+
export type { EditorShortcut, ShortcutScope, ShortcutStrings } from './shortcuts.js';
|
|
12
14
|
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, hasMarks } from './schema.js';
|
|
13
15
|
export { rendersHref, storableUrl } from './urls.js';
|
|
14
16
|
export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
|
package/dist/core/codec/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The codec barrel: the bidirectional bridge between one content field (`Content`)
|
|
2
|
-
// and one ProseMirror document (
|
|
2
|
+
// and one ProseMirror document (INVARIANTS §"The codec"). Decode (content → PM), lower (PM doc → a
|
|
3
3
|
// `Change` for `apply`), the UTF-16↔PM position map, and the `createField`
|
|
4
4
|
// prose leaf. Consumed by the VisualEditor and the codec test suite.
|
|
5
5
|
// ProseMirror's structural base styles and the gap cursor's, then the retint of the
|
|
@@ -22,6 +22,10 @@ export { DEFAULT_TABLE_STRINGS } from './table-view.js';
|
|
|
22
22
|
// The slash menu: the codec owns the model and the picks, the chrome the words and
|
|
23
23
|
// the pixels (`visual/SlashMenu.svelte` is the only off-barrel caller).
|
|
24
24
|
export { DEFAULT_SLASH_STRINGS } from './slash.js';
|
|
25
|
+
// The rich editor's shortcuts as a host lists them, read off the tables the keymaps bind from;
|
|
26
|
+
// the visual tier's `strings` set extends their wording, and the formatting popover binds its
|
|
27
|
+
// link chord from `FIELD_KEYS`.
|
|
28
|
+
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, editorShortcuts } from './shortcuts.js';
|
|
25
29
|
// Schemas (the decode/encode target; the VisualEditor mounts them). `hasMarks` is
|
|
26
30
|
// what a mark surface asks before offering itself over a leaf.
|
|
27
31
|
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, leafSchema, hasMarks } from './schema.js';
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
//
|
|
10
10
|
// A rule declines only where what it would mint is unrepresentable, or is a shape
|
|
11
11
|
// another gesture owns — never on how a quill renders it. What a quill typesets is not
|
|
12
|
-
// knowable here (a quill this build has not seen is the open-sets case,
|
|
13
|
-
//
|
|
14
|
-
// a document opens carrying a shape the editor refuses to make. So one rule answers
|
|
12
|
+
// knowable here (a quill this build has not seen is the open-sets case,
|
|
13
|
+
// INVARIANTS §Vocabularies), and a construct that arrives through `importMarkdown` must stay
|
|
14
|
+
// authorable or a document opens carrying a shape the editor refuses to make. So one rule answers
|
|
15
15
|
// otherwise: `- ` / `1. ` at the head of an existing item retypes the item's list, where
|
|
16
16
|
// a wrap would nest and Tab owns the nesting. A marker the item already shows, and `a. `,
|
|
17
17
|
// `(1) `, `(a) ` in a nested item, are taken as typed and change nothing.
|
|
@@ -15,7 +15,7 @@ export declare const islandBlockSpec: NodeSpec;
|
|
|
15
15
|
export declare const islandInlineSpec: NodeSpec;
|
|
16
16
|
/**
|
|
17
17
|
* A PM island node's attributes: the content entry, with `islandType` because `type` on a PM node
|
|
18
|
-
* is the node type; its set comes off the entry (
|
|
18
|
+
* is the node type; its set comes off the entry (INVARIANTS §"The boundary").
|
|
19
19
|
*/
|
|
20
20
|
export interface IslandNodeAttrs {
|
|
21
21
|
id: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// other type inline. The node carries `id`, `islandType`, `props` and `slots` verbatim, and a block
|
|
4
4
|
// island the id of the block it fills.
|
|
5
5
|
//
|
|
6
|
-
// `ContentIsland.props` is the typed union at the boundary (
|
|
6
|
+
// `ContentIsland.props` is the typed union at the boundary (INVARIANTS §"The boundary"), so a
|
|
7
7
|
// discriminant check narrows it; `props` still crosses the DOM as opaque JSON, which
|
|
8
8
|
// `table.ts` §`tableOfNode` guards.
|
|
9
9
|
import { Fragment, Slice } from 'prosemirror-model';
|
|
@@ -24,7 +24,7 @@ const islandAttrs = {
|
|
|
24
24
|
slots: { default: null }
|
|
25
25
|
};
|
|
26
26
|
// All three attributes cross the DOM, since a copy and a paste inside one body run the document
|
|
27
|
-
// through `toDOM`/`parseDOM` (
|
|
27
|
+
// through `toDOM`/`parseDOM` (INVARIANTS §"Markdown at the edges") and an island's tags alone say only
|
|
28
28
|
// `[table]`. `props` crosses as JSON. The names are `data-qm-*`, and the id is required: an island
|
|
29
29
|
// is a leaf, so a rule reading someone else's tag would swallow that element's whole subtree.
|
|
30
30
|
/** The DOM an island node writes and reads back, for either spec. */
|
|
@@ -160,7 +160,7 @@ export function isTableProps(props) {
|
|
|
160
160
|
/**
|
|
161
161
|
* A minter over one document: the positional `isl-{n}` sequence continued past the highest id the
|
|
162
162
|
* field holds, so a caller placing several islands keeps one minter. A minted id is part of the
|
|
163
|
-
* document's canonical bytes (
|
|
163
|
+
* document's canonical bytes (INVARIANTS §Islands): a counter over the projection in hand, never a UUID
|
|
164
164
|
* or clock reading, and never a re-numbering of existing ids.
|
|
165
165
|
*
|
|
166
166
|
* Reads the PM doc rather than stored content because that is what the caller holds and the commit
|
|
@@ -3,7 +3,7 @@ import type { Command } from 'prosemirror-state';
|
|
|
3
3
|
/** A multi-block leaf's structural keys, each link binding only what its schema
|
|
4
4
|
* declares: over `plainSchema`, which holds neither lists nor code blocks nor islands,
|
|
5
5
|
* the block link and the break link alone. The argument list is the precedence order
|
|
6
|
-
*
|
|
6
|
+
* INVARIANTS §Chrome, so a new link is one more argument at its place in that
|
|
7
7
|
* order rather than a nesting to read inside out.
|
|
8
8
|
*
|
|
9
9
|
* The slash menu is innermost of the three, and it is conditional rather than
|
|
@@ -6,6 +6,7 @@ import { codeKeymap } from './code.js';
|
|
|
6
6
|
import { listKeymap } from './lists.js';
|
|
7
7
|
import { listMoveKeymap } from './list-move.js';
|
|
8
8
|
import { slashKeymap } from './slash.js';
|
|
9
|
+
import { BODY_KEYS } from './shortcuts.js';
|
|
9
10
|
/** One chain per key, the maps taken in precedence order: on a key several bind, an
|
|
10
11
|
* earlier map's command runs first and the next runs only if it declines. A key one
|
|
11
12
|
* map alone binds is its own. No input is mutated. */
|
|
@@ -27,7 +28,7 @@ function exitKeymap(schema) {
|
|
|
27
28
|
return {
|
|
28
29
|
Tab: () => true,
|
|
29
30
|
'Shift-Tab': () => true,
|
|
30
|
-
|
|
31
|
+
[BODY_KEYS.leave]: (_state, _dispatch, view) => {
|
|
31
32
|
if (!view)
|
|
32
33
|
return false;
|
|
33
34
|
view.dom.blur();
|
|
@@ -38,7 +39,7 @@ function exitKeymap(schema) {
|
|
|
38
39
|
/** A multi-block leaf's structural keys, each link binding only what its schema
|
|
39
40
|
* declares: over `plainSchema`, which holds neither lists nor code blocks nor islands,
|
|
40
41
|
* the block link and the break link alone. The argument list is the precedence order
|
|
41
|
-
*
|
|
42
|
+
* INVARIANTS §Chrome, so a new link is one more argument at its place in that
|
|
42
43
|
* order rather than a nesting to read inside out.
|
|
43
44
|
*
|
|
44
45
|
* The slash menu is innermost of the three, and it is conditional rather than
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isList } from './list-node.js';
|
|
2
|
+
import { LIST_KEYS } from './shortcuts.js';
|
|
2
3
|
/** The items the selection stands in, in the innermost list holding all of them, moved
|
|
3
4
|
* one place up (`-1`) or down (`1`). */
|
|
4
5
|
function moveItems(dir) {
|
|
@@ -26,5 +27,5 @@ function moveItems(dir) {
|
|
|
26
27
|
export function listMoveKeymap(schema) {
|
|
27
28
|
if (!schema.nodes.list_item)
|
|
28
29
|
return {};
|
|
29
|
-
return {
|
|
30
|
+
return { [LIST_KEYS.moveUp]: moveItems(-1), [LIST_KEYS.moveDown]: moveItems(1) };
|
|
30
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// A pasted list takes the numbering of where it lands (
|
|
1
|
+
// A pasted list takes the numbering of where it lands (INVARIANTS §"Markdown at the edges").
|
|
2
2
|
// An item's number is its position, so a paste counts where it stands: items pasted into
|
|
3
3
|
// a list are that list's next items, of its kind and in its count, and items pasted on
|
|
4
4
|
// the empty line a list was just left by are the same list's. A list pasted on a line of
|
|
@@ -5,7 +5,7 @@ import type { Command } from 'prosemirror-state';
|
|
|
5
5
|
* no list nodes.
|
|
6
6
|
*
|
|
7
7
|
* `Tab` / `Shift-Tab` hold the list link of the body's Tab chain; surfaces owning Tab more locally
|
|
8
|
-
* prepend a link in `keymap.ts` (
|
|
8
|
+
* prepend a link in `keymap.ts` (INVARIANTS §Chrome). `Tab` sinks an unnumbered
|
|
9
9
|
* line alone into a sub-list, any other line its whole item, and a block right after a list into
|
|
10
10
|
* the list's last item. `Mod-Shift-7` / `Mod-Shift-8` are the list toggle (`list-toggle.ts`).
|
|
11
11
|
* `Mod-Enter` ticks the task item around the caret (`toggleTask`).
|
package/dist/core/codec/lists.js
CHANGED
|
@@ -21,6 +21,7 @@ import { withinNesting } from './nesting.js';
|
|
|
21
21
|
import { toggleList } from './list-toggle.js';
|
|
22
22
|
import { splitTaskItem, toggleTask } from './tasks.js';
|
|
23
23
|
import { joinAll, joinLists, touching } from './touching.js';
|
|
24
|
+
import { LIST_KEYS } from './shortcuts.js';
|
|
24
25
|
/**
|
|
25
26
|
* The caret's enclosing `list_item` when it sits at the very start of that item's first block,
|
|
26
27
|
* where both structural keys branch; `null` otherwise.
|
|
@@ -473,7 +474,7 @@ function sinkIntoList(itemType) {
|
|
|
473
474
|
* no list nodes.
|
|
474
475
|
*
|
|
475
476
|
* `Tab` / `Shift-Tab` hold the list link of the body's Tab chain; surfaces owning Tab more locally
|
|
476
|
-
* prepend a link in `keymap.ts` (
|
|
477
|
+
* prepend a link in `keymap.ts` (INVARIANTS §Chrome). `Tab` sinks an unnumbered
|
|
477
478
|
* line alone into a sub-list, any other line its whole item, and a block right after a list into
|
|
478
479
|
* the list's last item. `Mod-Shift-7` / `Mod-Shift-8` are the list toggle (`list-toggle.ts`).
|
|
479
480
|
* `Mod-Enter` ticks the task item around the caret (`toggleTask`).
|
|
@@ -497,11 +498,11 @@ export function listKeymap(schema) {
|
|
|
497
498
|
return {};
|
|
498
499
|
const backspace = chainCommands(markerOff(itemType), joinOntoList(itemType));
|
|
499
500
|
return {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
501
|
+
[LIST_KEYS.numbered]: toggleList(true),
|
|
502
|
+
[LIST_KEYS.bulleted]: toggleList(false),
|
|
503
|
+
[LIST_KEYS.indent]: chainCommands(sinkLine(itemType), sinkWithin(itemType), sinkIntoList(itemType)),
|
|
504
|
+
[LIST_KEYS.outdent]: outdent(itemType),
|
|
505
|
+
[LIST_KEYS.task]: toggleTask(itemType),
|
|
505
506
|
Enter: chainCommands(lineAbove(itemType, paragraph), lineOutOfMiddle(itemType), markerOn(itemType), splitTaskItem(itemType), liftListItem(itemType)),
|
|
506
507
|
Backspace: chainCommands(deleteAcross, markerOff(itemType), lineOut(itemType), joinOntoList(itemType)),
|
|
507
508
|
Delete: chainCommands(deleteAcross, deleteBelow(itemType, backspace))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Markdown on the clipboard as text lands parsed in a block leaf (
|
|
2
|
-
// edges"). A line opening a block is the shape a draft written in Notepad or copied out of
|
|
1
|
+
// Markdown on the clipboard as text lands parsed in a block leaf (INVARIANTS §"Markdown at
|
|
2
|
+
// the edges"). A line opening a block is the shape a draft written in Notepad or copied out of
|
|
3
3
|
// an LLM chat carries, and text holding one runs through `importMarkdown` and `decode`, so
|
|
4
4
|
// the paste stores what the source editor stores of the same text. Text holding none stays
|
|
5
5
|
// literal: a sentence with a dash in it, or a `**` with no block around it, keeps every
|
|
@@ -147,7 +147,7 @@ li.ProseMirror-selectednode::after {
|
|
|
147
147
|
pointer-events: none;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
/* A footnote and an equation are read, not edited (
|
|
150
|
+
/* A footnote and an equation are read, not edited (INVARIANTS §Decode), and draw as what
|
|
151
151
|
their markdown writes: a footnote its reference mark, numbered in reading order off a
|
|
152
152
|
counter each leaf resets, its note the marker's title (`islands.ts`); an equation its
|
|
153
153
|
TeX between its dollars, in the code face. */
|
|
@@ -589,7 +589,7 @@ li.ProseMirror-selectednode::after {
|
|
|
589
589
|
top: 100%;
|
|
590
590
|
height: var(--_qm-tap-min);
|
|
591
591
|
}
|
|
592
|
-
/* The reveal is the control's own (
|
|
592
|
+
/* The reveal is the control's own (INVARIANTS §"The table island"): one comes up while the
|
|
593
593
|
pointer is on that control, or while it is what a gesture is about — the selected line's grip, and the lifted one, which is drawn through a drag the
|
|
594
594
|
pointer has travelled off. A cell under the pointer draws its row's and its column's
|
|
595
595
|
grips (`table-view.ts` §`onHover`), one pill on each axis and none anywhere else.
|
|
@@ -651,7 +651,7 @@ li.ProseMirror-selectednode::after {
|
|
|
651
651
|
first row, the band's top edge being the grips'. Up only while its column is held and
|
|
652
652
|
absent otherwise (`table-view.ts` §`alignCluster`), so the reveal is `hidden` rather
|
|
653
653
|
than the band's opacity. It is a row of glyphs floating over text, the format popover's
|
|
654
|
-
family (
|
|
654
|
+
family (INVARIANTS §Styling), and takes that recipe: the popover's translucent
|
|
655
655
|
surface over a blur, the edge and `--_qm-lift` for its separation, and a scale-in on
|
|
656
656
|
arrival, stated from its starting style since the codec shows it by clearing
|
|
657
657
|
`hidden`. Its geometry is the popover's too, a row of toggles held one rung in from
|
|
@@ -11,7 +11,7 @@ export declare const inlineSchema: Schema<string, string>;
|
|
|
11
11
|
* The inline schema with no mark types: a `plaintext(inline)` field, whose value is literal text
|
|
12
12
|
* the boundary refuses to coerce back once it carries a mark. Declaring none makes that structural:
|
|
13
13
|
* `toggleMark` has no type, the mark input rules build nothing, a paste parses marks away, and
|
|
14
|
-
* `decode` drops any a stray content carries (
|
|
14
|
+
* `decode` drops any a stray content carries (INVARIANTS §"Inline mode").
|
|
15
15
|
*/
|
|
16
16
|
export declare const plaintextSchema: Schema<string, never>;
|
|
17
17
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// with hard breaks, for a table cell. Anchors are not marks here (decorations).
|
|
8
8
|
//
|
|
9
9
|
// `toDOM` and `parseDOM` are one tier: a copy and a paste inside one body run the whole document
|
|
10
|
-
// through them (
|
|
10
|
+
// through them (INVARIANTS §"Markdown at the edges"), so every attribute written here is read back here.
|
|
11
11
|
// Foreign HTML spells none of this package's `data-qm-*` names; the rules that widen that door on
|
|
12
12
|
// purpose are the fence's and a span's styled marks, a `<table>` being the block leaf's clipboard
|
|
13
13
|
// parser's (`table-paste.ts`).
|
|
@@ -210,7 +210,7 @@ const blockNodes = {
|
|
|
210
210
|
// A list stating no `start` starts at one, the absence `toDOM` writes;
|
|
211
211
|
// `Number(null)` would read it as zero. A value the store would normalize away
|
|
212
212
|
// reads as that absence too, since a PM doc keeping one would disagree with the
|
|
213
|
-
// store for the session (
|
|
213
|
+
// store for the session (INVARIANTS §Reconciliation). Zero is not one: `0.` is an
|
|
214
214
|
// ordinal `importMarkdown` produces.
|
|
215
215
|
const stated = el.getAttribute('start');
|
|
216
216
|
const start = stated ? Number(stated) : 1;
|
|
@@ -279,7 +279,7 @@ export const inlineSchema = new Schema({ nodes: inlineNodes, marks });
|
|
|
279
279
|
* The inline schema with no mark types: a `plaintext(inline)` field, whose value is literal text
|
|
280
280
|
* the boundary refuses to coerce back once it carries a mark. Declaring none makes that structural:
|
|
281
281
|
* `toggleMark` has no type, the mark input rules build nothing, a paste parses marks away, and
|
|
282
|
-
* `decode` drops any a stray content carries (
|
|
282
|
+
* `decode` drops any a stray content carries (INVARIANTS §"Inline mode").
|
|
283
283
|
*/
|
|
284
284
|
export const plaintextSchema = new Schema({ nodes: inlineNodes, marks: {} });
|
|
285
285
|
/**
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Schema } from 'prosemirror-model';
|
|
2
|
+
import type { Command } from 'prosemirror-state';
|
|
3
|
+
/** Every prose leaf, a table cell included: history and the marks. `link` binds in the
|
|
4
|
+
* formatting popover, which is the surface that prompts for the URL. */
|
|
5
|
+
export declare const FIELD_KEYS: {
|
|
6
|
+
readonly undo: "Mod-z";
|
|
7
|
+
readonly redo: "Mod-Shift-z";
|
|
8
|
+
readonly redoAlt: "Mod-y";
|
|
9
|
+
readonly bold: "Mod-b";
|
|
10
|
+
readonly italic: "Mod-i";
|
|
11
|
+
readonly underline: "Mod-u";
|
|
12
|
+
readonly strike: "Mod-Shift-x";
|
|
13
|
+
readonly code: "Mod-e";
|
|
14
|
+
readonly link: "Mod-k";
|
|
15
|
+
};
|
|
16
|
+
/** A multi-block body, outside any surface nested in it. */
|
|
17
|
+
export declare const BODY_KEYS: {
|
|
18
|
+
readonly lineBreak: "Shift-Enter";
|
|
19
|
+
readonly leave: "Escape";
|
|
20
|
+
};
|
|
21
|
+
/** A list item (`lists.ts`, `list-move.ts`). */
|
|
22
|
+
export declare const LIST_KEYS: {
|
|
23
|
+
readonly numbered: "Mod-Shift-7";
|
|
24
|
+
readonly bulleted: "Mod-Shift-8";
|
|
25
|
+
readonly indent: "Tab";
|
|
26
|
+
readonly outdent: "Shift-Tab";
|
|
27
|
+
readonly task: "Mod-Enter";
|
|
28
|
+
readonly moveUp: "Alt-ArrowUp";
|
|
29
|
+
readonly moveDown: "Alt-ArrowDown";
|
|
30
|
+
};
|
|
31
|
+
/** A table island's cell (`table-view.ts`). */
|
|
32
|
+
export declare const TABLE_KEYS: {
|
|
33
|
+
readonly next: "Tab";
|
|
34
|
+
readonly previous: "Shift-Tab";
|
|
35
|
+
readonly nextRow: "Enter";
|
|
36
|
+
readonly select: "Escape";
|
|
37
|
+
readonly selectAll: "Mod-a";
|
|
38
|
+
readonly moveUp: "Alt-ArrowUp";
|
|
39
|
+
readonly moveDown: "Alt-ArrowDown";
|
|
40
|
+
readonly moveLeft: "Alt-ArrowLeft";
|
|
41
|
+
readonly moveRight: "Alt-ArrowRight";
|
|
42
|
+
readonly alignLeft: "Shift-ArrowLeft";
|
|
43
|
+
readonly alignRight: "Shift-ArrowRight";
|
|
44
|
+
readonly erase: "Backspace";
|
|
45
|
+
readonly eraseAlt: "Delete";
|
|
46
|
+
};
|
|
47
|
+
/** The mark toggles, each bound only where the schema declares its mark. */
|
|
48
|
+
export declare function markKeymap(schema: Schema): Record<string, Command>;
|
|
49
|
+
/** Where a shortcut answers: any prose field, a multi-block body, a list item, a table cell. */
|
|
50
|
+
export type ShortcutScope = 'field' | 'body' | 'list' | 'table';
|
|
51
|
+
/** One shortcut as a host lists it. `keys` are the alternatives in `prosemirror-keymap`
|
|
52
|
+
* notation (`Mod-Shift-7`, `Alt-ArrowUp`): `Mod` is ⌘ on Apple platforms and Ctrl
|
|
53
|
+
* elsewhere, and the host prints them. */
|
|
54
|
+
export interface EditorShortcut {
|
|
55
|
+
keys: readonly string[];
|
|
56
|
+
label: string;
|
|
57
|
+
scope: ShortcutScope;
|
|
58
|
+
}
|
|
59
|
+
/** A shortcut's description, the gesture it names: a list's line, not a tooltip. */
|
|
60
|
+
export interface ShortcutStrings {
|
|
61
|
+
shortcutUndo: string;
|
|
62
|
+
shortcutRedo: string;
|
|
63
|
+
shortcutBold: string;
|
|
64
|
+
shortcutItalic: string;
|
|
65
|
+
shortcutUnderline: string;
|
|
66
|
+
shortcutStrikethrough: string;
|
|
67
|
+
shortcutCode: string;
|
|
68
|
+
shortcutLink: string;
|
|
69
|
+
shortcutLineBreak: string;
|
|
70
|
+
shortcutLeave: string;
|
|
71
|
+
shortcutNumberedList: string;
|
|
72
|
+
shortcutBulletedList: string;
|
|
73
|
+
shortcutIndent: string;
|
|
74
|
+
shortcutOutdent: string;
|
|
75
|
+
shortcutTask: string;
|
|
76
|
+
shortcutMoveItem: string;
|
|
77
|
+
shortcutNextCell: string;
|
|
78
|
+
shortcutPreviousCell: string;
|
|
79
|
+
shortcutNextRow: string;
|
|
80
|
+
shortcutSelectCells: string;
|
|
81
|
+
shortcutSelectRow: string;
|
|
82
|
+
shortcutMoveLine: string;
|
|
83
|
+
shortcutAlignColumn: string;
|
|
84
|
+
shortcutDeleteCells: string;
|
|
85
|
+
}
|
|
86
|
+
export declare const DEFAULT_SHORTCUT_STRINGS: ShortcutStrings;
|
|
87
|
+
/**
|
|
88
|
+
* The rich editor's shortcuts, worded by `strings` (the package's English where a key is unset),
|
|
89
|
+
* so a host's shortcut list is read off the bindings rather than copied from them.
|
|
90
|
+
*/
|
|
91
|
+
export declare function editorShortcuts(strings?: Partial<ShortcutStrings>): EditorShortcut[];
|