@estiva-app/protocol 0.25.0 → 0.26.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/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ Every entry answers the wire question explicitly, including when the answer is
4
4
  nothing (ADR 0002 §4b). A change to the bytes an app publishes is a MAJOR — in
5
5
  `0.x`, a MINOR — even when no TypeScript signature moved.
6
6
 
7
+ ## 0.26.0 — 2026-09-30
8
+
9
+ **Wire behaviour: unchanged.** A block document's translation to and from an
10
+ editor, moved down from Ship so a second editor of one gets it (MAN-9).
11
+
12
+ - **New: `toEditorDocument` / `fromEditorDocument`** — a §13.3 document as
13
+ ProseMirror's JSON and back, with every block id riding in
14
+ `attrs.blockId`. An unknown block is parked as an `unknownBlock` atom
15
+ carrying its source and its inline text, and handed back untouched; a
16
+ duplicated id is re-minted on the way out; a `null` attribute is dropped.
17
+ Ship's `src/lib/blockEditor.ts` (RIC-14) had the only copy, and Peek's
18
+ editor for a declared prose field (`format: estiva-blocks-1`) needs the
19
+ same one, or an edit there re-mints ids and detaches anchored comments.
20
+ - **New: `documentForEditing(value, format)`** — the document a stored value
21
+ is edited as: parsed when tagged `blocks`, bridged from marker text
22
+ otherwise, including a `blocks` value that does not parse.
23
+ - **New: `publishableFromEditor(doc)`** — what a save writes: the serialised
24
+ document and `contentFormat: 'estiva-blocks-1'`, or `{ value: '' }` for an
25
+ empty one.
26
+ - **New: `EDITOR_BLOCK_TYPES`, `UNKNOWN_BLOCK_NODE`, `REFERENCE_NODE`** — the
27
+ node names the editor schema must supply; `@estiva-app/ui/editor` does.
28
+
7
29
  ## 0.25.0 — 2026-09-30
8
30
 
9
31
  **Wire behaviour: unchanged.** One field read that was dropped before.
@@ -0,0 +1,108 @@
1
+ import { type BlockDocument } from './blocks.js';
2
+ import { BLOCK_DOCUMENT_FORMAT, type ContentFormat } from './render.js';
3
+ /**
4
+ * A block document, in and out of an editor — SPEC §13.3, RIC-14, MAN-9.
5
+ *
6
+ * `toRenderTree` is how a §13.3 document is *read*; this is how one is
7
+ * *edited*, so that every app writing one keeps the same ids. Written in Ship
8
+ * for its descriptions (RIC-14) and moved here when Peek became the second
9
+ * editor of the same documents (MAN-9, ADR 0002 §10). The editor schema these
10
+ * nodes need — the id attribute, the unknown block, the reference and the
11
+ * attachment — is `@estiva-app/ui/editor`'s.
12
+ *
13
+ * **The two models are the same shape already**, which is the reason this file
14
+ * is a translation rather than a design. SPEC §13.3's document is
15
+ * `{type: 'doc', content: [{type, id, attrs, content}]}` and ProseMirror's is
16
+ * `{type: 'doc', content: [{type, attrs, content}]}`; the block types §13.3
17
+ * names are ProseMirror's node names. So the whole conversion is: **the id
18
+ * moves between a field and an attribute**, and a reference moves between a
19
+ * mark and an atom.
20
+ *
21
+ * Marker text is still what a **legacy** body is written in and this reads it
22
+ * — `markerTextToBlockDocument` — it simply stops being what a person is shown
23
+ * while typing.
24
+ *
25
+ * No editor library is imported. The output is ProseMirror's JSON, a data
26
+ * shape, so this stays a pure function of the document like the rest of the
27
+ * package.
28
+ *
29
+ * ## Three things it refuses to lose
30
+ *
31
+ * **An unknown block.** §13.3 says a reader MUST render an unknown block's
32
+ * inline text and MUST NOT drop it silently. An editor is worse than a reader
33
+ * here: ProseMirror discards a node its schema does not know, and the save
34
+ * that follows would delete a `table` or a `widget` from somebody else's
35
+ * description with no error anywhere. So an unknown block becomes an atom that
36
+ * carries its original JSON and hands it back untouched.
37
+ *
38
+ * **A block id.** An anchored comment binds to `<address> + <block id>`
39
+ * (RFC 0.4 §6), so an edit that re-mints ids detaches every comment on the
40
+ * page. Ids ride in `attrs.blockId` and survive every edit that does not
41
+ * replace the block — which is what ProseMirror already gives us, since it
42
+ * preserves attributes across typing.
43
+ *
44
+ * **A duplicate id.** Copy a block, paste it, and both copies carry the same
45
+ * id — a document `validateBlockDocument` rejects and an anchor that points at
46
+ * two places. The second one gets a fresh id on the way out.
47
+ */
48
+ /** A ProseMirror/Tiptap node, as JSON. */
49
+ export interface EditorNode {
50
+ type: string;
51
+ attrs?: Record<string, unknown>;
52
+ content?: EditorNode[];
53
+ marks?: {
54
+ type: string;
55
+ attrs?: Record<string, unknown>;
56
+ }[];
57
+ text?: string;
58
+ }
59
+ export interface EditorDocument {
60
+ type: 'doc';
61
+ content: EditorNode[];
62
+ }
63
+ /**
64
+ * The block types the editor's schema knows.
65
+ *
66
+ * Everything else is preserved as an atom rather than edited. Deliberately not
67
+ * `KNOWN_BLOCK_TYPES` — that is what the *protocol* names, and the editor
68
+ * knows a subset of it. `widget` is in the protocol and has no editing design
69
+ * yet, so it travels through untouched. An editor using this translation needs
70
+ * a node for each of these: StarterKit, TableKit, and `@estiva-app/ui/editor`'s
71
+ * `AttachmentNode`, whose `BlockId` names the same list.
72
+ *
73
+ * `attachment` joined the list in SHI-2. It is "editable" only in the sense
74
+ * that the schema has a node for it — the block is an atom with nothing inside
75
+ * to type into, and what the editor offers is inserting and deleting one.
76
+ *
77
+ * **`table` joined in UIG-18**, with the three types inside it. The protocol
78
+ * names only `table`, not its parts, so what a row and a cell are called is
79
+ * decided by the editor that writes them — ProseMirror's names, which is what
80
+ * both apps' editors already are. A reader walks the nesting by name, and an
81
+ * unrecognised shape still renders its text, so a table written by anything
82
+ * else is not lost.
83
+ */
84
+ export declare const EDITOR_BLOCK_TYPES: ReadonlySet<string>;
85
+ /** The node type an unknown block is parked in — `@estiva-app/ui/editor`'s `UnknownBlock`. */
86
+ export declare const UNKNOWN_BLOCK_NODE = "unknownBlock";
87
+ /** The node type a `nostr:` reference is drawn as — `@estiva-app/ui/editor`'s `ReferenceNode`. */
88
+ export declare const REFERENCE_NODE = "reference";
89
+ /**
90
+ * The document a stored value is edited as, whichever model it arrived in —
91
+ * `format` is `contentFormatOf`'s classification of the event it came from.
92
+ */
93
+ export declare function documentForEditing(value: string, format: ContentFormat): BlockDocument;
94
+ export declare function toEditorDocument(document: BlockDocument): EditorDocument;
95
+ export declare function fromEditorDocument(document: EditorDocument): BlockDocument;
96
+ /**
97
+ * What a save publishes.
98
+ *
99
+ * An empty document stays empty **text** rather than becoming an empty
100
+ * document: there is nothing to address, and `{"type":"doc","content":[]}` in
101
+ * a `value` tag is a worse thing for another app to receive than "".
102
+ * `contentFormat` is what `buildActionEvents` is told, and absent for "".
103
+ */
104
+ export declare function publishableFromEditor(document: EditorDocument): {
105
+ value: string;
106
+ contentFormat?: typeof BLOCK_DOCUMENT_FORMAT;
107
+ };
108
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoF,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAGlI,OAAO,EAAE,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAA;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,KAAK,CAAA;IACX,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAcjD,CAAA;AAYF,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAChD,kGAAkG;AAClG,eAAO,MAAM,cAAc,cAAc,CAAA;AA6FzC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,aAAa,CAetF;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,cAAc,CAExE;AAgHD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,aAAa,CAM1E;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,CAAC,EAAE,OAAO,qBAAqB,CAAA;CAC7C,CAOA"}
package/dist/editor.js ADDED
@@ -0,0 +1,293 @@
1
+ import { newBlockId, parseBlockDocument, serializeBlockDocument, inlineTextOf } from './blocks.js';
2
+ import { markerTextToBlockDocument } from './bridge-content.js';
3
+ import { BLOCK_DOCUMENT_FORMAT } from './render.js';
4
+ /**
5
+ * The block types the editor's schema knows.
6
+ *
7
+ * Everything else is preserved as an atom rather than edited. Deliberately not
8
+ * `KNOWN_BLOCK_TYPES` — that is what the *protocol* names, and the editor
9
+ * knows a subset of it. `widget` is in the protocol and has no editing design
10
+ * yet, so it travels through untouched. An editor using this translation needs
11
+ * a node for each of these: StarterKit, TableKit, and `@estiva-app/ui/editor`'s
12
+ * `AttachmentNode`, whose `BlockId` names the same list.
13
+ *
14
+ * `attachment` joined the list in SHI-2. It is "editable" only in the sense
15
+ * that the schema has a node for it — the block is an atom with nothing inside
16
+ * to type into, and what the editor offers is inserting and deleting one.
17
+ *
18
+ * **`table` joined in UIG-18**, with the three types inside it. The protocol
19
+ * names only `table`, not its parts, so what a row and a cell are called is
20
+ * decided by the editor that writes them — ProseMirror's names, which is what
21
+ * both apps' editors already are. A reader walks the nesting by name, and an
22
+ * unrecognised shape still renders its text, so a table written by anything
23
+ * else is not lost.
24
+ */
25
+ export const EDITOR_BLOCK_TYPES = new Set([
26
+ 'paragraph',
27
+ 'heading',
28
+ 'bulletList',
29
+ 'orderedList',
30
+ 'listItem',
31
+ 'blockquote',
32
+ 'codeBlock',
33
+ 'horizontalRule',
34
+ 'attachment',
35
+ 'table',
36
+ 'tableRow',
37
+ 'tableHeader',
38
+ 'tableCell',
39
+ ]);
40
+ /**
41
+ * The nodes whose content is other blocks rather than inline runs.
42
+ *
43
+ * A list was the only one until UIG-18, which is why the check was written as
44
+ * two names. A table is four more — itself, its rows, and the two kinds of
45
+ * cell — and reading a cell's paragraphs as inline runs is exactly how the
46
+ * whole table came back empty the first time.
47
+ */
48
+ const BLOCK_CONTAINERS = new Set(['bulletList', 'orderedList', 'table', 'tableRow', 'tableHeader', 'tableCell']);
49
+ /** The node type an unknown block is parked in — `@estiva-app/ui/editor`'s `UnknownBlock`. */
50
+ export const UNKNOWN_BLOCK_NODE = 'unknownBlock';
51
+ /** The node type a `nostr:` reference is drawn as — `@estiva-app/ui/editor`'s `ReferenceNode`. */
52
+ export const REFERENCE_NODE = 'reference';
53
+ const isInlineRun = (content) => Array.isArray(content) && content.every((n) => n.type === 'text');
54
+ // ── Document → editor ────────────────────────────────────────────────────────
55
+ /**
56
+ * A run's `\n` is a line break in both models, and they spell it differently:
57
+ * the wire keeps it inside the text, ProseMirror uses a `hardBreak` node. A
58
+ * run split here is rejoined by {@link inlineFromEditor}.
59
+ */
60
+ function textNodes(text, marks) {
61
+ const out = [];
62
+ text.split('\n').forEach((line, i) => {
63
+ if (i > 0)
64
+ out.push({ type: 'hardBreak' });
65
+ // ProseMirror has no empty text node, and two consecutive breaks make one.
66
+ if (line !== '')
67
+ out.push({ type: 'text', text: line, ...(marks?.length ? { marks } : {}) });
68
+ });
69
+ return out;
70
+ }
71
+ function inlineToEditor(runs) {
72
+ return runs.flatMap((run) => {
73
+ const marks = run.marks ?? [];
74
+ const reference = marks.find((m) => m.type === 'reference');
75
+ if (reference) {
76
+ /*
77
+ An atom rather than a mark, and the difference is what a person sees.
78
+ A reference's text *is* its URI (`parseInlineReferences` splits the run
79
+ on it), so there is no prose to keep editable — and drawn as a mark it
80
+ would read as `nostr:naddr1…` while typing and as the object's name
81
+ while reading, which is the mode difference this ticket is about.
82
+
83
+ The run's other marks ride along so a bold reference comes back bold.
84
+ */
85
+ return [
86
+ {
87
+ type: REFERENCE_NODE,
88
+ attrs: {
89
+ uri: reference.attrs.uri,
90
+ marks: marks.filter((m) => m.type !== 'reference').map((m) => m.type),
91
+ },
92
+ },
93
+ ];
94
+ }
95
+ return textNodes(run.text, marks.map((m) => ({ type: m.type })));
96
+ });
97
+ }
98
+ function blockToEditor(block) {
99
+ if (!EDITOR_BLOCK_TYPES.has(block.type)) {
100
+ // `text` is §13.3's inline text, worked out here so the node view that
101
+ // shows it needs nothing from this package.
102
+ return { type: UNKNOWN_BLOCK_NODE, attrs: { blockId: block.id, source: block, text: inlineTextOf(block) } };
103
+ }
104
+ const attrs = { ...(block.attrs ?? {}), blockId: block.id };
105
+ if (block.type === 'codeBlock') {
106
+ // A fence is literal: its newlines are text, not breaks.
107
+ const text = isInlineRun(block.content) ? block.content.map((n) => n.text).join('') : '';
108
+ return { type: 'codeBlock', attrs, ...(text ? { content: [{ type: 'text', text }] } : {}) };
109
+ }
110
+ if (block.type === 'blockquote') {
111
+ /*
112
+ A quote is the same shape as a list item: §13.3's holds inline runs,
113
+ ProseMirror's holds blocks, and the paragraph is the wrapper. Without it
114
+ the quote's text was read as no text at all — typed into a description or
115
+ a message, a quote saved empty (found 30 September).
116
+ */
117
+ const inline = isInlineRun(block.content) ? inlineToEditor(block.content) : [];
118
+ return { type: 'blockquote', attrs, content: [{ type: 'paragraph', content: inline }] };
119
+ }
120
+ if (block.type === 'listItem') {
121
+ /*
122
+ §13.3's list item holds inline runs; ProseMirror's holds blocks. The
123
+ paragraph is that wrapper and nothing else — see `RichText`, which draws
124
+ a list item's *inline* content, so a list item that held anything but one
125
+ paragraph would render empty there.
126
+ */
127
+ const inline = isInlineRun(block.content) ? inlineToEditor(block.content) : [];
128
+ return { type: 'listItem', attrs, content: [{ type: 'paragraph', content: inline }] };
129
+ }
130
+ if (block.content === undefined)
131
+ return { type: block.type, attrs };
132
+ const content = isInlineRun(block.content)
133
+ ? inlineToEditor(block.content)
134
+ : block.content.map(blockToEditor);
135
+ return { type: block.type, attrs, ...(content.length ? { content } : {}) };
136
+ }
137
+ /**
138
+ * The document a stored value is edited as, whichever model it arrived in —
139
+ * `format` is `contentFormatOf`'s classification of the event it came from.
140
+ */
141
+ export function documentForEditing(value, format) {
142
+ if (value.trim() === '')
143
+ return { type: 'doc', content: [] };
144
+ // The classification off the event's tag ('marker' | 'blocks' | 'unknown'),
145
+ // not the tag's value — `BLOCK_DOCUMENT_FORMAT` is what gets written back.
146
+ if (format !== 'blocks')
147
+ return markerTextToBlockDocument(value);
148
+ try {
149
+ return parseBlockDocument(value);
150
+ }
151
+ catch {
152
+ /*
153
+ Tagged `blocks` and not a document. Reading it as marker text shows the
154
+ author what is actually stored, which is better than an empty editor
155
+ over a body that has something in it.
156
+ */
157
+ return markerTextToBlockDocument(value);
158
+ }
159
+ }
160
+ export function toEditorDocument(document) {
161
+ return { type: 'doc', content: document.content.map(blockToEditor) };
162
+ }
163
+ // ── Editor → document ────────────────────────────────────────────────────────
164
+ /** Mints on a missing id and on a repeat — see the header on duplicates. */
165
+ function idFor(node, seen) {
166
+ const claimed = node.attrs?.blockId;
167
+ const id = typeof claimed === 'string' && claimed !== '' && !seen.has(claimed) ? claimed : newBlockId();
168
+ seen.add(id);
169
+ return id;
170
+ }
171
+ function inlineFromEditor(nodes) {
172
+ const out = [];
173
+ for (const node of nodes) {
174
+ if (node.type === REFERENCE_NODE) {
175
+ const uri = String(node.attrs?.uri ?? '');
176
+ const carried = Array.isArray(node.attrs?.marks) ? node.attrs.marks : [];
177
+ const marks = [
178
+ ...carried.map((type) => ({ type })),
179
+ { type: 'reference', attrs: { uri } },
180
+ ];
181
+ out.push({ type: 'text', text: uri, marks });
182
+ continue;
183
+ }
184
+ if (node.type === 'hardBreak') {
185
+ // Rejoin onto the previous run where there is one, so a paragraph is not
186
+ // split into three runs by one break.
187
+ const last = out[out.length - 1];
188
+ if (last && !last.marks?.some((m) => m.type === 'reference'))
189
+ last.text += '\n';
190
+ else
191
+ out.push({ type: 'text', text: '\n' });
192
+ continue;
193
+ }
194
+ if (node.type !== 'text' || node.text === undefined)
195
+ continue;
196
+ const marks = (node.marks ?? []).map((m) => ({ type: m.type }));
197
+ const last = out[out.length - 1];
198
+ /*
199
+ Merge runs that carry the same marks. ProseMirror splits a text node
200
+ wherever a mark starts or a break lands, so a plain paragraph typed with
201
+ one Shift+Enter comes back as three nodes; the wire format has no reason
202
+ to keep that seam and a diff of two identical documents should be empty.
203
+ */
204
+ if (last && sameMarks(last.marks ?? [], marks))
205
+ last.text += node.text;
206
+ else
207
+ out.push({ type: 'text', text: node.text, ...(marks.length ? { marks } : {}) });
208
+ }
209
+ return out;
210
+ }
211
+ function sameMarks(a, b) {
212
+ if (a.length !== b.length)
213
+ return false;
214
+ if (a.some((m) => m.type === 'reference') || b.some((m) => m.type === 'reference'))
215
+ return false;
216
+ return a.every((m, i) => m.type === b[i].type);
217
+ }
218
+ function blockFromEditor(node, seen) {
219
+ if (node.type === UNKNOWN_BLOCK_NODE) {
220
+ /*
221
+ Handed back exactly as it arrived, id included. Re-minting it here would
222
+ be the silent deletion this file exists to prevent, one step later: the
223
+ block would survive and every comment anchored to it would not.
224
+ */
225
+ const source = node.attrs?.source;
226
+ if (!source)
227
+ return null;
228
+ seen.add(source.id);
229
+ return source;
230
+ }
231
+ const { blockId: _drop, ...rest } = node.attrs ?? {};
232
+ /*
233
+ A ProseMirror attribute that was never set is `null`, and §13.3's optional
234
+ fields are *absent* rather than null — a reader checking `attrs.thumb` copes
235
+ either way, but `imetaTag` would serialise `thumb null` and the relay would
236
+ refuse the event. Dropped here, where every block passes through, rather
237
+ than in the one place that noticed.
238
+ */
239
+ const attrs = Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== null && v !== undefined));
240
+ const id = idFor(node, seen);
241
+ const base = { type: node.type, id, ...(Object.keys(attrs).length ? { attrs } : {}) };
242
+ if (node.type === 'codeBlock') {
243
+ const text = (node.content ?? []).map((n) => n.text ?? '').join('');
244
+ return { ...base, ...(text ? { content: [{ type: 'text', text }] } : {}) };
245
+ }
246
+ if (node.type === 'blockquote') {
247
+ // Back out of the paragraph wrappers; a second paragraph in a quote is a second line of it.
248
+ const inline = [];
249
+ (node.content ?? []).forEach((child, i) => {
250
+ if (i > 0)
251
+ inline.push({ type: 'text', text: '\n' });
252
+ inline.push(...inlineFromEditor(child.content ?? []));
253
+ });
254
+ return { ...base, content: inline };
255
+ }
256
+ if (node.type === 'listItem') {
257
+ // Back out of the paragraph wrapper. A list item carries inline runs on
258
+ // the wire — see `blockToEditor`.
259
+ const inline = (node.content ?? []).flatMap((child) => inlineFromEditor(child.content ?? []));
260
+ return { ...base, content: inline };
261
+ }
262
+ if (BLOCK_CONTAINERS.has(node.type)) {
263
+ const children = (node.content ?? [])
264
+ .map((child) => blockFromEditor(child, seen))
265
+ .filter((b) => b !== null);
266
+ return { ...base, content: children };
267
+ }
268
+ const content = inlineFromEditor(node.content ?? []);
269
+ return { ...base, ...(content.length ? { content } : {}) };
270
+ }
271
+ export function fromEditorDocument(document) {
272
+ const seen = new Set();
273
+ return {
274
+ type: 'doc',
275
+ content: document.content.map((node) => blockFromEditor(node, seen)).filter((b) => b !== null),
276
+ };
277
+ }
278
+ /**
279
+ * What a save publishes.
280
+ *
281
+ * An empty document stays empty **text** rather than becoming an empty
282
+ * document: there is nothing to address, and `{"type":"doc","content":[]}` in
283
+ * a `value` tag is a worse thing for another app to receive than "".
284
+ * `contentFormat` is what `buildActionEvents` is told, and absent for "".
285
+ */
286
+ export function publishableFromEditor(document) {
287
+ const blocks = fromEditorDocument(document);
288
+ const empty = blocks.content.every((b) => b.type === 'paragraph' && (b.content === undefined || b.content.length === 0));
289
+ if (empty)
290
+ return { value: '' };
291
+ return { value: serializeBlockDocument(blocks), contentFormat: BLOCK_DOCUMENT_FORMAT };
292
+ }
293
+ //# sourceMappingURL=editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAA;AAClI,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,qBAAqB,EAAsB,MAAM,aAAa,CAAA;AA8DvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IAC7D,WAAW;IACX,SAAS;IACT,YAAY;IACZ,aAAa;IACb,UAAU;IACV,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,YAAY;IACZ,OAAO;IACP,UAAU;IACV,aAAa;IACb,WAAW;CACZ,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAA;AAEhH,8FAA8F;AAC9F,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAA;AAChD,kGAAkG;AAClG,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AAEzC,MAAM,WAAW,GAAG,CAAC,OAAyB,EAA+B,EAAE,CAC7E,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAuB,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;AAE1F,gFAAgF;AAEhF;;;;GAIG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,KAA0B;IACzD,MAAM,GAAG,GAAiB,EAAE,CAAA;IAC5B,IAAI,CAAC,KAAK,CAA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AAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAwB;IACzD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,OAAO;QACL,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAc,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;KAC3G,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAwB;IAI5D,MAAM,MAAM,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAChC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CACrF,CAAA;IACD,IAAI,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IAC/B,OAAO,EAAE,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA;AACxF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -46,7 +46,7 @@
46
46
  /** Bumped by hand with the version in package.json — `test/version.test.ts`
47
47
  * pins the two together. It exists so "the upgrade reached the app" can be
48
48
  * checked by grepping a built bundle rather than by trusting a lockfile. */
49
- export declare const PROTOCOL_VERSION = "0.25.0";
49
+ export declare const PROTOCOL_VERSION = "0.26.0";
50
50
  export { type NostrTag, type UnsignedEvent, type SignedEvent, type Profile, type ThreadRef, type ChannelVisibility, type ChannelKind, type MemberRole, type FolderOp, type Label, type ResolutionAction, KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE, computeEventId, toNostrSeconds, canonicalChannelName, threadTags, addr, relayAuthUrl, buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditChannelMetadata, buildFolderCommand, buildAddMember, buildDmOpen, buildDmHide, buildReaction, buildDeletion, buildEdit, buildMessage, buildResolution, buildBareFile, buildComponent, buildHighlight, buildUnsignedRelayAuthEvent, } from './events.js';
51
51
  export { type AddressPointer, type EventPointer, encodeNevent, decodeNevent, convertBits, bech32Encode, bech32Decode, encodeNaddr, decodeNaddr, pointerToAddress, addressToPointer, addrToNaddr, naddrToAddr, referenceToPointer, NADDR_RE, findNaddrs, stripNaddrs, encodeNpub, decodeNpub, NOSTR_URI_RE, findNostrUris, } from './nip19.js';
52
52
  export { type AuthEventArgs, TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
@@ -58,6 +58,7 @@ export { type InlineMark, type InlineMarkSpan, type BodySegment, type InlineMark
58
58
  export { type Block, type BlockDocument, type KnownBlockType, KNOWN_BLOCK_TYPES, BlockDocumentError, validateBlockDocument, parseBlockDocument, serializeBlockDocument, newBlockId, assignMissingBlockIds, blockIds, findBlock, inlineTextOf, documentText, } from './blocks.js';
59
59
  export { type RenderInline, type RenderBlock, type RenderFormat, type ContentFormat, CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, } from './render.js';
60
60
  export { markerTextToBlockDocument, blockDocumentToMarkerText, } from './bridge-content.js';
61
+ export { type EditorNode, type EditorDocument, EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
61
62
  export { type BlockAnchor, BLOCK_ANCHOR_TAG, blockAnchorOf, resolveBlockAnchor, } from './anchors.js';
62
63
  export { type BlossomVerb, type Imeta, BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, type BlobFetchLike, type BlobResponseLike, type FetchedBlob, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, type UploadedBlob, type BlobUploadFetchLike, } from './media.js';
63
64
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,WAAW,CAAA;AAExC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,EAEZ,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MA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qB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,WAAW,EAChB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,GACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,WAAW,CAAA;AAExC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB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ClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,WAAW,EAChB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,GACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@
46
46
  /** Bumped by hand with the version in package.json — `test/version.test.ts`
47
47
  * pins the two together. It exists so "the upgrade reached the app" can be
48
48
  * checked by grepping a built bundle rather than by trusting a lockfile. */
49
- export const PROTOCOL_VERSION = '0.25.0';
49
+ export const PROTOCOL_VERSION = '0.26.0';
50
50
  export {
51
51
  // constants
52
52
  KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE,
@@ -64,6 +64,7 @@ export { parseInlineMarks, wrapInlineMarks, parseBodySegments, stripInlineFormat
64
64
  export { KNOWN_BLOCK_TYPES, BlockDocumentError, validateBlockDocument, parseBlockDocument, serializeBlockDocument, newBlockId, assignMissingBlockIds, blockIds, findBlock, inlineTextOf, documentText, } from './blocks.js';
65
65
  export { CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, } from './render.js';
66
66
  export { markerTextToBlockDocument, blockDocumentToMarkerText, } from './bridge-content.js';
67
+ export { EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
67
68
  export { BLOCK_ANCHOR_TAG, blockAnchorOf, resolveBlockAnchor, } from './anchors.js';
68
69
  export { BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, } from './media.js';
69
70
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB;AACjB,8CAA8C;AAC9C,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY;AACZ,WAAW;AACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAA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AClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,GAGlB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB;AACjB,8CAA8C;AAC9C,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY;AACZ,WAAW;AACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAEL,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAGL,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAOL,oBAAoB,EACp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
3
+ "version": "0.26.0",
4
4
  "description": "The Estiva wire format: Buzz-shaped Nostr event builders, NIP-01 ids, NIP-19 naddr, NIP-98 HTTP auth, and the relay clients. Speaks the protocol; interprets nothing.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/editor.ts ADDED
@@ -0,0 +1,370 @@
1
+ import { newBlockId, parseBlockDocument, serializeBlockDocument, inlineTextOf, type Block, type BlockDocument } from './blocks.js'
2
+ import { markerTextToBlockDocument } from './bridge-content.js'
3
+ import type { InlineMarkNode, InlineTextNode } from './content.js'
4
+ import { BLOCK_DOCUMENT_FORMAT, type ContentFormat } from './render.js'
5
+
6
+ /**
7
+ * A block document, in and out of an editor — SPEC §13.3, RIC-14, MAN-9.
8
+ *
9
+ * `toRenderTree` is how a §13.3 document is *read*; this is how one is
10
+ * *edited*, so that every app writing one keeps the same ids. Written in Ship
11
+ * for its descriptions (RIC-14) and moved here when Peek became the second
12
+ * editor of the same documents (MAN-9, ADR 0002 §10). The editor schema these
13
+ * nodes need — the id attribute, the unknown block, the reference and the
14
+ * attachment — is `@estiva-app/ui/editor`'s.
15
+ *
16
+ * **The two models are the same shape already**, which is the reason this file
17
+ * is a translation rather than a design. SPEC §13.3's document is
18
+ * `{type: 'doc', content: [{type, id, attrs, content}]}` and ProseMirror's is
19
+ * `{type: 'doc', content: [{type, attrs, content}]}`; the block types §13.3
20
+ * names are ProseMirror's node names. So the whole conversion is: **the id
21
+ * moves between a field and an attribute**, and a reference moves between a
22
+ * mark and an atom.
23
+ *
24
+ * Marker text is still what a **legacy** body is written in and this reads it
25
+ * — `markerTextToBlockDocument` — it simply stops being what a person is shown
26
+ * while typing.
27
+ *
28
+ * No editor library is imported. The output is ProseMirror's JSON, a data
29
+ * shape, so this stays a pure function of the document like the rest of the
30
+ * package.
31
+ *
32
+ * ## Three things it refuses to lose
33
+ *
34
+ * **An unknown block.** §13.3 says a reader MUST render an unknown block's
35
+ * inline text and MUST NOT drop it silently. An editor is worse than a reader
36
+ * here: ProseMirror discards a node its schema does not know, and the save
37
+ * that follows would delete a `table` or a `widget` from somebody else's
38
+ * description with no error anywhere. So an unknown block becomes an atom that
39
+ * carries its original JSON and hands it back untouched.
40
+ *
41
+ * **A block id.** An anchored comment binds to `<address> + <block id>`
42
+ * (RFC 0.4 §6), so an edit that re-mints ids detaches every comment on the
43
+ * page. Ids ride in `attrs.blockId` and survive every edit that does not
44
+ * replace the block — which is what ProseMirror already gives us, since it
45
+ * preserves attributes across typing.
46
+ *
47
+ * **A duplicate id.** Copy a block, paste it, and both copies carry the same
48
+ * id — a document `validateBlockDocument` rejects and an anchor that points at
49
+ * two places. The second one gets a fresh id on the way out.
50
+ */
51
+
52
+ /** A ProseMirror/Tiptap node, as JSON. */
53
+ export interface EditorNode {
54
+ type: string
55
+ attrs?: Record<string, unknown>
56
+ content?: EditorNode[]
57
+ marks?: { type: string; attrs?: Record<string, unknown> }[]
58
+ text?: string
59
+ }
60
+
61
+ export interface EditorDocument {
62
+ type: 'doc'
63
+ content: EditorNode[]
64
+ }
65
+
66
+ /**
67
+ * The block types the editor's schema knows.
68
+ *
69
+ * Everything else is preserved as an atom rather than edited. Deliberately not
70
+ * `KNOWN_BLOCK_TYPES` — that is what the *protocol* names, and the editor
71
+ * knows a subset of it. `widget` is in the protocol and has no editing design
72
+ * yet, so it travels through untouched. An editor using this translation needs
73
+ * a node for each of these: StarterKit, TableKit, and `@estiva-app/ui/editor`'s
74
+ * `AttachmentNode`, whose `BlockId` names the same list.
75
+ *
76
+ * `attachment` joined the list in SHI-2. It is "editable" only in the sense
77
+ * that the schema has a node for it — the block is an atom with nothing inside
78
+ * to type into, and what the editor offers is inserting and deleting one.
79
+ *
80
+ * **`table` joined in UIG-18**, with the three types inside it. The protocol
81
+ * names only `table`, not its parts, so what a row and a cell are called is
82
+ * decided by the editor that writes them — ProseMirror's names, which is what
83
+ * both apps' editors already are. A reader walks the nesting by name, and an
84
+ * unrecognised shape still renders its text, so a table written by anything
85
+ * else is not lost.
86
+ */
87
+ export const EDITOR_BLOCK_TYPES: ReadonlySet<string> = new Set([
88
+ 'paragraph',
89
+ 'heading',
90
+ 'bulletList',
91
+ 'orderedList',
92
+ 'listItem',
93
+ 'blockquote',
94
+ 'codeBlock',
95
+ 'horizontalRule',
96
+ 'attachment',
97
+ 'table',
98
+ 'tableRow',
99
+ 'tableHeader',
100
+ 'tableCell',
101
+ ])
102
+
103
+ /**
104
+ * The nodes whose content is other blocks rather than inline runs.
105
+ *
106
+ * A list was the only one until UIG-18, which is why the check was written as
107
+ * two names. A table is four more — itself, its rows, and the two kinds of
108
+ * cell — and reading a cell's paragraphs as inline runs is exactly how the
109
+ * whole table came back empty the first time.
110
+ */
111
+ const BLOCK_CONTAINERS = new Set(['bulletList', 'orderedList', 'table', 'tableRow', 'tableHeader', 'tableCell'])
112
+
113
+ /** The node type an unknown block is parked in — `@estiva-app/ui/editor`'s `UnknownBlock`. */
114
+ export const UNKNOWN_BLOCK_NODE = 'unknownBlock'
115
+ /** The node type a `nostr:` reference is drawn as — `@estiva-app/ui/editor`'s `ReferenceNode`. */
116
+ export const REFERENCE_NODE = 'reference'
117
+
118
+ const isInlineRun = (content: Block['content']): content is InlineTextNode[] =>
119
+ Array.isArray(content) && content.every((n) => (n as { type?: string }).type === 'text')
120
+
121
+ // ── Document → editor ────────────────────────────────────────────────────────
122
+
123
+ /**
124
+ * A run's `\n` is a line break in both models, and they spell it differently:
125
+ * the wire keeps it inside the text, ProseMirror uses a `hardBreak` node. A
126
+ * run split here is rejoined by {@link inlineFromEditor}.
127
+ */
128
+ function textNodes(text: string, marks: EditorNode['marks']): EditorNode[] {
129
+ const out: EditorNode[] = []
130
+ text.split('\n').forEach((line, i) => {
131
+ if (i > 0) out.push({ type: 'hardBreak' })
132
+ // ProseMirror has no empty text node, and two consecutive breaks make one.
133
+ if (line !== '') out.push({ type: 'text', text: line, ...(marks?.length ? { marks } : {}) })
134
+ })
135
+ return out
136
+ }
137
+
138
+ function inlineToEditor(runs: readonly InlineTextNode[]): EditorNode[] {
139
+ return runs.flatMap((run) => {
140
+ const marks = run.marks ?? []
141
+ const reference = marks.find((m): m is Extract<InlineMarkNode, { type: 'reference' }> => m.type === 'reference')
142
+ if (reference) {
143
+ /*
144
+ An atom rather than a mark, and the difference is what a person sees.
145
+ A reference's text *is* its URI (`parseInlineReferences` splits the run
146
+ on it), so there is no prose to keep editable — and drawn as a mark it
147
+ would read as `nostr:naddr1…` while typing and as the object's name
148
+ while reading, which is the mode difference this ticket is about.
149
+
150
+ The run's other marks ride along so a bold reference comes back bold.
151
+ */
152
+ return [
153
+ {
154
+ type: REFERENCE_NODE,
155
+ attrs: {
156
+ uri: reference.attrs.uri,
157
+ marks: marks.filter((m) => m.type !== 'reference').map((m) => m.type),
158
+ },
159
+ },
160
+ ]
161
+ }
162
+ return textNodes(run.text, marks.map((m) => ({ type: m.type })))
163
+ })
164
+ }
165
+
166
+ function blockToEditor(block: Block): EditorNode {
167
+ if (!EDITOR_BLOCK_TYPES.has(block.type)) {
168
+ // `text` is §13.3's inline text, worked out here so the node view that
169
+ // shows it needs nothing from this package.
170
+ return { type: UNKNOWN_BLOCK_NODE, attrs: { blockId: block.id, source: block, text: inlineTextOf(block) } }
171
+ }
172
+ const attrs = { ...(block.attrs ?? {}), blockId: block.id }
173
+
174
+ if (block.type === 'codeBlock') {
175
+ // A fence is literal: its newlines are text, not breaks.
176
+ const text = isInlineRun(block.content) ? block.content.map((n) => n.text).join('') : ''
177
+ return { type: 'codeBlock', attrs, ...(text ? { content: [{ type: 'text', text }] } : {}) }
178
+ }
179
+
180
+ if (block.type === 'blockquote') {
181
+ /*
182
+ A quote is the same shape as a list item: §13.3's holds inline runs,
183
+ ProseMirror's holds blocks, and the paragraph is the wrapper. Without it
184
+ the quote's text was read as no text at all — typed into a description or
185
+ a message, a quote saved empty (found 30 September).
186
+ */
187
+ const inline = isInlineRun(block.content) ? inlineToEditor(block.content) : []
188
+ return { type: 'blockquote', attrs, content: [{ type: 'paragraph', content: inline }] }
189
+ }
190
+
191
+ if (block.type === 'listItem') {
192
+ /*
193
+ §13.3's list item holds inline runs; ProseMirror's holds blocks. The
194
+ paragraph is that wrapper and nothing else — see `RichText`, which draws
195
+ a list item's *inline* content, so a list item that held anything but one
196
+ paragraph would render empty there.
197
+ */
198
+ const inline = isInlineRun(block.content) ? inlineToEditor(block.content) : []
199
+ return { type: 'listItem', attrs, content: [{ type: 'paragraph', content: inline }] }
200
+ }
201
+
202
+ if (block.content === undefined) return { type: block.type, attrs }
203
+ const content = isInlineRun(block.content)
204
+ ? inlineToEditor(block.content)
205
+ : (block.content as Block[]).map(blockToEditor)
206
+ return { type: block.type, attrs, ...(content.length ? { content } : {}) }
207
+ }
208
+
209
+ /**
210
+ * The document a stored value is edited as, whichever model it arrived in —
211
+ * `format` is `contentFormatOf`'s classification of the event it came from.
212
+ */
213
+ export function documentForEditing(value: string, format: ContentFormat): BlockDocument {
214
+ if (value.trim() === '') return { type: 'doc', content: [] }
215
+ // The classification off the event's tag ('marker' | 'blocks' | 'unknown'),
216
+ // not the tag's value — `BLOCK_DOCUMENT_FORMAT` is what gets written back.
217
+ if (format !== 'blocks') return markerTextToBlockDocument(value)
218
+ try {
219
+ return parseBlockDocument(value)
220
+ } catch {
221
+ /*
222
+ Tagged `blocks` and not a document. Reading it as marker text shows the
223
+ author what is actually stored, which is better than an empty editor
224
+ over a body that has something in it.
225
+ */
226
+ return markerTextToBlockDocument(value)
227
+ }
228
+ }
229
+
230
+ export function toEditorDocument(document: BlockDocument): EditorDocument {
231
+ return { type: 'doc', content: document.content.map(blockToEditor) }
232
+ }
233
+
234
+ // ── Editor → document ────────────────────────────────────────────────────────
235
+
236
+ /** Mints on a missing id and on a repeat — see the header on duplicates. */
237
+ function idFor(node: EditorNode, seen: Set<string>): string {
238
+ const claimed = node.attrs?.blockId
239
+ const id = typeof claimed === 'string' && claimed !== '' && !seen.has(claimed) ? claimed : newBlockId()
240
+ seen.add(id)
241
+ return id
242
+ }
243
+
244
+ function inlineFromEditor(nodes: readonly EditorNode[]): InlineTextNode[] {
245
+ const out: InlineTextNode[] = []
246
+ for (const node of nodes) {
247
+ if (node.type === REFERENCE_NODE) {
248
+ const uri = String(node.attrs?.uri ?? '')
249
+ const carried = Array.isArray(node.attrs?.marks) ? (node.attrs.marks as string[]) : []
250
+ const marks: InlineMarkNode[] = [
251
+ ...carried.map((type) => ({ type }) as InlineMarkNode),
252
+ { type: 'reference', attrs: { uri } },
253
+ ]
254
+ out.push({ type: 'text', text: uri, marks })
255
+ continue
256
+ }
257
+ if (node.type === 'hardBreak') {
258
+ // Rejoin onto the previous run where there is one, so a paragraph is not
259
+ // split into three runs by one break.
260
+ const last = out[out.length - 1]
261
+ if (last && !last.marks?.some((m) => m.type === 'reference')) last.text += '\n'
262
+ else out.push({ type: 'text', text: '\n' })
263
+ continue
264
+ }
265
+ if (node.type !== 'text' || node.text === undefined) continue
266
+ const marks = (node.marks ?? []).map((m) => ({ type: m.type }) as InlineMarkNode)
267
+ const last = out[out.length - 1]
268
+ /*
269
+ Merge runs that carry the same marks. ProseMirror splits a text node
270
+ wherever a mark starts or a break lands, so a plain paragraph typed with
271
+ one Shift+Enter comes back as three nodes; the wire format has no reason
272
+ to keep that seam and a diff of two identical documents should be empty.
273
+ */
274
+ if (last && sameMarks(last.marks ?? [], marks)) last.text += node.text
275
+ else out.push({ type: 'text', text: node.text, ...(marks.length ? { marks } : {}) })
276
+ }
277
+ return out
278
+ }
279
+
280
+ function sameMarks(a: readonly InlineMarkNode[], b: readonly InlineMarkNode[]): boolean {
281
+ if (a.length !== b.length) return false
282
+ if (a.some((m) => m.type === 'reference') || b.some((m) => m.type === 'reference')) return false
283
+ return a.every((m, i) => m.type === b[i].type)
284
+ }
285
+
286
+ function blockFromEditor(node: EditorNode, seen: Set<string>): Block | null {
287
+ if (node.type === UNKNOWN_BLOCK_NODE) {
288
+ /*
289
+ Handed back exactly as it arrived, id included. Re-minting it here would
290
+ be the silent deletion this file exists to prevent, one step later: the
291
+ block would survive and every comment anchored to it would not.
292
+ */
293
+ const source = node.attrs?.source as Block | undefined
294
+ if (!source) return null
295
+ seen.add(source.id)
296
+ return source
297
+ }
298
+
299
+ const { blockId: _drop, ...rest } = node.attrs ?? {}
300
+ /*
301
+ A ProseMirror attribute that was never set is `null`, and §13.3's optional
302
+ fields are *absent* rather than null — a reader checking `attrs.thumb` copes
303
+ either way, but `imetaTag` would serialise `thumb null` and the relay would
304
+ refuse the event. Dropped here, where every block passes through, rather
305
+ than in the one place that noticed.
306
+ */
307
+ const attrs = Object.fromEntries(Object.entries(rest).filter(([, v]) => v !== null && v !== undefined))
308
+ const id = idFor(node, seen)
309
+ const base = { type: node.type, id, ...(Object.keys(attrs).length ? { attrs } : {}) }
310
+
311
+ if (node.type === 'codeBlock') {
312
+ const text = (node.content ?? []).map((n) => n.text ?? '').join('')
313
+ return { ...base, ...(text ? { content: [{ type: 'text', text }] } : {}) }
314
+ }
315
+
316
+ if (node.type === 'blockquote') {
317
+ // Back out of the paragraph wrappers; a second paragraph in a quote is a second line of it.
318
+ const inline: InlineTextNode[] = []
319
+ ;(node.content ?? []).forEach((child, i) => {
320
+ if (i > 0) inline.push({ type: 'text', text: '\n' })
321
+ inline.push(...inlineFromEditor(child.content ?? []))
322
+ })
323
+ return { ...base, content: inline }
324
+ }
325
+
326
+ if (node.type === 'listItem') {
327
+ // Back out of the paragraph wrapper. A list item carries inline runs on
328
+ // the wire — see `blockToEditor`.
329
+ const inline = (node.content ?? []).flatMap((child) => inlineFromEditor(child.content ?? []))
330
+ return { ...base, content: inline }
331
+ }
332
+
333
+ if (BLOCK_CONTAINERS.has(node.type)) {
334
+ const children = (node.content ?? [])
335
+ .map((child) => blockFromEditor(child, seen))
336
+ .filter((b): b is Block => b !== null)
337
+ return { ...base, content: children }
338
+ }
339
+
340
+ const content = inlineFromEditor(node.content ?? [])
341
+ return { ...base, ...(content.length ? { content } : {}) }
342
+ }
343
+
344
+ export function fromEditorDocument(document: EditorDocument): BlockDocument {
345
+ const seen = new Set<string>()
346
+ return {
347
+ type: 'doc',
348
+ content: document.content.map((node) => blockFromEditor(node, seen)).filter((b): b is Block => b !== null),
349
+ }
350
+ }
351
+
352
+ /**
353
+ * What a save publishes.
354
+ *
355
+ * An empty document stays empty **text** rather than becoming an empty
356
+ * document: there is nothing to address, and `{"type":"doc","content":[]}` in
357
+ * a `value` tag is a worse thing for another app to receive than "".
358
+ * `contentFormat` is what `buildActionEvents` is told, and absent for "".
359
+ */
360
+ export function publishableFromEditor(document: EditorDocument): {
361
+ value: string
362
+ contentFormat?: typeof BLOCK_DOCUMENT_FORMAT
363
+ } {
364
+ const blocks = fromEditorDocument(document)
365
+ const empty = blocks.content.every(
366
+ (b) => b.type === 'paragraph' && (b.content === undefined || b.content.length === 0),
367
+ )
368
+ if (empty) return { value: '' }
369
+ return { value: serializeBlockDocument(blocks), contentFormat: BLOCK_DOCUMENT_FORMAT }
370
+ }
package/src/index.ts CHANGED
@@ -47,7 +47,7 @@
47
47
  /** Bumped by hand with the version in package.json — `test/version.test.ts`
48
48
  * pins the two together. It exists so "the upgrade reached the app" can be
49
49
  * checked by grepping a built bundle rather than by trusting a lockfile. */
50
- export const PROTOCOL_VERSION = '0.25.0'
50
+ export const PROTOCOL_VERSION = '0.26.0'
51
51
 
52
52
  export {
53
53
  // types
@@ -227,6 +227,18 @@ export {
227
227
  blockDocumentToMarkerText,
228
228
  } from './bridge-content.js'
229
229
 
230
+ export {
231
+ type EditorNode,
232
+ type EditorDocument,
233
+ EDITOR_BLOCK_TYPES,
234
+ UNKNOWN_BLOCK_NODE,
235
+ REFERENCE_NODE,
236
+ documentForEditing,
237
+ toEditorDocument,
238
+ fromEditorDocument,
239
+ publishableFromEditor,
240
+ } from './editor.js'
241
+
230
242
  export {
231
243
  type BlockAnchor,
232
244
  BLOCK_ANCHOR_TAG,