@vscode/markdown-editor 0.0.2-5 → 0.0.2-50

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 (36) hide show
  1. package/README.md +26 -0
  2. package/dist/_observables/observableInternal/index.d.ts +1 -1
  3. package/dist/_observables/observableInternal/logging/consoleObservableLogger.d.ts +1 -1
  4. package/dist/_observables/observableInternal/logging/debugger/devToolsLogger.d.ts +1 -1
  5. package/dist/_observables/observableInternal/logging/logging.d.ts +1 -1
  6. package/dist/_observables/observableInternal/reactions/{autorun.d.ts → createEffect.d.ts} +11 -3
  7. package/dist/config-BGeaJqWk.js +286 -0
  8. package/dist/config-BGeaJqWk.js.map +1 -0
  9. package/dist/config.d.ts +10 -0
  10. package/dist/config.js +6 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/index.d.ts +1427 -56
  13. package/dist/index.js +6265 -2232
  14. package/dist/index.js.map +1 -1
  15. package/dist/markdown-editor.css +1 -0
  16. package/dist/observables.js +45 -43
  17. package/dist/observables.js.map +1 -1
  18. package/dist/{runOnChange-C00UIwqQ.js → runOnChange-e7FtCqOQ.js} +115 -111
  19. package/dist/runOnChange-e7FtCqOQ.js.map +1 -0
  20. package/dist/stringEdit-CVDbCUBY.js +215 -0
  21. package/dist/stringEdit-CVDbCUBY.js.map +1 -0
  22. package/dist/web-editors.d.ts +130 -0
  23. package/dist/web-editors.js +6185 -0
  24. package/dist/web-editors.js.map +1 -0
  25. package/package.json +48 -9
  26. package/src/contrib/comments/commentInput.css +150 -0
  27. package/src/contrib/comments/comments.css +129 -0
  28. package/src/contrib/commentsVscode/vscodeCommentWidgetV2.css +171 -0
  29. package/src/contrib/find/find.css +347 -0
  30. package/src/view/editor.css +522 -23
  31. package/src/view/themes/default.css +12 -3
  32. package/src/view/themes/github.css +13 -8
  33. package/src/view/themes/vscode-default.css +398 -0
  34. package/src/view/themes/vscode-github.css +395 -0
  35. package/dist/runOnChange-C00UIwqQ.js.map +0 -1
  36. /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 | FrontMatterAstNode | 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 | FrontMatterAstNode | 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,14 @@ 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
+ /**
158
+ * All blocks whose source range intersects `[start, endExclusive]`. A
159
+ * collapsed range (start === endExclusive) matches the block containing
160
+ * that offset (with the same boundary rule as {@link findBlockAtOffset}).
161
+ */
162
+ export declare function blocksIntersecting(doc: DocumentAstNode, start: SourceOffset, endExclusive: SourceOffset): BlockAstNode[];
163
+
164
+ declare type BlockViewData = HeadingViewData | ParagraphViewData | FrontMatterViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData | UnhandledBlockViewData;
134
165
 
135
166
  /**
136
167
  * Base view node for everything the editor renders, generic over the
@@ -151,6 +182,17 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
151
182
  constructor(data: T, dom: globalThis.Node, children: readonly ViewNode[]);
152
183
  get block(): BlockAstNode;
153
184
  get element(): HTMLElement;
185
+ /**
186
+ * The horizontal scroll viewport for selection/caret clipping
187
+ * ({@link blockViewportClip}). For most blocks the scroller *is*
188
+ * {@link element} — a code / math / unhandled block's `element` is the very
189
+ * `overflow-x: auto` box that scrolls. A table is the exception: its
190
+ * `element` stays the inner `<table>` (so the active/markers classes and
191
+ * `.md-table` theme styling are unaffected), but the box that actually
192
+ * scrolls is the wrapping `.md-table-wrapper`, so {@link TableViewNode}
193
+ * overrides this to return that wrapper.
194
+ */
195
+ get scrollElement(): HTMLElement;
154
196
  /**
155
197
  * Whether this already-built node can stand in for `data` unchanged. The
156
198
  * builder preserves view-data identity for any subtree whose ast and
@@ -174,9 +216,10 @@ export declare interface BlockViewOptions {
174
216
  /**
175
217
  * Opens a link's URL. Called when the user activates a link: a plain click
176
218
  * 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')`.
219
+ * is active (source shown). Return `false` to use the anchor's native
220
+ * navigation behavior.
178
221
  */
179
- readonly onOpenLink?: (url: string, event: MouseEvent) => void;
222
+ readonly onOpenLink?: (url: string, event: MouseEvent) => false | void;
180
223
  /**
181
224
  * Colours fenced code blocks. When set, a code block's content is rendered
182
225
  * as a sequence of token spans instead of one plain text node. This is the
@@ -196,6 +239,22 @@ export declare interface BlockViewOptions {
196
239
  * `katexEditableIdentifiers.ts`).
197
240
  */
198
241
  readonly renderMath?: (request: MathRenderRequest) => MathRendering | undefined;
242
+ /**
243
+ * Pluggable factory for an in-place, interactive editor that replaces the
244
+ * *rendered* (inactive) form of a fenced code block — see
245
+ * {@link IEmbeddedCodeEditor}. When it returns an editor for the block's
246
+ * language, that editor's element is mounted instead of the highlighted
247
+ * code, and content flows both ways as string edits. Returning `undefined`
248
+ * falls back to the default rendering. EXPERIMENTAL.
249
+ */
250
+ readonly embeddedCodeEditorFactory?: IEmbeddedCodeEditorFactory;
251
+ /**
252
+ * Called when an {@link IEmbeddedCodeEditor} edits its content. `contentEdit`
253
+ * is in the block's *content* coordinates; the host translates it to a
254
+ * document edit (via {@link CodeBlockAstNode.codeOffset} and the block's
255
+ * offset) and applies it to the model.
256
+ */
257
+ readonly onEmbeddedCodeEditorEdit?: (block: CodeBlockAstNode, contentEdit: StringEdit) => void;
199
258
  }
200
259
 
201
260
  export declare class CodeBlockAstNode extends BlockAstNodeBase {
@@ -271,10 +330,243 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
271
330
  * its predecessor's subscription explicitly.
272
331
  */
273
332
  private _snapshotSub;
333
+ /**
334
+ * An in-place interactive editor (e.g. an iframe) mounted instead of the
335
+ * rendered code. Like {@link _session} it is adopted from `previous` across
336
+ * rebuilds so the underlying editor keeps its state, and must be disposed
337
+ * manually (a node reused as `previous` is never {@link dispose}d).
338
+ */
339
+ private _embeddedEditor;
274
340
  constructor(data: CodeBlockViewData, options: BlockViewOptions | undefined, previous: ViewNode | undefined);
275
341
  dispose(): void;
276
342
  }
277
343
 
344
+ /** A persistent comment anchored to a source range. */
345
+ declare interface Comment_2 {
346
+ readonly id: string;
347
+ /** Source range the comment refers to (its highlighted region). */
348
+ readonly range: OffsetRange;
349
+ /** The comment text. */
350
+ readonly body: string;
351
+ /** Display name of the author, if any. */
352
+ readonly author?: string;
353
+ /** Creation time (epoch ms), used to render a relative timestamp. */
354
+ readonly createdAt?: number;
355
+ }
356
+ export { Comment_2 as Comment }
357
+
358
+ /**
359
+ * A self-contained comment input box — a rounded panel with an auto-growing
360
+ * textarea and a send button, styled after the gdocs/Word "add a comment"
361
+ * affordance.
362
+ *
363
+ * This widget is *positioning-agnostic*: it only owns its own DOM and state.
364
+ * A host (the comment-mode controller, or a fixture) mounts {@link element}
365
+ * wherever it likes and is responsible for placing it relative to a selection.
366
+ *
367
+ * State is observable-driven (no framework): {@link value} reflects the live
368
+ * textarea content; submit/cancel are reported through the option callbacks.
369
+ */
370
+ export declare class CommentInputWidget extends Disposable {
371
+ private readonly _options?;
372
+ readonly element: HTMLElement;
373
+ private readonly _textarea;
374
+ private readonly _measure;
375
+ private readonly _submitButton;
376
+ private readonly _value;
377
+ /** Live, untrimmed textarea content. */
378
+ get value(): IObservable<string>;
379
+ /** The raw textarea, exposed so a host can move focus into it (e.g. on Tab). */
380
+ get inputElement(): HTMLTextAreaElement;
381
+ constructor(_options?: CommentInputWidgetOptions | undefined);
382
+ /** Move focus into the textarea (caret at the end). */
383
+ focus(): void;
384
+ /** Replace the textarea content. */
385
+ setText(text: string): void;
386
+ /** Clear the textarea. */
387
+ clear(): void;
388
+ private _submit;
389
+ private _autoSize;
390
+ }
391
+
392
+ export declare interface CommentInputWidgetOptions {
393
+ /** Placeholder shown while the textarea is empty. Defaults to "Add Comment". */
394
+ readonly placeholder?: string;
395
+ /** Called after the textarea changes size. */
396
+ readonly onDidChangeSize?: () => void;
397
+ /**
398
+ * Called when the user submits a non-empty comment (Enter or the send
399
+ * button). The text is trimmed; never called with an empty string.
400
+ */
401
+ readonly onSubmit?: (text: string) => void;
402
+ /** Called when the user dismisses the input (Escape). */
403
+ readonly onCancel?: () => void;
404
+ }
405
+
406
+ /**
407
+ * Comment mode — a gdocs/Word-style "add a comment" affordance layered on top of
408
+ * the editor *without modifying it*. It reads the editor's public observables
409
+ * ({@link EditorModel.readonlyMode}, {@link EditorModel.selection}) and the
410
+ * exposed {@link EditorView.caretRect} geometry, and mounts a
411
+ * {@link CommentInputWidget} into {@link EditorView.overlayContainer}.
412
+ *
413
+ * Behaviour:
414
+ * - Only active in read-only mode (the "review" view).
415
+ * - When a user-created selection is non-empty, the input box appears next to
416
+ * the caret (the selection's active end) but does NOT take focus, so keyboard
417
+ * selection keeps working. Programmatic selections such as find matches do
418
+ * not summon it. Press Tab to move focus into the box, then type.
419
+ * - The box appears on mouse-up, not mid-drag, so it doesn't flicker/jump
420
+ * while a selection is being dragged out (keyboard selection shows at once).
421
+ * - While the box has focus or holds a draft it is frozen in place (selection
422
+ * changes, drags and clicks no longer move it). It is dismissed by Escape,
423
+ * by submitting, or by blurring an empty box.
424
+ * - The editor's logical caret geometry remains available for anchoring in
425
+ * read-only mode even though the painted caret is hidden. While the box has
426
+ * focus, `.md-comment-active` also suppresses the painted caret in any mode.
427
+ */
428
+ export declare class CommentModeController extends Disposable {
429
+ private readonly _model;
430
+ private readonly _view;
431
+ private readonly _options?;
432
+ private static _isCommentableSelectionSource;
433
+ private readonly _widget;
434
+ private readonly _gap;
435
+ private _visible;
436
+ private _anchorX;
437
+ private _pinnedRange;
438
+ /**
439
+ * The range a comment was just submitted for. The box stays hidden for it
440
+ * until the selection changes, so submitting doesn't immediately re-summon an
441
+ * empty box on the still-selected text.
442
+ */
443
+ private _submittedRange;
444
+ constructor(_model: EditorModel, _view: EditorView, _options?: CommentModeControllerOptions | undefined);
445
+ private _update;
446
+ private _show;
447
+ private _layoutHorizontally;
448
+ /** Force-hide and clear the box (used by Escape and submit). */
449
+ private _hide;
450
+ /**
451
+ * Hide unless the user is engaged with the box: it has focus or holds a
452
+ * non-empty draft. This preserves in-progress text and keeps a focused box
453
+ * open (it is dismissed explicitly via Escape/submit, or by blurring it).
454
+ */
455
+ private _autoHide;
456
+ private _widgetHasFocus;
457
+ /**
458
+ * The visible viewport (client coords) used for the flip-above decision: the
459
+ * nearest scrollable ancestor of the editor. `.md-editor` itself spans the
460
+ * full document height and never clips, so measuring against it would always
461
+ * report room below. Falls back to the window when nothing scrolls.
462
+ */
463
+ private _getViewportRect;
464
+ private _hideAndRefocus;
465
+ private _submit;
466
+ }
467
+
468
+ export declare interface CommentModeControllerOptions {
469
+ /** Called when the user submits a comment for the current selection. */
470
+ readonly onSubmit?: (submission: CommentSubmission) => void;
471
+ /** Gap (px) between the bottom of the selection and the top of the input box. */
472
+ readonly gap?: number;
473
+ }
474
+
475
+ /** Human-readable labels (for pickers / dropdowns). */
476
+ export declare const COMMENTS_DESIGN_LABELS: Record<CommentsDesign, string>;
477
+
478
+ /** design id → presenter factory over a shared CommentsModel + EditorView. */
479
+ export declare const COMMENTS_DESIGNS: Record<CommentsDesign, CommentsPresenterFactory>;
480
+
481
+ /** The available comment rendering designs. */
482
+ export declare type CommentsDesign = 'connected' | 'vscode' | 'vscode-v2';
483
+
484
+ /**
485
+ * Seedable store of {@link Comment}s for the comment-mode contribution. Owns the
486
+ * comment list and the shared hover state; it has no opinion on rendering or
487
+ * persistence — a host seeds it via {@link set}/{@link add} and observes
488
+ * {@link comments}.
489
+ */
490
+ export declare class CommentsModel {
491
+ private readonly _comments;
492
+ /** Monotonic counter for ids of comments created via {@link create}. */
493
+ private _sequence;
494
+ /** The current comments, in insertion order. */
495
+ get comments(): IObservable<readonly Comment_2[]>;
496
+ /**
497
+ * The comment currently hovered (by its card or its highlight), or
498
+ * `undefined`. Shared so the card and the highlight can react together.
499
+ */
500
+ readonly hoveredId: ISettableObservable<string | undefined>;
501
+ /** Replace the whole comment set. */
502
+ set(comments: readonly Comment_2[]): void;
503
+ /**
504
+ * Create a comment from a user submission and append it, generating its `id`
505
+ * and `createdAt` here so id/time allocation stays the store's concern (the
506
+ * UI only supplies the range and text). Returns the created comment.
507
+ */
508
+ create(input: {
509
+ range: OffsetRange;
510
+ body: string;
511
+ author?: string;
512
+ }): Comment_2;
513
+ /** Append a comment. */
514
+ add(comment: Comment_2): void;
515
+ /** Remove a comment by id. */
516
+ remove(id: string): void;
517
+ }
518
+
519
+ /** Optional, design-specific context a presenter may use (ignored by others). */
520
+ export declare interface CommentsPresenterContext {
521
+ /** Light/dark hint for the token-wrapped VS Code widget designs. */
522
+ readonly theme?: 'light' | 'dark';
523
+ /**
524
+ * Resolves a source offset to a 1-based line number, for designs that show
525
+ * line info (the VS Code V1 card). Optional because the model itself carries
526
+ * no text; the host (which owns the source) supplies it.
527
+ */
528
+ readonly resolveLine?: (offset: number) => number;
529
+ }
530
+
531
+ /** Builds a presenter for a given model + editor view. */
532
+ export declare type CommentsPresenterFactory = (model: CommentsModel, view: EditorView, context?: CommentsPresenterContext) => ICommentsPresenter;
533
+
534
+ /** A comment the user submitted, with the source range it was anchored to. */
535
+ export declare interface CommentSubmission {
536
+ readonly text: string;
537
+ readonly range: OffsetRange;
538
+ }
539
+
540
+ /**
541
+ * Renders persistent comments as a gdocs-style side rail: each comment's range
542
+ * is highlighted (reusing the editor's selection geometry via
543
+ * {@link EditorView.rangeRects}), a leader line curves from the bottom of that
544
+ * highlight to a card stacked in the right rail, and cards never overlap.
545
+ *
546
+ * Everything is mounted into {@link EditorView.overlayContainer} so it shares
547
+ * the selection/caret coordinate space and scrolls with the document. When the
548
+ * editor's natural right margin is too narrow for the rail, the view reserves
549
+ * proportional space by padding the editor on the right — but only while there
550
+ * are comments.
551
+ */
552
+ export declare class CommentsView extends Disposable {
553
+ private readonly _model;
554
+ private readonly _view;
555
+ private readonly _layer;
556
+ private readonly _entries;
557
+ constructor(_model: CommentsModel, _view: EditorView);
558
+ private _createLayer;
559
+ private _update;
560
+ /** Create/update/remove per-comment DOM to match `comments`. */
561
+ private _reconcile;
562
+ private _createEntry;
563
+ private _fillCard;
564
+ private _disposeEntry;
565
+ /** Position highlights, cards (stacked) and leader lines. */
566
+ private _layout;
567
+ private _applyHover;
568
+ }
569
+
278
570
  /**
279
571
  * A {@link MonacoSyntaxHighlighter} preloaded with a handful of common Monarch
280
572
  * grammars (plus the usual short aliases). Unknown languages fall back to an
@@ -292,6 +584,8 @@ export declare interface CursorCommandContext {
292
584
  readonly selection: Selection_2;
293
585
  readonly document: DocumentAstNode;
294
586
  readonly activeBlock: BlockAstNode | undefined;
587
+ readonly markerVisibleBlocks: ReadonlySet<BlockAstNode>;
588
+ readonly wordNavigationConfig: WordNavigationConfig;
295
589
  }
296
590
 
297
591
  export declare const cursorDocumentEnd: CursorCommand;
@@ -300,6 +594,8 @@ export declare const cursorDocumentStart: CursorCommand;
300
594
 
301
595
  export declare const cursorDown: VisualCursorCommand;
302
596
 
597
+ export declare type CursorKeyboardAction = 'left' | 'right' | 'up' | 'down' | 'wordLeft' | 'wordRight' | 'visualLineStart' | 'visualLineEnd' | 'logicalLineStart' | 'logicalLineEnd' | 'documentStart' | 'documentEnd';
598
+
303
599
  export declare const cursorLeft: CursorCommand;
304
600
 
305
601
  export declare const cursorLineEnd: CursorCommand;
@@ -329,15 +625,27 @@ export declare const cursorUp: VisualCursorCommand;
329
625
  * derived subscribed.
330
626
  */
331
627
  export declare class CursorView extends Disposable {
332
- private readonly _parent;
333
628
  readonly element: HTMLElement;
334
629
  readonly rendering: IObservable<CursorViewRendering>;
335
- constructor(_parent: HTMLElement, options: CursorViewOptions);
630
+ constructor(options: CursorViewOptions);
336
631
  }
337
632
 
338
633
  export declare interface CursorViewOptions {
339
634
  readonly offset: IObservable<SourceOffset | undefined>;
340
635
  readonly visualLineMap: IObservable<VisualLineMap>;
636
+ /**
637
+ * The mounted blocks, used to hide the caret when it sits at an offset that
638
+ * has been scrolled out of its (horizontally scrolling) block's viewport —
639
+ * matching how the selection is clipped there.
640
+ */
641
+ readonly blocks?: IObservable<readonly SelectionBlock[]>;
642
+ /**
643
+ * When set, the caret is drawn over the transient empty paragraph instead
644
+ * of at {@link offset} — its editor-local rect comes straight
645
+ * from that synthetic element's geometry, since it has no visual-line-map
646
+ * entry. Takes priority over the normal offset-based placement.
647
+ */
648
+ readonly pendingCaretRect?: IObservable<Rect2D | undefined>;
341
649
  }
342
650
 
343
651
  export declare class CursorViewRendering {
@@ -347,18 +655,100 @@ export declare class CursorViewRendering {
347
655
  constructor(offset: SourceOffset, visible: boolean, rect: Rect2D);
348
656
  }
349
657
 
658
+ export declare const cursorVisualLineEnd: VisualCursorCommand;
659
+
660
+ export declare const cursorVisualLineStart: VisualCursorCommand;
661
+
350
662
  export declare const cursorWordLeft: CursorCommand;
351
663
 
352
664
  export declare const cursorWordRight: CursorCommand;
353
665
 
666
+ export declare const DEFAULT_INDENTATION_CONFIG: IndentationConfig;
667
+
668
+ export declare const DEFAULT_WORD_NAVIGATION_CONFIG: WordNavigationConfig;
669
+
670
+ export declare const DEFAULT_WORD_SEPARATORS = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";
671
+
354
672
  export declare const deleteLeft: EditCommand;
355
673
 
674
+ export declare const deleteLineLeft: EditCommand;
675
+
676
+ export declare const deleteLineRight: EditCommand;
677
+
356
678
  export declare const deleteRight: EditCommand;
357
679
 
358
680
  export declare const deleteWordLeft: EditCommand;
359
681
 
360
682
  export declare const deleteWordRight: EditCommand;
361
683
 
684
+ /**
685
+ * A read-only "removed" decoration: an original block rendered (red) above its
686
+ * place in the modified document, occupying vertical space like a view-zone but
687
+ * contributing **zero** source length, so the editor's source mapping stays the
688
+ * modified document and editing is unaffected. Used for `removed` and the
689
+ * original side of a `replaced` block in editor diff mode.
690
+ */
691
+ declare class DiffDecorationViewData {
692
+ readonly ast: AstNode;
693
+ readonly side: BlockViewData;
694
+ readonly deletedRanges: readonly DiffHighlightRange[];
695
+ /** True when the whole block was removed: solid red band, no word rects. */
696
+ readonly whole: boolean;
697
+ /** Absolute offset of this block in the *original* document. */
698
+ readonly originalStart: number;
699
+ readonly kind = "diffDecoration";
700
+ constructor(ast: AstNode, side: BlockViewData, deletedRanges: readonly DiffHighlightRange[],
701
+ /** True when the whole block was removed: solid red band, no word rects. */
702
+ whole: boolean,
703
+ /** Absolute offset of this block in the *original* document. */
704
+ originalStart: number);
705
+ }
706
+
707
+ /** A word/character highlight inside one diff side, in block-local coords. */
708
+ declare interface DiffHighlightRange {
709
+ readonly range: OffsetRange;
710
+ readonly kind: 'inserted' | 'deleted';
711
+ }
712
+
713
+ /**
714
+ * A changed block rendered as its original form stacked over its modified form
715
+ * (either side may be absent for a pure deletion/insertion). It is itself a
716
+ * document child the renderer mounts like a block; its {@link ast} is the
717
+ * surviving side's ast, used only for view-node identity/reuse.
718
+ */
719
+ declare class DiffHunkViewData {
720
+ readonly ast: AstNode;
721
+ readonly original: DiffSideViewData | undefined;
722
+ readonly modified: DiffSideViewData | undefined;
723
+ readonly kind = "diffHunk";
724
+ constructor(ast: AstNode, original: DiffSideViewData | undefined, modified: DiffSideViewData | undefined);
725
+ }
726
+
727
+ /**
728
+ * The recursive classification of a diff. Each item describes one aligned
729
+ * position in the merged document:
730
+ *
731
+ * - `unchanged` — render the (modified) node once, neutral.
732
+ * - `added` — exists only in the modified document (green).
733
+ * - `removed` — exists only in the original document (red).
734
+ * - `replaced` — a *leaf* block changed in place → render original over
735
+ * modified, with word-level {@link AnnotatedRange}s on each.
736
+ * - `nested` — a *container* changed → render it once and diff its
737
+ * {@link NestedItem.children} recursively.
738
+ *
739
+ * Offsets ({@link UnchangedItem.modifiedStart} etc.) are absolute in their
740
+ * respective documents, so a renderer/visualizer can slice the source text.
741
+ */
742
+ declare type DiffItem = UnchangedItem | AddedItem | RemovedItem | ReplacedItem | NestedItem;
743
+
744
+ /** One side (original or modified) of a {@link DiffHunkViewData}. */
745
+ declare interface DiffSideViewData {
746
+ readonly view: BlockViewData;
747
+ /** Render in active form (markers/whitespace visible). */
748
+ readonly active: boolean;
749
+ readonly ranges: readonly DiffHighlightRange[];
750
+ }
751
+
362
752
  export declare class DocumentAstNode extends AstNode {
363
753
  readonly content: readonly (BlockAstNode | GlueAstNode)[];
364
754
  readonly kind = "document";
@@ -383,13 +773,21 @@ declare interface DocumentBlockViewData {
383
773
  readonly view: BlockViewData;
384
774
  }
385
775
 
386
- /** A mounted document child: a block or a run of inter-block glue. */
776
+ /** A mounted document child: a block, a run of inter-block glue, the
777
+ * transient empty paragraph (see {@link PendingParagraphViewData}), or a
778
+ * {@link DiffHunkViewData diff hunk} (stacked original/modified blocks). */
387
779
  declare interface DocumentChildViewData {
388
780
  readonly absoluteStart: number;
389
781
  /** For a block: selection reaches it. For glue: always false (unowned, hidden). */
390
782
  readonly isActive: boolean;
391
- readonly view: BlockViewData | GlueViewData;
392
- readonly kind: 'block' | 'glue';
783
+ readonly view: BlockViewData | GlueViewData | PendingParagraphViewData | DiffHunkViewData | DiffDecorationViewData;
784
+ readonly kind: 'block' | 'glue' | 'pendingParagraph' | 'diffHunk' | 'diffDecoration';
785
+ /**
786
+ * Diff mode: how this (modified) block changed. `added` = a whole new block
787
+ * (strong green band, no inline rects); `modified` = a partial change (light
788
+ * band + inline rects on the changed words).
789
+ */
790
+ readonly diffKind?: 'added' | 'modified';
393
791
  }
394
792
 
395
793
  /**
@@ -445,6 +843,8 @@ declare class DocumentViewData {
445
843
  */
446
844
  export declare class DocumentViewNode extends ViewNode {
447
845
  readonly blocks: readonly DocumentBlock[];
846
+ /** The transient empty-paragraph element, when one is armed. */
847
+ readonly pendingElement?: HTMLElement | undefined;
448
848
  static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
449
849
  private constructor();
450
850
  /** The stable content element this document mounts its children into. */
@@ -466,6 +866,8 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
466
866
  readonly selection: Selection_2;
467
867
  } | undefined;
468
868
 
869
+ export declare type EditKeyboardAction = 'deleteLeft' | 'deleteRight' | 'deleteWordLeft' | 'deleteWordRight' | 'deleteLineLeft' | 'deleteLineRight';
870
+
469
871
  /**
470
872
  * Translates raw browser input (mouse, keyboard, EditContext) into model
471
873
  * mutations. Knows about DOM event types but never reads/writes the DOM
@@ -474,25 +876,69 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
474
876
  *
475
877
  * Owns the only non-derivable controller state:
476
878
  * - `_desiredColumn` — sticky column for up/down navigation
879
+ * - `_clickCount` / `_lastPointerDown` — multi-click detection for pointer
880
+ * input, since `pointerdown` events (unlike `mousedown`) don't populate
881
+ * `detail` with a click count.
477
882
  */
478
883
  export declare class EditorController extends Disposable {
479
884
  private readonly _model;
480
885
  private readonly _view;
886
+ readonly findController: FindController | undefined;
481
887
  private _desiredColumn;
888
+ private readonly _keyboardPlatform;
889
+ private readonly _keyboardProfile;
890
+ private readonly _historyStrategy;
891
+ private readonly _indentation;
892
+ private readonly _tabFocusStatus;
893
+ private _tabMovesFocus;
894
+ /** Running click count for the current multi-click sequence (1, 2, 3, …). */
895
+ private _clickCount;
896
+ /** Timestamp and position of the previous pointer-down, for multi-click detection. */
897
+ private _lastPointerDown;
482
898
  constructor(_model: EditorModel, _view: EditorView, options?: EditorControllerOptions);
483
899
  private readonly _handleTextUpdate;
484
- private readonly _handleMouseDown;
900
+ private readonly _handlePointerDown;
485
901
  private _makeCursorContext;
486
902
  private _makeVisualCursorContext;
487
903
  private _executeCursorCommand;
488
904
  private _executeEditCommand;
905
+ private _runUndoableEdit;
489
906
  private _executeVisualCursorCommand;
907
+ private _setUserSelection;
490
908
  /** Move the cursor down one visual line (Arrow Down). */
491
909
  cursorDown(extend?: boolean): void;
492
910
  /** Move the cursor up one visual line (Arrow Up). */
493
911
  cursorUp(extend?: boolean): void;
494
912
  private _selectedText;
913
+ private readonly _updateModifierState;
914
+ private readonly _clearModifierState;
915
+ /**
916
+ * Drop any native DOM selection over the rendered text.
917
+ *
918
+ * The editor paints selection from `model.selection`, so a browser
919
+ * selection there is always spurious: nothing reads it (copy/cut read the
920
+ * model, hit-testing uses the measured layout) and nothing clears it, so it
921
+ * lingers as a second highlight even after the caret moves away.
922
+ * {@link isCaretMotionKey} stops the common source synchronously; this is
923
+ * the backstop for the rest of the browser's editing commands, which are
924
+ * platform- and version-specific and cannot be enumerated (Shift+PageDown
925
+ * and macOS Shift+Ctrl+B both reach one today).
926
+ *
927
+ * Scoped twice so it only ever discards selections the editor owns: the
928
+ * range must touch the rendered text (overlays such as comment widgets sit
929
+ * beside it and stay selectable), and input focus must still be inside this
930
+ * editor (so a host find-in-page, which selects while its own input is
931
+ * focused, is left alone).
932
+ */
933
+ private readonly _discardNativeSelection;
495
934
  private readonly _handleKeyDown;
935
+ private _executeKeyboardAction;
936
+ /**
937
+ * Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
938
+ * arms a transient empty paragraph when at the end of a paragraph.
939
+ */
940
+ private _smartEnter;
941
+ private _registerTabFocusAccessibility;
496
942
  }
497
943
 
498
944
  /** Options for an {@link EditorController}. */
@@ -503,10 +949,74 @@ export declare interface EditorControllerOptions {
503
949
  * strategy (e.g. `AsyncClipboardStrategy`) in hosts that swallow them.
504
950
  */
505
951
  readonly clipboardStrategy?: IClipboardStrategy;
952
+ /**
953
+ * Where undo and redo are executed: `LocalHistoryStrategy` for a
954
+ * self-contained editor, or a strategy that forwards to the host's own
955
+ * document history. Left unset, the chords are passed on to the host.
956
+ */
957
+ readonly historyStrategy?: IHistoryStrategy;
958
+ readonly keyboardPlatform?: KeyboardPlatform;
959
+ readonly keyboardProfile?: KeyboardProfile;
960
+ /** Tab-stop settings used outside semantic list indentation. */
961
+ readonly indentation?: IndentationConfig;
962
+ readonly find?: false;
506
963
  }
507
964
 
965
+ /**
966
+ * The editor overlay's local CSS-pixel coordinate space.
967
+ *
968
+ * Browser geometry and pointer APIs expose viewport client coordinates. This
969
+ * boundary converts them immediately into the coordinate system shared by the
970
+ * editor content and its overlays. Range rectangles are axis-aligned, so the
971
+ * current implementation deliberately supports positive axis-aligned scale and
972
+ * translation only.
973
+ */
974
+ export declare class EditorCoordinateSpace {
975
+ private readonly _getLocalToClientMatrix;
976
+ static forSvgOverlay(overlay: SVGSVGElement): EditorCoordinateSpace;
977
+ private constructor();
978
+ capture(): EditorCoordinateTransform;
979
+ }
980
+
981
+ /** A stable coordinate conversion captured for one measurement operation. */
982
+ export declare class EditorCoordinateTransform {
983
+ private readonly _localToClient;
984
+ private readonly _clientToLocal;
985
+ constructor(_localToClient: DOMMatrix);
986
+ toLocalPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
987
+ toClientPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
988
+ toLocalRect(rect: Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>): Rect2D;
989
+ toClientRect(rect: Pick<Rect2D, 'left' | 'top' | 'width' | 'height'>): Rect2D;
990
+ private _convertRect;
991
+ }
992
+
993
+ export declare type EditorKeyboardAction = {
994
+ readonly kind: 'cursor';
995
+ readonly command: CursorKeyboardAction;
996
+ readonly extend: boolean;
997
+ } | {
998
+ readonly kind: 'edit';
999
+ readonly command: EditKeyboardAction;
1000
+ } | {
1001
+ readonly kind: 'history';
1002
+ readonly command: HistoryKeyboardAction;
1003
+ } | {
1004
+ readonly kind: 'tab';
1005
+ readonly command: TabKeyboardAction;
1006
+ } | {
1007
+ readonly kind: 'toggleTabFocus';
1008
+ } | {
1009
+ readonly kind: 'selectAll';
1010
+ } | {
1011
+ readonly kind: 'enter';
1012
+ readonly command: 'smartEnter' | 'insertParagraph' | 'insertHardLineBreak';
1013
+ };
1014
+
508
1015
  export declare class EditorModel {
509
1016
  private readonly _parser;
1017
+ private readonly _sourceEditListeners;
1018
+ private readonly _sourceTextIds;
1019
+ private _lastSourceTextId;
510
1020
  /**
511
1021
  * The most recent edit applied to {@link sourceText}, used by
512
1022
  * {@link document} to let the parser link incrementally edited code
@@ -515,11 +1025,45 @@ export declare class EditorModel {
515
1025
  */
516
1026
  private _pendingEdit;
517
1027
  readonly sourceText: ISettableObservable<StringValue, void>;
1028
+ readonly wordNavigationConfig: ISettableObservable<WordNavigationConfig, void>;
1029
+ /**
1030
+ * Read-only mode. When `true`, the editor never reveals a block's source
1031
+ * markers (markdown special characters like `**`, `#`, list bullets, code
1032
+ * fences, `$…$`) — every block stays in its clean rendered form regardless
1033
+ * of where the caret/selection is — and source-mutating edits are ignored.
1034
+ * Plain text selection still works everywhere (so the user can copy). The
1035
+ * default (`false`) is the normal editing mode where the active block
1036
+ * reveals its markers.
1037
+ */
1038
+ readonly readonlyMode: ISettableObservable<boolean, void>;
518
1039
  /**
519
1040
  * The current selection, or `undefined` when the editor has no caret
520
1041
  * (e.g. an inactive/unfocused rendering).
521
1042
  */
522
1043
  readonly selection: ISettableObservable<Selection_2 | undefined, void>;
1044
+ readonly selectionSource: ISettableObservable<SelectionSource, void>;
1045
+ /**
1046
+ * Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
1047
+ * live keyboard state; the view reads it to show the link-open affordance
1048
+ * (underline + pointer cursor) only while a Ctrl/Cmd+click would open a link
1049
+ * whose block is active.
1050
+ */
1051
+ readonly ctrlOrMetaDown: ISettableObservable<boolean, void>;
1052
+ /**
1053
+ * Whether a pointer-driven selection drag is currently in progress. Set by
1054
+ * the controller between the pointer-down that starts the drag and the
1055
+ * pointer-up/cancel that ends it. Contributions read it to defer UI that
1056
+ * would otherwise flicker mid-drag (e.g. the comment input box appears only
1057
+ * once the drag ends).
1058
+ */
1059
+ readonly isSelecting: ISettableObservable<boolean, void>;
1060
+ /**
1061
+ * Gutter markers (source-control style change indicators) painted in the
1062
+ * left gutter. Each entry maps a source {@link OffsetRange} to a change kind
1063
+ * — see {@link GutterMarker}. Purely decorative: markers never affect the
1064
+ * parsed {@link document}, selection, or layout. Empty by default.
1065
+ */
1066
+ readonly gutterMarkers: ISettableObservable<readonly GutterMarker[], void>;
523
1067
  /**
524
1068
  * Forces the rendered active-block set. `undefined` (the default)
525
1069
  * derives the set from the current selection range (see
@@ -528,6 +1072,13 @@ export declare class EditorModel {
528
1072
  * collapsed/inactive rendering.
529
1073
  */
530
1074
  readonly activeBlocksOverride: ISettableObservable<readonly BlockAstNode[] | typeof NO_ACTIVE_BLOCKS | undefined, void>;
1075
+ /**
1076
+ * The transient empty-paragraph editing state, or `undefined` when none is
1077
+ * armed. See {@link PendingParagraph}. This is *not* document data — it is
1078
+ * cleared by any source edit and lives only between the Enter that armed it
1079
+ * and the next keystroke.
1080
+ */
1081
+ readonly pendingParagraph: ISettableObservable<PendingParagraph | undefined, void>;
531
1082
  readonly cursorOffset: IObservableWithChange<number | undefined, void>;
532
1083
  /**
533
1084
  * The parsed document. Threads the previous document into the parser so
@@ -551,10 +1102,62 @@ export declare class EditorModel {
551
1102
  * collapsed this is a one-element set holding {@link activeBlock}.
552
1103
  */
553
1104
  readonly activeBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
554
- applyEdit(edit: StringEdit): void;
1105
+ /**
1106
+ * The baseline document to diff against. When set, the editor renders in
1107
+ * diff mode: the modified document ({@link document}) stays editable, while
1108
+ * the baseline's removed/changed blocks are shown as read-only decorations.
1109
+ * `undefined` (the default) renders normally.
1110
+ */
1111
+ readonly baseline: ISettableObservable<StringValue | undefined, void>;
1112
+ private readonly _baselineDocument;
1113
+ /**
1114
+ * The diff of {@link baseline} → {@link document}, or `undefined` when no
1115
+ * baseline is set. The view renders the {@link DiffItem}s as stacked
1116
+ * decorations; `insertedRanges` (modified-side change spans) drive the green
1117
+ * word-level highlight.
1118
+ */
1119
+ readonly diff: IObservableWithChange< {
1120
+ items: DiffItem[];
1121
+ insertedRanges: OffsetRange[];
1122
+ changedBlocks: Set<BlockAstNode>;
1123
+ } | undefined, void>;
1124
+ readonly markerVisibleBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1125
+ onWillApplySourceEdit(listener: (event: SourceEditEvent) => void): IDisposable;
1126
+ /** Returns a stable per-object identity without retaining the source text. */
1127
+ getSourceTextId(sourceText: StringValue): number;
1128
+ /**
1129
+ * Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
1130
+ * AST node for it, and park the caret at the gap start. No source edit is
1131
+ * applied — the blank line exists only in the view until it is materialized.
1132
+ */
1133
+ armPendingParagraph(req: {
1134
+ anchorBlock: BlockAstNode;
1135
+ replaceRange: OffsetRange;
1136
+ atEof: boolean;
1137
+ }): void;
1138
+ /** Discard the pending paragraph (if any) without touching the source. */
1139
+ cancelPendingParagraph(): void;
1140
+ /**
1141
+ * Replace the source with an authoritative value from the host, mapping the
1142
+ * selection through the changed span and atomically discarding transient
1143
+ * state anchored to the previous parse.
1144
+ */
1145
+ replaceSourceText(text: StringValue): void;
1146
+ /**
1147
+ * Turn the pending paragraph into real source: rewrite its gap so the typed
1148
+ * `text` becomes its own paragraph, separated from its neighbours by blank
1149
+ * lines, and place the caret after the inserted text.
1150
+ */
1151
+ materializePendingParagraph(text: string): void;
1152
+ applyEdit(edit: StringEdit, selection?: Selection_2): void;
555
1153
  applyEditForSelection(edit: StringEdit): void;
1154
+ private _applySourceEdit;
1155
+ private _identifySourceEdit;
1156
+ private _emitWillApplySourceEdit;
556
1157
  }
557
1158
 
1159
+ export declare type EditorOverlayPosition = 'top-chrome' | 'below-selection' | 'above-decorations';
1160
+
558
1161
  /**
559
1162
  * Pure-render view of an {@link EditorModel}.
560
1163
  *
@@ -584,6 +1187,8 @@ export declare class EditorView extends Disposable {
584
1187
  readonly element: HTMLElement;
585
1188
  readonly editContext: EditContext;
586
1189
  readonly measuredLayout: MeasuredLayoutModel;
1190
+ readonly coordinateSpace: EditorCoordinateSpace;
1191
+ readonly forcedMarkerVisibleBlocks: ISettableObservable<ReadonlySet<BlockAstNode>, void>;
587
1192
  /**
588
1193
  * Inner container that holds the rendered document and the cursor/selection
589
1194
  * overlays. The outer {@link element} spans the full width; this container
@@ -593,6 +1198,11 @@ export declare class EditorView extends Disposable {
593
1198
  private readonly _contentContainer;
594
1199
  private readonly _cursorView;
595
1200
  private readonly _selectionView;
1201
+ private readonly _gutterMarkersView;
1202
+ private readonly _diffHighlightsView;
1203
+ private _readonlyToggleButton;
1204
+ private readonly _editContextSuspensions;
1205
+ private readonly _revealOcclusions;
596
1206
  /**
597
1207
  * The mounted block sequence, in source order. Rebuilt (not mutated) each
598
1208
  * frame by {@link DocumentViewNode.create}; the view just swaps one
@@ -612,20 +1222,146 @@ export declare class EditorView extends Disposable {
612
1222
  /** The current view-data tree (AST overlaid with selection flags), for debugging. */
613
1223
  private readonly _viewData;
614
1224
  get viewData(): IObservable<DocumentViewData | undefined>;
1225
+ /**
1226
+ * Whether the editor is genuinely focused: focus rests somewhere inside the
1227
+ * editor subtree *and* its window is focused. Mirrored onto the root as
1228
+ * `.md-focused`, which gates the painted caret — the blinking cursor is only
1229
+ * shown while this is `true`, so it never blinks in an unfocused editor or
1230
+ * after the window loses focus. Only the caret's visibility is affected; the
1231
+ * logical selection and caret geometry ({@link caretRect}) are unchanged.
1232
+ */
1233
+ private readonly _focused;
1234
+ get focused(): IObservable<boolean>;
1235
+ /**
1236
+ * Caret rect (editor-local coordinates) for the transient empty paragraph, or
1237
+ * `undefined` when none is armed. Set each frame from the synthetic
1238
+ * paragraph element's geometry and fed to the {@link CursorView}, which has
1239
+ * no visual-line-map entry to place the caret from otherwise.
1240
+ */
1241
+ private readonly _pendingCaretRect;
615
1242
  /**
616
1243
  * The block cache projected for views (selection painting) that need to
617
1244
  * react to mount/unmount. Derived from {@link _document}, so it stays in
618
1245
  * lock-step without any manual bookkeeping.
619
1246
  */
620
1247
  private readonly _selectionBlocksObs;
1248
+ /**
1249
+ * The caret rect (zero width) at the selection's active end, in
1250
+ * {@link overlayContainer}-local coordinates, or `undefined` when there is no
1251
+ * caret. This is the same geometry the editor paints its cursor from, so
1252
+ * contributions (e.g. comment mode) can anchor an overlay to the active end of
1253
+ * the selection — where the user's cursor is — without re-deriving geometry.
1254
+ */
1255
+ private readonly _caretRect;
1256
+ get caretRect(): IObservable<Rect2D | undefined>;
1257
+ /**
1258
+ * The container that establishes the positioning context for the editor's
1259
+ * overlays (cursor, selection, gutter). Contributions mount their own
1260
+ * absolutely-positioned overlays here so they share the coordinate space of
1261
+ * {@link caretRect}.
1262
+ */
1263
+ get overlayContainer(): HTMLElement;
1264
+ /**
1265
+ * Selection-style rectangles covering `range`, in {@link overlayContainer}-
1266
+ * local coordinates — the same geometry the live selection paints. Exposed so
1267
+ * contributions (e.g. persistent comments) can highlight arbitrary ranges and
1268
+ * anchor overlays to them. Recomputes when the measured layout changes.
1269
+ */
1270
+ rangeRects(range: OffsetRange): IObservable<readonly SelectionRect[]>;
621
1271
  constructor(_model: EditorModel, _options?: EditorViewOptions | undefined);
1272
+ /**
1273
+ * Mirrors the model's live Ctrl/Cmd state onto the editor root as
1274
+ * `.md-mod-down` so CSS can show the link-open underline and pointer cursor
1275
+ * only while a click would actually open the link: an inactive link opens on
1276
+ * a plain click, but an active link only opens with the modifier held.
1277
+ */
1278
+ private _setupModifierTracking;
1279
+ /**
1280
+ * Tracks whether the editor is genuinely focused and mirrors it onto the
1281
+ * root as `.md-focused` so CSS can gate the painted caret. "Focused" means
1282
+ * focus rests somewhere inside the editor subtree *and* the window itself is
1283
+ * focused; either condition failing (focus moving elsewhere, or the window
1284
+ * losing focus) hides the blinking caret while leaving the logical selection
1285
+ * and caret geometry intact.
1286
+ */
1287
+ private _setupFocusTracking;
1288
+ /**
1289
+ * Renders the edit/read-only mode toggle. It flips the model's
1290
+ * {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
1291
+ * in its clean rendered form (no markdown markers revealed) and edits are
1292
+ * ignored, while text selection still works. The control lives in a
1293
+ * zero-height *sticky* host inside the centered content container, so the
1294
+ * lock follows the content's right edge and remains pinned as the document
1295
+ * scrolls. The current mode is also mirrored onto the root as `.md-readonly`
1296
+ * for any CSS hooks.
1297
+ */
1298
+ private _setupReadonlyToggle;
1299
+ /** Draws attention to the mode toggle after text input is attempted while locked. */
1300
+ showReadonlyEditingAttempt(): void;
622
1301
  focus(): void;
1302
+ mountOverlay(element: HTMLElement | SVGSVGElement, position: EditorOverlayPosition): IDisposable;
1303
+ /** Registers floating editor chrome that should count as covering a range during reveal. */
1304
+ registerRevealOcclusion(element: Element): IDisposable;
1305
+ /**
1306
+ * Temporarily detaches the root {@link EditContext} while focus is inside
1307
+ * nested editor chrome. Chromium otherwise reclaims focus from non-text
1308
+ * controls inside the EditContext host, breaking keyboard access to controls
1309
+ * such as the find actions and read-only toggle.
1310
+ */
1311
+ suspendEditContextWhileFocused(element: HTMLElement): IDisposable;
1312
+ revealRangeInCenterIfOutsideViewport(range: OffsetRange, behavior?: ScrollBehavior): IDisposable;
1313
+ /**
1314
+ * Samples the ambient focus state that decides whether taking focus on open
1315
+ * would steal it from an explicit user target: whether the window is focused
1316
+ * and whether focus is still unclaimed (no active element, or the `<body>`
1317
+ * fallback).
1318
+ */
1319
+ private _sampleAutoFocusEnvironment;
1320
+ /**
1321
+ * One-shot guarded focus attempt: focuses the editor only if doing so will
1322
+ * not steal focus from an explicit user target — the window must already be
1323
+ * focused and no other element may have claimed focus yet. Returns whether
1324
+ * focus was taken. A no-op for a background window or when the user has
1325
+ * already focused something else. {@link autoFocusOnOpen} builds the
1326
+ * open-time behavior on top of this primitive.
1327
+ */
1328
+ tryAutoFocus(): boolean;
1329
+ /**
1330
+ * Focuses the editor when it opens without ever stealing focus from an
1331
+ * explicit user target. Tries once immediately; if the window is not focused
1332
+ * yet — a common open-time race where the editor is mounted before the host
1333
+ * routes focus to its window — the guarded attempt is deferred to the next
1334
+ * time the window gains focus and re-evaluated then. The deferral is
1335
+ * one-shot, so a later, unrelated window refocus never grabs focus, and the
1336
+ * re-check still respects any target the user has claimed in the meantime.
1337
+ */
1338
+ autoFocusOnOpen(): void;
1339
+ /**
1340
+ * Own point→offset resolution. When `true` (the default),
1341
+ * {@link resolveOffsetFromPoint} ignores the platform DOM hit-test
1342
+ * (`caretPositionFromPoint`) and snaps the point to the nearest offset purely
1343
+ * from the rendered {@link VisualLineMap} geometry — picking the nearest
1344
+ * visual line by `y`, then the nearest offset on it by `x`. Because a table
1345
+ * row's cells share one horizontal line band, this makes the whole width of a
1346
+ * row resolve into that row (rather than only the cell boxes), with no visible
1347
+ * layout change. It also lets a drag keep extending toward off-viewport points
1348
+ * (e.g. the pointer leaving the window), which the platform hit-test cannot
1349
+ * resolve. Set to `false` to fall back to the platform DOM hit-test.
1350
+ */
1351
+ readonly geometricHitTest: ISettableObservable<boolean, void>;
623
1352
  /**
624
1353
  * Client coordinates → absolute source offset (any block). Used during
625
1354
  * drag to keep extending the selection even when the pointer leaves the
626
- * original block.
1355
+ * original block. Honours {@link geometricHitTest}.
627
1356
  */
628
1357
  resolveOffsetFromPoint(point: Point2D): SourceOffset | undefined;
1358
+ /**
1359
+ * Resolve table-cell hits that have no measurable text run. Empty cells map
1360
+ * from their own box instead of snapping to a neighboring cell; element-only
1361
+ * content (for example an inactive image) maps through the hit element's view
1362
+ * node. Text-bearing cells keep the normal pixel-precise line-map/DOM path.
1363
+ */
1364
+ private _resolveTableCellOffset;
629
1365
  /**
630
1366
  * Whether a client point falls on the rendered document content, as
631
1367
  * opposed to the surrounding editor padding (the green area). Uses DOM
@@ -635,6 +1371,13 @@ export declare class EditorView extends Disposable {
635
1371
  * have `pointer-events: none`, so the hit-test sees through them.
636
1372
  */
637
1373
  isPointInContent(point: Point2D): boolean;
1374
+ /**
1375
+ * Whether `node` sits inside the rendered source text — the region whose
1376
+ * selection this editor paints itself from `model.selection`. Overlays
1377
+ * anchored beside the text (comment widgets and the like) are *not* part of
1378
+ * it and keep their own native selection behaviour.
1379
+ */
1380
+ containsRenderedContent(node: Node | null | undefined): boolean;
638
1381
  private readonly _renderAutorun;
639
1382
  /** Current mounted blocks, or empty before the first render. */
640
1383
  private get _blocks();
@@ -644,6 +1387,18 @@ export declare class EditorView extends Disposable {
644
1387
  * is not read here, so there is no feedback loop into the render autorun.
645
1388
  */
646
1389
  private _publishMeasurements;
1390
+ /**
1391
+ * Paint the diff highlights via the CSS Custom Highlight API: green over the
1392
+ * inserted/changed modified ranges (mapped on the document's own DOM), and
1393
+ * red over each {@link DiffDecorationViewNode}'s deleted ranges (mapped on
1394
+ * the decoration's own subtree). No DOM is mutated, so reconciliation and
1395
+ * editing are unaffected.
1396
+ */
1397
+ private _paintDiff;
1398
+ private _clearDiff;
1399
+ private _syncEditContextAttachment;
1400
+ private _revealRange;
1401
+ private _isRevealOccluded;
647
1402
  }
648
1403
 
649
1404
  export declare interface EditorViewOptions extends BlockViewOptions {
@@ -654,6 +1409,12 @@ export declare interface EditorViewOptions extends BlockViewOptions {
654
1409
  * only) unless a theme class is supplied.
655
1410
  */
656
1411
  readonly classNames?: readonly string[];
1412
+ /**
1413
+ * Whether to render the sticky edit/read-only toggle at the top-right edge
1414
+ * of the content. Defaults to `true`; set to `false` to omit it (e.g. in
1415
+ * fixtures that focus on selection rendering).
1416
+ */
1417
+ readonly showReadonlyToggle?: boolean;
657
1418
  /**
658
1419
  * Controls "limited width mode". The observable yields the maximum content
659
1420
  * width in pixels, or `undefined` to let the content fill the available
@@ -664,6 +1425,14 @@ export declare interface EditorViewOptions extends BlockViewOptions {
664
1425
  * root ({@link element}) always spans the full available width.
665
1426
  */
666
1427
  readonly limitedWidth?: IObservable<number | undefined>;
1428
+ /**
1429
+ * Diff mode only: render every read-only original decoration in active
1430
+ * (source) form, so even whole-block removals expose their markdown markers
1431
+ * as real text. Used by the diff-coverage fixture to verify that every
1432
+ * changed original character is rendered somewhere; off in normal use, where
1433
+ * whole removals show a clean solid band.
1434
+ */
1435
+ readonly diffDecorationsActive?: boolean;
667
1436
  }
668
1437
 
669
1438
  export declare class EmphasisAstNode extends AstNode {
@@ -683,6 +1452,111 @@ declare class EmphasisViewData {
683
1452
  constructor(ast: EmphasisAstNode, content: readonly AnyViewData[]);
684
1453
  }
685
1454
 
1455
+ export declare function escapeFindRegex(value: string): string;
1456
+
1457
+ export declare const FIND_MATCH_LIMIT = 19999;
1458
+
1459
+ export declare function findBlockAtOffset(doc: DocumentAstNode, offset: SourceOffset): BlockAstNode | undefined;
1460
+
1461
+ export declare class FindController extends Disposable {
1462
+ private readonly _editorModel;
1463
+ private readonly _view;
1464
+ private readonly _options;
1465
+ readonly model: FindModel;
1466
+ readonly widget: FindWidget;
1467
+ private readonly _selectionForScope;
1468
+ private _forcedMatch;
1469
+ private _selectedMatch;
1470
+ private _observedSourceTextId;
1471
+ private readonly _sourceEditTracker;
1472
+ private _revealRequest;
1473
+ constructor(_editorModel: EditorModel, _view: EditorView, _options: FindControllerOptions);
1474
+ private _setForcedMarkerVisibleBlocks;
1475
+ openAndFocus(): void;
1476
+ close(): void;
1477
+ private _handleKeyDown;
1478
+ private _cancelRevealRequest;
1479
+ private _findByKeyboard;
1480
+ private _querySeed;
1481
+ private _prepareSeed;
1482
+ private _selectedSingleLineText;
1483
+ private _toggleFindInSelection;
1484
+ }
1485
+
1486
+ export declare interface FindControllerOptions {
1487
+ readonly keyboardPlatform: KeyboardPlatform;
1488
+ }
1489
+
1490
+ export declare type FindDirection = 'next' | 'previous';
1491
+
1492
+ export declare class FindHighlightsView extends Disposable {
1493
+ private readonly _view;
1494
+ private readonly _matchesLayer;
1495
+ private readonly _currentLayer;
1496
+ private readonly _highlightRegistration;
1497
+ private readonly _resizeObserver;
1498
+ private readonly _resizeObservedElements;
1499
+ private _snapshot;
1500
+ private _paintRaf;
1501
+ constructor(_view: EditorView, findModel: FindModel);
1502
+ private _schedulePaint;
1503
+ private _paint;
1504
+ private _observeResizeAncestors;
1505
+ private _paintRanges;
1506
+ }
1507
+
1508
+ export declare interface FindMatchesResult {
1509
+ readonly matches: readonly OffsetRange[];
1510
+ readonly isCapped: boolean;
1511
+ }
1512
+
1513
+ export declare class FindModel extends Disposable {
1514
+ private readonly _editorModel;
1515
+ readonly isRevealed: ISettableObservable<boolean, void>;
1516
+ readonly searchString: ISettableObservable<string, void>;
1517
+ readonly isRegex: ISettableObservable<boolean, void>;
1518
+ readonly matchCase: ISettableObservable<boolean, void>;
1519
+ readonly wholeWord: ISettableObservable<boolean, void>;
1520
+ readonly searchScope: ISettableObservable<OffsetRange | undefined, void>;
1521
+ readonly currentMatch: ISettableObservable<OffsetRange | undefined, void>;
1522
+ readonly loop: ISettableObservable<boolean, void>;
1523
+ readonly searchResult: IObservableWithChange< {
1524
+ kind: "invalid";
1525
+ error: Error;
1526
+ pattern?: undefined;
1527
+ matches?: undefined;
1528
+ isCapped?: undefined;
1529
+ } | {
1530
+ kind: "valid";
1531
+ pattern: FindPattern;
1532
+ matches: readonly OffsetRange[];
1533
+ isCapped: boolean;
1534
+ error?: undefined;
1535
+ }, void>;
1536
+ readonly matchesCount: IObservableWithChange<number, void>;
1537
+ readonly isCapped: IObservableWithChange<boolean, void>;
1538
+ readonly currentMatchPosition: IObservableWithChange<number, void>;
1539
+ private _searchOrigin;
1540
+ private readonly _sourceEditTracker;
1541
+ private _pendingInitialDirection;
1542
+ constructor(_editorModel: EditorModel);
1543
+ reveal(options: {
1544
+ readonly origin: number;
1545
+ readonly searchString?: string;
1546
+ readonly direction?: FindDirection;
1547
+ }): void;
1548
+ hide(): void;
1549
+ setSearchOrigin(offset: number): void;
1550
+ setSearchScope(scope: OffsetRange | undefined): void;
1551
+ moveToNextMatch(): OffsetRange | undefined;
1552
+ moveToPreviousMatch(): OffsetRange | undefined;
1553
+ private _move;
1554
+ private _selectFromOrigin;
1555
+ private _mapStateThroughEdit;
1556
+ private _inputSnapshot;
1557
+ private _readInputSnapshot;
1558
+ }
1559
+
686
1560
  /**
687
1561
  * Source offset (relative to `root`) of the node with `target`'s id, or
688
1562
  * `undefined` when it is not in the tree. Ids are stable across edits, so this
@@ -690,14 +1564,117 @@ declare class EmphasisViewData {
690
1564
  */
691
1565
  export declare function findNodeOffsetById(root: AstNode, target: AstNode): number | undefined;
692
1566
 
693
- export declare function findWordAt(text: string, offset: number): {
1567
+ export declare class FindPattern {
1568
+ private readonly _source;
1569
+ private readonly _flags;
1570
+ private readonly _wholeWord;
1571
+ private readonly _wordSeparators;
1572
+ readonly isEmpty: boolean;
1573
+ private constructor();
1574
+ static create(query: FindQuery): FindQueryResult;
1575
+ findMatches(text: string, scope?: OffsetRange, limit?: number): FindMatchesResult;
1576
+ findNextMatch(text: string, after: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1577
+ findPreviousMatch(text: string, before: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1578
+ private _forEachMatch;
1579
+ }
1580
+
1581
+ export declare interface FindQuery {
1582
+ readonly searchString: string;
1583
+ readonly isRegex: boolean;
1584
+ readonly matchCase: boolean;
1585
+ readonly wholeWord: boolean;
1586
+ readonly wordSeparators: string;
1587
+ }
1588
+
1589
+ export declare type FindQueryResult = {
1590
+ readonly kind: 'valid';
1591
+ readonly pattern: FindPattern;
1592
+ } | {
1593
+ readonly kind: 'invalid';
1594
+ readonly error: Error;
1595
+ };
1596
+
1597
+ export declare type FindSearchResult = {
1598
+ readonly kind: 'valid';
1599
+ readonly pattern: FindPattern;
1600
+ readonly matches: readonly OffsetRange[];
1601
+ readonly isCapped: boolean;
1602
+ } | {
1603
+ readonly kind: 'invalid';
1604
+ readonly error: Error;
1605
+ };
1606
+
1607
+ export declare class FindWidget extends Disposable {
1608
+ private readonly _view;
1609
+ private readonly _options;
1610
+ readonly element: HTMLElement;
1611
+ readonly panelElement: HTMLElement;
1612
+ readonly focused: ISettableObservable<boolean, void>;
1613
+ private readonly _inputShell;
1614
+ private readonly _input;
1615
+ private readonly _matchesCount;
1616
+ private readonly _previousButton;
1617
+ private readonly _nextButton;
1618
+ private readonly _selectionButton;
1619
+ private readonly _caseButton;
1620
+ private readonly _wholeWordButton;
1621
+ private readonly _regexButton;
1622
+ private readonly _error;
1623
+ constructor(_view: EditorView, _options: FindWidgetOptions);
1624
+ focusAndSelect(): void;
1625
+ private _registerButton;
1626
+ private _render;
1627
+ }
1628
+
1629
+ export declare interface FindWidgetOptions {
1630
+ readonly findModel: FindModel;
1631
+ readonly canFindInSelection: IObservable<boolean>;
1632
+ readonly onNext: () => void;
1633
+ readonly onPrevious: () => void;
1634
+ readonly onToggleFindInSelection: () => void;
1635
+ readonly onClose: () => void;
1636
+ }
1637
+
1638
+ export declare function findWordAt(text: string, offset: number, config?: WordNavigationConfig): {
694
1639
  start: number;
695
1640
  end: number;
696
1641
  };
697
1642
 
698
- export declare function findWordBoundaryLeft(text: string, offset: number): number;
1643
+ export declare function findWordBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
699
1644
 
700
- export declare function findWordBoundaryRight(text: string, offset: number): number;
1645
+ export declare function findWordBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
1646
+
1647
+ export declare function findWordDeleteBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
1648
+
1649
+ export declare function findWordDeleteBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
1650
+
1651
+ /**
1652
+ * A leading YAML front matter block. The YAML value is intentionally opaque:
1653
+ * only the two fences and the exact source between them are modeled.
1654
+ */
1655
+ export declare class FrontMatterAstNode extends BlockAstNodeBase {
1656
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
1657
+ readonly leadingTrivia?: GlueAstNode | undefined;
1658
+ readonly kind = "frontMatter";
1659
+ constructor(content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
1660
+ get children(): readonly AstNode[];
1661
+ get openFence(): MarkerAstNode | undefined;
1662
+ get closeFence(): MarkerAstNode | undefined;
1663
+ get value(): MarkerAstNode | undefined;
1664
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
1665
+ withLeadingTrivia(trivia: GlueAstNode | undefined): FrontMatterAstNode;
1666
+ }
1667
+
1668
+ declare class FrontMatterViewData {
1669
+ readonly ast: FrontMatterAstNode;
1670
+ /** Active: render both fences; inactive: render only the opaque YAML value. */
1671
+ readonly showMarkup: boolean;
1672
+ readonly content: readonly AnyViewData[];
1673
+ readonly kind = "frontMatter";
1674
+ constructor(ast: FrontMatterAstNode,
1675
+ /** Active: render both fences; inactive: render only the opaque YAML value. */
1676
+ showMarkup: boolean, content: readonly AnyViewData[]);
1677
+ }
701
1678
 
702
1679
  export declare function getAnnotatedSource(node: AstNode, source: string, offset?: number): string;
703
1680
 
@@ -731,6 +1708,29 @@ declare class GlueViewData {
731
1708
  decorateNewline: boolean);
732
1709
  }
733
1710
 
1711
+ /**
1712
+ * A single gutter marker: a source {@link OffsetRange} tagged with a
1713
+ * {@link GutterMarkerType}. The view resolves the range to the visual lines it
1714
+ * covers and paints a bar (or, for `deleted`, a wedge at the range position) in
1715
+ * the left gutter.
1716
+ *
1717
+ * A `deleted` marker is normally an empty range (`range.isEmpty`) sitting at the
1718
+ * boundary where the removed text used to be — there is nothing left to span,
1719
+ * so it is drawn as a caret between lines rather than a bar.
1720
+ */
1721
+ export declare interface GutterMarker {
1722
+ readonly range: OffsetRange;
1723
+ readonly type: GutterMarkerType;
1724
+ }
1725
+
1726
+ /**
1727
+ * The kind of change a gutter marker represents, mirroring the three states a
1728
+ * source-control diff distinguishes (the git change markers in the editor
1729
+ * gutter): a freshly inserted region, an edited region, and a point where
1730
+ * content was removed.
1731
+ */
1732
+ export declare type GutterMarkerType = 'added' | 'modified' | 'deleted';
1733
+
734
1734
  export declare class HeadingAstNode extends BlockAstNodeBase {
735
1735
  readonly level: 1 | 2 | 3 | 4 | 5 | 6;
736
1736
  readonly marker: MarkerAstNode;
@@ -751,6 +1751,10 @@ declare class HeadingViewData {
751
1751
  constructor(ast: HeadingAstNode, content: readonly AnyViewData[]);
752
1752
  }
753
1753
 
1754
+ export declare function hiddenCursorRanges(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number): readonly OffsetRange[];
1755
+
1756
+ declare type HistoryKeyboardAction = 'undo' | 'redo';
1757
+
754
1758
  /**
755
1759
  * The editor operations a clipboard strategy drives. The strategy never
756
1760
  * touches the model or the DOM directly — it asks through this seam, so the
@@ -787,6 +1791,9 @@ export declare interface IClipboardStrategy {
787
1791
  connect(context: IClipboardContext): IDisposable;
788
1792
  }
789
1793
 
1794
+ /** A live rendering of a {@link CommentsModel}. Dispose to unmount it. */
1795
+ export declare type ICommentsPresenter = IDisposable;
1796
+
790
1797
  /** The Monarch language definitions the default highlighter wires up. */
791
1798
  export declare interface IDefaultMonarchGrammars {
792
1799
  typescript: unknown;
@@ -796,6 +1803,72 @@ export declare interface IDefaultMonarchGrammars {
796
1803
  python: unknown;
797
1804
  rust: unknown;
798
1805
  shell: unknown;
1806
+ yaml: unknown;
1807
+ }
1808
+
1809
+ /**
1810
+ * A live editor embedded in place of a fenced code block's *rendered* form.
1811
+ *
1812
+ * This is the internal seam between the block view and a concrete embedded
1813
+ * editor (e.g. an `<iframe>` speaking the web-editor protocol). The block view
1814
+ * only speaks string edits: it pushes the block's content down via
1815
+ * {@link setContent} and receives the editor's own changes back through
1816
+ * {@link onEdit} (set by the block view on each (re)construction, so it always
1817
+ * routes to the current AST node). The concrete implementation owns its DOM,
1818
+ * transport, and lifecycle.
1819
+ *
1820
+ * A single instance is adopted across re-renders (like the highlighter session)
1821
+ * so the underlying editor keeps its state across edits — see
1822
+ * {@link CodeBlockViewNode}.
1823
+ */
1824
+ declare interface IEmbeddedCodeEditor {
1825
+ /** The element mounted as the block's rendered form. */
1826
+ readonly element: HTMLElement;
1827
+ /**
1828
+ * Document → editor. The block's content changed (from any source). Must be
1829
+ * idempotent: pushing the content the editor already holds is a no-op, which
1830
+ * is how edits the editor itself originated are prevented from echoing back.
1831
+ */
1832
+ setContent(content: string): void;
1833
+ /**
1834
+ * Optional synchronous height (px) to reserve for `content` *before* the
1835
+ * editor has laid out. Return `undefined` to let the editor size itself
1836
+ * (the implementation may report its real height later). Lets a registration
1837
+ * avoid a layout jump when it can cheaply estimate the size from content.
1838
+ */
1839
+ estimateHeight?(content: string): number | undefined;
1840
+ /**
1841
+ * Editor → document. Set by the block view on every (re)construction to
1842
+ * route the editor's own edits, expressed in the block's *content*
1843
+ * coordinates, to the current AST node.
1844
+ */
1845
+ onEdit?: (edit: StringEdit) => void;
1846
+ dispose(): void;
1847
+ }
1848
+
1849
+ /** Creates an {@link IEmbeddedCodeEditor} for a fenced block, or opts out. */
1850
+ declare interface IEmbeddedCodeEditorFactory {
1851
+ /**
1852
+ * Return an editor for a fenced block of `language`, or `undefined` to fall
1853
+ * back to the default (highlighting / {@link BlockViewOptions.renderCustomCodeBlock}).
1854
+ */
1855
+ create(language: string, initialContent: string): IEmbeddedCodeEditor | undefined;
1856
+ }
1857
+
1858
+ /**
1859
+ * Routes undo and redo to whatever owns the document's history: the editor
1860
+ * itself on a standalone page, or the enclosing document in a host like
1861
+ * VS Code.
1862
+ */
1863
+ export declare interface IHistoryStrategy {
1864
+ undo(): void;
1865
+ redo(): void;
1866
+ /**
1867
+ * Invoked around each source mutation so the strategy can record it.
1868
+ * Implemented only by strategies that build their own history; a host that
1869
+ * forwards edits to a VS Code `TextDocument` lets it record them instead.
1870
+ */
1871
+ record?(operation: () => void, edit?: StringEdit): void;
799
1872
  }
800
1873
 
801
1874
  export declare class ImageAstNode extends AstNode {
@@ -832,6 +1905,14 @@ export declare interface IMonarchApi {
832
1905
  MonarchTokenizer: new (languageService: unknown, standaloneThemeService: unknown, languageId: string, lexer: unknown, configurationService: unknown) => MonarchTokenizer;
833
1906
  }
834
1907
 
1908
+ /** Controls tab-stop insertion and non-list line indentation. */
1909
+ export declare interface IndentationConfig {
1910
+ /** Number of visual columns between tab stops. */
1911
+ readonly tabSize: number;
1912
+ /** Whether indentation uses spaces instead of tab characters. */
1913
+ readonly insertSpaces: boolean;
1914
+ }
1915
+
835
1916
  export declare type InlineAstNode = TextAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode;
836
1917
 
837
1918
  export declare class InlineCodeAstNode extends AstNode {
@@ -881,6 +1962,27 @@ export declare const insertLineBreak: EditCommand;
881
1962
 
882
1963
  export declare const insertParagraph: EditCommand;
883
1964
 
1965
+ /**
1966
+ * Context-aware Enter. The behaviour is chosen from the active block:
1967
+ * - paragraph / heading / thematic break — the "rich text" thing: at the
1968
+ * block's end arm a transient empty paragraph (see {@link SmartEnterResult});
1969
+ * elsewhere split into two paragraphs (`\n\n`).
1970
+ * - fenced code / front matter — insert a newline that preserves the current
1971
+ * line's indentation, staying inside the fences.
1972
+ * - block quote — continue the quote (`\n> `); an empty quote line exits it.
1973
+ * - list — continue the list with the next marker (incrementing ordered
1974
+ * numbers, re-emitting task checkboxes); an empty item exits the list.
1975
+ * A non-collapsed selection, or any other block, falls back to a plain soft line
1976
+ * break, preserving today's behaviour.
1977
+ */
1978
+ export declare const insertSmartEnter: (ctx: CursorCommandContext) => SmartEnterResult;
1979
+
1980
+ /**
1981
+ * VS Code-style Tab: insert to the next tab stop for a caret or partial
1982
+ * single-line selection, and indent every selected line for a line selection.
1983
+ */
1984
+ export declare function insertTab(config?: IndentationConfig): EditCommand;
1985
+
884
1986
  export declare function insertText(text: string): EditCommand;
885
1987
 
886
1988
  /**
@@ -922,6 +2024,29 @@ export declare interface ISyntaxHighlighterDocument extends IDisposable {
922
2024
  readonly snapshot: IObservableWithChange<ISyntaxHighlightedSnapshot, LengthEdit>;
923
2025
  }
924
2026
 
2027
+ export declare interface KeyboardBinding {
2028
+ readonly key: string;
2029
+ readonly modifiers?: KeyboardModifiers;
2030
+ readonly platforms?: readonly KeyboardPlatform[];
2031
+ readonly action: EditorKeyboardAction;
2032
+ }
2033
+
2034
+ export declare interface KeyboardModifiers {
2035
+ readonly shift?: boolean;
2036
+ readonly alt?: boolean;
2037
+ readonly ctrl?: boolean;
2038
+ readonly meta?: boolean;
2039
+ }
2040
+
2041
+ export declare type KeyboardPlatform = 'macos' | 'windows' | 'linux';
2042
+
2043
+ export declare interface KeyboardProfile {
2044
+ /**
2045
+ * Bindings in priority order. The first exact key/modifier/platform match wins.
2046
+ */
2047
+ readonly bindings: readonly KeyboardBinding[];
2048
+ }
2049
+
925
2050
  declare abstract class LeafAstNode extends AstNode {
926
2051
  abstract readonly content: string;
927
2052
  get children(): readonly AstNode[];
@@ -1034,6 +2159,32 @@ declare class ListViewData {
1034
2159
  constructor(ast: ListAstNode, content: readonly AnyViewData[]);
1035
2160
  }
1036
2161
 
2162
+ /**
2163
+ * Compact in-memory history for editors that hold the only copy of the
2164
+ * document, such as a standalone browser page. Where the surrounding host
2165
+ * already records history — a VS Code `TextDocument` — forward to that
2166
+ * instead.
2167
+ */
2168
+ export declare class LocalHistoryStrategy implements IHistoryStrategy {
2169
+ private readonly _model;
2170
+ private readonly _past;
2171
+ private readonly _future;
2172
+ /**
2173
+ * The source text as of the last change this strategy recorded or applied.
2174
+ * Any other value means the document was replaced behind its back, so the
2175
+ * stored edits no longer line up and must be discarded rather than applied.
2176
+ */
2177
+ private _lastKnownText;
2178
+ constructor(_model: EditorModel);
2179
+ record(operation: () => void, edit?: StringEdit): void;
2180
+ undo(): void;
2181
+ redo(): void;
2182
+ /** The entry on top of `stack`, or `undefined` when it cannot be applied. */
2183
+ private _peekApplicable;
2184
+ private _apply;
2185
+ private _clear;
2186
+ }
2187
+
1037
2188
  /**
1038
2189
  * Parses markdown into a {@link DocumentAstNode}.
1039
2190
  *
@@ -1140,8 +2291,8 @@ export declare class MeasuredLayoutDebugRendering {
1140
2291
  * Exposes two DOM nodes the caller can place independently:
1141
2292
  *
1142
2293
  * - {@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.
2294
+ * inside the editor overlay container so dashed line-bands and run-boxes
2295
+ * share the measured editor-local coordinates.
1145
2296
  * - {@link infoElement} — block-flow; the caller mounts it as a sibling
1146
2297
  * *below* the editor. Contains the per-block summary table that used
1147
2298
  * to live on the overlay.
@@ -1152,7 +2303,6 @@ export declare class MeasuredLayoutDebugRendering {
1152
2303
  * the derived subscribed.
1153
2304
  */
1154
2305
  export declare class MeasuredLayoutDebugView extends Disposable {
1155
- private readonly _overlayParent;
1156
2306
  readonly overlayElement: HTMLElement;
1157
2307
  readonly infoElement: HTMLElement;
1158
2308
  readonly rendering: IObservable<MeasuredLayoutDebugRendering>;
@@ -1165,6 +2315,7 @@ export declare class MeasuredLayoutDebugView extends Disposable {
1165
2315
 
1166
2316
  export declare interface MeasuredLayoutDebugViewOptions {
1167
2317
  readonly model: MeasuredLayoutModel;
2318
+ readonly coordinateSpace: EditorCoordinateSpace;
1168
2319
  /**
1169
2320
  * DEBUG ONLY. Maps an absolute source offset to a fill color for that
1170
2321
  * character's glyph rect. The fixture passes the same function to the
@@ -1199,10 +2350,9 @@ export declare interface MeasuredLayoutDebugViewOptions {
1199
2350
  export declare class MeasuredLayoutModel {
1200
2351
  readonly measurements: ISettableObservable<readonly BlockMeasurement[], void>;
1201
2352
  /**
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.
2353
+ * Concatenated visual line map across all mounted blocks. Every per-block
2354
+ * map uses the same editor-local coordinate space, so concatenation is
2355
+ * well-formed without translation or re-sorting.
1206
2356
  */
1207
2357
  readonly visualLineMap: IObservableWithChange<VisualLineMap, void>;
1208
2358
  }
@@ -1244,14 +2394,25 @@ export declare class NativeClipboardStrategy implements IClipboardStrategy {
1244
2394
  connect(context: IClipboardContext): IDisposable;
1245
2395
  }
1246
2396
 
2397
+ declare interface NestedItem {
2398
+ readonly kind: 'nested';
2399
+ readonly original: AstNode;
2400
+ readonly originalStart: number;
2401
+ readonly modified: AstNode;
2402
+ readonly modifiedStart: number;
2403
+ readonly children: readonly DiffItem[];
2404
+ }
2405
+
1247
2406
  /**
1248
2407
  * Move the cursor one position left or right, skipping over hidden marker
1249
2408
  * ranges in inactive blocks (and inactive items of an active list).
1250
2409
  */
1251
- export declare function nextCursorPosition(doc: DocumentAstNode, activeBlock: BlockAstNode | undefined, cursor: number, direction: 'left' | 'right'): number;
2410
+ export declare function nextCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, direction: 'left' | 'right'): number;
1252
2411
 
1253
2412
  declare const NO_ACTIVE_BLOCKS: unique symbol;
1254
2413
 
2414
+ export declare function normalizeCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, target: number, direction: 'left' | 'right', includeHiddenRangeBoundary?: boolean): number;
2415
+
1255
2416
  export declare class OffsetRange {
1256
2417
  readonly start: number;
1257
2418
  readonly endExclusive: number;
@@ -1279,6 +2440,9 @@ export declare class OffsetRange {
1279
2440
  toString(): string;
1280
2441
  }
1281
2442
 
2443
+ /** Outdent the current line, or every line touched by the selection. */
2444
+ export declare function outdent(config?: IndentationConfig): EditCommand;
2445
+
1282
2446
  export declare class ParagraphAstNode extends BlockAstNodeBase {
1283
2447
  readonly content: readonly (InlineAstNode | GlueAstNode)[];
1284
2448
  readonly leadingTrivia?: GlueAstNode | undefined;
@@ -1297,7 +2461,48 @@ declare class ParagraphViewData {
1297
2461
  }
1298
2462
 
1299
2463
  /**
1300
- * Immutable point in 2D space, in CSS-pixel client coordinates.
2464
+ * A *transient* editing state: the empty paragraph the user conjured by
2465
+ * pressing Enter at the end of a paragraph. Markdown has no empty-paragraph
2466
+ * node, so this never lives in {@link EditorModel['sourceText']} or the parsed
2467
+ * {@link EditorModel.document} — it is pure edit intent that the view renders
2468
+ * as a synthetic blank line and that the controller either *materializes* (the
2469
+ * user types) or *cancels* (the user navigates away / backspaces).
2470
+ */
2471
+ declare interface PendingParagraph {
2472
+ /** The paragraph the blank line is rendered directly after. */
2473
+ readonly anchorBlock: BlockAstNode;
2474
+ /**
2475
+ * Source region rewritten when the pending paragraph is materialized — the
2476
+ * gap between {@link anchorBlock}'s text and whatever follows it.
2477
+ */
2478
+ readonly replaceRange: OffsetRange;
2479
+ /** Whether {@link replaceRange} ends at the end of the document. */
2480
+ readonly atEof: boolean;
2481
+ /**
2482
+ * A throwaway AST node that exists only to give the synthetic view child a
2483
+ * stable identity across render frames (the view pairs nodes by `ast.id`).
2484
+ * It is never part of {@link document}.
2485
+ */
2486
+ readonly syntheticAst: ParagraphAstNode;
2487
+ }
2488
+
2489
+ /**
2490
+ * View-data for the transient empty paragraph (see `PendingParagraph` in the
2491
+ * model). It carries only the throwaway {@link ParagraphAstNode} that gives the
2492
+ * rendered blank line a stable identity across frames; it has no content and is
2493
+ * never measured or part of the selection geometry — the caret is positioned
2494
+ * over it via a dedicated rect, not via the visual-line map.
2495
+ */
2496
+ declare class PendingParagraphViewData {
2497
+ readonly ast: ParagraphAstNode;
2498
+ readonly kind = "pendingParagraph";
2499
+ constructor(ast: ParagraphAstNode);
2500
+ }
2501
+
2502
+ /**
2503
+ * Immutable point in a caller-defined 2D CSS-pixel coordinate space.
2504
+ * Coordinate-owning APIs must document whether values are viewport-client or
2505
+ * editor-local; values from different spaces must not be mixed.
1301
2506
  */
1302
2507
  export declare class Point2D {
1303
2508
  readonly x: number;
@@ -1308,8 +2513,8 @@ export declare class Point2D {
1308
2513
  }
1309
2514
 
1310
2515
  /**
1311
- * Immutable axis-aligned rectangle in 2D space, in CSS-pixel client
1312
- * coordinates. `x`/`y` is the top-left corner, growing right/down.
2516
+ * Immutable axis-aligned rectangle in a caller-defined 2D CSS-pixel coordinate
2517
+ * space. `x`/`y` is the top-left corner, growing right/down.
1313
2518
  *
1314
2519
  * Half-open in both dimensions: `right` and `bottom` are excluded.
1315
2520
  */
@@ -1335,6 +2540,23 @@ export declare class Rect2D {
1335
2540
  translate(dx: number, dy: number): Rect2D;
1336
2541
  }
1337
2542
 
2543
+ declare interface RemovedItem {
2544
+ readonly kind: 'removed';
2545
+ readonly node: AstNode;
2546
+ readonly originalStart: number;
2547
+ readonly deletedLocal: readonly AnnotatedRange[];
2548
+ }
2549
+
2550
+ declare interface ReplacedItem {
2551
+ readonly kind: 'replaced';
2552
+ readonly original: AstNode;
2553
+ readonly originalStart: number;
2554
+ readonly modified: AstNode;
2555
+ readonly modifiedStart: number;
2556
+ readonly insertedLocal: readonly AnnotatedRange[];
2557
+ readonly deletedLocal: readonly AnnotatedRange[];
2558
+ }
2559
+
1338
2560
  export declare const selectAll: SelectionCommand;
1339
2561
 
1340
2562
  export declare function selectBlock(ctx: CursorCommandContext, blockRange: OffsetRange): Selection_2;
@@ -1360,8 +2582,13 @@ export { Selection_2 as Selection }
1360
2582
  export declare interface SelectionBlock {
1361
2583
  readonly block: BlockAstNode;
1362
2584
  readonly absoluteStart: number;
1363
- readonly viewNode: ViewNode;
1364
- readonly element: HTMLElement;
2585
+ /** Block border box in editor-local coordinates. */
2586
+ readonly rect: Rect2D;
2587
+ /** Visible horizontal padding-box bounds for a scrolling block. */
2588
+ readonly viewportClip: {
2589
+ readonly left: number;
2590
+ readonly right: number;
2591
+ } | undefined;
1365
2592
  }
1366
2593
 
1367
2594
  export declare type SelectionCommand = (ctx: CursorCommandContext, offset: SourceOffset) => Selection_2;
@@ -1373,6 +2600,9 @@ export declare interface SelectionRect {
1373
2600
  readonly height: number;
1374
2601
  }
1375
2602
 
2603
+ /** The interaction that produced the current editor selection. */
2604
+ export declare type SelectionSource = 'user' | 'find';
2605
+
1376
2606
  /**
1377
2607
  * Owns the SVG overlay that paints the selection.
1378
2608
  *
@@ -1393,11 +2623,10 @@ export declare interface SelectionRect {
1393
2623
  * envelope shape used by IDE selection rendering.
1394
2624
  */
1395
2625
  export declare class SelectionView extends Disposable {
1396
- private readonly _parent;
1397
2626
  readonly element: SVGSVGElement;
1398
2627
  readonly rendering: IObservable<SelectionViewRendering>;
1399
2628
  private readonly _path;
1400
- constructor(_parent: HTMLElement, options: SelectionViewOptions);
2629
+ constructor(options: SelectionViewOptions);
1401
2630
  }
1402
2631
 
1403
2632
  export declare interface SelectionViewOptions {
@@ -1413,6 +2642,25 @@ export declare class SelectionViewRendering {
1413
2642
 
1414
2643
  export declare const selectWord: SelectionCommand;
1415
2644
 
2645
+ /**
2646
+ * The outcome of {@link insertSmartEnter}: either a concrete source edit (the
2647
+ * ordinary cases), or a request to arm a transient empty paragraph (Enter at
2648
+ * the very end of a paragraph), which the controller turns into
2649
+ * {@link EditorModel.armPendingParagraph} rather than a source edit. Modelling
2650
+ * the empty paragraph as state instead of source keeps the document valid
2651
+ * Markdown — which has no empty-paragraph node — until the user actually types.
2652
+ */
2653
+ export declare type SmartEnterResult = {
2654
+ readonly kind: 'edit';
2655
+ readonly edit: StringEdit;
2656
+ readonly selection: Selection_2;
2657
+ } | {
2658
+ readonly kind: 'pending';
2659
+ readonly anchorBlock: BlockAstNode;
2660
+ readonly replaceRange: OffsetRange;
2661
+ readonly atEof: boolean;
2662
+ };
2663
+
1416
2664
  /**
1417
2665
  * A run of {@link Token}s together with the exact {@link OffsetRange} they
1418
2666
  * cover.
@@ -1426,8 +2674,39 @@ export declare interface SnapshotTokens {
1426
2674
  readonly tokens: readonly Token[];
1427
2675
  }
1428
2676
 
2677
+ /** Metadata delivered synchronously immediately before a model-owned source edit is applied. */
2678
+ export declare interface SourceEditEvent {
2679
+ readonly baseSourceTextId: number;
2680
+ readonly resultSourceTextId: number;
2681
+ readonly edit: StringEdit;
2682
+ readonly transaction: ITransaction;
2683
+ }
2684
+
1429
2685
  export declare type SourceOffset = number;
1430
2686
 
2687
+ export declare abstract class StackedCommentsPresenter extends Disposable implements ICommentsPresenter {
2688
+ protected readonly model: CommentsModel;
2689
+ protected readonly view: EditorView;
2690
+ protected readonly context?: CommentsPresenterContext | undefined;
2691
+ private readonly _layer;
2692
+ private readonly _entries;
2693
+ private _order;
2694
+ private _pendingRevealCommentId;
2695
+ constructor(model: CommentsModel, view: EditorView, context?: CommentsPresenterContext | undefined);
2696
+ /** Build the card DOM for a comment. Called once per new comment. */
2697
+ protected abstract createWidget(comment: Comment_2): StackWidget;
2698
+ revealComment(id: string): void;
2699
+ private _reconcile;
2700
+ private _relayout;
2701
+ private _revealPendingComment;
2702
+ }
2703
+
2704
+ /** The minimal widget contract a subclass must produce. */
2705
+ export declare interface StackWidget {
2706
+ readonly element: HTMLElement;
2707
+ dispose(): void;
2708
+ }
2709
+
1431
2710
  export declare class StrikethroughAstNode extends AstNode {
1432
2711
  readonly openMarker: MarkerAstNode;
1433
2712
  readonly content: readonly (InlineAstNode | GlueAstNode)[];
@@ -1470,6 +2749,11 @@ export declare class StringReplacement {
1470
2749
  constructor(replaceRange: OffsetRange, newText: string);
1471
2750
  get isEmpty(): boolean;
1472
2751
  equals(other: StringReplacement): boolean;
2752
+ /**
2753
+ * Narrows this replacement to the span that actually changes, by trimming
2754
+ * the prefix and suffix it shares with the text it replaces in `source`.
2755
+ */
2756
+ removeCommonSuffixPrefix(source: string): StringReplacement;
1473
2757
  toString(): string;
1474
2758
  }
1475
2759
 
@@ -1498,6 +2782,8 @@ declare class StrongViewData {
1498
2782
  constructor(ast: StrongAstNode, content: readonly AnyViewData[]);
1499
2783
  }
1500
2784
 
2785
+ declare type TabKeyboardAction = 'insert' | 'outdent';
2786
+
1501
2787
  export declare class TableAstNode extends BlockAstNodeBase {
1502
2788
  readonly content: readonly (TableRowAstNode | GlueAstNode)[];
1503
2789
  readonly leadingTrivia?: GlueAstNode | undefined;
@@ -1632,6 +2918,47 @@ export declare class Token {
1632
2918
  className: string | undefined);
1633
2919
  }
1634
2920
 
2921
+ declare interface UnchangedItem {
2922
+ readonly kind: 'unchanged';
2923
+ /** The modified-side node (identical in content to the original). */
2924
+ readonly node: AstNode;
2925
+ readonly modifiedStart: number;
2926
+ }
2927
+
2928
+ /**
2929
+ * A block whose token type the parser does not understand (a setext heading or
2930
+ * any future/extension construct). Rather than dropping the
2931
+ * span — which would demote its text to invisible glue — the parser captures the
2932
+ * whole source range verbatim as a single {@link MarkerAstNode} of kind
2933
+ * `content` and records the originating micromark {@link tokenType}, so the view
2934
+ * can render it as raw, editable text with an "unhandled" affordance. Offsets
2935
+ * stay sound: `content` tiles the block's full source span exactly.
2936
+ */
2937
+ declare class UnhandledBlockAstNode extends BlockAstNodeBase {
2938
+ readonly tokenType: string;
2939
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
2940
+ readonly leadingTrivia?: GlueAstNode | undefined;
2941
+ readonly kind = "unhandledBlock";
2942
+ constructor(tokenType: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
2943
+ get children(): readonly AstNode[];
2944
+ get code(): MarkerAstNode | undefined;
2945
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
2946
+ withLeadingTrivia(trivia: GlueAstNode | undefined): UnhandledBlockAstNode;
2947
+ protected _localEquals(o: this): boolean;
2948
+ }
2949
+
2950
+ /**
2951
+ * View-data for an {@link UnhandledBlockAstNode}. It has no active/inactive
2952
+ * split — the raw source *is* both the source and the rendered form — so it
2953
+ * carries no `showMarkup` flag; the renderer always shows the verbatim text.
2954
+ */
2955
+ declare class UnhandledBlockViewData {
2956
+ readonly ast: UnhandledBlockAstNode;
2957
+ readonly content: readonly AnyViewData[];
2958
+ readonly kind = "unhandledBlock";
2959
+ constructor(ast: UnhandledBlockAstNode, content: readonly AnyViewData[]);
2960
+ }
2961
+
1635
2962
  /**
1636
2963
  * Immutable view of an AST node. Pairs `ast` with its rendered `dom` and a
1637
2964
  * mirror of `ast.children` as ViewNode children. Source offsets are NEVER
@@ -1696,10 +3023,12 @@ export declare class ViewNode extends Disposable {
1696
3023
  /**
1697
3024
  * Map a DOM hit that lands on THIS node's own representation into a source
1698
3025
  * 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).
3026
+ * leaf maps the caret offset 1:1. For an element hit — an element-only node
3027
+ * (KaTeX math, `<hr>`, an image, a hidden marker) or a wrapper/container
3028
+ * element the platform reports a child-index offset, not a text caret, so
3029
+ * there is no internal mapping to honour: it snaps to the node's nearer
3030
+ * edge, `offset 0` (the "before" side) → start, any `offset >= 1` (the
3031
+ * "after" side) → end. Subclasses may override for finer control.
1703
3032
  */
1704
3033
  getLocalSourceRange(pos: DomPosition): OffsetRange;
1705
3034
  /**
@@ -1743,7 +3072,8 @@ export declare class VisualLine {
1743
3072
  /**
1744
3073
  * How `offset` relates to this line's runs:
1745
3074
  * - `'covers'`: a run starts at or strictly contains the offset
1746
- * (`start <= offset < endExclusive`) the caret belongs on this line.
3075
+ * (`start <= offset < endExclusive`), or a zero-length visual-line
3076
+ * anchor sits at the offset — the caret belongs on this line.
1747
3077
  * - `'end'`: the offset is only some run's trailing boundary
1748
3078
  * (`offset === endExclusive`) with no run covering it — a line-break
1749
3079
  * boundary the caret should leave for the next line.
@@ -1756,23 +3086,37 @@ export declare class VisualLine {
1756
3086
  */
1757
3087
  sourceDistanceTo(offset: SourceOffset): number;
1758
3088
  /**
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.
3089
+ * x of the caret position before `offset` on this line.
3090
+ *
3091
+ * The runs tile the source but are stored in paint order, not sorted by
3092
+ * source offset (hidden-marker runs are appended last). So this scans all
3093
+ * runs rather than assuming any ordering:
3094
+ *
3095
+ * - If some run *covers* `offset`, its own geometry places the caret
3096
+ * (exact glyph boundary for text runs). In the active, markers-visible
3097
+ * form every offset is covered, so this branch keeps distinct offsets
3098
+ * distinct.
3099
+ * - Otherwise `offset` sits in a gap — a hidden inline marker such as the
3100
+ * `**` of `**bold**`, or before/after the painted text. It snaps to the
3101
+ * seam between the source-nearest runs on either side: the right edge of
3102
+ * the closest run ending at/before `offset`, else the left edge of the
3103
+ * closest run starting at/after it. A hidden marker collapses to zero
3104
+ * width, so both edges coincide at the seam.
1763
3105
  */
1764
3106
  xAtOffset(offset: SourceOffset): number;
1765
3107
  /**
1766
3108
  * 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.
3109
+ * run, the run resolves the offset (exact glyph boundary for text runs,
3110
+ * nearer edge for source-less runs); otherwise it snaps to the closer
3111
+ * edge of the nearest run.
1769
3112
  */
1770
3113
  offsetAtX(x: number): SourceOffset;
1771
3114
  }
1772
3115
 
1773
3116
  /**
1774
3117
  * Geometry of the rendered document, as a map from source offsets to 2D
1775
- * positions and back.
3118
+ * positions and back. All geometry is expressed in the editor overlay's local
3119
+ * CSS-pixel coordinate space.
1776
3120
  *
1777
3121
  * Structure (top to bottom):
1778
3122
  *
@@ -1807,7 +3151,7 @@ export declare class VisualLineMap {
1807
3151
  static measure(blockViews: readonly {
1808
3152
  readonly absoluteStart: number;
1809
3153
  readonly viewNode: ViewNode;
1810
- }[]): VisualLineMap;
3154
+ }[], coordinateSpace: EditorCoordinateSpace, transform?: EditorCoordinateTransform): VisualLineMap;
1811
3155
  constructor(lines: readonly VisualLine[]);
1812
3156
  get lineCount(): number;
1813
3157
  get isEmpty(): boolean;
@@ -1845,6 +3189,8 @@ export declare class VisualLineMap {
1845
3189
  offsetAtPoint(point: Point2D): SourceOffset;
1846
3190
  /** Snap `x` to the nearest offset on a specific line. */
1847
3191
  offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
3192
+ lineStartOffset(lineIndex: number): SourceOffset | undefined;
3193
+ lineEndOffset(lineIndex: number): SourceOffset | undefined;
1848
3194
  }
1849
3195
 
1850
3196
  /**
@@ -1853,14 +3199,22 @@ export declare class VisualLineMap {
1853
3199
  * When constructed with a {@link VisualRunSource}, `xAtOffset` returns the
1854
3200
  * pixel-exact x of the caret before character `offset` by measuring the
1855
3201
  * prefix `[textNodeStart, textNodeStart + (offset - sourceStart))` with a
1856
- * DOM `Range`. Without a source it falls back to linear interpolation
1857
- * across `rect.width`.
3202
+ * DOM `Range`.
3203
+ *
3204
+ * A source-less run has no per-offset geometry: it either represents an
3205
+ * element-only block (KaTeX math, a mermaid/custom diagram, an image, an
3206
+ * inactive `<hr>`) whose box does not correspond to source offsets, or a
3207
+ * hand-built run in a test. Either way it maps between offsets and x by
3208
+ * snapping to the nearer edge of {@link rect} rather than fabricating
3209
+ * interior positions.
1858
3210
  */
1859
3211
  export declare class VisualRun {
1860
3212
  readonly sourceRange: OffsetRange;
1861
3213
  readonly rect: Rect2D;
1862
3214
  readonly source?: VisualRunSource | undefined;
1863
- constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined);
3215
+ readonly isVisualLineAnchor: boolean;
3216
+ static visualLineAnchor(sourceOffset: SourceOffset, rect: Rect2D): VisualRun;
3217
+ constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined, isVisualLineAnchor?: boolean);
1864
3218
  get sourceStart(): SourceOffset;
1865
3219
  get sourceEndExclusive(): SourceOffset;
1866
3220
  get sourceLength(): number;
@@ -1872,19 +3226,36 @@ export declare class VisualRun {
1872
3226
 
1873
3227
  /**
1874
3228
  * 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.
3229
+ * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`.
3230
+ * This matters for proportional fonts where character widths differ a lot
3231
+ * (e.g. `m` vs `i`): a caret placed by anything coarser than real glyph
3232
+ * measurement lands several pixels inside the wrong character.
1880
3233
  *
1881
- * Hand-built runs (tests) omit this; their `xAtOffset` falls back to
1882
- * linear interpolation.
3234
+ * A run without a source has no per-offset geometry, so it maps between
3235
+ * offsets and x by snapping to the nearer run edge. Real text runs always
3236
+ * carry a source; source-less runs are element-only blocks (see
3237
+ * {@link _appendElementBlockRun}) and hand-built runs in tests.
1883
3238
  */
1884
3239
  declare interface VisualRunSource {
1885
3240
  readonly textNode: Text;
1886
3241
  /** Offset within `textNode.data` corresponding to `sourceRange.start`. */
1887
3242
  readonly textNodeStart: number;
3243
+ readonly coordinateSpace: EditorCoordinateSpace;
3244
+ }
3245
+
3246
+ export declare const vscodeKeyboardProfile: KeyboardProfile;
3247
+
3248
+ export declare class VscodeStackedCommentsView extends StackedCommentsPresenter {
3249
+ protected createWidget(comment: Comment_2): StackWidget;
3250
+ }
3251
+
3252
+ export declare class VsCodeV2CommentsView extends StackedCommentsPresenter {
3253
+ protected createWidget(comment: Comment_2): StackWidget;
3254
+ }
3255
+
3256
+ export declare interface WordNavigationConfig {
3257
+ readonly wordSeparators: string;
3258
+ readonly wordSegmenterLocales: readonly string[];
1888
3259
  }
1889
3260
 
1890
3261
  export { }