oficina / mapa Public

Gate: untouched includes the block's context, at make ci

Fable's final review of 58fd476, gate honesty. Dropping a task's
checked state from the context key (so a toggled task box counted as
untouched and saved as it was) survived every make ci test; only make
browser's task-box click caught it. A serialize.test.mjs case now
toggles a task, changes a bullet and a quote's prefixes through the
holder's attributes alone, and requires each to be written again. With
checked dropped from contextKey it fails, and L3 does not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev e3788929fa5220075b4a2211fe677511fd8430dd parent a64af65
1 file changed, +27 −0
  • editor/serialize.test.mjs +27 −0
diff --git a/editor/serialize.test.mjs b/editor/serialize.test.mjs
index 6d96d13..8f1e363 100644
--- a/editor/serialize.test.mjs
+++ b/editor/serialize.test.mjs
@@ -213,3 +213,30 @@ test('applyBody takes a teammate\'s block, keeps the caret, and ends untouched',
view.run(undo)
assert.equal(serialise(view.state.doc, fidelity), 'one\n\ntwo\n\nthree!')
})
+
+// "Untouched" includes the block's context (§6.4 step 2): a block whose
+// own node is unchanged but whose item or quote attributes changed is
+// written from the document, not re-emitted. Without the context in the
+// rule a toggled task box saved as it was (review: only make browser's
+// task-box click caught that).
+test('a block whose context changed is written again: a task toggled, a bullet, a quote', () => {
+ const holder = (doc, name) => {
+ let found = null
+ doc.descendants((node, pos) => {
+ if (found === null && node.type.name === name) found = { node, pos }
+ })
+ return found
+ }
+ const cases = [
+ ['- [ ] Send Tom the summary\n- [x] Book the room', 'list_item', { checked: 'x' },
+ '- [x] Send Tom the summary\n- [x] Book the room'],
+ ['- one\n- two', 'list_item', { bullet: '*' }, '* one\n- two'],
+ ['> quoted\n> twice', 'blockquote', { prefix: ['>', '>'] }, '>quoted\n>twice']
+ ]
+ for (const [body, name, change, want] of cases) {
+ const { view, fidelity } = editor(body)
+ const { node, pos } = holder(view.state.doc, name)
+ view.dispatch(view.state.tr.setNodeMarkup(pos, null, { ...node.attrs, ...change }))
+ assert.equal(serialise(view.state.doc, fidelity), want, body)
+ }
+})