@quillmark/svelte 0.37.0 → 0.38.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/dist/core/codec/field.d.ts +6 -5
- package/dist/core/codec/field.js +15 -21
- package/dist/core/codec/index.d.ts +1 -1
- package/dist/core/codec/index.js +1 -1
- package/dist/core/codec/prose.css +6 -0
- package/dist/core/codec/review.js +8 -4
- package/dist/core/codec/value-diff.d.ts +4 -3
- package/dist/core/codec/value-diff.js +12 -7
- package/dist/core/codec/value-plan.d.ts +9 -0
- package/dist/core/codec/value-plan.js +110 -0
- package/dist/core/theme.css +5 -4
- package/dist/visual/ArrayField.svelte +143 -78
- package/dist/visual/Card.svelte +4 -3
- package/dist/visual/Card.svelte.d.ts +3 -2
- package/dist/visual/Field.svelte +12 -10
- package/dist/visual/Field.svelte.d.ts +3 -3
- package/dist/visual/FieldHint.svelte +3 -5
- package/dist/visual/FieldLabel.svelte +6 -42
- package/dist/visual/FieldLabel.svelte.d.ts +0 -3
- package/dist/visual/MatrixAdd.svelte +9 -10
- package/dist/visual/MatrixField.svelte +107 -15
- package/dist/visual/ObjectField.svelte +24 -12
- package/dist/visual/ObjectField.svelte.d.ts +5 -0
- package/dist/visual/ProseField.svelte +16 -8
- package/dist/visual/ProseField.svelte.d.ts +3 -2
- package/dist/visual/ProseValue.svelte +25 -23
- package/dist/visual/ProseValue.svelte.d.ts +3 -2
- package/dist/visual/ReviewCard.svelte +11 -4
- package/dist/visual/VisualEditorInner.svelte +63 -38
- package/dist/visual/guidance.d.ts +0 -2
- package/dist/visual/guidance.js +0 -10
- package/dist/visual/proposals.d.ts +14 -11
- package/dist/visual/proposals.js +44 -28
- package/dist/visual/props.d.ts +6 -4
- package/dist/visual/review-order.d.ts +1 -0
- package/dist/visual/review-order.js +4 -3
- package/dist/visual/review.d.ts +15 -2
- package/dist/visual/review.js +29 -1
- package/dist/visual/review.svelte.d.ts +6 -1
- package/dist/visual/review.svelte.js +37 -10
- package/dist/visual/strings.d.ts +2 -0
- package/dist/visual/strings.js +1 -0
- package/dist/visual/structure.d.ts +17 -9
- package/dist/visual/structure.js +20 -17
- package/package.json +1 -1
|
@@ -172,9 +172,9 @@ export interface FieldController {
|
|
|
172
172
|
* `text` leaf holds no anchors and draws none.
|
|
173
173
|
*/
|
|
174
174
|
setReview(items: readonly TextReview[], lit?: string): void;
|
|
175
|
-
/** Draw
|
|
176
|
-
* (`value-diff.ts`).
|
|
177
|
-
|
|
175
|
+
/** Draw proposed values over the leaf as a word diff, a whole value or each run of one
|
|
176
|
+
* answer, or none (`value-diff.ts`). */
|
|
177
|
+
setValueProposals(proposals: readonly ValueProposal[]): void;
|
|
178
178
|
/** The elements the review item `id` draws, in document order; `[]` for one not drawn. */
|
|
179
179
|
reviewElements(id: string): HTMLElement[];
|
|
180
180
|
/** Put the caret in the review item `id` and focus the leaf; false for one not drawn. */
|
|
@@ -230,13 +230,14 @@ export declare function isEmptyContent(rt: Content): boolean;
|
|
|
230
230
|
/**
|
|
231
231
|
* The `contenteditable`'s role and naming attributes, shared with `ProseValue`. A `div` takes no
|
|
232
232
|
* name without a role, so every leaf states itself a textbox, one-line or not by `multiline`.
|
|
233
|
-
* `aria-labelledby` supersedes `aria-label`.
|
|
233
|
+
* `aria-labelledby` supersedes `aria-label`. A leaf on a schema of paragraphs and hard breaks
|
|
234
|
+
* alone carries `data-qm-lines`, which sets its paragraphs single spaced (`prose.css`).
|
|
234
235
|
*/
|
|
235
236
|
export declare function proseAttributes(opts: {
|
|
236
237
|
label?: string;
|
|
237
238
|
labelledBy?: string;
|
|
238
239
|
describedBy?: string;
|
|
239
|
-
}, multiline: boolean): Record<string, string>;
|
|
240
|
+
}, multiline: boolean, lines?: boolean): Record<string, string>;
|
|
240
241
|
/** A held leaf's attributes, described by its note as well. A held leaf draws its structure
|
|
241
242
|
* in the block schema, and a non-editable view is no tab stop, so it states both itself. */
|
|
242
243
|
export declare function heldAttributes(opts: {
|
package/dist/core/codec/field.js
CHANGED
|
@@ -199,10 +199,13 @@ function changeCommittable(doc, addr) {
|
|
|
199
199
|
/**
|
|
200
200
|
* The `contenteditable`'s role and naming attributes, shared with `ProseValue`. A `div` takes no
|
|
201
201
|
* name without a role, so every leaf states itself a textbox, one-line or not by `multiline`.
|
|
202
|
-
* `aria-labelledby` supersedes `aria-label`.
|
|
202
|
+
* `aria-labelledby` supersedes `aria-label`. A leaf on a schema of paragraphs and hard breaks
|
|
203
|
+
* alone carries `data-qm-lines`, which sets its paragraphs single spaced (`prose.css`).
|
|
203
204
|
*/
|
|
204
|
-
export function proseAttributes(opts, multiline) {
|
|
205
|
+
export function proseAttributes(opts, multiline, lines = false) {
|
|
205
206
|
const attrs = { role: 'textbox', 'aria-multiline': String(multiline) };
|
|
207
|
+
if (lines)
|
|
208
|
+
attrs['data-qm-lines'] = '';
|
|
206
209
|
if (opts.labelledBy)
|
|
207
210
|
attrs['aria-labelledby'] = opts.labelledBy;
|
|
208
211
|
else if (opts.label)
|
|
@@ -284,10 +287,8 @@ export function createField(opts) {
|
|
|
284
287
|
point: (id) => opts.onReviewPoint?.(id),
|
|
285
288
|
drew: (report) => opts.onReviewDrawn?.(report)
|
|
286
289
|
});
|
|
287
|
-
let
|
|
288
|
-
const valueDiff =
|
|
289
|
-
? valueDiffPlugin(() => valueProposal, (id, state) => opts.onValuePlanned?.(id, state))
|
|
290
|
-
: undefined;
|
|
290
|
+
let valueProposals = [];
|
|
291
|
+
const valueDiff = valueDiffPlugin(() => valueProposals, (id, state) => opts.onValuePlanned?.(id, state));
|
|
291
292
|
// The menu's report channel; the vocabulary is the codec's own constant (`slash.ts`).
|
|
292
293
|
const slash = block ? opts.onSlash : undefined;
|
|
293
294
|
// Judged of the value being mounted rather than read off a diagnostic: a routed set
|
|
@@ -295,12 +296,13 @@ export function createField(opts) {
|
|
|
295
296
|
// `not_single_line` on a one-line `text` field.
|
|
296
297
|
const holds = (rt) => !fitsLeaf(rt, { inline, plaintext, paragraphs, islands: true });
|
|
297
298
|
let held = holds(reconciler.last);
|
|
298
|
-
const
|
|
299
|
+
const lines = isParagraphsSchema(schema);
|
|
300
|
+
const named = proseAttributes(opts, !inline, lines);
|
|
299
301
|
const defaultNamed = {
|
|
300
302
|
...proseAttributes({
|
|
301
303
|
...opts,
|
|
302
304
|
describedBy: [opts.describedBy, opts.defaultNoteId].filter(Boolean).join(' ') || undefined
|
|
303
|
-
}, !inline),
|
|
305
|
+
}, !inline, lines),
|
|
304
306
|
'data-default': ''
|
|
305
307
|
};
|
|
306
308
|
const heldNamed = heldAttributes(opts, opts.heldNoteId);
|
|
@@ -412,11 +414,7 @@ export function createField(opts) {
|
|
|
412
414
|
placeholder: () => placeholderText,
|
|
413
415
|
placeholderUntilEdit: opts.placeholderUntilEdit,
|
|
414
416
|
cap: opts.cap,
|
|
415
|
-
afterHistory: [
|
|
416
|
-
anchorPlugin(seededAnchors),
|
|
417
|
-
...(review ? [review.plugin] : []),
|
|
418
|
-
...(valueDiff ? [valueDiff] : [])
|
|
419
|
-
]
|
|
417
|
+
afterHistory: [anchorPlugin(seededAnchors), ...(review ? [review.plugin] : []), valueDiff]
|
|
420
418
|
})
|
|
421
419
|
});
|
|
422
420
|
return { state: built, index: seedIndex };
|
|
@@ -734,15 +732,11 @@ export function createField(opts) {
|
|
|
734
732
|
parsed.delete(markdown);
|
|
735
733
|
review.refresh(view);
|
|
736
734
|
},
|
|
737
|
-
|
|
738
|
-
|
|
735
|
+
setValueProposals(proposals) {
|
|
736
|
+
const key = (list) => JSON.stringify(list.map((p) => [p.id, p.lit, p.after, p.before]));
|
|
737
|
+
if (key(proposals) === key(valueProposals))
|
|
739
738
|
return;
|
|
740
|
-
|
|
741
|
-
p?.lit === valueProposal?.lit &&
|
|
742
|
-
JSON.stringify([p?.after, p?.before]) ===
|
|
743
|
-
JSON.stringify([valueProposal?.after, valueProposal?.before]))
|
|
744
|
-
return;
|
|
745
|
-
valueProposal = p;
|
|
739
|
+
valueProposals = proposals;
|
|
746
740
|
view.setProps({});
|
|
747
741
|
},
|
|
748
742
|
reviewElements(id) {
|
|
@@ -20,7 +20,7 @@ export type { ValuePlan, ValueChange } from './value-plan.js';
|
|
|
20
20
|
export type { DiffHunk } from './review-diff.js';
|
|
21
21
|
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
|
|
22
22
|
export type { EditorShortcut, ShortcutScope, ShortcutStrings } from './shortcuts.js';
|
|
23
|
-
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, hasMarks } from './schema.js';
|
|
23
|
+
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
|
|
24
24
|
export { rendersHref, storableUrl } from './urls.js';
|
|
25
25
|
export { decode, fitsInline, fitsLeaf, fitsPlain, renderContent, usvLength } from './decode.js';
|
|
26
26
|
export { pmToContent, lower } from './encode.js';
|
package/dist/core/codec/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export { asContent, planValue, valueChanges } from './value-plan.js';
|
|
|
34
34
|
export { DEFAULT_SHORTCUT_STRINGS, FIELD_KEYS, LIST_KEYS, REVIEW_KEYS, editorShortcuts } from './shortcuts.js';
|
|
35
35
|
// Schemas (the decode/encode target; the VisualEditor mounts them). `hasMarks` is
|
|
36
36
|
// what a mark surface asks before offering itself over a leaf.
|
|
37
|
-
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, hasMarks } from './schema.js';
|
|
37
|
+
export { blockSchema, inlineSchema, plaintextSchema, plainSchema, linesSchema, leafSchema, isParagraphsSchema, hasMarks } from './schema.js';
|
|
38
38
|
// The url edge: `rendersHref` is the link gate the prompt re-asks on submit, and
|
|
39
39
|
// `storableUrl` the encode the store's own refusal requires of the value it takes
|
|
40
40
|
// (`visual/links.ts`).
|
|
@@ -72,6 +72,12 @@ li.ProseMirror-selectednode::after {
|
|
|
72
72
|
margin-top: var(--_qm-space-3);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/* A leaf of lines sets its paragraphs single spaced, as the page does: in that shape a
|
|
76
|
+
paragraph break and a hard break are one line break. */
|
|
77
|
+
.ProseMirror[data-qm-lines] > * + * {
|
|
78
|
+
margin-top: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
/* A blockquote's UA indent was its only mark, and the reset above takes it. The rule
|
|
76
82
|
and the inset carry it instead: the same hairline every surface reads, so a quote
|
|
77
83
|
reads as set apart without a fill or a second box. */
|
|
@@ -136,13 +136,17 @@ function reach(leaf) {
|
|
|
136
136
|
? [leaf.pos + 1, leaf.pos + leaf.node.nodeSize - 1]
|
|
137
137
|
: [leaf.pos, leaf.pos + leaf.node.nodeSize];
|
|
138
138
|
}
|
|
139
|
+
/** `node`'s attributes without the id of the stored part it decodes from. */
|
|
140
|
+
const unnamed = (node) => 'id' in node.attrs ? { ...node.attrs, id: null } : node.attrs;
|
|
139
141
|
/** `doc`'s blocks from its `from`th leaf on, in the containers they sat in. A numbered list
|
|
140
|
-
* that lost its head keeps counting from where the kept items stood.
|
|
142
|
+
* that lost its head keeps counting from where the kept items stood. They carry no ids: the
|
|
143
|
+
* ones `doc` was read under are its own, and a leaf's block wearing one would lose it to an
|
|
144
|
+
* added block that stands ahead of it. */
|
|
141
145
|
function tail(doc, from) {
|
|
142
146
|
let seen = 0;
|
|
143
147
|
const keep = (node) => {
|
|
144
148
|
if (node.isTextblock || node.isAtom)
|
|
145
|
-
return seen++ >= from ? node : undefined;
|
|
149
|
+
return seen++ >= from ? node.type.create(unnamed(node), node.content, node.marks) : undefined;
|
|
146
150
|
const kids = [];
|
|
147
151
|
let dropped = 0;
|
|
148
152
|
node.forEach((child) => {
|
|
@@ -155,8 +159,8 @@ function tail(doc, from) {
|
|
|
155
159
|
if (!kids.length)
|
|
156
160
|
return undefined;
|
|
157
161
|
const attrs = node.type.name === 'ordered_list'
|
|
158
|
-
? { ...node
|
|
159
|
-
: node
|
|
162
|
+
? { ...unnamed(node), start: node.attrs.start + dropped }
|
|
163
|
+
: unnamed(node);
|
|
160
164
|
return node.type.create(attrs, kids);
|
|
161
165
|
};
|
|
162
166
|
const out = [];
|
|
@@ -15,7 +15,8 @@ export interface ValueProposal {
|
|
|
15
15
|
export type ValueState = 'open' | 'outdated' | 'applied';
|
|
16
16
|
export declare const valueDiffKey: PluginKey<void>;
|
|
17
17
|
/**
|
|
18
|
-
* The plugin, reading the
|
|
19
|
-
* `planned` hears, on each draw, how
|
|
18
|
+
* The plugin, reading the proposals live: a caller that moves them redraws with `setProps`.
|
|
19
|
+
* Each is a run of one answer or a whole value, drawn apart. `planned` hears, on each draw, how
|
|
20
|
+
* each stands against what the leaf holds.
|
|
20
21
|
*/
|
|
21
|
-
export declare function valueDiffPlugin(read: () => ValueProposal
|
|
22
|
+
export declare function valueDiffPlugin(read: () => readonly ValueProposal[], planned?: (id: string, state: ValueState) => void): Plugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// A field's whole
|
|
1
|
+
// A field's proposed values, a whole one or each run of one answer, drawn as a word diff over a leaf of lines: the words Accept would
|
|
2
2
|
// strike struck where they stand, the words it would write tinted beside them in their own
|
|
3
3
|
// formatting, nothing written. What is drawn is the difference between the leaf as it reads and
|
|
4
4
|
// what Accept would write (`planValue`), so the reader's words beside a proposal stay unstruck.
|
|
@@ -31,11 +31,15 @@ function inserted(schema, c, from, to) {
|
|
|
31
31
|
const inline = doc.firstChild?.isTextblock ? doc.firstChild.content : doc.content;
|
|
32
32
|
return DOMSerializer.fromSchema(schema).serializeFragment(inline);
|
|
33
33
|
}
|
|
34
|
-
function draw(state,
|
|
34
|
+
function draw(state, proposals, planned) {
|
|
35
35
|
const scan = scanDoc(state.doc);
|
|
36
36
|
const live = scanContent(scan);
|
|
37
37
|
const index = lineIndexOf(scan);
|
|
38
38
|
const at = (offset) => offsetToPM(index, offset);
|
|
39
|
+
return DecorationSet.create(state.doc, proposals.flatMap((p) => decorations(state, live, at, p, planned)));
|
|
40
|
+
}
|
|
41
|
+
/** One proposal's marks over the leaf as it reads, `live`. */
|
|
42
|
+
function decorations(state, live, at, p, planned) {
|
|
39
43
|
const { merged, outdated } = planValue(p.before, live, p.after);
|
|
40
44
|
const changes = valueChanges(live, merged);
|
|
41
45
|
planned?.(p.id, !changes.length ? 'applied' : outdated ? 'outdated' : 'open');
|
|
@@ -64,19 +68,20 @@ function draw(state, p, planned) {
|
|
|
64
68
|
key: `value:${p.id}:${n}:${start}:${JSON.stringify(slice(merged, start, to).marks)}:${text}:${p.lit}`
|
|
65
69
|
}));
|
|
66
70
|
});
|
|
67
|
-
return
|
|
71
|
+
return decos;
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
|
-
* The plugin, reading the
|
|
71
|
-
* `planned` hears, on each draw, how
|
|
74
|
+
* The plugin, reading the proposals live: a caller that moves them redraws with `setProps`.
|
|
75
|
+
* Each is a run of one answer or a whole value, drawn apart. `planned` hears, on each draw, how
|
|
76
|
+
* each stands against what the leaf holds.
|
|
72
77
|
*/
|
|
73
78
|
export function valueDiffPlugin(read, planned) {
|
|
74
79
|
return new Plugin({
|
|
75
80
|
key: valueDiffKey,
|
|
76
81
|
props: {
|
|
77
82
|
decorations(state) {
|
|
78
|
-
const
|
|
79
|
-
return
|
|
83
|
+
const proposals = read();
|
|
84
|
+
return proposals.length ? draw(state, proposals, planned) : null;
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
});
|
|
@@ -27,3 +27,12 @@ export declare function valueChanges(a: Content, b: Content): ValueChange[];
|
|
|
27
27
|
* the value already reads as `after`.
|
|
28
28
|
*/
|
|
29
29
|
export declare function planValue(before: Content | undefined, live: Content, after: Content): ValuePlan;
|
|
30
|
+
/**
|
|
31
|
+
* `after` as one proposal per run of lines it changes in `before`: each `before` with that run
|
|
32
|
+
* alone written as `after` has it, in reading order. Lines pair by their words and formatting
|
|
33
|
+
* along their longest common run, so a line added or taken out is one run, never every line below
|
|
34
|
+
* it. By `'run'`, runs at most two unchanged lines apart are one; by `'paragraph'`, a run that
|
|
35
|
+
* rewrites as many lines as it reads is one proposal per line, as the body proposes paragraphs. A
|
|
36
|
+
* value that holds more than lines of words, or one that changes a single line or run, is `[after]`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function lineRuns(before: Content, after: Content, unit?: 'run' | 'paragraph'): Content[];
|
|
@@ -155,3 +155,113 @@ export function planValue(before, live, after) {
|
|
|
155
155
|
}
|
|
156
156
|
return { merged, outdated: false };
|
|
157
157
|
}
|
|
158
|
+
/** Unchanged lines that may stand between two runs of changed lines on one proposal. */
|
|
159
|
+
const RUN_GAP = 2;
|
|
160
|
+
/** Line `k` of `c`, as a value of its own. */
|
|
161
|
+
function lineOf(c, starts, k) {
|
|
162
|
+
const from = starts[k];
|
|
163
|
+
const to = k + 1 < starts.length ? starts[k + 1] - 1 : c.text.length;
|
|
164
|
+
return { text: c.text.slice(from, to), marks: marksIn(c, from, to, 0) };
|
|
165
|
+
}
|
|
166
|
+
/** Where each line of `c` starts. */
|
|
167
|
+
function lineStarts(c) {
|
|
168
|
+
const out = [0];
|
|
169
|
+
for (let i = 0; i < c.text.length; i++)
|
|
170
|
+
if (c.text[i] === '\n')
|
|
171
|
+
out.push(i + 1);
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* `after` as one proposal per run of lines it changes in `before`: each `before` with that run
|
|
176
|
+
* alone written as `after` has it, in reading order. Lines pair by their words and formatting
|
|
177
|
+
* along their longest common run, so a line added or taken out is one run, never every line below
|
|
178
|
+
* it. By `'run'`, runs at most two unchanged lines apart are one; by `'paragraph'`, a run that
|
|
179
|
+
* rewrites as many lines as it reads is one proposal per line, as the body proposes paragraphs. A
|
|
180
|
+
* value that holds more than lines of words, or one that changes a single line or run, is `[after]`.
|
|
181
|
+
*/
|
|
182
|
+
export function lineRuns(before, after, unit = 'run') {
|
|
183
|
+
if ([before, after].some(structured))
|
|
184
|
+
return [after];
|
|
185
|
+
const bs = lineStarts(before);
|
|
186
|
+
const as = lineStarts(after);
|
|
187
|
+
if (bs.length !== before.blocks.length || as.length !== after.blocks.length)
|
|
188
|
+
return [after];
|
|
189
|
+
const key = (c, starts, k) => JSON.stringify(lineOf(c, starts, k));
|
|
190
|
+
const bk = bs.map((_, k) => key(before, bs, k));
|
|
191
|
+
const ak = as.map((_, k) => key(after, as, k));
|
|
192
|
+
const m = bk.length;
|
|
193
|
+
const n = ak.length;
|
|
194
|
+
const lcs = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
195
|
+
for (let i = m - 1; i >= 0; i--)
|
|
196
|
+
for (let j = n - 1; j >= 0; j--)
|
|
197
|
+
lcs[i][j] = bk[i] === ak[j] ? lcs[i + 1][j + 1] + 1 : Math.max(lcs[i + 1][j], lcs[i][j + 1]);
|
|
198
|
+
const runs = [];
|
|
199
|
+
let i = 0;
|
|
200
|
+
let j = 0;
|
|
201
|
+
let open;
|
|
202
|
+
const close = () => {
|
|
203
|
+
if (!open)
|
|
204
|
+
return;
|
|
205
|
+
const last = runs.at(-1);
|
|
206
|
+
if (unit === 'run' && last && open.b - last.be <= RUN_GAP) {
|
|
207
|
+
last.be = i;
|
|
208
|
+
last.ae = j;
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
runs.push({ b: open.b, be: i, a: open.a, ae: j });
|
|
212
|
+
open = undefined;
|
|
213
|
+
};
|
|
214
|
+
while (i < m || j < n) {
|
|
215
|
+
if (i < m && j < n && bk[i] === ak[j]) {
|
|
216
|
+
close();
|
|
217
|
+
i++;
|
|
218
|
+
j++;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
open ??= { b: i, a: j };
|
|
222
|
+
if (j >= n || (i < m && lcs[i + 1][j] >= lcs[i][j + 1]))
|
|
223
|
+
i++;
|
|
224
|
+
else
|
|
225
|
+
j++;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
close();
|
|
229
|
+
const apart = unit === 'paragraph'
|
|
230
|
+
? runs.flatMap((r) => r.be - r.b === r.ae - r.a && r.be - r.b > 1
|
|
231
|
+
? Array.from({ length: r.be - r.b }, (_, k) => ({
|
|
232
|
+
b: r.b + k,
|
|
233
|
+
be: r.b + k + 1,
|
|
234
|
+
a: r.a + k,
|
|
235
|
+
ae: r.a + k + 1
|
|
236
|
+
}))
|
|
237
|
+
: [r])
|
|
238
|
+
: runs;
|
|
239
|
+
if (apart.length < 2)
|
|
240
|
+
return [after];
|
|
241
|
+
return apart.map((run) => {
|
|
242
|
+
const lines = [
|
|
243
|
+
...bs.slice(0, run.b).map((_, k) => lineOf(before, bs, k)),
|
|
244
|
+
...as.slice(run.a, run.ae).map((_, k) => lineOf(after, as, run.a + k)),
|
|
245
|
+
...bs.slice(run.be).map((_, k) => lineOf(before, bs, run.be + k))
|
|
246
|
+
];
|
|
247
|
+
const blocks = [
|
|
248
|
+
...before.blocks.slice(0, run.b),
|
|
249
|
+
...after.blocks.slice(run.a, run.ae),
|
|
250
|
+
...before.blocks.slice(run.be)
|
|
251
|
+
].map((b, k) => ({ ...b, id: `b${k}` }));
|
|
252
|
+
let at = 0;
|
|
253
|
+
const marks = [];
|
|
254
|
+
for (const line of lines) {
|
|
255
|
+
for (const mark of line.marks)
|
|
256
|
+
marks.push({ ...mark, start: mark.start + at, end: mark.end + at });
|
|
257
|
+
at += line.text.length + 1;
|
|
258
|
+
}
|
|
259
|
+
const out = { ...before, text: lines.map((l) => l.text).join('\n'), blocks };
|
|
260
|
+
if (marks.length)
|
|
261
|
+
out.marks = marks;
|
|
262
|
+
else
|
|
263
|
+
delete out.marks;
|
|
264
|
+
delete out.anchors;
|
|
265
|
+
return out;
|
|
266
|
+
});
|
|
267
|
+
}
|
package/dist/core/theme.css
CHANGED
|
@@ -227,13 +227,14 @@
|
|
|
227
227
|
thumb and the check, holds 3:1 at both poles, at 3.3:1 and 4.2:1. */
|
|
228
228
|
--_qm-accent-default: color-mix(in oklab, var(--_qm-accent), var(--_qm-bg) 20%);
|
|
229
229
|
/* The review hue, three ways. `tint` is held under the words a proposal would add, at
|
|
230
|
-
the strength the accent's own tint is held under body text
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
the strength the accent's own tint is held under body text, so the open items a
|
|
231
|
+
review leaves at rest stand back from the one it is on. `lit` is that tint under
|
|
232
|
+
attention, near three times as strong: the caret in the item, a step to it, a host
|
|
233
|
+
revealing it. `line` is the stroke through the words a
|
|
233
234
|
proposal would take, held back so it reads under the ink rather than as it, yet at 3:1 over
|
|
234
235
|
the card and a well at both poles, being the one mark a struck word or a tinted control's
|
|
235
236
|
edge has that is not colour alone: 75% of the light pole's hue, 60% of the dark's. */
|
|
236
|
-
--_qm-review-tint: color-mix(in oklab, var(--_qm-review)
|
|
237
|
+
--_qm-review-tint: color-mix(in oklab, var(--_qm-review) 12%, transparent);
|
|
237
238
|
--_qm-review-lit: color-mix(in oklab, var(--_qm-review) 34%, transparent);
|
|
238
239
|
--_qm-review-line: light-dark(
|
|
239
240
|
color-mix(in oklab, var(--_qm-review) 75%, transparent),
|