@quillmark/svelte 0.38.1 → 0.39.1
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 -0
- package/dist/core/codec/encode.d.ts +10 -0
- package/dist/core/codec/encode.js +101 -0
- package/dist/core/codec/field.d.ts +1 -2
- package/dist/core/codec/field.js +51 -10
- package/dist/core/codec/index.d.ts +2 -1
- package/dist/core/codec/index.js +2 -1
- package/dist/core/codec/review-caret.d.ts +30 -0
- package/dist/core/codec/review-caret.js +195 -0
- package/dist/core/codec/review.d.ts +6 -4
- package/dist/core/codec/review.js +4 -60
- package/dist/core/codec/value-diff.d.ts +4 -1
- package/dist/core/codec/value-diff.js +16 -0
- package/dist/core/frame.d.ts +27 -0
- package/dist/core/frame.js +108 -0
- package/dist/core/theme.css +10 -0
- package/dist/visual/Field.svelte +1 -1
- package/dist/visual/ProseValue.svelte +11 -1
- package/dist/visual/ReviewCard.svelte +25 -23
- package/dist/visual/ReviewCard.svelte.d.ts +1 -0
- package/dist/visual/VisualEditorInner.svelte +68 -19
- package/dist/visual/index.d.ts +1 -1
- package/dist/visual/index.js +1 -1
- package/dist/visual/proposals.d.ts +9 -0
- package/dist/visual/proposals.js +71 -17
- package/package.json +1 -1
package/dist/visual/proposals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fieldPathForAddr } from '../core/address.js';
|
|
1
|
+
import { addrForFieldPath, fieldPathForAddr } from '../core/address.js';
|
|
2
2
|
import { asContent, lineRuns } from '../core/codec/value-plan.js';
|
|
3
|
-
import { sameValue } from './review.js';
|
|
3
|
+
import { byBlocks, sameValue } from './review.js';
|
|
4
4
|
import { VARIANT_DISCRIMINANT, baseType, fieldValues, textKind } from './structure.js';
|
|
5
5
|
let minted = 0;
|
|
6
6
|
/**
|
|
@@ -233,30 +233,84 @@ const addrOf = (card, field) => ({
|
|
|
233
233
|
});
|
|
234
234
|
/**
|
|
235
235
|
* `now` with the first block's id on the block that is the first block read: a rewrite keeps that
|
|
236
|
-
* id on whichever block it puts first, so blocks added above the first read as its rewrite.
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* or, where the block put first is of another kind, the first of the first block's kind. The block
|
|
240
|
-
* put first then takes an id `was` does not hold, so it and those after it up to that block are
|
|
241
|
-
* added before it.
|
|
236
|
+
* id on whichever block it puts first, so blocks added above the first read as its rewrite. The
|
|
237
|
+
* block put first then takes an id `was` does not hold, so it and those after it up to that block
|
|
238
|
+
* are added before it.
|
|
242
239
|
*/
|
|
243
240
|
function leading(was, now) {
|
|
241
|
+
const at = heir(was, now);
|
|
242
|
+
if (!at)
|
|
243
|
+
return now;
|
|
244
|
+
const first = was[0].id;
|
|
245
|
+
const held = new Set(was.map((b) => b.id));
|
|
246
|
+
let added = `${first}+`;
|
|
247
|
+
while (held.has(added))
|
|
248
|
+
added += '+';
|
|
249
|
+
return now.map((b, i) => (i === 0 ? { ...b, id: added } : i === at ? { ...b, id: first } : b));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The index in `now` of the block that is `was`'s first block where a rewrite put others above it,
|
|
253
|
+
* `0` where it stands first. Of the blocks ahead of the next one `now` keeps, the first reading as
|
|
254
|
+
* the first block did is it, or, where the block put first is of another kind, the first of the
|
|
255
|
+
* first block's kind.
|
|
256
|
+
*/
|
|
257
|
+
function heir(was, now) {
|
|
244
258
|
const first = was[0];
|
|
245
259
|
if (!first || now[0]?.id !== first.id || now[0].markdown === first.markdown)
|
|
246
|
-
return
|
|
260
|
+
return 0;
|
|
247
261
|
const held = new Set(was.map((b) => b.id));
|
|
248
262
|
let end = 1;
|
|
249
263
|
while (end < now.length && !held.has(now[end].id))
|
|
250
264
|
end++;
|
|
251
265
|
const ahead = now.slice(1, end);
|
|
252
|
-
|
|
253
|
-
(now[0].kind !== first.kind && ahead.findIndex((b) => b.kind === first.kind) + 1)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
266
|
+
return (ahead.findIndex((b) => b.markdown === first.markdown) + 1 ||
|
|
267
|
+
(now[0].kind !== first.kind && ahead.findIndex((b) => b.kind === first.kind) + 1) ||
|
|
268
|
+
0);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* `items` naming the blocks of `now`, a whole-document revise of `was`, such as a return from
|
|
272
|
+
* editing the document as Markdown. A revise keeps a field's first id on whichever block it puts
|
|
273
|
+
* first, so a block written above the first takes its id and the first block moves under a new
|
|
274
|
+
* one. An item naming that id, to rewrite the block or to add beside it, names the new one, where
|
|
275
|
+
* the first block stands as {@link proposalsBetween} reads a block put above it. Every other item
|
|
276
|
+
* is as it was, and so is every id a revise keeps on its block.
|
|
277
|
+
*/
|
|
278
|
+
export function reviewRevised(items, was, now) {
|
|
279
|
+
const moves = new Map();
|
|
280
|
+
const moveOf = (item) => {
|
|
281
|
+
const key = `${item.card ?? ''} ${item.field}`;
|
|
282
|
+
if (moves.has(key))
|
|
283
|
+
return moves.get(key);
|
|
284
|
+
let move;
|
|
285
|
+
const addr = addrForFieldPath(item.field);
|
|
286
|
+
if (addr) {
|
|
287
|
+
const at = item.card === undefined ? addr : { ...addr, card: item.card };
|
|
288
|
+
const before = blocksOf(was, at);
|
|
289
|
+
const after = blocksOf(now, at);
|
|
290
|
+
const k = heir(before, after);
|
|
291
|
+
if (k)
|
|
292
|
+
move = [before[0].id, after[k].id];
|
|
293
|
+
}
|
|
294
|
+
moves.set(key, move);
|
|
295
|
+
return move;
|
|
296
|
+
};
|
|
297
|
+
return items.map((item) => {
|
|
298
|
+
if (!byBlocks(item))
|
|
299
|
+
return item;
|
|
300
|
+
const move = moveOf(item);
|
|
301
|
+
if (!move)
|
|
302
|
+
return item;
|
|
303
|
+
const moved = (id) => (id === move[0] ? move[1] : id);
|
|
304
|
+
if ('replace' in item)
|
|
305
|
+
return { ...item, replace: item.replace.map(moved) };
|
|
306
|
+
const at = item.insert;
|
|
307
|
+
if (at === 'end')
|
|
308
|
+
return item;
|
|
309
|
+
return {
|
|
310
|
+
...item,
|
|
311
|
+
insert: 'after' in at ? { after: moved(at.after) } : { before: moved(at.before) }
|
|
312
|
+
};
|
|
313
|
+
});
|
|
260
314
|
}
|
|
261
315
|
/** The blocks of the value at `addr`, none where it holds none. */
|
|
262
316
|
function blocksOf(doc, addr) {
|