@quillmark/svelte 0.30.0 → 0.31.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 +2 -2
- package/dist/core/codec/decode.d.ts +3 -2
- package/dist/core/codec/decode.js +15 -11
- package/dist/core/codec/field.d.ts +2 -1
- package/dist/core/codec/field.js +119 -30
- package/dist/core/codec/positions.d.ts +12 -1
- package/dist/core/codec/prose.css +0 -8
- package/dist/core/codec/schema.d.ts +2 -2
- package/dist/core/codec/schema.js +3 -3
- package/dist/core/codec/slash.d.ts +4 -2
- package/dist/core/codec/slash.js +11 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/theme.css +14 -6
- package/dist/visual/ArrayField.svelte +167 -82
- package/dist/visual/BooleanField.svelte +2 -2
- package/dist/visual/Card.svelte +65 -44
- package/dist/visual/DateField.svelte +16 -1
- package/dist/visual/DiagnosticList.svelte +34 -2
- package/dist/visual/EnumField.svelte +58 -44
- package/dist/visual/Field.svelte +13 -3
- package/dist/visual/Field.svelte.d.ts +3 -1
- package/dist/visual/FieldHint.svelte +10 -3
- package/dist/visual/MatrixAdd.svelte +3 -18
- package/dist/visual/MatrixField.svelte +20 -12
- package/dist/visual/ObjectField.svelte +164 -145
- package/dist/visual/ProseField.svelte +6 -1
- package/dist/visual/SlashMenu.svelte +24 -12
- package/dist/visual/SlashMenu.svelte.d.ts +2 -0
- package/dist/visual/VisualEditor.svelte +1 -1
- package/dist/visual/VisualEditor.svelte.d.ts +1 -1
- package/dist/visual/VisualEditorInner.svelte +144 -9
- package/dist/visual/VisualEditorInner.svelte.d.ts +1 -1
- package/dist/visual/controls.css +42 -4
- package/dist/visual/strings.d.ts +27 -10
- package/dist/visual/strings.js +40 -6
- package/dist/visual/structure.d.ts +17 -9
- package/dist/visual/structure.js +19 -16
- package/dist/visual/undo.svelte.d.ts +36 -0
- package/dist/visual/undo.svelte.js +119 -0
- package/package.json +2 -2
- package/dist/visual/hold.d.ts +0 -17
- package/dist/visual/hold.js +0 -39
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ const quill = Quill.fromTree(tree); // tree: Map<string, Uint8Array> of the quil
|
|
|
39
39
|
const doc = quill.seedDocument();
|
|
40
40
|
|
|
41
41
|
// An EXISTING document: parsed back from what you stored.
|
|
42
|
-
const doc = Document.
|
|
42
|
+
const doc = Document.parse(markdown); // canonical Quillmark markdown
|
|
43
43
|
const doc = Document.fromStored(json); // the versioned storage DTO (`doc.toStored()`)
|
|
44
44
|
|
|
45
45
|
const session = await new Engine().open(quill, doc);
|
|
@@ -53,7 +53,7 @@ const session = await new Engine().open(quill, doc);
|
|
|
53
53
|
A stored document carries none of its quill's bytes, only a reference: `doc.quillRef` is `name@version`, persisted in the markdown itself. Resolution is **host code**: read the ref, map it to a `Quill`, open. No surface resolves, so one resolution per document holds by construction.
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
|
-
const doc = Document.
|
|
56
|
+
const doc = Document.parse(stored); // Document, from the gate above
|
|
57
57
|
const quill = await registry.getQuill(doc.quillRef); // your ref → Quill mapping
|
|
58
58
|
const session = await new Engine().open(quill, doc);
|
|
59
59
|
```
|
|
@@ -12,8 +12,9 @@ export declare function renderContent(rt: Content, schema: Schema): Node;
|
|
|
12
12
|
export declare function decode(rt: Content, schema: Schema): PMNode;
|
|
13
13
|
/**
|
|
14
14
|
* Whether `rt` decodes under an inline schema with nothing but whitespace dropped: upstream's
|
|
15
|
-
* one-line rule, or one plain line and the
|
|
16
|
-
* scalar keeps in a `text` value). Marks are the
|
|
15
|
+
* one-line rule, or one plain line and the break a trailing `\n` spells (the one a YAML `|`
|
|
16
|
+
* scalar keeps in a `text` value), or the empty line a trailing blank line opens. Marks are the
|
|
17
|
+
* schema's business.
|
|
17
18
|
*/
|
|
18
19
|
export declare function fitsInline(rt: Content): boolean;
|
|
19
20
|
/**
|
|
@@ -52,18 +52,20 @@ export function decode(rt, schema) {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Whether `rt` decodes under an inline schema with nothing but whitespace dropped: upstream's
|
|
55
|
-
* one-line rule, or one plain line and the
|
|
56
|
-
* scalar keeps in a `text` value). Marks are the
|
|
55
|
+
* one-line rule, or one plain line and the break a trailing `\n` spells (the one a YAML `|`
|
|
56
|
+
* scalar keeps in a `text` value), or the empty line a trailing blank line opens. Marks are the
|
|
57
|
+
* schema's business.
|
|
57
58
|
*/
|
|
58
59
|
export function fitsInline(rt) {
|
|
59
60
|
if (core().isInline(rt))
|
|
60
61
|
return true;
|
|
61
62
|
const plain = (b) => b.kind === 'para' && !b.path?.length;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
if (rt.islands?.length || !rt.blocks.every(plain))
|
|
64
|
+
return false;
|
|
65
|
+
const breaks = rt.text.split(HARD_BREAK).length - 1;
|
|
66
|
+
if (rt.blocks.length === 1)
|
|
67
|
+
return breaks === 1 && rt.text.endsWith(HARD_BREAK);
|
|
68
|
+
return rt.blocks.length === 2 && rt.text.endsWith('\n') && breaks === 0;
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Whether `rt` decodes under `plainSchema` losing nothing but its marks, which the next commit
|
|
@@ -91,12 +93,14 @@ export function fitsLeaf(rt, leaf) {
|
|
|
91
93
|
}
|
|
92
94
|
/** Inline decode: one paragraph, containers and islands stripped. */
|
|
93
95
|
function decodeInline(schema, segments, marks, cursor) {
|
|
94
|
-
// An inline field is single-line: stray blocks and breaks join with a space. The
|
|
95
|
-
// trailing `\n`
|
|
96
|
-
// representable inline: the slot char is
|
|
96
|
+
// An inline field is single-line: stray blocks and breaks join with a space. The break a
|
|
97
|
+
// trailing `\n` spells, and the empty block a trailing blank line opens, are dropped, so a first
|
|
98
|
+
// edit stores no space nobody typed. Islands are not representable inline: the slot char is
|
|
99
|
+
// dropped and its entry skipped.
|
|
97
100
|
const inline = [];
|
|
98
101
|
const last = segments.length - 1;
|
|
99
|
-
segments.forEach((
|
|
102
|
+
segments.forEach((at, i) => {
|
|
103
|
+
const seg = i === last && at.text.endsWith(HARD_BREAK) ? { ...at, text: at.text.slice(0, -1) } : at;
|
|
100
104
|
if (i > 0 && i === last && seg.text === '')
|
|
101
105
|
return;
|
|
102
106
|
if (i > 0)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type Schema } from 'prosemirror-model';
|
|
2
2
|
import { Plugin } from 'prosemirror-state';
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
|
-
import type { Document, Content, Addr,
|
|
4
|
+
import type { Document, Content, Addr, Quill } from '@quillmark/wasm';
|
|
5
5
|
import type { EditorErrorHandler } from '../errors.js';
|
|
6
|
+
import { type Delta } from './positions.js';
|
|
6
7
|
import { type TextCap } from './cap.js';
|
|
7
8
|
import { type TableChromeStrings } from './table-view.js';
|
|
8
9
|
import { type SlashState, type SlashStrings } from './slash.js';
|
package/dist/core/codec/field.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// hold it re-evaluates flips.
|
|
10
10
|
import { baseKeymap, toggleMark } from 'prosemirror-commands';
|
|
11
11
|
import { gapCursor } from 'prosemirror-gapcursor';
|
|
12
|
-
import { history, redo, undo } from 'prosemirror-history';
|
|
12
|
+
import { history, isHistoryTransaction, redo, undo } from 'prosemirror-history';
|
|
13
13
|
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';
|
|
@@ -21,7 +21,7 @@ import { decode, fitsLeaf } from './decode.js';
|
|
|
21
21
|
import { offsetToPM, pmToOffset, buildLineIndex, lineIndexOf, mapThroughDelta } from './positions.js';
|
|
22
22
|
import { lower, pmToContent, scanContent, scanDoc } from './encode.js';
|
|
23
23
|
import { capPlugin } from './cap.js';
|
|
24
|
-
import {
|
|
24
|
+
import { islandPastePlugin } from './islands.js';
|
|
25
25
|
import { anchorsFromContent } from './marks.js';
|
|
26
26
|
import { contentEqual, createReconciler } from './reconcile.js';
|
|
27
27
|
import { inputRulesPlugin, undoRuleKeymap } from './inputrules.js';
|
|
@@ -42,41 +42,106 @@ import { taskPlugin } from './tasks.js';
|
|
|
42
42
|
import { DEFAULT_TABLE_STRINGS, tableNodeView } from './table-view.js';
|
|
43
43
|
import { DEFAULT_SLASH_STRINGS, focusSlashItem, runSlashItem, slashPlugin } from './slash.js';
|
|
44
44
|
const anchorKey = new PluginKey('quill-anchors');
|
|
45
|
+
const GHOSTS = 100;
|
|
45
46
|
/**
|
|
46
47
|
* Plugin-held anchors (PM coords), mapped through every edit's `StepMap` and mutated by an {@link
|
|
47
48
|
* AnchorEdit} meta. The store's rule, so the commit has nothing to reconcile: a range keeps its
|
|
48
49
|
* edges, text typed at either landing outside it, and a point stays left of text typed at it. A
|
|
49
|
-
* range whose text is wholly deleted goes
|
|
50
|
+
* 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.
|
|
50
52
|
*/
|
|
51
53
|
function anchorPlugin(seed) {
|
|
52
54
|
return new Plugin({
|
|
53
55
|
key: anchorKey,
|
|
54
56
|
state: {
|
|
55
|
-
init: () => seed,
|
|
56
|
-
apply: (tr,
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const start = tr.mapping.map(a.start, 1);
|
|
64
|
-
const end = tr.mapping.map(a.end, -1);
|
|
65
|
-
return start < end ? [{ id: a.id, start, end }] : [];
|
|
66
|
-
})
|
|
67
|
-
: anchors;
|
|
57
|
+
init: () => ({ anchors: seed, ghosts: [] }),
|
|
58
|
+
apply: (tr, held) => {
|
|
59
|
+
let { anchors, ghosts } = held;
|
|
60
|
+
if (tr.docChanged) {
|
|
61
|
+
const undoing = isHistoryTransaction(tr);
|
|
62
|
+
for (const map of tr.mapping.maps)
|
|
63
|
+
({ anchors, ghosts } = mapAnchors(map, anchors, ghosts, undoing));
|
|
64
|
+
}
|
|
68
65
|
const edit = tr.getMeta(anchorKey);
|
|
69
66
|
if (edit?.op === 'add')
|
|
70
|
-
|
|
71
|
-
else if (edit?.op === 'remove')
|
|
72
|
-
|
|
67
|
+
anchors = [...anchors, { id: edit.id, start: edit.start, end: edit.end }];
|
|
68
|
+
else if (edit?.op === 'remove') {
|
|
69
|
+
anchors = anchors.filter((a) => a.id !== edit.id);
|
|
70
|
+
ghosts = ghosts.filter((g) => g.id !== edit.id);
|
|
71
|
+
}
|
|
73
72
|
else if (edit?.op === 'reset')
|
|
74
|
-
|
|
75
|
-
return
|
|
73
|
+
anchors = edit.anchors;
|
|
74
|
+
return { anchors, ghosts: ghosts.slice(-GHOSTS) };
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
}
|
|
79
|
+
/** The replaced range of `map` holding `[from, to]`, where one does. */
|
|
80
|
+
function rangeOf(map, from, to) {
|
|
81
|
+
let hit;
|
|
82
|
+
map.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
83
|
+
if (!hit && oldStart <= from && to <= oldEnd)
|
|
84
|
+
hit = { oldStart, oldEnd, newStart, newEnd };
|
|
85
|
+
});
|
|
86
|
+
return hit;
|
|
87
|
+
}
|
|
88
|
+
/** One step's map over the anchors and ghosts: a range the step deletes whole becomes a ghost,
|
|
89
|
+
* and under a history step a ghost whose slice comes back whole becomes its anchor again. */
|
|
90
|
+
function mapAnchors(map, anchors, ghosts, undoing) {
|
|
91
|
+
const nextAnchors = [];
|
|
92
|
+
const nextGhosts = [];
|
|
93
|
+
for (const g of ghosts) {
|
|
94
|
+
const range = rangeOf(map, g.at, g.at);
|
|
95
|
+
if (!range) {
|
|
96
|
+
nextGhosts.push({ ...g, at: map.map(g.at, -1) });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const { oldStart, oldEnd, newStart, newEnd } = range;
|
|
100
|
+
if (undoing && newEnd - newStart === g.lead + g.len + g.trail) {
|
|
101
|
+
if (g.inner)
|
|
102
|
+
nextGhosts.push({ ...g.inner, at: newStart + g.lead });
|
|
103
|
+
else
|
|
104
|
+
nextAnchors.push({ id: g.id, start: newStart + g.lead, end: newStart + g.lead + g.len });
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (oldEnd === oldStart) {
|
|
108
|
+
nextGhosts.push({ ...g, at: map.map(g.at, -1) });
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
nextGhosts.push({
|
|
112
|
+
id: g.id,
|
|
113
|
+
at: newStart,
|
|
114
|
+
lead: g.at - oldStart,
|
|
115
|
+
len: 0,
|
|
116
|
+
trail: oldEnd - g.at,
|
|
117
|
+
inner: g
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
for (const a of anchors) {
|
|
121
|
+
if (a.start === a.end) {
|
|
122
|
+
const at = map.map(a.start, -1);
|
|
123
|
+
nextAnchors.push({ id: a.id, start: at, end: at });
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const start = map.map(a.start, 1);
|
|
127
|
+
const end = map.map(a.end, -1);
|
|
128
|
+
if (start < end) {
|
|
129
|
+
nextAnchors.push({ id: a.id, start, end });
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const range = rangeOf(map, a.start, a.end);
|
|
133
|
+
nextGhosts.push(range
|
|
134
|
+
? {
|
|
135
|
+
id: a.id,
|
|
136
|
+
at: range.newStart,
|
|
137
|
+
lead: a.start - range.oldStart,
|
|
138
|
+
len: a.end - a.start,
|
|
139
|
+
trail: range.oldEnd - a.end
|
|
140
|
+
}
|
|
141
|
+
: { id: a.id, at: start, lead: 0, len: a.end - a.start, trail: 0 });
|
|
142
|
+
}
|
|
143
|
+
return { anchors: nextAnchors, ghosts: nextGhosts };
|
|
144
|
+
}
|
|
80
145
|
/** An anchor in content offsets at its PM positions over `index`. */
|
|
81
146
|
function toPM(index, a) {
|
|
82
147
|
return { id: a.id, start: offsetToPM(index, a.start), end: offsetToPM(index, a.end) };
|
|
@@ -143,6 +208,11 @@ export function heldAttributes(opts, noteId) {
|
|
|
143
208
|
tabindex: '0'
|
|
144
209
|
};
|
|
145
210
|
}
|
|
211
|
+
/** A plain leaf's value as the literal text its `text` field takes: a paragraph break a blank
|
|
212
|
+
* line and a hard break a lone `\n`, as the engine spells a `codec: "plain"` value. */
|
|
213
|
+
function literalOf(rt) {
|
|
214
|
+
return core().exportMarkdown({ ...rt, codec: 'plain' });
|
|
215
|
+
}
|
|
146
216
|
export function createField(opts) {
|
|
147
217
|
const { doc, addr, container } = opts;
|
|
148
218
|
const inline = !!opts.inline;
|
|
@@ -288,7 +358,7 @@ export function createField(opts) {
|
|
|
288
358
|
if (opts.emptyUnsets && heldAnchors().length === 0 && isEmptyContent(newRt))
|
|
289
359
|
return commitUnset();
|
|
290
360
|
if (plaintext)
|
|
291
|
-
return commitPlain(newRt
|
|
361
|
+
return commitPlain(literalOf(newRt));
|
|
292
362
|
try {
|
|
293
363
|
// Only a field not yet at content rest replaces by choice: neither an absent declared
|
|
294
364
|
// field nor an authored string has anchors to lose (`changeCommittable`).
|
|
@@ -414,7 +484,7 @@ export function createField(opts) {
|
|
|
414
484
|
}
|
|
415
485
|
}
|
|
416
486
|
/** The anchors the plugin currently holds (PM coords); `[]` before the first apply. */
|
|
417
|
-
const heldAnchors = () => anchorKey.getState(view.state) ?? [];
|
|
487
|
+
const heldAnchors = () => anchorKey.getState(view.state)?.anchors ?? [];
|
|
418
488
|
/** The plugin's anchors as content offsets, against `index` — which `dispatchTransaction`
|
|
419
489
|
* rebuilt over the new document before the commit this reads for. */
|
|
420
490
|
function readAnchors() {
|
|
@@ -585,17 +655,36 @@ export function proseLeafPlugins(schema, opts) {
|
|
|
585
655
|
return list;
|
|
586
656
|
}
|
|
587
657
|
/**
|
|
588
|
-
* A plain leaf's clipboard text is literal,
|
|
589
|
-
*
|
|
658
|
+
* A plain leaf's clipboard text is literal both ways, spelled as the engine spells a `text` value:
|
|
659
|
+
* a lone `\n` a hard break, a blank line a paragraph boundary, and a run of `\n` its pairs as
|
|
660
|
+
* paragraph boundaries, an odd one over a hard break before them. Upstream's defaults split pasted
|
|
661
|
+
* text on any run of newlines and write a copy's breaks as nothing.
|
|
590
662
|
*/
|
|
591
663
|
function plainClipboardPlugin() {
|
|
592
|
-
const { paragraph } = plainSchema.nodes;
|
|
664
|
+
const { paragraph, hard_break } = plainSchema.nodes;
|
|
665
|
+
const line = (text) => paragraph.create(null, text
|
|
666
|
+
.split('\n')
|
|
667
|
+
.flatMap((part, i) => [
|
|
668
|
+
...(i ? [hard_break.create()] : []),
|
|
669
|
+
...(part ? [plainSchema.text(part)] : [])
|
|
670
|
+
]));
|
|
593
671
|
return new Plugin({
|
|
594
672
|
props: {
|
|
595
|
-
clipboardTextParser: (text) =>
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
673
|
+
clipboardTextParser: (text) => {
|
|
674
|
+
const paragraphs = [''];
|
|
675
|
+
for (const piece of text.replace(/\r\n?/g, '\n').split(/(\n+)/)) {
|
|
676
|
+
if (!piece.startsWith('\n')) {
|
|
677
|
+
paragraphs[paragraphs.length - 1] += piece;
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
if (piece.length % 2)
|
|
681
|
+
paragraphs[paragraphs.length - 1] += '\n';
|
|
682
|
+
for (let k = 0; k < piece.length >> 1; k++)
|
|
683
|
+
paragraphs.push('');
|
|
684
|
+
}
|
|
685
|
+
return new Slice(Fragment.from(paragraphs.map(line)), 1, 1);
|
|
686
|
+
},
|
|
687
|
+
clipboardTextSerializer: (slice) => slice.content.textBetween(0, slice.content.size, '\n\n', '\n')
|
|
599
688
|
}
|
|
600
689
|
});
|
|
601
690
|
}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { Node as PMNode } from 'prosemirror-model';
|
|
2
|
-
import type { Delta } from '@quillmark/wasm';
|
|
3
2
|
import { type PosRun, type Scan } from './encode.js';
|
|
3
|
+
/** A text change as one pass over the text before, offsets in UTF-16 code units: what a host
|
|
4
|
+
* hands `applyExternal` for a field another writer changed, such as `@quillmark/collab`'s
|
|
5
|
+
* `RemoteChange` delta. */
|
|
6
|
+
export interface Delta {
|
|
7
|
+
ops: ({
|
|
8
|
+
retain: number;
|
|
9
|
+
} | {
|
|
10
|
+
insert: string;
|
|
11
|
+
} | {
|
|
12
|
+
delete: number;
|
|
13
|
+
})[];
|
|
14
|
+
}
|
|
4
15
|
/** A prebuilt position index for a PM doc, rebuilt on structural change. */
|
|
5
16
|
export interface LineIndex {
|
|
6
17
|
runs: PosRun[];
|
|
@@ -72,14 +72,6 @@ li.ProseMirror-selectednode::after {
|
|
|
72
72
|
margin-top: var(--_qm-space-3);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
/* A plain leaf's paragraph is a line of literal text (`schema.ts` §`plainSchema`), and
|
|
76
|
-
a boundary between two stores the one `\n` a hard break does. So no rhythm: a gap
|
|
77
|
-
would draw a blank line the value does not hold, and the two spellings of one string
|
|
78
|
-
would read apart. */
|
|
79
|
-
.ProseMirror > [data-qm-line] + [data-qm-line] {
|
|
80
|
-
margin-top: 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
75
|
/* A blockquote's UA indent was its only mark, and the reset above takes it. The rule
|
|
84
76
|
and the inset carry it instead: the same hairline every surface reads, so a quote
|
|
85
77
|
reads as set apart without a fill or a second box. */
|
|
@@ -22,8 +22,8 @@ export declare const plaintextSchema: Schema<string, never>;
|
|
|
22
22
|
export declare const cellSchema: Schema<"hard_break", string>;
|
|
23
23
|
/**
|
|
24
24
|
* A `text` field declaring `multiline: true`: paragraphs and hard breaks, no marks, islands or
|
|
25
|
-
* containers, the shape `Content::is_plain` admits.
|
|
26
|
-
*
|
|
25
|
+
* containers, the shape `Content::is_plain` admits. Its literal text spells a break as a `\n` and a
|
|
26
|
+
* paragraph boundary as a blank line.
|
|
27
27
|
*/
|
|
28
28
|
export declare const plainSchema: Schema<"text" | "paragraph" | "hard_break" | "doc", never>;
|
|
29
29
|
/** The schema a leaf of the declared type mounts: `inline` narrows either type to one
|
|
@@ -293,13 +293,13 @@ export const cellSchema = new Schema({
|
|
|
293
293
|
});
|
|
294
294
|
/**
|
|
295
295
|
* A `text` field declaring `multiline: true`: paragraphs and hard breaks, no marks, islands or
|
|
296
|
-
* containers, the shape `Content::is_plain` admits.
|
|
297
|
-
*
|
|
296
|
+
* containers, the shape `Content::is_plain` admits. Its literal text spells a break as a `\n` and a
|
|
297
|
+
* paragraph boundary as a blank line.
|
|
298
298
|
*/
|
|
299
299
|
export const plainSchema = new Schema({
|
|
300
300
|
nodes: {
|
|
301
301
|
doc: { content: 'paragraph+' },
|
|
302
|
-
paragraph:
|
|
302
|
+
paragraph: blockNodes.paragraph,
|
|
303
303
|
text: inlineLeafNodes.text,
|
|
304
304
|
hard_break: inlineLeafNodes.hard_break
|
|
305
305
|
},
|
|
@@ -18,13 +18,15 @@ export interface SlashState {
|
|
|
18
18
|
anchor: RangeAnchor;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* The menu's wording: its accessible name
|
|
22
|
-
*
|
|
21
|
+
* The menu's wording: its accessible name, the empty line's hint, and each row's name. The tokens
|
|
22
|
+
* a row shows beside its name are not translated: they are what is typed.
|
|
23
23
|
*/
|
|
24
24
|
export interface SlashStrings {
|
|
25
25
|
slashLabel: string;
|
|
26
26
|
/** Drawn on the empty line a focused caret holds, naming the key that opens the menu. */
|
|
27
27
|
slashHint: string;
|
|
28
|
+
/** A command's row name, by its token: `numbered-list` → `Numbered list`. */
|
|
29
|
+
slashName: (command: string) => string;
|
|
28
30
|
}
|
|
29
31
|
/** The package's English, beside the surface that draws it; the visual `strings` set extends it. */
|
|
30
32
|
export declare const DEFAULT_SLASH_STRINGS: SlashStrings;
|
package/dist/core/codec/slash.js
CHANGED
|
@@ -4,10 +4,20 @@ import { rangeAnchor } from './anchor.js';
|
|
|
4
4
|
import { consuming, pickList, pickSubList, toCodeBlock, toHeading, wrapInQuote } from './blocks.js';
|
|
5
5
|
import { mintIslandId } from './islands.js';
|
|
6
6
|
import { islandOf, newTable } from './table.js';
|
|
7
|
+
const SLASH_NAMES = {
|
|
8
|
+
heading: 'Heading',
|
|
9
|
+
list: 'Bulleted list',
|
|
10
|
+
'numbered-list': 'Numbered list',
|
|
11
|
+
subparagraph: 'Subparagraph',
|
|
12
|
+
quote: 'Quote',
|
|
13
|
+
code: 'Code block',
|
|
14
|
+
table: 'Table'
|
|
15
|
+
};
|
|
7
16
|
/** The package's English, beside the surface that draws it; the visual `strings` set extends it. */
|
|
8
17
|
export const DEFAULT_SLASH_STRINGS = {
|
|
9
18
|
slashLabel: 'Insert',
|
|
10
|
-
slashHint: 'Type / to insert'
|
|
19
|
+
slashHint: 'Type / to insert',
|
|
20
|
+
slashName: (command) => SLASH_NAMES[command] ?? command.charAt(0).toUpperCase() + command.slice(1).replace(/-/g, ' ')
|
|
11
21
|
};
|
|
12
22
|
/**
|
|
13
23
|
* The vocabulary a caret can run, in menu order, each name asked whether it would fire here: a row
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { init } from './lifecycle.js';
|
|
2
2
|
export type { DocPath, Landing, Place } from './address.js';
|
|
3
3
|
export { fieldPathForAddr, addrForFieldPath } from './address.js';
|
|
4
|
+
export type { Delta } from './codec/positions.js';
|
|
4
5
|
export type { EditorError, EditorErrorCode, EditorErrorHandler } from './errors.js';
|
package/dist/core/theme.css
CHANGED
|
@@ -141,6 +141,11 @@
|
|
|
141
141
|
--_qm-surface: var(--_qm-bg);
|
|
142
142
|
--_qm-surface-well: oklab(from var(--_qm-bg) calc(l - (0.04 + 0.0202 * (1 - l))) a b);
|
|
143
143
|
--_qm-surface-sunken: var(--_qm-surface-well);
|
|
144
|
+
/* The well's own edge, drawn inside it: the fill alone stands about 1.1:1 off the
|
|
145
|
+
card, too faint to find a field by. A step toward the ink laid over the well,
|
|
146
|
+
translucent as `hover` is, so it darkens a light well and lightens a dark one by
|
|
147
|
+
the same measure. */
|
|
148
|
+
--_qm-well-edge: color-mix(in oklab, var(--_qm-fg) 10%, transparent);
|
|
144
149
|
/* `raised` is the same ramp spelled as a mix, its step 0.08 × (1 − l): the light
|
|
145
150
|
arm is zero, a white card having nowhere further to go, so a floating surface
|
|
146
151
|
separates on its hairline and `--_qm-lift` there and the step joins them in
|
|
@@ -244,9 +249,9 @@
|
|
|
244
249
|
/* ── Ratios and effects ──────────────────────────────────────────────────
|
|
245
250
|
No palette fixes these, so they are their own rungs. */
|
|
246
251
|
--_qm-blur: 8px;
|
|
247
|
-
/* The popover's
|
|
248
|
-
|
|
249
|
-
--_qm-surface-popover: color-mix(in oklab, var(--_qm-surface-raised)
|
|
252
|
+
/* The popover's surface: the raised rung all but opaque, so the blur softens what
|
|
253
|
+
is behind it and a line of text under a toolbar never reads through it. */
|
|
254
|
+
--_qm-surface-popover: color-mix(in oklab, var(--_qm-surface-raised) 96%, transparent);
|
|
250
255
|
/* What a surface with no plane under it lifts on. A tone rung cannot carry that at
|
|
251
256
|
both poles: `raised` is a no-op against a white card (§Colour), so in light the
|
|
252
257
|
hairline is otherwise the whole separation over the body prose these float on.
|
|
@@ -256,10 +261,13 @@
|
|
|
256
261
|
the cue means one thing whichever way the scale runs. Spent only on what floats,
|
|
257
262
|
and the one shadow any surface casts, which is review's to hold. */
|
|
258
263
|
--_qm-lift: 0 0 12px color-mix(in oklab, #000 16%, transparent);
|
|
259
|
-
/* The recede ladder: a
|
|
260
|
-
|
|
261
|
-
correctly given the element's own colour is a rung.
|
|
264
|
+
/* The recede ladder: a disabled affordance, a muted one, and a live one at rest
|
|
265
|
+
that comes up under the pointer. Opacity recedes toward whatever is behind, so
|
|
266
|
+
these invert correctly given the element's own colour is a rung. `rest` keeps a
|
|
267
|
+
label-ink control over 3:1 on the card and the well (WCAG 1.4.11), where `idle`
|
|
268
|
+
is a disabled control's, which owes no contrast. */
|
|
262
269
|
--_qm-opacity-idle: 0.35;
|
|
270
|
+
--_qm-opacity-rest: 0.75;
|
|
263
271
|
--_qm-opacity-muted: 0.5;
|
|
264
272
|
|
|
265
273
|
/* ── Focus ───────────────────────────────────────────────────────────────
|