@vscode/markdown-editor 0.0.2-6 → 0.0.2-61

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 (39) 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/commands.d.ts +65 -0
  8. package/dist/commands.js +159 -0
  9. package/dist/commands.js.map +1 -0
  10. package/dist/config-BGeaJqWk.js +286 -0
  11. package/dist/config-BGeaJqWk.js.map +1 -0
  12. package/dist/config.d.ts +10 -0
  13. package/dist/config.js +6 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/index.d.ts +1459 -104
  16. package/dist/index.js +6070 -2000
  17. package/dist/index.js.map +1 -1
  18. package/dist/markdown-editor.css +1 -0
  19. package/dist/observables.js +45 -43
  20. package/dist/observables.js.map +1 -1
  21. package/dist/{runOnChange-C00UIwqQ.js → runOnChange-e7FtCqOQ.js} +115 -111
  22. package/dist/runOnChange-e7FtCqOQ.js.map +1 -0
  23. package/dist/stringEdit-CVDbCUBY.js +215 -0
  24. package/dist/stringEdit-CVDbCUBY.js.map +1 -0
  25. package/dist/web-editors.d.ts +282 -0
  26. package/dist/web-editors.js +7240 -0
  27. package/dist/web-editors.js.map +1 -0
  28. package/package.json +60 -13
  29. package/src/contrib/comments/commentInput.css +150 -0
  30. package/src/contrib/comments/comments.css +129 -0
  31. package/src/contrib/commentsVscode/vscodeCommentWidgetV2.css +171 -0
  32. package/src/contrib/find/find.css +347 -0
  33. package/src/view/editor.css +505 -20
  34. package/src/view/themes/default.css +13 -4
  35. package/src/view/themes/github.css +16 -13
  36. package/src/view/themes/vscode-default.css +397 -0
  37. package/src/view/themes/vscode-github.css +393 -0
  38. package/dist/runOnChange-C00UIwqQ.js.map +0 -1
  39. /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;
@@ -126,11 +150,22 @@ export declare class BlockQuoteAstNode extends BlockAstNodeBase {
126
150
  declare class BlockQuoteViewData {
127
151
  readonly ast: BlockQuoteAstNode;
128
152
  readonly content: readonly AnyViewData[];
153
+ /** False while a pending paragraph replaces the final marker-only line. */
154
+ readonly showFinalMarkerOnlyLine: boolean;
129
155
  readonly kind = "blockQuote";
130
- constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[]);
156
+ constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[],
157
+ /** False while a pending paragraph replaces the final marker-only line. */
158
+ showFinalMarkerOnlyLine: boolean);
131
159
  }
132
160
 
133
- declare type BlockViewData = HeadingViewData | ParagraphViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData;
161
+ /**
162
+ * All blocks whose source range intersects `[start, endExclusive]`. A
163
+ * collapsed range (start === endExclusive) matches the block containing
164
+ * that offset (with the same boundary rule as {@link findBlockAtOffset}).
165
+ */
166
+ export declare function blocksIntersecting(doc: DocumentAstNode, start: SourceOffset, endExclusive: SourceOffset): BlockAstNode[];
167
+
168
+ declare type BlockViewData = HeadingViewData | ParagraphViewData | FrontMatterViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData | UnhandledBlockViewData;
134
169
 
135
170
  /**
136
171
  * Base view node for everything the editor renders, generic over the
@@ -151,6 +186,17 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
151
186
  constructor(data: T, dom: globalThis.Node, children: readonly ViewNode[]);
152
187
  get block(): BlockAstNode;
153
188
  get element(): HTMLElement;
189
+ /**
190
+ * The horizontal scroll viewport for selection/caret clipping
191
+ * ({@link blockViewportClip}). For most blocks the scroller *is*
192
+ * {@link element} — a code / math / unhandled block's `element` is the very
193
+ * `overflow-x: auto` box that scrolls. A table is the exception: its
194
+ * `element` stays the inner `<table>` (so the active/markers classes and
195
+ * `.md-table` theme styling are unaffected), but the box that actually
196
+ * scrolls is the wrapping `.md-table-wrapper`, so {@link TableViewNode}
197
+ * overrides this to return that wrapper.
198
+ */
199
+ get scrollElement(): HTMLElement;
154
200
  /**
155
201
  * Whether this already-built node can stand in for `data` unchanged. The
156
202
  * builder preserves view-data identity for any subtree whose ast and
@@ -158,7 +204,7 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
158
204
  * single identity check captures "nothing in my subtree changed" — and its
159
205
  * whole subtree, and any session it owns, are kept as-is.
160
206
  */
161
- canReuse(data: AnyViewData): boolean;
207
+ canReuse(data: AnyViewData, _options: BlockViewOptions | undefined): boolean;
162
208
  /**
163
209
  * Called by the view after this block is mounted and measured, with the
164
210
  * block's rendered height in px. The default is a no-op; subclasses whose
@@ -174,9 +220,10 @@ export declare interface BlockViewOptions {
174
220
  /**
175
221
  * Opens a link's URL. Called when the user activates a link: a plain click
176
222
  * 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')`.
223
+ * is active (source shown). Return `false` to use the anchor's native
224
+ * navigation behavior.
178
225
  */
179
- readonly onOpenLink?: (url: string, event: MouseEvent) => void;
226
+ readonly onOpenLink?: (url: string, event: MouseEvent) => false | void;
180
227
  /**
181
228
  * Colours fenced code blocks. When set, a code block's content is rendered
182
229
  * as a sequence of token spans instead of one plain text node. This is the
@@ -196,16 +243,43 @@ export declare interface BlockViewOptions {
196
243
  * `katexEditableIdentifiers.ts`).
197
244
  */
198
245
  readonly renderMath?: (request: MathRenderRequest) => MathRendering | undefined;
246
+ /**
247
+ * Pluggable factory for an in-place, interactive editor that replaces the
248
+ * *rendered* (inactive) form of a fenced code block — see
249
+ * {@link IEmbeddedCodeEditor}. When it returns an editor for the block's
250
+ * language, that editor's element is mounted instead of the highlighted
251
+ * code, and content flows both ways as string edits. Returning `undefined`
252
+ * falls back to the default rendering. EXPERIMENTAL.
253
+ */
254
+ readonly embeddedCodeEditorFactory?: IEmbeddedCodeEditorFactory;
255
+ /** Current read-only state forwarded to embedded code editors. */
256
+ readonly embeddedCodeEditorReadOnly?: boolean;
257
+ /** Identity used to invalidate previously created embedded editors. */
258
+ readonly embeddedCodeEditorFactoryVersion?: unknown;
259
+ /**
260
+ * Called when an {@link IEmbeddedCodeEditor} edits its content. `contentEdit`
261
+ * is in the block's *content* coordinates; the host translates it to a
262
+ * document edit (via {@link CodeBlockAstNode.codeOffset} and the block's
263
+ * offset) and applies it to the model.
264
+ */
265
+ readonly onEmbeddedCodeEditorEdit?: (block: CodeBlockAstNode, contentEdit: StringEdit) => void;
199
266
  }
200
267
 
201
268
  export declare class CodeBlockAstNode extends BlockAstNodeBase {
269
+ /** First token of the fenced code block info string, used for syntax highlighting. */
202
270
  readonly language: string;
271
+ /** Complete fenced code block info string, including metadata after the language token. */
272
+ readonly infoString: string;
203
273
  readonly content: readonly (MarkerAstNode | GlueAstNode)[];
204
274
  readonly leadingTrivia?: GlueAstNode | undefined;
205
275
  readonly kind = "codeBlock";
206
276
  private _previous?;
207
277
  private _contentEdit?;
208
- constructor(language: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
278
+ constructor(
279
+ /** First token of the fenced code block info string, used for syntax highlighting. */
280
+ language: string,
281
+ /** Complete fenced code block info string, including metadata after the language token. */
282
+ infoString: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
209
283
  get children(): readonly AstNode[];
210
284
  get openFence(): MarkerAstNode | undefined;
211
285
  get closeFence(): MarkerAstNode | undefined;
@@ -271,10 +345,260 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
271
345
  * its predecessor's subscription explicitly.
272
346
  */
273
347
  private _snapshotSub;
348
+ /**
349
+ * An in-place interactive editor (e.g. an iframe) mounted instead of the
350
+ * rendered code. Like {@link _session} it is adopted from `previous` across
351
+ * rebuilds so the underlying editor keeps its state, and must be disposed
352
+ * manually (a node reused as `previous` is never {@link dispose}d).
353
+ */
354
+ private _embeddedEditor;
355
+ private readonly _embeddedEditorFactoryVersion;
356
+ private readonly _embeddedEditorReadOnly;
357
+ canReuse(data: AnyViewData, options: BlockViewOptions | undefined): boolean;
274
358
  constructor(data: CodeBlockViewData, options: BlockViewOptions | undefined, previous: ViewNode | undefined);
275
359
  dispose(): void;
276
360
  }
277
361
 
362
+ /**
363
+ * Canonical editor command catalog. Standalone keyboard handling and host
364
+ * integrations derive their command registration and default keybindings from
365
+ * this list.
366
+ */
367
+ export declare const commands: readonly EditorCommandDefinition[];
368
+
369
+ /** A persistent comment anchored to a source range. */
370
+ declare interface Comment_2 {
371
+ readonly id: string;
372
+ /** Source range the comment refers to (its highlighted region). */
373
+ readonly range: OffsetRange;
374
+ /** The comment text. */
375
+ readonly body: string;
376
+ /** Display name of the author, if any. */
377
+ readonly author?: string;
378
+ /** Creation time (epoch ms), used to render a relative timestamp. */
379
+ readonly createdAt?: number;
380
+ }
381
+ export { Comment_2 as Comment }
382
+
383
+ /**
384
+ * A self-contained comment input box — a rounded panel with an auto-growing
385
+ * textarea and a send button, styled after the gdocs/Word "add a comment"
386
+ * affordance.
387
+ *
388
+ * This widget is *positioning-agnostic*: it only owns its own DOM and state.
389
+ * A host (the comment-mode controller, or a fixture) mounts {@link element}
390
+ * wherever it likes and is responsible for placing it relative to a selection.
391
+ *
392
+ * State is observable-driven (no framework): {@link value} reflects the live
393
+ * textarea content; submit/cancel are reported through the option callbacks.
394
+ */
395
+ export declare class CommentInputWidget extends Disposable {
396
+ private readonly _options?;
397
+ readonly element: HTMLElement;
398
+ private readonly _textarea;
399
+ private readonly _measure;
400
+ private readonly _submitButton;
401
+ private readonly _value;
402
+ /** Live, untrimmed textarea content. */
403
+ get value(): IObservable<string>;
404
+ /** The raw textarea, exposed so a host can move focus into it (e.g. on Tab). */
405
+ get inputElement(): HTMLTextAreaElement;
406
+ constructor(_options?: CommentInputWidgetOptions | undefined);
407
+ /** Move focus into the textarea (caret at the end). */
408
+ focus(): void;
409
+ /** Replace the textarea content. */
410
+ setText(text: string): void;
411
+ /** Clear the textarea. */
412
+ clear(): void;
413
+ private _submit;
414
+ private _autoSize;
415
+ }
416
+
417
+ export declare interface CommentInputWidgetOptions {
418
+ /** Placeholder shown while the textarea is empty. Defaults to "Add Comment". */
419
+ readonly placeholder?: string;
420
+ /** Called after the textarea changes size. */
421
+ readonly onDidChangeSize?: () => void;
422
+ /**
423
+ * Called when the user submits a non-empty comment (Enter or the send
424
+ * button). The text is trimmed; never called with an empty string.
425
+ */
426
+ readonly onSubmit?: (text: string) => void;
427
+ /** Called when the user dismisses the input (Escape). */
428
+ readonly onCancel?: () => void;
429
+ }
430
+
431
+ /**
432
+ * Comment mode — a gdocs/Word-style "add a comment" affordance layered on top of
433
+ * the editor *without modifying it*. It reads the editor's public observables
434
+ * ({@link EditorModel.readonlyMode}, {@link EditorModel.selection}) and the
435
+ * exposed {@link EditorView.caretRect} geometry, and mounts a
436
+ * {@link CommentInputWidget} into {@link EditorView.overlayContainer}.
437
+ *
438
+ * Behaviour:
439
+ * - Only active in read-only mode (the "review" view).
440
+ * - When a user-created selection is non-empty, the input box appears next to
441
+ * the caret (the selection's active end) but does NOT take focus, so keyboard
442
+ * selection keeps working. Programmatic selections such as find matches do
443
+ * not summon it. Press Tab to move focus into the box, then type.
444
+ * - The box appears on mouse-up, not mid-drag, so it doesn't flicker/jump
445
+ * while a selection is being dragged out (keyboard selection shows at once).
446
+ * - While the box has focus or holds a draft it is frozen in place (selection
447
+ * changes, drags and clicks no longer move it). It is dismissed by Escape,
448
+ * by submitting, or by blurring an empty box.
449
+ * - The editor's logical caret geometry remains available for anchoring in
450
+ * read-only mode even though the painted caret is hidden. While the box has
451
+ * focus, `.md-comment-active` also suppresses the painted caret in any mode.
452
+ */
453
+ export declare class CommentModeController extends Disposable {
454
+ private readonly _model;
455
+ private readonly _view;
456
+ private readonly _options?;
457
+ private static _isCommentableSelectionSource;
458
+ private readonly _widget;
459
+ private readonly _gap;
460
+ private _visible;
461
+ private _anchorX;
462
+ private _pinnedRange;
463
+ /**
464
+ * The range a comment was just submitted for. The box stays hidden for it
465
+ * until the selection changes, so submitting doesn't immediately re-summon an
466
+ * empty box on the still-selected text.
467
+ */
468
+ private _submittedRange;
469
+ constructor(_model: EditorModel, _view: EditorView, _options?: CommentModeControllerOptions | undefined);
470
+ private _update;
471
+ private _show;
472
+ private _layoutHorizontally;
473
+ /** Force-hide and clear the box (used by Escape and submit). */
474
+ private _hide;
475
+ /**
476
+ * Hide unless the user is engaged with the box: it has focus or holds a
477
+ * non-empty draft. This preserves in-progress text and keeps a focused box
478
+ * open (it is dismissed explicitly via Escape/submit, or by blurring it).
479
+ */
480
+ private _autoHide;
481
+ private _widgetHasFocus;
482
+ /**
483
+ * The visible viewport (client coords) used for the flip-above decision: the
484
+ * nearest scrollable ancestor of the editor. `.md-editor` itself spans the
485
+ * full document height and never clips, so measuring against it would always
486
+ * report room below. Falls back to the window when nothing scrolls.
487
+ */
488
+ private _getViewportRect;
489
+ private _hideAndRefocus;
490
+ private _submit;
491
+ }
492
+
493
+ export declare interface CommentModeControllerOptions {
494
+ /** Called when the user submits a comment for the current selection. */
495
+ readonly onSubmit?: (submission: CommentSubmission) => void;
496
+ /** Gap (px) between the bottom of the selection and the top of the input box. */
497
+ readonly gap?: number;
498
+ }
499
+
500
+ /** Human-readable labels (for pickers / dropdowns). */
501
+ export declare const COMMENTS_DESIGN_LABELS: Record<CommentsDesign, string>;
502
+
503
+ /** design id → presenter factory over a shared CommentsModel + EditorView. */
504
+ export declare const COMMENTS_DESIGNS: Record<CommentsDesign, CommentsPresenterFactory>;
505
+
506
+ /** The available comment rendering designs. */
507
+ export declare type CommentsDesign = 'connected' | 'vscode' | 'vscode-v2';
508
+
509
+ /**
510
+ * Seedable store of {@link Comment}s for the comment-mode contribution. Owns the
511
+ * comment list and the shared hover state; it has no opinion on rendering or
512
+ * persistence — a host seeds it via {@link set}/{@link add} and observes
513
+ * {@link comments}.
514
+ */
515
+ export declare class CommentsModel {
516
+ private readonly _comments;
517
+ /** Monotonic counter for ids of comments created via {@link create}. */
518
+ private _sequence;
519
+ /** The current comments, in insertion order. */
520
+ get comments(): IObservable<readonly Comment_2[]>;
521
+ /**
522
+ * The comment currently hovered (by its card or its highlight), or
523
+ * `undefined`. Shared so the card and the highlight can react together.
524
+ */
525
+ readonly hoveredId: ISettableObservable<string | undefined>;
526
+ /** Replace the whole comment set. */
527
+ set(comments: readonly Comment_2[]): void;
528
+ /**
529
+ * Create a comment from a user submission and append it, generating its `id`
530
+ * and `createdAt` here so id/time allocation stays the store's concern (the
531
+ * UI only supplies the range and text). Returns the created comment.
532
+ */
533
+ create(input: {
534
+ range: OffsetRange;
535
+ body: string;
536
+ author?: string;
537
+ }): Comment_2;
538
+ /** Append a comment. */
539
+ add(comment: Comment_2): void;
540
+ /** Remove a comment by id. */
541
+ remove(id: string): void;
542
+ }
543
+
544
+ /** Optional, design-specific context a presenter may use (ignored by others). */
545
+ export declare interface CommentsPresenterContext {
546
+ /** Light/dark hint for the token-wrapped VS Code widget designs. */
547
+ readonly theme?: 'light' | 'dark';
548
+ /**
549
+ * Resolves a source offset to a 1-based line number, for designs that show
550
+ * line info (the VS Code V1 card). Optional because the model itself carries
551
+ * no text; the host (which owns the source) supplies it.
552
+ */
553
+ readonly resolveLine?: (offset: number) => number;
554
+ }
555
+
556
+ /** Builds a presenter for a given model + editor view. */
557
+ export declare type CommentsPresenterFactory = (model: CommentsModel, view: EditorView, context?: CommentsPresenterContext) => ICommentsPresenter;
558
+
559
+ /** A comment the user submitted, with the source range it was anchored to. */
560
+ export declare interface CommentSubmission {
561
+ readonly text: string;
562
+ readonly range: OffsetRange;
563
+ }
564
+
565
+ /**
566
+ * Renders persistent comments as a gdocs-style side rail: each comment's range
567
+ * is highlighted (reusing the editor's selection geometry via
568
+ * {@link EditorView.rangeRects}), a leader line curves from the bottom of that
569
+ * highlight to a card stacked in the right rail, and cards never overlap.
570
+ *
571
+ * Everything is mounted into {@link EditorView.overlayContainer} so it shares
572
+ * the selection/caret coordinate space and scrolls with the document. When the
573
+ * editor's natural right margin is too narrow for the rail, the view reserves
574
+ * proportional space by padding the editor on the right — but only while there
575
+ * are comments.
576
+ */
577
+ export declare class CommentsView extends Disposable {
578
+ private readonly _model;
579
+ private readonly _view;
580
+ private readonly _layer;
581
+ private readonly _entries;
582
+ constructor(_model: CommentsModel, _view: EditorView);
583
+ private _createLayer;
584
+ private _update;
585
+ /** Create/update/remove per-comment DOM to match `comments`. */
586
+ private _reconcile;
587
+ private _createEntry;
588
+ private _fillCard;
589
+ private _disposeEntry;
590
+ /** Position highlights, cards (stacked) and leader lines. */
591
+ private _layout;
592
+ private _applyHover;
593
+ }
594
+
595
+ /** The lossless source slices of a complete block HTML comment. */
596
+ declare interface CompleteHtmlCommentSource extends HtmlCommentSourceBase {
597
+ readonly kind: 'complete';
598
+ readonly closing: '-->';
599
+ readonly trailingWhitespace: string;
600
+ }
601
+
278
602
  /**
279
603
  * A {@link MonacoSyntaxHighlighter} preloaded with a handful of common Monarch
280
604
  * grammars (plus the usual short aliases). Unknown languages fall back to an
@@ -285,13 +609,16 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
285
609
  */
286
610
  export declare function createDefaultMonacoSyntaxHighlighter(monaco: IMonarchApi, grammars: IDefaultMonarchGrammars): MonacoSyntaxHighlighter;
287
611
 
288
- export declare type CursorCommand = (ctx: CursorCommandContext) => SourceOffset;
612
+ export declare type CursorCommand = (ctx: CursorCommandContext) => CursorPosition;
289
613
 
290
614
  export declare interface CursorCommandContext {
291
615
  readonly text: string;
292
616
  readonly selection: Selection_2;
293
617
  readonly document: DocumentAstNode;
294
618
  readonly activeBlock: BlockAstNode | undefined;
619
+ readonly markerVisibleBlocks: ReadonlySet<BlockAstNode>;
620
+ readonly wordNavigationConfig: WordNavigationConfig;
621
+ readonly cursorPosition: CursorPosition;
295
622
  }
296
623
 
297
624
  export declare const cursorDocumentEnd: CursorCommand;
@@ -300,6 +627,8 @@ export declare const cursorDocumentStart: CursorCommand;
300
627
 
301
628
  export declare const cursorDown: VisualCursorCommand;
302
629
 
630
+ export declare type CursorKeyboardAction = 'left' | 'right' | 'up' | 'down' | 'wordLeft' | 'wordRight' | 'visualLineStart' | 'visualLineEnd' | 'logicalLineStart' | 'logicalLineEnd' | 'documentStart' | 'documentEnd';
631
+
303
632
  export declare const cursorLeft: CursorCommand;
304
633
 
305
634
  export declare const cursorLineEnd: CursorCommand;
@@ -309,12 +638,26 @@ export declare const cursorLineStart: CursorCommand;
309
638
  export declare const cursorMoveLeft: CursorCommand;
310
639
 
311
640
  export declare interface CursorMoveResult {
312
- readonly offset: SourceOffset;
641
+ readonly position: CursorPosition;
313
642
  readonly desiredColumn: number | undefined;
314
643
  }
315
644
 
316
645
  export declare const cursorMoveRight: CursorCommand;
317
646
 
647
+ /** The cursor's position in either source text or a source-less visual line. */
648
+ export declare type CursorPosition = {
649
+ readonly kind: 'source';
650
+ readonly offset: SourceOffset;
651
+ } | {
652
+ readonly kind: 'virtual';
653
+ readonly line: VirtualCursorLine;
654
+ };
655
+
656
+ export declare namespace CursorPosition {
657
+ export function source(offset: SourceOffset): CursorPosition;
658
+ export function virtual(line: VirtualCursorLine): CursorPosition;
659
+ }
660
+
318
661
  export declare const cursorRight: CursorCommand;
319
662
 
320
663
  export declare const cursorUp: VisualCursorCommand;
@@ -323,49 +666,129 @@ export declare const cursorUp: VisualCursorCommand;
323
666
  * Owns the blinking cursor DOM element.
324
667
  *
325
668
  * The rendering pipeline is a single `derived` whose compute callback
326
- * asks the {@link VisualLineMap} for the caret rect at the current
327
- * offset, writes it to {@link element}, and returns a
669
+ * asks the {@link VisualLineMap} for the caret rect at the current source or
670
+ * virtual position, writes it to {@link element}, and returns a
328
671
  * {@link CursorViewRendering} value as proof. An autorun keeps the
329
672
  * derived subscribed.
330
673
  */
331
674
  export declare class CursorView extends Disposable {
332
- private readonly _parent;
333
675
  readonly element: HTMLElement;
334
676
  readonly rendering: IObservable<CursorViewRendering>;
335
- constructor(_parent: HTMLElement, options: CursorViewOptions);
677
+ constructor(options: CursorViewOptions);
336
678
  }
337
679
 
338
680
  export declare interface CursorViewOptions {
339
- readonly offset: IObservable<SourceOffset | undefined>;
681
+ readonly position: IObservable<CursorPosition | undefined>;
340
682
  readonly visualLineMap: IObservable<VisualLineMap>;
341
683
  /**
342
- * When set, the caret is drawn over the transient empty paragraph instead
343
- * of at {@link offset} its rect (in client coordinates) comes straight
344
- * from that synthetic element's geometry, since it has no visual-line-map
345
- * entry. Takes priority over the normal offset-based placement.
684
+ * The mounted blocks, used to hide the caret when it sits at an offset that
685
+ * has been scrolled out of its (horizontally scrolling) block's viewport —
686
+ * matching how the selection is clipped there.
346
687
  */
347
- readonly pendingCaretRect?: IObservable<Rect2D | undefined>;
688
+ readonly blocks?: IObservable<readonly SelectionBlock[]>;
348
689
  }
349
690
 
350
691
  export declare class CursorViewRendering {
351
- readonly offset: SourceOffset;
692
+ readonly position: CursorPosition;
352
693
  readonly visible: boolean;
353
694
  readonly rect: Rect2D;
354
- constructor(offset: SourceOffset, visible: boolean, rect: Rect2D);
695
+ constructor(position: CursorPosition, visible: boolean, rect: Rect2D);
355
696
  }
356
697
 
698
+ export declare const cursorVisualLineEnd: VisualCursorCommand;
699
+
700
+ export declare const cursorVisualLineStart: VisualCursorCommand;
701
+
357
702
  export declare const cursorWordLeft: CursorCommand;
358
703
 
359
704
  export declare const cursorWordRight: CursorCommand;
360
705
 
706
+ export declare const DEFAULT_INDENTATION_CONFIG: IndentationConfig;
707
+
708
+ export declare const DEFAULT_WORD_NAVIGATION_CONFIG: WordNavigationConfig;
709
+
710
+ export declare const DEFAULT_WORD_SEPARATORS = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";
711
+
361
712
  export declare const deleteLeft: EditCommand;
362
713
 
714
+ export declare const deleteLineLeft: EditCommand;
715
+
716
+ export declare const deleteLineRight: EditCommand;
717
+
363
718
  export declare const deleteRight: EditCommand;
364
719
 
365
720
  export declare const deleteWordLeft: EditCommand;
366
721
 
367
722
  export declare const deleteWordRight: EditCommand;
368
723
 
724
+ /**
725
+ * A read-only "removed" decoration: an original block rendered (red) above its
726
+ * place in the modified document, occupying vertical space like a view-zone but
727
+ * contributing **zero** source length, so the editor's source mapping stays the
728
+ * modified document and editing is unaffected. Used for `removed` and the
729
+ * original side of a `replaced` block in editor diff mode.
730
+ */
731
+ declare class DiffDecorationViewData {
732
+ readonly ast: AstNode;
733
+ readonly side: BlockViewData;
734
+ readonly deletedRanges: readonly DiffHighlightRange[];
735
+ /** True when the whole block was removed: solid red band, no word rects. */
736
+ readonly whole: boolean;
737
+ /** Absolute offset of this block in the *original* document. */
738
+ readonly originalStart: number;
739
+ readonly kind = "diffDecoration";
740
+ constructor(ast: AstNode, side: BlockViewData, deletedRanges: readonly DiffHighlightRange[],
741
+ /** True when the whole block was removed: solid red band, no word rects. */
742
+ whole: boolean,
743
+ /** Absolute offset of this block in the *original* document. */
744
+ originalStart: number);
745
+ }
746
+
747
+ /** A word/character highlight inside one diff side, in block-local coords. */
748
+ declare interface DiffHighlightRange {
749
+ readonly range: OffsetRange;
750
+ readonly kind: 'inserted' | 'deleted';
751
+ }
752
+
753
+ /**
754
+ * A changed block rendered as its original form stacked over its modified form
755
+ * (either side may be absent for a pure deletion/insertion). It is itself a
756
+ * document child the renderer mounts like a block; its {@link ast} is the
757
+ * surviving side's ast, used only for view-node identity/reuse.
758
+ */
759
+ declare class DiffHunkViewData {
760
+ readonly ast: AstNode;
761
+ readonly original: DiffSideViewData | undefined;
762
+ readonly modified: DiffSideViewData | undefined;
763
+ readonly kind = "diffHunk";
764
+ constructor(ast: AstNode, original: DiffSideViewData | undefined, modified: DiffSideViewData | undefined);
765
+ }
766
+
767
+ /**
768
+ * The recursive classification of a diff. Each item describes one aligned
769
+ * position in the merged document:
770
+ *
771
+ * - `unchanged` — render the (modified) node once, neutral.
772
+ * - `added` — exists only in the modified document (green).
773
+ * - `removed` — exists only in the original document (red).
774
+ * - `replaced` — a *leaf* block changed in place → render original over
775
+ * modified, with word-level {@link AnnotatedRange}s on each.
776
+ * - `nested` — a *container* changed → render it once and diff its
777
+ * {@link NestedItem.children} recursively.
778
+ *
779
+ * Offsets ({@link UnchangedItem.modifiedStart} etc.) are absolute in their
780
+ * respective documents, so a renderer/visualizer can slice the source text.
781
+ */
782
+ declare type DiffItem = UnchangedItem | AddedItem | RemovedItem | ReplacedItem | NestedItem;
783
+
784
+ /** One side (original or modified) of a {@link DiffHunkViewData}. */
785
+ declare interface DiffSideViewData {
786
+ readonly view: BlockViewData;
787
+ /** Render in active form (markers/whitespace visible). */
788
+ readonly active: boolean;
789
+ readonly ranges: readonly DiffHighlightRange[];
790
+ }
791
+
369
792
  export declare class DocumentAstNode extends AstNode {
370
793
  readonly content: readonly (BlockAstNode | GlueAstNode)[];
371
794
  readonly kind = "document";
@@ -390,14 +813,21 @@ declare interface DocumentBlockViewData {
390
813
  readonly view: BlockViewData;
391
814
  }
392
815
 
393
- /** A mounted document child: a block, a run of inter-block glue, or the
394
- * transient empty paragraph (see {@link PendingParagraphViewData}). */
816
+ /** A mounted document child: a block, a run of inter-block glue, the
817
+ * transient empty paragraph (see {@link PendingParagraphViewData}), or a
818
+ * {@link DiffHunkViewData diff hunk} (stacked original/modified blocks). */
395
819
  declare interface DocumentChildViewData {
396
820
  readonly absoluteStart: number;
397
821
  /** For a block: selection reaches it. For glue: always false (unowned, hidden). */
398
822
  readonly isActive: boolean;
399
- readonly view: BlockViewData | GlueViewData | PendingParagraphViewData;
400
- readonly kind: 'block' | 'glue' | 'pendingParagraph';
823
+ readonly view: BlockViewData | GlueViewData | PendingParagraphViewData | DiffHunkViewData | DiffDecorationViewData;
824
+ readonly kind: 'block' | 'glue' | 'pendingParagraph' | 'diffHunk' | 'diffDecoration';
825
+ /**
826
+ * Diff mode: how this (modified) block changed. `added` = a whole new block
827
+ * (strong green band, no inline rects); `modified` = a partial change (light
828
+ * band + inline rects on the changed words).
829
+ */
830
+ readonly diffKind?: 'added' | 'modified';
401
831
  }
402
832
 
403
833
  /**
@@ -454,7 +884,7 @@ declare class DocumentViewData {
454
884
  export declare class DocumentViewNode extends ViewNode {
455
885
  readonly blocks: readonly DocumentBlock[];
456
886
  /** The transient empty-paragraph element, when one is armed. */
457
- readonly pendingElement?: HTMLElement | undefined;
887
+ readonly pendingParagraph?: PendingParagraphViewNode | undefined;
458
888
  static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
459
889
  private constructor();
460
890
  /** The stable content element this document mounts its children into. */
@@ -476,6 +906,26 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
476
906
  readonly selection: Selection_2;
477
907
  } | undefined;
478
908
 
909
+ export declare type EditKeyboardAction = 'deleteLeft' | 'deleteRight' | 'deleteWordLeft' | 'deleteWordRight' | 'deleteLineLeft' | 'deleteLineRight';
910
+
911
+ export declare interface EditorCommandDefinition {
912
+ readonly id: `markdown.editor.${string}`;
913
+ readonly title: string;
914
+ readonly action: EditorKeyboardAction;
915
+ readonly keybindings: readonly EditorCommandKeybinding[];
916
+ /**
917
+ * Local commands must execute synchronously in the webview instead of being
918
+ * forwarded through the VS Code keybinding service.
919
+ */
920
+ readonly routing?: 'host' | 'local';
921
+ }
922
+
923
+ export declare interface EditorCommandKeybinding {
924
+ readonly key: string;
925
+ readonly modifiers?: KeyboardModifiers;
926
+ readonly platforms?: readonly KeyboardPlatform[];
927
+ }
928
+
479
929
  /**
480
930
  * Translates raw browser input (mouse, keyboard, EditContext) into model
481
931
  * mutations. Knows about DOM event types but never reads/writes the DOM
@@ -484,19 +934,38 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
484
934
  *
485
935
  * Owns the only non-derivable controller state:
486
936
  * - `_desiredColumn` — sticky column for up/down navigation
937
+ * - `_clickCount` / `_lastPointerDown` — multi-click detection for pointer
938
+ * input, since `pointerdown` events (unlike `mousedown`) don't populate
939
+ * `detail` with a click count.
487
940
  */
488
941
  export declare class EditorController extends Disposable {
489
942
  private readonly _model;
490
943
  private readonly _view;
944
+ readonly findController: FindController | undefined;
491
945
  private _desiredColumn;
946
+ private readonly _keyboardPlatform;
947
+ private readonly _keyboardProfile;
948
+ private readonly _forwardedKeyboardProfile;
949
+ private readonly _historyStrategy;
950
+ private readonly _indentation;
951
+ private readonly _tabFocusStatus;
952
+ private _tabMovesFocus;
953
+ /** Running click count for the current multi-click sequence (1, 2, 3, …). */
954
+ private _clickCount;
955
+ /** Timestamp and position of the previous pointer-down, for multi-click detection. */
956
+ private _lastPointerDown;
492
957
  constructor(_model: EditorModel, _view: EditorView, options?: EditorControllerOptions);
493
958
  private readonly _handleTextUpdate;
494
- private readonly _handleMouseDown;
959
+ private readonly _handlePointerDown;
495
960
  private _makeCursorContext;
496
961
  private _makeVisualCursorContext;
497
962
  private _executeCursorCommand;
498
963
  private _executeEditCommand;
964
+ private _runUndoableEdit;
499
965
  private _executeVisualCursorCommand;
966
+ private _cursorDown;
967
+ private _setUserSelection;
968
+ private _applyCursorPosition;
500
969
  /** Move the cursor down one visual line (Arrow Down). */
501
970
  cursorDown(extend?: boolean): void;
502
971
  /** Move the cursor up one visual line (Arrow Up). */
@@ -504,12 +973,34 @@ export declare class EditorController extends Disposable {
504
973
  private _selectedText;
505
974
  private readonly _updateModifierState;
506
975
  private readonly _clearModifierState;
976
+ /**
977
+ * Drop any native DOM selection over the rendered text.
978
+ *
979
+ * The editor paints selection from `model.selection`, so a browser
980
+ * selection there is always spurious: nothing reads it (copy/cut read the
981
+ * model, hit-testing uses the measured layout) and nothing clears it, so it
982
+ * lingers as a second highlight even after the caret moves away.
983
+ * {@link isCaretMotionKey} stops the common source synchronously; this is
984
+ * the backstop for the rest of the browser's editing commands, which are
985
+ * platform- and version-specific and cannot be enumerated (Shift+PageDown
986
+ * and macOS Shift+Ctrl+B both reach one today).
987
+ *
988
+ * Scoped twice so it only ever discards selections the editor owns: the
989
+ * range must touch the rendered text (overlays such as comment widgets sit
990
+ * beside it and stay selectable), and input focus must still be inside this
991
+ * editor (so a host find-in-page, which selects while its own input is
992
+ * focused, is left alone).
993
+ */
994
+ private readonly _discardNativeSelection;
507
995
  private readonly _handleKeyDown;
996
+ executeCommand(command: EditorCommandDefinition): void;
997
+ private _executeKeyboardAction;
508
998
  /**
509
999
  * Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
510
1000
  * arms a transient empty paragraph when at the end of a paragraph.
511
1001
  */
512
1002
  private _smartEnter;
1003
+ private _registerTabFocusAccessibility;
513
1004
  }
514
1005
 
515
1006
  /** Options for an {@link EditorController}. */
@@ -520,10 +1011,79 @@ export declare interface EditorControllerOptions {
520
1011
  * strategy (e.g. `AsyncClipboardStrategy`) in hosts that swallow them.
521
1012
  */
522
1013
  readonly clipboardStrategy?: IClipboardStrategy;
1014
+ /**
1015
+ * Where undo and redo are executed: `LocalHistoryStrategy` for a
1016
+ * self-contained editor, or a strategy that forwards to the host's own
1017
+ * document history. Left unset, the chords are passed on to the host.
1018
+ */
1019
+ readonly historyStrategy?: IHistoryStrategy;
1020
+ readonly keyboardPlatform?: KeyboardPlatform;
1021
+ readonly keyboardProfile?: KeyboardProfile;
1022
+ /**
1023
+ * Bindings owned by the host. Matching events have their browser default
1024
+ * suppressed but continue propagating so the host keybinding service sees them.
1025
+ */
1026
+ readonly forwardedKeyboardProfile?: KeyboardProfile;
1027
+ /** Tab-stop settings used outside semantic list indentation. */
1028
+ readonly indentation?: IndentationConfig;
1029
+ readonly find?: false;
523
1030
  }
524
1031
 
1032
+ /**
1033
+ * The editor overlay's local CSS-pixel coordinate space.
1034
+ *
1035
+ * Browser geometry and pointer APIs expose viewport client coordinates. This
1036
+ * boundary converts them immediately into the coordinate system shared by the
1037
+ * editor content and its overlays. Range rectangles are axis-aligned, so the
1038
+ * current implementation deliberately supports positive axis-aligned scale and
1039
+ * translation only.
1040
+ */
1041
+ export declare class EditorCoordinateSpace {
1042
+ private readonly _getLocalToClientMatrix;
1043
+ static forSvgOverlay(overlay: SVGSVGElement): EditorCoordinateSpace;
1044
+ private constructor();
1045
+ capture(): EditorCoordinateTransform;
1046
+ }
1047
+
1048
+ /** A stable coordinate conversion captured for one measurement operation. */
1049
+ export declare class EditorCoordinateTransform {
1050
+ private readonly _localToClient;
1051
+ private readonly _clientToLocal;
1052
+ constructor(_localToClient: DOMMatrix);
1053
+ toLocalPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
1054
+ toClientPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
1055
+ toLocalRect(rect: Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>): Rect2D;
1056
+ toClientRect(rect: Pick<Rect2D, 'left' | 'top' | 'width' | 'height'>): Rect2D;
1057
+ private _convertRect;
1058
+ }
1059
+
1060
+ export declare type EditorKeyboardAction = {
1061
+ readonly kind: 'cursor';
1062
+ readonly command: CursorKeyboardAction;
1063
+ readonly extend: boolean;
1064
+ } | {
1065
+ readonly kind: 'edit';
1066
+ readonly command: EditKeyboardAction;
1067
+ } | {
1068
+ readonly kind: 'history';
1069
+ readonly command: HistoryKeyboardAction;
1070
+ } | {
1071
+ readonly kind: 'tab';
1072
+ readonly command: TabKeyboardAction;
1073
+ } | {
1074
+ readonly kind: 'toggleTabFocus';
1075
+ } | {
1076
+ readonly kind: 'selectAll';
1077
+ } | {
1078
+ readonly kind: 'enter';
1079
+ readonly command: 'smartEnter' | 'insertParagraph' | 'insertHardLineBreak';
1080
+ };
1081
+
525
1082
  export declare class EditorModel {
526
1083
  private readonly _parser;
1084
+ private readonly _sourceEditListeners;
1085
+ private readonly _sourceTextIds;
1086
+ private _lastSourceTextId;
527
1087
  /**
528
1088
  * The most recent edit applied to {@link sourceText}, used by
529
1089
  * {@link document} to let the parser link incrementally edited code
@@ -532,11 +1092,23 @@ export declare class EditorModel {
532
1092
  */
533
1093
  private _pendingEdit;
534
1094
  readonly sourceText: ISettableObservable<StringValue, void>;
1095
+ readonly wordNavigationConfig: ISettableObservable<WordNavigationConfig, void>;
1096
+ /**
1097
+ * Read-only mode. When `true`, the editor never reveals a block's source
1098
+ * markers (markdown special characters like `**`, `#`, list bullets, code
1099
+ * fences, `$…$`) — every block stays in its clean rendered form regardless
1100
+ * of where the caret/selection is — and source-mutating edits are ignored.
1101
+ * Plain text selection still works everywhere (so the user can copy). The
1102
+ * default (`false`) is the normal editing mode where the active block
1103
+ * reveals its markers.
1104
+ */
1105
+ readonly readonlyMode: ISettableObservable<boolean, void>;
535
1106
  /**
536
1107
  * The current selection, or `undefined` when the editor has no caret
537
1108
  * (e.g. an inactive/unfocused rendering).
538
1109
  */
539
1110
  readonly selection: ISettableObservable<Selection_2 | undefined, void>;
1111
+ readonly selectionSource: ISettableObservable<SelectionSource, void>;
540
1112
  /**
541
1113
  * Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
542
1114
  * live keyboard state; the view reads it to show the link-open affordance
@@ -544,6 +1116,14 @@ export declare class EditorModel {
544
1116
  * whose block is active.
545
1117
  */
546
1118
  readonly ctrlOrMetaDown: ISettableObservable<boolean, void>;
1119
+ /**
1120
+ * Whether a pointer-driven selection drag is currently in progress. Set by
1121
+ * the controller between the pointer-down that starts the drag and the
1122
+ * pointer-up/cancel that ends it. Contributions read it to defer UI that
1123
+ * would otherwise flicker mid-drag (e.g. the comment input box appears only
1124
+ * once the drag ends).
1125
+ */
1126
+ readonly isSelecting: ISettableObservable<boolean, void>;
547
1127
  /**
548
1128
  * Gutter markers (source-control style change indicators) painted in the
549
1129
  * left gutter. Each entry maps a source {@link OffsetRange} to a change kind
@@ -567,6 +1147,7 @@ export declare class EditorModel {
567
1147
  */
568
1148
  readonly pendingParagraph: ISettableObservable<PendingParagraph | undefined, void>;
569
1149
  readonly cursorOffset: IObservableWithChange<number | undefined, void>;
1150
+ readonly cursorPosition: IObservableWithChange<CursorPosition | undefined, void>;
570
1151
  /**
571
1152
  * The parsed document. Threads the previous document into the parser so
572
1153
  * unchanged blocks keep their object identity across reparses (see
@@ -589,28 +1170,58 @@ export declare class EditorModel {
589
1170
  * collapsed this is a one-element set holding {@link activeBlock}.
590
1171
  */
591
1172
  readonly activeBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1173
+ /**
1174
+ * The baseline document to diff against. When set, the editor renders in
1175
+ * diff mode: the modified document ({@link document}) stays editable, while
1176
+ * the baseline's removed/changed blocks are shown as read-only decorations.
1177
+ * `undefined` (the default) renders normally.
1178
+ */
1179
+ readonly baseline: ISettableObservable<StringValue | undefined, void>;
1180
+ private readonly _baselineDocument;
1181
+ /**
1182
+ * The diff of {@link baseline} → {@link document}, or `undefined` when no
1183
+ * baseline is set. The view renders the {@link DiffItem}s as stacked
1184
+ * decorations; `insertedRanges` (modified-side change spans) drive the green
1185
+ * word-level highlight.
1186
+ */
1187
+ readonly diff: IObservableWithChange< {
1188
+ items: DiffItem[];
1189
+ insertedRanges: OffsetRange[];
1190
+ changedBlocks: Set<BlockAstNode>;
1191
+ } | undefined, void>;
1192
+ readonly markerVisibleBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1193
+ onWillApplySourceEdit(listener: (event: SourceEditEvent) => void): IDisposable;
1194
+ /** Returns a stable per-object identity without retaining the source text. */
1195
+ getSourceTextId(sourceText: StringValue): number;
592
1196
  /**
593
1197
  * Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
594
1198
  * AST node for it, and park the caret at the gap start. No source edit is
595
1199
  * applied — the blank line exists only in the view until it is materialized.
596
1200
  */
597
- armPendingParagraph(req: {
598
- anchorBlock: BlockAstNode;
599
- replaceRange: OffsetRange;
600
- atEof: boolean;
601
- }): void;
1201
+ armPendingParagraph(req: Omit<PendingParagraph, 'syntheticAst' | 'cursorLine'>): void;
602
1202
  /** Discard the pending paragraph (if any) without touching the source. */
603
1203
  cancelPendingParagraph(): void;
1204
+ /**
1205
+ * Replace the source with an authoritative value from the host, mapping the
1206
+ * selection through the changed span and atomically discarding transient
1207
+ * state anchored to the previous parse.
1208
+ */
1209
+ replaceSourceText(text: StringValue): void;
604
1210
  /**
605
1211
  * Turn the pending paragraph into real source: rewrite its gap so the typed
606
1212
  * `text` becomes its own paragraph, separated from its neighbours by blank
607
1213
  * lines, and place the caret after the inserted text.
608
1214
  */
609
1215
  materializePendingParagraph(text: string): void;
610
- applyEdit(edit: StringEdit): void;
1216
+ applyEdit(edit: StringEdit, selection?: Selection_2): void;
611
1217
  applyEditForSelection(edit: StringEdit): void;
1218
+ private _applySourceEdit;
1219
+ private _identifySourceEdit;
1220
+ private _emitWillApplySourceEdit;
612
1221
  }
613
1222
 
1223
+ export declare type EditorOverlayPosition = 'top-chrome' | 'below-selection' | 'above-decorations';
1224
+
614
1225
  /**
615
1226
  * Pure-render view of an {@link EditorModel}.
616
1227
  *
@@ -640,6 +1251,8 @@ export declare class EditorView extends Disposable {
640
1251
  readonly element: HTMLElement;
641
1252
  readonly editContext: EditContext;
642
1253
  readonly measuredLayout: MeasuredLayoutModel;
1254
+ readonly coordinateSpace: EditorCoordinateSpace;
1255
+ readonly forcedMarkerVisibleBlocks: ISettableObservable<ReadonlySet<BlockAstNode>, void>;
643
1256
  /**
644
1257
  * Inner container that holds the rendered document and the cursor/selection
645
1258
  * overlays. The outer {@link element} spans the full width; this container
@@ -647,9 +1260,14 @@ export declare class EditorView extends Disposable {
647
1260
  * to their parent's box) stay aligned with the content.
648
1261
  */
649
1262
  private readonly _contentContainer;
1263
+ private readonly _resizeObserver;
650
1264
  private readonly _cursorView;
651
1265
  private readonly _selectionView;
652
1266
  private readonly _gutterMarkersView;
1267
+ private readonly _diffHighlightsView;
1268
+ private _readonlyToggleButton;
1269
+ private readonly _editContextSuspensions;
1270
+ private readonly _revealOcclusions;
653
1271
  /**
654
1272
  * The mounted block sequence, in source order. Rebuilt (not mutated) each
655
1273
  * frame by {@link DocumentViewNode.create}; the view just swaps one
@@ -657,8 +1275,11 @@ export declare class EditorView extends Disposable {
657
1275
  * (those go through the measured-layout model).
658
1276
  */
659
1277
  private readonly _document;
1278
+ private readonly _embeddedCodeEditorFactoryVersion;
660
1279
  /** The current view-node tree (AST overlaid with rendered DOM), for debugging. */
661
1280
  get documentViewNode(): IObservable<DocumentViewNode | undefined>;
1281
+ /** Re-resolves embedded code editors while preserving the surrounding editor view. */
1282
+ refreshEmbeddedCodeEditors(): void;
662
1283
  /**
663
1284
  * Last frame's view-data overlay, threaded back into
664
1285
  * {@link buildDocumentViewData} so any subtree whose ast and selection flags
@@ -670,18 +1291,44 @@ export declare class EditorView extends Disposable {
670
1291
  private readonly _viewData;
671
1292
  get viewData(): IObservable<DocumentViewData | undefined>;
672
1293
  /**
673
- * Caret rect (client coords) for the transient empty paragraph, or
674
- * `undefined` when none is armed. Set each frame from the synthetic
675
- * paragraph element's geometry and fed to the {@link CursorView}, which has
676
- * no visual-line-map entry to place the caret from otherwise.
1294
+ * Whether the editor is genuinely focused: focus rests somewhere inside the
1295
+ * editor subtree *and* its window is focused. Mirrored onto the root as
1296
+ * `.md-focused`, which gates the painted caret the blinking cursor is only
1297
+ * shown while this is `true`, so it never blinks in an unfocused editor or
1298
+ * after the window loses focus. Only the caret's visibility is affected; the
1299
+ * logical selection and caret geometry ({@link caretRect}) are unchanged.
677
1300
  */
678
- private readonly _pendingCaretRect;
1301
+ private readonly _focused;
1302
+ get focused(): IObservable<boolean>;
679
1303
  /**
680
1304
  * The block cache projected for views (selection painting) that need to
681
1305
  * react to mount/unmount. Derived from {@link _document}, so it stays in
682
1306
  * lock-step without any manual bookkeeping.
683
1307
  */
684
1308
  private readonly _selectionBlocksObs;
1309
+ /**
1310
+ * The caret rect (zero width) at the selection's active end, in
1311
+ * {@link overlayContainer}-local coordinates, or `undefined` when there is no
1312
+ * caret. This is the same geometry the editor paints its cursor from, so
1313
+ * contributions (e.g. comment mode) can anchor an overlay to the active end of
1314
+ * the selection — where the user's cursor is — without re-deriving geometry.
1315
+ */
1316
+ private readonly _caretRect;
1317
+ get caretRect(): IObservable<Rect2D | undefined>;
1318
+ /**
1319
+ * The container that establishes the positioning context for the editor's
1320
+ * overlays (cursor, selection, gutter). Contributions mount their own
1321
+ * absolutely-positioned overlays here so they share the coordinate space of
1322
+ * {@link caretRect}.
1323
+ */
1324
+ get overlayContainer(): HTMLElement;
1325
+ /**
1326
+ * Selection-style rectangles covering `range`, in {@link overlayContainer}-
1327
+ * local coordinates — the same geometry the live selection paints. Exposed so
1328
+ * contributions (e.g. persistent comments) can highlight arbitrary ranges and
1329
+ * anchor overlays to them. Recomputes when the measured layout changes.
1330
+ */
1331
+ rangeRects(range: OffsetRange): IObservable<readonly SelectionRect[]>;
685
1332
  constructor(_model: EditorModel, _options?: EditorViewOptions | undefined);
686
1333
  /**
687
1334
  * Mirrors the model's live Ctrl/Cmd state onto the editor root as
@@ -690,13 +1337,92 @@ export declare class EditorView extends Disposable {
690
1337
  * a plain click, but an active link only opens with the modifier held.
691
1338
  */
692
1339
  private _setupModifierTracking;
1340
+ /**
1341
+ * Tracks whether the editor is genuinely focused and mirrors it onto the
1342
+ * root as `.md-focused` so CSS can gate the painted caret. "Focused" means
1343
+ * focus rests somewhere inside the editor subtree *and* the window itself is
1344
+ * focused; either condition failing (focus moving elsewhere, or the window
1345
+ * losing focus) hides the blinking caret while leaving the logical selection
1346
+ * and caret geometry intact.
1347
+ */
1348
+ private _setupFocusTracking;
1349
+ /**
1350
+ * Renders the edit/read-only mode toggle. It flips the model's
1351
+ * {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
1352
+ * in its clean rendered form (no markdown markers revealed) and edits are
1353
+ * ignored, while text selection still works. The control lives in a
1354
+ * zero-height *sticky* host inside the centered content container, so the
1355
+ * lock follows the content's right edge and remains pinned as the document
1356
+ * scrolls. The current mode is also mirrored onto the root as `.md-readonly`
1357
+ * for any CSS hooks.
1358
+ */
1359
+ private _setupReadonlyToggle;
1360
+ /** Draws attention to the mode toggle after text input is attempted while locked. */
1361
+ showReadonlyEditingAttempt(): void;
693
1362
  focus(): void;
1363
+ mountOverlay(element: HTMLElement | SVGSVGElement, position: EditorOverlayPosition): IDisposable;
1364
+ /** Registers floating editor chrome that should count as covering a range during reveal. */
1365
+ registerRevealOcclusion(element: Element): IDisposable;
1366
+ /**
1367
+ * Temporarily detaches the root {@link EditContext} while focus is inside
1368
+ * nested editor chrome. Chromium otherwise reclaims focus from non-text
1369
+ * controls inside the EditContext host, breaking keyboard access to controls
1370
+ * such as the find actions and read-only toggle.
1371
+ */
1372
+ suspendEditContextWhileFocused(element: HTMLElement): IDisposable;
1373
+ revealRangeInCenterIfOutsideViewport(range: OffsetRange, behavior?: ScrollBehavior): IDisposable;
1374
+ /**
1375
+ * Samples the ambient focus state that decides whether taking focus on open
1376
+ * would steal it from an explicit user target: whether the window is focused
1377
+ * and whether focus is still unclaimed (no active element, or the `<body>`
1378
+ * fallback).
1379
+ */
1380
+ private _sampleAutoFocusEnvironment;
1381
+ /**
1382
+ * One-shot guarded focus attempt: focuses the editor only if doing so will
1383
+ * not steal focus from an explicit user target — the window must already be
1384
+ * focused and no other element may have claimed focus yet. Returns whether
1385
+ * focus was taken. A no-op for a background window or when the user has
1386
+ * already focused something else. {@link autoFocusOnOpen} builds the
1387
+ * open-time behavior on top of this primitive.
1388
+ */
1389
+ tryAutoFocus(): boolean;
1390
+ /**
1391
+ * Focuses the editor when it opens without ever stealing focus from an
1392
+ * explicit user target. Tries once immediately; if the window is not focused
1393
+ * yet — a common open-time race where the editor is mounted before the host
1394
+ * routes focus to its window — the guarded attempt is deferred to the next
1395
+ * time the window gains focus and re-evaluated then. The deferral is
1396
+ * one-shot, so a later, unrelated window refocus never grabs focus, and the
1397
+ * re-check still respects any target the user has claimed in the meantime.
1398
+ */
1399
+ autoFocusOnOpen(): void;
1400
+ /**
1401
+ * Own point→offset resolution. When `true` (the default),
1402
+ * {@link resolveOffsetFromPoint} ignores the platform DOM hit-test
1403
+ * (`caretPositionFromPoint`) and snaps the point to the nearest offset purely
1404
+ * from the rendered {@link VisualLineMap} geometry — picking the nearest
1405
+ * visual line by `y`, then the nearest offset on it by `x`. Because a table
1406
+ * row's cells share one horizontal line band, this makes the whole width of a
1407
+ * row resolve into that row (rather than only the cell boxes), with no visible
1408
+ * layout change. It also lets a drag keep extending toward off-viewport points
1409
+ * (e.g. the pointer leaving the window), which the platform hit-test cannot
1410
+ * resolve. Set to `false` to fall back to the platform DOM hit-test.
1411
+ */
1412
+ readonly geometricHitTest: ISettableObservable<boolean, void>;
694
1413
  /**
695
1414
  * Client coordinates → absolute source offset (any block). Used during
696
1415
  * drag to keep extending the selection even when the pointer leaves the
697
- * original block.
1416
+ * original block. Honours {@link geometricHitTest}.
698
1417
  */
699
1418
  resolveOffsetFromPoint(point: Point2D): SourceOffset | undefined;
1419
+ /**
1420
+ * Resolve table-cell hits that have no measurable text run. Empty cells map
1421
+ * from their own box instead of snapping to a neighboring cell; element-only
1422
+ * content (for example an inactive image) maps through the hit element's view
1423
+ * node. Text-bearing cells keep the normal pixel-precise line-map/DOM path.
1424
+ */
1425
+ private _resolveTableCellOffset;
700
1426
  /**
701
1427
  * Whether a client point falls on the rendered document content, as
702
1428
  * opposed to the surrounding editor padding (the green area). Uses DOM
@@ -706,6 +1432,13 @@ export declare class EditorView extends Disposable {
706
1432
  * have `pointer-events: none`, so the hit-test sees through them.
707
1433
  */
708
1434
  isPointInContent(point: Point2D): boolean;
1435
+ /**
1436
+ * Whether `node` sits inside the rendered source text — the region whose
1437
+ * selection this editor paints itself from `model.selection`. Overlays
1438
+ * anchored beside the text (comment widgets and the like) are *not* part of
1439
+ * it and keep their own native selection behaviour.
1440
+ */
1441
+ containsRenderedContent(node: Node | null | undefined): boolean;
709
1442
  private readonly _renderAutorun;
710
1443
  /** Current mounted blocks, or empty before the first render. */
711
1444
  private get _blocks();
@@ -715,6 +1448,18 @@ export declare class EditorView extends Disposable {
715
1448
  * is not read here, so there is no feedback loop into the render autorun.
716
1449
  */
717
1450
  private _publishMeasurements;
1451
+ /**
1452
+ * Paint the diff highlights via the CSS Custom Highlight API: green over the
1453
+ * inserted/changed modified ranges (mapped on the document's own DOM), and
1454
+ * red over each {@link DiffDecorationViewNode}'s deleted ranges (mapped on
1455
+ * the decoration's own subtree). No DOM is mutated, so reconciliation and
1456
+ * editing are unaffected.
1457
+ */
1458
+ private _paintDiff;
1459
+ private _clearDiff;
1460
+ private _syncEditContextAttachment;
1461
+ private _revealRange;
1462
+ private _isRevealOccluded;
718
1463
  }
719
1464
 
720
1465
  export declare interface EditorViewOptions extends BlockViewOptions {
@@ -725,6 +1470,12 @@ export declare interface EditorViewOptions extends BlockViewOptions {
725
1470
  * only) unless a theme class is supplied.
726
1471
  */
727
1472
  readonly classNames?: readonly string[];
1473
+ /**
1474
+ * Whether to render the sticky edit/read-only toggle at the top-right edge
1475
+ * of the content. Defaults to `true`; set to `false` to omit it (e.g. in
1476
+ * fixtures that focus on selection rendering).
1477
+ */
1478
+ readonly showReadonlyToggle?: boolean;
728
1479
  /**
729
1480
  * Controls "limited width mode". The observable yields the maximum content
730
1481
  * width in pixels, or `undefined` to let the content fill the available
@@ -735,6 +1486,14 @@ export declare interface EditorViewOptions extends BlockViewOptions {
735
1486
  * root ({@link element}) always spans the full available width.
736
1487
  */
737
1488
  readonly limitedWidth?: IObservable<number | undefined>;
1489
+ /**
1490
+ * Diff mode only: render every read-only original decoration in active
1491
+ * (source) form, so even whole-block removals expose their markdown markers
1492
+ * as real text. Used by the diff-coverage fixture to verify that every
1493
+ * changed original character is rendered somewhere; off in normal use, where
1494
+ * whole removals show a clean solid band.
1495
+ */
1496
+ readonly diffDecorationsActive?: boolean;
738
1497
  }
739
1498
 
740
1499
  export declare class EmphasisAstNode extends AstNode {
@@ -754,6 +1513,111 @@ declare class EmphasisViewData {
754
1513
  constructor(ast: EmphasisAstNode, content: readonly AnyViewData[]);
755
1514
  }
756
1515
 
1516
+ export declare function escapeFindRegex(value: string): string;
1517
+
1518
+ export declare const FIND_MATCH_LIMIT = 19999;
1519
+
1520
+ export declare function findBlockAtOffset(doc: DocumentAstNode, offset: SourceOffset): BlockAstNode | undefined;
1521
+
1522
+ export declare class FindController extends Disposable {
1523
+ private readonly _editorModel;
1524
+ private readonly _view;
1525
+ private readonly _options;
1526
+ readonly model: FindModel;
1527
+ readonly widget: FindWidget;
1528
+ private readonly _selectionForScope;
1529
+ private _forcedMatch;
1530
+ private _selectedMatch;
1531
+ private _observedSourceTextId;
1532
+ private readonly _sourceEditTracker;
1533
+ private _revealRequest;
1534
+ constructor(_editorModel: EditorModel, _view: EditorView, _options: FindControllerOptions);
1535
+ private _setForcedMarkerVisibleBlocks;
1536
+ openAndFocus(): void;
1537
+ close(): void;
1538
+ private _handleKeyDown;
1539
+ private _cancelRevealRequest;
1540
+ private _findByKeyboard;
1541
+ private _querySeed;
1542
+ private _prepareSeed;
1543
+ private _selectedSingleLineText;
1544
+ private _toggleFindInSelection;
1545
+ }
1546
+
1547
+ export declare interface FindControllerOptions {
1548
+ readonly keyboardPlatform: KeyboardPlatform;
1549
+ }
1550
+
1551
+ export declare type FindDirection = 'next' | 'previous';
1552
+
1553
+ export declare class FindHighlightsView extends Disposable {
1554
+ private readonly _view;
1555
+ private readonly _matchesLayer;
1556
+ private readonly _currentLayer;
1557
+ private readonly _highlightRegistration;
1558
+ private readonly _resizeObserver;
1559
+ private readonly _resizeObservedElements;
1560
+ private _snapshot;
1561
+ private _paintRaf;
1562
+ constructor(_view: EditorView, findModel: FindModel);
1563
+ private _schedulePaint;
1564
+ private _paint;
1565
+ private _observeResizeAncestors;
1566
+ private _paintRanges;
1567
+ }
1568
+
1569
+ export declare interface FindMatchesResult {
1570
+ readonly matches: readonly OffsetRange[];
1571
+ readonly isCapped: boolean;
1572
+ }
1573
+
1574
+ export declare class FindModel extends Disposable {
1575
+ private readonly _editorModel;
1576
+ readonly isRevealed: ISettableObservable<boolean, void>;
1577
+ readonly searchString: ISettableObservable<string, void>;
1578
+ readonly isRegex: ISettableObservable<boolean, void>;
1579
+ readonly matchCase: ISettableObservable<boolean, void>;
1580
+ readonly wholeWord: ISettableObservable<boolean, void>;
1581
+ readonly searchScope: ISettableObservable<OffsetRange | undefined, void>;
1582
+ readonly currentMatch: ISettableObservable<OffsetRange | undefined, void>;
1583
+ readonly loop: ISettableObservable<boolean, void>;
1584
+ readonly searchResult: IObservableWithChange< {
1585
+ kind: "invalid";
1586
+ error: Error;
1587
+ pattern?: undefined;
1588
+ matches?: undefined;
1589
+ isCapped?: undefined;
1590
+ } | {
1591
+ kind: "valid";
1592
+ pattern: FindPattern;
1593
+ matches: readonly OffsetRange[];
1594
+ isCapped: boolean;
1595
+ error?: undefined;
1596
+ }, void>;
1597
+ readonly matchesCount: IObservableWithChange<number, void>;
1598
+ readonly isCapped: IObservableWithChange<boolean, void>;
1599
+ readonly currentMatchPosition: IObservableWithChange<number, void>;
1600
+ private _searchOrigin;
1601
+ private readonly _sourceEditTracker;
1602
+ private _pendingInitialDirection;
1603
+ constructor(_editorModel: EditorModel);
1604
+ reveal(options: {
1605
+ readonly origin: number;
1606
+ readonly searchString?: string;
1607
+ readonly direction?: FindDirection;
1608
+ }): void;
1609
+ hide(): void;
1610
+ setSearchOrigin(offset: number): void;
1611
+ setSearchScope(scope: OffsetRange | undefined): void;
1612
+ moveToNextMatch(): OffsetRange | undefined;
1613
+ moveToPreviousMatch(): OffsetRange | undefined;
1614
+ private _move;
1615
+ private _selectFromOrigin;
1616
+ private _mapStateThroughEdit;
1617
+ private _inputSnapshot;
1618
+ private _readInputSnapshot;
1619
+ }
1620
+
757
1621
  /**
758
1622
  * Source offset (relative to `root`) of the node with `target`'s id, or
759
1623
  * `undefined` when it is not in the tree. Ids are stable across edits, so this
@@ -761,14 +1625,117 @@ declare class EmphasisViewData {
761
1625
  */
762
1626
  export declare function findNodeOffsetById(root: AstNode, target: AstNode): number | undefined;
763
1627
 
764
- export declare function findWordAt(text: string, offset: number): {
1628
+ export declare class FindPattern {
1629
+ private readonly _source;
1630
+ private readonly _flags;
1631
+ private readonly _wholeWord;
1632
+ private readonly _wordSeparators;
1633
+ readonly isEmpty: boolean;
1634
+ private constructor();
1635
+ static create(query: FindQuery): FindQueryResult;
1636
+ findMatches(text: string, scope?: OffsetRange, limit?: number): FindMatchesResult;
1637
+ findNextMatch(text: string, after: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1638
+ findPreviousMatch(text: string, before: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1639
+ private _forEachMatch;
1640
+ }
1641
+
1642
+ export declare interface FindQuery {
1643
+ readonly searchString: string;
1644
+ readonly isRegex: boolean;
1645
+ readonly matchCase: boolean;
1646
+ readonly wholeWord: boolean;
1647
+ readonly wordSeparators: string;
1648
+ }
1649
+
1650
+ export declare type FindQueryResult = {
1651
+ readonly kind: 'valid';
1652
+ readonly pattern: FindPattern;
1653
+ } | {
1654
+ readonly kind: 'invalid';
1655
+ readonly error: Error;
1656
+ };
1657
+
1658
+ export declare type FindSearchResult = {
1659
+ readonly kind: 'valid';
1660
+ readonly pattern: FindPattern;
1661
+ readonly matches: readonly OffsetRange[];
1662
+ readonly isCapped: boolean;
1663
+ } | {
1664
+ readonly kind: 'invalid';
1665
+ readonly error: Error;
1666
+ };
1667
+
1668
+ export declare class FindWidget extends Disposable {
1669
+ private readonly _view;
1670
+ private readonly _options;
1671
+ readonly element: HTMLElement;
1672
+ readonly panelElement: HTMLElement;
1673
+ readonly focused: ISettableObservable<boolean, void>;
1674
+ private readonly _inputShell;
1675
+ private readonly _input;
1676
+ private readonly _matchesCount;
1677
+ private readonly _previousButton;
1678
+ private readonly _nextButton;
1679
+ private readonly _selectionButton;
1680
+ private readonly _caseButton;
1681
+ private readonly _wholeWordButton;
1682
+ private readonly _regexButton;
1683
+ private readonly _error;
1684
+ constructor(_view: EditorView, _options: FindWidgetOptions);
1685
+ focusAndSelect(): void;
1686
+ private _registerButton;
1687
+ private _render;
1688
+ }
1689
+
1690
+ export declare interface FindWidgetOptions {
1691
+ readonly findModel: FindModel;
1692
+ readonly canFindInSelection: IObservable<boolean>;
1693
+ readonly onNext: () => void;
1694
+ readonly onPrevious: () => void;
1695
+ readonly onToggleFindInSelection: () => void;
1696
+ readonly onClose: () => void;
1697
+ }
1698
+
1699
+ export declare function findWordAt(text: string, offset: number, config?: WordNavigationConfig): {
765
1700
  start: number;
766
1701
  end: number;
767
1702
  };
768
1703
 
769
- export declare function findWordBoundaryLeft(text: string, offset: number): number;
1704
+ export declare function findWordBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
770
1705
 
771
- export declare function findWordBoundaryRight(text: string, offset: number): number;
1706
+ export declare function findWordBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
1707
+
1708
+ export declare function findWordDeleteBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
1709
+
1710
+ export declare function findWordDeleteBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
1711
+
1712
+ /**
1713
+ * A leading YAML front matter block. The YAML value is intentionally opaque:
1714
+ * only the two fences and the exact source between them are modeled.
1715
+ */
1716
+ export declare class FrontMatterAstNode extends BlockAstNodeBase {
1717
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
1718
+ readonly leadingTrivia?: GlueAstNode | undefined;
1719
+ readonly kind = "frontMatter";
1720
+ constructor(content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
1721
+ get children(): readonly AstNode[];
1722
+ get openFence(): MarkerAstNode | undefined;
1723
+ get closeFence(): MarkerAstNode | undefined;
1724
+ get value(): MarkerAstNode | undefined;
1725
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
1726
+ withLeadingTrivia(trivia: GlueAstNode | undefined): FrontMatterAstNode;
1727
+ }
1728
+
1729
+ declare class FrontMatterViewData {
1730
+ readonly ast: FrontMatterAstNode;
1731
+ /** Active: render both fences; inactive: render only the opaque YAML value. */
1732
+ readonly showMarkup: boolean;
1733
+ readonly content: readonly AnyViewData[];
1734
+ readonly kind = "frontMatter";
1735
+ constructor(ast: FrontMatterAstNode,
1736
+ /** Active: render both fences; inactive: render only the opaque YAML value. */
1737
+ showMarkup: boolean, content: readonly AnyViewData[]);
1738
+ }
772
1739
 
773
1740
  export declare function getAnnotatedSource(node: AstNode, source: string, offset?: number): string;
774
1741
 
@@ -845,6 +1812,19 @@ declare class HeadingViewData {
845
1812
  constructor(ast: HeadingAstNode, content: readonly AnyViewData[]);
846
1813
  }
847
1814
 
1815
+ export declare function hiddenCursorRanges(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number): readonly OffsetRange[];
1816
+
1817
+ export declare type HistoryKeyboardAction = 'undo' | 'redo';
1818
+
1819
+ /** A block HTML comment, discriminated by whether its closing delimiter is present. */
1820
+ declare type HtmlCommentSource = OpenHtmlCommentSource | CompleteHtmlCommentSource;
1821
+
1822
+ declare interface HtmlCommentSourceBase {
1823
+ readonly leadingWhitespace: string;
1824
+ readonly opening: '<!--';
1825
+ readonly body: string;
1826
+ }
1827
+
848
1828
  /**
849
1829
  * The editor operations a clipboard strategy drives. The strategy never
850
1830
  * touches the model or the DOM directly — it asks through this seam, so the
@@ -881,6 +1861,9 @@ export declare interface IClipboardStrategy {
881
1861
  connect(context: IClipboardContext): IDisposable;
882
1862
  }
883
1863
 
1864
+ /** A live rendering of a {@link CommentsModel}. Dispose to unmount it. */
1865
+ export declare type ICommentsPresenter = IDisposable;
1866
+
884
1867
  /** The Monarch language definitions the default highlighter wires up. */
885
1868
  export declare interface IDefaultMonarchGrammars {
886
1869
  typescript: unknown;
@@ -890,6 +1873,74 @@ export declare interface IDefaultMonarchGrammars {
890
1873
  python: unknown;
891
1874
  rust: unknown;
892
1875
  shell: unknown;
1876
+ yaml: unknown;
1877
+ }
1878
+
1879
+ /**
1880
+ * A live editor embedded in place of a fenced code block's *rendered* form.
1881
+ *
1882
+ * This is the internal seam between the block view and a concrete embedded
1883
+ * editor (e.g. an `<iframe>` speaking the web-editor protocol). The block view
1884
+ * only speaks string edits: it pushes the block's content down via
1885
+ * {@link setContent} and receives the editor's own changes back through
1886
+ * {@link onEdit} (set by the block view on each (re)construction, so it always
1887
+ * routes to the current AST node). The concrete implementation owns its DOM,
1888
+ * transport, and lifecycle.
1889
+ *
1890
+ * A single instance is adopted across re-renders (like the highlighter session)
1891
+ * so the underlying editor keeps its state across edits — see
1892
+ * {@link CodeBlockViewNode}.
1893
+ */
1894
+ declare interface IEmbeddedCodeEditor {
1895
+ /** The element mounted as the block's rendered form. */
1896
+ readonly element: HTMLElement;
1897
+ /**
1898
+ * Document → editor. The block's content changed (from any source). Must be
1899
+ * idempotent: pushing the content the editor already holds is a no-op, which
1900
+ * is how edits the editor itself originated are prevented from echoing back.
1901
+ */
1902
+ setContent(content: string): void;
1903
+ /** Update whether the embedded editor may change its content. */
1904
+ setReadOnly?(readOnly: boolean): void;
1905
+ /**
1906
+ * Optional synchronous height (px) to reserve for `content` *before* the
1907
+ * editor has laid out. Return `undefined` to let the editor size itself
1908
+ * (the implementation may report its real height later). Lets a registration
1909
+ * avoid a layout jump when it can cheaply estimate the size from content.
1910
+ */
1911
+ estimateHeight?(content: string): number | undefined;
1912
+ /**
1913
+ * Editor → document. Set by the block view on every (re)construction to
1914
+ * route the editor's own edits, expressed in the block's *content*
1915
+ * coordinates, to the current AST node.
1916
+ */
1917
+ onEdit?: (edit: StringEdit) => void;
1918
+ dispose(): void;
1919
+ }
1920
+
1921
+ /** Creates an {@link IEmbeddedCodeEditor} for a fenced block, or opts out. */
1922
+ declare interface IEmbeddedCodeEditorFactory {
1923
+ /**
1924
+ * Return an editor for a fenced block, or `undefined` to fall
1925
+ * back to the default (highlighting / {@link BlockViewOptions.renderCustomCodeBlock}).
1926
+ */
1927
+ create(language: string, infoString: string, initialContent: string): IEmbeddedCodeEditor | undefined;
1928
+ }
1929
+
1930
+ /**
1931
+ * Routes undo and redo to whatever owns the document's history: the editor
1932
+ * itself on a standalone page, or the enclosing document in a host like
1933
+ * VS Code.
1934
+ */
1935
+ export declare interface IHistoryStrategy {
1936
+ undo(): void;
1937
+ redo(): void;
1938
+ /**
1939
+ * Invoked around each source mutation so the strategy can record it.
1940
+ * Implemented only by strategies that build their own history; a host that
1941
+ * forwards edits to a VS Code `TextDocument` lets it record them instead.
1942
+ */
1943
+ record?(operation: () => void, edit?: StringEdit): void;
893
1944
  }
894
1945
 
895
1946
  export declare class ImageAstNode extends AstNode {
@@ -926,6 +1977,14 @@ export declare interface IMonarchApi {
926
1977
  MonarchTokenizer: new (languageService: unknown, standaloneThemeService: unknown, languageId: string, lexer: unknown, configurationService: unknown) => MonarchTokenizer;
927
1978
  }
928
1979
 
1980
+ /** Controls tab-stop insertion and non-list line indentation. */
1981
+ export declare interface IndentationConfig {
1982
+ /** Number of visual columns between tab stops. */
1983
+ readonly tabSize: number;
1984
+ /** Whether indentation uses spaces instead of tab characters. */
1985
+ readonly insertSpaces: boolean;
1986
+ }
1987
+
929
1988
  export declare type InlineAstNode = TextAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode;
930
1989
 
931
1990
  export declare class InlineCodeAstNode extends AstNode {
@@ -980,16 +2039,25 @@ export declare const insertParagraph: EditCommand;
980
2039
  * - paragraph / heading / thematic break — the "rich text" thing: at the
981
2040
  * block's end arm a transient empty paragraph (see {@link SmartEnterResult});
982
2041
  * elsewhere split into two paragraphs (`\n\n`).
983
- * - code block — insert a newline that preserves the current line's indentation,
984
- * staying inside the fence.
2042
+ * - fenced code / front matter — insert a newline that preserves the current
2043
+ * line's indentation, staying inside the fences.
985
2044
  * - block quote — continue the quote (`\n> `); an empty quote line exits it.
986
2045
  * - list — continue the list with the next marker (incrementing ordered
987
2046
  * numbers, re-emitting task checkboxes); an empty item exits the list.
2047
+ * - complete HTML comment — at the comment's end, leave it by arming a
2048
+ * transient paragraph; inside it (or while the comment is open), insert a
2049
+ * normal source line break.
988
2050
  * A non-collapsed selection, or any other block, falls back to a plain soft line
989
2051
  * break, preserving today's behaviour.
990
2052
  */
991
2053
  export declare const insertSmartEnter: (ctx: CursorCommandContext) => SmartEnterResult;
992
2054
 
2055
+ /**
2056
+ * VS Code-style Tab: insert to the next tab stop for a caret or partial
2057
+ * single-line selection, and indent every selected line for a line selection.
2058
+ */
2059
+ export declare function insertTab(config?: IndentationConfig): EditCommand;
2060
+
993
2061
  export declare function insertText(text: string): EditCommand;
994
2062
 
995
2063
  /**
@@ -1031,6 +2099,29 @@ export declare interface ISyntaxHighlighterDocument extends IDisposable {
1031
2099
  readonly snapshot: IObservableWithChange<ISyntaxHighlightedSnapshot, LengthEdit>;
1032
2100
  }
1033
2101
 
2102
+ export declare interface KeyboardBinding {
2103
+ readonly key: string;
2104
+ readonly modifiers?: KeyboardModifiers;
2105
+ readonly platforms?: readonly KeyboardPlatform[];
2106
+ readonly action: EditorKeyboardAction;
2107
+ }
2108
+
2109
+ export declare interface KeyboardModifiers {
2110
+ readonly shift?: boolean;
2111
+ readonly alt?: boolean;
2112
+ readonly ctrl?: boolean;
2113
+ readonly meta?: boolean;
2114
+ }
2115
+
2116
+ export declare type KeyboardPlatform = 'macos' | 'windows' | 'linux';
2117
+
2118
+ export declare interface KeyboardProfile {
2119
+ /**
2120
+ * Bindings in priority order. The first exact key/modifier/platform match wins.
2121
+ */
2122
+ readonly bindings: readonly KeyboardBinding[];
2123
+ }
2124
+
1034
2125
  declare abstract class LeafAstNode extends AstNode {
1035
2126
  abstract readonly content: string;
1036
2127
  get children(): readonly AstNode[];
@@ -1143,6 +2234,32 @@ declare class ListViewData {
1143
2234
  constructor(ast: ListAstNode, content: readonly AnyViewData[]);
1144
2235
  }
1145
2236
 
2237
+ /**
2238
+ * Compact in-memory history for editors that hold the only copy of the
2239
+ * document, such as a standalone browser page. Where the surrounding host
2240
+ * already records history — a VS Code `TextDocument` — forward to that
2241
+ * instead.
2242
+ */
2243
+ export declare class LocalHistoryStrategy implements IHistoryStrategy {
2244
+ private readonly _model;
2245
+ private readonly _past;
2246
+ private readonly _future;
2247
+ /**
2248
+ * The source text as of the last change this strategy recorded or applied.
2249
+ * Any other value means the document was replaced behind its back, so the
2250
+ * stored edits no longer line up and must be discarded rather than applied.
2251
+ */
2252
+ private _lastKnownText;
2253
+ constructor(_model: EditorModel);
2254
+ record(operation: () => void, edit?: StringEdit): void;
2255
+ undo(): void;
2256
+ redo(): void;
2257
+ /** The entry on top of `stack`, or `undefined` when it cannot be applied. */
2258
+ private _peekApplicable;
2259
+ private _apply;
2260
+ private _clear;
2261
+ }
2262
+
1146
2263
  /**
1147
2264
  * Parses markdown into a {@link DocumentAstNode}.
1148
2265
  *
@@ -1249,8 +2366,8 @@ export declare class MeasuredLayoutDebugRendering {
1249
2366
  * Exposes two DOM nodes the caller can place independently:
1250
2367
  *
1251
2368
  * - {@link overlayElement} — absolutely positioned; the caller mounts it
1252
- * inside the editor element so dashed line-bands and run-boxes line up
1253
- * with the editor's client coordinates.
2369
+ * inside the editor overlay container so dashed line-bands and run-boxes
2370
+ * share the measured editor-local coordinates.
1254
2371
  * - {@link infoElement} — block-flow; the caller mounts it as a sibling
1255
2372
  * *below* the editor. Contains the per-block summary table that used
1256
2373
  * to live on the overlay.
@@ -1261,7 +2378,6 @@ export declare class MeasuredLayoutDebugRendering {
1261
2378
  * the derived subscribed.
1262
2379
  */
1263
2380
  export declare class MeasuredLayoutDebugView extends Disposable {
1264
- private readonly _overlayParent;
1265
2381
  readonly overlayElement: HTMLElement;
1266
2382
  readonly infoElement: HTMLElement;
1267
2383
  readonly rendering: IObservable<MeasuredLayoutDebugRendering>;
@@ -1274,6 +2390,7 @@ export declare class MeasuredLayoutDebugView extends Disposable {
1274
2390
 
1275
2391
  export declare interface MeasuredLayoutDebugViewOptions {
1276
2392
  readonly model: MeasuredLayoutModel;
2393
+ readonly coordinateSpace: EditorCoordinateSpace;
1277
2394
  /**
1278
2395
  * DEBUG ONLY. Maps an absolute source offset to a fill color for that
1279
2396
  * character's glyph rect. The fixture passes the same function to the
@@ -1306,14 +2423,16 @@ export declare interface MeasuredLayoutDebugViewOptions {
1306
2423
  * through this model and never touches view fields directly.
1307
2424
  */
1308
2425
  export declare class MeasuredLayoutModel {
1309
- readonly measurements: ISettableObservable<readonly BlockMeasurement[], void>;
2426
+ private readonly _measurements;
2427
+ readonly measurements: IObservable<readonly BlockMeasurement[]>;
2428
+ private readonly _virtualLines;
1310
2429
  /**
1311
- * Concatenated visual line map across all mounted blocks. Lines are
1312
- * left in DOM (client-coordinate) y order each per-block map already
1313
- * uses absolute client coordinates from `getClientRects()`, so the
1314
- * concatenation is well-formed without re-sorting.
2430
+ * Concatenated visual line map across all mounted blocks. Every per-block
2431
+ * map uses the same editor-local coordinate space, so concatenation is
2432
+ * well-formed without translation or re-sorting.
1315
2433
  */
1316
2434
  readonly visualLineMap: IObservableWithChange<VisualLineMap, void>;
2435
+ setMeasurements(measurements: readonly BlockMeasurement[], virtualLines: readonly VirtualLineMeasurement[]): void;
1317
2436
  }
1318
2437
 
1319
2438
  /**
@@ -1353,14 +2472,25 @@ export declare class NativeClipboardStrategy implements IClipboardStrategy {
1353
2472
  connect(context: IClipboardContext): IDisposable;
1354
2473
  }
1355
2474
 
2475
+ declare interface NestedItem {
2476
+ readonly kind: 'nested';
2477
+ readonly original: AstNode;
2478
+ readonly originalStart: number;
2479
+ readonly modified: AstNode;
2480
+ readonly modifiedStart: number;
2481
+ readonly children: readonly DiffItem[];
2482
+ }
2483
+
1356
2484
  /**
1357
2485
  * Move the cursor one position left or right, skipping over hidden marker
1358
2486
  * ranges in inactive blocks (and inactive items of an active list).
1359
2487
  */
1360
- export declare function nextCursorPosition(doc: DocumentAstNode, activeBlock: BlockAstNode | undefined, cursor: number, direction: 'left' | 'right'): number;
2488
+ export declare function nextCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, direction: 'left' | 'right'): number;
1361
2489
 
1362
2490
  declare const NO_ACTIVE_BLOCKS: unique symbol;
1363
2491
 
2492
+ export declare function normalizeCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, target: number, direction: 'left' | 'right', includeHiddenRangeBoundary?: boolean): number;
2493
+
1364
2494
  export declare class OffsetRange {
1365
2495
  readonly start: number;
1366
2496
  readonly endExclusive: number;
@@ -1388,6 +2518,14 @@ export declare class OffsetRange {
1388
2518
  toString(): string;
1389
2519
  }
1390
2520
 
2521
+ /** The lossless source slices of a block HTML comment whose closer has not been typed. */
2522
+ declare interface OpenHtmlCommentSource extends HtmlCommentSourceBase {
2523
+ readonly kind: 'open';
2524
+ }
2525
+
2526
+ /** Outdent the current line, or every line touched by the selection. */
2527
+ export declare function outdent(config?: IndentationConfig): EditCommand;
2528
+
1391
2529
  export declare class ParagraphAstNode extends BlockAstNodeBase {
1392
2530
  readonly content: readonly (InlineAstNode | GlueAstNode)[];
1393
2531
  readonly leadingTrivia?: GlueAstNode | undefined;
@@ -1406,23 +2544,27 @@ declare class ParagraphViewData {
1406
2544
  }
1407
2545
 
1408
2546
  /**
1409
- * A *transient* editing state: the empty paragraph the user conjured by
1410
- * pressing Enter at the end of a paragraph. Markdown has no empty-paragraph
1411
- * node, so this never lives in {@link EditorModel.sourceText} or the parsed
1412
- * {@link EditorModel.document} — it is pure edit intent that the view renders
1413
- * as a synthetic blank line and that the controller either *materializes* (the
1414
- * user types) or *cancels* (the user navigates away / backspaces).
2547
+ * A *transient* editing state: an empty paragraph adjacent to a real block.
2548
+ * Markdown has no empty-paragraph node, so this never lives in
2549
+ * {@link EditorModel['sourceText']} or the parsed {@link EditorModel.document}
2550
+ * — it is pure edit intent that the view renders as a synthetic blank line and
2551
+ * that the controller either *materializes* (the user types) or *cancels* (the
2552
+ * user navigates away / backspaces).
1415
2553
  */
1416
2554
  declare interface PendingParagraph {
1417
- /** The paragraph the blank line is rendered directly after. */
2555
+ /** The block the blank line is rendered directly after. */
1418
2556
  readonly anchorBlock: BlockAstNode;
1419
2557
  /**
1420
2558
  * Source region rewritten when the pending paragraph is materialized — the
1421
2559
  * gap between {@link anchorBlock}'s text and whatever follows it.
1422
2560
  */
1423
2561
  readonly replaceRange: OffsetRange;
2562
+ /** Whether materialized text needs a blank-line separator before it. */
2563
+ readonly separateFromPreviousBlock: boolean;
1424
2564
  /** Whether {@link replaceRange} ends at the end of the document. */
1425
2565
  readonly atEof: boolean;
2566
+ /** The source-less visual line occupied by the pending caret. */
2567
+ readonly cursorLine: VirtualCursorLine;
1426
2568
  /**
1427
2569
  * A throwaway AST node that exists only to give the synthetic view child a
1428
2570
  * stable identity across render frames (the view pairs nodes by `ast.id`).
@@ -1431,21 +2573,46 @@ declare interface PendingParagraph {
1431
2573
  readonly syntheticAst: ParagraphAstNode;
1432
2574
  }
1433
2575
 
2576
+ declare interface PendingParagraphResult {
2577
+ readonly kind: 'pending';
2578
+ readonly anchorBlock: BlockAstNode;
2579
+ readonly replaceRange: OffsetRange;
2580
+ /** Whether materialized text needs a blank-line separator before it. */
2581
+ readonly separateFromPreviousBlock: boolean;
2582
+ readonly atEof: boolean;
2583
+ }
2584
+
1434
2585
  /**
1435
2586
  * View-data for the transient empty paragraph (see `PendingParagraph` in the
1436
2587
  * model). It carries only the throwaway {@link ParagraphAstNode} that gives the
1437
- * rendered blank line a stable identity across frames; it has no content and is
1438
- * never measured or part of the selection geometry the caret is positioned
1439
- * over it via a dedicated rect, not via the visual-line map.
2588
+ * rendered blank line a stable identity across frames, its anchor block, and
2589
+ * its source-less cursor line. It has no source content or selection range.
1440
2590
  */
1441
2591
  declare class PendingParagraphViewData {
1442
2592
  readonly ast: ParagraphAstNode;
2593
+ readonly anchorBlock: BlockAstNode;
2594
+ readonly cursorLine: VirtualCursorLine;
1443
2595
  readonly kind = "pendingParagraph";
1444
- constructor(ast: ParagraphAstNode);
2596
+ constructor(ast: ParagraphAstNode, anchorBlock: BlockAstNode, cursorLine: VirtualCursorLine);
2597
+ }
2598
+
2599
+ /**
2600
+ * The mounted transient empty paragraph: a `<p class="md-pending-paragraph">`
2601
+ * holding a single `<br>` so it occupies a line's height. It is a leaf view
2602
+ * node with no inline source content; the document view publishes its element
2603
+ * geometry as a virtual visual line.
2604
+ */
2605
+ declare class PendingParagraphViewNode extends ViewNode {
2606
+ readonly element: HTMLElement;
2607
+ readonly anchorBlock: BlockAstNode;
2608
+ readonly cursorLine: VirtualCursorLine;
2609
+ constructor(view: PendingParagraphViewData);
1445
2610
  }
1446
2611
 
1447
2612
  /**
1448
- * Immutable point in 2D space, in CSS-pixel client coordinates.
2613
+ * Immutable point in a caller-defined 2D CSS-pixel coordinate space.
2614
+ * Coordinate-owning APIs must document whether values are viewport-client or
2615
+ * editor-local; values from different spaces must not be mixed.
1449
2616
  */
1450
2617
  export declare class Point2D {
1451
2618
  readonly x: number;
@@ -1456,8 +2623,8 @@ export declare class Point2D {
1456
2623
  }
1457
2624
 
1458
2625
  /**
1459
- * Immutable axis-aligned rectangle in 2D space, in CSS-pixel client
1460
- * coordinates. `x`/`y` is the top-left corner, growing right/down.
2626
+ * Immutable axis-aligned rectangle in a caller-defined 2D CSS-pixel coordinate
2627
+ * space. `x`/`y` is the top-left corner, growing right/down.
1461
2628
  *
1462
2629
  * Half-open in both dimensions: `right` and `bottom` are excluded.
1463
2630
  */
@@ -1483,6 +2650,23 @@ export declare class Rect2D {
1483
2650
  translate(dx: number, dy: number): Rect2D;
1484
2651
  }
1485
2652
 
2653
+ declare interface RemovedItem {
2654
+ readonly kind: 'removed';
2655
+ readonly node: AstNode;
2656
+ readonly originalStart: number;
2657
+ readonly deletedLocal: readonly AnnotatedRange[];
2658
+ }
2659
+
2660
+ declare interface ReplacedItem {
2661
+ readonly kind: 'replaced';
2662
+ readonly original: AstNode;
2663
+ readonly originalStart: number;
2664
+ readonly modified: AstNode;
2665
+ readonly modifiedStart: number;
2666
+ readonly insertedLocal: readonly AnnotatedRange[];
2667
+ readonly deletedLocal: readonly AnnotatedRange[];
2668
+ }
2669
+
1486
2670
  export declare const selectAll: SelectionCommand;
1487
2671
 
1488
2672
  export declare function selectBlock(ctx: CursorCommandContext, blockRange: OffsetRange): Selection_2;
@@ -1508,8 +2692,13 @@ export { Selection_2 as Selection }
1508
2692
  export declare interface SelectionBlock {
1509
2693
  readonly block: BlockAstNode;
1510
2694
  readonly absoluteStart: number;
1511
- readonly viewNode: ViewNode;
1512
- readonly element: HTMLElement;
2695
+ /** Block border box in editor-local coordinates. */
2696
+ readonly rect: Rect2D;
2697
+ /** Visible horizontal padding-box bounds for a scrolling block. */
2698
+ readonly viewportClip: {
2699
+ readonly left: number;
2700
+ readonly right: number;
2701
+ } | undefined;
1513
2702
  }
1514
2703
 
1515
2704
  export declare type SelectionCommand = (ctx: CursorCommandContext, offset: SourceOffset) => Selection_2;
@@ -1521,6 +2710,9 @@ export declare interface SelectionRect {
1521
2710
  readonly height: number;
1522
2711
  }
1523
2712
 
2713
+ /** The interaction that produced the current editor selection. */
2714
+ export declare type SelectionSource = 'user' | 'find';
2715
+
1524
2716
  /**
1525
2717
  * Owns the SVG overlay that paints the selection.
1526
2718
  *
@@ -1541,11 +2733,10 @@ export declare interface SelectionRect {
1541
2733
  * envelope shape used by IDE selection rendering.
1542
2734
  */
1543
2735
  export declare class SelectionView extends Disposable {
1544
- private readonly _parent;
1545
2736
  readonly element: SVGSVGElement;
1546
2737
  readonly rendering: IObservable<SelectionViewRendering>;
1547
2738
  private readonly _path;
1548
- constructor(_parent: HTMLElement, options: SelectionViewOptions);
2739
+ constructor(options: SelectionViewOptions);
1549
2740
  }
1550
2741
 
1551
2742
  export declare interface SelectionViewOptions {
@@ -1573,12 +2764,7 @@ export declare type SmartEnterResult = {
1573
2764
  readonly kind: 'edit';
1574
2765
  readonly edit: StringEdit;
1575
2766
  readonly selection: Selection_2;
1576
- } | {
1577
- readonly kind: 'pending';
1578
- readonly anchorBlock: BlockAstNode;
1579
- readonly replaceRange: OffsetRange;
1580
- readonly atEof: boolean;
1581
- };
2767
+ } | PendingParagraphResult;
1582
2768
 
1583
2769
  /**
1584
2770
  * A run of {@link Token}s together with the exact {@link OffsetRange} they
@@ -1593,8 +2779,39 @@ export declare interface SnapshotTokens {
1593
2779
  readonly tokens: readonly Token[];
1594
2780
  }
1595
2781
 
2782
+ /** Metadata delivered synchronously immediately before a model-owned source edit is applied. */
2783
+ export declare interface SourceEditEvent {
2784
+ readonly baseSourceTextId: number;
2785
+ readonly resultSourceTextId: number;
2786
+ readonly edit: StringEdit;
2787
+ readonly transaction: ITransaction;
2788
+ }
2789
+
1596
2790
  export declare type SourceOffset = number;
1597
2791
 
2792
+ export declare abstract class StackedCommentsPresenter extends Disposable implements ICommentsPresenter {
2793
+ protected readonly model: CommentsModel;
2794
+ protected readonly view: EditorView;
2795
+ protected readonly context?: CommentsPresenterContext | undefined;
2796
+ private readonly _layer;
2797
+ private readonly _entries;
2798
+ private _order;
2799
+ private _pendingRevealCommentId;
2800
+ constructor(model: CommentsModel, view: EditorView, context?: CommentsPresenterContext | undefined);
2801
+ /** Build the card DOM for a comment. Called once per new comment. */
2802
+ protected abstract createWidget(comment: Comment_2): StackWidget;
2803
+ revealComment(id: string): void;
2804
+ private _reconcile;
2805
+ private _relayout;
2806
+ private _revealPendingComment;
2807
+ }
2808
+
2809
+ /** The minimal widget contract a subclass must produce. */
2810
+ export declare interface StackWidget {
2811
+ readonly element: HTMLElement;
2812
+ dispose(): void;
2813
+ }
2814
+
1598
2815
  export declare class StrikethroughAstNode extends AstNode {
1599
2816
  readonly openMarker: MarkerAstNode;
1600
2817
  readonly content: readonly (InlineAstNode | GlueAstNode)[];
@@ -1637,6 +2854,11 @@ export declare class StringReplacement {
1637
2854
  constructor(replaceRange: OffsetRange, newText: string);
1638
2855
  get isEmpty(): boolean;
1639
2856
  equals(other: StringReplacement): boolean;
2857
+ /**
2858
+ * Narrows this replacement to the span that actually changes, by trimming
2859
+ * the prefix and suffix it shares with the text it replaces in `source`.
2860
+ */
2861
+ removeCommonSuffixPrefix(source: string): StringReplacement;
1640
2862
  toString(): string;
1641
2863
  }
1642
2864
 
@@ -1665,6 +2887,8 @@ declare class StrongViewData {
1665
2887
  constructor(ast: StrongAstNode, content: readonly AnyViewData[]);
1666
2888
  }
1667
2889
 
2890
+ export declare type TabKeyboardAction = 'insert' | 'outdent';
2891
+
1668
2892
  export declare class TableAstNode extends BlockAstNodeBase {
1669
2893
  readonly content: readonly (TableRowAstNode | GlueAstNode)[];
1670
2894
  readonly leadingTrivia?: GlueAstNode | undefined;
@@ -1799,6 +3023,55 @@ export declare class Token {
1799
3023
  className: string | undefined);
1800
3024
  }
1801
3025
 
3026
+ declare interface UnchangedItem {
3027
+ readonly kind: 'unchanged';
3028
+ /** The modified-side node (identical in content to the original). */
3029
+ readonly node: AstNode;
3030
+ readonly modifiedStart: number;
3031
+ }
3032
+
3033
+ /**
3034
+ * A block whose token type the parser does not understand (a setext heading or
3035
+ * any future/extension construct). Rather than dropping the
3036
+ * span — which would demote its text to invisible glue — the parser captures the
3037
+ * whole source range verbatim as a single {@link MarkerAstNode} of kind
3038
+ * `content` and records the originating micromark {@link tokenType}, so the view
3039
+ * can render it as raw, editable text with an "unhandled" affordance. Offsets
3040
+ * stay sound: `content` tiles the block's full source span exactly.
3041
+ */
3042
+ declare class UnhandledBlockAstNode extends BlockAstNodeBase {
3043
+ readonly tokenType: string;
3044
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
3045
+ readonly leadingTrivia?: GlueAstNode | undefined;
3046
+ readonly kind = "unhandledBlock";
3047
+ constructor(tokenType: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
3048
+ get children(): readonly AstNode[];
3049
+ get code(): MarkerAstNode | undefined;
3050
+ /**
3051
+ * Lossless slices when this raw HTML block starts one comment after optional
3052
+ * whitespace. An open comment consumes the remaining source as its body. A
3053
+ * complete comment permits only trailing whitespace after its closer.
3054
+ */
3055
+ get htmlComment(): HtmlCommentSource | undefined;
3056
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
3057
+ withLeadingTrivia(trivia: GlueAstNode | undefined): UnhandledBlockAstNode;
3058
+ protected _localEquals(o: this): boolean;
3059
+ }
3060
+
3061
+ /**
3062
+ * View-data for an {@link UnhandledBlockAstNode}. The source remains verbatim
3063
+ * in both states. Complete HTML comments use {@link showMarkup} to switch
3064
+ * between their quiet reading treatment and editable source presentation;
3065
+ * other unhandled blocks ignore the flag and keep their warning treatment.
3066
+ */
3067
+ declare class UnhandledBlockViewData {
3068
+ readonly ast: UnhandledBlockAstNode;
3069
+ readonly showMarkup: boolean;
3070
+ readonly content: readonly AnyViewData[];
3071
+ readonly kind = "unhandledBlock";
3072
+ constructor(ast: UnhandledBlockAstNode, showMarkup: boolean, content: readonly AnyViewData[]);
3073
+ }
3074
+
1802
3075
  /**
1803
3076
  * Immutable view of an AST node. Pairs `ast` with its rendered `dom` and a
1804
3077
  * mirror of `ast.children` as ViewNode children. Source offsets are NEVER
@@ -1863,10 +3136,12 @@ export declare class ViewNode extends Disposable {
1863
3136
  /**
1864
3137
  * Map a DOM hit that lands on THIS node's own representation into a source
1865
3138
  * range in this node's local space `[0, ast.length)`. Polymorphic: a text
1866
- * leaf maps the caret offset 1:1; an element-only node (KaTeX math, `<hr>`,
1867
- * an image, a hidden marker) has no internal text mapping and snaps to its
1868
- * start by default subclasses may override (e.g. to snap to the nearer
1869
- * edge by x).
3139
+ * leaf maps the caret offset 1:1. For an element hit — an element-only node
3140
+ * (KaTeX math, `<hr>`, an image, a hidden marker) or a wrapper/container
3141
+ * element the platform reports a child-index offset, not a text caret, so
3142
+ * there is no internal mapping to honour: it snaps to the node's nearer
3143
+ * edge, `offset 0` (the "before" side) → start, any `offset >= 1` (the
3144
+ * "after" side) → end. Subclasses may override for finer control.
1870
3145
  */
1871
3146
  getLocalSourceRange(pos: DomPosition): OffsetRange;
1872
3147
  /**
@@ -1888,6 +3163,24 @@ export declare class ViewNode extends Disposable {
1888
3163
  forEachTextLeaf(nodeOffset: number, visitor: (leaf: ViewNode, leafOffset: number) => void): void;
1889
3164
  }
1890
3165
 
3166
+ /**
3167
+ * A visual cursor line that has no representation in the source text.
3168
+ *
3169
+ * The two source offsets are the positions immediately before and after the
3170
+ * virtual line. The object itself is the stable identity of the line.
3171
+ */
3172
+ export declare class VirtualCursorLine {
3173
+ readonly sourceOffsetBefore: SourceOffset;
3174
+ readonly sourceOffsetAfter: SourceOffset;
3175
+ constructor(sourceOffsetBefore: SourceOffset, sourceOffsetAfter: SourceOffset);
3176
+ }
3177
+
3178
+ /** A measured source-less line inserted directly after a source block. */
3179
+ declare interface VirtualLineMeasurement {
3180
+ readonly afterBlock: BlockAstNode;
3181
+ readonly line: VisualLine;
3182
+ }
3183
+
1891
3184
  export declare type VisualCursorCommand = (ctx: VisualCursorCommandContext) => CursorMoveResult;
1892
3185
 
1893
3186
  export declare interface VisualCursorCommandContext extends CursorCommandContext {
@@ -1905,12 +3198,15 @@ export declare function visualizeAst(root: AstNode, source: string): AstVisualiz
1905
3198
  export declare class VisualLine {
1906
3199
  readonly rect: Rect2D;
1907
3200
  readonly runs: readonly VisualRun[];
1908
- constructor(rect: Rect2D, runs: readonly VisualRun[]);
3201
+ readonly virtualCursorLine?: VirtualCursorLine | undefined;
3202
+ static virtual(cursorLine: VirtualCursorLine, rect: Rect2D): VisualLine;
3203
+ constructor(rect: Rect2D, runs: readonly VisualRun[], virtualCursorLine?: VirtualCursorLine | undefined);
1909
3204
  containsOffset(offset: SourceOffset): boolean;
1910
3205
  /**
1911
3206
  * How `offset` relates to this line's runs:
1912
3207
  * - `'covers'`: a run starts at or strictly contains the offset
1913
- * (`start <= offset < endExclusive`) the caret belongs on this line.
3208
+ * (`start <= offset < endExclusive`), or a zero-length visual-line
3209
+ * anchor sits at the offset — the caret belongs on this line.
1914
3210
  * - `'end'`: the offset is only some run's trailing boundary
1915
3211
  * (`offset === endExclusive`) with no run covering it — a line-break
1916
3212
  * boundary the caret should leave for the next line.
@@ -1923,23 +3219,42 @@ export declare class VisualLine {
1923
3219
  */
1924
3220
  sourceDistanceTo(offset: SourceOffset): number;
1925
3221
  /**
1926
- * x of the caret position before `offset` on this line. When `offset`
1927
- * is past all runs (trailing whitespace / blank line), returns the
1928
- * right edge of the last run; when before all runs, returns the left
1929
- * edge of the first run.
3222
+ * x of the caret position before `offset` on this line.
3223
+ *
3224
+ * The runs tile the source but are stored in paint order, not sorted by
3225
+ * source offset (hidden-marker runs are appended last). So this scans all
3226
+ * runs rather than assuming any ordering:
3227
+ *
3228
+ * - A zero-source visual anchor owns its exact offset, so a marker-only line
3229
+ * wins over the preceding line's inclusive end boundary.
3230
+ * - Otherwise a run starting at `offset` owns that seam. This keeps an
3231
+ * out-of-flow prefix from placing the caret at its trailing edge when the
3232
+ * following body starts at a visually separate x.
3233
+ * - Otherwise, if some run *covers* `offset`, its own geometry places the
3234
+ * caret (exact glyph boundary for text runs). In the active,
3235
+ * markers-visible form every interior offset is covered, so this branch
3236
+ * keeps distinct offsets distinct.
3237
+ * - Otherwise `offset` sits in a gap — a hidden inline marker such as the
3238
+ * `**` of `**bold**`, or before/after the painted text. It snaps to the
3239
+ * seam between the source-nearest runs on either side: the right edge of
3240
+ * the closest run ending at/before `offset`, else the left edge of the
3241
+ * closest run starting at/after it. A hidden marker collapses to zero
3242
+ * width, so both edges coincide at the seam.
1930
3243
  */
1931
3244
  xAtOffset(offset: SourceOffset): number;
1932
3245
  /**
1933
3246
  * Snap `x` to the nearest offset on this line. If `x` falls inside a
1934
- * run, the offset is interpolated by character fraction; otherwise it
1935
- * snaps to the closer edge of the nearest run.
3247
+ * run, the run resolves the offset (exact glyph boundary for text runs,
3248
+ * nearer edge for source-less runs); otherwise it snaps to the closer
3249
+ * edge of the nearest run.
1936
3250
  */
1937
3251
  offsetAtX(x: number): SourceOffset;
1938
3252
  }
1939
3253
 
1940
3254
  /**
1941
3255
  * Geometry of the rendered document, as a map from source offsets to 2D
1942
- * positions and back.
3256
+ * positions and back. All geometry is expressed in the editor overlay's local
3257
+ * CSS-pixel coordinate space.
1943
3258
  *
1944
3259
  * Structure (top to bottom):
1945
3260
  *
@@ -1974,7 +3289,9 @@ export declare class VisualLineMap {
1974
3289
  static measure(blockViews: readonly {
1975
3290
  readonly absoluteStart: number;
1976
3291
  readonly viewNode: ViewNode;
1977
- }[]): VisualLineMap;
3292
+ }[], coordinateSpace: EditorCoordinateSpace, transform?: EditorCoordinateTransform): VisualLineMap;
3293
+ /** Lines backed by source ranges, excluding source-less cursor lines. */
3294
+ readonly sourceLines: readonly VisualLine[];
1978
3295
  constructor(lines: readonly VisualLine[]);
1979
3296
  get lineCount(): number;
1980
3297
  get isEmpty(): boolean;
@@ -1999,6 +3316,12 @@ export declare class VisualLineMap {
1999
3316
  * {@link lineIndexOfOffset}. Returns `0` when the map is empty.
2000
3317
  */
2001
3318
  xAtOffset(offset: SourceOffset): number;
3319
+ /**
3320
+ * Line occupied by a source or virtual cursor position. A virtual position
3321
+ * returns `undefined` until its corresponding DOM line has been measured.
3322
+ */
3323
+ lineIndexOfPosition(position: CursorPosition): number | undefined;
3324
+ xAtPosition(position: CursorPosition): number;
2002
3325
  /**
2003
3326
  * Line whose vertical band contains `y`, clamped to the first/last
2004
3327
  * line when `y` is outside the document.
@@ -2012,6 +3335,9 @@ export declare class VisualLineMap {
2012
3335
  offsetAtPoint(point: Point2D): SourceOffset;
2013
3336
  /** Snap `x` to the nearest offset on a specific line. */
2014
3337
  offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
3338
+ positionInLineAtX(lineIndex: number, x: number): CursorPosition;
3339
+ lineStartOffset(lineIndex: number): SourceOffset | undefined;
3340
+ lineEndOffset(lineIndex: number): SourceOffset | undefined;
2015
3341
  }
2016
3342
 
2017
3343
  /**
@@ -2020,14 +3346,22 @@ export declare class VisualLineMap {
2020
3346
  * When constructed with a {@link VisualRunSource}, `xAtOffset` returns the
2021
3347
  * pixel-exact x of the caret before character `offset` by measuring the
2022
3348
  * prefix `[textNodeStart, textNodeStart + (offset - sourceStart))` with a
2023
- * DOM `Range`. Without a source it falls back to linear interpolation
2024
- * across `rect.width`.
3349
+ * DOM `Range`.
3350
+ *
3351
+ * A source-less run has no per-offset geometry: it either represents an
3352
+ * element-only block (KaTeX math, a mermaid/custom diagram, an image, an
3353
+ * inactive `<hr>`) whose box does not correspond to source offsets, or a
3354
+ * hand-built run in a test. Either way it maps between offsets and x by
3355
+ * snapping to the nearer edge of {@link rect} rather than fabricating
3356
+ * interior positions.
2025
3357
  */
2026
3358
  export declare class VisualRun {
2027
3359
  readonly sourceRange: OffsetRange;
2028
3360
  readonly rect: Rect2D;
2029
3361
  readonly source?: VisualRunSource | undefined;
2030
- constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined);
3362
+ readonly isVisualLineAnchor: boolean;
3363
+ static visualLineAnchor(sourceOffset: SourceOffset, rect: Rect2D): VisualRun;
3364
+ constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined, isVisualLineAnchor?: boolean);
2031
3365
  get sourceStart(): SourceOffset;
2032
3366
  get sourceEndExclusive(): SourceOffset;
2033
3367
  get sourceLength(): number;
@@ -2039,19 +3373,40 @@ export declare class VisualRun {
2039
3373
 
2040
3374
  /**
2041
3375
  * The DOM source of a {@link VisualRun}. When set, `xAtOffset` and
2042
- * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`
2043
- * instead of linear interpolation across the run's rect. This matters for
2044
- * proportional fonts where character widths differ a lot (e.g. `m` vs `i`)
2045
- * and a caret placed by interpolation lands several pixels inside the
2046
- * wrong character.
3376
+ * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`.
3377
+ * This matters for proportional fonts where character widths differ a lot
3378
+ * (e.g. `m` vs `i`): a caret placed by anything coarser than real glyph
3379
+ * measurement lands several pixels inside the wrong character.
2047
3380
  *
2048
- * Hand-built runs (tests) omit this; their `xAtOffset` falls back to
2049
- * linear interpolation.
3381
+ * A run without a source has no per-offset geometry, so it maps between
3382
+ * offsets and x by snapping to the nearer run edge. Real text runs always
3383
+ * carry a source; source-less runs are element-only blocks (see
3384
+ * {@link _appendElementBlockRun}) and hand-built runs in tests.
2050
3385
  */
2051
3386
  declare interface VisualRunSource {
2052
3387
  readonly textNode: Text;
2053
3388
  /** Offset within `textNode.data` corresponding to `sourceRange.start`. */
2054
3389
  readonly textNodeStart: number;
3390
+ readonly coordinateSpace: EditorCoordinateSpace;
3391
+ }
3392
+
3393
+ export declare const vscodeHostKeyboardProfile: KeyboardProfile;
3394
+
3395
+ export declare const vscodeKeyboardProfile: KeyboardProfile;
3396
+
3397
+ export declare const vscodeLocalKeyboardProfile: KeyboardProfile;
3398
+
3399
+ export declare class VscodeStackedCommentsView extends StackedCommentsPresenter {
3400
+ protected createWidget(comment: Comment_2): StackWidget;
3401
+ }
3402
+
3403
+ export declare class VsCodeV2CommentsView extends StackedCommentsPresenter {
3404
+ protected createWidget(comment: Comment_2): StackWidget;
3405
+ }
3406
+
3407
+ export declare interface WordNavigationConfig {
3408
+ readonly wordSeparators: string;
3409
+ readonly wordSegmenterLocales: readonly string[];
2055
3410
  }
2056
3411
 
2057
3412
  export { }