@input/pen-types 0.1.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/LICENSE.md +21 -0
- package/README.md +45 -0
- package/dist/index.cjs +467 -0
- package/dist/index.d.cts +2477 -0
- package/dist/index.d.ts +2477 -0
- package/dist/index.mjs +394 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2477 @@
|
|
|
1
|
+
type Unsubscribe = () => void;
|
|
2
|
+
type Spacing = number | {
|
|
3
|
+
top?: number;
|
|
4
|
+
right?: number;
|
|
5
|
+
bottom?: number;
|
|
6
|
+
left?: number;
|
|
7
|
+
};
|
|
8
|
+
type BorderDef = {
|
|
9
|
+
width?: number;
|
|
10
|
+
style?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Which side of a position inserted text lands on. `-1` sticks to the
|
|
16
|
+
* character before the position, `1` to the character after — so a caret with
|
|
17
|
+
* `assoc: -1` stays put when text is inserted at its offset, and one with
|
|
18
|
+
* `assoc: 1` is pushed along by it.
|
|
19
|
+
*
|
|
20
|
+
* This is the single declaration; `@input/pen-types/anchors` re-exports it.
|
|
21
|
+
*/
|
|
22
|
+
type Assoc = -1 | 1;
|
|
23
|
+
type DefaultAssoc = 1;
|
|
24
|
+
interface Point {
|
|
25
|
+
readonly blockId: string;
|
|
26
|
+
readonly offset: number;
|
|
27
|
+
}
|
|
28
|
+
interface TextSplice {
|
|
29
|
+
readonly from: number;
|
|
30
|
+
readonly to: number;
|
|
31
|
+
readonly insertLength: number;
|
|
32
|
+
}
|
|
33
|
+
interface BlockTextChange {
|
|
34
|
+
readonly blockId: string;
|
|
35
|
+
readonly splices: readonly TextSplice[];
|
|
36
|
+
readonly formatRanges: readonly {
|
|
37
|
+
from: number;
|
|
38
|
+
to: number;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
type StructuralChange = {
|
|
42
|
+
readonly type: "block-inserted";
|
|
43
|
+
readonly blockId: string;
|
|
44
|
+
readonly parentId: string | null;
|
|
45
|
+
readonly index: number;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "block-removed";
|
|
48
|
+
readonly blockId: string;
|
|
49
|
+
readonly parentId: string | null;
|
|
50
|
+
readonly index: number;
|
|
51
|
+
} | {
|
|
52
|
+
readonly type: "block-moved";
|
|
53
|
+
readonly blockId: string;
|
|
54
|
+
readonly fromParentId: string | null;
|
|
55
|
+
readonly fromIndex: number;
|
|
56
|
+
readonly toParentId: string | null;
|
|
57
|
+
readonly toIndex: number;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "block-props-changed";
|
|
60
|
+
readonly blockId: string;
|
|
61
|
+
readonly keys: readonly string[];
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: "block-split";
|
|
64
|
+
readonly blockId: string;
|
|
65
|
+
readonly newBlockId: string;
|
|
66
|
+
readonly offset: number;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "blocks-merged";
|
|
69
|
+
readonly targetBlockId: string;
|
|
70
|
+
readonly sourceBlockId: string;
|
|
71
|
+
readonly joinOffset: number;
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: "table-changed";
|
|
74
|
+
readonly blockId: string;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: "apps-changed";
|
|
77
|
+
readonly appIds: readonly string[];
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: "metadata-changed";
|
|
80
|
+
readonly namespaces: readonly string[];
|
|
81
|
+
};
|
|
82
|
+
interface ChangeSummary {
|
|
83
|
+
readonly commitId: number;
|
|
84
|
+
readonly blockText: readonly BlockTextChange[];
|
|
85
|
+
readonly structural: readonly StructuralChange[];
|
|
86
|
+
readonly affectedBlockIds: readonly string[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A resolved document location in the logical text domain (AN1, AN10).
|
|
91
|
+
*/
|
|
92
|
+
interface AnchorTarget {
|
|
93
|
+
readonly blockId: string;
|
|
94
|
+
readonly offset: number;
|
|
95
|
+
readonly cell?: {
|
|
96
|
+
readonly row: number;
|
|
97
|
+
readonly col: number;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A frozen CRDT-relative position minted against one block or cell (AN12).
|
|
102
|
+
*/
|
|
103
|
+
interface Anchor {
|
|
104
|
+
readonly kind: "anchor";
|
|
105
|
+
readonly blockId: string;
|
|
106
|
+
readonly assoc: Assoc;
|
|
107
|
+
readonly cell?: {
|
|
108
|
+
readonly row: number;
|
|
109
|
+
readonly col: number;
|
|
110
|
+
};
|
|
111
|
+
readonly position: Uint8Array;
|
|
112
|
+
readonly provenance: "local" | "wire";
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A pair of anchors that bound a range (AN5).
|
|
116
|
+
*/
|
|
117
|
+
interface AnchorRange {
|
|
118
|
+
readonly kind: "anchor-range";
|
|
119
|
+
readonly from: Anchor;
|
|
120
|
+
readonly to: Anchor;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A resolved {@link AnchorRange} plus the AN5 collapse signal.
|
|
124
|
+
*/
|
|
125
|
+
interface ResolvedAnchorRange {
|
|
126
|
+
readonly from: AnchorTarget;
|
|
127
|
+
readonly to: AnchorTarget;
|
|
128
|
+
readonly collapsed: boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Resolver flag for {@link CRDTAdapter.resolveRelativePosition} (AN13).
|
|
132
|
+
*
|
|
133
|
+
* Local-provenance anchors pass `true`; wire-provenance anchors pass `false`.
|
|
134
|
+
*/
|
|
135
|
+
interface ResolveRelativePositionOptions {
|
|
136
|
+
readonly followUndoneDeletions?: boolean;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Editor-facing anchor mint, resolve, and wire surface (AN6, AN8, AN9, AN11).
|
|
140
|
+
*/
|
|
141
|
+
interface EditorAnchors {
|
|
142
|
+
/** Mint a local-provenance anchor, or `null` plus `anchor-target-missing` if the target is gone. */
|
|
143
|
+
create(target: AnchorTarget, assoc?: Assoc): Anchor | null;
|
|
144
|
+
/** Mint a range (`from` assoc `-1`, `to` assoc `1`), or `null` if either end is missing. */
|
|
145
|
+
range(range: {
|
|
146
|
+
anchor: AnchorTarget;
|
|
147
|
+
focus: AnchorTarget;
|
|
148
|
+
}): AnchorRange | null;
|
|
149
|
+
/** Resolve to a live target, or `null` (AN1). */
|
|
150
|
+
resolve(anchor: Anchor): AnchorTarget | null;
|
|
151
|
+
/** Resolve both ends and set `collapsed` when they meet (AN5). */
|
|
152
|
+
resolveRange(range: AnchorRange): ResolvedAnchorRange | null;
|
|
153
|
+
/** Encode the v1 wire JSON (AN11). */
|
|
154
|
+
serialize(anchor: Anchor): string;
|
|
155
|
+
/** Decode untrusted input; never throws (AN6). */
|
|
156
|
+
deserialize(input: string): Anchor | null;
|
|
157
|
+
/** Live minted-or-deserialized count for the AN9 budget. */
|
|
158
|
+
readonly liveCount: number;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface Block<Type extends string = string, Props extends Record<string, unknown> = Record<string, unknown>> {
|
|
162
|
+
id: string;
|
|
163
|
+
type: Type;
|
|
164
|
+
props: Props;
|
|
165
|
+
content?: string;
|
|
166
|
+
children?: Block[];
|
|
167
|
+
}
|
|
168
|
+
type AnchorPosition = "before" | "after" | "left" | "right" | "overlay";
|
|
169
|
+
type AppPlacement = {
|
|
170
|
+
mode: "inline";
|
|
171
|
+
blockId: string;
|
|
172
|
+
index: number;
|
|
173
|
+
} | {
|
|
174
|
+
mode: "anchored";
|
|
175
|
+
blockId: string;
|
|
176
|
+
anchor: AnchorPosition;
|
|
177
|
+
};
|
|
178
|
+
interface App<Type extends string = string, Config extends Record<string, unknown> = Record<string, unknown>> {
|
|
179
|
+
id: string;
|
|
180
|
+
type: Type;
|
|
181
|
+
config: Config;
|
|
182
|
+
placement: AppPlacement;
|
|
183
|
+
}
|
|
184
|
+
interface Range {
|
|
185
|
+
index: number;
|
|
186
|
+
length: number;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type OpOriginType = "user" | "ai" | "ai-session" | "suggestion-resolution" | "collaborator" | "extension" | "history" | "input-rule" | "app" | "import" | "system" | "migration";
|
|
190
|
+
interface StructuredOpOrigin {
|
|
191
|
+
type: OpOriginType | (string & {});
|
|
192
|
+
groupId?: string;
|
|
193
|
+
requestId?: string;
|
|
194
|
+
actorId?: string;
|
|
195
|
+
source?: string;
|
|
196
|
+
intent?: string;
|
|
197
|
+
}
|
|
198
|
+
type OpOrigin = OpOriginType | StructuredOpOrigin;
|
|
199
|
+
interface MutationGroupMetadata {
|
|
200
|
+
groupId: string;
|
|
201
|
+
originType: string;
|
|
202
|
+
requestId?: string;
|
|
203
|
+
actorId?: string;
|
|
204
|
+
source?: string;
|
|
205
|
+
}
|
|
206
|
+
type StructuralOriginTag = {
|
|
207
|
+
kind: "split";
|
|
208
|
+
blockId: string;
|
|
209
|
+
newBlockId: string;
|
|
210
|
+
offset: number;
|
|
211
|
+
} | {
|
|
212
|
+
kind: "merge";
|
|
213
|
+
targetBlockId: string;
|
|
214
|
+
sourceBlockId: string;
|
|
215
|
+
};
|
|
216
|
+
interface ApplyOptions {
|
|
217
|
+
origin?: OpOrigin;
|
|
218
|
+
undoGroup?: boolean;
|
|
219
|
+
groupId?: string;
|
|
220
|
+
undoGroupId?: string;
|
|
221
|
+
/** In-transaction AN14 stamp for split/merge recipes. Not hung on origin. */
|
|
222
|
+
structural?: StructuralOriginTag;
|
|
223
|
+
}
|
|
224
|
+
declare const MUTATION_GROUP_METADATA_KEY = "mutation-group";
|
|
225
|
+
type Position = "first" | "last" | {
|
|
226
|
+
before: string;
|
|
227
|
+
} | {
|
|
228
|
+
after: string;
|
|
229
|
+
} | {
|
|
230
|
+
parent: string;
|
|
231
|
+
index: number;
|
|
232
|
+
};
|
|
233
|
+
type DocumentOp = SpliceTextOp | FormatTextOp | InsertBlockOp | DeleteBlockOp | MoveBlockOp | SetPropsOp | SetMetaOp | GridOp | AppOp | StreamOpenOp;
|
|
234
|
+
type InlineInsert = string | {
|
|
235
|
+
readonly nodeType: string;
|
|
236
|
+
readonly props: Record<string, unknown>;
|
|
237
|
+
};
|
|
238
|
+
interface SpliceTextOp {
|
|
239
|
+
type: "splice-text";
|
|
240
|
+
blockId: string;
|
|
241
|
+
cell?: {
|
|
242
|
+
row: number;
|
|
243
|
+
col: number;
|
|
244
|
+
};
|
|
245
|
+
from: number;
|
|
246
|
+
to: number;
|
|
247
|
+
insert: InlineInsert | readonly InlineInsert[];
|
|
248
|
+
marks?: Record<string, unknown | null>;
|
|
249
|
+
}
|
|
250
|
+
interface FormatTextOp {
|
|
251
|
+
type: "format-text";
|
|
252
|
+
blockId: string;
|
|
253
|
+
cell?: {
|
|
254
|
+
row: number;
|
|
255
|
+
col: number;
|
|
256
|
+
};
|
|
257
|
+
from: number;
|
|
258
|
+
to: number;
|
|
259
|
+
marks: Record<string, unknown | null>;
|
|
260
|
+
}
|
|
261
|
+
interface InsertBlockOp {
|
|
262
|
+
type: "insert-block";
|
|
263
|
+
blockId: string;
|
|
264
|
+
blockType: string;
|
|
265
|
+
props: Record<string, unknown>;
|
|
266
|
+
position: Position;
|
|
267
|
+
}
|
|
268
|
+
interface DeleteBlockOp {
|
|
269
|
+
type: "delete-block";
|
|
270
|
+
blockId: string;
|
|
271
|
+
}
|
|
272
|
+
interface MoveBlockOp {
|
|
273
|
+
type: "move-block";
|
|
274
|
+
blockId: string;
|
|
275
|
+
position: Position;
|
|
276
|
+
}
|
|
277
|
+
interface SetPropsOp {
|
|
278
|
+
type: "set-props";
|
|
279
|
+
blockId: string;
|
|
280
|
+
props: Record<string, unknown | null>;
|
|
281
|
+
}
|
|
282
|
+
interface SetMetaOp {
|
|
283
|
+
type: "set-meta";
|
|
284
|
+
blockId: string;
|
|
285
|
+
namespace: string;
|
|
286
|
+
data: Record<string, unknown> | null;
|
|
287
|
+
}
|
|
288
|
+
type GridChange = {
|
|
289
|
+
kind: "insert-row";
|
|
290
|
+
index: number;
|
|
291
|
+
} | {
|
|
292
|
+
kind: "delete-row";
|
|
293
|
+
index: number;
|
|
294
|
+
} | {
|
|
295
|
+
kind: "insert-column";
|
|
296
|
+
index: number;
|
|
297
|
+
} | {
|
|
298
|
+
kind: "delete-column";
|
|
299
|
+
index: number;
|
|
300
|
+
} | {
|
|
301
|
+
kind: "merge-cells";
|
|
302
|
+
anchor: {
|
|
303
|
+
row: number;
|
|
304
|
+
col: number;
|
|
305
|
+
};
|
|
306
|
+
head: {
|
|
307
|
+
row: number;
|
|
308
|
+
col: number;
|
|
309
|
+
};
|
|
310
|
+
} | {
|
|
311
|
+
kind: "split-cell";
|
|
312
|
+
row: number;
|
|
313
|
+
col: number;
|
|
314
|
+
};
|
|
315
|
+
interface GridOp {
|
|
316
|
+
type: "grid";
|
|
317
|
+
blockId: string;
|
|
318
|
+
change: GridChange;
|
|
319
|
+
}
|
|
320
|
+
type AppChange = {
|
|
321
|
+
kind: "create";
|
|
322
|
+
appId: string;
|
|
323
|
+
appType: string;
|
|
324
|
+
config: Record<string, unknown>;
|
|
325
|
+
placement: AppPlacement;
|
|
326
|
+
} | {
|
|
327
|
+
kind: "update";
|
|
328
|
+
appId: string;
|
|
329
|
+
patch: Record<string, unknown>;
|
|
330
|
+
} | {
|
|
331
|
+
kind: "delete";
|
|
332
|
+
appId: string;
|
|
333
|
+
};
|
|
334
|
+
interface AppOp {
|
|
335
|
+
type: "app";
|
|
336
|
+
change: AppChange;
|
|
337
|
+
}
|
|
338
|
+
/** Synthetic open-time op for stream veto (`06-commit-pipeline.md` ST1). */
|
|
339
|
+
interface StreamOpenOp {
|
|
340
|
+
type: "stream-open";
|
|
341
|
+
blockId: string;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Caret display side at line-wrap and bidi-run boundaries (`03-selection.md` §1.1).
|
|
346
|
+
* Meaningless for a non-collapsed text selection.
|
|
347
|
+
*/
|
|
348
|
+
type Affinity = "upstream" | "downstream";
|
|
349
|
+
type SelectionOrigin = "pointer" | "keyboard" | "ime" | "programmatic" | "mapped" | "restore" | "gc";
|
|
350
|
+
interface TextSelection {
|
|
351
|
+
type: "text";
|
|
352
|
+
anchor: Point;
|
|
353
|
+
focus: Point;
|
|
354
|
+
/**
|
|
355
|
+
* Written by SelectionAuthority. Absent on v1 manager
|
|
356
|
+
* objects; readers default to `"downstream"`.
|
|
357
|
+
*/
|
|
358
|
+
readonly affinity?: Affinity;
|
|
359
|
+
/**
|
|
360
|
+
* Preserved visual x for vertical caret motion. Null unless the last
|
|
361
|
+
* motion was vertical. Written by SelectionAuthority.
|
|
362
|
+
*/
|
|
363
|
+
readonly goalX?: number | null;
|
|
364
|
+
}
|
|
365
|
+
interface BlockSelection {
|
|
366
|
+
type: "block";
|
|
367
|
+
readonly blockIds: readonly string[];
|
|
368
|
+
/** Block that extends/shrinks on shift-arrow. Written by SelectionAuthority. */
|
|
369
|
+
readonly head?: string;
|
|
370
|
+
}
|
|
371
|
+
interface AppSelection {
|
|
372
|
+
type: "app";
|
|
373
|
+
appId: string;
|
|
374
|
+
}
|
|
375
|
+
interface CellSelection {
|
|
376
|
+
type: "cell";
|
|
377
|
+
blockId: string;
|
|
378
|
+
anchor: {
|
|
379
|
+
row: number;
|
|
380
|
+
col: number;
|
|
381
|
+
};
|
|
382
|
+
head: {
|
|
383
|
+
row: number;
|
|
384
|
+
col: number;
|
|
385
|
+
};
|
|
386
|
+
rowIds?: string[];
|
|
387
|
+
columnIds?: string[];
|
|
388
|
+
}
|
|
389
|
+
type SelectionState = TextSelection | BlockSelection | AppSelection | CellSelection | null;
|
|
390
|
+
/**
|
|
391
|
+
* Read view of `SelectionState`. Helpers only read, so they take this
|
|
392
|
+
* rather than the live writable value. Nested fields are readonly
|
|
393
|
+
* (cell coords are readonly). A live `SelectionState` assigns here,
|
|
394
|
+
* and so does any deep-readonly unwrap of the same value.
|
|
395
|
+
*/
|
|
396
|
+
type ReadonlySelectionState = {
|
|
397
|
+
readonly type: "text";
|
|
398
|
+
readonly anchor: Point;
|
|
399
|
+
readonly focus: Point;
|
|
400
|
+
readonly affinity?: Affinity;
|
|
401
|
+
readonly goalX?: number | null;
|
|
402
|
+
} | {
|
|
403
|
+
readonly type: "block";
|
|
404
|
+
readonly blockIds: readonly string[];
|
|
405
|
+
readonly head?: string;
|
|
406
|
+
} | {
|
|
407
|
+
readonly type: "app";
|
|
408
|
+
readonly appId: string;
|
|
409
|
+
} | {
|
|
410
|
+
readonly type: "cell";
|
|
411
|
+
readonly blockId: string;
|
|
412
|
+
readonly anchor: {
|
|
413
|
+
readonly row: number;
|
|
414
|
+
readonly col: number;
|
|
415
|
+
};
|
|
416
|
+
readonly head: {
|
|
417
|
+
readonly row: number;
|
|
418
|
+
readonly col: number;
|
|
419
|
+
};
|
|
420
|
+
readonly rowIds?: readonly string[];
|
|
421
|
+
readonly columnIds?: readonly string[];
|
|
422
|
+
} | null;
|
|
423
|
+
/**
|
|
424
|
+
* Serializable selection as of a commit. Same variants as `SelectionState`.
|
|
425
|
+
* `affinity` / `goalX` / `head` are required here because
|
|
426
|
+
* `snapshotSelectionRecord` already writes them.
|
|
427
|
+
*
|
|
428
|
+
* Computed v1 fields (`isCollapsed` / `isMultiBlock` / `blockRange` /
|
|
429
|
+
* `toRange`) live on helpers in `@input/pen-core`, not on either shape.
|
|
430
|
+
*/
|
|
431
|
+
type SelectionRecordState = {
|
|
432
|
+
readonly type: "text";
|
|
433
|
+
readonly anchor: Point;
|
|
434
|
+
readonly focus: Point;
|
|
435
|
+
readonly affinity: Affinity;
|
|
436
|
+
readonly goalX: number | null;
|
|
437
|
+
} | {
|
|
438
|
+
readonly type: "block";
|
|
439
|
+
readonly blockIds: readonly string[];
|
|
440
|
+
readonly head: string;
|
|
441
|
+
} | {
|
|
442
|
+
readonly type: "app";
|
|
443
|
+
readonly appId: string;
|
|
444
|
+
} | {
|
|
445
|
+
readonly type: "cell";
|
|
446
|
+
readonly blockId: string;
|
|
447
|
+
readonly anchor: {
|
|
448
|
+
readonly row: number;
|
|
449
|
+
readonly col: number;
|
|
450
|
+
};
|
|
451
|
+
readonly head: {
|
|
452
|
+
readonly row: number;
|
|
453
|
+
readonly col: number;
|
|
454
|
+
};
|
|
455
|
+
} | null;
|
|
456
|
+
interface SelectionRecord {
|
|
457
|
+
readonly state: SelectionRecordState;
|
|
458
|
+
readonly version: number;
|
|
459
|
+
readonly origin: SelectionOrigin;
|
|
460
|
+
readonly commitId: number;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
interface DocumentRange {
|
|
464
|
+
start: {
|
|
465
|
+
blockId: string;
|
|
466
|
+
offset: number;
|
|
467
|
+
};
|
|
468
|
+
end: {
|
|
469
|
+
blockId: string;
|
|
470
|
+
offset: number;
|
|
471
|
+
};
|
|
472
|
+
readonly isMultiBlock: boolean;
|
|
473
|
+
readonly blockRange: string[];
|
|
474
|
+
contains(point: {
|
|
475
|
+
blockId: string;
|
|
476
|
+
offset: number;
|
|
477
|
+
}): boolean;
|
|
478
|
+
overlaps(other: DocumentRange): boolean;
|
|
479
|
+
equals(other: DocumentRange): boolean;
|
|
480
|
+
toTextSelection(): TextSelection;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
type DocumentProfile = "structured" | "flow";
|
|
484
|
+
interface CRDTArray<T> {
|
|
485
|
+
readonly length: number;
|
|
486
|
+
get(index: number): T;
|
|
487
|
+
toArray(): T[];
|
|
488
|
+
[Symbol.iterator](): Iterator<T>;
|
|
489
|
+
}
|
|
490
|
+
interface CRDTMap<T> {
|
|
491
|
+
get(key: string): T | undefined;
|
|
492
|
+
has(key: string): boolean;
|
|
493
|
+
entries(): IterableIterator<[string, T]>;
|
|
494
|
+
keys(): IterableIterator<string>;
|
|
495
|
+
readonly size: number;
|
|
496
|
+
}
|
|
497
|
+
interface LoadDocumentOptions {
|
|
498
|
+
/**
|
|
499
|
+
* Apply structural repairs (duplicate `blockOrder` entries, dangling
|
|
500
|
+
* references, orphans). Defaults to `true`. The diagnostic list from
|
|
501
|
+
* `onDiagnostic` / `getDocumentLoadReport` is the API for what changed.
|
|
502
|
+
*/
|
|
503
|
+
repair?: boolean;
|
|
504
|
+
}
|
|
505
|
+
interface CRDTAdapter {
|
|
506
|
+
createDocument(): CRDTDocument;
|
|
507
|
+
loadDocument(binary: Uint8Array, options?: LoadDocumentOptions): CRDTDocument;
|
|
508
|
+
encodeState(doc: CRDTDocument): Uint8Array;
|
|
509
|
+
encodeUpdate(doc: CRDTDocument, since?: Uint8Array): Uint8Array;
|
|
510
|
+
applyUpdate(doc: CRDTDocument, update: Uint8Array): void;
|
|
511
|
+
transact(doc: CRDTDocument, fn: () => void, origin?: unknown): void;
|
|
512
|
+
createUndoManager(doc: CRDTDocument, options?: UndoManagerOptions): CRDTUndoManager;
|
|
513
|
+
createAwareness?(doc: CRDTDocument): Awareness;
|
|
514
|
+
observe(doc: CRDTDocument, callback: (event: CRDTEvent) => void): Unsubscribe;
|
|
515
|
+
createSnapshot(doc: CRDTDocument): Uint8Array;
|
|
516
|
+
restoreSnapshot(doc: CRDTDocument, snapshot: Uint8Array): CRDTDocument;
|
|
517
|
+
mergeUpdates?(updates: Uint8Array[]): Uint8Array;
|
|
518
|
+
fork?(doc: CRDTDocument): CRDTDocument;
|
|
519
|
+
merge?(target: CRDTDocument, source: CRDTDocument): void;
|
|
520
|
+
getClientId(doc: CRDTDocument): number;
|
|
521
|
+
getDocumentProfile?(doc: CRDTDocument): DocumentProfile | null;
|
|
522
|
+
setDocumentProfile?(doc: CRDTDocument, profile: DocumentProfile): void;
|
|
523
|
+
raw<T>(doc: CRDTDocument): T;
|
|
524
|
+
createMap(): unknown;
|
|
525
|
+
createArray(): unknown;
|
|
526
|
+
createText(): unknown;
|
|
527
|
+
initBlockMap(doc: CRDTDocument, blockId: string, blockType: string, contentType: "inline" | "nested" | "table" | "subdocument" | "none"): unknown;
|
|
528
|
+
getAttributionRanges?(doc: CRDTDocument, blockId: string): AttributionRange[];
|
|
529
|
+
/** Mint an encoded relative position for `target`, or `null` if it is missing. */
|
|
530
|
+
createRelativePosition(doc: CRDTDocument, target: AnchorTarget, assoc: Assoc): Uint8Array | null;
|
|
531
|
+
/**
|
|
532
|
+
* Resolve an encoded relative position (AN1).
|
|
533
|
+
*
|
|
534
|
+
* `options.followUndoneDeletions` is the AN13 path flag, never a constant.
|
|
535
|
+
* The three-argument form is shipped; a two-arg adapter was never frozen.
|
|
536
|
+
* Host policy lives on `editor.anchors.resolve` (provenance), not here.
|
|
537
|
+
*/
|
|
538
|
+
resolveRelativePosition(doc: CRDTDocument, encoded: Uint8Array, options?: ResolveRelativePositionOptions): AnchorTarget | null;
|
|
539
|
+
}
|
|
540
|
+
interface AttributionRange {
|
|
541
|
+
offset: number;
|
|
542
|
+
length: number;
|
|
543
|
+
clientId: number;
|
|
544
|
+
}
|
|
545
|
+
type DocumentScopeKind = "root" | "subdocument";
|
|
546
|
+
interface DocumentScopeInfo {
|
|
547
|
+
id: string;
|
|
548
|
+
guid: string;
|
|
549
|
+
kind: DocumentScopeKind;
|
|
550
|
+
parentId: string | null;
|
|
551
|
+
ownerBlockId: string | null;
|
|
552
|
+
}
|
|
553
|
+
interface DocumentScope extends DocumentScopeInfo {
|
|
554
|
+
readonly doc: CRDTDocument;
|
|
555
|
+
}
|
|
556
|
+
interface CreateSubdocumentOptions {
|
|
557
|
+
scopeId?: string;
|
|
558
|
+
guid?: string;
|
|
559
|
+
autoLoad?: boolean;
|
|
560
|
+
}
|
|
561
|
+
interface DocumentScopeLookupOptions {
|
|
562
|
+
scopeId?: string;
|
|
563
|
+
}
|
|
564
|
+
interface ReplaceScopeDocumentOptions {
|
|
565
|
+
destroyReplacedDoc?: boolean;
|
|
566
|
+
}
|
|
567
|
+
interface DocumentScopeReplacementEvent {
|
|
568
|
+
previousScope: DocumentScopeInfo;
|
|
569
|
+
scope: DocumentScope;
|
|
570
|
+
}
|
|
571
|
+
interface DocumentSessionAttachOptions {
|
|
572
|
+
onScopeReplaced?: (event: DocumentScopeReplacementEvent) => void;
|
|
573
|
+
}
|
|
574
|
+
interface DocumentSession {
|
|
575
|
+
readonly adapter: CRDTAdapter;
|
|
576
|
+
readonly rootScope: DocumentScope;
|
|
577
|
+
getScope(scopeId: string): DocumentScope | null;
|
|
578
|
+
getScopeByGuid(guid: string): DocumentScope | null;
|
|
579
|
+
getScopeForBlock(blockId: string, options?: DocumentScopeLookupOptions): DocumentScope | null;
|
|
580
|
+
listScopes(): readonly DocumentScope[];
|
|
581
|
+
getAwareness(scopeId?: string): Awareness | null;
|
|
582
|
+
observe(scopeId: string, callback: (event: CRDTEvent) => void): Unsubscribe;
|
|
583
|
+
observeAll(callback: (event: CRDTEvent) => void): Unsubscribe;
|
|
584
|
+
createSubdocument(blockId: string, options?: CreateSubdocumentOptions): DocumentScope | null;
|
|
585
|
+
loadSubdocument(scopeId: string): void;
|
|
586
|
+
replaceScopeDocument(scopeId: string, doc: CRDTDocument, options?: ReplaceScopeDocumentOptions): void;
|
|
587
|
+
attachEditor(options?: DocumentSessionAttachOptions): Unsubscribe;
|
|
588
|
+
destroy(): void;
|
|
589
|
+
}
|
|
590
|
+
interface CRDTDocument {
|
|
591
|
+
readonly adapter: CRDTAdapter;
|
|
592
|
+
}
|
|
593
|
+
interface PenDocument {
|
|
594
|
+
readonly blockOrder: CRDTArray<string>;
|
|
595
|
+
readonly blocks: CRDTMap<unknown>;
|
|
596
|
+
readonly apps: CRDTMap<unknown>;
|
|
597
|
+
readonly metadata: CRDTMap<unknown>;
|
|
598
|
+
readonly adapter: CRDTAdapter;
|
|
599
|
+
}
|
|
600
|
+
interface UndoManagerOptions {
|
|
601
|
+
trackedOriginTypes?: string[];
|
|
602
|
+
captureTimeout?: number;
|
|
603
|
+
/**
|
|
604
|
+
* Maximum undo/redo stack items to retain.
|
|
605
|
+
* Defaults to 500 (CH7). Y.UndoManager has no native cap; the Yjs
|
|
606
|
+
* adapter trims oldest items on `stack-item-added`.
|
|
607
|
+
*/
|
|
608
|
+
maxDepth?: number;
|
|
609
|
+
}
|
|
610
|
+
interface CRDTUndoManager {
|
|
611
|
+
undo(): boolean;
|
|
612
|
+
redo(): boolean;
|
|
613
|
+
canUndo(): boolean;
|
|
614
|
+
canRedo(): boolean;
|
|
615
|
+
stopCapturing(): void;
|
|
616
|
+
setCaptureTimeout?(ms: number): void;
|
|
617
|
+
addTrackedOrigin(originType: string): void;
|
|
618
|
+
removeTrackedOrigin(originType: string): void;
|
|
619
|
+
destroy(): void;
|
|
620
|
+
onStackItemAdded?(callback: (stackItem: CRDTUndoStackItem, kind: "undo" | "redo") => void): Unsubscribe;
|
|
621
|
+
onStackItemUpdated?(callback: (stackItem: CRDTUndoStackItem, kind: "undo" | "redo") => void): Unsubscribe;
|
|
622
|
+
onStackItemPopped?(callback: (stackItem: CRDTUndoStackItem, kind: "undo" | "redo") => void): Unsubscribe;
|
|
623
|
+
}
|
|
624
|
+
interface CRDTUndoStackItem {
|
|
625
|
+
getMeta<T>(key: string): T | undefined;
|
|
626
|
+
setMeta(key: string, value: unknown): void;
|
|
627
|
+
}
|
|
628
|
+
interface AwarenessChangeEvent {
|
|
629
|
+
added: number[];
|
|
630
|
+
updated: number[];
|
|
631
|
+
removed: number[];
|
|
632
|
+
}
|
|
633
|
+
interface Awareness {
|
|
634
|
+
getLocalState(): Record<string, unknown> | null;
|
|
635
|
+
setLocalState(state: Record<string, unknown> | null): void;
|
|
636
|
+
getStates(): Map<number, Record<string, unknown>>;
|
|
637
|
+
on(event: "change", callback: (changes: AwarenessChangeEvent) => void): void;
|
|
638
|
+
off(event: "change", callback: (changes: AwarenessChangeEvent) => void): void;
|
|
639
|
+
destroy(): void;
|
|
640
|
+
}
|
|
641
|
+
interface GenerationZone {
|
|
642
|
+
id: string;
|
|
643
|
+
blockId: string;
|
|
644
|
+
range: DocumentRange;
|
|
645
|
+
status: "idle" | "streaming" | "complete" | "error";
|
|
646
|
+
}
|
|
647
|
+
interface CRDTEvent {
|
|
648
|
+
origin: OpOrigin;
|
|
649
|
+
readonly affectedBlocks: readonly string[];
|
|
650
|
+
ops: readonly DocumentOp[];
|
|
651
|
+
timestamp: number;
|
|
652
|
+
scope?: DocumentScopeInfo;
|
|
653
|
+
/** Pipeline-stamped commit source; observer-originated events omit this. */
|
|
654
|
+
readonly source?: "apply" | "remote" | "undo" | "redo" | "stream";
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
type Precedence = "highest" | "high" | "default" | "low" | "lowest";
|
|
658
|
+
interface FacetSpec<Input, Output> {
|
|
659
|
+
readonly name: string;
|
|
660
|
+
combine(inputs: readonly Input[]): Output;
|
|
661
|
+
compareOutput?(a: Output, b: Output): boolean;
|
|
662
|
+
compareInput?(a: Input, b: Input): boolean;
|
|
663
|
+
readonly static?: boolean;
|
|
664
|
+
}
|
|
665
|
+
interface Facet<Input, Output = readonly Input[]> {
|
|
666
|
+
readonly name: string;
|
|
667
|
+
of(value: Input, precedence?: Precedence): FacetProvider;
|
|
668
|
+
compute(deps: readonly FacetDependency[], fn: (editor: Editor) => Input, precedence?: Precedence): FacetProvider;
|
|
669
|
+
}
|
|
670
|
+
type FacetDependency = Facet<unknown, unknown> | "document" | "selection";
|
|
671
|
+
interface FacetProvider {
|
|
672
|
+
readonly facetName: string;
|
|
673
|
+
readonly precedence: Precedence;
|
|
674
|
+
}
|
|
675
|
+
type FacetOutput<F> = F extends Facet<infer _Input, infer Output> ? Output : never;
|
|
676
|
+
type DefineFacet = <Input, Output = readonly Input[]>(spec: FacetSpec<Input, Output>) => Facet<Input, Output>;
|
|
677
|
+
|
|
678
|
+
type Decoration = InlineDecoration | BlockDecoration | AppDecoration;
|
|
679
|
+
interface InlineDecoration {
|
|
680
|
+
type: "inline";
|
|
681
|
+
blockId: string;
|
|
682
|
+
from: number;
|
|
683
|
+
to: number;
|
|
684
|
+
attributes: Record<string, string | number | boolean>;
|
|
685
|
+
virtualText?: string;
|
|
686
|
+
virtualPlacement?: "before" | "after";
|
|
687
|
+
/** When true, decorated text is omitted from rendered output (e.g. hidden delete ranges). */
|
|
688
|
+
omitFromRender?: boolean;
|
|
689
|
+
key?: string;
|
|
690
|
+
}
|
|
691
|
+
/** Generic decoration attribute written when {@link InlineDecoration.omitFromRender} is true. */
|
|
692
|
+
declare const DECORATION_OMIT_FROM_RENDER_ATTRIBUTE = "data-pen-omit-from-render";
|
|
693
|
+
interface BlockDecoration {
|
|
694
|
+
type: "block";
|
|
695
|
+
blockId: string;
|
|
696
|
+
attributes: Record<string, string | number | boolean>;
|
|
697
|
+
position?: "before" | "after" | "wrap";
|
|
698
|
+
}
|
|
699
|
+
interface AppDecoration {
|
|
700
|
+
type: "app";
|
|
701
|
+
blockId: string;
|
|
702
|
+
offset: number;
|
|
703
|
+
component: unknown;
|
|
704
|
+
key: string;
|
|
705
|
+
}
|
|
706
|
+
interface DecorationSet {
|
|
707
|
+
readonly decorations: readonly Decoration[];
|
|
708
|
+
readonly generation: number;
|
|
709
|
+
forBlock(blockId: string): readonly Decoration[];
|
|
710
|
+
inlineForBlock(blockId: string): readonly InlineDecoration[];
|
|
711
|
+
equals(other: DecorationSet): boolean;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
interface ServerExtensionContext {
|
|
715
|
+
editor: Editor;
|
|
716
|
+
emit(event: string, payload?: unknown): void;
|
|
717
|
+
getState<T>(name: string): T | undefined;
|
|
718
|
+
}
|
|
719
|
+
interface ClientExtensionContext extends ServerExtensionContext {
|
|
720
|
+
dom?: Document;
|
|
721
|
+
}
|
|
722
|
+
interface Extension {
|
|
723
|
+
name: string;
|
|
724
|
+
version: string;
|
|
725
|
+
readonly dependencies?: readonly string[];
|
|
726
|
+
readonly facets?: readonly FacetProvider[];
|
|
727
|
+
activateServer?(ctx: ServerExtensionContext): Promise<void>;
|
|
728
|
+
deactivateServer?(): Promise<void>;
|
|
729
|
+
activateClient?(ctx: ClientExtensionContext): Promise<void>;
|
|
730
|
+
deactivateClient?(): Promise<void>;
|
|
731
|
+
observe?(events: readonly CommitEvent[], editor: Editor): void;
|
|
732
|
+
state?: ExtensionStateSpec<unknown>;
|
|
733
|
+
}
|
|
734
|
+
interface ExtensionStateSpec<T> {
|
|
735
|
+
init(editor: Editor): T;
|
|
736
|
+
apply?(state: T, events: readonly CommitEvent[], editor: Editor): T;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
type BlockCapabilityKey = "table";
|
|
740
|
+
|
|
741
|
+
interface BlockCapabilityMap {
|
|
742
|
+
table: TableBlockHandle;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
interface LayoutSchema {
|
|
746
|
+
modes: readonly ("flex" | "grid")[];
|
|
747
|
+
defaultMode: "flex" | "grid";
|
|
748
|
+
allowedChildren?: string[];
|
|
749
|
+
minChildren?: number;
|
|
750
|
+
maxChildren?: number;
|
|
751
|
+
}
|
|
752
|
+
interface LayoutProps {
|
|
753
|
+
display: "flex" | "grid";
|
|
754
|
+
direction?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
755
|
+
wrap?: "nowrap" | "wrap" | "wrap-reverse";
|
|
756
|
+
gap?: number | string;
|
|
757
|
+
alignItems?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
758
|
+
justifyContent?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
759
|
+
columns?: string;
|
|
760
|
+
rows?: string;
|
|
761
|
+
autoFlow?: "row" | "column" | "dense";
|
|
762
|
+
padding?: Spacing;
|
|
763
|
+
margin?: Spacing;
|
|
764
|
+
background?: string;
|
|
765
|
+
border?: BorderDef;
|
|
766
|
+
borderRadius?: number | string;
|
|
767
|
+
width?: string;
|
|
768
|
+
maxWidth?: string;
|
|
769
|
+
minHeight?: string;
|
|
770
|
+
overflow?: "visible" | "hidden" | "auto";
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
type ColumnType = "text" | "number" | "checkbox" | "select" | "multiSelect" | "date" | "url" | "email" | "relation" | "formula";
|
|
774
|
+
interface SelectOption {
|
|
775
|
+
id: string;
|
|
776
|
+
value: string;
|
|
777
|
+
color?: string;
|
|
778
|
+
label?: string;
|
|
779
|
+
}
|
|
780
|
+
interface NumberFormat {
|
|
781
|
+
style: "plain" | "currency" | "percent";
|
|
782
|
+
decimals?: number;
|
|
783
|
+
currency?: string;
|
|
784
|
+
}
|
|
785
|
+
interface DateFormat {
|
|
786
|
+
includeTime?: boolean;
|
|
787
|
+
dateStyle?: "short" | "medium" | "long";
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
interface TableRowHandle {
|
|
791
|
+
readonly id: string;
|
|
792
|
+
readonly index: number;
|
|
793
|
+
}
|
|
794
|
+
interface InlineNodeDeltaInsert {
|
|
795
|
+
type: string;
|
|
796
|
+
props: Record<string, unknown>;
|
|
797
|
+
}
|
|
798
|
+
interface InlineDelta {
|
|
799
|
+
insert: string | InlineNodeDeltaInsert;
|
|
800
|
+
attributes?: Record<string, unknown>;
|
|
801
|
+
}
|
|
802
|
+
interface TableColumnSchema {
|
|
803
|
+
id: string;
|
|
804
|
+
title: string;
|
|
805
|
+
type: ColumnType;
|
|
806
|
+
width?: number;
|
|
807
|
+
hidden?: boolean;
|
|
808
|
+
pinned?: "left" | "right";
|
|
809
|
+
options?: SelectOption[];
|
|
810
|
+
format?: NumberFormat | DateFormat;
|
|
811
|
+
readonly?: boolean;
|
|
812
|
+
}
|
|
813
|
+
interface TableCellHandle {
|
|
814
|
+
readonly id: string;
|
|
815
|
+
readonly row: number;
|
|
816
|
+
readonly col: number;
|
|
817
|
+
textContent(): string;
|
|
818
|
+
length(): number;
|
|
819
|
+
inlineDeltas(): InlineDelta[];
|
|
820
|
+
textDeltas(): Array<{
|
|
821
|
+
insert: string;
|
|
822
|
+
attributes?: Record<string, unknown>;
|
|
823
|
+
}>;
|
|
824
|
+
}
|
|
825
|
+
interface BlockHandle {
|
|
826
|
+
readonly id: string;
|
|
827
|
+
readonly type: string;
|
|
828
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
829
|
+
readonly index: number;
|
|
830
|
+
readonly prev: BlockHandle | null;
|
|
831
|
+
readonly next: BlockHandle | null;
|
|
832
|
+
readonly parent: BlockHandle | null;
|
|
833
|
+
readonly children: readonly BlockHandle[];
|
|
834
|
+
descendants(type?: string): Iterable<BlockHandle>;
|
|
835
|
+
ancestors(): Iterable<BlockHandle>;
|
|
836
|
+
siblings(): Iterable<BlockHandle>;
|
|
837
|
+
readonly layout: LayoutProps | null;
|
|
838
|
+
readonly isLayoutChild: boolean;
|
|
839
|
+
layoutParent(): BlockHandle | null;
|
|
840
|
+
anchoredApps(): readonly AppHandle[];
|
|
841
|
+
textContent(options?: {
|
|
842
|
+
resolved?: boolean;
|
|
843
|
+
}): string;
|
|
844
|
+
inlineDeltas(): InlineDelta[];
|
|
845
|
+
textDeltas(): Array<{
|
|
846
|
+
insert: string;
|
|
847
|
+
attributes?: Record<string, unknown>;
|
|
848
|
+
}>;
|
|
849
|
+
length(): number;
|
|
850
|
+
as<K extends BlockCapabilityKey>(capability: K): BlockCapabilityMap[K] | null;
|
|
851
|
+
meta(namespace: string): Readonly<Record<string, unknown>> | null;
|
|
852
|
+
}
|
|
853
|
+
interface TableBlockHandle extends BlockHandle {
|
|
854
|
+
tableRowCount(): number;
|
|
855
|
+
tableColumnCount(): number;
|
|
856
|
+
tableRow(row: number): TableRowHandle | null;
|
|
857
|
+
tableCell(row: number, col: number): TableCellHandle | null;
|
|
858
|
+
tableColumns(): readonly TableColumnSchema[];
|
|
859
|
+
}
|
|
860
|
+
interface AppHandle {
|
|
861
|
+
readonly id: string;
|
|
862
|
+
readonly type: string;
|
|
863
|
+
readonly placement: AppPlacement;
|
|
864
|
+
readonly config: Readonly<Record<string, unknown>>;
|
|
865
|
+
readonly anchorBlock: BlockHandle | null;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
interface MarkdownNode {
|
|
869
|
+
type: string;
|
|
870
|
+
children?: MarkdownNode[];
|
|
871
|
+
value?: string;
|
|
872
|
+
url?: string;
|
|
873
|
+
alt?: string;
|
|
874
|
+
title?: string | null;
|
|
875
|
+
depth?: number;
|
|
876
|
+
lang?: string | null;
|
|
877
|
+
ordered?: boolean;
|
|
878
|
+
start?: number | null;
|
|
879
|
+
checked?: boolean | null;
|
|
880
|
+
attributes?: Record<string, unknown>;
|
|
881
|
+
}
|
|
882
|
+
interface HTMLImportTextNode {
|
|
883
|
+
type: "text";
|
|
884
|
+
textContent: string;
|
|
885
|
+
}
|
|
886
|
+
interface HTMLImportElement {
|
|
887
|
+
type: "element";
|
|
888
|
+
tagName: string;
|
|
889
|
+
attributes: Record<string, string>;
|
|
890
|
+
children: HTMLImportNode[];
|
|
891
|
+
textContent?: string;
|
|
892
|
+
getAttribute(name: string): string | null;
|
|
893
|
+
hasAttribute(name: string): boolean;
|
|
894
|
+
}
|
|
895
|
+
type HTMLImportNode = HTMLImportElement | HTMLImportTextNode;
|
|
896
|
+
interface XMLElement {
|
|
897
|
+
tagName: string;
|
|
898
|
+
attributes: Record<string, string>;
|
|
899
|
+
children: XMLElement[];
|
|
900
|
+
textContent?: string;
|
|
901
|
+
}
|
|
902
|
+
interface Exporter<Output = string, Extra extends Record<string, unknown> = Record<string, never>> {
|
|
903
|
+
name: string;
|
|
904
|
+
mimeType: string;
|
|
905
|
+
fileExtension: string;
|
|
906
|
+
/**
|
|
907
|
+
* Serialize the current document as it exists.
|
|
908
|
+
*
|
|
909
|
+
* Exporters are document-preservation surfaces, not authoring policy
|
|
910
|
+
* surfaces: they should generally serialize existing blocks even when those
|
|
911
|
+
* block types are hidden from menus or disallowed as new insertions in the
|
|
912
|
+
* active documentProfile.
|
|
913
|
+
*/
|
|
914
|
+
export(editor: Editor, options?: ExportOptions<Extra>): Output | Promise<Output>;
|
|
915
|
+
exportFragment?(blocks: BlockHandle[], options?: ExportOptions<Extra>): Output;
|
|
916
|
+
}
|
|
917
|
+
interface ExportOptions<Extra extends Record<string, unknown> = Record<string, never>> {
|
|
918
|
+
/**
|
|
919
|
+
* Export flags shape serialization output, but they do not redefine document
|
|
920
|
+
* authoring policy. Use schema/profile-aware helpers on authoring surfaces
|
|
921
|
+
* (menus, tools, paste/import) when deciding what users may insert.
|
|
922
|
+
*/
|
|
923
|
+
includeApps?: boolean;
|
|
924
|
+
includeLayout?: boolean;
|
|
925
|
+
includeMetadata?: boolean;
|
|
926
|
+
includeSuggestions?: boolean;
|
|
927
|
+
prettyPrint?: boolean;
|
|
928
|
+
extra?: Extra;
|
|
929
|
+
}
|
|
930
|
+
interface Importer<Input = string, Parsed = unknown> {
|
|
931
|
+
name: string;
|
|
932
|
+
mimeType: string;
|
|
933
|
+
parse?(input: Input, editor: Editor): Parsed | Promise<Parsed>;
|
|
934
|
+
/**
|
|
935
|
+
* Import is an authoring boundary. Implementations should normalize parsed
|
|
936
|
+
* content against the active schema/documentProfile before applying writes so
|
|
937
|
+
* callers can observe dropped or transformed content deterministically.
|
|
938
|
+
*/
|
|
939
|
+
import(input: Input, editor: Editor, options?: ImportOptions): ImportResult | void | Promise<ImportResult | void>;
|
|
940
|
+
}
|
|
941
|
+
interface ImportOptions {
|
|
942
|
+
position?: Position;
|
|
943
|
+
replace?: boolean;
|
|
944
|
+
validate?: boolean;
|
|
945
|
+
normalize?: boolean;
|
|
946
|
+
undoGroup?: boolean;
|
|
947
|
+
}
|
|
948
|
+
interface ImportResult {
|
|
949
|
+
/**
|
|
950
|
+
* Summary of import-side normalization. This reports what parsed content was
|
|
951
|
+
* accepted into the current authoring surface; it may therefore differ from
|
|
952
|
+
* what an exporter would serialize from an already-existing document.
|
|
953
|
+
*/
|
|
954
|
+
parsedTopLevelBlockCount: number;
|
|
955
|
+
importedTopLevelBlockCount: number;
|
|
956
|
+
droppedBlockCount: number;
|
|
957
|
+
droppedBlockTypes: string[];
|
|
958
|
+
normalized: boolean;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
interface KeyBindingContext {
|
|
962
|
+
blockType?: string[];
|
|
963
|
+
hasSelection?: boolean;
|
|
964
|
+
collapsed?: boolean;
|
|
965
|
+
withinLayout?: string[];
|
|
966
|
+
}
|
|
967
|
+
interface KeyBinding {
|
|
968
|
+
key: string;
|
|
969
|
+
priority?: number;
|
|
970
|
+
context?: KeyBindingContext;
|
|
971
|
+
description?: string;
|
|
972
|
+
handler: (editor: Editor, event: KeyboardEvent) => boolean;
|
|
973
|
+
}
|
|
974
|
+
interface InputRuleContext {
|
|
975
|
+
editor: Editor;
|
|
976
|
+
blockId: string;
|
|
977
|
+
blockType: string;
|
|
978
|
+
textBefore: string;
|
|
979
|
+
fullText: string;
|
|
980
|
+
}
|
|
981
|
+
type InputRuleHandler = (match: RegExpMatchArray, context: InputRuleContext) => DocumentOp[] | null;
|
|
982
|
+
interface InputRule {
|
|
983
|
+
id: string;
|
|
984
|
+
match: RegExp;
|
|
985
|
+
blockTypes?: string[];
|
|
986
|
+
handler: InputRuleHandler;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
interface BlockA11ySpec<Props = Record<string, unknown>> {
|
|
990
|
+
label: string | ((props: Props) => string);
|
|
991
|
+
roleDescription?: string;
|
|
992
|
+
}
|
|
993
|
+
/** Surface label for `pen.a11yLabel`: `aria-label` string or `aria-labelledby` id. */
|
|
994
|
+
type A11yLabel = string | {
|
|
995
|
+
readonly labelledBy: string;
|
|
996
|
+
};
|
|
997
|
+
declare function isA11yLabelledBy(value: A11yLabel): value is {
|
|
998
|
+
readonly labelledBy: string;
|
|
999
|
+
};
|
|
1000
|
+
interface EditorAnnouncer {
|
|
1001
|
+
announce(message: string, priority?: "polite" | "assertive", key?: string): void;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
type PropSchema = {
|
|
1005
|
+
type?: string | string[];
|
|
1006
|
+
default?: unknown;
|
|
1007
|
+
enum?: unknown[];
|
|
1008
|
+
description?: string;
|
|
1009
|
+
properties?: Record<string, PropSchema>;
|
|
1010
|
+
items?: PropSchema;
|
|
1011
|
+
minimum?: number;
|
|
1012
|
+
maximum?: number;
|
|
1013
|
+
[key: string]: unknown;
|
|
1014
|
+
};
|
|
1015
|
+
type ContentType = "inline" | "none" | "table" | "subdocument" | BlockSchema[];
|
|
1016
|
+
declare function isNestedContent(content: ContentType): content is BlockSchema[];
|
|
1017
|
+
interface BlockDisplay {
|
|
1018
|
+
title: string;
|
|
1019
|
+
description?: string;
|
|
1020
|
+
icon?: string;
|
|
1021
|
+
group?: string;
|
|
1022
|
+
aliases?: string[];
|
|
1023
|
+
hidden?: boolean;
|
|
1024
|
+
}
|
|
1025
|
+
interface ImportInlineMark {
|
|
1026
|
+
type: string;
|
|
1027
|
+
props?: Record<string, unknown>;
|
|
1028
|
+
start: number;
|
|
1029
|
+
end: number;
|
|
1030
|
+
}
|
|
1031
|
+
interface ImportContentSource {
|
|
1032
|
+
markdownNodes?: MarkdownNode[];
|
|
1033
|
+
markdownHtml?: string;
|
|
1034
|
+
htmlElement?: HTMLImportElement;
|
|
1035
|
+
}
|
|
1036
|
+
interface BlockImportMatch<Type extends string = string, Props extends Record<string, unknown> = Record<string, unknown>> {
|
|
1037
|
+
type: Type;
|
|
1038
|
+
props: Props;
|
|
1039
|
+
content?: string;
|
|
1040
|
+
marks?: ImportInlineMark[];
|
|
1041
|
+
children?: BlockImportMatch[];
|
|
1042
|
+
importContentSource?: ImportContentSource;
|
|
1043
|
+
}
|
|
1044
|
+
type InferProps<P extends Record<string, PropSchema>> = {
|
|
1045
|
+
[K in keyof P]: unknown;
|
|
1046
|
+
};
|
|
1047
|
+
type FieldEditorType = "richtext" | "plaintext" | "code" | "table" | "subdocument" | "none";
|
|
1048
|
+
type FlowBlockCapability = "flow-inline" | "flow-structural" | "flow-delegated" | "flow-disallowed";
|
|
1049
|
+
type BlockSelectionRole = "editable-inline" | "structural" | "delegated";
|
|
1050
|
+
interface BlockAuthoring {
|
|
1051
|
+
flowCapability?: FlowBlockCapability;
|
|
1052
|
+
selectionRole?: BlockSelectionRole;
|
|
1053
|
+
}
|
|
1054
|
+
interface BlockSchema<Type extends string = string, Props extends Record<string, PropSchema> = Record<string, PropSchema>, Content extends ContentType = "inline"> {
|
|
1055
|
+
type: Type;
|
|
1056
|
+
propSchema: Props;
|
|
1057
|
+
content: Content;
|
|
1058
|
+
layout?: LayoutSchema;
|
|
1059
|
+
serialize: {
|
|
1060
|
+
toMarkdown?: (block: Block<Type, InferProps<Props>>) => string;
|
|
1061
|
+
fromMarkdown?: (node: MarkdownNode) => BlockImportMatch<Type, InferProps<Props>> | null;
|
|
1062
|
+
toHTML?: (block: Block<Type, InferProps<Props>>) => string;
|
|
1063
|
+
fromHTML?: (element: HTMLImportElement) => BlockImportMatch<Type, InferProps<Props>> | null;
|
|
1064
|
+
toXML?: (block: Block<Type, InferProps<Props>>) => string;
|
|
1065
|
+
fromXML?: (element: XMLElement) => Block<Type, InferProps<Props>> | null;
|
|
1066
|
+
};
|
|
1067
|
+
normalize?: (block: Block<Type, InferProps<Props>>) => Block<Type, InferProps<Props>>;
|
|
1068
|
+
validateProps?: (raw: Record<string, unknown>) => InferProps<Props>;
|
|
1069
|
+
fieldEditor?: FieldEditorType;
|
|
1070
|
+
keyBindings?: readonly KeyBinding[];
|
|
1071
|
+
placeholder?: string;
|
|
1072
|
+
display?: BlockDisplay;
|
|
1073
|
+
authoring?: BlockAuthoring;
|
|
1074
|
+
isContainer?: boolean;
|
|
1075
|
+
aiDescription?: string;
|
|
1076
|
+
a11y?: BlockA11ySpec<InferProps<Props>>;
|
|
1077
|
+
}
|
|
1078
|
+
interface InlineSchema<Type extends string = string, Props extends Record<string, PropSchema> = Record<string, PropSchema>> {
|
|
1079
|
+
type: Type;
|
|
1080
|
+
propSchema: Props;
|
|
1081
|
+
kind: "mark" | "node";
|
|
1082
|
+
serialize: {
|
|
1083
|
+
toMarkdown?: (text: string, props: Record<string, unknown>) => string;
|
|
1084
|
+
fromMarkdown?: (node: MarkdownNode) => Record<string, unknown> | null;
|
|
1085
|
+
toHTML?: (text: string, props: Record<string, unknown>) => string;
|
|
1086
|
+
toXML?: (text: string, props: Record<string, unknown>) => string;
|
|
1087
|
+
};
|
|
1088
|
+
apply?(content: unknown, range: Range, value: unknown): void;
|
|
1089
|
+
remove?(content: unknown, range: Range): void;
|
|
1090
|
+
query?(content: unknown, index: number): unknown | null;
|
|
1091
|
+
priority?: number;
|
|
1092
|
+
expand?: "after" | "before" | "both" | "none";
|
|
1093
|
+
system?: boolean;
|
|
1094
|
+
aiDescription?: string;
|
|
1095
|
+
a11y?: BlockA11ySpec<InferProps<Props>>;
|
|
1096
|
+
}
|
|
1097
|
+
interface AppSchema<Type extends string = string, Config extends Record<string, PropSchema> = Record<string, PropSchema>> {
|
|
1098
|
+
type: Type;
|
|
1099
|
+
configSchema: Config;
|
|
1100
|
+
defaultPlacement: AppPlacement["mode"];
|
|
1101
|
+
allowedPlacements: AppPlacement["mode"][];
|
|
1102
|
+
onAnchorDeleted?: "delete" | "orphan";
|
|
1103
|
+
isolation?: "none" | "error-boundary" | "iframe";
|
|
1104
|
+
serialize: {
|
|
1105
|
+
toMarkdown?: (app: App<Type>) => string;
|
|
1106
|
+
toHTML?: (app: App<Type>) => string;
|
|
1107
|
+
toXML?: (app: App<Type>) => string;
|
|
1108
|
+
};
|
|
1109
|
+
aiDescription?: string;
|
|
1110
|
+
}
|
|
1111
|
+
interface SchemaRegistry {
|
|
1112
|
+
resolve(type: string): BlockSchema | null;
|
|
1113
|
+
resolveInline(type: string): InlineSchema | null;
|
|
1114
|
+
resolveApp(type: string): AppSchema | null;
|
|
1115
|
+
resolveLayout(type: string): LayoutSchema | null;
|
|
1116
|
+
allBlocks(): readonly BlockSchema[];
|
|
1117
|
+
allInlines(): readonly InlineSchema[];
|
|
1118
|
+
allApps(): readonly AppSchema[];
|
|
1119
|
+
allBlockDisplays(): readonly (BlockSchema & {
|
|
1120
|
+
display: BlockDisplay;
|
|
1121
|
+
})[];
|
|
1122
|
+
onUnknownBlock?: (type: string, raw: unknown) => BlockSchema | "drop" | "passthrough";
|
|
1123
|
+
onUnknownInline?: (type: string, raw: unknown) => InlineSchema | "drop" | "passthrough";
|
|
1124
|
+
}
|
|
1125
|
+
interface ComposableSchema extends SchemaRegistry {
|
|
1126
|
+
extend(schemas: readonly (BlockSchema | InlineSchema)[]): ComposableSchema;
|
|
1127
|
+
without(types: readonly string[]): ComposableSchema;
|
|
1128
|
+
override(type: string, overrides: Partial<BlockSchema>): ComposableSchema;
|
|
1129
|
+
overrideSystemMark(type: string, schema: InlineSchema): ComposableSchema;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Host-owned persistence for a Pen document's Yjs bytes and version snapshots.
|
|
1134
|
+
*
|
|
1135
|
+
* `@input/pen-snapshots` calls the version-snapshot members. The update-log
|
|
1136
|
+
* members and {@link PenPersistence.compact} are host-implemented: Pen never
|
|
1137
|
+
* calls them (API10). See `PERSISTENCE.md` for the per-member disposition,
|
|
1138
|
+
* including {@link AssetProvider} / {@link AssetUploadOptions}.
|
|
1139
|
+
*/
|
|
1140
|
+
interface PenPersistence {
|
|
1141
|
+
/**
|
|
1142
|
+
* Load the latest persisted state for `docId`.
|
|
1143
|
+
*
|
|
1144
|
+
* @remarks
|
|
1145
|
+
* Host-implemented. Pen never calls `loadDocument`. The host calls this
|
|
1146
|
+
* when it opens a stored document, then feeds the bytes to
|
|
1147
|
+
* `CRDTAdapter.loadDocument` (or `Editor.loadDocument` after adapting).
|
|
1148
|
+
* Return `null` when the host has no bytes for `docId` — the host then
|
|
1149
|
+
* creates a new document with `adapter.createDocument()`. Rejection is
|
|
1150
|
+
* host-defined; Pen is not on the stack and does not catch it. A rejected
|
|
1151
|
+
* load is an aborted open.
|
|
1152
|
+
*/
|
|
1153
|
+
loadDocument(docId: string): Promise<Uint8Array | null>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Persist a full encoded document state.
|
|
1156
|
+
*
|
|
1157
|
+
* @remarks
|
|
1158
|
+
* Host-implemented. Pen never calls `saveSnapshot`. The host calls this
|
|
1159
|
+
* on its own schedule (idle, interval, unload) with
|
|
1160
|
+
* `adapter.encodeState` / `Y.encodeStateAsUpdate` bytes. This is a
|
|
1161
|
+
* full-state write, not an incremental update. Rejection is host-defined;
|
|
1162
|
+
* Pen does not catch it. A rejected save means that full state is not
|
|
1163
|
+
* durable — if the host also keeps an update log, that log is the
|
|
1164
|
+
* recovery path.
|
|
1165
|
+
*/
|
|
1166
|
+
saveSnapshot(docId: string, state: Uint8Array): Promise<void>;
|
|
1167
|
+
/**
|
|
1168
|
+
* Append a Yjs update to the document's update log.
|
|
1169
|
+
*
|
|
1170
|
+
* @remarks
|
|
1171
|
+
* Host-implemented. Pen never calls `appendUpdate`. The host typically
|
|
1172
|
+
* calls this from a `Y.Doc` update observer after encoding the update.
|
|
1173
|
+
* Rejection is host-defined; Pen does not catch it. A dropped append
|
|
1174
|
+
* leaves a gap in the log, so a later rebuild from `getUpdates` is
|
|
1175
|
+
* incomplete unless the host also has a later `saveSnapshot`. Hosts that
|
|
1176
|
+
* persist only full snapshots may implement this as a no-op.
|
|
1177
|
+
*/
|
|
1178
|
+
appendUpdate(docId: string, update: Uint8Array): Promise<void>;
|
|
1179
|
+
/**
|
|
1180
|
+
* Read updates from the document's update log.
|
|
1181
|
+
*
|
|
1182
|
+
* @remarks
|
|
1183
|
+
* Host-implemented. Pen never calls `getUpdates`. The host calls this to
|
|
1184
|
+
* rebuild state or feed a replica. `since` is an opaque cursor the host
|
|
1185
|
+
* defines (often the last persisted update or a state vector); omit it
|
|
1186
|
+
* to read the whole log. Rejection is host-defined; Pen does not catch
|
|
1187
|
+
* it. Hosts that persist only full snapshots may return `[]`.
|
|
1188
|
+
*/
|
|
1189
|
+
getUpdates(docId: string, since?: Uint8Array): Promise<Uint8Array[]>;
|
|
1190
|
+
/**
|
|
1191
|
+
* Compact stored updates for `docId`.
|
|
1192
|
+
*
|
|
1193
|
+
* @remarks
|
|
1194
|
+
* Host-implemented. Pen never calls `compact`. The host calls this when
|
|
1195
|
+
* it wants to shrink its own update log. Compaction is a host storage
|
|
1196
|
+
* concern: `Y.mergeUpdates` folds an update log, not tombstones. Snapshot
|
|
1197
|
+
* retention and `gc: true` are separate tradeoffs — see the compaction
|
|
1198
|
+
* notes in `@input/pen-yjs`. Rejection is host-defined; Pen does not
|
|
1199
|
+
* catch it. A rejected compact leaves the log as stored.
|
|
1200
|
+
*/
|
|
1201
|
+
compact(docId: string): Promise<void>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Persist a version snapshot.
|
|
1204
|
+
*
|
|
1205
|
+
* @remarks
|
|
1206
|
+
* Called by `@input/pen-snapshots` `SnapshotManager.createSnapshot`.
|
|
1207
|
+
* If this rejects, `createSnapshot` rejects and no version is listed.
|
|
1208
|
+
* Pen does not catch the rejection; the host chooses the error type.
|
|
1209
|
+
*/
|
|
1210
|
+
saveVersionSnapshot(docId: string, snapshot: Uint8Array, metadata: VersionMetadata): Promise<void>;
|
|
1211
|
+
/**
|
|
1212
|
+
* List version snapshots.
|
|
1213
|
+
*
|
|
1214
|
+
* @remarks
|
|
1215
|
+
* Called by `@input/pen-snapshots` `SnapshotManager.createSnapshot` (latest
|
|
1216
|
+
* entry after write, `{ limit: 1 }`) and `SnapshotManager.listSnapshots`.
|
|
1217
|
+
* If this rejects, the calling method rejects. If `createSnapshot`
|
|
1218
|
+
* receives an empty list after a successful write, it synthesizes an
|
|
1219
|
+
* entry with a fresh id. There is no `getVersionSnapshots`.
|
|
1220
|
+
*/
|
|
1221
|
+
listVersions(docId: string, options?: {
|
|
1222
|
+
limit?: number;
|
|
1223
|
+
before?: string;
|
|
1224
|
+
}): Promise<VersionEntry[]>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Load a version snapshot for restore.
|
|
1227
|
+
*
|
|
1228
|
+
* @remarks
|
|
1229
|
+
* Called by `@input/pen-snapshots` `SnapshotManager.restoreSnapshot`.
|
|
1230
|
+
* Restore uses the returned `snapshot` bytes. A missing version throws
|
|
1231
|
+
* `Snapshot ${versionId} not found` from the manager. If this rejects,
|
|
1232
|
+
* restore rejects. Pen does not catch the rejection.
|
|
1233
|
+
* Listing is {@link PenPersistence.listVersions}.
|
|
1234
|
+
*/
|
|
1235
|
+
loadVersion(docId: string, versionId: string): Promise<{
|
|
1236
|
+
state: Uint8Array;
|
|
1237
|
+
snapshot: Uint8Array;
|
|
1238
|
+
}>;
|
|
1239
|
+
}
|
|
1240
|
+
interface VersionMetadata {
|
|
1241
|
+
label?: string;
|
|
1242
|
+
trigger: "auto" | "manual" | "ai-generation" | "import";
|
|
1243
|
+
clientId: number;
|
|
1244
|
+
timestamp: number;
|
|
1245
|
+
}
|
|
1246
|
+
interface VersionEntry {
|
|
1247
|
+
id: string;
|
|
1248
|
+
metadata: VersionMetadata;
|
|
1249
|
+
createdAt: number;
|
|
1250
|
+
}
|
|
1251
|
+
interface AssetRef {
|
|
1252
|
+
id: string;
|
|
1253
|
+
url: string;
|
|
1254
|
+
mimeType: string;
|
|
1255
|
+
size: number;
|
|
1256
|
+
}
|
|
1257
|
+
interface AssetUploadOptions {
|
|
1258
|
+
mimeType?: string;
|
|
1259
|
+
/**
|
|
1260
|
+
* Maximum accepted size in bytes. Pen enforces this before calling
|
|
1261
|
+
* {@link AssetProvider.upload} and forwards the same limit to the provider.
|
|
1262
|
+
* Oversize files emit `asset-upload-failed` naming this limit and the actual
|
|
1263
|
+
* size; they are not uploaded and produce no image block.
|
|
1264
|
+
*/
|
|
1265
|
+
maxSize?: number;
|
|
1266
|
+
/**
|
|
1267
|
+
* Upload progress in the range `[0, 1]`. Pen forwards this callback to
|
|
1268
|
+
* {@link AssetProvider.upload}; the provider invokes it during the upload.
|
|
1269
|
+
*/
|
|
1270
|
+
onProgress?: (progress: number) => void;
|
|
1271
|
+
}
|
|
1272
|
+
interface AssetProvider {
|
|
1273
|
+
/**
|
|
1274
|
+
* Host-declared maximum upload size in bytes.
|
|
1275
|
+
*
|
|
1276
|
+
* @remarks
|
|
1277
|
+
* Read by `@input/pen-dom` `uploadImageFiles` and
|
|
1278
|
+
* `@input/pen-interop/html` `applyHtmlImageSrcPolicy` before `upload`.
|
|
1279
|
+
* The same limit is forwarded as {@link AssetUploadOptions.maxSize}.
|
|
1280
|
+
*/
|
|
1281
|
+
readonly maxSize?: number;
|
|
1282
|
+
/**
|
|
1283
|
+
* Store `file` and return a durable ref.
|
|
1284
|
+
*
|
|
1285
|
+
* @remarks
|
|
1286
|
+
* Called by `@input/pen-dom` `uploadImageFiles` (paste/drop) and
|
|
1287
|
+
* `@input/pen-interop/html` `applyHtmlImageSrcPolicy` when `imageSrc` is
|
|
1288
|
+
* `"ingest"`.
|
|
1289
|
+
*/
|
|
1290
|
+
upload(file: File | Blob, options?: AssetUploadOptions): Promise<AssetRef>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Return a URL the renderer can use for `ref`.
|
|
1293
|
+
*
|
|
1294
|
+
* @remarks
|
|
1295
|
+
* Called after a successful `upload` at the same two sites.
|
|
1296
|
+
*/
|
|
1297
|
+
resolve(ref: AssetRef): string;
|
|
1298
|
+
/**
|
|
1299
|
+
* Remove an asset from host storage.
|
|
1300
|
+
*
|
|
1301
|
+
* @remarks
|
|
1302
|
+
* Host-implemented. Pen never calls `delete`. Pen cannot know whether a
|
|
1303
|
+
* removed block's asset is still referenced by another document, a version
|
|
1304
|
+
* snapshot, or a collaborator's pending undo. Hosts own reference counting
|
|
1305
|
+
* and should call `delete` only when their count reaches zero.
|
|
1306
|
+
*/
|
|
1307
|
+
delete(ref: AssetRef): Promise<void>;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
type A11yMessageKey = "blockConverted" | "undoApplied" | "redoApplied" | "blockSelectionEntered" | "blockSelectionChanged" | "cellSelectionChanged" | "suggestionAppeared" | "suggestionAccepted" | "suggestionRejected" | "streamingStarted" | "streamingFinished" | "findMatches" | "atomSelected" | "collaboratorJoined" | "collaboratorEditing";
|
|
1311
|
+
type A11yMessageCatalog = Record<A11yMessageKey, string>;
|
|
1312
|
+
|
|
1313
|
+
type NoMessageParams = Record<never, never>;
|
|
1314
|
+
type A11yMessageParams = {
|
|
1315
|
+
blockConverted: {
|
|
1316
|
+
blockType: string;
|
|
1317
|
+
};
|
|
1318
|
+
undoApplied: {
|
|
1319
|
+
hint: string;
|
|
1320
|
+
};
|
|
1321
|
+
redoApplied: {
|
|
1322
|
+
hint: string;
|
|
1323
|
+
};
|
|
1324
|
+
blockSelectionEntered: {
|
|
1325
|
+
count: number;
|
|
1326
|
+
};
|
|
1327
|
+
blockSelectionChanged: {
|
|
1328
|
+
count: number;
|
|
1329
|
+
};
|
|
1330
|
+
cellSelectionChanged: {
|
|
1331
|
+
rows: number;
|
|
1332
|
+
columns: number;
|
|
1333
|
+
};
|
|
1334
|
+
suggestionAppeared: NoMessageParams;
|
|
1335
|
+
suggestionAccepted: NoMessageParams;
|
|
1336
|
+
suggestionRejected: NoMessageParams;
|
|
1337
|
+
streamingStarted: NoMessageParams;
|
|
1338
|
+
streamingFinished: NoMessageParams;
|
|
1339
|
+
findMatches: {
|
|
1340
|
+
count: number;
|
|
1341
|
+
};
|
|
1342
|
+
atomSelected: {
|
|
1343
|
+
atomType: string;
|
|
1344
|
+
};
|
|
1345
|
+
collaboratorJoined: {
|
|
1346
|
+
name: string;
|
|
1347
|
+
};
|
|
1348
|
+
collaboratorEditing: {
|
|
1349
|
+
name: string;
|
|
1350
|
+
};
|
|
1351
|
+
};
|
|
1352
|
+
type PluralMessage = {
|
|
1353
|
+
readonly other: string;
|
|
1354
|
+
} & Partial<Record<Exclude<Intl.LDMLPluralRule, "other">, string>>;
|
|
1355
|
+
type MessageValue = string | PluralMessage;
|
|
1356
|
+
type MessageParamsByKey = {
|
|
1357
|
+
[K in A11yMessageKey as `pen.a11y.${K}`]: A11yMessageParams[K];
|
|
1358
|
+
} & {
|
|
1359
|
+
"pen.selection.blocksSelected": {
|
|
1360
|
+
count: number;
|
|
1361
|
+
};
|
|
1362
|
+
"pen.ai.review.accept": NoMessageParams;
|
|
1363
|
+
"pen.schema.paragraph.title": NoMessageParams;
|
|
1364
|
+
"pen.schema.paragraph.description": NoMessageParams;
|
|
1365
|
+
"pen.schema.paragraph.placeholder": NoMessageParams;
|
|
1366
|
+
"pen.schema.heading.title": NoMessageParams;
|
|
1367
|
+
"pen.schema.heading.placeholder": NoMessageParams;
|
|
1368
|
+
"pen.display.group.basic": NoMessageParams;
|
|
1369
|
+
"pen.display.group.lists": NoMessageParams;
|
|
1370
|
+
"pen.display.group.other": NoMessageParams;
|
|
1371
|
+
"pen.schema.document.emptyPlaceholder": NoMessageParams;
|
|
1372
|
+
"pen.editor.label": NoMessageParams;
|
|
1373
|
+
"pen.toolbar.formatting": NoMessageParams;
|
|
1374
|
+
"pen.drag.reorderBlock": NoMessageParams;
|
|
1375
|
+
"pen.blockHandle.reorder": NoMessageParams;
|
|
1376
|
+
"pen.blockHandle.moveUp": NoMessageParams;
|
|
1377
|
+
"pen.blockHandle.moveDown": NoMessageParams;
|
|
1378
|
+
"pen.search.input.placeholder": NoMessageParams;
|
|
1379
|
+
"pen.search.input.label": NoMessageParams;
|
|
1380
|
+
"pen.search.replace.placeholder": NoMessageParams;
|
|
1381
|
+
"pen.search.replace.label": NoMessageParams;
|
|
1382
|
+
"pen.search.results.label": NoMessageParams;
|
|
1383
|
+
"pen.search.results.none": NoMessageParams;
|
|
1384
|
+
"pen.search.results.count": {
|
|
1385
|
+
current: number;
|
|
1386
|
+
count: number;
|
|
1387
|
+
};
|
|
1388
|
+
"pen.search.next": NoMessageParams;
|
|
1389
|
+
"pen.search.previous": NoMessageParams;
|
|
1390
|
+
"pen.search.replaceMatch": NoMessageParams;
|
|
1391
|
+
"pen.search.replaceAll": NoMessageParams;
|
|
1392
|
+
"pen.search.toggle.caseSensitive": NoMessageParams;
|
|
1393
|
+
"pen.search.toggle.regex": NoMessageParams;
|
|
1394
|
+
"pen.search.toggle.wholeWord": NoMessageParams;
|
|
1395
|
+
"pen.slash.input.placeholder": NoMessageParams;
|
|
1396
|
+
"pen.slash.list.label": NoMessageParams;
|
|
1397
|
+
"pen.suggestion.list.label": NoMessageParams;
|
|
1398
|
+
"pen.table.addColumn": NoMessageParams;
|
|
1399
|
+
"pen.table.addRow": NoMessageParams;
|
|
1400
|
+
"pen.table.columnPlaceholder": {
|
|
1401
|
+
index: number;
|
|
1402
|
+
};
|
|
1403
|
+
"pen.table.columnMenu.label": {
|
|
1404
|
+
title: string;
|
|
1405
|
+
};
|
|
1406
|
+
"pen.table.columnMenu.type": NoMessageParams;
|
|
1407
|
+
"pen.table.columnMenu.insertLeft": NoMessageParams;
|
|
1408
|
+
"pen.table.columnMenu.insertRight": NoMessageParams;
|
|
1409
|
+
"pen.table.columnMenu.delete": NoMessageParams;
|
|
1410
|
+
"pen.table.columnType.text": NoMessageParams;
|
|
1411
|
+
"pen.table.columnType.number": NoMessageParams;
|
|
1412
|
+
"pen.table.columnType.select": NoMessageParams;
|
|
1413
|
+
"pen.table.columnType.checkbox": NoMessageParams;
|
|
1414
|
+
"pen.table.columnType.date": NoMessageParams;
|
|
1415
|
+
"pen.table.columnType.url": NoMessageParams;
|
|
1416
|
+
"pen.table.columnType.email": NoMessageParams;
|
|
1417
|
+
"pen.toggle.collapse": NoMessageParams;
|
|
1418
|
+
"pen.toggle.expand": NoMessageParams;
|
|
1419
|
+
"pen.toggle.empty": NoMessageParams;
|
|
1420
|
+
"pen.checklist.toggle": NoMessageParams;
|
|
1421
|
+
"pen.ai.suggestion.previous": NoMessageParams;
|
|
1422
|
+
"pen.ai.suggestion.next": NoMessageParams;
|
|
1423
|
+
"pen.ai.suggestion.count": {
|
|
1424
|
+
current: number;
|
|
1425
|
+
count: number;
|
|
1426
|
+
};
|
|
1427
|
+
"pen.ai.suggestion.groupPrevious": NoMessageParams;
|
|
1428
|
+
"pen.ai.suggestion.groupNext": NoMessageParams;
|
|
1429
|
+
"pen.ai.prompt.placeholder": NoMessageParams;
|
|
1430
|
+
"pen.ai.turn.pending": {
|
|
1431
|
+
count: number;
|
|
1432
|
+
};
|
|
1433
|
+
"pen.ai.turn.working": NoMessageParams;
|
|
1434
|
+
"pen.ai.turn.accepted": NoMessageParams;
|
|
1435
|
+
"pen.ai.turn.rejected": NoMessageParams;
|
|
1436
|
+
"pen.ai.turn.error": NoMessageParams;
|
|
1437
|
+
"pen.ai.turn.done": NoMessageParams;
|
|
1438
|
+
"pen.ai.review.reject": NoMessageParams;
|
|
1439
|
+
"pen.ai.session.inlineEdit": NoMessageParams;
|
|
1440
|
+
"pen.ai.session.selectedRange": NoMessageParams;
|
|
1441
|
+
"pen.ai.session.selectedText": NoMessageParams;
|
|
1442
|
+
"pen.ai.session.targetActive": NoMessageParams;
|
|
1443
|
+
"pen.ai.session.targetPinned": NoMessageParams;
|
|
1444
|
+
"pen.ai.session.followUp": NoMessageParams;
|
|
1445
|
+
"pen.ai.session.runEdit": NoMessageParams;
|
|
1446
|
+
"pen.ai.commandMenu.placeholder": NoMessageParams;
|
|
1447
|
+
"pen.ai.commandMenu.label": NoMessageParams;
|
|
1448
|
+
"pen.ai.command.rewrite": NoMessageParams;
|
|
1449
|
+
"pen.ai.command.rewrite.description": NoMessageParams;
|
|
1450
|
+
"pen.ai.command.continue": NoMessageParams;
|
|
1451
|
+
"pen.ai.command.continue.description": NoMessageParams;
|
|
1452
|
+
"pen.ai.command.summarize": NoMessageParams;
|
|
1453
|
+
"pen.ai.command.summarize.description": NoMessageParams;
|
|
1454
|
+
"pen.ai.command.fixGrammar": NoMessageParams;
|
|
1455
|
+
"pen.ai.command.fixGrammar.description": NoMessageParams;
|
|
1456
|
+
"pen.ai.command.simplify": NoMessageParams;
|
|
1457
|
+
"pen.ai.command.simplify.description": NoMessageParams;
|
|
1458
|
+
"pen.ai.command.expand": NoMessageParams;
|
|
1459
|
+
"pen.ai.command.expand.description": NoMessageParams;
|
|
1460
|
+
"pen.ai.command.translate": NoMessageParams;
|
|
1461
|
+
"pen.ai.command.translate.description": NoMessageParams;
|
|
1462
|
+
"pen.ai.shortcut.undoInline": NoMessageParams;
|
|
1463
|
+
"pen.ai.shortcut.redoInline": NoMessageParams;
|
|
1464
|
+
"pen.ai.suggestion.keep": NoMessageParams;
|
|
1465
|
+
"pen.ai.suggestion.undo": NoMessageParams;
|
|
1466
|
+
"pen.ai.suggestion.heading": NoMessageParams;
|
|
1467
|
+
"pen.ai.suggestion.applyHint": NoMessageParams;
|
|
1468
|
+
"pen.ai.suggestion.dismiss": NoMessageParams;
|
|
1469
|
+
"pen.ai.suggestion.apply": NoMessageParams;
|
|
1470
|
+
"pen.ai.suggestion.kind.spelling": NoMessageParams;
|
|
1471
|
+
"pen.ai.suggestion.kind.grammar": NoMessageParams;
|
|
1472
|
+
"pen.ai.suggestion.kind.clarity": NoMessageParams;
|
|
1473
|
+
"pen.ai.suggestion.kind.rephrase": NoMessageParams;
|
|
1474
|
+
"pen.ai.suggestion.kind.other": NoMessageParams;
|
|
1475
|
+
"pen.ai.review.section.content": NoMessageParams;
|
|
1476
|
+
"pen.ai.review.section.block": NoMessageParams;
|
|
1477
|
+
"pen.ai.review.section.row": NoMessageParams;
|
|
1478
|
+
"pen.ai.review.section.cell": NoMessageParams;
|
|
1479
|
+
"pen.ai.review.section.schema": NoMessageParams;
|
|
1480
|
+
"pen.ai.review.section.view": NoMessageParams;
|
|
1481
|
+
"pen.ai.review.kind.added": NoMessageParams;
|
|
1482
|
+
"pen.ai.review.kind.removed": NoMessageParams;
|
|
1483
|
+
"pen.ai.review.kind.updated": NoMessageParams;
|
|
1484
|
+
"pen.ai.review.kind.moved": NoMessageParams;
|
|
1485
|
+
"pen.ai.review.subgroup.content.added": NoMessageParams;
|
|
1486
|
+
"pen.ai.review.subgroup.content.removed": NoMessageParams;
|
|
1487
|
+
"pen.ai.review.subgroup.content.updated": NoMessageParams;
|
|
1488
|
+
"pen.ai.review.subgroup.content.moved": NoMessageParams;
|
|
1489
|
+
"pen.ai.review.subgroup.block.added": NoMessageParams;
|
|
1490
|
+
"pen.ai.review.subgroup.block.removed": NoMessageParams;
|
|
1491
|
+
"pen.ai.review.subgroup.block.updated": NoMessageParams;
|
|
1492
|
+
"pen.ai.review.subgroup.block.moved": NoMessageParams;
|
|
1493
|
+
"pen.ai.review.subgroup.row.added": NoMessageParams;
|
|
1494
|
+
"pen.ai.review.subgroup.row.removed": NoMessageParams;
|
|
1495
|
+
"pen.ai.review.subgroup.row.updated": NoMessageParams;
|
|
1496
|
+
"pen.ai.review.subgroup.row.moved": NoMessageParams;
|
|
1497
|
+
"pen.ai.review.subgroup.cell.added": NoMessageParams;
|
|
1498
|
+
"pen.ai.review.subgroup.cell.removed": NoMessageParams;
|
|
1499
|
+
"pen.ai.review.subgroup.cell.updated": NoMessageParams;
|
|
1500
|
+
"pen.ai.review.subgroup.cell.moved": NoMessageParams;
|
|
1501
|
+
"pen.ai.review.subgroup.schema.added": NoMessageParams;
|
|
1502
|
+
"pen.ai.review.subgroup.schema.removed": NoMessageParams;
|
|
1503
|
+
"pen.ai.review.subgroup.schema.updated": NoMessageParams;
|
|
1504
|
+
"pen.ai.review.subgroup.schema.moved": NoMessageParams;
|
|
1505
|
+
"pen.ai.review.subgroup.view.added": NoMessageParams;
|
|
1506
|
+
"pen.ai.review.subgroup.view.removed": NoMessageParams;
|
|
1507
|
+
"pen.ai.review.subgroup.view.updated": NoMessageParams;
|
|
1508
|
+
"pen.ai.review.subgroup.view.moved": NoMessageParams;
|
|
1509
|
+
"pen.ai.review.action.insert": NoMessageParams;
|
|
1510
|
+
"pen.ai.review.action.delete": NoMessageParams;
|
|
1511
|
+
"pen.ai.review.action.move": NoMessageParams;
|
|
1512
|
+
"pen.ai.review.action.convert": NoMessageParams;
|
|
1513
|
+
"pen.ai.review.action.change": NoMessageParams;
|
|
1514
|
+
"pen.ai.review.blockSuggestion.insert": {
|
|
1515
|
+
blockType: string;
|
|
1516
|
+
};
|
|
1517
|
+
"pen.ai.review.blockSuggestion.delete": {
|
|
1518
|
+
blockType: string;
|
|
1519
|
+
};
|
|
1520
|
+
"pen.ai.review.blockSuggestion.move": {
|
|
1521
|
+
blockType: string;
|
|
1522
|
+
};
|
|
1523
|
+
"pen.ai.review.blockSuggestion.convert": {
|
|
1524
|
+
blockType: string;
|
|
1525
|
+
};
|
|
1526
|
+
"pen.ai.review.blockType.fallback": NoMessageParams;
|
|
1527
|
+
"pen.ai.review.acceptGroup": NoMessageParams;
|
|
1528
|
+
"pen.ai.review.rejectGroup": NoMessageParams;
|
|
1529
|
+
"pen.ai.review.acceptSubgroup": NoMessageParams;
|
|
1530
|
+
"pen.ai.review.rejectSubgroup": NoMessageParams;
|
|
1531
|
+
"pen.ai.review.expand": NoMessageParams;
|
|
1532
|
+
"pen.ai.review.collapse": NoMessageParams;
|
|
1533
|
+
"pen.ai.review.structuralSuggestion": NoMessageParams;
|
|
1534
|
+
"pen.ai.review.noPendingChanges": NoMessageParams;
|
|
1535
|
+
"pen.ai.session.close": NoMessageParams;
|
|
1536
|
+
};
|
|
1537
|
+
type MessageKey = keyof MessageParamsByKey;
|
|
1538
|
+
type MessageParams<K extends MessageKey> = MessageParamsByKey[K];
|
|
1539
|
+
type MessageCatalog = {
|
|
1540
|
+
[K in MessageKey]: MessageValue;
|
|
1541
|
+
};
|
|
1542
|
+
type MessageArgs<K extends MessageKey> = [
|
|
1543
|
+
keyof MessageParamsByKey[K]
|
|
1544
|
+
] extends [never] ? [params?: MessageParamsByKey[K]] : [params: MessageParamsByKey[K]];
|
|
1545
|
+
declare const DEFAULT_MESSAGE_CATALOG: MessageCatalog;
|
|
1546
|
+
declare function isMessageKey(value: string): value is MessageKey;
|
|
1547
|
+
declare function isPluralMessage(value: unknown): value is PluralMessage;
|
|
1548
|
+
|
|
1549
|
+
type EditorViewMode = DocumentProfile;
|
|
1550
|
+
/** Named commit-pipeline phases (`06-commit-pipeline.md`). */
|
|
1551
|
+
type PipelinePhase = "hooks" | "validate" | "execute" | "normalize" | "summarize" | "map-selection" | "settle-facets" | "emit";
|
|
1552
|
+
type InteractionModel = "content-first" | "block-first";
|
|
1553
|
+
/**
|
|
1554
|
+
* Which rung `Mod-a` enters the T1 select-all ladder on
|
|
1555
|
+
* (`spec/rules/selection.md` T1).
|
|
1556
|
+
*
|
|
1557
|
+
* `"block-first"` starts at the active block and escalates on each press.
|
|
1558
|
+
* `"document-first"` enters at the top rung, so one press covers all content.
|
|
1559
|
+
*/
|
|
1560
|
+
type SelectAllBehavior = "document-first" | "block-first";
|
|
1561
|
+
interface DocumentState {
|
|
1562
|
+
readonly documentProfile: DocumentProfile;
|
|
1563
|
+
readonly blockOrder: readonly string[];
|
|
1564
|
+
readonly blockCount: number;
|
|
1565
|
+
readonly blocks: Iterable<BlockHandle>;
|
|
1566
|
+
readonly isEmpty: boolean;
|
|
1567
|
+
readonly generation: number;
|
|
1568
|
+
allBlocks(): Iterable<BlockHandle>;
|
|
1569
|
+
blockAt(index: number): string | null;
|
|
1570
|
+
indexOf(blockId: string): number;
|
|
1571
|
+
parentOf(blockId: string): string | null;
|
|
1572
|
+
}
|
|
1573
|
+
interface UndoManager {
|
|
1574
|
+
undo(): boolean;
|
|
1575
|
+
redo(): boolean;
|
|
1576
|
+
canUndo(): boolean;
|
|
1577
|
+
canRedo(): boolean;
|
|
1578
|
+
stopCapturing(): void;
|
|
1579
|
+
syncExplicitUndoGroup(groupId: string | null): void;
|
|
1580
|
+
setGroupTimeout(ms: number): void;
|
|
1581
|
+
registerTrackedOrigins(origins: OpOrigin[]): Unsubscribe;
|
|
1582
|
+
onStackChange(callback: () => void): Unsubscribe;
|
|
1583
|
+
}
|
|
1584
|
+
interface UndoHistoryMetadataEntry<T = unknown> {
|
|
1585
|
+
before: T | null;
|
|
1586
|
+
after: T | null;
|
|
1587
|
+
}
|
|
1588
|
+
interface UndoHistoryMetadataRestoreContext {
|
|
1589
|
+
editor: Editor;
|
|
1590
|
+
direction: "undo" | "redo";
|
|
1591
|
+
requestId: number;
|
|
1592
|
+
}
|
|
1593
|
+
interface UndoHistoryMetadataController {
|
|
1594
|
+
getCurrentEntryMetadata<T>(key: string): UndoHistoryMetadataEntry<T> | null;
|
|
1595
|
+
setCurrentEntryMetadata<T>(key: string, value: UndoHistoryMetadataEntry<T>): boolean;
|
|
1596
|
+
registerMetadataRestorer<T>(key: string, restore: (value: T | null, context: UndoHistoryMetadataRestoreContext) => void): Unsubscribe;
|
|
1597
|
+
}
|
|
1598
|
+
interface UndoHistoryRestore {
|
|
1599
|
+
focusBlockId: string | null;
|
|
1600
|
+
requestId: number;
|
|
1601
|
+
}
|
|
1602
|
+
interface HistoryAppliedEvent {
|
|
1603
|
+
kind: "undo" | "redo";
|
|
1604
|
+
selection: SelectionState;
|
|
1605
|
+
focusBlockId: string | null;
|
|
1606
|
+
requestId: number;
|
|
1607
|
+
}
|
|
1608
|
+
type CommitEventSource = "apply" | "remote" | "undo" | "redo" | "stream";
|
|
1609
|
+
/** Dropped ops and validation failures for one commit (`06-commit-pipeline.md`). */
|
|
1610
|
+
type Diagnostic = DiagnosticEvent;
|
|
1611
|
+
|
|
1612
|
+
interface CommitEvent {
|
|
1613
|
+
readonly commitId: number;
|
|
1614
|
+
readonly origin: StructuredOpOrigin;
|
|
1615
|
+
readonly summary: ChangeSummary;
|
|
1616
|
+
readonly selectionBefore: SelectionRecord;
|
|
1617
|
+
readonly selectionAfter: SelectionRecord;
|
|
1618
|
+
readonly source: CommitEventSource;
|
|
1619
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
1620
|
+
}
|
|
1621
|
+
interface SchemaEngine {
|
|
1622
|
+
markDirty(blockId: string): void;
|
|
1623
|
+
normalizeDirty(): void;
|
|
1624
|
+
normalizeAll(): void;
|
|
1625
|
+
deferBlock(blockId: string): void;
|
|
1626
|
+
undeferBlock(blockId: string): void;
|
|
1627
|
+
}
|
|
1628
|
+
interface DiagnosticEvent {
|
|
1629
|
+
code: string;
|
|
1630
|
+
level: "warn" | "error" | "info";
|
|
1631
|
+
source: string;
|
|
1632
|
+
message: string;
|
|
1633
|
+
remediation?: string;
|
|
1634
|
+
op?: DocumentOp;
|
|
1635
|
+
extension?: string;
|
|
1636
|
+
error?: unknown;
|
|
1637
|
+
[key: string]: unknown;
|
|
1638
|
+
}
|
|
1639
|
+
interface DocumentValidationError {
|
|
1640
|
+
code: "MISSING_SHARED_TYPE" | "INVALID_BLOCK_STRUCTURE" | "ORPHAN_BLOCK" | "DUPLICATE_BLOCK_ORDER" | "UNKNOWN_CONTENT_TYPE" | "MISSING_BLOCK_MAP_KEY" | "INVALID_SUBDOCUMENT";
|
|
1641
|
+
blockId?: string;
|
|
1642
|
+
message: string;
|
|
1643
|
+
severity: "error" | "warning";
|
|
1644
|
+
}
|
|
1645
|
+
interface PenEventMap {
|
|
1646
|
+
commit: (event: CommitEvent) => void;
|
|
1647
|
+
historyApplied: (event: HistoryAppliedEvent) => void;
|
|
1648
|
+
decorationsChange: (generation: number) => void;
|
|
1649
|
+
selectionChange: (record: SelectionRecord) => void;
|
|
1650
|
+
diagnostic: (event: DiagnosticEvent) => void;
|
|
1651
|
+
"crdt:corruption": (errors: DocumentValidationError[]) => void;
|
|
1652
|
+
"crdt:recovered": (method: "snapshot" | "repair") => void;
|
|
1653
|
+
}
|
|
1654
|
+
declare const HOOK_PRIORITY_AUTH = 100;
|
|
1655
|
+
declare const HOOK_PRIORITY_SUGGEST = 200;
|
|
1656
|
+
declare const HOOK_PRIORITY_INPUT_RULE = 300;
|
|
1657
|
+
declare const HOOK_PRIORITY_DEFAULT = 500;
|
|
1658
|
+
interface EditorPresetContext {
|
|
1659
|
+
schema: SchemaRegistry;
|
|
1660
|
+
documentProfile: DocumentProfile;
|
|
1661
|
+
}
|
|
1662
|
+
interface EditorPresetResult {
|
|
1663
|
+
extensions?: Extension[];
|
|
1664
|
+
schema?: SchemaRegistry;
|
|
1665
|
+
}
|
|
1666
|
+
interface EditorPreset {
|
|
1667
|
+
resolve(context: EditorPresetContext): EditorPresetResult;
|
|
1668
|
+
}
|
|
1669
|
+
interface CreateEditorOptions {
|
|
1670
|
+
schema?: SchemaRegistry;
|
|
1671
|
+
preset?: EditorPreset;
|
|
1672
|
+
extensions?: Extension[];
|
|
1673
|
+
crdt?: CRDTAdapter;
|
|
1674
|
+
assets?: AssetProvider;
|
|
1675
|
+
document?: CRDTDocument;
|
|
1676
|
+
documentSession?: DocumentSession;
|
|
1677
|
+
documentScopeId?: string;
|
|
1678
|
+
documentProfile?: DocumentProfile;
|
|
1679
|
+
editorViewMode?: EditorViewMode;
|
|
1680
|
+
locale?: string;
|
|
1681
|
+
messages?: Partial<MessageCatalog>;
|
|
1682
|
+
a11yLabel?: A11yLabel;
|
|
1683
|
+
}
|
|
1684
|
+
interface CommandContext {
|
|
1685
|
+
editor: Editor;
|
|
1686
|
+
selection: SelectionState;
|
|
1687
|
+
activeBlock: BlockHandle | null;
|
|
1688
|
+
}
|
|
1689
|
+
interface InlineCompletionSuggestion {
|
|
1690
|
+
id: string;
|
|
1691
|
+
blockId: string;
|
|
1692
|
+
offset: number;
|
|
1693
|
+
text: string;
|
|
1694
|
+
type: "inline" | "block";
|
|
1695
|
+
blockType?: string;
|
|
1696
|
+
props?: Record<string, unknown>;
|
|
1697
|
+
previewBlocks?: readonly InlineCompletionPreviewBlock[];
|
|
1698
|
+
accept?: (editor: Editor, suggestion: InlineCompletionSuggestion) => boolean;
|
|
1699
|
+
}
|
|
1700
|
+
interface InlineCompletionPreviewBlock {
|
|
1701
|
+
id: string;
|
|
1702
|
+
text: string;
|
|
1703
|
+
blockType?: string;
|
|
1704
|
+
props?: Record<string, unknown>;
|
|
1705
|
+
}
|
|
1706
|
+
interface InlineCompletionState {
|
|
1707
|
+
visibleSuggestion: InlineCompletionSuggestion | null;
|
|
1708
|
+
}
|
|
1709
|
+
interface InlineCompletionController {
|
|
1710
|
+
getState(): InlineCompletionState;
|
|
1711
|
+
subscribe(listener: () => void): () => void;
|
|
1712
|
+
showSuggestion(suggestion: InlineCompletionSuggestion): void;
|
|
1713
|
+
dismissSuggestion(): void;
|
|
1714
|
+
acceptSuggestion(): boolean;
|
|
1715
|
+
hasVisibleSuggestion(): boolean;
|
|
1716
|
+
buildDecorations(): readonly Decoration[];
|
|
1717
|
+
destroy(): void;
|
|
1718
|
+
}
|
|
1719
|
+
interface TextStreamWriter {
|
|
1720
|
+
append(text: string, marks?: Record<string, unknown>): void;
|
|
1721
|
+
splice(from: number, to: number, text: string): void;
|
|
1722
|
+
readonly position: Point;
|
|
1723
|
+
flush(): void;
|
|
1724
|
+
close(): void;
|
|
1725
|
+
abort(): void;
|
|
1726
|
+
}
|
|
1727
|
+
interface OpenTextStreamOptions {
|
|
1728
|
+
origin: OpOrigin;
|
|
1729
|
+
flushIntervalMs?: number;
|
|
1730
|
+
deferNormalization?: boolean;
|
|
1731
|
+
}
|
|
1732
|
+
interface Editor {
|
|
1733
|
+
apply(ops: DocumentOp[], options?: ApplyOptions): void;
|
|
1734
|
+
openTextStream(target: {
|
|
1735
|
+
blockId: string;
|
|
1736
|
+
}, options: OpenTextStreamOptions): TextStreamWriter;
|
|
1737
|
+
loadDocument(doc: CRDTDocument): void;
|
|
1738
|
+
onBeforeApply(hook: (ops: DocumentOp[], options: ApplyOptions) => DocumentOp[], options?: {
|
|
1739
|
+
priority?: number;
|
|
1740
|
+
}): Unsubscribe;
|
|
1741
|
+
facet<F extends Facet<unknown, unknown>>(facet: F): FacetOutput<F>;
|
|
1742
|
+
whenReady(): Promise<void>;
|
|
1743
|
+
readonly schema: SchemaRegistry;
|
|
1744
|
+
readonly selection: SelectionState;
|
|
1745
|
+
/** CRDT-relative positions that survive commits (AN1–AN14). */
|
|
1746
|
+
readonly anchors: EditorAnchors;
|
|
1747
|
+
readonly documentState: DocumentState;
|
|
1748
|
+
readonly internals: EditorInternals;
|
|
1749
|
+
readonly lastChangeSummary: ChangeSummary | null;
|
|
1750
|
+
readonly clientId: number;
|
|
1751
|
+
readonly documentScope: DocumentScope;
|
|
1752
|
+
readonly documentProfile: DocumentProfile;
|
|
1753
|
+
readonly editorViewMode: EditorViewMode;
|
|
1754
|
+
blocks(type?: string): Iterable<BlockHandle>;
|
|
1755
|
+
getBlock(blockId: string): BlockHandle | null;
|
|
1756
|
+
firstBlock(): BlockHandle | null;
|
|
1757
|
+
lastBlock(): BlockHandle | null;
|
|
1758
|
+
blockCount(): number;
|
|
1759
|
+
getBlockRevision(blockId: string): number;
|
|
1760
|
+
setSelection(selection: SelectionState, options?: {
|
|
1761
|
+
origin?: SelectionOrigin;
|
|
1762
|
+
}): void;
|
|
1763
|
+
getSelection(): SelectionState;
|
|
1764
|
+
selectBlock(blockId: string): void;
|
|
1765
|
+
selectBlocks(blockIds: string[]): void;
|
|
1766
|
+
selectCell(blockId: string, row: number, col: number): void;
|
|
1767
|
+
selectCellRange(blockId: string, anchor: {
|
|
1768
|
+
row: number;
|
|
1769
|
+
col: number;
|
|
1770
|
+
}, head: {
|
|
1771
|
+
row: number;
|
|
1772
|
+
col: number;
|
|
1773
|
+
}): void;
|
|
1774
|
+
selectText(blockId: string, from: number, to: number): void;
|
|
1775
|
+
selectTextRange(anchor: {
|
|
1776
|
+
blockId: string;
|
|
1777
|
+
offset: number;
|
|
1778
|
+
}, focus: {
|
|
1779
|
+
blockId: string;
|
|
1780
|
+
offset: number;
|
|
1781
|
+
}): void;
|
|
1782
|
+
selectAll(behavior?: SelectAllBehavior): void;
|
|
1783
|
+
getSelectedText(): string;
|
|
1784
|
+
getSelectedBlocks(): BlockHandle[];
|
|
1785
|
+
replaceSelection(content: string | Block[]): void;
|
|
1786
|
+
deleteSelection(options?: ApplyOptions): void;
|
|
1787
|
+
requestDecorationUpdate(): void;
|
|
1788
|
+
getDecorations(): DecorationSet;
|
|
1789
|
+
scrollToBlock?(blockId: string): void;
|
|
1790
|
+
onSelectionChange(callback: PenEventMap["selectionChange"]): Unsubscribe;
|
|
1791
|
+
onHistoryApplied(callback: PenEventMap["historyApplied"]): Unsubscribe;
|
|
1792
|
+
on<K extends keyof PenEventMap>(event: K, handler: PenEventMap[K]): Unsubscribe;
|
|
1793
|
+
on(event: `ext:${string}:${string}`, handler: (...args: unknown[]) => void): Unsubscribe;
|
|
1794
|
+
readonly undoManager: UndoManager;
|
|
1795
|
+
getExtensionState<T>(name: string): T | undefined;
|
|
1796
|
+
normalizeAll(): void;
|
|
1797
|
+
/**
|
|
1798
|
+
* Deactivates extensions and tears down observation. Does not destroy an
|
|
1799
|
+
* attached field editor — hosts own that call. The returned promise
|
|
1800
|
+
* settles when queued teardown finishes; callers that ignore it stay
|
|
1801
|
+
* correct.
|
|
1802
|
+
*/
|
|
1803
|
+
destroy(): Promise<void>;
|
|
1804
|
+
}
|
|
1805
|
+
interface EditorInternals {
|
|
1806
|
+
readonly adapter: CRDTAdapter;
|
|
1807
|
+
readonly crdtDoc: CRDTDocument;
|
|
1808
|
+
readonly doc: PenDocument;
|
|
1809
|
+
readonly engine: SchemaEngine;
|
|
1810
|
+
readonly awareness: Awareness | null;
|
|
1811
|
+
readonly documentSession: DocumentSession | null;
|
|
1812
|
+
readonly documentScope: DocumentScope;
|
|
1813
|
+
readonly viewId: string;
|
|
1814
|
+
emit<K extends keyof PenEventMap>(event: K, ...args: Parameters<PenEventMap[K]>): void;
|
|
1815
|
+
hasListeners<K extends keyof PenEventMap>(event: K): boolean;
|
|
1816
|
+
onApplyBoundary(hook: (event: {
|
|
1817
|
+
phase: "before" | "after";
|
|
1818
|
+
ops: readonly DocumentOp[];
|
|
1819
|
+
origin: OpOrigin;
|
|
1820
|
+
applied: boolean;
|
|
1821
|
+
}) => void): Unsubscribe;
|
|
1822
|
+
onPipelinePhase(listener: (phase: PipelinePhase) => void): Unsubscribe;
|
|
1823
|
+
assignSlot: (key: string, value: unknown) => void;
|
|
1824
|
+
getBlockText(blockId: string): unknown;
|
|
1825
|
+
getCellText(blockId: string, row: number, col: number): unknown;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
type ConnectionState = "disconnected" | "connecting" | "connected" | "syncing" | "error";
|
|
1829
|
+
interface MultiplayerSessionContext {
|
|
1830
|
+
editor: Editor;
|
|
1831
|
+
awareness: Awareness;
|
|
1832
|
+
}
|
|
1833
|
+
interface MultiplayerSession {
|
|
1834
|
+
readonly connectionState: ConnectionState;
|
|
1835
|
+
connect(): void;
|
|
1836
|
+
disconnect(): void;
|
|
1837
|
+
destroy(): void;
|
|
1838
|
+
onStateChange(listener: (state: ConnectionState) => void): Unsubscribe;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
interface Command<P = void> {
|
|
1842
|
+
readonly name: string;
|
|
1843
|
+
}
|
|
1844
|
+
type CommandResult = boolean | {
|
|
1845
|
+
ops: DocumentOp[];
|
|
1846
|
+
options?: ApplyOptions;
|
|
1847
|
+
} | {
|
|
1848
|
+
selection: SelectionState;
|
|
1849
|
+
};
|
|
1850
|
+
type CommandHandler<P> = (editor: Editor, param: P) => CommandResult | false;
|
|
1851
|
+
interface CommandHandlerRegistration<P = unknown> {
|
|
1852
|
+
readonly command: Command<P>;
|
|
1853
|
+
readonly handler: CommandHandler<P>;
|
|
1854
|
+
}
|
|
1855
|
+
type DefineCommand = <P = void>(name: string) => Command<P>;
|
|
1856
|
+
interface CommandHandlerProvider extends FacetProvider {
|
|
1857
|
+
readonly command: Command<unknown>;
|
|
1858
|
+
readonly handler: CommandHandler<unknown>;
|
|
1859
|
+
readonly precedence: Precedence;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
interface ToolRegistry {
|
|
1863
|
+
registerTool(def: ToolDefinition): void;
|
|
1864
|
+
unregisterTool(name: string): void;
|
|
1865
|
+
listTools(): readonly ToolDefinition[];
|
|
1866
|
+
getTool(name: string): ToolDefinition | null;
|
|
1867
|
+
}
|
|
1868
|
+
interface ToolRuntime extends ToolRegistry {
|
|
1869
|
+
executeTool(name: string, input: unknown, ctx: ToolContext): Promise<unknown> | AsyncIterable<unknown>;
|
|
1870
|
+
}
|
|
1871
|
+
type ToolExecutionResult = Promise<unknown> | AsyncIterable<unknown>;
|
|
1872
|
+
interface ToolDefinition {
|
|
1873
|
+
name: string;
|
|
1874
|
+
description: string;
|
|
1875
|
+
inputSchema: PropSchema;
|
|
1876
|
+
handler: (input: unknown, ctx: ToolContext) => Promise<unknown> | AsyncIterable<unknown>;
|
|
1877
|
+
/**
|
|
1878
|
+
* Tool authority (AIB3). A tool that writes to the document declares
|
|
1879
|
+
* `mutating: true` and is default-denied unless the grant allowlists it;
|
|
1880
|
+
* `destructive: true` additionally marks irreversible effects.
|
|
1881
|
+
*
|
|
1882
|
+
* Left undefined, authority falls back to name-based classification, which
|
|
1883
|
+
* is a heuristic — declare these on any tool whose name is not obviously
|
|
1884
|
+
* read-only.
|
|
1885
|
+
*/
|
|
1886
|
+
mutating?: boolean;
|
|
1887
|
+
destructive?: boolean;
|
|
1888
|
+
}
|
|
1889
|
+
type ModelToolChoice = {
|
|
1890
|
+
type: "auto";
|
|
1891
|
+
} | {
|
|
1892
|
+
type: "any";
|
|
1893
|
+
} | {
|
|
1894
|
+
type: "tool";
|
|
1895
|
+
name: string;
|
|
1896
|
+
};
|
|
1897
|
+
interface ModelAdapterCapabilities {
|
|
1898
|
+
partialToolInput?: boolean;
|
|
1899
|
+
forcedToolChoice?: boolean;
|
|
1900
|
+
}
|
|
1901
|
+
interface ModelAdapter {
|
|
1902
|
+
capabilities?: ModelAdapterCapabilities;
|
|
1903
|
+
stream(options: {
|
|
1904
|
+
messages: ModelMessage[];
|
|
1905
|
+
tools: ToolSchema[];
|
|
1906
|
+
signal?: AbortSignal;
|
|
1907
|
+
requestMode?: string;
|
|
1908
|
+
operation?: ModelRequestedOperation;
|
|
1909
|
+
sessionId?: string;
|
|
1910
|
+
turnId?: string;
|
|
1911
|
+
generationId?: string;
|
|
1912
|
+
toolChoice?: ModelToolChoice;
|
|
1913
|
+
}): AsyncIterable<ModelStreamEvent>;
|
|
1914
|
+
}
|
|
1915
|
+
type ModelOperationKind = "rewrite-selection" | "rewrite-block" | "continue-block" | "document-transform";
|
|
1916
|
+
interface ModelOperationSelectionTarget {
|
|
1917
|
+
kind: "selection";
|
|
1918
|
+
blockId: string | null;
|
|
1919
|
+
anchor: {
|
|
1920
|
+
blockId: string;
|
|
1921
|
+
offset: number;
|
|
1922
|
+
};
|
|
1923
|
+
focus: {
|
|
1924
|
+
blockId: string;
|
|
1925
|
+
offset: number;
|
|
1926
|
+
};
|
|
1927
|
+
sourceText: string;
|
|
1928
|
+
}
|
|
1929
|
+
interface ModelOperationScopedRangeTarget {
|
|
1930
|
+
kind: "scoped-range";
|
|
1931
|
+
blockId: string | null;
|
|
1932
|
+
anchor: {
|
|
1933
|
+
blockId: string;
|
|
1934
|
+
offset: number;
|
|
1935
|
+
};
|
|
1936
|
+
focus: {
|
|
1937
|
+
blockId: string;
|
|
1938
|
+
offset: number;
|
|
1939
|
+
};
|
|
1940
|
+
sourceText: string;
|
|
1941
|
+
blockIds: readonly string[];
|
|
1942
|
+
contentFormat: "text" | "markdown";
|
|
1943
|
+
scope: "block" | "paragraph" | "document" | "heading";
|
|
1944
|
+
}
|
|
1945
|
+
type ModelOperationRangeTarget = ModelOperationSelectionTarget | ModelOperationScopedRangeTarget;
|
|
1946
|
+
declare function isScopedSelectionTarget(target: ModelOperationRangeTarget): target is ModelOperationScopedRangeTarget;
|
|
1947
|
+
interface ModelOperationBlockTarget {
|
|
1948
|
+
kind: "block";
|
|
1949
|
+
blockId: string;
|
|
1950
|
+
blockType: string | null;
|
|
1951
|
+
sourceText: string;
|
|
1952
|
+
insertionOffset?: number;
|
|
1953
|
+
}
|
|
1954
|
+
interface ModelOperationDocumentTarget {
|
|
1955
|
+
kind: "document";
|
|
1956
|
+
activeBlockId: string | null;
|
|
1957
|
+
blockIds?: readonly string[];
|
|
1958
|
+
placement?: "append-after-block" | "replace-empty-block" | "replace-blocks";
|
|
1959
|
+
transform?: "write" | "rewrite" | "remove";
|
|
1960
|
+
}
|
|
1961
|
+
interface ModelOperationProvenance {
|
|
1962
|
+
documentVersion?: number | null;
|
|
1963
|
+
blockRevision?: number | null;
|
|
1964
|
+
selectionSignature?: string | null;
|
|
1965
|
+
syncedGeneration?: number | null;
|
|
1966
|
+
}
|
|
1967
|
+
interface ModelRequestedOperation {
|
|
1968
|
+
kind: ModelOperationKind;
|
|
1969
|
+
target: ModelOperationSelectionTarget | ModelOperationScopedRangeTarget | ModelOperationBlockTarget | ModelOperationDocumentTarget;
|
|
1970
|
+
promptIntent?: string;
|
|
1971
|
+
provenance?: ModelOperationProvenance | null;
|
|
1972
|
+
}
|
|
1973
|
+
type ModelStreamEvent = {
|
|
1974
|
+
type: "text-delta";
|
|
1975
|
+
delta: string;
|
|
1976
|
+
} | {
|
|
1977
|
+
type: "replace-preview";
|
|
1978
|
+
operation: ModelRequestedOperation;
|
|
1979
|
+
text: string;
|
|
1980
|
+
} | {
|
|
1981
|
+
type: "replace-final";
|
|
1982
|
+
operation: ModelRequestedOperation;
|
|
1983
|
+
text: string;
|
|
1984
|
+
} | {
|
|
1985
|
+
type: "insert-preview";
|
|
1986
|
+
operation: ModelRequestedOperation;
|
|
1987
|
+
text: string;
|
|
1988
|
+
} | {
|
|
1989
|
+
type: "insert-final";
|
|
1990
|
+
operation: ModelRequestedOperation;
|
|
1991
|
+
text: string;
|
|
1992
|
+
} | {
|
|
1993
|
+
type: "conflict";
|
|
1994
|
+
reason: string;
|
|
1995
|
+
operation?: ModelRequestedOperation;
|
|
1996
|
+
} | {
|
|
1997
|
+
type: "structured-data";
|
|
1998
|
+
contract?: "grid" | "app";
|
|
1999
|
+
data: unknown;
|
|
2000
|
+
final?: boolean;
|
|
2001
|
+
} | {
|
|
2002
|
+
type: "tool-input-start";
|
|
2003
|
+
toolCallId: string;
|
|
2004
|
+
toolName: string;
|
|
2005
|
+
} | {
|
|
2006
|
+
type: "tool-input-delta";
|
|
2007
|
+
toolCallId: string;
|
|
2008
|
+
inputTextDelta: string;
|
|
2009
|
+
} | {
|
|
2010
|
+
type: "tool-call";
|
|
2011
|
+
toolCallId: string;
|
|
2012
|
+
toolName: string;
|
|
2013
|
+
input: unknown;
|
|
2014
|
+
} | {
|
|
2015
|
+
type: "done";
|
|
2016
|
+
usage?: {
|
|
2017
|
+
promptTokens: number;
|
|
2018
|
+
completionTokens: number;
|
|
2019
|
+
};
|
|
2020
|
+
} | {
|
|
2021
|
+
type: "error";
|
|
2022
|
+
error: unknown;
|
|
2023
|
+
};
|
|
2024
|
+
interface ToolSchema {
|
|
2025
|
+
name: string;
|
|
2026
|
+
description: string;
|
|
2027
|
+
inputSchema: PropSchema;
|
|
2028
|
+
}
|
|
2029
|
+
interface ModelMessage {
|
|
2030
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
2031
|
+
content: string | ModelMessagePart[];
|
|
2032
|
+
toolCallId?: string;
|
|
2033
|
+
toolName?: string;
|
|
2034
|
+
}
|
|
2035
|
+
type ModelMessagePart = {
|
|
2036
|
+
type: "text";
|
|
2037
|
+
text: string;
|
|
2038
|
+
} | {
|
|
2039
|
+
type: "tool-call";
|
|
2040
|
+
toolCallId: string;
|
|
2041
|
+
toolName: string;
|
|
2042
|
+
input: unknown;
|
|
2043
|
+
} | {
|
|
2044
|
+
type: "tool-result";
|
|
2045
|
+
toolCallId: string;
|
|
2046
|
+
result: unknown;
|
|
2047
|
+
isError?: boolean;
|
|
2048
|
+
};
|
|
2049
|
+
interface ToolContext {
|
|
2050
|
+
readonly editor: Editor;
|
|
2051
|
+
readonly docId: string;
|
|
2052
|
+
emit(part: PenStreamPart): void;
|
|
2053
|
+
insertBlock(blockType: string, props: Record<string, unknown>, position: Position): string;
|
|
2054
|
+
updateBlock(blockId: string, props: Record<string, unknown>): void;
|
|
2055
|
+
deleteBlock(blockId: string): void;
|
|
2056
|
+
beginStreaming(zoneId: string, blockId: string): void;
|
|
2057
|
+
appendDelta(delta: string): void;
|
|
2058
|
+
endStreaming(status: "complete" | "cancelled" | "error"): void;
|
|
2059
|
+
}
|
|
2060
|
+
declare function isAsyncIterable(value: unknown): value is AsyncIterable<unknown>;
|
|
2061
|
+
|
|
2062
|
+
type PenStreamPart = GenStartPart | GenDeltaPart | GenEndPart | BlockInsertPart | BlockUpdatePart | BlockDeletePart | BlockMovePart | LayoutUpdatePart | AppCreatePart | AppUpdatePart | AppDeletePart | StepStartPart | StepEndPart | ToolInputStartPart | ToolInputDeltaPart | ToolInputAvailablePart | ToolOutputPart | ToolErrorPart | DataPart | ErrorPart | AbortPart | PingPart | DonePart;
|
|
2063
|
+
interface GenStartPart {
|
|
2064
|
+
type: "gen-start";
|
|
2065
|
+
zoneId: string;
|
|
2066
|
+
blockId: string;
|
|
2067
|
+
}
|
|
2068
|
+
interface GenDeltaPart {
|
|
2069
|
+
type: "gen-delta";
|
|
2070
|
+
zoneId: string;
|
|
2071
|
+
delta: string;
|
|
2072
|
+
}
|
|
2073
|
+
interface GenEndPart {
|
|
2074
|
+
type: "gen-end";
|
|
2075
|
+
zoneId: string;
|
|
2076
|
+
status: "complete" | "cancelled" | "error";
|
|
2077
|
+
}
|
|
2078
|
+
interface BlockInsertPart {
|
|
2079
|
+
type: "block-insert";
|
|
2080
|
+
blockId: string;
|
|
2081
|
+
blockType: string;
|
|
2082
|
+
props?: Record<string, unknown>;
|
|
2083
|
+
position: Position;
|
|
2084
|
+
}
|
|
2085
|
+
interface BlockUpdatePart {
|
|
2086
|
+
type: "block-update";
|
|
2087
|
+
blockId: string;
|
|
2088
|
+
props: Record<string, unknown>;
|
|
2089
|
+
}
|
|
2090
|
+
interface BlockDeletePart {
|
|
2091
|
+
type: "block-delete";
|
|
2092
|
+
blockId: string;
|
|
2093
|
+
}
|
|
2094
|
+
interface BlockMovePart {
|
|
2095
|
+
type: "block-move";
|
|
2096
|
+
blockId: string;
|
|
2097
|
+
position: Position;
|
|
2098
|
+
}
|
|
2099
|
+
interface LayoutUpdatePart {
|
|
2100
|
+
type: "layout-update";
|
|
2101
|
+
blockId: string;
|
|
2102
|
+
layout: Partial<LayoutProps>;
|
|
2103
|
+
}
|
|
2104
|
+
interface AppCreatePart {
|
|
2105
|
+
type: "app-create";
|
|
2106
|
+
appId: string;
|
|
2107
|
+
appType: string;
|
|
2108
|
+
config: Record<string, unknown>;
|
|
2109
|
+
placement: AppPlacement;
|
|
2110
|
+
}
|
|
2111
|
+
interface AppUpdatePart {
|
|
2112
|
+
type: "app-update";
|
|
2113
|
+
appId: string;
|
|
2114
|
+
patch: Record<string, unknown>;
|
|
2115
|
+
}
|
|
2116
|
+
interface AppDeletePart {
|
|
2117
|
+
type: "app-delete";
|
|
2118
|
+
appId: string;
|
|
2119
|
+
}
|
|
2120
|
+
interface StepStartPart {
|
|
2121
|
+
type: "step-start";
|
|
2122
|
+
stepIndex: number;
|
|
2123
|
+
label?: string;
|
|
2124
|
+
}
|
|
2125
|
+
interface StepEndPart {
|
|
2126
|
+
type: "step-end";
|
|
2127
|
+
stepIndex: number;
|
|
2128
|
+
}
|
|
2129
|
+
interface ToolInputStartPart {
|
|
2130
|
+
type: "tool-input-start";
|
|
2131
|
+
toolCallId: string;
|
|
2132
|
+
toolName: string;
|
|
2133
|
+
}
|
|
2134
|
+
interface ToolInputDeltaPart {
|
|
2135
|
+
type: "tool-input-delta";
|
|
2136
|
+
toolCallId: string;
|
|
2137
|
+
inputDelta: string;
|
|
2138
|
+
}
|
|
2139
|
+
interface ToolInputAvailablePart {
|
|
2140
|
+
type: "tool-input-available";
|
|
2141
|
+
toolCallId: string;
|
|
2142
|
+
toolName: string;
|
|
2143
|
+
input: unknown;
|
|
2144
|
+
}
|
|
2145
|
+
interface ToolOutputPart {
|
|
2146
|
+
type: "tool-output";
|
|
2147
|
+
toolCallId: string;
|
|
2148
|
+
output: unknown;
|
|
2149
|
+
}
|
|
2150
|
+
interface ToolErrorPart {
|
|
2151
|
+
type: "tool-error";
|
|
2152
|
+
toolCallId: string;
|
|
2153
|
+
error: string;
|
|
2154
|
+
}
|
|
2155
|
+
interface DataPart {
|
|
2156
|
+
type: `data-${string}`;
|
|
2157
|
+
id?: string;
|
|
2158
|
+
data: unknown;
|
|
2159
|
+
transient?: boolean;
|
|
2160
|
+
}
|
|
2161
|
+
interface ErrorPart {
|
|
2162
|
+
type: "error";
|
|
2163
|
+
errorText: string;
|
|
2164
|
+
code?: string;
|
|
2165
|
+
}
|
|
2166
|
+
interface AbortPart {
|
|
2167
|
+
type: "abort";
|
|
2168
|
+
reason: string;
|
|
2169
|
+
}
|
|
2170
|
+
interface PingPart {
|
|
2171
|
+
type: "ping";
|
|
2172
|
+
}
|
|
2173
|
+
interface DonePart {
|
|
2174
|
+
type: "done";
|
|
2175
|
+
}
|
|
2176
|
+
/** Frozen protocol version for stream handshake (AIB5). */
|
|
2177
|
+
declare const PEN_STREAM_PROTOCOL_VERSION = 1;
|
|
2178
|
+
/**
|
|
2179
|
+
* Wire request for `PenTransport.stream`. `context` is the serializable
|
|
2180
|
+
* subset (AIB2). A live `Editor` is not expressible on the wire — pass it
|
|
2181
|
+
* to `directTransport` / `createSSEHandler` at construction.
|
|
2182
|
+
*/
|
|
2183
|
+
interface PenStreamRequest {
|
|
2184
|
+
prompt: string;
|
|
2185
|
+
context?: {
|
|
2186
|
+
docId?: string;
|
|
2187
|
+
selection?: SelectionState;
|
|
2188
|
+
blockId?: string;
|
|
2189
|
+
};
|
|
2190
|
+
tools?: ToolSchema[];
|
|
2191
|
+
toolCalls?: Array<{
|
|
2192
|
+
toolCallId: string;
|
|
2193
|
+
name: string;
|
|
2194
|
+
input: unknown;
|
|
2195
|
+
}>;
|
|
2196
|
+
messages?: ModelMessage[];
|
|
2197
|
+
signal?: AbortSignal;
|
|
2198
|
+
streamId?: string;
|
|
2199
|
+
protocolVersion?: number;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
type FieldEditorBehavior = "inline-richtext" | "inline-plaintext" | "inline-code" | "grid" | "none";
|
|
2203
|
+
type FieldEditorInputMode = "richtext" | "code" | "table" | "none";
|
|
2204
|
+
|
|
2205
|
+
type FieldEditorFocusReason = "user-pointer" | "keyboard" | "programmatic" | "default" | "backend" | "selection-sync";
|
|
2206
|
+
type FieldEditorFocusOptions = {
|
|
2207
|
+
reason?: FieldEditorFocusReason;
|
|
2208
|
+
domFocus?: boolean;
|
|
2209
|
+
passive?: boolean;
|
|
2210
|
+
};
|
|
2211
|
+
interface FieldEditor {
|
|
2212
|
+
readonly focusBlockId: string | null;
|
|
2213
|
+
readonly activeBlockIds: readonly string[];
|
|
2214
|
+
readonly isEditing: boolean;
|
|
2215
|
+
readonly isFocused: boolean;
|
|
2216
|
+
readonly isComposing: boolean;
|
|
2217
|
+
readonly inputMode: FieldEditorInputMode;
|
|
2218
|
+
selection: SelectionState | null;
|
|
2219
|
+
focus(options?: FieldEditorFocusOptions): boolean;
|
|
2220
|
+
blur(): void;
|
|
2221
|
+
activate(blockId: string): void;
|
|
2222
|
+
activateCell?(blockId: string, row: number, col: number): void;
|
|
2223
|
+
activateCellFromElement?(blockId: string, row: number, col: number, element: HTMLElement): void;
|
|
2224
|
+
deactivate(): void;
|
|
2225
|
+
suspendForPointerSelection?(): void;
|
|
2226
|
+
syncTextSelection?(blockId: string, anchorOffset: number, focusOffset: number): void;
|
|
2227
|
+
activateTextSelection?(blockId: string, anchorOffset: number, focusOffset: number, options?: FieldEditorFocusOptions): void;
|
|
2228
|
+
focusTextSelection?(blockId: string, anchorOffset: number, focusOffset: number, options?: FieldEditorFocusOptions): Promise<boolean>;
|
|
2229
|
+
commitProgrammaticTextSelection?(blockId: string, anchorOffset: number, focusOffset: number): void;
|
|
2230
|
+
waitForAttachment?(blockId?: string | null): Promise<boolean>;
|
|
2231
|
+
expandTo(blockId: string): void;
|
|
2232
|
+
contractToFocused(): void;
|
|
2233
|
+
attachElement(el: HTMLElement): void;
|
|
2234
|
+
delegate(blockSchema: BlockSchema): boolean;
|
|
2235
|
+
getPendingMarks?(): Readonly<Record<string, unknown | null>>;
|
|
2236
|
+
togglePendingMark?(markType: string): boolean;
|
|
2237
|
+
clearPendingMarks?(): void;
|
|
2238
|
+
destroy(): void;
|
|
2239
|
+
onActivate?(callback: (blockIds: string[]) => void): Unsubscribe;
|
|
2240
|
+
onDeactivate?(callback: (blockIds: string[]) => void): Unsubscribe;
|
|
2241
|
+
onSelectionChange?(callback: (record: SelectionRecord) => void): Unsubscribe;
|
|
2242
|
+
}
|
|
2243
|
+
interface StreamingTarget {
|
|
2244
|
+
readonly generationZone: GenerationZone | null;
|
|
2245
|
+
beginStreaming(zoneId: string, blockId: string, origin?: OpOrigin): void;
|
|
2246
|
+
appendDelta(delta: string): void;
|
|
2247
|
+
endStreaming(status: "complete" | "cancelled" | "error"): void;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
declare const AI_REQUEST_REFUSED_CODE = "ai-request-refused";
|
|
2251
|
+
declare const AI_EGRESS_INVENTORY_CODE = "ai-egress-inventory";
|
|
2252
|
+
type AIRequestFeature = "generation" | "suggestions" | "autocomplete" | "agentic-step";
|
|
2253
|
+
type AIDocumentExcerptKind = "selection" | "target" | "context" | "tool-result";
|
|
2254
|
+
interface AIDocumentExcerpt {
|
|
2255
|
+
readonly blockId: string;
|
|
2256
|
+
readonly kind: AIDocumentExcerptKind;
|
|
2257
|
+
readonly text: string;
|
|
2258
|
+
}
|
|
2259
|
+
interface AIRequestContext {
|
|
2260
|
+
readonly feature: AIRequestFeature;
|
|
2261
|
+
readonly messages: readonly ModelMessage[];
|
|
2262
|
+
readonly documentExcerpts: readonly AIDocumentExcerpt[];
|
|
2263
|
+
readonly tools: readonly ToolSchema[];
|
|
2264
|
+
}
|
|
2265
|
+
type AIRequestFilter = (context: AIRequestContext) => AIRequestContext | null;
|
|
2266
|
+
|
|
2267
|
+
declare const PEN_DOCUMENT_FORMAT = 3;
|
|
2268
|
+
declare const PEN_FORMAT_METADATA_KEY = "penFormat";
|
|
2269
|
+
declare const DOCUMENT_PROFILE_METADATA_KEY = "documentProfile";
|
|
2270
|
+
declare const MIGRATION_LEDGER_METADATA_KEY = "penMigrations";
|
|
2271
|
+
/**
|
|
2272
|
+
* Metadata keys Pen writes. Hosts may use any other key; Pen never inspects
|
|
2273
|
+
* those and preserves them verbatim (DUR1, DUR4).
|
|
2274
|
+
*/
|
|
2275
|
+
declare const RESERVED_METADATA_KEYS: readonly ["penFormat", "documentProfile", "penMigrations"];
|
|
2276
|
+
type ReservedMetadataKey = (typeof RESERVED_METADATA_KEYS)[number];
|
|
2277
|
+
/**
|
|
2278
|
+
* Store-generation identity written at `metadata.penFormat`.
|
|
2279
|
+
*
|
|
2280
|
+
* `format` and `minReader` are about the Yjs store shape, not about schemas.
|
|
2281
|
+
* v2 does not change that shape, so it writes `minReader: 1` (DUR1).
|
|
2282
|
+
*/
|
|
2283
|
+
interface PenFormatStamp {
|
|
2284
|
+
format: number;
|
|
2285
|
+
minReader: number;
|
|
2286
|
+
writer: string;
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Absent stamps are v1-by-absence, not corrupt. `writer` is `"unknown"` until
|
|
2290
|
+
* a v2 session writes the real stamp.
|
|
2291
|
+
*/
|
|
2292
|
+
declare const IMPLICIT_V1_FORMAT_STAMP: PenFormatStamp;
|
|
2293
|
+
|
|
2294
|
+
declare const INLINE_COMPLETION_VISIBLE_BLOCK_ATTRIBUTE = "data-pen-inline-completion-visible";
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* The review surface's class vocabulary (RS4).
|
|
2298
|
+
*
|
|
2299
|
+
* One module names every class the review surface can put on screen, because
|
|
2300
|
+
* those names are a host contract rather than an implementation detail: the
|
|
2301
|
+
* renderer refuses inline `style` from decoration attributes (SEC2), so a
|
|
2302
|
+
* class is the only hook that survives to the DOM, and a host that wants to
|
|
2303
|
+
* theme review presentation has nothing else to hang a rule on.
|
|
2304
|
+
*
|
|
2305
|
+
* It lives in the contract layer because two packages emit these names —
|
|
2306
|
+
* `@input/pen-ai` from review decorations and `@input/pen-dom` when it
|
|
2307
|
+
* reconciles a `suggestion` mark — and neither depends on the other.
|
|
2308
|
+
*
|
|
2309
|
+
* One class, one job. The exported sheet styles every name here; hosts theme
|
|
2310
|
+
* through `--pen-ai-review-*` custom properties rather than adding a second
|
|
2311
|
+
* insert/delete taxonomy on the same span.
|
|
2312
|
+
*/
|
|
2313
|
+
declare const REVIEW_SURFACE_CLASSES: Readonly<{
|
|
2314
|
+
/** Inserted text in a proposed edit. */
|
|
2315
|
+
readonly suggestionInsert: "pen-suggestion-insert";
|
|
2316
|
+
/** Deleted text in a proposed edit, including in-flight originals. */
|
|
2317
|
+
readonly suggestionDelete: "pen-suggestion-delete";
|
|
2318
|
+
/** Text still arriving, shown before anything is written. */
|
|
2319
|
+
readonly preview: "pen-ai-review-preview";
|
|
2320
|
+
/** Selection context kept visible around an edit under review. */
|
|
2321
|
+
readonly context: "pen-ai-review-context";
|
|
2322
|
+
/** The range an edit under review affects. */
|
|
2323
|
+
readonly affectedRange: "pen-ai-affected-range";
|
|
2324
|
+
/** A block carrying a proposed structural change. */
|
|
2325
|
+
readonly blockSuggestion: "pen-block-suggestion";
|
|
2326
|
+
}>;
|
|
2327
|
+
/**
|
|
2328
|
+
* Per-action block-suggestion classes, enumerated rather than interpolated so
|
|
2329
|
+
* the vocabulary stays a closed set a host can style exhaustively and the
|
|
2330
|
+
* contract layer stays free of runtime (API3).
|
|
2331
|
+
*/
|
|
2332
|
+
declare const REVIEW_SURFACE_BLOCK_SUGGESTION_CLASSES: Readonly<{
|
|
2333
|
+
readonly "insert-block": "pen-block-suggestion-insert-block";
|
|
2334
|
+
readonly "delete-block": "pen-block-suggestion-delete-block";
|
|
2335
|
+
readonly "move-block": "pen-block-suggestion-move-block";
|
|
2336
|
+
readonly "convert-block": "pen-block-suggestion-convert-block";
|
|
2337
|
+
readonly "split-block": "pen-block-suggestion-split-block";
|
|
2338
|
+
readonly "format-text": "pen-block-suggestion-format-text";
|
|
2339
|
+
}>;
|
|
2340
|
+
/**
|
|
2341
|
+
* The custom properties that theme the review surface. Hosts set these; they
|
|
2342
|
+
* do not re-implement the rule blocks the exported sheet already carries.
|
|
2343
|
+
*/
|
|
2344
|
+
declare const REVIEW_SURFACE_CUSTOM_PROPERTIES: Readonly<{
|
|
2345
|
+
readonly insertColor: "--pen-ai-review-insert-color";
|
|
2346
|
+
readonly insertBackground: "--pen-ai-review-insert-background";
|
|
2347
|
+
readonly deleteColor: "--pen-ai-review-delete-color";
|
|
2348
|
+
readonly contextBackground: "--pen-ai-review-context-background";
|
|
2349
|
+
readonly contextBoxShadow: "--pen-ai-review-context-box-shadow";
|
|
2350
|
+
readonly borderRadius: "--pen-ai-review-border-radius";
|
|
2351
|
+
readonly inlinePaddingBlock: "--pen-ai-review-inline-padding-block";
|
|
2352
|
+
readonly inlineMarginBlock: "--pen-ai-review-inline-margin-block";
|
|
2353
|
+
}>;
|
|
2354
|
+
|
|
2355
|
+
interface PenTransport {
|
|
2356
|
+
stream(request: PenStreamRequest): AsyncIterable<PenStreamPart>;
|
|
2357
|
+
reconnect?(streamId: string): AsyncIterable<PenStreamPart>;
|
|
2358
|
+
connect(): Promise<void>;
|
|
2359
|
+
disconnect(): Promise<void>;
|
|
2360
|
+
readonly connected: boolean;
|
|
2361
|
+
onConnectionChange(callback: (connected: boolean) => void): Unsubscribe;
|
|
2362
|
+
}
|
|
2363
|
+
interface ServerConfig {
|
|
2364
|
+
port?: number;
|
|
2365
|
+
host?: string;
|
|
2366
|
+
transport?: "stdio" | "sse" | "ws";
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
declare const PEN_CLIPBOARD_PAYLOAD_VERSION = 1;
|
|
2370
|
+
/** Spec JSON flavor written on copy (SEC4 / IOP1). */
|
|
2371
|
+
declare const PEN_CLIPBOARD_JSON_MIME = "application/x-pen-blocks+json";
|
|
2372
|
+
/** Pre-SEC4 flavor. Readers still accept it. */
|
|
2373
|
+
declare const PEN_CLIPBOARD_JSON_MIME_LEGACY = "application/x-pen-blocks";
|
|
2374
|
+
interface PenClipboardDelta {
|
|
2375
|
+
insert: string | {
|
|
2376
|
+
type: string;
|
|
2377
|
+
props?: Record<string, unknown>;
|
|
2378
|
+
};
|
|
2379
|
+
attributes?: Record<string, unknown>;
|
|
2380
|
+
}
|
|
2381
|
+
interface PenClipboardBlock {
|
|
2382
|
+
type: string;
|
|
2383
|
+
props?: Record<string, unknown>;
|
|
2384
|
+
content?: string;
|
|
2385
|
+
deltas?: readonly PenClipboardDelta[];
|
|
2386
|
+
children?: readonly PenClipboardBlock[];
|
|
2387
|
+
/** Partial inline copy: paste inserts into the current block, not as a new block. */
|
|
2388
|
+
isPartial?: boolean;
|
|
2389
|
+
}
|
|
2390
|
+
interface PenClipboardPayload {
|
|
2391
|
+
version: number;
|
|
2392
|
+
blockTypes: readonly string[];
|
|
2393
|
+
blocks: readonly PenClipboardBlock[];
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
interface BlockRenderContext {
|
|
2397
|
+
editable: boolean;
|
|
2398
|
+
selected: boolean;
|
|
2399
|
+
decorations: readonly Decoration[];
|
|
2400
|
+
ref: unknown;
|
|
2401
|
+
}
|
|
2402
|
+
type BlockRenderer<Props = Record<string, unknown>> = (block: BlockHandle, ctx: BlockRenderContext) => unknown;
|
|
2403
|
+
|
|
2404
|
+
interface BlockSuggestion {
|
|
2405
|
+
id: string;
|
|
2406
|
+
action: "insert-block" | "delete-block" | "move-block" | "convert-block";
|
|
2407
|
+
author: string;
|
|
2408
|
+
authorType: "user" | "ai";
|
|
2409
|
+
createdAt: number;
|
|
2410
|
+
model?: string;
|
|
2411
|
+
sessionId?: string;
|
|
2412
|
+
requestId?: string;
|
|
2413
|
+
turnId?: string;
|
|
2414
|
+
generationId?: string;
|
|
2415
|
+
previousState?: {
|
|
2416
|
+
type?: string;
|
|
2417
|
+
position?: Position;
|
|
2418
|
+
props?: Record<string, unknown>;
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
/**
|
|
2423
|
+
* The only ID source in Pen (HOST4, `spec/rules/host.md`). Returns a v4 UUID.
|
|
2424
|
+
*
|
|
2425
|
+
* `crypto.randomUUID` is secure-context-only, so it is absent on plain-HTTP origins — which
|
|
2426
|
+
* is how a phone on the LAN reaches a dev server — and on Safari below 15.4. Calling it
|
|
2427
|
+
* directly therefore throws in environments Pen supports, which is why no other module may
|
|
2428
|
+
* (enforced by the `pen/no-bare-random-uuid` lint rule).
|
|
2429
|
+
*
|
|
2430
|
+
* `crypto.getRandomValues` has no such restriction and gives the same entropy, so the
|
|
2431
|
+
* insecure-context path is a real UUID, not a degraded one. The final branch runs only where
|
|
2432
|
+
* Web Crypto is absent entirely: same shape, weaker randomness, no throw. Pen IDs identify
|
|
2433
|
+
* blocks and requests; they are not secrets and are not used for authorization.
|
|
2434
|
+
*/
|
|
2435
|
+
declare function generateId(): string;
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* Extension-slot keys shared across core, renderers, and extensions.
|
|
2439
|
+
*
|
|
2440
|
+
* These are the contract `editor.internals.assignSlot` speaks. They are
|
|
2441
|
+
* not host-app API — a host using `createEditor` never names them — but
|
|
2442
|
+
* they are the extension author write surface, and several packages
|
|
2443
|
+
* re-export the key they own (`SEARCH_CONTROLLER_SLOT`,
|
|
2444
|
+
* `MULTIPLAYER_CONTROLLER_SLOT`, `SNAPSHOTS_CONTROLLER_SLOT`,
|
|
2445
|
+
* `AUTOCOMPLETE_CONTROLLER_SLOT`).
|
|
2446
|
+
*
|
|
2447
|
+
* Marking them with the internal JSDoc tag would remove them from the
|
|
2448
|
+
* published `.d.ts` (`stripInternal`) while every in-repo consumer
|
|
2449
|
+
* still imports them from the root barrel. `package.json` exports only
|
|
2450
|
+
* `.` (no internal subpath), so hiding them in this package alone
|
|
2451
|
+
* breaks typecheck. Keep them public until this package gains an
|
|
2452
|
+
* internal entry or the consumers write facets directly.
|
|
2453
|
+
*/
|
|
2454
|
+
declare const FIELD_EDITOR_SLOT_KEY = "field-editor";
|
|
2455
|
+
declare const COLLECT_KEY_BINDINGS_SLOT_KEY = "core:collect-key-bindings";
|
|
2456
|
+
declare const AWAIT_EXTENSION_LIFECYCLE_SLOT_KEY = "core:await-extension-lifecycle";
|
|
2457
|
+
declare const INPUT_RULES_ENGINE_SLOT_KEY = "input-rules:engine";
|
|
2458
|
+
declare const UNDO_HISTORY_RESTORE_SLOT_KEY = "undo:history-restore";
|
|
2459
|
+
declare const UNDO_HISTORY_METADATA_CONTROLLER_SLOT_KEY = "undo:history-metadata-controller";
|
|
2460
|
+
declare const INLINE_COMPLETION_SLOT = "ai:inline-completion";
|
|
2461
|
+
declare const AI_CONTROLLER_SLOT = "ai:controller";
|
|
2462
|
+
declare const AI_INLINE_HISTORY_SLOT = "ai:inline-history";
|
|
2463
|
+
declare const AI_REVIEW_CONTROLLER_SLOT = "ai:review";
|
|
2464
|
+
declare const AI_AUTOCOMPLETE_CONTROLLER_SLOT = "ai-autocomplete:controller";
|
|
2465
|
+
declare const AI_SUGGESTIONS_CONTROLLER_SLOT = "ai-suggestions:controller";
|
|
2466
|
+
declare const SEARCH_CONTROLLER_SLOT = "search:controller";
|
|
2467
|
+
declare const MULTIPLAYER_CONTROLLER_SLOT = "multiplayer:controller";
|
|
2468
|
+
declare const SNAPSHOTS_CONTROLLER_SLOT = "snapshots:controller";
|
|
2469
|
+
declare const ANNOUNCER_SLOT_KEY = "pen.announcer";
|
|
2470
|
+
/**
|
|
2471
|
+
* Tag placed on Yjs transaction origins by the undo manager. The rendering
|
|
2472
|
+
* layer checks this instead of relying on `constructor.name` (which breaks
|
|
2473
|
+
* under minification).
|
|
2474
|
+
*/
|
|
2475
|
+
declare const HISTORY_ORIGIN_TAG = "__pen_history__";
|
|
2476
|
+
|
|
2477
|
+
export { type A11yLabel, type A11yMessageCatalog, type A11yMessageKey, type AIDocumentExcerpt, type AIDocumentExcerptKind, type AIRequestContext, type AIRequestFeature, type AIRequestFilter, AI_AUTOCOMPLETE_CONTROLLER_SLOT, AI_CONTROLLER_SLOT, AI_EGRESS_INVENTORY_CODE, AI_INLINE_HISTORY_SLOT, AI_REQUEST_REFUSED_CODE, AI_REVIEW_CONTROLLER_SLOT, AI_SUGGESTIONS_CONTROLLER_SLOT, ANNOUNCER_SLOT_KEY, AWAIT_EXTENSION_LIFECYCLE_SLOT_KEY, type AbortPart, type Affinity, type Anchor, type AnchorPosition, type AnchorRange, type AnchorTarget, type App, type AppChange, type AppCreatePart, type AppDecoration, type AppDeletePart, type AppHandle, type AppOp, type AppPlacement, type AppSchema, type AppSelection, type AppUpdatePart, type ApplyOptions, type AssetProvider, type AssetRef, type AssetUploadOptions, type Assoc, type AttributionRange, type Awareness, type AwarenessChangeEvent, type Block, type BlockA11ySpec, type BlockAuthoring, type BlockCapabilityKey, type BlockCapabilityMap, type BlockDecoration, type BlockDeletePart, type BlockDisplay, type BlockHandle, type BlockImportMatch, type BlockInsertPart, type BlockMovePart, type BlockRenderContext, type BlockRenderer, type BlockSchema, type BlockSelection, type BlockSelectionRole, type BlockSuggestion, type BlockTextChange, type BlockUpdatePart, type BorderDef, COLLECT_KEY_BINDINGS_SLOT_KEY, type CRDTAdapter, type CRDTArray, type CRDTDocument, type CRDTEvent, type CRDTMap, type CRDTUndoManager, type CRDTUndoStackItem, type CellSelection, type ChangeSummary, type ClientExtensionContext, type ColumnType, type Command, type CommandContext, type CommandHandler, type CommandHandlerProvider, type CommandHandlerRegistration, type CommandResult, type CommitEvent, type CommitEventSource, type ComposableSchema, type ConnectionState, type ContentType, type CreateEditorOptions, type CreateSubdocumentOptions, DECORATION_OMIT_FROM_RENDER_ATTRIBUTE, DEFAULT_MESSAGE_CATALOG, DOCUMENT_PROFILE_METADATA_KEY, type DataPart, type DateFormat, type Decoration, type DecorationSet, type DefaultAssoc, type DefineCommand, type DefineFacet, type DeleteBlockOp, type Diagnostic, type DiagnosticEvent, type DocumentOp, type DocumentProfile, type DocumentRange, type DocumentScope, type DocumentScopeInfo, type DocumentScopeKind, type DocumentScopeLookupOptions, type DocumentScopeReplacementEvent, type DocumentSession, type DocumentSessionAttachOptions, type DocumentState, type DocumentValidationError, type DonePart, type Editor, type EditorAnchors, type EditorAnnouncer, type EditorInternals, type EditorPreset, type EditorPresetContext, type EditorPresetResult, type EditorViewMode, type ErrorPart, type ExportOptions, type Exporter, type Extension, type ExtensionStateSpec, FIELD_EDITOR_SLOT_KEY, type Facet, type FacetDependency, type FacetOutput, type FacetProvider, type FacetSpec, type FieldEditor, type FieldEditorBehavior, type FieldEditorFocusOptions, type FieldEditorFocusReason, type FieldEditorInputMode, type FieldEditorType, type FlowBlockCapability, type FormatTextOp, type GenDeltaPart, type GenEndPart, type GenStartPart, type GenerationZone, type GridChange, type GridOp, HISTORY_ORIGIN_TAG, HOOK_PRIORITY_AUTH, HOOK_PRIORITY_DEFAULT, HOOK_PRIORITY_INPUT_RULE, HOOK_PRIORITY_SUGGEST, type HTMLImportElement, type HTMLImportNode, type HTMLImportTextNode, type HistoryAppliedEvent, IMPLICIT_V1_FORMAT_STAMP, INLINE_COMPLETION_SLOT, INLINE_COMPLETION_VISIBLE_BLOCK_ATTRIBUTE, INPUT_RULES_ENGINE_SLOT_KEY, type ImportContentSource, type ImportInlineMark, type ImportOptions, type ImportResult, type Importer, type InlineCompletionController, type InlineCompletionPreviewBlock, type InlineCompletionState, type InlineCompletionSuggestion, type InlineDecoration, type InlineDelta, type InlineInsert, type InlineNodeDeltaInsert, type InlineSchema, type InputRule, type InputRuleContext, type InputRuleHandler, type InsertBlockOp, type InteractionModel, type KeyBinding, type KeyBindingContext, type LayoutProps, type LayoutSchema, type LayoutUpdatePart, type LoadDocumentOptions, MIGRATION_LEDGER_METADATA_KEY, MULTIPLAYER_CONTROLLER_SLOT, MUTATION_GROUP_METADATA_KEY, type MarkdownNode, type MessageArgs, type MessageCatalog, type MessageKey, type MessageParams, type MessageParamsByKey, type MessageValue, type ModelAdapter, type ModelAdapterCapabilities, type ModelMessage, type ModelMessagePart, type ModelOperationBlockTarget, type ModelOperationDocumentTarget, type ModelOperationKind, type ModelOperationProvenance, type ModelOperationRangeTarget, type ModelOperationScopedRangeTarget, type ModelOperationSelectionTarget, type ModelRequestedOperation, type ModelStreamEvent, type ModelToolChoice, type MoveBlockOp, type MultiplayerSession, type MultiplayerSessionContext, type MutationGroupMetadata, type NumberFormat, type OpOrigin, type OpOriginType, type OpenTextStreamOptions, PEN_CLIPBOARD_JSON_MIME, PEN_CLIPBOARD_JSON_MIME_LEGACY, PEN_CLIPBOARD_PAYLOAD_VERSION, PEN_DOCUMENT_FORMAT, PEN_FORMAT_METADATA_KEY, PEN_STREAM_PROTOCOL_VERSION, type PenClipboardBlock, type PenClipboardDelta, type PenClipboardPayload, type PenDocument, type PenEventMap, type PenFormatStamp, type PenPersistence, type PenStreamPart, type PenStreamRequest, type PenTransport, type PingPart, type PipelinePhase, type PluralMessage, type Point, type Position, type Precedence, type PropSchema, RESERVED_METADATA_KEYS, REVIEW_SURFACE_BLOCK_SUGGESTION_CLASSES, REVIEW_SURFACE_CLASSES, REVIEW_SURFACE_CUSTOM_PROPERTIES, type Range, type ReadonlySelectionState, type ReplaceScopeDocumentOptions, type ReservedMetadataKey, type ResolveRelativePositionOptions, type ResolvedAnchorRange, SEARCH_CONTROLLER_SLOT, SNAPSHOTS_CONTROLLER_SLOT, type SchemaEngine, type SchemaRegistry, type SelectAllBehavior, type SelectOption, type SelectionOrigin, type SelectionRecord, type SelectionRecordState, type SelectionState, type ServerConfig, type ServerExtensionContext, type SetMetaOp, type SetPropsOp, type Spacing, type SpliceTextOp, type StepEndPart, type StepStartPart, type StreamOpenOp, type StreamingTarget, type StructuralChange, type StructuralOriginTag, type StructuredOpOrigin, type TableBlockHandle, type TableCellHandle, type TableColumnSchema, type TableRowHandle, type TextSelection, type TextSplice, type TextStreamWriter, type ToolContext, type ToolDefinition, type ToolErrorPart, type ToolExecutionResult, type ToolInputAvailablePart, type ToolInputDeltaPart, type ToolInputStartPart, type ToolOutputPart, type ToolRegistry, type ToolRuntime, type ToolSchema, UNDO_HISTORY_METADATA_CONTROLLER_SLOT_KEY, UNDO_HISTORY_RESTORE_SLOT_KEY, type UndoHistoryMetadataController, type UndoHistoryMetadataEntry, type UndoHistoryMetadataRestoreContext, type UndoHistoryRestore, type UndoManager, type UndoManagerOptions, type Unsubscribe, type VersionEntry, type VersionMetadata, type XMLElement, generateId, isA11yLabelledBy, isAsyncIterable, isMessageKey, isNestedContent, isPluralMessage, isScopedSelectionTarget };
|