@estiva-app/protocol 0.36.0 → 0.37.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 +17 -0
- package/dist/anchors.d.ts +2 -0
- package/dist/anchors.d.ts.map +1 -1
- package/dist/anchors.js +2 -0
- package/dist/anchors.js.map +1 -1
- package/dist/comment-anchor.d.ts +147 -0
- package/dist/comment-anchor.d.ts.map +1 -0
- package/dist/comment-anchor.js +304 -0
- package/dist/comment-anchor.js.map +1 -0
- package/dist/editor.d.ts +2 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js.map +1 -1
- package/dist/embeds.d.ts.map +1 -1
- package/dist/embeds.js +2 -0
- package/dist/embeds.js.map +1 -1
- package/dist/events.d.ts +2 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anchors.ts +2 -0
- package/src/comment-anchor.ts +339 -0
- package/src/editor.ts +2 -0
- package/src/embeds.ts +2 -0
- package/src/events.ts +2 -0
- package/src/index.ts +20 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A comment on a selection — SPEC §13.3 "A run of blocks" and §13.6 (LEAF-7).
|
|
3
|
+
*
|
|
4
|
+
* A comment's anchor is a run of blocks, listed in its `block` tag the way a
|
|
5
|
+
* `part` lists one, narrowed by the words where the selection starts and ends
|
|
6
|
+
* in a `quote` tag:
|
|
7
|
+
*
|
|
8
|
+
* ["block", <first id>, …, <last id>]
|
|
9
|
+
* ["quote", <start words>, <end words> | "", <prefix> | "", <suffix> | ""]
|
|
10
|
+
*
|
|
11
|
+
* - A selection inside one block quotes exactly its words.
|
|
12
|
+
* - Across blocks, the start words lie in the first listed block and the end
|
|
13
|
+
* words in the last, each inside one block's text, so no rule for joining
|
|
14
|
+
* blocks is needed.
|
|
15
|
+
* - A selection of whole blocks carries no `quote`: it is about the blocks and
|
|
16
|
+
* grows with the run.
|
|
17
|
+
* - Prefix and suffix are written only when the words repeat in their block.
|
|
18
|
+
*
|
|
19
|
+
* Resolving one has five outcomes, and the new one is `reworded`: the run is
|
|
20
|
+
* there and the words are not. It is not `detached` — the blocks still are —
|
|
21
|
+
* and it is not `resolved`, because nothing may be highlighted on a guess.
|
|
22
|
+
*
|
|
23
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-comment-remembers-where-its-selection-starts-and-ends.md
|
|
24
|
+
*/
|
|
25
|
+
import { type Block, type BlockDocument, inlineTextOf, parseBlockDocument } from './blocks.js'
|
|
26
|
+
import { BLOCK_ANCHOR_TAG } from './anchors.js'
|
|
27
|
+
import type { ContentFormat } from './render.js'
|
|
28
|
+
|
|
29
|
+
/** The tag carrying a comment's words (§13.6). */
|
|
30
|
+
export const QUOTE_TAG = 'quote'
|
|
31
|
+
|
|
32
|
+
/** The most ids a run lists: a longer selection keeps its first and last 32 (§13.3). */
|
|
33
|
+
export const MAX_RUN_IDS = 64
|
|
34
|
+
|
|
35
|
+
/** A reader reads no further into a `block` tag than this many entries. */
|
|
36
|
+
export const MAX_RUN_ENTRIES_READ = 1024
|
|
37
|
+
|
|
38
|
+
/** Up to this many characters, a selection's words are quoted whole; a reader voids a longer quote string. */
|
|
39
|
+
export const QUOTE_WHOLE_MAX = 1000
|
|
40
|
+
|
|
41
|
+
/** Otherwise, about this many characters at each end, cut at a word boundary. */
|
|
42
|
+
export const QUOTE_END_LENGTH = 150
|
|
43
|
+
|
|
44
|
+
/** How much of the text around repeated words is kept to tell them apart. */
|
|
45
|
+
export const QUOTE_CONTEXT_LENGTH = 32
|
|
46
|
+
|
|
47
|
+
/** The ids a run may name: safe in a URL fragment and a selector (§13.3, §13.6.1). */
|
|
48
|
+
const BLOCK_ID = /^[A-Za-z0-9_-]{1,64}$/
|
|
49
|
+
|
|
50
|
+
/** The first 32 and the last 32 of a list longer than {@link MAX_RUN_IDS}. */
|
|
51
|
+
function capRun(ids: readonly string[]): string[] {
|
|
52
|
+
if (ids.length <= MAX_RUN_IDS) return [...ids]
|
|
53
|
+
const half = MAX_RUN_IDS / 2
|
|
54
|
+
return [...ids.slice(0, half), ...ids.slice(ids.length - half)]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A run's ids as §13.3 reads them: an invalid first id voids it; later ones are skipped; duplicates dropped. */
|
|
58
|
+
export function readRunIds(ids: readonly string[]): string[] | undefined {
|
|
59
|
+
const [first] = ids
|
|
60
|
+
if (first === undefined || !BLOCK_ID.test(first)) return undefined
|
|
61
|
+
// A writer lists at most 64; a list far longer is a stranger's, and is read
|
|
62
|
+
// no further than its first 1,024 entries, so it costs every reader little.
|
|
63
|
+
const out = new Set<string>()
|
|
64
|
+
for (const id of ids.slice(0, MAX_RUN_ENTRIES_READ)) if (BLOCK_ID.test(id)) out.add(id)
|
|
65
|
+
return capRun([...out])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The `block` tag for a run, ids in document order. One id is today's one-block tag, unchanged. */
|
|
69
|
+
export function blockRunTag(ids: readonly string[]): string[] {
|
|
70
|
+
return [BLOCK_ANCHOR_TAG, ...capRun(ids)]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The run a comment anchors to, or `undefined` when it anchors to none.
|
|
75
|
+
*
|
|
76
|
+
* Only a `kind:1111` anchors (§13.6). Every id from index 1 is the run; a
|
|
77
|
+
* reader that knows only one block reads index 1 and gets its first block.
|
|
78
|
+
*/
|
|
79
|
+
export function blockRunOf(event: { kind?: number; tags: string[][] }): string[] | undefined {
|
|
80
|
+
if (event.kind !== undefined && event.kind !== 1111) return undefined
|
|
81
|
+
const tag = event.tags.find((t) => t[0] === BLOCK_ANCHOR_TAG)
|
|
82
|
+
return tag ? readRunIds(tag.slice(1)) : undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Where each block sits: its parent's children (the document's own list at the top) and its index there. */
|
|
86
|
+
function placesIn(doc: BlockDocument): Map<string, { siblings: Block[]; index: number }> {
|
|
87
|
+
const out = new Map<string, { siblings: Block[]; index: number }>()
|
|
88
|
+
const walk = (blocks: Block[]) => {
|
|
89
|
+
blocks.forEach((block, index) => {
|
|
90
|
+
if (typeof block.id === 'string' && block.id !== '' && !out.has(block.id)) out.set(block.id, { siblings: blocks, index })
|
|
91
|
+
if (Array.isArray(block.content) && block.content.some((c) => (c as { type?: string }).type !== 'text')) walk(block.content as Block[])
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
walk(doc.content)
|
|
95
|
+
return out
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The blocks a run names in the document as it is now — §13.3's span — or
|
|
100
|
+
* `undefined` when none of its ids is present.
|
|
101
|
+
*
|
|
102
|
+
* The parent most of the present ids sit under (on a tie, the one of the
|
|
103
|
+
* earliest listed), and every child of it from the earliest to the latest of
|
|
104
|
+
* those ids, in current order. So a block inserted in the middle joins the run,
|
|
105
|
+
* a deleted end shortens it, and an id that drifted to another parent is left
|
|
106
|
+
* out rather than dragging the run across levels.
|
|
107
|
+
*/
|
|
108
|
+
export function resolveBlockRun(doc: BlockDocument, ids: readonly string[]): Block[] | undefined {
|
|
109
|
+
const places = placesIn(doc)
|
|
110
|
+
const groups: { siblings: Block[]; indexes: number[] }[] = []
|
|
111
|
+
for (const id of ids) {
|
|
112
|
+
const place = places.get(id)
|
|
113
|
+
if (!place) continue
|
|
114
|
+
const group = groups.find((g) => g.siblings === place.siblings)
|
|
115
|
+
if (group) group.indexes.push(place.index)
|
|
116
|
+
else groups.push({ siblings: place.siblings, indexes: [place.index] })
|
|
117
|
+
}
|
|
118
|
+
if (groups.length === 0) return undefined
|
|
119
|
+
const best = groups.reduce((a, b) => (b.indexes.length > a.indexes.length ? b : a))
|
|
120
|
+
return best.siblings.slice(Math.min(...best.indexes), Math.max(...best.indexes) + 1)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** A comment's words: where the selection starts and, across blocks or when long, where it ends. */
|
|
124
|
+
export interface Quote {
|
|
125
|
+
/** The selected words in the first block, or all of them when they fit. */
|
|
126
|
+
start: string
|
|
127
|
+
/** The selected words in the last block, when the selection crosses blocks or is long. */
|
|
128
|
+
end?: string
|
|
129
|
+
/** The text just before `start`, only when `start` repeats in its block. */
|
|
130
|
+
prefix?: string
|
|
131
|
+
/** The text just after the words, only when they repeat in their block. */
|
|
132
|
+
suffix?: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The `quote` tag, with empty placeholders only where a later value needs its index. */
|
|
136
|
+
export function quoteTag(quote: Quote): string[] {
|
|
137
|
+
const tag = [QUOTE_TAG, quote.start, quote.end ?? '', quote.prefix ?? '', quote.suffix ?? '']
|
|
138
|
+
while (tag.length > 2 && tag[tag.length - 1] === '') tag.pop()
|
|
139
|
+
return tag
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** A comment's `quote` tag, read. An empty start voids it; empty later values mean absent. */
|
|
143
|
+
export function quoteOf(event: { tags: string[][] }): Quote | undefined {
|
|
144
|
+
const tag = event.tags.find((t) => t[0] === QUOTE_TAG)
|
|
145
|
+
const [, start, end, prefix, suffix] = tag ?? []
|
|
146
|
+
if (!start || start.length > QUOTE_WHOLE_MAX || (end && end.length > QUOTE_WHOLE_MAX)) return undefined
|
|
147
|
+
return {
|
|
148
|
+
start,
|
|
149
|
+
...(end ? { end } : {}),
|
|
150
|
+
...(prefix ? { prefix } : {}),
|
|
151
|
+
...(suffix ? { suffix } : {}),
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** A place in a block's text: an offset into its wire text ({@link inlineTextOf}). */
|
|
156
|
+
export interface TextPoint {
|
|
157
|
+
block: string
|
|
158
|
+
offset: number
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The text a quote is matched in: §13.3's runs, a mention as its `nostr:` text,
|
|
163
|
+
* exactly as stored — not normalised, so an offset into it is an offset into
|
|
164
|
+
* the block's own text.
|
|
165
|
+
*/
|
|
166
|
+
function textOf(block: Block): string {
|
|
167
|
+
return inlineTextOf(block)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** How many times `words` occurs in `text` (none for empty words). */
|
|
171
|
+
function occurrences(text: string, words: string): number {
|
|
172
|
+
if (words === '') return 0
|
|
173
|
+
let count = 0
|
|
174
|
+
for (let at = text.indexOf(words); at !== -1; at = text.indexOf(words, at + 1)) count++
|
|
175
|
+
return count
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** At most `length` characters from the front of `text`, cut back to a word boundary when one is near. */
|
|
179
|
+
function headOf(text: string, length: number): string {
|
|
180
|
+
if (text.length <= length) return text
|
|
181
|
+
const cut = text.lastIndexOf(' ', length)
|
|
182
|
+
return text.slice(0, cut > length / 2 ? cut : length)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** At most `length` characters from the back of `text`, cut forward to a word boundary when one is near. */
|
|
186
|
+
function tailOf(text: string, length: number): string {
|
|
187
|
+
if (text.length <= length) return text
|
|
188
|
+
const from = text.length - length
|
|
189
|
+
const cut = text.indexOf(' ', from)
|
|
190
|
+
return text.slice(cut !== -1 && cut < from + length / 2 ? cut + 1 : from)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The anchor tags for a selection: the `block` run, and a `quote` unless the
|
|
195
|
+
* selection covers its first and last blocks whole.
|
|
196
|
+
*
|
|
197
|
+
* `run` is the selected blocks' ids in document order; `start` and `end` are
|
|
198
|
+
* where the selection begins in the first and ends in the last. Omit both for
|
|
199
|
+
* a selection of whole blocks. Nothing is trimmed: the words are exactly the
|
|
200
|
+
* block's text between the two points.
|
|
201
|
+
*/
|
|
202
|
+
export function selectionAnchorTags(
|
|
203
|
+
doc: BlockDocument,
|
|
204
|
+
run: readonly string[],
|
|
205
|
+
selection?: { start: TextPoint; end: TextPoint },
|
|
206
|
+
): string[][] {
|
|
207
|
+
if (!selection) return [blockRunTag(run)]
|
|
208
|
+
const places = placesIn(doc)
|
|
209
|
+
const blockOf = (id: string | undefined) => {
|
|
210
|
+
const place = id === undefined ? undefined : places.get(id)
|
|
211
|
+
if (!place) throw new Error(`block ${id} is not in the document`)
|
|
212
|
+
return textOf(place.siblings[place.index])
|
|
213
|
+
}
|
|
214
|
+
let ids = [...run]
|
|
215
|
+
let { start, end } = selection
|
|
216
|
+
if (start.block !== ids[0] || end.block !== ids[ids.length - 1]) throw new Error('a selection starts in the run\'s first block and ends in its last')
|
|
217
|
+
// A selection that starts at the very end of its first block, or ends at the
|
|
218
|
+
// very start of its last, holds no text in it: that block is not in the run.
|
|
219
|
+
if (ids.length > 1 && start.offset >= blockOf(start.block).length) {
|
|
220
|
+
ids = ids.slice(1)
|
|
221
|
+
start = { block: ids[0], offset: 0 }
|
|
222
|
+
}
|
|
223
|
+
if (ids.length > 1 && end.offset <= 0) {
|
|
224
|
+
ids = ids.slice(0, -1)
|
|
225
|
+
end = { block: ids[ids.length - 1], offset: blockOf(ids[ids.length - 1]).length }
|
|
226
|
+
}
|
|
227
|
+
const tags = [blockRunTag(ids)]
|
|
228
|
+
const firstText = blockOf(start.block)
|
|
229
|
+
const lastText = start.block === end.block ? firstText : blockOf(end.block)
|
|
230
|
+
if (start.offset === 0 && end.offset >= lastText.length) return tags
|
|
231
|
+
|
|
232
|
+
const quote: Quote = { start: '' }
|
|
233
|
+
if (start.block === end.block && end.offset - start.offset <= QUOTE_WHOLE_MAX) {
|
|
234
|
+
quote.start = firstText.slice(start.offset, end.offset)
|
|
235
|
+
} else {
|
|
236
|
+
const startWords = start.block === end.block ? firstText.slice(start.offset, end.offset) : firstText.slice(start.offset)
|
|
237
|
+
const endWords = start.block === end.block ? startWords : lastText.slice(0, end.offset)
|
|
238
|
+
quote.start = headOf(startWords, QUOTE_END_LENGTH)
|
|
239
|
+
quote.end = tailOf(endWords, QUOTE_END_LENGTH)
|
|
240
|
+
}
|
|
241
|
+
if (quote.start === '' || quote.end === '') return tags
|
|
242
|
+
if (occurrences(firstText, quote.start) > 1) quote.prefix = firstText.slice(Math.max(0, start.offset - QUOTE_CONTEXT_LENGTH), start.offset)
|
|
243
|
+
if (occurrences(lastText, quote.end ?? quote.start) > 1) quote.suffix = lastText.slice(end.offset, end.offset + QUOTE_CONTEXT_LENGTH)
|
|
244
|
+
if (quote.prefix === '') delete quote.prefix
|
|
245
|
+
if (quote.suffix === '') delete quote.suffix
|
|
246
|
+
tags.push(quoteTag(quote))
|
|
247
|
+
return tags
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* What a comment's anchor resolved to (§13.6). Five states, none a degree of
|
|
252
|
+
* another:
|
|
253
|
+
*
|
|
254
|
+
* - `unanchored` — no `block` tag: a comment about the whole object. A `quote`
|
|
255
|
+
* without a `block` is ignored.
|
|
256
|
+
* - `resolved` — the run is there and so are its words, or it quotes none.
|
|
257
|
+
* `words` says where to highlight; absent, the comment is about the blocks.
|
|
258
|
+
* - `reworded` — the run is there and its words are not, in order. Show the
|
|
259
|
+
* comment beside `blocks` with no highlight and `quote` as what the commenter
|
|
260
|
+
* quoted, never as what the page says; never as `detached`.
|
|
261
|
+
* - `unaddressable` — the body is not a block document.
|
|
262
|
+
* - `detached` — none of the run's blocks is left.
|
|
263
|
+
*/
|
|
264
|
+
export type CommentAnchor =
|
|
265
|
+
| { state: 'unanchored' }
|
|
266
|
+
| { state: 'resolved'; ids: string[]; blocks: Block[]; words?: { start: TextPoint; end: TextPoint } }
|
|
267
|
+
| { state: 'reworded'; ids: string[]; blocks: Block[]; quote: Quote }
|
|
268
|
+
| { state: 'unaddressable'; ids: string[] }
|
|
269
|
+
| { state: 'detached'; ids: string[] }
|
|
270
|
+
|
|
271
|
+
/** Where `words` sits in `text` at or after `from`: the occurrence whose context matches, else the first. */
|
|
272
|
+
function find(text: string, words: string, from: number, context: (at: number) => boolean): number {
|
|
273
|
+
let first = -1
|
|
274
|
+
for (let at = text.indexOf(words, from); at !== -1; at = text.indexOf(words, at + 1)) {
|
|
275
|
+
if (first === -1) first = at
|
|
276
|
+
if (context(at)) return at
|
|
277
|
+
}
|
|
278
|
+
return first
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Which of §13.6's five states a comment's anchor is in, against the body as it
|
|
283
|
+
* is now — the object's folded `description` (§6.10), never its root alone.
|
|
284
|
+
*
|
|
285
|
+
* `format` comes from the event carrying the body, as for
|
|
286
|
+
* {@link resolveBlockAnchor}. Matching is exact: a reader may suggest where
|
|
287
|
+
* reworded words might be, but never as `resolved`.
|
|
288
|
+
*/
|
|
289
|
+
export function resolveCommentAnchor(
|
|
290
|
+
event: { kind?: number; tags: string[][] },
|
|
291
|
+
value: string,
|
|
292
|
+
format: ContentFormat,
|
|
293
|
+
): CommentAnchor {
|
|
294
|
+
const ids = blockRunOf(event)
|
|
295
|
+
if (!ids) return { state: 'unanchored' }
|
|
296
|
+
if (format !== 'blocks') return { state: 'unaddressable', ids }
|
|
297
|
+
let doc: BlockDocument
|
|
298
|
+
try {
|
|
299
|
+
doc = parseBlockDocument(value)
|
|
300
|
+
} catch {
|
|
301
|
+
return { state: 'unaddressable', ids }
|
|
302
|
+
}
|
|
303
|
+
const blocks = resolveBlockRun(doc, ids)
|
|
304
|
+
if (!blocks) return { state: 'detached', ids }
|
|
305
|
+
const quote = quoteOf(event)
|
|
306
|
+
if (!quote) return { state: 'resolved', ids, blocks }
|
|
307
|
+
|
|
308
|
+
const reworded = { state: 'reworded' as const, ids, blocks, quote }
|
|
309
|
+
const first = blocks.findIndex((b) => b.id === ids[0])
|
|
310
|
+
const last = blocks.findIndex((b) => b.id === ids[ids.length - 1])
|
|
311
|
+
if (first === -1 || last === -1 || last < first) return reworded
|
|
312
|
+
const firstText = textOf(blocks[first])
|
|
313
|
+
const lastText = textOf(blocks[last])
|
|
314
|
+
const { start, end } = quote
|
|
315
|
+
// Context longer than a writer ever sends is a stranger's, and ignored: each
|
|
316
|
+
// check below is then a short comparison however often the words repeat.
|
|
317
|
+
const prefix = quote.prefix && quote.prefix.length <= QUOTE_CONTEXT_LENGTH ? quote.prefix : undefined
|
|
318
|
+
const suffix = quote.suffix && quote.suffix.length <= QUOTE_CONTEXT_LENGTH ? quote.suffix : undefined
|
|
319
|
+
const before = (text: string, i: number) => !prefix || text.slice(Math.max(0, i - prefix.length), i) === prefix
|
|
320
|
+
const after = (text: string, i: number) => !suffix || text.slice(i, i + suffix.length) === suffix
|
|
321
|
+
|
|
322
|
+
if (end === undefined) {
|
|
323
|
+
const at = find(firstText, start, 0, (i) => before(firstText, i) && after(firstText, i + start.length))
|
|
324
|
+
if (at === -1) return reworded
|
|
325
|
+
return { state: 'resolved', ids, blocks, words: { start: { block: ids[0], offset: at }, end: { block: ids[0], offset: at + start.length } } }
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const startAt = find(firstText, start, 0, (i) => before(firstText, i))
|
|
329
|
+
if (startAt === -1) return reworded
|
|
330
|
+
const from = first === last ? startAt + start.length : 0
|
|
331
|
+
const endAt = find(lastText, end, from, (i) => after(lastText, i + end.length))
|
|
332
|
+
if (endAt === -1) return reworded
|
|
333
|
+
return {
|
|
334
|
+
state: 'resolved',
|
|
335
|
+
ids,
|
|
336
|
+
blocks,
|
|
337
|
+
words: { start: { block: ids[0], offset: startAt }, end: { block: ids[ids.length - 1], offset: endAt + end.length } },
|
|
338
|
+
}
|
|
339
|
+
}
|
package/src/editor.ts
CHANGED
|
@@ -69,6 +69,8 @@ import { BLOCK_DOCUMENT_FORMAT, type ContentFormat } from './render.js'
|
|
|
69
69
|
* the original carried on into — the only place Enter-then-type above a
|
|
70
70
|
* paragraph can be told from the paragraph. It falls back to this rule, so a
|
|
71
71
|
* change to `holdsText` here belongs there too.
|
|
72
|
+
*
|
|
73
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/the-block-editor-kit-lives-in-protocol-and-ui.md
|
|
72
74
|
*/
|
|
73
75
|
|
|
74
76
|
/** A ProseMirror/Tiptap node, as JSON. */
|
package/src/embeds.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* `a`/`q` match: an edit carries no index tags (§6.8), and a value first named
|
|
18
18
|
* in an edit can still carry a card (Miky, 2026-10-13, OPT-16 kickoff).
|
|
19
19
|
* {@link cardsIn} applies that rule; {@link embedsOf} reads the tags alone.
|
|
20
|
+
*
|
|
21
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/where-a-link-sits-decides-how-it-draws.md
|
|
20
22
|
*/
|
|
21
23
|
import { addrToNaddr, bech32Decode, convertBits, decodeNevent, encodeNevent, naddrToAddr } from './nip19.js'
|
|
22
24
|
import type { PartPointer } from './anchors.js'
|
package/src/events.ts
CHANGED
|
@@ -125,6 +125,8 @@ export const KIND = {
|
|
|
125
125
|
* owns an issue; Leaf is the first owner. The bare file's shape, but owned:
|
|
126
126
|
* a document is written and opened in its owner's app, where a topic
|
|
127
127
|
* (`FILE`) is a conversation nobody owns (SPEC, Miky 2026-10-14).
|
|
128
|
+
*
|
|
129
|
+
* why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-document-is-its-own-type-of-file.md
|
|
128
130
|
*/
|
|
129
131
|
DOCUMENT: 30842,
|
|
130
132
|
/**
|
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.
|
|
50
|
+
export const PROTOCOL_VERSION = '0.37.0'
|
|
51
51
|
|
|
52
52
|
export {
|
|
53
53
|
// types
|
|
@@ -265,6 +265,25 @@ export {
|
|
|
265
265
|
resolveBlockAnchor,
|
|
266
266
|
resolvePart,
|
|
267
267
|
} from './anchors.js'
|
|
268
|
+
export {
|
|
269
|
+
type CommentAnchor,
|
|
270
|
+
type Quote,
|
|
271
|
+
type TextPoint,
|
|
272
|
+
MAX_RUN_ENTRIES_READ,
|
|
273
|
+
MAX_RUN_IDS,
|
|
274
|
+
QUOTE_CONTEXT_LENGTH,
|
|
275
|
+
QUOTE_END_LENGTH,
|
|
276
|
+
QUOTE_TAG,
|
|
277
|
+
QUOTE_WHOLE_MAX,
|
|
278
|
+
blockRunOf,
|
|
279
|
+
blockRunTag,
|
|
280
|
+
quoteOf,
|
|
281
|
+
quoteTag,
|
|
282
|
+
readRunIds,
|
|
283
|
+
resolveBlockRun,
|
|
284
|
+
resolveCommentAnchor,
|
|
285
|
+
selectionAnchorTags,
|
|
286
|
+
} from './comment-anchor.js'
|
|
268
287
|
export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf, linksAsReferences, referenceOfLink, urlRunsIn } from './embeds.js'
|
|
269
288
|
export {
|
|
270
289
|
type BlossomVerb,
|