@vscode/markdown-editor 0.0.2-3 → 0.0.2-30

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.
Files changed (34) hide show
  1. package/dist/_observables/observableInternal/index.d.ts +1 -1
  2. package/dist/_observables/observableInternal/logging/consoleObservableLogger.d.ts +1 -1
  3. package/dist/_observables/observableInternal/logging/debugger/devToolsLogger.d.ts +1 -1
  4. package/dist/_observables/observableInternal/logging/logging.d.ts +1 -1
  5. package/dist/_observables/observableInternal/reactions/{autorun.d.ts → createEffect.d.ts} +11 -3
  6. package/dist/config-Dvgk17FF.js +282 -0
  7. package/dist/config-Dvgk17FF.js.map +1 -0
  8. package/dist/config.d.ts +10 -0
  9. package/dist/config.js +6 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/index.d.ts +1049 -54
  12. package/dist/index.js +4196 -1870
  13. package/dist/index.js.map +1 -1
  14. package/dist/markdown-editor.css +1 -0
  15. package/dist/observables.js +45 -43
  16. package/dist/observables.js.map +1 -1
  17. package/dist/{runOnChange-C00UIwqQ.js → runOnChange-e7FtCqOQ.js} +115 -111
  18. package/dist/runOnChange-e7FtCqOQ.js.map +1 -0
  19. package/dist/stringEdit-DzLs4E1d.js +177 -0
  20. package/dist/stringEdit-DzLs4E1d.js.map +1 -0
  21. package/dist/web-editors.d.ts +125 -0
  22. package/dist/web-editors.js +5169 -0
  23. package/dist/web-editors.js.map +1 -0
  24. package/package.json +46 -9
  25. package/src/contrib/comments/commentInput.css +150 -0
  26. package/src/contrib/comments/comments.css +129 -0
  27. package/src/contrib/commentsVscode/vscodeCommentWidgetV2.css +171 -0
  28. package/src/view/editor.css +493 -20
  29. package/src/view/themes/default.css +11 -3
  30. package/src/view/themes/github.css +12 -8
  31. package/src/view/themes/vscode-default.css +355 -0
  32. package/src/view/themes/vscode-github.css +349 -0
  33. package/dist/runOnChange-C00UIwqQ.js.map +0 -1
  34. /package/dist/_observables/observableInternal/reactions/{autorunImpl.d.ts → createEffectImpl.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -6,10 +6,27 @@ import { ISettableObservable } from './_observables/index';
6
6
  import { ITransaction } from './_observables/index';
7
7
  import { MonarchTokenizer } from 'monaco-editor/esm/vs/editor/standalone/common/monarch/monarchLexer.js';
8
8
 
9
+ declare interface AddedItem {
10
+ readonly kind: 'added';
11
+ readonly node: AstNode;
12
+ readonly modifiedStart: number;
13
+ readonly insertedLocal: readonly AnnotatedRange[];
14
+ }
15
+
16
+ /**
17
+ * A word/character-level highlight inside a single block, in that block's
18
+ * *local* coordinate space (`0` = block start). `inserted` ranges live on a
19
+ * modified/added block, `deleted` ranges on an original/removed block.
20
+ */
21
+ declare interface AnnotatedRange {
22
+ readonly range: OffsetRange;
23
+ readonly kind: 'inserted' | 'deleted';
24
+ }
25
+
9
26
  /** Every concrete node kind, for exhaustive consumer-side dispatch. */
10
- export declare type AnyAstNode = TextAstNode | MarkerAstNode | GlueAstNode | ThematicBreakAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode | HeadingAstNode | ParagraphAstNode | CodeBlockAstNode | MathBlockAstNode | BlockQuoteAstNode | ListAstNode | ListItemAstNode | TableAstNode | TableRowAstNode | TableCellAstNode | DocumentAstNode;
27
+ export declare type AnyAstNode = TextAstNode | MarkerAstNode | GlueAstNode | ThematicBreakAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode | HeadingAstNode | ParagraphAstNode | CodeBlockAstNode | MathBlockAstNode | BlockQuoteAstNode | ListAstNode | ListItemAstNode | TableAstNode | TableRowAstNode | TableCellAstNode | DocumentAstNode | UnhandledBlockAstNode;
11
28
 
12
- declare type AnyViewData = DocumentViewData | BlockViewData | InlineViewData | ListItemViewData | TableRowViewData | TableCellViewData | MarkerViewData | GlueViewData;
29
+ declare type AnyViewData = DocumentViewData | BlockViewData | InlineViewData | ListItemViewData | TableRowViewData | TableCellViewData | MarkerViewData | GlueViewData | DiffHunkViewData | DiffDecorationViewData;
13
30
 
14
31
  export declare abstract class AstNode {
15
32
  abstract readonly kind: string;
@@ -71,7 +88,7 @@ export declare class AsyncClipboardStrategy implements IClipboardStrategy {
71
88
  connect(context: IClipboardContext): IDisposable;
72
89
  }
73
90
 
74
- export declare type BlockAstNode = HeadingAstNode | ParagraphAstNode | CodeBlockAstNode | MathBlockAstNode | ThematicBreakAstNode | BlockQuoteAstNode | ListAstNode | TableAstNode;
91
+ export declare type BlockAstNode = HeadingAstNode | ParagraphAstNode | CodeBlockAstNode | MathBlockAstNode | ThematicBreakAstNode | BlockQuoteAstNode | ListAstNode | TableAstNode | UnhandledBlockAstNode;
75
92
 
76
93
  /**
77
94
  * A block-level node. Every block may carry a {@link leadingTrivia} glue — the
@@ -92,7 +109,7 @@ declare abstract class BlockAstNodeBase extends AstNode {
92
109
  /**
93
110
  * One block's place in the rendered document.
94
111
  *
95
- * `height` is in CSS pixels. It is either a real DOM measurement
112
+ * Geometry is in editor-local CSS pixels. `height` is either a real DOM measurement
96
113
  * (`isMeasured: true`) or an estimate produced when the block is not
97
114
  * currently mounted (`isMeasured: false`). Estimates exist so virtual
98
115
  * rendering can size the scroll container without mounting every block.
@@ -107,6 +124,13 @@ export declare interface BlockMeasurement {
107
124
  readonly block: BlockAstNode;
108
125
  readonly absoluteStart: number;
109
126
  readonly height: number;
127
+ /** Local border box when mounted and measured. */
128
+ readonly rect: Rect2D | undefined;
129
+ /** Local horizontal padding-box clip when this block scrolls horizontally. */
130
+ readonly viewportClip: {
131
+ readonly left: number;
132
+ readonly right: number;
133
+ } | undefined;
110
134
  readonly isMeasured: boolean;
111
135
  readonly visualLineMap: VisualLineMap | undefined;
112
136
  readonly viewNode: ViewNode | undefined;
@@ -130,7 +154,7 @@ declare class BlockQuoteViewData {
130
154
  constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[]);
131
155
  }
132
156
 
133
- declare type BlockViewData = HeadingViewData | ParagraphViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData;
157
+ declare type BlockViewData = HeadingViewData | ParagraphViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData | UnhandledBlockViewData;
134
158
 
135
159
  /**
136
160
  * Base view node for everything the editor renders, generic over the
@@ -151,6 +175,17 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
151
175
  constructor(data: T, dom: globalThis.Node, children: readonly ViewNode[]);
152
176
  get block(): BlockAstNode;
153
177
  get element(): HTMLElement;
178
+ /**
179
+ * The horizontal scroll viewport for selection/caret clipping
180
+ * ({@link blockViewportClip}). For most blocks the scroller *is*
181
+ * {@link element} — a code / math / unhandled block's `element` is the very
182
+ * `overflow-x: auto` box that scrolls. A table is the exception: its
183
+ * `element` stays the inner `<table>` (so the active/markers classes and
184
+ * `.md-table` theme styling are unaffected), but the box that actually
185
+ * scrolls is the wrapping `.md-table-wrapper`, so {@link TableViewNode}
186
+ * overrides this to return that wrapper.
187
+ */
188
+ get scrollElement(): HTMLElement;
154
189
  /**
155
190
  * Whether this already-built node can stand in for `data` unchanged. The
156
191
  * builder preserves view-data identity for any subtree whose ast and
@@ -174,9 +209,10 @@ export declare interface BlockViewOptions {
174
209
  /**
175
210
  * Opens a link's URL. Called when the user activates a link: a plain click
176
211
  * while the link's block is inactive (rendered), or a Ctrl/Cmd+click while it
177
- * is active (source shown). Defaults to `window.open(url, '_blank')`.
212
+ * is active (source shown). Return `false` to use the anchor's native
213
+ * navigation behavior.
178
214
  */
179
- readonly onOpenLink?: (url: string, event: MouseEvent) => void;
215
+ readonly onOpenLink?: (url: string, event: MouseEvent) => false | void;
180
216
  /**
181
217
  * Colours fenced code blocks. When set, a code block's content is rendered
182
218
  * as a sequence of token spans instead of one plain text node. This is the
@@ -196,6 +232,22 @@ export declare interface BlockViewOptions {
196
232
  * `katexEditableIdentifiers.ts`).
197
233
  */
198
234
  readonly renderMath?: (request: MathRenderRequest) => MathRendering | undefined;
235
+ /**
236
+ * Pluggable factory for an in-place, interactive editor that replaces the
237
+ * *rendered* (inactive) form of a fenced code block — see
238
+ * {@link IEmbeddedCodeEditor}. When it returns an editor for the block's
239
+ * language, that editor's element is mounted instead of the highlighted
240
+ * code, and content flows both ways as string edits. Returning `undefined`
241
+ * falls back to the default rendering. EXPERIMENTAL.
242
+ */
243
+ readonly embeddedCodeEditorFactory?: IEmbeddedCodeEditorFactory;
244
+ /**
245
+ * Called when an {@link IEmbeddedCodeEditor} edits its content. `contentEdit`
246
+ * is in the block's *content* coordinates; the host translates it to a
247
+ * document edit (via {@link CodeBlockAstNode.codeOffset} and the block's
248
+ * offset) and applies it to the model.
249
+ */
250
+ readonly onEmbeddedCodeEditorEdit?: (block: CodeBlockAstNode, contentEdit: StringEdit) => void;
199
251
  }
200
252
 
201
253
  export declare class CodeBlockAstNode extends BlockAstNodeBase {
@@ -271,10 +323,241 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
271
323
  * its predecessor's subscription explicitly.
272
324
  */
273
325
  private _snapshotSub;
326
+ /**
327
+ * An in-place interactive editor (e.g. an iframe) mounted instead of the
328
+ * rendered code. Like {@link _session} it is adopted from `previous` across
329
+ * rebuilds so the underlying editor keeps its state, and must be disposed
330
+ * manually (a node reused as `previous` is never {@link dispose}d).
331
+ */
332
+ private _embeddedEditor;
274
333
  constructor(data: CodeBlockViewData, options: BlockViewOptions | undefined, previous: ViewNode | undefined);
275
334
  dispose(): void;
276
335
  }
277
336
 
337
+ /** A persistent comment anchored to a source range. */
338
+ declare interface Comment_2 {
339
+ readonly id: string;
340
+ /** Source range the comment refers to (its highlighted region). */
341
+ readonly range: OffsetRange;
342
+ /** The comment text. */
343
+ readonly body: string;
344
+ /** Display name of the author, if any. */
345
+ readonly author?: string;
346
+ /** Creation time (epoch ms), used to render a relative timestamp. */
347
+ readonly createdAt?: number;
348
+ }
349
+ export { Comment_2 as Comment }
350
+
351
+ /**
352
+ * A self-contained comment input box — a rounded panel with an auto-growing
353
+ * textarea and a send button, styled after the gdocs/Word "add a comment"
354
+ * affordance.
355
+ *
356
+ * This widget is *positioning-agnostic*: it only owns its own DOM and state.
357
+ * A host (the comment-mode controller, or a fixture) mounts {@link element}
358
+ * wherever it likes and is responsible for placing it relative to a selection.
359
+ *
360
+ * State is observable-driven (no framework): {@link value} reflects the live
361
+ * textarea content; submit/cancel are reported through the option callbacks.
362
+ */
363
+ export declare class CommentInputWidget extends Disposable {
364
+ private readonly _options?;
365
+ readonly element: HTMLElement;
366
+ private readonly _textarea;
367
+ private readonly _measure;
368
+ private readonly _submitButton;
369
+ private readonly _value;
370
+ /** Live, untrimmed textarea content. */
371
+ get value(): IObservable<string>;
372
+ /** The raw textarea, exposed so a host can move focus into it (e.g. on Tab). */
373
+ get inputElement(): HTMLTextAreaElement;
374
+ constructor(_options?: CommentInputWidgetOptions | undefined);
375
+ /** Move focus into the textarea (caret at the end). */
376
+ focus(): void;
377
+ /** Replace the textarea content. */
378
+ setText(text: string): void;
379
+ /** Clear the textarea. */
380
+ clear(): void;
381
+ private _submit;
382
+ private _autoSize;
383
+ }
384
+
385
+ export declare interface CommentInputWidgetOptions {
386
+ /** Placeholder shown while the textarea is empty. Defaults to "Add Comment". */
387
+ readonly placeholder?: string;
388
+ /** Called after the textarea changes size. */
389
+ readonly onDidChangeSize?: () => void;
390
+ /**
391
+ * Called when the user submits a non-empty comment (Enter or the send
392
+ * button). The text is trimmed; never called with an empty string.
393
+ */
394
+ readonly onSubmit?: (text: string) => void;
395
+ /** Called when the user dismisses the input (Escape). */
396
+ readonly onCancel?: () => void;
397
+ }
398
+
399
+ /**
400
+ * Comment mode — a gdocs/Word-style "add a comment" affordance layered on top of
401
+ * the editor *without modifying it*. It reads the editor's public observables
402
+ * ({@link EditorModel.readonlyMode}, {@link EditorModel.selection}) and the
403
+ * exposed {@link EditorView.caretRect} geometry, and mounts a
404
+ * {@link CommentInputWidget} into {@link EditorView.overlayContainer}.
405
+ *
406
+ * Behaviour:
407
+ * - Only active in read-only mode (the "review" view).
408
+ * - When the selection is non-empty, the input box appears next to the caret
409
+ * (the selection's active end) but does NOT take focus, so keyboard selection
410
+ * keeps working. Press Tab to move focus into the box, then type.
411
+ * - The box appears on mouse-up, not mid-drag, so it doesn't flicker/jump
412
+ * while a selection is being dragged out (keyboard selection shows at once).
413
+ * - While the box has focus or holds a draft it is frozen in place (selection
414
+ * changes, drags and clicks no longer move it). It is dismissed by Escape,
415
+ * by submitting, or by blurring an empty box.
416
+ * - The editor's logical caret geometry remains available for anchoring in
417
+ * read-only mode even though the painted caret is hidden. While the box has
418
+ * focus, `.md-comment-active` also suppresses the painted caret in any mode.
419
+ */
420
+ export declare class CommentModeController extends Disposable {
421
+ private readonly _model;
422
+ private readonly _view;
423
+ private readonly _options?;
424
+ private readonly _widget;
425
+ private readonly _gap;
426
+ private _visible;
427
+ private _anchorX;
428
+ private _pinnedRange;
429
+ /**
430
+ * The range a comment was just submitted for. The box stays hidden for it
431
+ * until the selection changes, so submitting doesn't immediately re-summon an
432
+ * empty box on the still-selected text.
433
+ */
434
+ private _submittedRange;
435
+ constructor(_model: EditorModel, _view: EditorView, _options?: CommentModeControllerOptions | undefined);
436
+ private _update;
437
+ private _show;
438
+ private _layoutHorizontally;
439
+ /** Force-hide and clear the box (used by Escape and submit). */
440
+ private _hide;
441
+ /**
442
+ * Hide unless the user is engaged with the box: it has focus or holds a
443
+ * non-empty draft. This preserves in-progress text and keeps a focused box
444
+ * open (it is dismissed explicitly via Escape/submit, or by blurring it).
445
+ */
446
+ private _autoHide;
447
+ private _widgetHasFocus;
448
+ /**
449
+ * The visible viewport (client coords) used for the flip-above decision: the
450
+ * nearest scrollable ancestor of the editor. `.md-editor` itself spans the
451
+ * full document height and never clips, so measuring against it would always
452
+ * report room below. Falls back to the window when nothing scrolls.
453
+ */
454
+ private _getViewportRect;
455
+ private _hideAndRefocus;
456
+ private _submit;
457
+ }
458
+
459
+ export declare interface CommentModeControllerOptions {
460
+ /** Called when the user submits a comment for the current selection. */
461
+ readonly onSubmit?: (submission: CommentSubmission) => void;
462
+ /** Gap (px) between the bottom of the selection and the top of the input box. */
463
+ readonly gap?: number;
464
+ }
465
+
466
+ /** Human-readable labels (for pickers / dropdowns). */
467
+ export declare const COMMENTS_DESIGN_LABELS: Record<CommentsDesign, string>;
468
+
469
+ /** design id → presenter factory over a shared CommentsModel + EditorView. */
470
+ export declare const COMMENTS_DESIGNS: Record<CommentsDesign, CommentsPresenterFactory>;
471
+
472
+ /** The available comment rendering designs. */
473
+ export declare type CommentsDesign = 'connected' | 'vscode' | 'vscode-v2';
474
+
475
+ /**
476
+ * Seedable store of {@link Comment}s for the comment-mode contribution. Owns the
477
+ * comment list and the shared hover state; it has no opinion on rendering or
478
+ * persistence — a host seeds it via {@link set}/{@link add} and observes
479
+ * {@link comments}.
480
+ */
481
+ export declare class CommentsModel {
482
+ private readonly _comments;
483
+ /** Monotonic counter for ids of comments created via {@link create}. */
484
+ private _sequence;
485
+ /** The current comments, in insertion order. */
486
+ get comments(): IObservable<readonly Comment_2[]>;
487
+ /**
488
+ * The comment currently hovered (by its card or its highlight), or
489
+ * `undefined`. Shared so the card and the highlight can react together.
490
+ */
491
+ readonly hoveredId: ISettableObservable<string | undefined>;
492
+ /** Replace the whole comment set. */
493
+ set(comments: readonly Comment_2[]): void;
494
+ /**
495
+ * Create a comment from a user submission and append it, generating its `id`
496
+ * and `createdAt` here so id/time allocation stays the store's concern (the
497
+ * UI only supplies the range and text). Returns the created comment.
498
+ */
499
+ create(input: {
500
+ range: OffsetRange;
501
+ body: string;
502
+ author?: string;
503
+ }): Comment_2;
504
+ /** Append a comment. */
505
+ add(comment: Comment_2): void;
506
+ /** Remove a comment by id. */
507
+ remove(id: string): void;
508
+ }
509
+
510
+ /** Optional, design-specific context a presenter may use (ignored by others). */
511
+ export declare interface CommentsPresenterContext {
512
+ /** Light/dark hint for the token-wrapped VS Code widget designs. */
513
+ readonly theme?: 'light' | 'dark';
514
+ /**
515
+ * Resolves a source offset to a 1-based line number, for designs that show
516
+ * line info (the VS Code V1 card). Optional because the model itself carries
517
+ * no text; the host (which owns the source) supplies it.
518
+ */
519
+ readonly resolveLine?: (offset: number) => number;
520
+ }
521
+
522
+ /** Builds a presenter for a given model + editor view. */
523
+ export declare type CommentsPresenterFactory = (model: CommentsModel, view: EditorView, context?: CommentsPresenterContext) => ICommentsPresenter;
524
+
525
+ /** A comment the user submitted, with the source range it was anchored to. */
526
+ export declare interface CommentSubmission {
527
+ readonly text: string;
528
+ readonly range: OffsetRange;
529
+ }
530
+
531
+ /**
532
+ * Renders persistent comments as a gdocs-style side rail: each comment's range
533
+ * is highlighted (reusing the editor's selection geometry via
534
+ * {@link EditorView.rangeRects}), a leader line curves from the bottom of that
535
+ * highlight to a card stacked in the right rail, and cards never overlap.
536
+ *
537
+ * Everything is mounted into {@link EditorView.overlayContainer} so it shares
538
+ * the selection/caret coordinate space and scrolls with the document. When the
539
+ * editor's natural right margin is too narrow for the rail, the view reserves
540
+ * proportional space by padding the editor on the right — but only while there
541
+ * are comments.
542
+ */
543
+ export declare class CommentsView extends Disposable {
544
+ private readonly _model;
545
+ private readonly _view;
546
+ private readonly _layer;
547
+ private readonly _entries;
548
+ constructor(_model: CommentsModel, _view: EditorView);
549
+ private _createLayer;
550
+ private _update;
551
+ /** Create/update/remove per-comment DOM to match `comments`. */
552
+ private _reconcile;
553
+ private _createEntry;
554
+ private _fillCard;
555
+ private _disposeEntry;
556
+ /** Position highlights, cards (stacked) and leader lines. */
557
+ private _layout;
558
+ private _applyHover;
559
+ }
560
+
278
561
  /**
279
562
  * A {@link MonacoSyntaxHighlighter} preloaded with a handful of common Monarch
280
563
  * grammars (plus the usual short aliases). Unknown languages fall back to an
@@ -292,6 +575,8 @@ export declare interface CursorCommandContext {
292
575
  readonly selection: Selection_2;
293
576
  readonly document: DocumentAstNode;
294
577
  readonly activeBlock: BlockAstNode | undefined;
578
+ readonly markerVisibleBlocks: ReadonlySet<BlockAstNode>;
579
+ readonly wordNavigationConfig: WordNavigationConfig;
295
580
  }
296
581
 
297
582
  export declare const cursorDocumentEnd: CursorCommand;
@@ -300,6 +585,8 @@ export declare const cursorDocumentStart: CursorCommand;
300
585
 
301
586
  export declare const cursorDown: VisualCursorCommand;
302
587
 
588
+ export declare type CursorKeyboardAction = 'left' | 'right' | 'up' | 'down' | 'wordLeft' | 'wordRight' | 'visualLineStart' | 'visualLineEnd' | 'logicalLineStart' | 'logicalLineEnd' | 'documentStart' | 'documentEnd';
589
+
303
590
  export declare const cursorLeft: CursorCommand;
304
591
 
305
592
  export declare const cursorLineEnd: CursorCommand;
@@ -329,15 +616,27 @@ export declare const cursorUp: VisualCursorCommand;
329
616
  * derived subscribed.
330
617
  */
331
618
  export declare class CursorView extends Disposable {
332
- private readonly _parent;
333
619
  readonly element: HTMLElement;
334
620
  readonly rendering: IObservable<CursorViewRendering>;
335
- constructor(_parent: HTMLElement, options: CursorViewOptions);
621
+ constructor(options: CursorViewOptions);
336
622
  }
337
623
 
338
624
  export declare interface CursorViewOptions {
339
625
  readonly offset: IObservable<SourceOffset | undefined>;
340
626
  readonly visualLineMap: IObservable<VisualLineMap>;
627
+ /**
628
+ * The mounted blocks, used to hide the caret when it sits at an offset that
629
+ * has been scrolled out of its (horizontally scrolling) block's viewport —
630
+ * matching how the selection is clipped there.
631
+ */
632
+ readonly blocks?: IObservable<readonly SelectionBlock[]>;
633
+ /**
634
+ * When set, the caret is drawn over the transient empty paragraph instead
635
+ * of at {@link offset} — its editor-local rect comes straight
636
+ * from that synthetic element's geometry, since it has no visual-line-map
637
+ * entry. Takes priority over the normal offset-based placement.
638
+ */
639
+ readonly pendingCaretRect?: IObservable<Rect2D | undefined>;
341
640
  }
342
641
 
343
642
  export declare class CursorViewRendering {
@@ -347,18 +646,98 @@ export declare class CursorViewRendering {
347
646
  constructor(offset: SourceOffset, visible: boolean, rect: Rect2D);
348
647
  }
349
648
 
649
+ export declare const cursorVisualLineEnd: VisualCursorCommand;
650
+
651
+ export declare const cursorVisualLineStart: VisualCursorCommand;
652
+
350
653
  export declare const cursorWordLeft: CursorCommand;
351
654
 
352
655
  export declare const cursorWordRight: CursorCommand;
353
656
 
657
+ export declare const DEFAULT_WORD_NAVIGATION_CONFIG: WordNavigationConfig;
658
+
659
+ export declare const DEFAULT_WORD_SEPARATORS = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";
660
+
354
661
  export declare const deleteLeft: EditCommand;
355
662
 
663
+ export declare const deleteLineLeft: EditCommand;
664
+
665
+ export declare const deleteLineRight: EditCommand;
666
+
356
667
  export declare const deleteRight: EditCommand;
357
668
 
358
669
  export declare const deleteWordLeft: EditCommand;
359
670
 
360
671
  export declare const deleteWordRight: EditCommand;
361
672
 
673
+ /**
674
+ * A read-only "removed" decoration: an original block rendered (red) above its
675
+ * place in the modified document, occupying vertical space like a view-zone but
676
+ * contributing **zero** source length, so the editor's source mapping stays the
677
+ * modified document and editing is unaffected. Used for `removed` and the
678
+ * original side of a `replaced` block in editor diff mode.
679
+ */
680
+ declare class DiffDecorationViewData {
681
+ readonly ast: AstNode;
682
+ readonly side: BlockViewData;
683
+ readonly deletedRanges: readonly DiffHighlightRange[];
684
+ /** True when the whole block was removed: solid red band, no word rects. */
685
+ readonly whole: boolean;
686
+ /** Absolute offset of this block in the *original* document. */
687
+ readonly originalStart: number;
688
+ readonly kind = "diffDecoration";
689
+ constructor(ast: AstNode, side: BlockViewData, deletedRanges: readonly DiffHighlightRange[],
690
+ /** True when the whole block was removed: solid red band, no word rects. */
691
+ whole: boolean,
692
+ /** Absolute offset of this block in the *original* document. */
693
+ originalStart: number);
694
+ }
695
+
696
+ /** A word/character highlight inside one diff side, in block-local coords. */
697
+ declare interface DiffHighlightRange {
698
+ readonly range: OffsetRange;
699
+ readonly kind: 'inserted' | 'deleted';
700
+ }
701
+
702
+ /**
703
+ * A changed block rendered as its original form stacked over its modified form
704
+ * (either side may be absent for a pure deletion/insertion). It is itself a
705
+ * document child the renderer mounts like a block; its {@link ast} is the
706
+ * surviving side's ast, used only for view-node identity/reuse.
707
+ */
708
+ declare class DiffHunkViewData {
709
+ readonly ast: AstNode;
710
+ readonly original: DiffSideViewData | undefined;
711
+ readonly modified: DiffSideViewData | undefined;
712
+ readonly kind = "diffHunk";
713
+ constructor(ast: AstNode, original: DiffSideViewData | undefined, modified: DiffSideViewData | undefined);
714
+ }
715
+
716
+ /**
717
+ * The recursive classification of a diff. Each item describes one aligned
718
+ * position in the merged document:
719
+ *
720
+ * - `unchanged` — render the (modified) node once, neutral.
721
+ * - `added` — exists only in the modified document (green).
722
+ * - `removed` — exists only in the original document (red).
723
+ * - `replaced` — a *leaf* block changed in place → render original over
724
+ * modified, with word-level {@link AnnotatedRange}s on each.
725
+ * - `nested` — a *container* changed → render it once and diff its
726
+ * {@link NestedItem.children} recursively.
727
+ *
728
+ * Offsets ({@link UnchangedItem.modifiedStart} etc.) are absolute in their
729
+ * respective documents, so a renderer/visualizer can slice the source text.
730
+ */
731
+ declare type DiffItem = UnchangedItem | AddedItem | RemovedItem | ReplacedItem | NestedItem;
732
+
733
+ /** One side (original or modified) of a {@link DiffHunkViewData}. */
734
+ declare interface DiffSideViewData {
735
+ readonly view: BlockViewData;
736
+ /** Render in active form (markers/whitespace visible). */
737
+ readonly active: boolean;
738
+ readonly ranges: readonly DiffHighlightRange[];
739
+ }
740
+
362
741
  export declare class DocumentAstNode extends AstNode {
363
742
  readonly content: readonly (BlockAstNode | GlueAstNode)[];
364
743
  readonly kind = "document";
@@ -383,13 +762,21 @@ declare interface DocumentBlockViewData {
383
762
  readonly view: BlockViewData;
384
763
  }
385
764
 
386
- /** A mounted document child: a block or a run of inter-block glue. */
765
+ /** A mounted document child: a block, a run of inter-block glue, the
766
+ * transient empty paragraph (see {@link PendingParagraphViewData}), or a
767
+ * {@link DiffHunkViewData diff hunk} (stacked original/modified blocks). */
387
768
  declare interface DocumentChildViewData {
388
769
  readonly absoluteStart: number;
389
770
  /** For a block: selection reaches it. For glue: always false (unowned, hidden). */
390
771
  readonly isActive: boolean;
391
- readonly view: BlockViewData | GlueViewData;
392
- readonly kind: 'block' | 'glue';
772
+ readonly view: BlockViewData | GlueViewData | PendingParagraphViewData | DiffHunkViewData | DiffDecorationViewData;
773
+ readonly kind: 'block' | 'glue' | 'pendingParagraph' | 'diffHunk' | 'diffDecoration';
774
+ /**
775
+ * Diff mode: how this (modified) block changed. `added` = a whole new block
776
+ * (strong green band, no inline rects); `modified` = a partial change (light
777
+ * band + inline rects on the changed words).
778
+ */
779
+ readonly diffKind?: 'added' | 'modified';
393
780
  }
394
781
 
395
782
  /**
@@ -445,6 +832,8 @@ declare class DocumentViewData {
445
832
  */
446
833
  export declare class DocumentViewNode extends ViewNode {
447
834
  readonly blocks: readonly DocumentBlock[];
835
+ /** The transient empty-paragraph element, when one is armed. */
836
+ readonly pendingElement?: HTMLElement | undefined;
448
837
  static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
449
838
  private constructor();
450
839
  /** The stable content element this document mounts its children into. */
@@ -466,6 +855,8 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
466
855
  readonly selection: Selection_2;
467
856
  } | undefined;
468
857
 
858
+ export declare type EditKeyboardAction = 'deleteLeft' | 'deleteRight' | 'deleteWordLeft' | 'deleteWordRight' | 'deleteLineLeft' | 'deleteLineRight';
859
+
469
860
  /**
470
861
  * Translates raw browser input (mouse, keyboard, EditContext) into model
471
862
  * mutations. Knows about DOM event types but never reads/writes the DOM
@@ -474,14 +865,23 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
474
865
  *
475
866
  * Owns the only non-derivable controller state:
476
867
  * - `_desiredColumn` — sticky column for up/down navigation
868
+ * - `_clickCount` / `_lastPointerDown` — multi-click detection for pointer
869
+ * input, since `pointerdown` events (unlike `mousedown`) don't populate
870
+ * `detail` with a click count.
477
871
  */
478
872
  export declare class EditorController extends Disposable {
479
873
  private readonly _model;
480
874
  private readonly _view;
481
875
  private _desiredColumn;
876
+ private readonly _keyboardPlatform;
877
+ private readonly _keyboardProfile;
878
+ /** Running click count for the current multi-click sequence (1, 2, 3, …). */
879
+ private _clickCount;
880
+ /** Timestamp and position of the previous pointer-down, for multi-click detection. */
881
+ private _lastPointerDown;
482
882
  constructor(_model: EditorModel, _view: EditorView, options?: EditorControllerOptions);
483
883
  private readonly _handleTextUpdate;
484
- private readonly _handleMouseDown;
884
+ private readonly _handlePointerDown;
485
885
  private _makeCursorContext;
486
886
  private _makeVisualCursorContext;
487
887
  private _executeCursorCommand;
@@ -492,7 +892,34 @@ export declare class EditorController extends Disposable {
492
892
  /** Move the cursor up one visual line (Arrow Up). */
493
893
  cursorUp(extend?: boolean): void;
494
894
  private _selectedText;
895
+ private readonly _updateModifierState;
896
+ private readonly _clearModifierState;
897
+ /**
898
+ * Drop any native DOM selection over the rendered text.
899
+ *
900
+ * The editor paints selection from `model.selection`, so a browser
901
+ * selection there is always spurious: nothing reads it (copy/cut read the
902
+ * model, hit-testing uses the measured layout) and nothing clears it, so it
903
+ * lingers as a second highlight even after the caret moves away.
904
+ * {@link isCaretMotionKey} stops the common source synchronously; this is
905
+ * the backstop for the rest of the browser's editing commands, which are
906
+ * platform- and version-specific and cannot be enumerated (Shift+PageDown
907
+ * and macOS Shift+Ctrl+B both reach one today).
908
+ *
909
+ * Scoped twice so it only ever discards selections the editor owns: the
910
+ * range must touch the rendered text (overlays such as comment widgets sit
911
+ * beside it and stay selectable), and input focus must still be inside this
912
+ * editor (so a host find-in-page, which selects while its own input is
913
+ * focused, is left alone).
914
+ */
915
+ private readonly _discardNativeSelection;
495
916
  private readonly _handleKeyDown;
917
+ private _executeKeyboardAction;
918
+ /**
919
+ * Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
920
+ * arms a transient empty paragraph when at the end of a paragraph.
921
+ */
922
+ private _smartEnter;
496
923
  }
497
924
 
498
925
  /** Options for an {@link EditorController}. */
@@ -503,8 +930,52 @@ export declare interface EditorControllerOptions {
503
930
  * strategy (e.g. `AsyncClipboardStrategy`) in hosts that swallow them.
504
931
  */
505
932
  readonly clipboardStrategy?: IClipboardStrategy;
933
+ readonly keyboardPlatform?: KeyboardPlatform;
934
+ readonly keyboardProfile?: KeyboardProfile;
506
935
  }
507
936
 
937
+ /**
938
+ * The editor overlay's local CSS-pixel coordinate space.
939
+ *
940
+ * Browser geometry and pointer APIs expose viewport client coordinates. This
941
+ * boundary converts them immediately into the coordinate system shared by the
942
+ * editor content and its overlays. Range rectangles are axis-aligned, so the
943
+ * current implementation deliberately supports positive axis-aligned scale and
944
+ * translation only.
945
+ */
946
+ export declare class EditorCoordinateSpace {
947
+ private readonly _getLocalToClientMatrix;
948
+ static forSvgOverlay(overlay: SVGSVGElement): EditorCoordinateSpace;
949
+ private constructor();
950
+ capture(): EditorCoordinateTransform;
951
+ }
952
+
953
+ /** A stable coordinate conversion captured for one measurement operation. */
954
+ export declare class EditorCoordinateTransform {
955
+ private readonly _localToClient;
956
+ private readonly _clientToLocal;
957
+ constructor(_localToClient: DOMMatrix);
958
+ toLocalPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
959
+ toClientPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
960
+ toLocalRect(rect: Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>): Rect2D;
961
+ toClientRect(rect: Pick<Rect2D, 'left' | 'top' | 'width' | 'height'>): Rect2D;
962
+ private _convertRect;
963
+ }
964
+
965
+ export declare type EditorKeyboardAction = {
966
+ readonly kind: 'cursor';
967
+ readonly command: CursorKeyboardAction;
968
+ readonly extend: boolean;
969
+ } | {
970
+ readonly kind: 'edit';
971
+ readonly command: EditKeyboardAction;
972
+ } | {
973
+ readonly kind: 'selectAll';
974
+ } | {
975
+ readonly kind: 'enter';
976
+ readonly command: 'smartEnter' | 'insertParagraph' | 'insertHardLineBreak';
977
+ };
978
+
508
979
  export declare class EditorModel {
509
980
  private readonly _parser;
510
981
  /**
@@ -515,11 +986,44 @@ export declare class EditorModel {
515
986
  */
516
987
  private _pendingEdit;
517
988
  readonly sourceText: ISettableObservable<StringValue, void>;
989
+ readonly wordNavigationConfig: ISettableObservable<WordNavigationConfig, void>;
990
+ /**
991
+ * Read-only mode. When `true`, the editor never reveals a block's source
992
+ * markers (markdown special characters like `**`, `#`, list bullets, code
993
+ * fences, `$…$`) — every block stays in its clean rendered form regardless
994
+ * of where the caret/selection is — and source-mutating edits are ignored.
995
+ * Plain text selection still works everywhere (so the user can copy). The
996
+ * default (`false`) is the normal editing mode where the active block
997
+ * reveals its markers.
998
+ */
999
+ readonly readonlyMode: ISettableObservable<boolean, void>;
518
1000
  /**
519
1001
  * The current selection, or `undefined` when the editor has no caret
520
1002
  * (e.g. an inactive/unfocused rendering).
521
1003
  */
522
1004
  readonly selection: ISettableObservable<Selection_2 | undefined, void>;
1005
+ /**
1006
+ * Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
1007
+ * live keyboard state; the view reads it to show the link-open affordance
1008
+ * (underline + pointer cursor) only while a Ctrl/Cmd+click would open a link
1009
+ * whose block is active.
1010
+ */
1011
+ readonly ctrlOrMetaDown: ISettableObservable<boolean, void>;
1012
+ /**
1013
+ * Whether a pointer-driven selection drag is currently in progress. Set by
1014
+ * the controller between the pointer-down that starts the drag and the
1015
+ * pointer-up/cancel that ends it. Contributions read it to defer UI that
1016
+ * would otherwise flicker mid-drag (e.g. the comment input box appears only
1017
+ * once the drag ends).
1018
+ */
1019
+ readonly isSelecting: ISettableObservable<boolean, void>;
1020
+ /**
1021
+ * Gutter markers (source-control style change indicators) painted in the
1022
+ * left gutter. Each entry maps a source {@link OffsetRange} to a change kind
1023
+ * — see {@link GutterMarker}. Purely decorative: markers never affect the
1024
+ * parsed {@link document}, selection, or layout. Empty by default.
1025
+ */
1026
+ readonly gutterMarkers: ISettableObservable<readonly GutterMarker[], void>;
523
1027
  /**
524
1028
  * Forces the rendered active-block set. `undefined` (the default)
525
1029
  * derives the set from the current selection range (see
@@ -528,6 +1032,13 @@ export declare class EditorModel {
528
1032
  * collapsed/inactive rendering.
529
1033
  */
530
1034
  readonly activeBlocksOverride: ISettableObservable<readonly BlockAstNode[] | typeof NO_ACTIVE_BLOCKS | undefined, void>;
1035
+ /**
1036
+ * The transient empty-paragraph editing state, or `undefined` when none is
1037
+ * armed. See {@link PendingParagraph}. This is *not* document data — it is
1038
+ * cleared by any source edit and lives only between the Enter that armed it
1039
+ * and the next keystroke.
1040
+ */
1041
+ readonly pendingParagraph: ISettableObservable<PendingParagraph | undefined, void>;
531
1042
  readonly cursorOffset: IObservableWithChange<number | undefined, void>;
532
1043
  /**
533
1044
  * The parsed document. Threads the previous document into the parser so
@@ -551,7 +1062,45 @@ export declare class EditorModel {
551
1062
  * collapsed this is a one-element set holding {@link activeBlock}.
552
1063
  */
553
1064
  readonly activeBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
554
- applyEdit(edit: StringEdit): void;
1065
+ /**
1066
+ * The baseline document to diff against. When set, the editor renders in
1067
+ * diff mode: the modified document ({@link document}) stays editable, while
1068
+ * the baseline's removed/changed blocks are shown as read-only decorations.
1069
+ * `undefined` (the default) renders normally.
1070
+ */
1071
+ readonly baseline: ISettableObservable<StringValue | undefined, void>;
1072
+ private readonly _baselineDocument;
1073
+ /**
1074
+ * The diff of {@link baseline} → {@link document}, or `undefined` when no
1075
+ * baseline is set. The view renders the {@link DiffItem}s as stacked
1076
+ * decorations; `insertedRanges` (modified-side change spans) drive the green
1077
+ * word-level highlight.
1078
+ */
1079
+ readonly diff: IObservableWithChange< {
1080
+ items: DiffItem[];
1081
+ insertedRanges: OffsetRange[];
1082
+ changedBlocks: Set<BlockAstNode>;
1083
+ } | undefined, void>;
1084
+ readonly markerVisibleBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1085
+ /**
1086
+ * Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
1087
+ * AST node for it, and park the caret at the gap start. No source edit is
1088
+ * applied — the blank line exists only in the view until it is materialized.
1089
+ */
1090
+ armPendingParagraph(req: {
1091
+ anchorBlock: BlockAstNode;
1092
+ replaceRange: OffsetRange;
1093
+ atEof: boolean;
1094
+ }): void;
1095
+ /** Discard the pending paragraph (if any) without touching the source. */
1096
+ cancelPendingParagraph(): void;
1097
+ /**
1098
+ * Turn the pending paragraph into real source: rewrite its gap so the typed
1099
+ * `text` becomes its own paragraph, separated from its neighbours by blank
1100
+ * lines, and place the caret after the inserted text.
1101
+ */
1102
+ materializePendingParagraph(text: string): void;
1103
+ applyEdit(edit: StringEdit, selection?: Selection_2): void;
555
1104
  applyEditForSelection(edit: StringEdit): void;
556
1105
  }
557
1106
 
@@ -584,6 +1133,7 @@ export declare class EditorView extends Disposable {
584
1133
  readonly element: HTMLElement;
585
1134
  readonly editContext: EditContext;
586
1135
  readonly measuredLayout: MeasuredLayoutModel;
1136
+ readonly coordinateSpace: EditorCoordinateSpace;
587
1137
  /**
588
1138
  * Inner container that holds the rendered document and the cursor/selection
589
1139
  * overlays. The outer {@link element} spans the full width; this container
@@ -593,6 +1143,9 @@ export declare class EditorView extends Disposable {
593
1143
  private readonly _contentContainer;
594
1144
  private readonly _cursorView;
595
1145
  private readonly _selectionView;
1146
+ private readonly _gutterMarkersView;
1147
+ private readonly _diffHighlightsView;
1148
+ private _readonlyToggleButton;
596
1149
  /**
597
1150
  * The mounted block sequence, in source order. Rebuilt (not mutated) each
598
1151
  * frame by {@link DocumentViewNode.create}; the view just swaps one
@@ -612,20 +1165,117 @@ export declare class EditorView extends Disposable {
612
1165
  /** The current view-data tree (AST overlaid with selection flags), for debugging. */
613
1166
  private readonly _viewData;
614
1167
  get viewData(): IObservable<DocumentViewData | undefined>;
1168
+ /**
1169
+ * Whether the editor is genuinely focused: focus rests somewhere inside the
1170
+ * editor subtree *and* its window is focused. Mirrored onto the root as
1171
+ * `.md-focused`, which gates the painted caret — the blinking cursor is only
1172
+ * shown while this is `true`, so it never blinks in an unfocused editor or
1173
+ * after the window loses focus. Only the caret's visibility is affected; the
1174
+ * logical selection and caret geometry ({@link caretRect}) are unchanged.
1175
+ */
1176
+ private readonly _focused;
1177
+ get focused(): IObservable<boolean>;
1178
+ /**
1179
+ * Caret rect (editor-local coordinates) for the transient empty paragraph, or
1180
+ * `undefined` when none is armed. Set each frame from the synthetic
1181
+ * paragraph element's geometry and fed to the {@link CursorView}, which has
1182
+ * no visual-line-map entry to place the caret from otherwise.
1183
+ */
1184
+ private readonly _pendingCaretRect;
615
1185
  /**
616
1186
  * The block cache projected for views (selection painting) that need to
617
1187
  * react to mount/unmount. Derived from {@link _document}, so it stays in
618
1188
  * lock-step without any manual bookkeeping.
619
1189
  */
620
1190
  private readonly _selectionBlocksObs;
1191
+ /**
1192
+ * The caret rect (zero width) at the selection's active end, in
1193
+ * {@link overlayContainer}-local coordinates, or `undefined` when there is no
1194
+ * caret. This is the same geometry the editor paints its cursor from, so
1195
+ * contributions (e.g. comment mode) can anchor an overlay to the active end of
1196
+ * the selection — where the user's cursor is — without re-deriving geometry.
1197
+ */
1198
+ private readonly _caretRect;
1199
+ get caretRect(): IObservable<Rect2D | undefined>;
1200
+ /**
1201
+ * The container that establishes the positioning context for the editor's
1202
+ * overlays (cursor, selection, gutter). Contributions mount their own
1203
+ * absolutely-positioned overlays here so they share the coordinate space of
1204
+ * {@link caretRect}.
1205
+ */
1206
+ get overlayContainer(): HTMLElement;
1207
+ /**
1208
+ * Selection-style rectangles covering `range`, in {@link overlayContainer}-
1209
+ * local coordinates — the same geometry the live selection paints. Exposed so
1210
+ * contributions (e.g. persistent comments) can highlight arbitrary ranges and
1211
+ * anchor overlays to them. Recomputes when the measured layout changes.
1212
+ */
1213
+ rangeRects(range: OffsetRange): IObservable<readonly SelectionRect[]>;
621
1214
  constructor(_model: EditorModel, _options?: EditorViewOptions | undefined);
1215
+ /**
1216
+ * Mirrors the model's live Ctrl/Cmd state onto the editor root as
1217
+ * `.md-mod-down` so CSS can show the link-open underline and pointer cursor
1218
+ * only while a click would actually open the link: an inactive link opens on
1219
+ * a plain click, but an active link only opens with the modifier held.
1220
+ */
1221
+ private _setupModifierTracking;
1222
+ /**
1223
+ * Tracks whether the editor is genuinely focused and mirrors it onto the
1224
+ * root as `.md-focused` so CSS can gate the painted caret. "Focused" means
1225
+ * focus rests somewhere inside the editor subtree *and* the window itself is
1226
+ * focused; either condition failing (focus moving elsewhere, or the window
1227
+ * losing focus) hides the blinking caret while leaving the logical selection
1228
+ * and caret geometry intact.
1229
+ */
1230
+ private _setupFocusTracking;
1231
+ /**
1232
+ * Renders the edit/read-only mode toggle. It flips the model's
1233
+ * {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
1234
+ * in its clean rendered form (no markdown markers revealed) and edits are
1235
+ * ignored, while text selection still works. The control lives in a
1236
+ * zero-height *sticky* host inside the centered content container, so the
1237
+ * lock follows the content's right edge and remains pinned as the document
1238
+ * scrolls. The current mode is also mirrored onto the root as `.md-readonly`
1239
+ * for any CSS hooks.
1240
+ */
1241
+ private _setupReadonlyToggle;
1242
+ /** Draws attention to the mode toggle after text input is attempted while locked. */
1243
+ showReadonlyEditingAttempt(): void;
622
1244
  focus(): void;
1245
+ /**
1246
+ * Focuses the editor when it opens, but only if doing so will not steal
1247
+ * focus from an explicit user target: the window must already be focused and
1248
+ * no other element may have claimed focus yet. Returns whether focus was
1249
+ * taken. Intended for the single editable editor on open; a no-op for a
1250
+ * background window or when the user has already focused something else.
1251
+ */
1252
+ tryAutoFocus(): boolean;
1253
+ /**
1254
+ * Own point→offset resolution. When `true` (the default),
1255
+ * {@link resolveOffsetFromPoint} ignores the platform DOM hit-test
1256
+ * (`caretPositionFromPoint`) and snaps the point to the nearest offset purely
1257
+ * from the rendered {@link VisualLineMap} geometry — picking the nearest
1258
+ * visual line by `y`, then the nearest offset on it by `x`. Because a table
1259
+ * row's cells share one horizontal line band, this makes the whole width of a
1260
+ * row resolve into that row (rather than only the cell boxes), with no visible
1261
+ * layout change. It also lets a drag keep extending toward off-viewport points
1262
+ * (e.g. the pointer leaving the window), which the platform hit-test cannot
1263
+ * resolve. Set to `false` to fall back to the platform DOM hit-test.
1264
+ */
1265
+ readonly geometricHitTest: ISettableObservable<boolean, void>;
623
1266
  /**
624
1267
  * Client coordinates → absolute source offset (any block). Used during
625
1268
  * drag to keep extending the selection even when the pointer leaves the
626
- * original block.
1269
+ * original block. Honours {@link geometricHitTest}.
627
1270
  */
628
1271
  resolveOffsetFromPoint(point: Point2D): SourceOffset | undefined;
1272
+ /**
1273
+ * Resolve table-cell hits that have no measurable text run. Empty cells map
1274
+ * from their own box instead of snapping to a neighboring cell; element-only
1275
+ * content (for example an inactive image) maps through the hit element's view
1276
+ * node. Text-bearing cells keep the normal pixel-precise line-map/DOM path.
1277
+ */
1278
+ private _resolveTableCellOffset;
629
1279
  /**
630
1280
  * Whether a client point falls on the rendered document content, as
631
1281
  * opposed to the surrounding editor padding (the green area). Uses DOM
@@ -635,6 +1285,13 @@ export declare class EditorView extends Disposable {
635
1285
  * have `pointer-events: none`, so the hit-test sees through them.
636
1286
  */
637
1287
  isPointInContent(point: Point2D): boolean;
1288
+ /**
1289
+ * Whether `node` sits inside the rendered source text — the region whose
1290
+ * selection this editor paints itself from `model.selection`. Overlays
1291
+ * anchored beside the text (comment widgets and the like) are *not* part of
1292
+ * it and keep their own native selection behaviour.
1293
+ */
1294
+ containsRenderedContent(node: Node | null | undefined): boolean;
638
1295
  private readonly _renderAutorun;
639
1296
  /** Current mounted blocks, or empty before the first render. */
640
1297
  private get _blocks();
@@ -644,6 +1301,15 @@ export declare class EditorView extends Disposable {
644
1301
  * is not read here, so there is no feedback loop into the render autorun.
645
1302
  */
646
1303
  private _publishMeasurements;
1304
+ /**
1305
+ * Paint the diff highlights via the CSS Custom Highlight API: green over the
1306
+ * inserted/changed modified ranges (mapped on the document's own DOM), and
1307
+ * red over each {@link DiffDecorationViewNode}'s deleted ranges (mapped on
1308
+ * the decoration's own subtree). No DOM is mutated, so reconciliation and
1309
+ * editing are unaffected.
1310
+ */
1311
+ private _paintDiff;
1312
+ private _clearDiff;
647
1313
  }
648
1314
 
649
1315
  export declare interface EditorViewOptions extends BlockViewOptions {
@@ -654,6 +1320,12 @@ export declare interface EditorViewOptions extends BlockViewOptions {
654
1320
  * only) unless a theme class is supplied.
655
1321
  */
656
1322
  readonly classNames?: readonly string[];
1323
+ /**
1324
+ * Whether to render the sticky edit/read-only toggle at the top-right edge
1325
+ * of the content. Defaults to `true`; set to `false` to omit it (e.g. in
1326
+ * fixtures that focus on selection rendering).
1327
+ */
1328
+ readonly showReadonlyToggle?: boolean;
657
1329
  /**
658
1330
  * Controls "limited width mode". The observable yields the maximum content
659
1331
  * width in pixels, or `undefined` to let the content fill the available
@@ -664,6 +1336,14 @@ export declare interface EditorViewOptions extends BlockViewOptions {
664
1336
  * root ({@link element}) always spans the full available width.
665
1337
  */
666
1338
  readonly limitedWidth?: IObservable<number | undefined>;
1339
+ /**
1340
+ * Diff mode only: render every read-only original decoration in active
1341
+ * (source) form, so even whole-block removals expose their markdown markers
1342
+ * as real text. Used by the diff-coverage fixture to verify that every
1343
+ * changed original character is rendered somewhere; off in normal use, where
1344
+ * whole removals show a clean solid band.
1345
+ */
1346
+ readonly diffDecorationsActive?: boolean;
667
1347
  }
668
1348
 
669
1349
  export declare class EmphasisAstNode extends AstNode {
@@ -690,14 +1370,18 @@ declare class EmphasisViewData {
690
1370
  */
691
1371
  export declare function findNodeOffsetById(root: AstNode, target: AstNode): number | undefined;
692
1372
 
693
- export declare function findWordAt(text: string, offset: number): {
1373
+ export declare function findWordAt(text: string, offset: number, config?: WordNavigationConfig): {
694
1374
  start: number;
695
1375
  end: number;
696
1376
  };
697
1377
 
698
- export declare function findWordBoundaryLeft(text: string, offset: number): number;
1378
+ export declare function findWordBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
1379
+
1380
+ export declare function findWordBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
699
1381
 
700
- export declare function findWordBoundaryRight(text: string, offset: number): number;
1382
+ export declare function findWordDeleteBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
1383
+
1384
+ export declare function findWordDeleteBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
701
1385
 
702
1386
  export declare function getAnnotatedSource(node: AstNode, source: string, offset?: number): string;
703
1387
 
@@ -731,6 +1415,29 @@ declare class GlueViewData {
731
1415
  decorateNewline: boolean);
732
1416
  }
733
1417
 
1418
+ /**
1419
+ * A single gutter marker: a source {@link OffsetRange} tagged with a
1420
+ * {@link GutterMarkerType}. The view resolves the range to the visual lines it
1421
+ * covers and paints a bar (or, for `deleted`, a wedge at the range position) in
1422
+ * the left gutter.
1423
+ *
1424
+ * A `deleted` marker is normally an empty range (`range.isEmpty`) sitting at the
1425
+ * boundary where the removed text used to be — there is nothing left to span,
1426
+ * so it is drawn as a caret between lines rather than a bar.
1427
+ */
1428
+ export declare interface GutterMarker {
1429
+ readonly range: OffsetRange;
1430
+ readonly type: GutterMarkerType;
1431
+ }
1432
+
1433
+ /**
1434
+ * The kind of change a gutter marker represents, mirroring the three states a
1435
+ * source-control diff distinguishes (the git change markers in the editor
1436
+ * gutter): a freshly inserted region, an edited region, and a point where
1437
+ * content was removed.
1438
+ */
1439
+ export declare type GutterMarkerType = 'added' | 'modified' | 'deleted';
1440
+
734
1441
  export declare class HeadingAstNode extends BlockAstNodeBase {
735
1442
  readonly level: 1 | 2 | 3 | 4 | 5 | 6;
736
1443
  readonly marker: MarkerAstNode;
@@ -751,6 +1458,8 @@ declare class HeadingViewData {
751
1458
  constructor(ast: HeadingAstNode, content: readonly AnyViewData[]);
752
1459
  }
753
1460
 
1461
+ export declare function hiddenCursorRanges(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number): readonly OffsetRange[];
1462
+
754
1463
  /**
755
1464
  * The editor operations a clipboard strategy drives. The strategy never
756
1465
  * touches the model or the DOM directly — it asks through this seam, so the
@@ -787,6 +1496,9 @@ export declare interface IClipboardStrategy {
787
1496
  connect(context: IClipboardContext): IDisposable;
788
1497
  }
789
1498
 
1499
+ /** A live rendering of a {@link CommentsModel}. Dispose to unmount it. */
1500
+ export declare type ICommentsPresenter = IDisposable;
1501
+
790
1502
  /** The Monarch language definitions the default highlighter wires up. */
791
1503
  export declare interface IDefaultMonarchGrammars {
792
1504
  typescript: unknown;
@@ -798,6 +1510,55 @@ export declare interface IDefaultMonarchGrammars {
798
1510
  shell: unknown;
799
1511
  }
800
1512
 
1513
+ /**
1514
+ * A live editor embedded in place of a fenced code block's *rendered* form.
1515
+ *
1516
+ * This is the internal seam between the block view and a concrete embedded
1517
+ * editor (e.g. an `<iframe>` speaking the web-editor protocol). The block view
1518
+ * only speaks string edits: it pushes the block's content down via
1519
+ * {@link setContent} and receives the editor's own changes back through
1520
+ * {@link onEdit} (set by the block view on each (re)construction, so it always
1521
+ * routes to the current AST node). The concrete implementation owns its DOM,
1522
+ * transport, and lifecycle.
1523
+ *
1524
+ * A single instance is adopted across re-renders (like the highlighter session)
1525
+ * so the underlying editor keeps its state across edits — see
1526
+ * {@link CodeBlockViewNode}.
1527
+ */
1528
+ declare interface IEmbeddedCodeEditor {
1529
+ /** The element mounted as the block's rendered form. */
1530
+ readonly element: HTMLElement;
1531
+ /**
1532
+ * Document → editor. The block's content changed (from any source). Must be
1533
+ * idempotent: pushing the content the editor already holds is a no-op, which
1534
+ * is how edits the editor itself originated are prevented from echoing back.
1535
+ */
1536
+ setContent(content: string): void;
1537
+ /**
1538
+ * Optional synchronous height (px) to reserve for `content` *before* the
1539
+ * editor has laid out. Return `undefined` to let the editor size itself
1540
+ * (the implementation may report its real height later). Lets a registration
1541
+ * avoid a layout jump when it can cheaply estimate the size from content.
1542
+ */
1543
+ estimateHeight?(content: string): number | undefined;
1544
+ /**
1545
+ * Editor → document. Set by the block view on every (re)construction to
1546
+ * route the editor's own edits, expressed in the block's *content*
1547
+ * coordinates, to the current AST node.
1548
+ */
1549
+ onEdit?: (edit: StringEdit) => void;
1550
+ dispose(): void;
1551
+ }
1552
+
1553
+ /** Creates an {@link IEmbeddedCodeEditor} for a fenced block, or opts out. */
1554
+ declare interface IEmbeddedCodeEditorFactory {
1555
+ /**
1556
+ * Return an editor for a fenced block of `language`, or `undefined` to fall
1557
+ * back to the default (highlighting / {@link BlockViewOptions.renderCustomCodeBlock}).
1558
+ */
1559
+ create(language: string, initialContent: string): IEmbeddedCodeEditor | undefined;
1560
+ }
1561
+
801
1562
  export declare class ImageAstNode extends AstNode {
802
1563
  readonly alt: string;
803
1564
  readonly url: string;
@@ -881,6 +1642,21 @@ export declare const insertLineBreak: EditCommand;
881
1642
 
882
1643
  export declare const insertParagraph: EditCommand;
883
1644
 
1645
+ /**
1646
+ * Context-aware Enter. The behaviour is chosen from the active block:
1647
+ * - paragraph / heading / thematic break — the "rich text" thing: at the
1648
+ * block's end arm a transient empty paragraph (see {@link SmartEnterResult});
1649
+ * elsewhere split into two paragraphs (`\n\n`).
1650
+ * - code block — insert a newline that preserves the current line's indentation,
1651
+ * staying inside the fence.
1652
+ * - block quote — continue the quote (`\n> `); an empty quote line exits it.
1653
+ * - list — continue the list with the next marker (incrementing ordered
1654
+ * numbers, re-emitting task checkboxes); an empty item exits the list.
1655
+ * A non-collapsed selection, or any other block, falls back to a plain soft line
1656
+ * break, preserving today's behaviour.
1657
+ */
1658
+ export declare const insertSmartEnter: (ctx: CursorCommandContext) => SmartEnterResult;
1659
+
884
1660
  export declare function insertText(text: string): EditCommand;
885
1661
 
886
1662
  /**
@@ -922,6 +1698,29 @@ export declare interface ISyntaxHighlighterDocument extends IDisposable {
922
1698
  readonly snapshot: IObservableWithChange<ISyntaxHighlightedSnapshot, LengthEdit>;
923
1699
  }
924
1700
 
1701
+ export declare interface KeyboardBinding {
1702
+ readonly key: string;
1703
+ readonly modifiers?: KeyboardModifiers;
1704
+ readonly platforms?: readonly KeyboardPlatform[];
1705
+ readonly action: EditorKeyboardAction;
1706
+ }
1707
+
1708
+ export declare interface KeyboardModifiers {
1709
+ readonly shift?: boolean;
1710
+ readonly alt?: boolean;
1711
+ readonly ctrl?: boolean;
1712
+ readonly meta?: boolean;
1713
+ }
1714
+
1715
+ export declare type KeyboardPlatform = 'macos' | 'windows' | 'linux';
1716
+
1717
+ export declare interface KeyboardProfile {
1718
+ /**
1719
+ * Bindings in priority order. The first exact key/modifier/platform match wins.
1720
+ */
1721
+ readonly bindings: readonly KeyboardBinding[];
1722
+ }
1723
+
925
1724
  declare abstract class LeafAstNode extends AstNode {
926
1725
  abstract readonly content: string;
927
1726
  get children(): readonly AstNode[];
@@ -1140,8 +1939,8 @@ export declare class MeasuredLayoutDebugRendering {
1140
1939
  * Exposes two DOM nodes the caller can place independently:
1141
1940
  *
1142
1941
  * - {@link overlayElement} — absolutely positioned; the caller mounts it
1143
- * inside the editor element so dashed line-bands and run-boxes line up
1144
- * with the editor's client coordinates.
1942
+ * inside the editor overlay container so dashed line-bands and run-boxes
1943
+ * share the measured editor-local coordinates.
1145
1944
  * - {@link infoElement} — block-flow; the caller mounts it as a sibling
1146
1945
  * *below* the editor. Contains the per-block summary table that used
1147
1946
  * to live on the overlay.
@@ -1152,7 +1951,6 @@ export declare class MeasuredLayoutDebugRendering {
1152
1951
  * the derived subscribed.
1153
1952
  */
1154
1953
  export declare class MeasuredLayoutDebugView extends Disposable {
1155
- private readonly _overlayParent;
1156
1954
  readonly overlayElement: HTMLElement;
1157
1955
  readonly infoElement: HTMLElement;
1158
1956
  readonly rendering: IObservable<MeasuredLayoutDebugRendering>;
@@ -1165,6 +1963,7 @@ export declare class MeasuredLayoutDebugView extends Disposable {
1165
1963
 
1166
1964
  export declare interface MeasuredLayoutDebugViewOptions {
1167
1965
  readonly model: MeasuredLayoutModel;
1966
+ readonly coordinateSpace: EditorCoordinateSpace;
1168
1967
  /**
1169
1968
  * DEBUG ONLY. Maps an absolute source offset to a fill color for that
1170
1969
  * character's glyph rect. The fixture passes the same function to the
@@ -1199,10 +1998,9 @@ export declare interface MeasuredLayoutDebugViewOptions {
1199
1998
  export declare class MeasuredLayoutModel {
1200
1999
  readonly measurements: ISettableObservable<readonly BlockMeasurement[], void>;
1201
2000
  /**
1202
- * Concatenated visual line map across all mounted blocks. Lines are
1203
- * left in DOM (client-coordinate) y order each per-block map already
1204
- * uses absolute client coordinates from `getClientRects()`, so the
1205
- * concatenation is well-formed without re-sorting.
2001
+ * Concatenated visual line map across all mounted blocks. Every per-block
2002
+ * map uses the same editor-local coordinate space, so concatenation is
2003
+ * well-formed without translation or re-sorting.
1206
2004
  */
1207
2005
  readonly visualLineMap: IObservableWithChange<VisualLineMap, void>;
1208
2006
  }
@@ -1244,14 +2042,25 @@ export declare class NativeClipboardStrategy implements IClipboardStrategy {
1244
2042
  connect(context: IClipboardContext): IDisposable;
1245
2043
  }
1246
2044
 
2045
+ declare interface NestedItem {
2046
+ readonly kind: 'nested';
2047
+ readonly original: AstNode;
2048
+ readonly originalStart: number;
2049
+ readonly modified: AstNode;
2050
+ readonly modifiedStart: number;
2051
+ readonly children: readonly DiffItem[];
2052
+ }
2053
+
1247
2054
  /**
1248
2055
  * Move the cursor one position left or right, skipping over hidden marker
1249
2056
  * ranges in inactive blocks (and inactive items of an active list).
1250
2057
  */
1251
- export declare function nextCursorPosition(doc: DocumentAstNode, activeBlock: BlockAstNode | undefined, cursor: number, direction: 'left' | 'right'): number;
2058
+ export declare function nextCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, direction: 'left' | 'right'): number;
1252
2059
 
1253
2060
  declare const NO_ACTIVE_BLOCKS: unique symbol;
1254
2061
 
2062
+ export declare function normalizeCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, target: number, direction: 'left' | 'right', includeHiddenRangeBoundary?: boolean): number;
2063
+
1255
2064
  export declare class OffsetRange {
1256
2065
  readonly start: number;
1257
2066
  readonly endExclusive: number;
@@ -1297,7 +2106,48 @@ declare class ParagraphViewData {
1297
2106
  }
1298
2107
 
1299
2108
  /**
1300
- * Immutable point in 2D space, in CSS-pixel client coordinates.
2109
+ * A *transient* editing state: the empty paragraph the user conjured by
2110
+ * pressing Enter at the end of a paragraph. Markdown has no empty-paragraph
2111
+ * node, so this never lives in {@link EditorModel.sourceText} or the parsed
2112
+ * {@link EditorModel.document} — it is pure edit intent that the view renders
2113
+ * as a synthetic blank line and that the controller either *materializes* (the
2114
+ * user types) or *cancels* (the user navigates away / backspaces).
2115
+ */
2116
+ declare interface PendingParagraph {
2117
+ /** The paragraph the blank line is rendered directly after. */
2118
+ readonly anchorBlock: BlockAstNode;
2119
+ /**
2120
+ * Source region rewritten when the pending paragraph is materialized — the
2121
+ * gap between {@link anchorBlock}'s text and whatever follows it.
2122
+ */
2123
+ readonly replaceRange: OffsetRange;
2124
+ /** Whether {@link replaceRange} ends at the end of the document. */
2125
+ readonly atEof: boolean;
2126
+ /**
2127
+ * A throwaway AST node that exists only to give the synthetic view child a
2128
+ * stable identity across render frames (the view pairs nodes by `ast.id`).
2129
+ * It is never part of {@link document}.
2130
+ */
2131
+ readonly syntheticAst: ParagraphAstNode;
2132
+ }
2133
+
2134
+ /**
2135
+ * View-data for the transient empty paragraph (see `PendingParagraph` in the
2136
+ * model). It carries only the throwaway {@link ParagraphAstNode} that gives the
2137
+ * rendered blank line a stable identity across frames; it has no content and is
2138
+ * never measured or part of the selection geometry — the caret is positioned
2139
+ * over it via a dedicated rect, not via the visual-line map.
2140
+ */
2141
+ declare class PendingParagraphViewData {
2142
+ readonly ast: ParagraphAstNode;
2143
+ readonly kind = "pendingParagraph";
2144
+ constructor(ast: ParagraphAstNode);
2145
+ }
2146
+
2147
+ /**
2148
+ * Immutable point in a caller-defined 2D CSS-pixel coordinate space.
2149
+ * Coordinate-owning APIs must document whether values are viewport-client or
2150
+ * editor-local; values from different spaces must not be mixed.
1301
2151
  */
1302
2152
  export declare class Point2D {
1303
2153
  readonly x: number;
@@ -1308,8 +2158,8 @@ export declare class Point2D {
1308
2158
  }
1309
2159
 
1310
2160
  /**
1311
- * Immutable axis-aligned rectangle in 2D space, in CSS-pixel client
1312
- * coordinates. `x`/`y` is the top-left corner, growing right/down.
2161
+ * Immutable axis-aligned rectangle in a caller-defined 2D CSS-pixel coordinate
2162
+ * space. `x`/`y` is the top-left corner, growing right/down.
1313
2163
  *
1314
2164
  * Half-open in both dimensions: `right` and `bottom` are excluded.
1315
2165
  */
@@ -1335,6 +2185,23 @@ export declare class Rect2D {
1335
2185
  translate(dx: number, dy: number): Rect2D;
1336
2186
  }
1337
2187
 
2188
+ declare interface RemovedItem {
2189
+ readonly kind: 'removed';
2190
+ readonly node: AstNode;
2191
+ readonly originalStart: number;
2192
+ readonly deletedLocal: readonly AnnotatedRange[];
2193
+ }
2194
+
2195
+ declare interface ReplacedItem {
2196
+ readonly kind: 'replaced';
2197
+ readonly original: AstNode;
2198
+ readonly originalStart: number;
2199
+ readonly modified: AstNode;
2200
+ readonly modifiedStart: number;
2201
+ readonly insertedLocal: readonly AnnotatedRange[];
2202
+ readonly deletedLocal: readonly AnnotatedRange[];
2203
+ }
2204
+
1338
2205
  export declare const selectAll: SelectionCommand;
1339
2206
 
1340
2207
  export declare function selectBlock(ctx: CursorCommandContext, blockRange: OffsetRange): Selection_2;
@@ -1360,8 +2227,13 @@ export { Selection_2 as Selection }
1360
2227
  export declare interface SelectionBlock {
1361
2228
  readonly block: BlockAstNode;
1362
2229
  readonly absoluteStart: number;
1363
- readonly viewNode: ViewNode;
1364
- readonly element: HTMLElement;
2230
+ /** Block border box in editor-local coordinates. */
2231
+ readonly rect: Rect2D;
2232
+ /** Visible horizontal padding-box bounds for a scrolling block. */
2233
+ readonly viewportClip: {
2234
+ readonly left: number;
2235
+ readonly right: number;
2236
+ } | undefined;
1365
2237
  }
1366
2238
 
1367
2239
  export declare type SelectionCommand = (ctx: CursorCommandContext, offset: SourceOffset) => Selection_2;
@@ -1393,11 +2265,10 @@ export declare interface SelectionRect {
1393
2265
  * envelope shape used by IDE selection rendering.
1394
2266
  */
1395
2267
  export declare class SelectionView extends Disposable {
1396
- private readonly _parent;
1397
2268
  readonly element: SVGSVGElement;
1398
2269
  readonly rendering: IObservable<SelectionViewRendering>;
1399
2270
  private readonly _path;
1400
- constructor(_parent: HTMLElement, options: SelectionViewOptions);
2271
+ constructor(options: SelectionViewOptions);
1401
2272
  }
1402
2273
 
1403
2274
  export declare interface SelectionViewOptions {
@@ -1413,6 +2284,25 @@ export declare class SelectionViewRendering {
1413
2284
 
1414
2285
  export declare const selectWord: SelectionCommand;
1415
2286
 
2287
+ /**
2288
+ * The outcome of {@link insertSmartEnter}: either a concrete source edit (the
2289
+ * ordinary cases), or a request to arm a transient empty paragraph (Enter at
2290
+ * the very end of a paragraph), which the controller turns into
2291
+ * {@link EditorModel.armPendingParagraph} rather than a source edit. Modelling
2292
+ * the empty paragraph as state instead of source keeps the document valid
2293
+ * Markdown — which has no empty-paragraph node — until the user actually types.
2294
+ */
2295
+ export declare type SmartEnterResult = {
2296
+ readonly kind: 'edit';
2297
+ readonly edit: StringEdit;
2298
+ readonly selection: Selection_2;
2299
+ } | {
2300
+ readonly kind: 'pending';
2301
+ readonly anchorBlock: BlockAstNode;
2302
+ readonly replaceRange: OffsetRange;
2303
+ readonly atEof: boolean;
2304
+ };
2305
+
1416
2306
  /**
1417
2307
  * A run of {@link Token}s together with the exact {@link OffsetRange} they
1418
2308
  * cover.
@@ -1428,6 +2318,29 @@ export declare interface SnapshotTokens {
1428
2318
 
1429
2319
  export declare type SourceOffset = number;
1430
2320
 
2321
+ export declare abstract class StackedCommentsPresenter extends Disposable implements ICommentsPresenter {
2322
+ protected readonly model: CommentsModel;
2323
+ protected readonly view: EditorView;
2324
+ protected readonly context?: CommentsPresenterContext | undefined;
2325
+ private readonly _layer;
2326
+ private readonly _entries;
2327
+ private _order;
2328
+ private _pendingRevealCommentId;
2329
+ constructor(model: CommentsModel, view: EditorView, context?: CommentsPresenterContext | undefined);
2330
+ /** Build the card DOM for a comment. Called once per new comment. */
2331
+ protected abstract createWidget(comment: Comment_2): StackWidget;
2332
+ revealComment(id: string): void;
2333
+ private _reconcile;
2334
+ private _relayout;
2335
+ private _revealPendingComment;
2336
+ }
2337
+
2338
+ /** The minimal widget contract a subclass must produce. */
2339
+ export declare interface StackWidget {
2340
+ readonly element: HTMLElement;
2341
+ dispose(): void;
2342
+ }
2343
+
1431
2344
  export declare class StrikethroughAstNode extends AstNode {
1432
2345
  readonly openMarker: MarkerAstNode;
1433
2346
  readonly content: readonly (InlineAstNode | GlueAstNode)[];
@@ -1632,6 +2545,47 @@ export declare class Token {
1632
2545
  className: string | undefined);
1633
2546
  }
1634
2547
 
2548
+ declare interface UnchangedItem {
2549
+ readonly kind: 'unchanged';
2550
+ /** The modified-side node (identical in content to the original). */
2551
+ readonly node: AstNode;
2552
+ readonly modifiedStart: number;
2553
+ }
2554
+
2555
+ /**
2556
+ * A block whose token type the parser does not understand (a setext heading, a
2557
+ * frontmatter fence, any future/extension construct). Rather than dropping the
2558
+ * span — which would demote its text to invisible glue — the parser captures the
2559
+ * whole source range verbatim as a single {@link MarkerAstNode} of kind
2560
+ * `content` and records the originating micromark {@link tokenType}, so the view
2561
+ * can render it as raw, editable text with an "unhandled" affordance. Offsets
2562
+ * stay sound: `content` tiles the block's full source span exactly.
2563
+ */
2564
+ declare class UnhandledBlockAstNode extends BlockAstNodeBase {
2565
+ readonly tokenType: string;
2566
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
2567
+ readonly leadingTrivia?: GlueAstNode | undefined;
2568
+ readonly kind = "unhandledBlock";
2569
+ constructor(tokenType: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
2570
+ get children(): readonly AstNode[];
2571
+ get code(): MarkerAstNode | undefined;
2572
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
2573
+ withLeadingTrivia(trivia: GlueAstNode | undefined): UnhandledBlockAstNode;
2574
+ protected _localEquals(o: this): boolean;
2575
+ }
2576
+
2577
+ /**
2578
+ * View-data for an {@link UnhandledBlockAstNode}. It has no active/inactive
2579
+ * split — the raw source *is* both the source and the rendered form — so it
2580
+ * carries no `showMarkup` flag; the renderer always shows the verbatim text.
2581
+ */
2582
+ declare class UnhandledBlockViewData {
2583
+ readonly ast: UnhandledBlockAstNode;
2584
+ readonly content: readonly AnyViewData[];
2585
+ readonly kind = "unhandledBlock";
2586
+ constructor(ast: UnhandledBlockAstNode, content: readonly AnyViewData[]);
2587
+ }
2588
+
1635
2589
  /**
1636
2590
  * Immutable view of an AST node. Pairs `ast` with its rendered `dom` and a
1637
2591
  * mirror of `ast.children` as ViewNode children. Source offsets are NEVER
@@ -1696,10 +2650,12 @@ export declare class ViewNode extends Disposable {
1696
2650
  /**
1697
2651
  * Map a DOM hit that lands on THIS node's own representation into a source
1698
2652
  * range in this node's local space `[0, ast.length)`. Polymorphic: a text
1699
- * leaf maps the caret offset 1:1; an element-only node (KaTeX math, `<hr>`,
1700
- * an image, a hidden marker) has no internal text mapping and snaps to its
1701
- * start by default subclasses may override (e.g. to snap to the nearer
1702
- * edge by x).
2653
+ * leaf maps the caret offset 1:1. For an element hit — an element-only node
2654
+ * (KaTeX math, `<hr>`, an image, a hidden marker) or a wrapper/container
2655
+ * element the platform reports a child-index offset, not a text caret, so
2656
+ * there is no internal mapping to honour: it snaps to the node's nearer
2657
+ * edge, `offset 0` (the "before" side) → start, any `offset >= 1` (the
2658
+ * "after" side) → end. Subclasses may override for finer control.
1703
2659
  */
1704
2660
  getLocalSourceRange(pos: DomPosition): OffsetRange;
1705
2661
  /**
@@ -1756,23 +2712,37 @@ export declare class VisualLine {
1756
2712
  */
1757
2713
  sourceDistanceTo(offset: SourceOffset): number;
1758
2714
  /**
1759
- * x of the caret position before `offset` on this line. When `offset`
1760
- * is past all runs (trailing whitespace / blank line), returns the
1761
- * right edge of the last run; when before all runs, returns the left
1762
- * edge of the first run.
2715
+ * x of the caret position before `offset` on this line.
2716
+ *
2717
+ * The runs tile the source but are stored in paint order, not sorted by
2718
+ * source offset (hidden-marker runs are appended last). So this scans all
2719
+ * runs rather than assuming any ordering:
2720
+ *
2721
+ * - If some run *covers* `offset`, its own geometry places the caret
2722
+ * (exact glyph boundary for text runs). In the active, markers-visible
2723
+ * form every offset is covered, so this branch keeps distinct offsets
2724
+ * distinct.
2725
+ * - Otherwise `offset` sits in a gap — a hidden inline marker such as the
2726
+ * `**` of `**bold**`, or before/after the painted text. It snaps to the
2727
+ * seam between the source-nearest runs on either side: the right edge of
2728
+ * the closest run ending at/before `offset`, else the left edge of the
2729
+ * closest run starting at/after it. A hidden marker collapses to zero
2730
+ * width, so both edges coincide at the seam.
1763
2731
  */
1764
2732
  xAtOffset(offset: SourceOffset): number;
1765
2733
  /**
1766
2734
  * Snap `x` to the nearest offset on this line. If `x` falls inside a
1767
- * run, the offset is interpolated by character fraction; otherwise it
1768
- * snaps to the closer edge of the nearest run.
2735
+ * run, the run resolves the offset (exact glyph boundary for text runs,
2736
+ * nearer edge for source-less runs); otherwise it snaps to the closer
2737
+ * edge of the nearest run.
1769
2738
  */
1770
2739
  offsetAtX(x: number): SourceOffset;
1771
2740
  }
1772
2741
 
1773
2742
  /**
1774
2743
  * Geometry of the rendered document, as a map from source offsets to 2D
1775
- * positions and back.
2744
+ * positions and back. All geometry is expressed in the editor overlay's local
2745
+ * CSS-pixel coordinate space.
1776
2746
  *
1777
2747
  * Structure (top to bottom):
1778
2748
  *
@@ -1807,7 +2777,7 @@ export declare class VisualLineMap {
1807
2777
  static measure(blockViews: readonly {
1808
2778
  readonly absoluteStart: number;
1809
2779
  readonly viewNode: ViewNode;
1810
- }[]): VisualLineMap;
2780
+ }[], coordinateSpace: EditorCoordinateSpace, transform?: EditorCoordinateTransform): VisualLineMap;
1811
2781
  constructor(lines: readonly VisualLine[]);
1812
2782
  get lineCount(): number;
1813
2783
  get isEmpty(): boolean;
@@ -1845,6 +2815,8 @@ export declare class VisualLineMap {
1845
2815
  offsetAtPoint(point: Point2D): SourceOffset;
1846
2816
  /** Snap `x` to the nearest offset on a specific line. */
1847
2817
  offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
2818
+ lineStartOffset(lineIndex: number): SourceOffset | undefined;
2819
+ lineEndOffset(lineIndex: number): SourceOffset | undefined;
1848
2820
  }
1849
2821
 
1850
2822
  /**
@@ -1853,8 +2825,14 @@ export declare class VisualLineMap {
1853
2825
  * When constructed with a {@link VisualRunSource}, `xAtOffset` returns the
1854
2826
  * pixel-exact x of the caret before character `offset` by measuring the
1855
2827
  * prefix `[textNodeStart, textNodeStart + (offset - sourceStart))` with a
1856
- * DOM `Range`. Without a source it falls back to linear interpolation
1857
- * across `rect.width`.
2828
+ * DOM `Range`.
2829
+ *
2830
+ * A source-less run has no per-offset geometry: it either represents an
2831
+ * element-only block (KaTeX math, a mermaid/custom diagram, an image, an
2832
+ * inactive `<hr>`) whose box does not correspond to source offsets, or a
2833
+ * hand-built run in a test. Either way it maps between offsets and x by
2834
+ * snapping to the nearer edge of {@link rect} rather than fabricating
2835
+ * interior positions.
1858
2836
  */
1859
2837
  export declare class VisualRun {
1860
2838
  readonly sourceRange: OffsetRange;
@@ -1872,19 +2850,36 @@ export declare class VisualRun {
1872
2850
 
1873
2851
  /**
1874
2852
  * The DOM source of a {@link VisualRun}. When set, `xAtOffset` and
1875
- * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`
1876
- * instead of linear interpolation across the run's rect. This matters for
1877
- * proportional fonts where character widths differ a lot (e.g. `m` vs `i`)
1878
- * and a caret placed by interpolation lands several pixels inside the
1879
- * wrong character.
2853
+ * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`.
2854
+ * This matters for proportional fonts where character widths differ a lot
2855
+ * (e.g. `m` vs `i`): a caret placed by anything coarser than real glyph
2856
+ * measurement lands several pixels inside the wrong character.
1880
2857
  *
1881
- * Hand-built runs (tests) omit this; their `xAtOffset` falls back to
1882
- * linear interpolation.
2858
+ * A run without a source has no per-offset geometry, so it maps between
2859
+ * offsets and x by snapping to the nearer run edge. Real text runs always
2860
+ * carry a source; source-less runs are element-only blocks (see
2861
+ * {@link _appendElementBlockRun}) and hand-built runs in tests.
1883
2862
  */
1884
2863
  declare interface VisualRunSource {
1885
2864
  readonly textNode: Text;
1886
2865
  /** Offset within `textNode.data` corresponding to `sourceRange.start`. */
1887
2866
  readonly textNodeStart: number;
2867
+ readonly coordinateSpace: EditorCoordinateSpace;
2868
+ }
2869
+
2870
+ export declare const vscodeKeyboardProfile: KeyboardProfile;
2871
+
2872
+ export declare class VscodeStackedCommentsView extends StackedCommentsPresenter {
2873
+ protected createWidget(comment: Comment_2): StackWidget;
2874
+ }
2875
+
2876
+ export declare class VsCodeV2CommentsView extends StackedCommentsPresenter {
2877
+ protected createWidget(comment: Comment_2): StackWidget;
2878
+ }
2879
+
2880
+ export declare interface WordNavigationConfig {
2881
+ readonly wordSeparators: string;
2882
+ readonly wordSegmenterLocales: readonly string[];
1888
2883
  }
1889
2884
 
1890
2885
  export { }