@input/pen-core 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.
@@ -0,0 +1,998 @@
1
+ import * as _input_pen_types from '@input/pen-types';
2
+ import { ImportOptions, DocumentOp, DocumentProfile, FlowBlockCapability, InsertBlockOp, SetPropsOp, ImportResult, SchemaRegistry, BlockAuthoring, BlockSelectionRole, Editor, BlockSchema, InlineSchema, AppSchema, ComposableSchema, LayoutSchema, BlockDisplay, PropSchema, ContentType, BlockA11ySpec, Extension, DocumentState, DecorationSet, CreateEditorOptions, SchemaEngine, PenDocument, CRDTDocument, DiagnosticEvent, AppHandle, BlockHandle, CRDTAdapter, DocumentSession, Unsubscribe, Decoration, InlineCompletionController, DocumentRange, TextSelection, EditorAnchors, Anchor, AnchorTarget, Assoc, AnchorRange, ResolvedAnchorRange, SelectionRecord, SelectionState, SelectionOrigin, ChangeSummary, Point, Affinity, ReadonlySelectionState, CommitEvent, KeyBinding, CellSelection, ModelOperationRangeTarget, Block, FacetSpec, Facet, FacetProvider, FacetOutput, ApplyOptions, CommandHandlerRegistration, InputRule, AIRequestFilter, AIRequestContext, ModelAdapter, ModelRequestedOperation, ModelToolChoice, ModelStreamEvent, Command, StructuralOriginTag, SpliceTextOp, CommandHandler, Precedence, OpOrigin, MessageCatalog, A11yLabel, MessageKey, MessageArgs, MutationGroupMetadata, ToolExecutionResult, FieldEditorBehavior, FieldEditorInputMode, A11yMessageKey, TextSplice } from '@input/pen-types';
3
+ export { ImportOptions as ImporterOptions } from '@input/pen-types';
4
+
5
+ type PendingInlineSegment = {
6
+ type: "text";
7
+ text: string;
8
+ attributes?: Record<string, unknown>;
9
+ } | {
10
+ type: "node";
11
+ nodeType: string;
12
+ props?: Record<string, unknown>;
13
+ };
14
+ interface PendingBlock {
15
+ type: string;
16
+ props: Record<string, unknown>;
17
+ content?: string;
18
+ marks?: Array<{
19
+ type: string;
20
+ props?: Record<string, unknown>;
21
+ start: number;
22
+ end: number;
23
+ }>;
24
+ segments?: PendingInlineSegment[];
25
+ children?: PendingBlock[];
26
+ }
27
+ declare function blocksToOps(blocks: PendingBlock[], options?: ImportOptions): DocumentOp[];
28
+
29
+ type BlockSchemaCapabilityLike = {
30
+ authoring?: BlockAuthoring;
31
+ content?: string | unknown[];
32
+ display?: {
33
+ hidden?: boolean;
34
+ };
35
+ fieldEditor?: string;
36
+ } | null | undefined;
37
+ declare function getFlowCapabilityFromSchema(schema: BlockSchemaCapabilityLike): FlowBlockCapability | null;
38
+ declare function getBlockSelectionRoleFromSchema(schema: BlockSchemaCapabilityLike): BlockSelectionRole | null;
39
+ declare function getFlowCapabilityFromType(blockType: string | null | undefined): FlowBlockCapability | null;
40
+ declare function shouldForceBlockScopedSelectAll(documentProfile: DocumentProfile, capability: FlowBlockCapability | null): boolean;
41
+ declare function isContinuousTextFlowCapability(capability: FlowBlockCapability | null): boolean;
42
+ declare function shouldAllowFlowInsertionInSlashMenu(documentProfile: DocumentProfile, capability: FlowBlockCapability | null): boolean;
43
+ declare function shouldShowBlockInDefaultMenus(documentProfile: DocumentProfile, schema: BlockSchemaCapabilityLike): boolean;
44
+ declare function shouldExposeBlockInTooling(documentProfile: DocumentProfile, schema: BlockSchemaCapabilityLike): boolean;
45
+ declare function shouldAllowDirectBlockPaste(documentProfile: DocumentProfile, capability: FlowBlockCapability | null): boolean;
46
+ declare function getBlockSelectionRoleFromType(blockType: string | null | undefined): BlockSelectionRole;
47
+ declare function resolveBlockFlowCapability(registry: SchemaRegistry, blockType: string | null | undefined): FlowBlockCapability | null;
48
+ type ImportNormalizationEditor = {
49
+ documentProfile: Editor["documentProfile"];
50
+ internals: {
51
+ emit: Editor["internals"]["emit"];
52
+ };
53
+ };
54
+ interface PendingBlockProfilePolicyViolation {
55
+ readonly blockType: string;
56
+ readonly documentProfile: DocumentProfile;
57
+ readonly capability: FlowBlockCapability;
58
+ readonly reason: "flow-disallowed-block";
59
+ }
60
+ interface PendingBlockImportPolicyViolation {
61
+ readonly blockType: string;
62
+ readonly documentProfile: DocumentProfile;
63
+ readonly capability: FlowBlockCapability | null;
64
+ readonly reason: "flow-disallowed-block" | "unknown-block-type";
65
+ }
66
+ declare function createImportResult(parsedTopLevelBlockCount: number, importedTopLevelBlockCount: number, violations: readonly Pick<PendingBlockImportPolicyViolation, "blockType">[]): ImportResult;
67
+ declare function normalizePendingBlocksForImport(blocks: readonly PendingBlock[], documentProfile: DocumentProfile, registry: SchemaRegistry): {
68
+ readonly blocks: PendingBlock[];
69
+ readonly violations: PendingBlockImportPolicyViolation[];
70
+ };
71
+ declare function reportPendingBlockProfileViolations(editor: ImportNormalizationEditor, violations: readonly PendingBlockProfilePolicyViolation[], surface: string): void;
72
+ declare function filterPendingBlocksForDocumentProfile(blocks: readonly PendingBlock[], documentProfile: DocumentProfile, registry: SchemaRegistry): {
73
+ readonly blocks: PendingBlock[];
74
+ readonly violations: PendingBlockProfilePolicyViolation[];
75
+ };
76
+ declare function reportPendingBlockImportViolations(editor: ImportNormalizationEditor, violations: readonly PendingBlockImportPolicyViolation[], surface: string): void;
77
+ interface ProfilePolicyViolation {
78
+ readonly op: InsertBlockOp | SetPropsOp;
79
+ readonly blockType: string;
80
+ readonly documentProfile: DocumentProfile;
81
+ readonly capability: FlowBlockCapability;
82
+ readonly reason: "flow-disallowed-block";
83
+ }
84
+ declare function filterOpsForDocumentProfile(ops: readonly DocumentOp[], documentProfile: DocumentProfile, registry: SchemaRegistry): {
85
+ readonly ops: DocumentOp[];
86
+ readonly violations: ProfilePolicyViolation[];
87
+ };
88
+
89
+ interface SchemaRegistryConfig {
90
+ blocks?: readonly BlockSchema[];
91
+ inlines?: readonly InlineSchema[];
92
+ apps?: readonly AppSchema[];
93
+ systemMarks?: readonly InlineSchema[];
94
+ onUnknownBlock?: (type: string, raw: unknown) => BlockSchema | "drop" | "passthrough";
95
+ onUnknownInline?: (type: string, raw: unknown) => InlineSchema | "drop" | "passthrough";
96
+ }
97
+ declare class SchemaRegistryImpl implements ComposableSchema {
98
+ private readonly _blocks;
99
+ private readonly _inlines;
100
+ private readonly _apps;
101
+ private readonly _systemMarks;
102
+ private readonly _onUnknownBlock?;
103
+ private readonly _onUnknownInline?;
104
+ constructor(config: SchemaRegistryConfig);
105
+ resolve(type: string): BlockSchema | null;
106
+ resolveInline(type: string): InlineSchema | null;
107
+ resolveApp(type: string): AppSchema | null;
108
+ resolveLayout(type: string): LayoutSchema | null;
109
+ allBlocks(): readonly BlockSchema[];
110
+ allInlines(): readonly InlineSchema[];
111
+ allApps(): readonly AppSchema[];
112
+ allBlockDisplays(): readonly (BlockSchema & {
113
+ display: BlockDisplay;
114
+ })[];
115
+ extend(schemas: readonly (BlockSchema | InlineSchema)[]): ComposableSchema;
116
+ without(types: readonly string[]): ComposableSchema;
117
+ override(type: string, patch: Partial<BlockSchema>): ComposableSchema;
118
+ overrideSystemMark(type: string, schema: InlineSchema): ComposableSchema;
119
+ }
120
+ declare function mergeSchemas(...registries: SchemaRegistry[]): ComposableSchema;
121
+
122
+ type DefineBlockConfig = Omit<Partial<BlockSchema<string, Record<string, PropSchema>, ContentType>>, "type" | "propSchema" | "validateProps"> & {
123
+ props?: Record<string, unknown>;
124
+ propSchema?: Record<string, unknown>;
125
+ aiDescription?: string;
126
+ };
127
+ type DefinedBlockSchema<Type extends string = string> = Omit<BlockSchema<Type, Record<string, PropSchema>, ContentType>, "a11y"> & {
128
+ a11y(spec: BlockA11ySpec): BlockSchema<Type, Record<string, PropSchema>, ContentType>;
129
+ };
130
+ declare function defineBlock<Type extends string>(type: Type, config: DefineBlockConfig): DefinedBlockSchema<Type>;
131
+ declare function defineBlock<Type extends string>(config: DefineBlockConfig & {
132
+ type: Type;
133
+ }): DefinedBlockSchema<Type>;
134
+
135
+ type ExtensionCleanup = {
136
+ expose?: Record<string, unknown>;
137
+ destroy?: () => void;
138
+ decorations?: (state: DocumentState) => DecorationSet;
139
+ };
140
+ type DefineExtensionConfig<TConfig = void> = Omit<Extension, "version" | "setup"> & {
141
+ version?: string;
142
+ setup?: TConfig extends void ? (editor: Editor) => ExtensionCleanup | void : (editor: Editor, config: TConfig) => ExtensionCleanup | void;
143
+ };
144
+ declare function defineExtension<TConfig = void>(config: DefineExtensionConfig<TConfig>): Extension;
145
+
146
+ declare class PropChainImpl {
147
+ private _schema;
148
+ constructor(init: Record<string, unknown>);
149
+ default(value: unknown): this;
150
+ describe(text: string): this;
151
+ min(value: number): this;
152
+ max(value: number): this;
153
+ optional(): PropChainImpl;
154
+ toSchema(): PropSchema;
155
+ toJSON(): Record<string, unknown>;
156
+ }
157
+ declare function resolveSchema(value: unknown): PropSchema;
158
+ declare const prop: {
159
+ string(): PropChainImpl;
160
+ number(): PropChainImpl;
161
+ boolean(): PropChainImpl;
162
+ enum(values: readonly (string | number)[]): PropChainImpl;
163
+ array(items: PropChainImpl | PropSchema): PropChainImpl;
164
+ object(properties: Record<string, PropChainImpl | PropSchema>): PropChainImpl;
165
+ json(): PropChainImpl;
166
+ optional(inner: PropChainImpl): PropChainImpl;
167
+ };
168
+
169
+ /** Empty registry for hosts that do not pass `schema` or a preset that provides one. */
170
+ declare function createEmptySchema(): SchemaRegistryImpl;
171
+ declare function resolveEditorSchema(options?: CreateEditorOptions): SchemaRegistry;
172
+
173
+ declare function sortDeltaAttributes(attributes: Record<string, unknown>, registry: SchemaRegistry): Record<string, unknown>;
174
+ declare function deepEqual(a: unknown, b: unknown): boolean;
175
+ type DiagnosticSink = (event: DiagnosticEvent) => void;
176
+ declare class SchemaEngineImpl implements SchemaEngine {
177
+ private readonly registry;
178
+ private readonly doc;
179
+ private readonly crdtDoc;
180
+ private readonly dirtyBlockIds;
181
+ private readonly deferredBlockIds;
182
+ private onDiagnostic;
183
+ private passIndex;
184
+ constructor(registry: SchemaRegistry, doc: PenDocument, crdtDoc: CRDTDocument, onDiagnostic?: DiagnosticSink);
185
+ setOnDiagnostic(onDiagnostic: DiagnosticSink | undefined): void;
186
+ markDirty(blockId: string): void;
187
+ deferBlock(blockId: string): void;
188
+ undeferBlock(blockId: string): void;
189
+ normalizeDirty(): void;
190
+ normalizeAll(): void;
191
+ private normalizeBlock;
192
+ private stripSuperfluousMarks;
193
+ private ensureContentExists;
194
+ private stripDefaultProps;
195
+ private runBlockNormalize;
196
+ private normalizeLayout;
197
+ private deduplicateBlockIds;
198
+ private deduplicateBlockOrder;
199
+ private deduplicateArray;
200
+ private deduplicateAtIndices;
201
+ private handleDeletedBlock;
202
+ private breakParentCycle;
203
+ private walkParentCycle;
204
+ private parentOf;
205
+ private readParentIdProp;
206
+ private parentEdgeOwner;
207
+ private clearParentEdge;
208
+ private enforceCrossArrayMembership;
209
+ private isInBlockOrder;
210
+ private findParentWithChild;
211
+ private removeFromBlockOrder;
212
+ private insertIntoBlockOrder;
213
+ private getBlockOrderIndex;
214
+ private readPropsWithDefaults;
215
+ private get blockOrder();
216
+ private get blocksMap();
217
+ private getBlockMap;
218
+ private deleteBlock;
219
+ private getPassIndex;
220
+ private invalidatePassIndex;
221
+ private buildPassIndex;
222
+ }
223
+
224
+ declare function createBlockHandle(blockId: string, doc: PenDocument, crdtDoc: CRDTDocument, registry: SchemaRegistry): BlockHandle;
225
+ declare function createAppHandle(appId: string, doc: PenDocument, crdtDoc: CRDTDocument, registry: SchemaRegistry): AppHandle;
226
+
227
+ declare const suggestion: InlineSchema;
228
+
229
+ declare function createEditor(options?: CreateEditorOptions): Editor;
230
+ interface CreateHeadlessEditorOptions extends CreateEditorOptions {
231
+ /**
232
+ * Headless server/workflow editors default to the core apply pipeline only.
233
+ * Enable default extensions when a host explicitly needs undo, shortcuts, or
234
+ * delta stream behavior in a non-rendered environment.
235
+ */
236
+ useDefaultExtensions?: boolean;
237
+ }
238
+ declare function createHeadlessEditor(options?: CreateHeadlessEditorOptions): Editor;
239
+
240
+ interface CreateDocumentSessionOptions {
241
+ adapter: CRDTAdapter;
242
+ document?: CRDTDocument;
243
+ destroyWhenIdle?: boolean;
244
+ ownsDocuments?: boolean;
245
+ }
246
+ declare function createDocumentSession(options: CreateDocumentSessionOptions): DocumentSession;
247
+
248
+ type Handler = (...args: unknown[]) => void;
249
+ declare class EventEmitter {
250
+ private readonly _handlers;
251
+ on(event: string, handler: Handler): Unsubscribe;
252
+ off(event: string, handler: Handler): void;
253
+ emit(event: string, ...args: unknown[]): void;
254
+ has(event: string): boolean;
255
+ removeAllListeners(event?: string): void;
256
+ }
257
+
258
+ declare function createDecorationSet(decorations: Decoration[]): DecorationSet;
259
+ declare function emptyDecorationSet(): DecorationSet;
260
+ declare function mergeDecorationSets(...sets: DecorationSet[]): DecorationSet;
261
+
262
+ declare function getInlineCompletionController(editor: Editor): InlineCompletionController | null;
263
+ declare function ensureInlineCompletionController(editor: Editor): {
264
+ controller: InlineCompletionController;
265
+ isOwner: boolean;
266
+ release: () => void;
267
+ };
268
+
269
+ declare class DocumentRangeImpl implements DocumentRange {
270
+ readonly start: {
271
+ blockId: string;
272
+ offset: number;
273
+ };
274
+ readonly end: {
275
+ blockId: string;
276
+ offset: number;
277
+ };
278
+ private readonly _anchor;
279
+ private readonly _focus;
280
+ private readonly _doc;
281
+ constructor(anchor: {
282
+ blockId: string;
283
+ offset?: number;
284
+ }, focus: {
285
+ blockId: string;
286
+ offset?: number;
287
+ }, doc: PenDocument);
288
+ get isMultiBlock(): boolean;
289
+ get blockRange(): string[];
290
+ contains(point: {
291
+ blockId: string;
292
+ offset: number;
293
+ }): boolean;
294
+ overlaps(other: DocumentRange): boolean;
295
+ equals(other: DocumentRange): boolean;
296
+ toTextSelection(): TextSelection;
297
+ private _indexOfBlock;
298
+ }
299
+
300
+ interface EditorAnchorsHost {
301
+ adapter: CRDTAdapter;
302
+ emit(event: DiagnosticEvent): void;
303
+ commitId(): number;
304
+ }
305
+ declare class EditorAnchorsImpl implements EditorAnchors {
306
+ private _doc;
307
+ private readonly _host;
308
+ private readonly _cache;
309
+ private readonly _lastTarget;
310
+ private _liveCount;
311
+ private _budgetWarned;
312
+ constructor(doc: CRDTDocument, host: EditorAnchorsHost);
313
+ get liveCount(): number;
314
+ updateDocument(doc: CRDTDocument): void;
315
+ peekLastTarget(anchor: Anchor): AnchorTarget | null;
316
+ rememberTarget(anchor: Anchor, target: AnchorTarget): void;
317
+ remint(target: AnchorTarget, assoc: Assoc, provenance: Anchor["provenance"]): Anchor | null;
318
+ create(target: AnchorTarget, assoc?: Assoc): Anchor | null;
319
+ range(range: {
320
+ anchor: AnchorTarget;
321
+ focus: AnchorTarget;
322
+ }): AnchorRange | null;
323
+ resolve(anchor: Anchor): AnchorTarget | null;
324
+ resolveRange(range: AnchorRange): ResolvedAnchorRange | null;
325
+ serialize(anchor: Anchor): string;
326
+ deserialize(input: string): Anchor | null;
327
+ private _noteMint;
328
+ private _rejectDecode;
329
+ }
330
+
331
+ interface SelectionAuthority {
332
+ readonly record: SelectionRecord;
333
+ set(state: SelectionState, options: {
334
+ origin: SelectionOrigin;
335
+ }): SelectionRecord;
336
+ onCommit(summary: ChangeSummary): void;
337
+ }
338
+ declare class SelectionAuthorityImpl implements SelectionAuthority {
339
+ private _state;
340
+ private _version;
341
+ private _origin;
342
+ private _commitId;
343
+ private _doc;
344
+ private _crdtDoc;
345
+ private readonly _registry;
346
+ private readonly _emitter;
347
+ private readonly _anchors;
348
+ private _editor;
349
+ private _fromAnchor;
350
+ private _toAnchor;
351
+ constructor(doc: PenDocument, crdtDoc: CRDTDocument, registry: SchemaRegistry, emitter: EventEmitter, anchors: EditorAnchorsImpl);
352
+ bindEditor(editor: Editor): void;
353
+ get record(): SelectionRecord;
354
+ getSelection(): SelectionState;
355
+ set(state: SelectionState, options: {
356
+ origin: SelectionOrigin;
357
+ }): SelectionRecord;
358
+ onCommit(summary: ChangeSummary): void;
359
+ updateDocument(doc: PenDocument, crdtDoc: CRDTDocument): void;
360
+ getSelectedText(): string;
361
+ getSelectedBlocks(): BlockHandle[];
362
+ private _accept;
363
+ private _repairHeldAnchors;
364
+ private _isNonTextBlock;
365
+ private _clampOffset;
366
+ private _logicalText;
367
+ /** N1: each inline embed occupies one logical offset. */
368
+ private _logicalLength;
369
+ private _tableGrid;
370
+ private _blockExists;
371
+ private _handle;
372
+ private _emitMissingBlock;
373
+ private _emitDiagnostic;
374
+ private _getSelectedCellText;
375
+ }
376
+
377
+ /**
378
+ * A pre-commit text range that a structural commit copied onto another block (AN14).
379
+ */
380
+ interface ContentMove {
381
+ readonly fromBlockId: string;
382
+ readonly fromRange: {
383
+ readonly from: number;
384
+ readonly to: number;
385
+ };
386
+ readonly toBlockId: string;
387
+ readonly toOffset: number;
388
+ }
389
+ /**
390
+ * Derive the copy-based content moves a structural commit performed (AN14).
391
+ *
392
+ * Local Pen commits expose `block-split` / `blocks-merged` on the summary.
393
+ * Remote commits without those tags fall back to same-length delete/insert pairing.
394
+ * `intent` is accepted for the AN14 signature; recipes live on the summary.
395
+ */
396
+ declare function deriveContentMoves(summary: ChangeSummary, _intent: string | undefined): readonly ContentMove[];
397
+ /**
398
+ * Re-mint into the destination when the pre-commit target sat in a moved range (AN14).
399
+ *
400
+ * Returns the same object when no move applies. Remint keeps the original provenance.
401
+ */
402
+ declare function repairAnchor(editor: Editor, anchor: Anchor, moves: readonly ContentMove[]): Anchor;
403
+
404
+ /**
405
+ * Reads the selection authority's current {@link SelectionRecord} from an editor.
406
+ *
407
+ * The record carries the version and origin alongside the selection state, which
408
+ * the DOM reader needs to tell a projection echo from a fresh user gesture. The
409
+ * plain `editor.selection` state cannot answer that.
410
+ *
411
+ * @param editor - Any editor; the record lives on the runtime implementation.
412
+ * @returns The current record, or `null` on an editor that does not carry one.
413
+ */
414
+ declare function getEditorSelectionRecord(editor: Editor): SelectionRecord | null;
415
+
416
+ type ReadonlyTextSelection = Extract<ReadonlySelectionState, {
417
+ type: "text";
418
+ }>;
419
+ /**
420
+ * Live `TextSelection` constructor. Defaults `affinity` / `goalX`.
421
+ * Predicates and the block span are helpers, not fields.
422
+ */
423
+ declare function createTextSelection(input: {
424
+ readonly anchor: Point;
425
+ readonly focus: Point;
426
+ readonly affinity?: Affinity;
427
+ readonly goalX?: number | null;
428
+ }): TextSelection;
429
+ declare function isCollapsed(sel: ReadonlySelectionState): boolean;
430
+ declare function isMultiBlock(sel: ReadonlySelectionState): boolean;
431
+ /**
432
+ * Document-order block ids covered by `sel`. Pass a plain `blockOrder`
433
+ * snapshot (`editor.documentState.blockOrder`) from a renderer effect —
434
+ * walking a live `Y.Array` through a deep-proxied document writes back.
435
+ */
436
+ declare function getSelectionBlockRange(doc: PenDocument | readonly string[], sel: ReadonlySelectionState): string[];
437
+ declare function isBlockSelected(blockOrder: readonly string[], sel: ReadonlySelectionState, blockId: string): boolean;
438
+ declare function selectionToRange(doc: PenDocument, sel: ReadonlyTextSelection): DocumentRange;
439
+
440
+ /**
441
+ * N1–N3 normal caret positions (`spec/rules/selection.md` §3).
442
+ *
443
+ * Pure functions over a fake doc snapshot. Not wired to the
444
+ * manager, commands, or reader.
445
+ */
446
+
447
+ type NormalPositionDirection = -1 | 1;
448
+
449
+ interface BlockBoundary {
450
+ readonly blockBoundary: string;
451
+ }
452
+ type NextNormalPositionResult = Point | BlockBoundary | null;
453
+ interface AtomExtent {
454
+ readonly start: number;
455
+ readonly end: number;
456
+ }
457
+ type NormalPositionBlockKind = "text" | "structural";
458
+ interface NormalPositionBlock {
459
+ readonly kind: NormalPositionBlockKind;
460
+ readonly text: string;
461
+ readonly atoms?: readonly AtomExtent[];
462
+ }
463
+ /**
464
+ * A document-shaped view sufficient to decide whether a point is a normal position.
465
+ *
466
+ * Deliberately not the live document: normal-position checks run on the DOM read
467
+ * path, and walking the CRDT there couples reading to document mutation. Build one
468
+ * with `buildNormalPositionSnapshot`.
469
+ */
470
+ interface NormalPositionSnapshot {
471
+ readonly blockOrder: readonly string[];
472
+ readonly blocks: Readonly<Record<string, NormalPositionBlock>>;
473
+ }
474
+ /**
475
+ * Snap a point onto a normal position without stepping.
476
+ * Interior atom offsets go to the start (`-1`) or end (`1`).
477
+ * Non-text blocks yield `{ blockBoundary }` (N2).
478
+ */
479
+ declare function snapToNormalPosition(doc: NormalPositionSnapshot, point: Point, direction: NormalPositionDirection): NextNormalPositionResult;
480
+
481
+ /**
482
+ * Ops that change one block's type in place, keeping its id and its text.
483
+ *
484
+ * A nested block's `parentId` is re-asserted after the type change, because
485
+ * `set-props` replaces the prop set and would otherwise orphan the block out
486
+ * of its parent.
487
+ */
488
+ declare function convertBlockOps(editor: Editor, options: {
489
+ blockId: string;
490
+ newType: string;
491
+ newProps?: Record<string, unknown>;
492
+ }): DocumentOp[];
493
+
494
+ /**
495
+ * Captures a {@link NormalPositionSnapshot} from an editor's current document.
496
+ *
497
+ * Exported so renderers can feed `snapToNormalPosition` without building a second
498
+ * adapter over the document shape; two snapshot builders would drift apart and the
499
+ * snap rule would disagree with core about where a caret may legally sit.
500
+ *
501
+ * @param editor - The editor to read block order and block content from.
502
+ * @returns A snapshot detached from the live document.
503
+ */
504
+ declare function buildNormalPositionSnapshot(editor: Editor): NormalPositionSnapshot;
505
+
506
+ declare class ExtensionManagerImpl {
507
+ private readonly _extensions;
508
+ private _sorted;
509
+ private readonly _stateMap;
510
+ private readonly _emitter;
511
+ constructor(emitter: EventEmitter);
512
+ private _emitLifecycleDiagnostic;
513
+ register(ext: Extension): void;
514
+ unregister(name: string): void;
515
+ activateAll(editor: Editor): Promise<void>;
516
+ deactivateAll(editor: Editor): Promise<void>;
517
+ dispatchObserve(events: readonly CommitEvent[], editor: Editor): void;
518
+ collectDecorations(state: DocumentState, editor: Editor): DecorationSet;
519
+ collectKeyBindings(registry: SchemaRegistry, extensionBindings?: readonly KeyBinding[]): readonly KeyBinding[];
520
+ getExtensionState<T>(name: string): T | undefined;
521
+ private _resortAndValidate;
522
+ }
523
+ declare function collectEditorKeyBindings(editor: Editor): readonly KeyBinding[];
524
+
525
+ /**
526
+ * Named commit-pipeline phases from spec/rules/pipeline.md.
527
+ * Step 2.1 makes the boundaries visible; step 2.2 replaces phase 8's
528
+ * v1 `change` / `documentCommit` emit with `CommitEvent`.
529
+ */
530
+ declare const PIPELINE_PHASES: readonly ["hooks", "validate", "execute", "normalize", "summarize", "map-selection", "settle-facets", "emit"];
531
+ /** Nested applies beyond this queue depth in one task turn trip `apply-storm` (I7). */
532
+ declare const APPLY_STORM_QUEUE_LIMIT = 16;
533
+ declare const APPLY_STORM_CODE = "apply-storm";
534
+
535
+ interface ResolvedCellSelectionCell {
536
+ row: number;
537
+ col: number;
538
+ rowId: string | null;
539
+ columnId: string | null;
540
+ }
541
+ declare function hasIndexedCellSelectionMetadata(selection: CellSelection): boolean;
542
+ declare function resolveCellSelectionCoord(block: BlockHandle, selection: CellSelection, coord: {
543
+ row: number;
544
+ col: number;
545
+ }): ResolvedCellSelectionCell | null;
546
+ declare function resolveCellSelectionMatrix(block: BlockHandle, selection: CellSelection): ResolvedCellSelectionCell[][];
547
+
548
+ declare function getNumberedListItemValue(block: BlockHandle | null | undefined): number | null;
549
+
550
+ declare function resolveSelectionTargetBlockIds(editor: Editor, target: ModelOperationRangeTarget): string[];
551
+ declare function renderSelectionTargetText(editor: Editor, target: ModelOperationRangeTarget, options?: {
552
+ resolved?: boolean;
553
+ }): string;
554
+ declare function renderSelectionTargetBlockText(editor: Editor, target: ModelOperationRangeTarget, options?: {
555
+ resolved?: boolean;
556
+ }): string;
557
+
558
+ declare function buildTableChildren(handle: BlockHandle): Block[] | undefined;
559
+
560
+ interface DocumentMigration {
561
+ readonly id: string;
562
+ run(editor: Editor): void;
563
+ }
564
+ interface MigrationReport {
565
+ readonly applied: readonly string[];
566
+ readonly skipped: readonly string[];
567
+ readonly failed: readonly {
568
+ id: string;
569
+ error: unknown;
570
+ }[];
571
+ }
572
+
573
+ declare function runMigrations(editor: Editor, migrations: readonly DocumentMigration[]): MigrationReport;
574
+
575
+ /**
576
+ * Grapheme/word boundary queries and match folding (LOC4, LOC5).
577
+ *
578
+ * `Intl.Segmenter` is above the HOST4 floor (Firefox only since 125). It is
579
+ * feature-detected on every call. When it is missing:
580
+ * - character operations degrade to code points, never to UTF-16 code units
581
+ * - word operations degrade to whitespace runs
582
+ *
583
+ * Offsets are in the logical text domain (`spec/rules/selection.md` §2): UTF-16
584
+ * indices into the block string with the empty-block sentinel already erased.
585
+ * This module does not look for the sentinel.
586
+ */
587
+ interface WordRange {
588
+ readonly start: number;
589
+ readonly end: number;
590
+ }
591
+ declare function previousGraphemeBoundary(text: string, offset: number, locale: string): number;
592
+ declare function nextGraphemeBoundary(text: string, offset: number, locale: string): number;
593
+ declare function previousWordBoundary(text: string, offset: number, locale: string): number;
594
+ declare function nextWordBoundary(text: string, offset: number, locale: string): number;
595
+ declare function wordRangeAt(text: string, offset: number, locale: string): WordRange | null;
596
+ /**
597
+ * Locale-aware case fold plus NFC for match comparison (LOC5).
598
+ * Maps Greek final sigma to medial sigma. Not `toLowerCase()` — that misses
599
+ * Turkish ı/I and ς/σ.
600
+ */
601
+ declare function foldAndNormalize(text: string, locale: string): string;
602
+
603
+ declare function defineFacet<Input, Output = readonly Input[]>(spec: FacetSpec<Input, Output>): Facet<Input, Output>;
604
+
605
+ interface FacetSettleInput {
606
+ readonly commitId?: number;
607
+ readonly emptyCommit?: boolean;
608
+ readonly selectionVersion?: number;
609
+ }
610
+
611
+ interface CreateFacetRegistryOptions {
612
+ extensions?: readonly Extension[];
613
+ providers?: readonly FacetProvider[];
614
+ editor?: Editor;
615
+ }
616
+ interface FacetRegistry {
617
+ markReady(): void;
618
+ read<F extends Facet<unknown, unknown>>(facet: F): FacetOutput<F>;
619
+ override<F extends Facet<unknown, unknown>>(facet: F, value: FacetOutput<F>): void;
620
+ settle(input: FacetSettleInput): void;
621
+ }
622
+ declare function createFacetRegistry(options?: CreateFacetRegistryOptions): FacetRegistry;
623
+
624
+ type Keymap = readonly KeyBinding[];
625
+ type BeforeApplyHook = (ops: DocumentOp[], options: ApplyOptions) => DocumentOp[];
626
+ type DecorationSource = ((state: DocumentState, editor: Editor) => DecorationSet) | DecorationSet;
627
+ type ClipboardHandler = unknown;
628
+ type CommandHandlerTable = {
629
+ readonly [commandName: string]: readonly CommandHandlerRegistration[];
630
+ };
631
+ declare const keymapFacet: _input_pen_types.Facet<Keymap, readonly KeyBinding[]>;
632
+ declare const beforeApplyFacet: _input_pen_types.Facet<BeforeApplyHook, readonly BeforeApplyHook[]>;
633
+ declare const decorationsFacet: _input_pen_types.Facet<DecorationSource, readonly DecorationSource[]>;
634
+ declare const inputRulesFacet: _input_pen_types.Facet<InputRule, readonly InputRule[]>;
635
+ declare const commandsFacet: _input_pen_types.Facet<CommandHandlerRegistration<unknown>, CommandHandlerTable>;
636
+ declare const ariaReadOnlyFacet: _input_pen_types.Facet<boolean, boolean>;
637
+ declare const clipboardFacet: _input_pen_types.Facet<unknown, readonly unknown[]>;
638
+
639
+ type UrlContext = "link" | "image" | "media" | "download";
640
+ interface UrlPolicy {
641
+ resolve(rawValue: unknown, context: UrlContext): string | null;
642
+ }
643
+ declare const urlPolicy: UrlPolicy;
644
+
645
+ declare const urlPolicyFacet: _input_pen_types.Facet<UrlPolicy, UrlPolicy | undefined>;
646
+
647
+ declare const aiEgressFacet: _input_pen_types.Facet<AIRequestFilter, AIRequestFilter | undefined>;
648
+ declare function aiEgressExtension(filter: AIRequestFilter): Extension;
649
+ declare function filterAIRequest(editor: Editor, context: AIRequestContext): AIRequestContext | null;
650
+ /**
651
+ * The one door to a `ModelAdapter` (AIB1). `extras` carries every request field
652
+ * that is not filterable content, so a caller needing one of them forwards it
653
+ * here rather than wrapping the adapter — a wrapper would set that field after
654
+ * the filter ran, and would be a second call site the filter does not govern.
655
+ */
656
+ declare function streamThroughEgress(editor: Editor, model: ModelAdapter, context: AIRequestContext, extras?: {
657
+ signal?: AbortSignal;
658
+ requestMode?: string;
659
+ operation?: ModelRequestedOperation | null;
660
+ sessionId?: string;
661
+ turnId?: string;
662
+ generationId?: string;
663
+ toolChoice?: ModelToolChoice;
664
+ }): AsyncIterable<ModelStreamEvent>;
665
+
666
+ type BlockDirection = "ltr" | "rtl";
667
+ type BlockDirectionSetting = BlockDirection | "auto";
668
+
669
+ type BlockDirectionResolver = (block: BlockHandle, editor: Editor) => BlockDirection | null | undefined;
670
+ declare const blockDirectionFacet: _input_pen_types.Facet<BlockDirectionResolver, readonly BlockDirectionResolver[]>;
671
+ declare const defaultDirectionFacet: _input_pen_types.Facet<BlockDirection, BlockDirection>;
672
+
673
+ declare function resolveBlockDirection(editor: Editor, block: BlockHandle): BlockDirection;
674
+
675
+ /**
676
+ * Stored text of a block. Empty string is empty; missing blocks emit a
677
+ * diagnostic and return "".
678
+ */
679
+ declare function blockLogicalText(editor: Editor, blockId: string): string;
680
+
681
+ type DefaultKeymapContext = "text" | "cell" | "block" | "any";
682
+ type KeymapPlatform = "macos" | "windows" | "linux";
683
+ interface DefaultKeymapBinding {
684
+ readonly key: string;
685
+ readonly command: Command<unknown>;
686
+ readonly param?: unknown;
687
+ readonly context?: DefaultKeymapContext;
688
+ }
689
+ declare function resolveDefaultKeymap(platform: KeymapPlatform): readonly DefaultKeymapBinding[];
690
+ declare const defaultKeymapBindings: {
691
+ shared: readonly DefaultKeymapBinding[];
692
+ macos: readonly DefaultKeymapBinding[];
693
+ windowsLinux: readonly DefaultKeymapBinding[];
694
+ };
695
+
696
+ /**
697
+ * K1 / M2: remap a matched keymap binding for the focus block's resolved
698
+ * direction. Command handlers stay logical; only the dispatched command
699
+ * changes. Intended once per keystroke on the matched binding — direction
700
+ * comes from the DIR1 fingerprint cache, not a geometry measure.
701
+ */
702
+ declare function resolveDirectedBinding(editor: Editor, binding: DefaultKeymapBinding): DefaultKeymapBinding;
703
+ /** DIR1-cached resolved direction of the focus block, or null if none. */
704
+ declare function resolveFocusBlockDirection(editor: Editor): BlockDirection | null;
705
+ /**
706
+ * Pure M2 / M4 command swap. `pen.caretLeft/Right` and word variants flip
707
+ * under rtl; line, vertical, and delete commands are untouched.
708
+ */
709
+ declare function resolveDirectedCommand<P>(command: Command<P>, direction: BlockDirection): Command<P>;
710
+ declare function applyDirectedBinding(binding: DefaultKeymapBinding, direction: BlockDirection): DefaultKeymapBinding;
711
+
712
+ declare function spliceInsertOp(blockId: string, offset: number, text: string, marks?: Record<string, unknown | null>): SpliceTextOp;
713
+ declare function spliceDeleteOp(blockId: string, offset: number, length: number): SpliceTextOp;
714
+ declare function buildSplitBlockRecipe(options: {
715
+ block: BlockHandle;
716
+ offset: number;
717
+ newBlockId: string;
718
+ newBlockType?: string;
719
+ }): {
720
+ ops: DocumentOp[];
721
+ structural: StructuralOriginTag;
722
+ };
723
+ declare function buildMergeBlocksRecipe(options: {
724
+ target: BlockHandle;
725
+ source: BlockHandle;
726
+ }): {
727
+ ops: DocumentOp[];
728
+ structural: StructuralOriginTag;
729
+ };
730
+ declare function applySplitBlock(editor: Editor, options: {
731
+ blockId: string;
732
+ offset: number;
733
+ newBlockId: string;
734
+ newBlockType?: string;
735
+ applyOptions?: ApplyOptions;
736
+ }): void;
737
+ declare function applyMergeBlocks(editor: Editor, options: {
738
+ targetBlockId: string;
739
+ sourceBlockId: string;
740
+ applyOptions?: ApplyOptions;
741
+ }): void;
742
+
743
+ declare function defineCommand<P = void>(name: string): Command<P>;
744
+ declare function commandHandler<P>(command: Command<P>, handler: CommandHandler<P>, precedence?: Precedence): FacetProvider;
745
+
746
+ interface CommandDispatchContext {
747
+ origin?: OpOrigin;
748
+ fromKeymap?: boolean;
749
+ }
750
+ interface RecordedApplyIntent {
751
+ ops: DocumentOp[];
752
+ options?: ApplyOptions;
753
+ }
754
+ interface RecordedSelectionIntent {
755
+ selection: SelectionState;
756
+ origin: "keyboard" | "programmatic";
757
+ }
758
+ interface CreateCommandRegistryOptions {
759
+ providers?: readonly FacetProvider[];
760
+ editor?: Editor;
761
+ apply?: (ops: DocumentOp[], options?: ApplyOptions) => void;
762
+ setSelection?: (selection: SelectionState, origin: "keyboard" | "programmatic") => void;
763
+ }
764
+ interface CommandRegistry {
765
+ dispatch<P>(command: Command<P>, param: P, context?: CommandDispatchContext): boolean;
766
+ canDispatch<P>(command: Command<P>, param: P): boolean;
767
+ probe(): Editor;
768
+ readonly recordedApplies: readonly RecordedApplyIntent[];
769
+ readonly recordedSelections: readonly RecordedSelectionIntent[];
770
+ readonly diagnostics: readonly DiagnosticEvent[];
771
+ }
772
+ declare function createCommandRegistry(options?: CreateCommandRegistryOptions): CommandRegistry;
773
+
774
+ declare function getCommandRegistry(editor: Editor): CommandRegistry | undefined;
775
+
776
+ declare function builtinCommandHandlers(): FacetProvider[];
777
+
778
+ interface CaretMotionParam {
779
+ readonly extend: boolean;
780
+ }
781
+ interface SelectBlockParam {
782
+ readonly blockId: string;
783
+ }
784
+
785
+ type CellCaretFocus = {
786
+ readonly blockId: string;
787
+ readonly row: number;
788
+ readonly col: number;
789
+ readonly start: number;
790
+ readonly end: number;
791
+ };
792
+ type CellCaretWrite = (next: {
793
+ readonly start: number;
794
+ readonly end: number;
795
+ }) => void;
796
+ declare function setCellCaretFocus(editor: Editor, focus: CellCaretFocus | null, write?: CellCaretWrite | null): void;
797
+ declare function getCellCaretFocus(editor: Editor): CellCaretFocus | null;
798
+
799
+ declare const caretLeft: _input_pen_types.Command<CaretMotionParam>;
800
+ declare const caretRight: _input_pen_types.Command<CaretMotionParam>;
801
+ declare const caretUp: _input_pen_types.Command<CaretMotionParam>;
802
+ declare const caretDown: _input_pen_types.Command<CaretMotionParam>;
803
+ declare const caretLineStart: _input_pen_types.Command<CaretMotionParam>;
804
+ declare const caretLineEnd: _input_pen_types.Command<CaretMotionParam>;
805
+ declare const caretBlockStart: _input_pen_types.Command<CaretMotionParam>;
806
+ declare const caretBlockEnd: _input_pen_types.Command<CaretMotionParam>;
807
+ declare const caretDocStart: _input_pen_types.Command<CaretMotionParam>;
808
+ declare const caretDocEnd: _input_pen_types.Command<CaretMotionParam>;
809
+ declare const caretWordLeft: _input_pen_types.Command<CaretMotionParam>;
810
+ declare const caretWordRight: _input_pen_types.Command<CaretMotionParam>;
811
+ declare const selectAll: _input_pen_types.Command<void>;
812
+ declare const selectBlock: _input_pen_types.Command<SelectBlockParam>;
813
+
814
+ /**
815
+ * Geometry seam for `pen.caretUp` / `pen.caretDown` (G5).
816
+ *
817
+ * Core cannot import `@input/pen-dom`. The field-editor host registers
818
+ * `measureNow(() => verticalCaretTarget(...))` here after `createEditor()`.
819
+ * Headless tests inject a fake. Until a measure is registered, the handlers
820
+ * cross at logical block edges and emit `caret-geometry-unavailable` as a
821
+ * defined no-op when the caret is mid-block (no throw, no silent miss).
822
+ *
823
+ * Stored on a symbol of the editor instance so registry dispatch proxies
824
+ * (which forward `get` to the source) still see the same seam. `goalX` is
825
+ * here because v1 `SelectionState` has no field for it.
826
+ * No rAF / timeout / retry — S4.
827
+ */
828
+ type VerticalCaretDirection = "up" | "down";
829
+ type VerticalCaretPoint = {
830
+ readonly blockId: string;
831
+ readonly offset: number;
832
+ };
833
+ type VerticalCaretMeasureResult = {
834
+ readonly point: VerticalCaretPoint;
835
+ readonly goalX: number;
836
+ };
837
+ type VerticalCaretMeasure = (editor: Editor, current: VerticalCaretPoint, direction: VerticalCaretDirection, goalX: number | null) => VerticalCaretMeasureResult | null;
838
+ declare function setVerticalCaretMeasure(editor: Editor, measure: VerticalCaretMeasure | null): void;
839
+ declare function getVerticalCaretMeasure(editor: Editor): VerticalCaretMeasure | undefined;
840
+ declare function getVerticalCaretGoalX(editor: Editor): number | null;
841
+ declare function setVerticalCaretGoalX(editor: Editor, goalX: number | null): void;
842
+
843
+ type DeleteGranularity = "grapheme" | "word" | "line";
844
+ interface InsertTextParam {
845
+ readonly text: string;
846
+ readonly marks?: Record<string, unknown | null>;
847
+ }
848
+ interface DeleteParam {
849
+ readonly granularity: DeleteGranularity;
850
+ }
851
+ interface ToggleMarkParam {
852
+ readonly mark: string;
853
+ readonly value?: unknown;
854
+ }
855
+ interface ConvertBlockParam {
856
+ readonly blockId: string;
857
+ readonly newType: string;
858
+ readonly newProps?: Record<string, unknown>;
859
+ }
860
+
861
+ /**
862
+ * Adjacent inline atom → SELECT it. Does not mutate the document.
863
+ * The next delete (non-collapsed `handleDelete`) removes it through the
864
+ * ordinary selection-delete path.
865
+ */
866
+ declare function selectAdjacentInlineAtom(editor: Editor, direction: "backward" | "forward"): SelectionState | null;
867
+ /**
868
+ * One-shot helper: adjacent inline atom → DELETE it.
869
+ * Same detection as `selectAdjacentInlineAtom`. The live registry no
870
+ * longer calls this; first-press Backspace / Delete selects instead.
871
+ */
872
+ declare function deleteAdjacentInlineAtom(editor: Editor, direction: "backward" | "forward"): {
873
+ ops: DocumentOp[];
874
+ caret: Point;
875
+ } | null;
876
+
877
+ declare const insertText: _input_pen_types.Command<InsertTextParam>;
878
+ declare const deleteBackward: _input_pen_types.Command<DeleteParam>;
879
+ declare const deleteForward: _input_pen_types.Command<DeleteParam>;
880
+ declare const insertLineBreak: _input_pen_types.Command<void>;
881
+ declare const splitBlock: _input_pen_types.Command<void>;
882
+ declare const indent: _input_pen_types.Command<void>;
883
+ declare const outdent: _input_pen_types.Command<void>;
884
+ declare const toggleMark: _input_pen_types.Command<ToggleMarkParam>;
885
+ declare const convertBlock: _input_pen_types.Command<ConvertBlockParam>;
886
+
887
+ interface StructureBlockParam {
888
+ readonly blockId?: string;
889
+ }
890
+ declare const moveBlockUp: _input_pen_types.Command<StructureBlockParam>;
891
+ declare const moveBlockDown: _input_pen_types.Command<StructureBlockParam>;
892
+ declare const duplicateBlock: _input_pen_types.Command<StructureBlockParam>;
893
+ declare const deleteBlock: _input_pen_types.Command<StructureBlockParam>;
894
+
895
+ declare const tableCellNext: _input_pen_types.Command<void>;
896
+ declare const tableCellPrev: _input_pen_types.Command<void>;
897
+ declare const tableCellDown: _input_pen_types.Command<void>;
898
+ declare const tableEscapeGrid: _input_pen_types.Command<void>;
899
+
900
+ declare const historyUndo: _input_pen_types.Command<void>;
901
+ declare const historyRedo: _input_pen_types.Command<void>;
902
+
903
+ declare const localeFacet: _input_pen_types.Facet<string, string>;
904
+ declare const messagesFacet: _input_pen_types.Facet<Partial<MessageCatalog>, MessageCatalog>;
905
+
906
+ declare const a11yLabelFacet: _input_pen_types.Facet<A11yLabel, A11yLabel | undefined>;
907
+
908
+ declare function interpolateMessage(template: string, params?: Record<string, unknown>): string;
909
+ declare function resolveMessage<K extends MessageKey>(catalog: Partial<MessageCatalog>, key: K, ...args: MessageArgs<K>): string;
910
+
911
+ declare function getOpOriginType(origin: OpOrigin): string;
912
+ declare function getOpOriginGroupId(origin: OpOrigin): string | undefined;
913
+ declare function getApplyOptionsGroupId(origin: OpOrigin, options?: Pick<ApplyOptions, "groupId" | "undoGroupId">): string | undefined;
914
+ declare function createMutationGroupMetadata(origin: OpOrigin, groupId: string): MutationGroupMetadata;
915
+
916
+ declare function collectToolExecutionOutput(result: ToolExecutionResult, onPart?: (part: unknown, output: unknown) => void): Promise<unknown>;
917
+
918
+ type FieldEditorSchemaLike = Pick<BlockSchema, "content" | "fieldEditor">;
919
+ declare function resolveFieldEditorBehavior(schema: FieldEditorSchemaLike | null | undefined): FieldEditorBehavior;
920
+ declare function resolveFieldEditorInputMode(schema: FieldEditorSchemaLike | null | undefined): FieldEditorInputMode;
921
+ declare function usesInlineTextSelection(schema: FieldEditorSchemaLike | null | undefined): boolean;
922
+ declare function supportsInlineMarks(schema: FieldEditorSchemaLike | null | undefined): boolean;
923
+ declare function supportsInlineInputRules(schema: FieldEditorSchemaLike | null | undefined): boolean;
924
+ declare function delegatesToGridEditing(schema: FieldEditorSchemaLike | null | undefined): boolean;
925
+ declare function hasFieldEditorSurface(schema: FieldEditorSchemaLike | null | undefined): boolean;
926
+
927
+ declare function resolveEditorMessage<K extends MessageKey>(editor: Editor, key: K, ...args: MessageArgs<K>): string;
928
+
929
+ declare const A11Y_MISSING_LABEL_CODE = "a11y-missing-label";
930
+ interface EditorA11yLabelAttrs {
931
+ "aria-label"?: string;
932
+ "aria-labelledby"?: string;
933
+ }
934
+ declare function resolveEditorA11yLabel(editor: Editor): EditorA11yLabelAttrs;
935
+
936
+ declare function announceEditorA11y<K extends A11yMessageKey>(editor: Editor, key: K, ...args: MessageArgs<`pen.a11y.${K}` & MessageKey>): void;
937
+ declare function resolveA11yBlockTypeLabel(editor: Editor, type: string): string;
938
+
939
+ type SchemaA11yKind = "block" | "inline";
940
+ type SchemaA11yAttrs = {
941
+ label: string;
942
+ roleDescription?: string;
943
+ };
944
+ declare function resolveSchemaA11y(editor: Editor, target: {
945
+ kind: SchemaA11yKind;
946
+ type: string;
947
+ props: Record<string, unknown>;
948
+ }): SchemaA11yAttrs;
949
+ declare function resolveA11ySpec(spec: BlockA11ySpec | undefined, type: string, props: Record<string, unknown>, editor?: Editor): SchemaA11yAttrs;
950
+
951
+ declare const PSEUDO_LOCALE_OPEN = "[[";
952
+ declare const PSEUDO_LOCALE_CLOSE = " \u00B7\u00B7\u00B7]]";
953
+ declare function toPseudoLocaleText(text: string): string;
954
+ declare function createPseudoLocaleCatalog(catalog?: MessageCatalog): MessageCatalog;
955
+ declare function isPseudoLocaleText(text: string): boolean;
956
+
957
+ declare const HOOK_PRIORITIES: {
958
+ readonly AUTH: 100;
959
+ readonly SUGGEST: 200;
960
+ readonly INPUT_RULE: 300;
961
+ readonly DEFAULT: 500;
962
+ };
963
+ declare function priorityToPrecedence(priority: number): Precedence;
964
+ declare function hookPriorityToPrecedence(priority: number): Precedence;
965
+ declare function keyBindingPriorityToPrecedence(priority: number): Precedence;
966
+
967
+ declare function singleController<T>(name: string): _input_pen_types.Facet<T, T | null>;
968
+ declare const fieldEditorHostFacet: _input_pen_types.Facet<unknown, unknown>;
969
+ declare const inputRulesEngineFacet: _input_pen_types.Facet<unknown, unknown>;
970
+ declare const undoRestoreControllerFacet: _input_pen_types.Facet<unknown, unknown>;
971
+ declare const undoMetadataControllerFacet: _input_pen_types.Facet<unknown, unknown>;
972
+ declare const undoManagerFacet: _input_pen_types.Facet<unknown, unknown>;
973
+ declare const aiInlineCompletionFacet: _input_pen_types.Facet<unknown, unknown>;
974
+ declare const aiControllerFacet: _input_pen_types.Facet<unknown, unknown>;
975
+ declare const aiInlineHistoryFacet: _input_pen_types.Facet<unknown, unknown>;
976
+ declare const aiReviewControllerFacet: _input_pen_types.Facet<unknown, unknown>;
977
+ declare const aiAutocompleteControllerFacet: _input_pen_types.Facet<unknown, unknown>;
978
+ declare const aiSuggestionsControllerFacet: _input_pen_types.Facet<unknown, unknown>;
979
+ declare const searchControllerFacet: _input_pen_types.Facet<unknown, unknown>;
980
+ declare const multiplayerControllerFacet: _input_pen_types.Facet<unknown, unknown>;
981
+ declare const snapshotsControllerFacet: _input_pen_types.Facet<unknown, unknown>;
982
+ declare const assetProviderFacet: _input_pen_types.Facet<unknown, unknown>;
983
+ declare const toolRuntimeFacet: _input_pen_types.Facet<unknown, unknown>;
984
+ declare const announcerFacet: _input_pen_types.Facet<unknown, unknown>;
985
+ declare const streamingTargetFacet: _input_pen_types.Facet<unknown, unknown>;
986
+
987
+ declare function affectedBlockIdsFromSummary(summary: Pick<ChangeSummary, "blockText" | "structural">, documentOrder?: readonly string[]): string[];
988
+
989
+ /**
990
+ * The splice helper is a function, not an algebra. `mapOffsetThroughSplices`
991
+ * is a pure convenience for derived-tier providers shifting per-block results
992
+ * within **one** summary. Clamp semantics only. There is no `compose`, no
993
+ * multi-summary form, no map modes, and no cross-commit law: code that needs a
994
+ * position to survive more than one commit uses an anchor (I13).
995
+ */
996
+ declare function mapOffsetThroughSplices(splices: readonly TextSplice[], offset: number, assoc: Assoc): number;
997
+
998
+ export { A11Y_MISSING_LABEL_CODE, APPLY_STORM_CODE, APPLY_STORM_QUEUE_LIMIT, type BeforeApplyHook, type BlockDirection, type BlockDirectionResolver, type BlockDirectionSetting, type CaretMotionParam, type CellCaretFocus, type CellCaretWrite, type ClipboardHandler, type CommandDispatchContext, type CommandHandlerTable, type CommandRegistry, type ContentMove, type ConvertBlockParam, type CreateCommandRegistryOptions, type CreateFacetRegistryOptions, type CreateHeadlessEditorOptions, type DecorationSource, type DefaultKeymapBinding, type DefaultKeymapContext, type DefinedBlockSchema, type DeleteGranularity, type DeleteParam, type DocumentMigration, DocumentRangeImpl, type EditorA11yLabelAttrs, EventEmitter, ExtensionManagerImpl, type FacetRegistry, type FacetSettleInput, HOOK_PRIORITIES, type InsertTextParam, type Keymap, type KeymapPlatform, type MigrationReport, type NormalPositionSnapshot, PIPELINE_PHASES, PSEUDO_LOCALE_CLOSE, PSEUDO_LOCALE_OPEN, type PendingBlock, type PendingBlockImportPolicyViolation, type PendingBlockProfilePolicyViolation, type ProfilePolicyViolation, type SchemaA11yAttrs, type SchemaA11yKind, SchemaEngineImpl, type SchemaRegistryConfig, SchemaRegistryImpl, type SelectBlockParam, SelectionAuthorityImpl as SelectionAuthority, type StructureBlockParam, type ToggleMarkParam, type UrlContext, type UrlPolicy, type VerticalCaretDirection, type VerticalCaretMeasure, type VerticalCaretMeasureResult, type VerticalCaretPoint, type WordRange, a11yLabelFacet, affectedBlockIdsFromSummary, aiAutocompleteControllerFacet, aiControllerFacet, aiEgressExtension, aiEgressFacet, aiInlineCompletionFacet, aiInlineHistoryFacet, aiReviewControllerFacet, aiSuggestionsControllerFacet, announceEditorA11y, announcerFacet, applyDirectedBinding, applyMergeBlocks, applySplitBlock, ariaReadOnlyFacet, assetProviderFacet, beforeApplyFacet, blockDirectionFacet, blockLogicalText, blocksToOps, buildMergeBlocksRecipe, buildNormalPositionSnapshot, buildSplitBlockRecipe, buildTableChildren, builtinCommandHandlers, caretBlockEnd, caretBlockStart, caretDocEnd, caretDocStart, caretDown, caretLeft, caretLineEnd, caretLineStart, caretRight, caretUp, caretWordLeft, caretWordRight, clipboardFacet, collectEditorKeyBindings, collectToolExecutionOutput, commandHandler, commandsFacet, convertBlock, convertBlockOps, createAppHandle, createBlockHandle, createCommandRegistry, createDecorationSet, createDocumentSession, createEditor, createEmptySchema, createFacetRegistry, createHeadlessEditor, createImportResult, createMutationGroupMetadata, createPseudoLocaleCatalog, createTextSelection, decorationsFacet, deepEqual, defaultDirectionFacet, defaultKeymapBindings, defineBlock, defineCommand, defineExtension, defineFacet, delegatesToGridEditing, deleteAdjacentInlineAtom, deleteBackward, deleteBlock, deleteForward, deriveContentMoves, duplicateBlock, emptyDecorationSet, ensureInlineCompletionController, fieldEditorHostFacet, filterAIRequest, filterOpsForDocumentProfile, filterPendingBlocksForDocumentProfile, foldAndNormalize, getApplyOptionsGroupId, getBlockSelectionRoleFromSchema, getBlockSelectionRoleFromType, getCellCaretFocus, getCommandRegistry, getEditorSelectionRecord, getFlowCapabilityFromSchema, getFlowCapabilityFromType, getInlineCompletionController, getNumberedListItemValue, getOpOriginGroupId, getOpOriginType, getSelectionBlockRange, getVerticalCaretGoalX, getVerticalCaretMeasure, hasFieldEditorSurface, hasIndexedCellSelectionMetadata, historyRedo, historyUndo, hookPriorityToPrecedence, indent, inputRulesEngineFacet, inputRulesFacet, insertLineBreak, insertText, interpolateMessage, isBlockSelected, isCollapsed, isContinuousTextFlowCapability, isMultiBlock, isPseudoLocaleText, keyBindingPriorityToPrecedence, keymapFacet, localeFacet, mapOffsetThroughSplices, mergeDecorationSets, mergeSchemas, messagesFacet, moveBlockDown, moveBlockUp, multiplayerControllerFacet, nextGraphemeBoundary, nextWordBoundary, normalizePendingBlocksForImport, outdent, previousGraphemeBoundary, previousWordBoundary, priorityToPrecedence, prop, renderSelectionTargetBlockText, renderSelectionTargetText, repairAnchor, reportPendingBlockImportViolations, reportPendingBlockProfileViolations, resolveA11yBlockTypeLabel, resolveA11ySpec, resolveBlockDirection, resolveBlockFlowCapability, resolveCellSelectionCoord, resolveCellSelectionMatrix, resolveDefaultKeymap, resolveDirectedBinding, resolveDirectedCommand, resolveEditorA11yLabel, resolveEditorMessage, resolveEditorSchema, resolveFieldEditorBehavior, resolveFieldEditorInputMode, resolveFocusBlockDirection, resolveMessage, resolveSchema, resolveSchemaA11y, resolveSelectionTargetBlockIds, runMigrations, searchControllerFacet, selectAdjacentInlineAtom, selectAll, selectBlock, selectionToRange, setCellCaretFocus, setVerticalCaretGoalX, setVerticalCaretMeasure, shouldAllowDirectBlockPaste, shouldAllowFlowInsertionInSlashMenu, shouldExposeBlockInTooling, shouldForceBlockScopedSelectAll, shouldShowBlockInDefaultMenus, singleController, snapToNormalPosition, snapshotsControllerFacet, sortDeltaAttributes, spliceDeleteOp, spliceInsertOp, splitBlock, streamThroughEgress, streamingTargetFacet, suggestion, supportsInlineInputRules, supportsInlineMarks, tableCellDown, tableCellNext, tableCellPrev, tableEscapeGrid, toPseudoLocaleText, toggleMark, toolRuntimeFacet, undoManagerFacet, undoMetadataControllerFacet, undoRestoreControllerFacet, urlPolicy, urlPolicyFacet, usesInlineTextSelection, wordRangeAt };