@vscode/markdown-editor 0.0.2-9 → 0.0.2-90

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 (75) hide show
  1. package/README.md +31 -0
  2. package/dist/commands.d.ts +65 -0
  3. package/dist/commands.js +159 -0
  4. package/dist/commands.js.map +1 -0
  5. package/dist/config-BGeaJqWk.js +286 -0
  6. package/dist/config-BGeaJqWk.js.map +1 -0
  7. package/dist/config.d.ts +10 -0
  8. package/dist/config.js +6 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/index.d.ts +1560 -121
  11. package/dist/index.js +6168 -2077
  12. package/dist/index.js.map +1 -1
  13. package/dist/markdown-editor.css +1 -0
  14. package/dist/stringEdit-CVDbCUBY.js +215 -0
  15. package/dist/stringEdit-CVDbCUBY.js.map +1 -0
  16. package/dist/web-editors.d.ts +297 -0
  17. package/dist/web-editors.js +7359 -0
  18. package/dist/web-editors.js.map +1 -0
  19. package/package.json +54 -16
  20. package/src/contrib/comments/commentInput.css +89 -0
  21. package/src/contrib/comments/commentWidget.css +60 -0
  22. package/src/contrib/find/find.css +347 -0
  23. package/src/view/editor.css +1157 -31
  24. package/src/view/themes/default.css +13 -4
  25. package/src/view/themes/github.css +16 -13
  26. package/src/view/themes/vscode-default.css +397 -0
  27. package/src/view/themes/{vscode.css → vscode-github.css} +124 -62
  28. package/dist/_observables/assert.d.ts +0 -2
  29. package/dist/_observables/deps.d.ts +0 -28
  30. package/dist/_observables/disposables.d.ts +0 -19
  31. package/dist/_observables/equals.d.ts +0 -32
  32. package/dist/_observables/index.d.ts +0 -2
  33. package/dist/_observables/observableInternal/base.d.ts +0 -172
  34. package/dist/_observables/observableInternal/changeTracker.d.ts +0 -44
  35. package/dist/_observables/observableInternal/commonFacade/cancellation.d.ts +0 -24
  36. package/dist/_observables/observableInternal/commonFacade/deps.d.ts +0 -24
  37. package/dist/_observables/observableInternal/debugLocation.d.ts +0 -21
  38. package/dist/_observables/observableInternal/debugName.d.ts +0 -33
  39. package/dist/_observables/observableInternal/experimental/deferUnobserve.d.ts +0 -16
  40. package/dist/_observables/observableInternal/experimental/reducer.d.ts +0 -37
  41. package/dist/_observables/observableInternal/experimental/utils.d.ts +0 -15
  42. package/dist/_observables/observableInternal/index.d.ts +0 -25
  43. package/dist/_observables/observableInternal/logging/consoleObservableLogger.d.ts +0 -40
  44. package/dist/_observables/observableInternal/logging/debugGetDependencyGraph.d.ts +0 -4
  45. package/dist/_observables/observableInternal/logging/debugger/debuggerRpc.d.ts +0 -4
  46. package/dist/_observables/observableInternal/logging/debugger/devToolsLogger.d.ts +0 -43
  47. package/dist/_observables/observableInternal/logging/debugger/rpc.d.ts +0 -41
  48. package/dist/_observables/observableInternal/logging/debugger/utils.d.ts +0 -13
  49. package/dist/_observables/observableInternal/logging/logging.d.ts +0 -30
  50. package/dist/_observables/observableInternal/map.d.ts +0 -18
  51. package/dist/_observables/observableInternal/observables/baseObservable.d.ts +0 -58
  52. package/dist/_observables/observableInternal/observables/constObservable.d.ts +0 -5
  53. package/dist/_observables/observableInternal/observables/derived.d.ts +0 -46
  54. package/dist/_observables/observableInternal/observables/derivedImpl.d.ts +0 -83
  55. package/dist/_observables/observableInternal/observables/lazyObservableValue.d.ts +0 -27
  56. package/dist/_observables/observableInternal/observables/observableFromEvent.d.ts +0 -37
  57. package/dist/_observables/observableInternal/observables/observableSignal.d.ts +0 -11
  58. package/dist/_observables/observableInternal/observables/observableSignalFromEvent.d.ts +0 -5
  59. package/dist/_observables/observableInternal/observables/observableValue.d.ts +0 -37
  60. package/dist/_observables/observableInternal/observables/observableValueOpts.d.ts +0 -8
  61. package/dist/_observables/observableInternal/reactions/autorun.d.ts +0 -56
  62. package/dist/_observables/observableInternal/reactions/autorunImpl.d.ts +0 -53
  63. package/dist/_observables/observableInternal/set.d.ts +0 -17
  64. package/dist/_observables/observableInternal/transaction.d.ts +0 -27
  65. package/dist/_observables/observableInternal/utils/promise.d.ts +0 -75
  66. package/dist/_observables/observableInternal/utils/runOnChange.d.ts +0 -7
  67. package/dist/_observables/observableInternal/utils/utils.d.ts +0 -43
  68. package/dist/_observables/observableInternal/utils/utilsCancellation.d.ts +0 -10
  69. package/dist/_observables/observableInternal/utils/valueWithChangeEvent.d.ts +0 -10
  70. package/dist/_observables/utils.d.ts +0 -15
  71. package/dist/observables.d.ts +0 -4
  72. package/dist/observables.js +0 -439
  73. package/dist/observables.js.map +0 -1
  74. package/dist/runOnChange-C00UIwqQ.js +0 -1538
  75. package/dist/runOnChange-C00UIwqQ.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,15 +1,32 @@
1
- import { Disposable } from './_observables/index';
2
- import { IDisposable } from './_observables/index';
3
- import { IObservable } from './_observables/index';
4
- import { IObservableWithChange } from './_observables/index';
5
- import { ISettableObservable } from './_observables/index';
6
- import { ITransaction } from './_observables/index';
1
+ import { Disposable } from '@vscode/observables';
2
+ import { IDisposable } from '@vscode/observables';
3
+ import { IObservable } from '@vscode/observables';
4
+ import { IObservableWithChange } from '@vscode/observables';
5
+ import { ISettableObservable } from '@vscode/observables';
6
+ import { ITransaction } from '@vscode/observables';
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
@@ -171,12 +217,18 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
171
217
  export declare interface BlockViewOptions {
172
218
  readonly renderCustomCodeBlock?: (language: string, content: string) => HTMLElement | undefined;
173
219
  readonly onToggleCheckbox?: (item: ListItemAstNode, newChecked: boolean) => void;
220
+ /**
221
+ * Supplies live, declarative metadata for recognized links. The editor owns
222
+ * the markup and styling; providers own lookup, caching, and updates.
223
+ */
224
+ readonly linkPresentationProvider?: ILinkPresentationProvider;
174
225
  /**
175
226
  * Opens a link's URL. Called when the user activates a link: a plain click
176
227
  * 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')`.
228
+ * is active (source shown). Return `false` to use the anchor's native
229
+ * navigation behavior.
178
230
  */
179
- readonly onOpenLink?: (url: string, event: MouseEvent) => void;
231
+ readonly onOpenLink?: (url: string, event: MouseEvent) => false | void;
180
232
  /**
181
233
  * Colours fenced code blocks. When set, a code block's content is rendered
182
234
  * as a sequence of token spans instead of one plain text node. This is the
@@ -196,16 +248,43 @@ export declare interface BlockViewOptions {
196
248
  * `katexEditableIdentifiers.ts`).
197
249
  */
198
250
  readonly renderMath?: (request: MathRenderRequest) => MathRendering | undefined;
251
+ /**
252
+ * Pluggable factory for an in-place, interactive editor that replaces the
253
+ * *rendered* (inactive) form of a fenced code block — see
254
+ * {@link IEmbeddedCodeEditor}. When it returns an editor for the block's
255
+ * language, that editor's element is mounted instead of the highlighted
256
+ * code, and content flows both ways as string edits. Returning `undefined`
257
+ * falls back to the default rendering. EXPERIMENTAL.
258
+ */
259
+ readonly embeddedCodeEditorFactory?: IEmbeddedCodeEditorFactory;
260
+ /** Current read-only state forwarded to embedded code editors. */
261
+ readonly embeddedCodeEditorReadOnly?: boolean;
262
+ /** Identity used to invalidate previously created embedded editors. */
263
+ readonly embeddedCodeEditorFactoryVersion?: unknown;
264
+ /**
265
+ * Called when an {@link IEmbeddedCodeEditor} edits its content. `contentEdit`
266
+ * is in the block's *content* coordinates; the host translates it to a
267
+ * document edit (via {@link CodeBlockAstNode.codeOffset} and the block's
268
+ * offset) and applies it to the model.
269
+ */
270
+ readonly onEmbeddedCodeEditorEdit?: (block: CodeBlockAstNode, contentEdit: StringEdit) => void;
199
271
  }
200
272
 
201
273
  export declare class CodeBlockAstNode extends BlockAstNodeBase {
274
+ /** First token of the fenced code block info string, used for syntax highlighting. */
202
275
  readonly language: string;
276
+ /** Complete fenced code block info string, including metadata after the language token. */
277
+ readonly infoString: string;
203
278
  readonly content: readonly (MarkerAstNode | GlueAstNode)[];
204
279
  readonly leadingTrivia?: GlueAstNode | undefined;
205
280
  readonly kind = "codeBlock";
206
281
  private _previous?;
207
282
  private _contentEdit?;
208
- constructor(language: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
283
+ constructor(
284
+ /** First token of the fenced code block info string, used for syntax highlighting. */
285
+ language: string,
286
+ /** Complete fenced code block info string, including metadata after the language token. */
287
+ infoString: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
209
288
  get children(): readonly AstNode[];
210
289
  get openFence(): MarkerAstNode | undefined;
211
290
  get closeFence(): MarkerAstNode | undefined;
@@ -271,10 +350,222 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
271
350
  * its predecessor's subscription explicitly.
272
351
  */
273
352
  private _snapshotSub;
353
+ /**
354
+ * An in-place interactive editor (e.g. an iframe) mounted instead of the
355
+ * rendered code. Like {@link _session} it is adopted from `previous` across
356
+ * rebuilds so the underlying editor keeps its state, and must be disposed
357
+ * manually (a node reused as `previous` is never {@link dispose}d).
358
+ */
359
+ private _embeddedEditor;
360
+ private readonly _embeddedEditorFactoryVersion;
361
+ private readonly _embeddedEditorReadOnly;
362
+ canReuse(data: AnyViewData, options: BlockViewOptions | undefined): boolean;
274
363
  constructor(data: CodeBlockViewData, options: BlockViewOptions | undefined, previous: ViewNode | undefined);
275
364
  dispose(): void;
276
365
  }
277
366
 
367
+ /**
368
+ * Canonical editor command catalog. Standalone keyboard handling and host
369
+ * integrations derive their command registration and default keybindings from
370
+ * this list.
371
+ */
372
+ export declare const commands: readonly EditorCommandDefinition[];
373
+
374
+ /** A persistent comment anchored to a source range. */
375
+ declare interface Comment_2 {
376
+ readonly id: string;
377
+ /** Source range the comment refers to (its highlighted region). */
378
+ readonly range: OffsetRange;
379
+ /** The comment text. */
380
+ readonly body: string;
381
+ /** Display name of the author, if any. */
382
+ readonly author?: string;
383
+ /** Creation time (epoch ms), used to render a relative timestamp. */
384
+ readonly createdAt?: number;
385
+ }
386
+ export { Comment_2 as Comment }
387
+
388
+ /**
389
+ * The compact editing state for a markdown comment.
390
+ *
391
+ * The widget owns its DOM and draft state but not its position. The comment-mode
392
+ * controller mounts it next to the active selection.
393
+ */
394
+ export declare class CommentInputWidget extends Disposable {
395
+ private readonly _options?;
396
+ readonly element: HTMLElement;
397
+ private readonly _textarea;
398
+ private readonly _measure;
399
+ private readonly _submitButton;
400
+ private readonly _value;
401
+ /** Live, untrimmed textarea content. */
402
+ get value(): IObservable<string>;
403
+ /** The raw textarea, exposed so a host can move focus into it. */
404
+ get inputElement(): HTMLTextAreaElement;
405
+ constructor(_options?: CommentInputWidgetOptions | undefined);
406
+ focus(): void;
407
+ setText(text: string): void;
408
+ clear(): void;
409
+ private _submit;
410
+ private _autoSize;
411
+ }
412
+
413
+ export declare interface CommentInputWidgetOptions {
414
+ /** Placeholder shown while the textarea is empty. Defaults to "Add comment". */
415
+ readonly placeholder?: string;
416
+ /** Called after the textarea changes size. */
417
+ readonly onDidChangeSize?: () => void;
418
+ /**
419
+ * Called when the user submits a non-empty comment (Enter or the add button).
420
+ * The text is trimmed; never called with an empty string.
421
+ */
422
+ readonly onSubmit?: (text: string) => void;
423
+ /** Called when the user dismisses the input (Escape). */
424
+ readonly onCancel?: () => void;
425
+ }
426
+
427
+ /**
428
+ * Comment mode — a compact "add a comment" affordance layered on top of
429
+ * the editor *without modifying it*. It reads the editor's public observables
430
+ * ({@link EditorModel.readonlyMode}, {@link EditorModel.selection}) and the
431
+ * exposed {@link EditorView.caretRect} geometry, and mounts a
432
+ * {@link CommentInputWidget} into {@link EditorView.overlayContainer}.
433
+ *
434
+ * Behaviour:
435
+ * - Only active in read-only mode (the "review" view).
436
+ * - When a user-created selection is non-empty, the input box appears next to
437
+ * the caret (the selection's active end) but does NOT take focus, so keyboard
438
+ * selection keeps working. Programmatic selections such as find matches do
439
+ * not summon it. Press Tab to move focus into the box, then type.
440
+ * - The box appears on mouse-up, not mid-drag, so it doesn't flicker/jump
441
+ * while a selection is being dragged out (keyboard selection shows at once).
442
+ * - While the box has focus or holds a draft it is frozen in place (selection
443
+ * changes, drags and clicks no longer move it). It is dismissed by Escape,
444
+ * by submitting, or by blurring an empty box.
445
+ * - The editor's logical caret geometry remains available for anchoring in
446
+ * read-only mode even though the painted caret is hidden. While the box has
447
+ * focus, `.md-comment-active` also suppresses the painted caret in any mode.
448
+ */
449
+ export declare class CommentModeController extends Disposable {
450
+ private readonly _model;
451
+ private readonly _view;
452
+ private readonly _options?;
453
+ private static _isCommentableSelectionSource;
454
+ private readonly _widget;
455
+ private readonly _gap;
456
+ private _visible;
457
+ private _anchorX;
458
+ private _pinnedRange;
459
+ /**
460
+ * The range a comment was just submitted for. The box stays hidden for it
461
+ * until the selection changes, so submitting doesn't immediately re-summon an
462
+ * empty box on the still-selected text.
463
+ */
464
+ private _submittedRange;
465
+ constructor(_model: EditorModel, _view: EditorView, _options?: CommentModeControllerOptions | undefined);
466
+ private _update;
467
+ private _show;
468
+ private _layoutHorizontally;
469
+ /** Force-hide and clear the box (used by Escape and submit). */
470
+ private _hide;
471
+ /**
472
+ * Hide unless the user is engaged with the box: it has focus or holds a
473
+ * non-empty draft. This preserves in-progress text and keeps a focused box
474
+ * open (it is dismissed explicitly via Escape/submit, or by blurring it).
475
+ */
476
+ private _autoHide;
477
+ private _widgetHasFocus;
478
+ /**
479
+ * The visible viewport (client coords) used for the flip-above decision: the
480
+ * nearest scrollable ancestor of the editor. `.md-editor` itself spans the
481
+ * full document height and never clips, so measuring against it would always
482
+ * report room below. Falls back to the window when nothing scrolls.
483
+ */
484
+ private _getViewportRect;
485
+ private _hideAndRefocus;
486
+ private _submit;
487
+ }
488
+
489
+ export declare interface CommentModeControllerOptions {
490
+ /** Called when the user submits a comment for the current selection. */
491
+ readonly onSubmit?: (submission: CommentSubmission) => void;
492
+ /** Gap (px) between the bottom of the selection and the top of the input box. */
493
+ readonly gap?: number;
494
+ }
495
+
496
+ /**
497
+ * Seedable store of {@link Comment}s for the comment-mode contribution. It has
498
+ * no opinion on rendering or persistence — a host seeds it via
499
+ * {@link set}/{@link add} and observes {@link comments}.
500
+ */
501
+ export declare class CommentsModel {
502
+ private readonly _comments;
503
+ /** Monotonic counter for ids of comments created via {@link create}. */
504
+ private _sequence;
505
+ /** The current comments, in insertion order. */
506
+ get comments(): IObservable<readonly Comment_2[]>;
507
+ /** Replace the whole comment set. */
508
+ set(comments: readonly Comment_2[]): void;
509
+ /**
510
+ * Create a comment from a user submission and append it, generating its `id`
511
+ * and `createdAt` here so id/time allocation stays the store's concern (the
512
+ * UI only supplies the range and text). Returns the created comment.
513
+ */
514
+ create(input: {
515
+ range: OffsetRange;
516
+ body: string;
517
+ author?: string;
518
+ }): Comment_2;
519
+ /** Append a comment. */
520
+ add(comment: Comment_2): void;
521
+ /** Remove a comment by id. */
522
+ remove(id: string): void;
523
+ }
524
+
525
+ /** A comment the user submitted, with the source range it was anchored to. */
526
+ export declare interface CommentSubmission {
527
+ readonly text: string;
528
+ readonly range: OffsetRange;
529
+ }
530
+
531
+ /** Displays posted comments beside their source ranges. */
532
+ export declare class CommentsView extends Disposable {
533
+ private readonly _model;
534
+ private readonly _view;
535
+ private readonly _layer;
536
+ private readonly _entries;
537
+ private _order;
538
+ private _pendingRevealCommentId;
539
+ constructor(_model: CommentsModel, _view: EditorView);
540
+ revealComment(id: string): void;
541
+ private _reconcile;
542
+ private _relayout;
543
+ private _revealPendingComment;
544
+ }
545
+
546
+ /** Compact posted state for a markdown comment. */
547
+ export declare class CommentWidget {
548
+ private readonly _domNode;
549
+ private readonly _disposables;
550
+ get element(): HTMLElement;
551
+ constructor(options: CommentWidgetOptions);
552
+ dispose(): void;
553
+ }
554
+
555
+ export declare interface CommentWidgetOptions {
556
+ /** The posted comment body. */
557
+ readonly body: string;
558
+ /** If provided, shows a delete action and invokes it when activated. */
559
+ readonly onDelete?: () => void;
560
+ }
561
+
562
+ /** The lossless source slices of a complete block HTML comment. */
563
+ declare interface CompleteHtmlCommentSource extends HtmlCommentSourceBase {
564
+ readonly kind: 'complete';
565
+ readonly closing: '-->';
566
+ readonly trailingWhitespace: string;
567
+ }
568
+
278
569
  /**
279
570
  * A {@link MonacoSyntaxHighlighter} preloaded with a handful of common Monarch
280
571
  * grammars (plus the usual short aliases). Unknown languages fall back to an
@@ -285,13 +576,16 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
285
576
  */
286
577
  export declare function createDefaultMonacoSyntaxHighlighter(monaco: IMonarchApi, grammars: IDefaultMonarchGrammars): MonacoSyntaxHighlighter;
287
578
 
288
- export declare type CursorCommand = (ctx: CursorCommandContext) => SourceOffset;
579
+ export declare type CursorCommand = (ctx: CursorCommandContext) => CursorPosition;
289
580
 
290
581
  export declare interface CursorCommandContext {
291
582
  readonly text: string;
292
583
  readonly selection: Selection_2;
293
584
  readonly document: DocumentAstNode;
294
585
  readonly activeBlock: BlockAstNode | undefined;
586
+ readonly markerVisibleBlocks: ReadonlySet<BlockAstNode>;
587
+ readonly wordNavigationConfig: WordNavigationConfig;
588
+ readonly cursorPosition: CursorPosition;
295
589
  }
296
590
 
297
591
  export declare const cursorDocumentEnd: CursorCommand;
@@ -300,6 +594,8 @@ export declare const cursorDocumentStart: CursorCommand;
300
594
 
301
595
  export declare const cursorDown: VisualCursorCommand;
302
596
 
597
+ export declare type CursorKeyboardAction = 'left' | 'right' | 'up' | 'down' | 'wordLeft' | 'wordRight' | 'visualLineStart' | 'visualLineEnd' | 'logicalLineStart' | 'logicalLineEnd' | 'documentStart' | 'documentEnd';
598
+
303
599
  export declare const cursorLeft: CursorCommand;
304
600
 
305
601
  export declare const cursorLineEnd: CursorCommand;
@@ -309,12 +605,26 @@ export declare const cursorLineStart: CursorCommand;
309
605
  export declare const cursorMoveLeft: CursorCommand;
310
606
 
311
607
  export declare interface CursorMoveResult {
312
- readonly offset: SourceOffset;
608
+ readonly position: CursorPosition;
313
609
  readonly desiredColumn: number | undefined;
314
610
  }
315
611
 
316
612
  export declare const cursorMoveRight: CursorCommand;
317
613
 
614
+ /** The cursor's position in either source text or a source-less visual line. */
615
+ export declare type CursorPosition = {
616
+ readonly kind: 'source';
617
+ readonly offset: SourceOffset;
618
+ } | {
619
+ readonly kind: 'virtual';
620
+ readonly line: VirtualCursorLine;
621
+ };
622
+
623
+ export declare namespace CursorPosition {
624
+ export function source(offset: SourceOffset): CursorPosition;
625
+ export function virtual(line: VirtualCursorLine): CursorPosition;
626
+ }
627
+
318
628
  export declare const cursorRight: CursorCommand;
319
629
 
320
630
  export declare const cursorUp: VisualCursorCommand;
@@ -323,49 +633,129 @@ export declare const cursorUp: VisualCursorCommand;
323
633
  * Owns the blinking cursor DOM element.
324
634
  *
325
635
  * 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
636
+ * asks the {@link VisualLineMap} for the caret rect at the current source or
637
+ * virtual position, writes it to {@link element}, and returns a
328
638
  * {@link CursorViewRendering} value as proof. An autorun keeps the
329
639
  * derived subscribed.
330
640
  */
331
641
  export declare class CursorView extends Disposable {
332
- private readonly _parent;
333
642
  readonly element: HTMLElement;
334
643
  readonly rendering: IObservable<CursorViewRendering>;
335
- constructor(_parent: HTMLElement, options: CursorViewOptions);
644
+ constructor(options: CursorViewOptions);
336
645
  }
337
646
 
338
647
  export declare interface CursorViewOptions {
339
- readonly offset: IObservable<SourceOffset | undefined>;
648
+ readonly position: IObservable<CursorPosition | undefined>;
340
649
  readonly visualLineMap: IObservable<VisualLineMap>;
341
650
  /**
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.
651
+ * The mounted blocks, used to hide the caret when it sits at an offset that
652
+ * has been scrolled out of its (horizontally scrolling) block's viewport —
653
+ * matching how the selection is clipped there.
346
654
  */
347
- readonly pendingCaretRect?: IObservable<Rect2D | undefined>;
655
+ readonly blocks?: IObservable<readonly SelectionBlock[]>;
348
656
  }
349
657
 
350
658
  export declare class CursorViewRendering {
351
- readonly offset: SourceOffset;
659
+ readonly position: CursorPosition;
352
660
  readonly visible: boolean;
353
661
  readonly rect: Rect2D;
354
- constructor(offset: SourceOffset, visible: boolean, rect: Rect2D);
662
+ constructor(position: CursorPosition, visible: boolean, rect: Rect2D);
355
663
  }
356
664
 
665
+ export declare const cursorVisualLineEnd: VisualCursorCommand;
666
+
667
+ export declare const cursorVisualLineStart: VisualCursorCommand;
668
+
357
669
  export declare const cursorWordLeft: CursorCommand;
358
670
 
359
671
  export declare const cursorWordRight: CursorCommand;
360
672
 
673
+ export declare const DEFAULT_INDENTATION_CONFIG: IndentationConfig;
674
+
675
+ export declare const DEFAULT_WORD_NAVIGATION_CONFIG: WordNavigationConfig;
676
+
677
+ export declare const DEFAULT_WORD_SEPARATORS = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";
678
+
361
679
  export declare const deleteLeft: EditCommand;
362
680
 
681
+ export declare const deleteLineLeft: EditCommand;
682
+
683
+ export declare const deleteLineRight: EditCommand;
684
+
363
685
  export declare const deleteRight: EditCommand;
364
686
 
365
687
  export declare const deleteWordLeft: EditCommand;
366
688
 
367
689
  export declare const deleteWordRight: EditCommand;
368
690
 
691
+ /**
692
+ * A read-only "removed" decoration: an original block rendered (red) above its
693
+ * place in the modified document, occupying vertical space like a view-zone but
694
+ * contributing **zero** source length, so the editor's source mapping stays the
695
+ * modified document and editing is unaffected. Used for `removed` and the
696
+ * original side of a `replaced` block in editor diff mode.
697
+ */
698
+ declare class DiffDecorationViewData {
699
+ readonly ast: AstNode;
700
+ readonly side: BlockViewData;
701
+ readonly deletedRanges: readonly DiffHighlightRange[];
702
+ /** True when the whole block was removed: solid red band, no word rects. */
703
+ readonly whole: boolean;
704
+ /** Absolute offset of this block in the *original* document. */
705
+ readonly originalStart: number;
706
+ readonly kind = "diffDecoration";
707
+ constructor(ast: AstNode, side: BlockViewData, deletedRanges: readonly DiffHighlightRange[],
708
+ /** True when the whole block was removed: solid red band, no word rects. */
709
+ whole: boolean,
710
+ /** Absolute offset of this block in the *original* document. */
711
+ originalStart: number);
712
+ }
713
+
714
+ /** A word/character highlight inside one diff side, in block-local coords. */
715
+ declare interface DiffHighlightRange {
716
+ readonly range: OffsetRange;
717
+ readonly kind: 'inserted' | 'deleted';
718
+ }
719
+
720
+ /**
721
+ * A changed block rendered as its original form stacked over its modified form
722
+ * (either side may be absent for a pure deletion/insertion). It is itself a
723
+ * document child the renderer mounts like a block; its {@link ast} is the
724
+ * surviving side's ast, used only for view-node identity/reuse.
725
+ */
726
+ declare class DiffHunkViewData {
727
+ readonly ast: AstNode;
728
+ readonly original: DiffSideViewData | undefined;
729
+ readonly modified: DiffSideViewData | undefined;
730
+ readonly kind = "diffHunk";
731
+ constructor(ast: AstNode, original: DiffSideViewData | undefined, modified: DiffSideViewData | undefined);
732
+ }
733
+
734
+ /**
735
+ * The recursive classification of a diff. Each item describes one aligned
736
+ * position in the merged document:
737
+ *
738
+ * - `unchanged` — render the (modified) node once, neutral.
739
+ * - `added` — exists only in the modified document (green).
740
+ * - `removed` — exists only in the original document (red).
741
+ * - `replaced` — a *leaf* block changed in place → render original over
742
+ * modified, with word-level {@link AnnotatedRange}s on each.
743
+ * - `nested` — a *container* changed → render it once and diff its
744
+ * {@link NestedItem.children} recursively.
745
+ *
746
+ * Offsets ({@link UnchangedItem.modifiedStart} etc.) are absolute in their
747
+ * respective documents, so a renderer/visualizer can slice the source text.
748
+ */
749
+ declare type DiffItem = UnchangedItem | AddedItem | RemovedItem | ReplacedItem | NestedItem;
750
+
751
+ /** One side (original or modified) of a {@link DiffHunkViewData}. */
752
+ declare interface DiffSideViewData {
753
+ readonly view: BlockViewData;
754
+ /** Render in active form (markers/whitespace visible). */
755
+ readonly active: boolean;
756
+ readonly ranges: readonly DiffHighlightRange[];
757
+ }
758
+
369
759
  export declare class DocumentAstNode extends AstNode {
370
760
  readonly content: readonly (BlockAstNode | GlueAstNode)[];
371
761
  readonly kind = "document";
@@ -390,14 +780,21 @@ declare interface DocumentBlockViewData {
390
780
  readonly view: BlockViewData;
391
781
  }
392
782
 
393
- /** A mounted document child: a block, a run of inter-block glue, or the
394
- * transient empty paragraph (see {@link PendingParagraphViewData}). */
783
+ /** A mounted document child: a block, a run of inter-block glue, the
784
+ * transient empty paragraph (see {@link PendingParagraphViewData}), or a
785
+ * {@link DiffHunkViewData diff hunk} (stacked original/modified blocks). */
395
786
  declare interface DocumentChildViewData {
396
787
  readonly absoluteStart: number;
397
788
  /** For a block: selection reaches it. For glue: always false (unowned, hidden). */
398
789
  readonly isActive: boolean;
399
- readonly view: BlockViewData | GlueViewData | PendingParagraphViewData;
400
- readonly kind: 'block' | 'glue' | 'pendingParagraph';
790
+ readonly view: BlockViewData | GlueViewData | PendingParagraphViewData | DiffHunkViewData | DiffDecorationViewData;
791
+ readonly kind: 'block' | 'glue' | 'pendingParagraph' | 'diffHunk' | 'diffDecoration';
792
+ /**
793
+ * Diff mode: how this (modified) block changed. `added` = a whole new block
794
+ * (strong green band, no inline rects); `modified` = a partial change (light
795
+ * band + inline rects on the changed words).
796
+ */
797
+ readonly diffKind?: 'added' | 'modified';
401
798
  }
402
799
 
403
800
  /**
@@ -454,7 +851,7 @@ declare class DocumentViewData {
454
851
  export declare class DocumentViewNode extends ViewNode {
455
852
  readonly blocks: readonly DocumentBlock[];
456
853
  /** The transient empty-paragraph element, when one is armed. */
457
- readonly pendingElement?: HTMLElement | undefined;
854
+ readonly pendingParagraph?: PendingParagraphViewNode | undefined;
458
855
  static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
459
856
  private constructor();
460
857
  /** The stable content element this document mounts its children into. */
@@ -476,6 +873,26 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
476
873
  readonly selection: Selection_2;
477
874
  } | undefined;
478
875
 
876
+ export declare type EditKeyboardAction = 'deleteLeft' | 'deleteRight' | 'deleteWordLeft' | 'deleteWordRight' | 'deleteLineLeft' | 'deleteLineRight';
877
+
878
+ export declare interface EditorCommandDefinition {
879
+ readonly id: `markdown.editor.${string}`;
880
+ readonly title: string;
881
+ readonly action: EditorKeyboardAction;
882
+ readonly keybindings: readonly EditorCommandKeybinding[];
883
+ /**
884
+ * Local commands must execute synchronously in the webview instead of being
885
+ * forwarded through the VS Code keybinding service.
886
+ */
887
+ readonly routing?: 'host' | 'local';
888
+ }
889
+
890
+ export declare interface EditorCommandKeybinding {
891
+ readonly key: string;
892
+ readonly modifiers?: KeyboardModifiers;
893
+ readonly platforms?: readonly KeyboardPlatform[];
894
+ }
895
+
479
896
  /**
480
897
  * Translates raw browser input (mouse, keyboard, EditContext) into model
481
898
  * mutations. Knows about DOM event types but never reads/writes the DOM
@@ -484,19 +901,45 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
484
901
  *
485
902
  * Owns the only non-derivable controller state:
486
903
  * - `_desiredColumn` — sticky column for up/down navigation
904
+ * - `_clickCount` / `_lastPointerDown` — multi-click detection for pointer
905
+ * input, since `pointerdown` events (unlike `mousedown`) don't populate
906
+ * `detail` with a click count.
487
907
  */
488
908
  export declare class EditorController extends Disposable {
489
909
  private readonly _model;
490
910
  private readonly _view;
911
+ readonly findController: FindController | undefined;
491
912
  private _desiredColumn;
913
+ private readonly _keyboardPlatform;
914
+ private readonly _keyboardProfile;
915
+ private readonly _forwardedKeyboardProfile;
916
+ private readonly _historyStrategy;
917
+ private readonly _indentation;
918
+ private readonly _tabFocusStatus;
919
+ private _tabMovesFocus;
920
+ /** Indentation copied by the most recent fenced-code Enter, while still untouched. */
921
+ private _generatedIndentation;
922
+ /** Running click count for the current multi-click sequence (1, 2, 3, …). */
923
+ private _clickCount;
924
+ /** Timestamp and position of the previous pointer-down, for multi-click detection. */
925
+ private _lastPointerDown;
492
926
  constructor(_model: EditorModel, _view: EditorView, options?: EditorControllerOptions);
493
927
  private readonly _handleTextUpdate;
494
- private readonly _handleMouseDown;
928
+ private _insertText;
929
+ private _remainingGeneratedIndentation;
930
+ /** Handle typed, pasted, or command-generated text while a paragraph is pending. */
931
+ private _handlePendingInput;
932
+ private _deletePendingText;
933
+ private readonly _handlePointerDown;
495
934
  private _makeCursorContext;
496
935
  private _makeVisualCursorContext;
497
936
  private _executeCursorCommand;
498
937
  private _executeEditCommand;
938
+ private _runUndoableEdit;
499
939
  private _executeVisualCursorCommand;
940
+ private _cursorDown;
941
+ private _setUserSelection;
942
+ private _applyCursorPosition;
500
943
  /** Move the cursor down one visual line (Arrow Down). */
501
944
  cursorDown(extend?: boolean): void;
502
945
  /** Move the cursor up one visual line (Arrow Up). */
@@ -504,12 +947,34 @@ export declare class EditorController extends Disposable {
504
947
  private _selectedText;
505
948
  private readonly _updateModifierState;
506
949
  private readonly _clearModifierState;
950
+ /**
951
+ * Drop any native DOM selection over the rendered text.
952
+ *
953
+ * The editor paints selection from `model.selection`, so a browser
954
+ * selection there is always spurious: nothing reads it (copy/cut read the
955
+ * model, hit-testing uses the measured layout) and nothing clears it, so it
956
+ * lingers as a second highlight even after the caret moves away.
957
+ * {@link isCaretMotionKey} stops the common source synchronously; this is
958
+ * the backstop for the rest of the browser's editing commands, which are
959
+ * platform- and version-specific and cannot be enumerated (Shift+PageDown
960
+ * and macOS Shift+Ctrl+B both reach one today).
961
+ *
962
+ * Scoped twice so it only ever discards selections the editor owns: the
963
+ * range must touch the rendered text (overlays such as comment widgets sit
964
+ * beside it and stay selectable), and input focus must still be inside this
965
+ * editor (so a host find-in-page, which selects while its own input is
966
+ * focused, is left alone).
967
+ */
968
+ private readonly _discardNativeSelection;
507
969
  private readonly _handleKeyDown;
970
+ executeCommand(command: EditorCommandDefinition): void;
971
+ private _executeKeyboardAction;
508
972
  /**
509
973
  * Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
510
974
  * arms a transient empty paragraph when at the end of a paragraph.
511
975
  */
512
976
  private _smartEnter;
977
+ private _registerTabFocusAccessibility;
513
978
  }
514
979
 
515
980
  /** Options for an {@link EditorController}. */
@@ -520,10 +985,79 @@ export declare interface EditorControllerOptions {
520
985
  * strategy (e.g. `AsyncClipboardStrategy`) in hosts that swallow them.
521
986
  */
522
987
  readonly clipboardStrategy?: IClipboardStrategy;
988
+ /**
989
+ * Where undo and redo are executed: `LocalHistoryStrategy` for a
990
+ * self-contained editor, or a strategy that forwards to the host's own
991
+ * document history. Left unset, the chords are passed on to the host.
992
+ */
993
+ readonly historyStrategy?: IHistoryStrategy;
994
+ readonly keyboardPlatform?: KeyboardPlatform;
995
+ readonly keyboardProfile?: KeyboardProfile;
996
+ /**
997
+ * Bindings owned by the host. Matching events have their browser default
998
+ * suppressed but continue propagating so the host keybinding service sees them.
999
+ */
1000
+ readonly forwardedKeyboardProfile?: KeyboardProfile;
1001
+ /** Tab-stop settings used outside semantic list indentation. */
1002
+ readonly indentation?: IndentationConfig;
1003
+ readonly find?: false;
523
1004
  }
524
1005
 
1006
+ /**
1007
+ * The editor overlay's local CSS-pixel coordinate space.
1008
+ *
1009
+ * Browser geometry and pointer APIs expose viewport client coordinates. This
1010
+ * boundary converts them immediately into the coordinate system shared by the
1011
+ * editor content and its overlays. Range rectangles are axis-aligned, so the
1012
+ * current implementation deliberately supports positive axis-aligned scale and
1013
+ * translation only.
1014
+ */
1015
+ export declare class EditorCoordinateSpace {
1016
+ private readonly _getLocalToClientMatrix;
1017
+ static forSvgOverlay(overlay: SVGSVGElement): EditorCoordinateSpace;
1018
+ private constructor();
1019
+ capture(): EditorCoordinateTransform;
1020
+ }
1021
+
1022
+ /** A stable coordinate conversion captured for one measurement operation. */
1023
+ export declare class EditorCoordinateTransform {
1024
+ private readonly _localToClient;
1025
+ private readonly _clientToLocal;
1026
+ constructor(_localToClient: DOMMatrix);
1027
+ toLocalPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
1028
+ toClientPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
1029
+ toLocalRect(rect: Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>): Rect2D;
1030
+ toClientRect(rect: Pick<Rect2D, 'left' | 'top' | 'width' | 'height'>): Rect2D;
1031
+ private _convertRect;
1032
+ }
1033
+
1034
+ export declare type EditorKeyboardAction = {
1035
+ readonly kind: 'cursor';
1036
+ readonly command: CursorKeyboardAction;
1037
+ readonly extend: boolean;
1038
+ } | {
1039
+ readonly kind: 'edit';
1040
+ readonly command: EditKeyboardAction;
1041
+ } | {
1042
+ readonly kind: 'history';
1043
+ readonly command: HistoryKeyboardAction;
1044
+ } | {
1045
+ readonly kind: 'tab';
1046
+ readonly command: TabKeyboardAction;
1047
+ } | {
1048
+ readonly kind: 'toggleTabFocus';
1049
+ } | {
1050
+ readonly kind: 'selectAll';
1051
+ } | {
1052
+ readonly kind: 'enter';
1053
+ readonly command: 'smartEnter' | 'insertParagraph' | 'insertHardLineBreak';
1054
+ };
1055
+
525
1056
  export declare class EditorModel {
526
1057
  private readonly _parser;
1058
+ private readonly _sourceEditListeners;
1059
+ private readonly _sourceTextIds;
1060
+ private _lastSourceTextId;
527
1061
  /**
528
1062
  * The most recent edit applied to {@link sourceText}, used by
529
1063
  * {@link document} to let the parser link incrementally edited code
@@ -532,11 +1066,24 @@ export declare class EditorModel {
532
1066
  */
533
1067
  private _pendingEdit;
534
1068
  readonly sourceText: ISettableObservable<StringValue, void>;
1069
+ readonly wordNavigationConfig: ISettableObservable<WordNavigationConfig, void>;
1070
+ /**
1071
+ * Read-only mode. When `true`, the editor never reveals a block's source
1072
+ * markers (markdown special characters like `**`, `#`, list bullets, code
1073
+ * fences, `$…$`) — every block stays in its clean rendered form regardless of
1074
+ * where the caret/selection is — and text-editing commands are ignored.
1075
+ * Explicit interactions with rendered controls, such as task checkboxes,
1076
+ * remain available. Plain text selection still works everywhere (so the user
1077
+ * can copy). The default (`false`) is the normal editing mode where the active
1078
+ * block reveals its markers.
1079
+ */
1080
+ readonly readonlyMode: ISettableObservable<boolean, void>;
535
1081
  /**
536
1082
  * The current selection, or `undefined` when the editor has no caret
537
1083
  * (e.g. an inactive/unfocused rendering).
538
1084
  */
539
1085
  readonly selection: ISettableObservable<Selection_2 | undefined, void>;
1086
+ readonly selectionSource: ISettableObservable<SelectionSource, void>;
540
1087
  /**
541
1088
  * Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
542
1089
  * live keyboard state; the view reads it to show the link-open affordance
@@ -544,6 +1091,14 @@ export declare class EditorModel {
544
1091
  * whose block is active.
545
1092
  */
546
1093
  readonly ctrlOrMetaDown: ISettableObservable<boolean, void>;
1094
+ /**
1095
+ * Whether a pointer-driven selection drag is currently in progress. Set by
1096
+ * the controller between the pointer-down that starts the drag and the
1097
+ * pointer-up/cancel that ends it. Contributions read it to defer UI that
1098
+ * would otherwise flicker mid-drag (e.g. the comment input box appears only
1099
+ * once the drag ends).
1100
+ */
1101
+ readonly isSelecting: ISettableObservable<boolean, void>;
547
1102
  /**
548
1103
  * Gutter markers (source-control style change indicators) painted in the
549
1104
  * left gutter. Each entry maps a source {@link OffsetRange} to a change kind
@@ -563,16 +1118,17 @@ export declare class EditorModel {
563
1118
  * The transient empty-paragraph editing state, or `undefined` when none is
564
1119
  * armed. See {@link PendingParagraph}. This is *not* document data — it is
565
1120
  * cleared by any source edit and lives only between the Enter that armed it
566
- * and the next keystroke.
1121
+ * and the next content-producing edit.
567
1122
  */
568
1123
  readonly pendingParagraph: ISettableObservable<PendingParagraph | undefined, void>;
569
1124
  readonly cursorOffset: IObservableWithChange<number | undefined, void>;
1125
+ readonly cursorPosition: IObservableWithChange<CursorPosition | undefined, void>;
570
1126
  /**
571
1127
  * The parsed document. Threads the previous document into the parser so
572
1128
  * unchanged blocks keep their object identity across reparses (see
573
1129
  * {@link MarkdownParser.parse}). Writing `previous` inside the compute is
574
- * a safe optimization: `derived` only recomputes when `sourceText`
575
- * changes, and the result is structurally identical to a full reparse.
1130
+ * safe: unchanged source reuses it directly, while changed source produces
1131
+ * a result structurally identical to a full reparse.
576
1132
  */
577
1133
  readonly document: IObservableWithChange<DocumentAstNode, void>;
578
1134
  /**
@@ -589,28 +1145,62 @@ export declare class EditorModel {
589
1145
  * collapsed this is a one-element set holding {@link activeBlock}.
590
1146
  */
591
1147
  readonly activeBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1148
+ /**
1149
+ * The baseline document to diff against. When set, the editor renders in
1150
+ * diff mode: the modified document ({@link document}) stays editable, while
1151
+ * the baseline's removed/changed blocks are shown as read-only decorations.
1152
+ * `undefined` (the default) renders normally.
1153
+ */
1154
+ readonly baseline: ISettableObservable<StringValue | undefined, void>;
1155
+ private readonly _baselineDocument;
1156
+ /**
1157
+ * The diff of {@link baseline} → {@link document}, or `undefined` when no
1158
+ * baseline is set. The view renders the {@link DiffItem}s as stacked
1159
+ * decorations; `insertedRanges` (modified-side change spans) drive the green
1160
+ * word-level highlight.
1161
+ */
1162
+ readonly diff: IObservableWithChange< {
1163
+ items: DiffItem[];
1164
+ insertedRanges: OffsetRange[];
1165
+ changedBlocks: Set<BlockAstNode>;
1166
+ } | undefined, void>;
1167
+ readonly markerVisibleBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
1168
+ onWillApplySourceEdit(listener: (event: SourceEditEvent) => void): IDisposable;
1169
+ /** Returns a stable per-object identity without retaining the source text. */
1170
+ getSourceTextId(sourceText: StringValue): number;
592
1171
  /**
593
1172
  * Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
594
1173
  * AST node for it, and park the caret at the gap start. No source edit is
595
1174
  * applied — the blank line exists only in the view until it is materialized.
596
1175
  */
597
- armPendingParagraph(req: {
598
- anchorBlock: BlockAstNode;
599
- replaceRange: OffsetRange;
600
- atEof: boolean;
601
- }): void;
1176
+ armPendingParagraph(req: Omit<PendingParagraph, 'syntheticAst' | 'cursorLine' | 'text'>): void;
602
1177
  /** Discard the pending paragraph (if any) without touching the source. */
603
1178
  cancelPendingParagraph(): void;
1179
+ /**
1180
+ * Replace the source with an authoritative value from the host, mapping the
1181
+ * selection through the changed span and atomically discarding transient
1182
+ * state anchored to the previous parse.
1183
+ */
1184
+ replaceSourceText(text: StringValue): void;
1185
+ /** Replace the transient horizontal whitespace on the pending line. */
1186
+ setPendingParagraphText(text: string): void;
604
1187
  /**
605
1188
  * Turn the pending paragraph into real source: rewrite its gap so the typed
606
- * `text` becomes its own paragraph, separated from its neighbours by blank
607
- * lines, and place the caret after the inserted text.
1189
+ * text, including any transient indentation, is separated from its neighbours
1190
+ * by blank lines, and place the caret after it.
608
1191
  */
609
1192
  materializePendingParagraph(text: string): void;
610
- applyEdit(edit: StringEdit): void;
1193
+ /** Sets a rendered task checkbox state in either editing or read-only mode. */
1194
+ setTaskCheckboxChecked(item: ListItemAstNode, checked: boolean): void;
1195
+ applyEdit(edit: StringEdit, selection?: Selection_2): void;
611
1196
  applyEditForSelection(edit: StringEdit): void;
1197
+ private _applySourceEdit;
1198
+ private _identifySourceEdit;
1199
+ private _emitWillApplySourceEdit;
612
1200
  }
613
1201
 
1202
+ export declare type EditorOverlayPosition = 'top-chrome' | 'below-selection' | 'above-decorations';
1203
+
614
1204
  /**
615
1205
  * Pure-render view of an {@link EditorModel}.
616
1206
  *
@@ -640,6 +1230,8 @@ export declare class EditorView extends Disposable {
640
1230
  readonly element: HTMLElement;
641
1231
  readonly editContext: EditContext;
642
1232
  readonly measuredLayout: MeasuredLayoutModel;
1233
+ readonly coordinateSpace: EditorCoordinateSpace;
1234
+ readonly forcedMarkerVisibleBlocks: ISettableObservable<ReadonlySet<BlockAstNode>, void>;
643
1235
  /**
644
1236
  * Inner container that holds the rendered document and the cursor/selection
645
1237
  * overlays. The outer {@link element} spans the full width; this container
@@ -647,9 +1239,17 @@ export declare class EditorView extends Disposable {
647
1239
  * to their parent's box) stay aligned with the content.
648
1240
  */
649
1241
  private readonly _contentContainer;
1242
+ private readonly _resizeObserver;
650
1243
  private readonly _cursorView;
651
1244
  private readonly _selectionView;
652
1245
  private readonly _gutterMarkersView;
1246
+ private readonly _diffHighlightsView;
1247
+ private _readonlyToggleButton;
1248
+ private readonly _editContextSuspensions;
1249
+ private readonly _revealOcclusions;
1250
+ private _caretRevealRaf;
1251
+ private _followedCaretBlock;
1252
+ private _followCaretAfterEdit;
653
1253
  /**
654
1254
  * The mounted block sequence, in source order. Rebuilt (not mutated) each
655
1255
  * frame by {@link DocumentViewNode.create}; the view just swaps one
@@ -657,8 +1257,11 @@ export declare class EditorView extends Disposable {
657
1257
  * (those go through the measured-layout model).
658
1258
  */
659
1259
  private readonly _document;
1260
+ private readonly _embeddedCodeEditorFactoryVersion;
660
1261
  /** The current view-node tree (AST overlaid with rendered DOM), for debugging. */
661
1262
  get documentViewNode(): IObservable<DocumentViewNode | undefined>;
1263
+ /** Re-resolves embedded code editors while preserving the surrounding editor view. */
1264
+ refreshEmbeddedCodeEditors(): void;
662
1265
  /**
663
1266
  * Last frame's view-data overlay, threaded back into
664
1267
  * {@link buildDocumentViewData} so any subtree whose ast and selection flags
@@ -670,18 +1273,44 @@ export declare class EditorView extends Disposable {
670
1273
  private readonly _viewData;
671
1274
  get viewData(): IObservable<DocumentViewData | undefined>;
672
1275
  /**
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.
1276
+ * Whether the editor is genuinely focused: focus rests somewhere inside the
1277
+ * editor subtree *and* its window is focused. Mirrored onto the root as
1278
+ * `.md-focused`, which gates the painted caret the blinking cursor is only
1279
+ * shown while this is `true`, so it never blinks in an unfocused editor or
1280
+ * after the window loses focus. Only the caret's visibility is affected; the
1281
+ * logical selection and caret geometry ({@link caretRect}) are unchanged.
677
1282
  */
678
- private readonly _pendingCaretRect;
1283
+ private readonly _focused;
1284
+ get focused(): IObservable<boolean>;
679
1285
  /**
680
1286
  * The block cache projected for views (selection painting) that need to
681
1287
  * react to mount/unmount. Derived from {@link _document}, so it stays in
682
1288
  * lock-step without any manual bookkeeping.
683
1289
  */
684
1290
  private readonly _selectionBlocksObs;
1291
+ /**
1292
+ * The caret rect (zero width) at the selection's active end, in
1293
+ * {@link overlayContainer}-local coordinates, or `undefined` when there is no
1294
+ * caret. This is the same geometry the editor paints its cursor from, so
1295
+ * contributions (e.g. comment mode) can anchor an overlay to the active end of
1296
+ * the selection — where the user's cursor is — without re-deriving geometry.
1297
+ */
1298
+ private readonly _caretRect;
1299
+ get caretRect(): IObservable<Rect2D | undefined>;
1300
+ /**
1301
+ * The container that establishes the positioning context for the editor's
1302
+ * overlays (cursor, selection, gutter). Contributions mount their own
1303
+ * absolutely-positioned overlays here so they share the coordinate space of
1304
+ * {@link caretRect}.
1305
+ */
1306
+ get overlayContainer(): HTMLElement;
1307
+ /**
1308
+ * Selection-style rectangles covering `range`, in {@link overlayContainer}-
1309
+ * local coordinates — the same geometry the live selection paints. Exposed so
1310
+ * contributions (e.g. persistent comments) can highlight arbitrary ranges and
1311
+ * anchor overlays to them. Recomputes when the measured layout changes.
1312
+ */
1313
+ rangeRects(range: OffsetRange): IObservable<readonly SelectionRect[]>;
685
1314
  constructor(_model: EditorModel, _options?: EditorViewOptions | undefined);
686
1315
  /**
687
1316
  * Mirrors the model's live Ctrl/Cmd state onto the editor root as
@@ -690,13 +1319,105 @@ export declare class EditorView extends Disposable {
690
1319
  * a plain click, but an active link only opens with the modifier held.
691
1320
  */
692
1321
  private _setupModifierTracking;
1322
+ /**
1323
+ * Tracks whether the editor is genuinely focused and mirrors it onto the
1324
+ * root as `.md-focused` so CSS can gate the painted caret. "Focused" means
1325
+ * focus rests somewhere inside the editor subtree *and* the window itself is
1326
+ * focused; either condition failing (focus moving elsewhere, or the window
1327
+ * losing focus) hides the blinking caret while leaving the logical selection
1328
+ * and caret geometry intact.
1329
+ */
1330
+ private _setupFocusTracking;
1331
+ private _setupCaretScrollPadding;
1332
+ /**
1333
+ * Renders the edit/read-only mode toggle. It flips the model's
1334
+ * {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
1335
+ * in its clean rendered form (no markdown markers revealed) and edits are
1336
+ * ignored, while text selection still works. The control lives in a
1337
+ * zero-height *sticky* host inside the centered content container, so the
1338
+ * lock follows the content's right edge and remains pinned as the document
1339
+ * scrolls. The current mode is also mirrored onto the root as `.md-readonly`
1340
+ * for any CSS hooks.
1341
+ */
1342
+ private _setupReadonlyToggle;
1343
+ /** Draws attention to the mode toggle after text input is attempted while locked. */
1344
+ showReadonlyEditingAttempt(): void;
693
1345
  focus(): void;
1346
+ mountOverlay(element: HTMLElement | SVGSVGElement, position: EditorOverlayPosition): IDisposable;
1347
+ /** Registers floating editor chrome that should count as covering a range during reveal. */
1348
+ registerRevealOcclusion(element: Element): IDisposable;
1349
+ /**
1350
+ * Temporarily detaches the root {@link EditContext} while focus is inside
1351
+ * nested editor chrome. Chromium otherwise reclaims focus from non-text
1352
+ * controls inside the EditContext host, breaking keyboard access to controls
1353
+ * such as the find actions and read-only toggle.
1354
+ */
1355
+ suspendEditContextWhileFocused(element: HTMLElement): IDisposable;
1356
+ revealRangeInCenterIfOutsideViewport(range: OffsetRange, behavior?: ScrollBehavior): IDisposable;
1357
+ /**
1358
+ * Keeps the caret visible after an editor-driven text edit. The reveal is
1359
+ * deferred until the rebuilt document has been laid out and uses nearest-edge
1360
+ * scrolling so ordinary typing only moves the containing viewport as far as
1361
+ * needed. While this mode is active, a later resize of the same active block
1362
+ * also re-reveals the caret (for asynchronous code, math, or diagram layout).
1363
+ */
1364
+ revealCaretAfterEdit(): void;
1365
+ /** Keeps a keyboard-moved caret visible without enabling edit-resize following. */
1366
+ revealCaretAfterKeyboardNavigation(): void;
1367
+ /** Stops edit-driven caret following before pointer-based selection begins. */
1368
+ stopFollowingCaret(): void;
1369
+ /**
1370
+ * Samples the ambient focus state that decides whether taking focus on open
1371
+ * would steal it from an explicit user target: whether the window is focused
1372
+ * and whether focus is still unclaimed (no active element, or the `<body>`
1373
+ * fallback).
1374
+ */
1375
+ private _sampleAutoFocusEnvironment;
1376
+ /**
1377
+ * One-shot guarded focus attempt: focuses the editor only if doing so will
1378
+ * not steal focus from an explicit user target — the window must already be
1379
+ * focused and no other element may have claimed focus yet. Returns whether
1380
+ * focus was taken. A no-op for a background window or when the user has
1381
+ * already focused something else. {@link autoFocusOnOpen} builds the
1382
+ * open-time behavior on top of this primitive.
1383
+ */
1384
+ tryAutoFocus(): boolean;
1385
+ /**
1386
+ * Focuses the editor when it opens without ever stealing focus from an
1387
+ * explicit user target. Tries once immediately; if the window is not focused
1388
+ * yet — a common open-time race where the editor is mounted before the host
1389
+ * routes focus to its window — the guarded attempt is deferred to the next
1390
+ * time the window gains focus and re-evaluated then. The deferral is
1391
+ * one-shot, so a later, unrelated window refocus never grabs focus, and the
1392
+ * re-check still respects any target the user has claimed in the meantime.
1393
+ */
1394
+ autoFocusOnOpen(): void;
1395
+ /**
1396
+ * Own point→offset resolution. When `true` (the default),
1397
+ * {@link resolveOffsetFromPoint} ignores the platform DOM hit-test
1398
+ * (`caretPositionFromPoint`) and snaps the point to the nearest offset purely
1399
+ * from the rendered {@link VisualLineMap} geometry — picking the nearest
1400
+ * visual line by `y`, then the nearest offset on it by `x`. Because a table
1401
+ * row's cells share one horizontal line band, this makes the whole width of a
1402
+ * row resolve into that row (rather than only the cell boxes), with no visible
1403
+ * layout change. It also lets a drag keep extending toward off-viewport points
1404
+ * (e.g. the pointer leaving the window), which the platform hit-test cannot
1405
+ * resolve. Set to `false` to fall back to the platform DOM hit-test.
1406
+ */
1407
+ readonly geometricHitTest: ISettableObservable<boolean, void>;
694
1408
  /**
695
1409
  * Client coordinates → absolute source offset (any block). Used during
696
1410
  * drag to keep extending the selection even when the pointer leaves the
697
- * original block.
1411
+ * original block. Honours {@link geometricHitTest}.
698
1412
  */
699
1413
  resolveOffsetFromPoint(point: Point2D): SourceOffset | undefined;
1414
+ /**
1415
+ * Resolve table-cell hits that have no measurable text run. Empty cells map
1416
+ * from their own box instead of snapping to a neighboring cell; element-only
1417
+ * content (for example an inactive image) maps through the hit element's view
1418
+ * node. Text-bearing cells keep the normal pixel-precise line-map/DOM path.
1419
+ */
1420
+ private _resolveTableCellOffset;
700
1421
  /**
701
1422
  * Whether a client point falls on the rendered document content, as
702
1423
  * opposed to the surrounding editor padding (the green area). Uses DOM
@@ -706,6 +1427,14 @@ export declare class EditorView extends Disposable {
706
1427
  * have `pointer-events: none`, so the hit-test sees through them.
707
1428
  */
708
1429
  isPointInContent(point: Point2D): boolean;
1430
+ /**
1431
+ * Whether `range` intersects the rendered source text — the region whose
1432
+ * selection this editor paints itself from `model.selection`. This also
1433
+ * catches select-all ranges whose endpoints surround the rendered content.
1434
+ * Overlays anchored beside the text (comment widgets and the like) are *not*
1435
+ * part of it and keep their own native selection behaviour.
1436
+ */
1437
+ intersectsRenderedContent(range: Range): boolean;
709
1438
  private readonly _renderAutorun;
710
1439
  /** Current mounted blocks, or empty before the first render. */
711
1440
  private get _blocks();
@@ -715,6 +1444,25 @@ export declare class EditorView extends Disposable {
715
1444
  * is not read here, so there is no feedback loop into the render autorun.
716
1445
  */
717
1446
  private _publishMeasurements;
1447
+ /**
1448
+ * Paint the diff highlights via the CSS Custom Highlight API: green over the
1449
+ * inserted/changed modified ranges (mapped on the document's own DOM), and
1450
+ * red over each {@link DiffDecorationViewNode}'s deleted ranges (mapped on
1451
+ * the decoration's own subtree). No DOM is mutated, so reconciliation and
1452
+ * editing are unaffected.
1453
+ */
1454
+ private _paintDiff;
1455
+ private _clearDiff;
1456
+ private _syncEditContextAttachment;
1457
+ private _revealRange;
1458
+ private _revealTarget;
1459
+ private _scheduleCaretReveal;
1460
+ private _revealCaretNearest;
1461
+ private _revealCaretAfterActiveBlockResize;
1462
+ private _caretBlockAt;
1463
+ private _measurementAt;
1464
+ private _stopFollowingCaret;
1465
+ private _isRevealOccluded;
718
1466
  }
719
1467
 
720
1468
  export declare interface EditorViewOptions extends BlockViewOptions {
@@ -725,6 +1473,12 @@ export declare interface EditorViewOptions extends BlockViewOptions {
725
1473
  * only) unless a theme class is supplied.
726
1474
  */
727
1475
  readonly classNames?: readonly string[];
1476
+ /**
1477
+ * Whether to render the sticky edit/read-only toggle at the top-right edge
1478
+ * of the content. Defaults to `true`; set to `false` to omit it (e.g. in
1479
+ * fixtures that focus on selection rendering).
1480
+ */
1481
+ readonly showReadonlyToggle?: boolean;
728
1482
  /**
729
1483
  * Controls "limited width mode". The observable yields the maximum content
730
1484
  * width in pixels, or `undefined` to let the content fill the available
@@ -735,6 +1489,14 @@ export declare interface EditorViewOptions extends BlockViewOptions {
735
1489
  * root ({@link element}) always spans the full available width.
736
1490
  */
737
1491
  readonly limitedWidth?: IObservable<number | undefined>;
1492
+ /**
1493
+ * Diff mode only: render every read-only original decoration in active
1494
+ * (source) form, so even whole-block removals expose their markdown markers
1495
+ * as real text. Used by the diff-coverage fixture to verify that every
1496
+ * changed original character is rendered somewhere; off in normal use, where
1497
+ * whole removals show a clean solid band.
1498
+ */
1499
+ readonly diffDecorationsActive?: boolean;
738
1500
  }
739
1501
 
740
1502
  export declare class EmphasisAstNode extends AstNode {
@@ -754,6 +1516,111 @@ declare class EmphasisViewData {
754
1516
  constructor(ast: EmphasisAstNode, content: readonly AnyViewData[]);
755
1517
  }
756
1518
 
1519
+ export declare function escapeFindRegex(value: string): string;
1520
+
1521
+ export declare const FIND_MATCH_LIMIT = 19999;
1522
+
1523
+ export declare function findBlockAtOffset(doc: DocumentAstNode, offset: SourceOffset): BlockAstNode | undefined;
1524
+
1525
+ export declare class FindController extends Disposable {
1526
+ private readonly _editorModel;
1527
+ private readonly _view;
1528
+ private readonly _options;
1529
+ readonly model: FindModel;
1530
+ readonly widget: FindWidget;
1531
+ private readonly _selectionForScope;
1532
+ private _forcedMatch;
1533
+ private _selectedMatch;
1534
+ private _observedSourceTextId;
1535
+ private readonly _sourceEditTracker;
1536
+ private _revealRequest;
1537
+ constructor(_editorModel: EditorModel, _view: EditorView, _options: FindControllerOptions);
1538
+ private _setForcedMarkerVisibleBlocks;
1539
+ openAndFocus(): void;
1540
+ close(): void;
1541
+ private _handleKeyDown;
1542
+ private _cancelRevealRequest;
1543
+ private _findByKeyboard;
1544
+ private _querySeed;
1545
+ private _prepareSeed;
1546
+ private _selectedSingleLineText;
1547
+ private _toggleFindInSelection;
1548
+ }
1549
+
1550
+ export declare interface FindControllerOptions {
1551
+ readonly keyboardPlatform: KeyboardPlatform;
1552
+ }
1553
+
1554
+ export declare type FindDirection = 'next' | 'previous';
1555
+
1556
+ export declare class FindHighlightsView extends Disposable {
1557
+ private readonly _view;
1558
+ private readonly _matchesLayer;
1559
+ private readonly _currentLayer;
1560
+ private readonly _highlightRegistration;
1561
+ private readonly _resizeObserver;
1562
+ private readonly _resizeObservedElements;
1563
+ private _snapshot;
1564
+ private _paintRaf;
1565
+ constructor(_view: EditorView, findModel: FindModel);
1566
+ private _schedulePaint;
1567
+ private _paint;
1568
+ private _observeResizeAncestors;
1569
+ private _paintRanges;
1570
+ }
1571
+
1572
+ export declare interface FindMatchesResult {
1573
+ readonly matches: readonly OffsetRange[];
1574
+ readonly isCapped: boolean;
1575
+ }
1576
+
1577
+ export declare class FindModel extends Disposable {
1578
+ private readonly _editorModel;
1579
+ readonly isRevealed: ISettableObservable<boolean, void>;
1580
+ readonly searchString: ISettableObservable<string, void>;
1581
+ readonly isRegex: ISettableObservable<boolean, void>;
1582
+ readonly matchCase: ISettableObservable<boolean, void>;
1583
+ readonly wholeWord: ISettableObservable<boolean, void>;
1584
+ readonly searchScope: ISettableObservable<OffsetRange | undefined, void>;
1585
+ readonly currentMatch: ISettableObservable<OffsetRange | undefined, void>;
1586
+ readonly loop: ISettableObservable<boolean, void>;
1587
+ readonly searchResult: IObservableWithChange< {
1588
+ kind: "invalid";
1589
+ error: Error;
1590
+ pattern?: undefined;
1591
+ matches?: undefined;
1592
+ isCapped?: undefined;
1593
+ } | {
1594
+ kind: "valid";
1595
+ pattern: FindPattern;
1596
+ matches: readonly OffsetRange[];
1597
+ isCapped: boolean;
1598
+ error?: undefined;
1599
+ }, void>;
1600
+ readonly matchesCount: IObservableWithChange<number, void>;
1601
+ readonly isCapped: IObservableWithChange<boolean, void>;
1602
+ readonly currentMatchPosition: IObservableWithChange<number, void>;
1603
+ private _searchOrigin;
1604
+ private readonly _sourceEditTracker;
1605
+ private _pendingInitialDirection;
1606
+ constructor(_editorModel: EditorModel);
1607
+ reveal(options: {
1608
+ readonly origin: number;
1609
+ readonly searchString?: string;
1610
+ readonly direction?: FindDirection;
1611
+ }): void;
1612
+ hide(): void;
1613
+ setSearchOrigin(offset: number): void;
1614
+ setSearchScope(scope: OffsetRange | undefined): void;
1615
+ moveToNextMatch(): OffsetRange | undefined;
1616
+ moveToPreviousMatch(): OffsetRange | undefined;
1617
+ private _move;
1618
+ private _selectFromOrigin;
1619
+ private _mapStateThroughEdit;
1620
+ private _inputSnapshot;
1621
+ private _readInputSnapshot;
1622
+ }
1623
+
757
1624
  /**
758
1625
  * Source offset (relative to `root`) of the node with `target`'s id, or
759
1626
  * `undefined` when it is not in the tree. Ids are stable across edits, so this
@@ -761,14 +1628,117 @@ declare class EmphasisViewData {
761
1628
  */
762
1629
  export declare function findNodeOffsetById(root: AstNode, target: AstNode): number | undefined;
763
1630
 
764
- export declare function findWordAt(text: string, offset: number): {
1631
+ export declare class FindPattern {
1632
+ private readonly _source;
1633
+ private readonly _flags;
1634
+ private readonly _wholeWord;
1635
+ private readonly _wordSeparators;
1636
+ readonly isEmpty: boolean;
1637
+ private constructor();
1638
+ static create(query: FindQuery): FindQueryResult;
1639
+ findMatches(text: string, scope?: OffsetRange, limit?: number): FindMatchesResult;
1640
+ findNextMatch(text: string, after: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1641
+ findPreviousMatch(text: string, before: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
1642
+ private _forEachMatch;
1643
+ }
1644
+
1645
+ export declare interface FindQuery {
1646
+ readonly searchString: string;
1647
+ readonly isRegex: boolean;
1648
+ readonly matchCase: boolean;
1649
+ readonly wholeWord: boolean;
1650
+ readonly wordSeparators: string;
1651
+ }
1652
+
1653
+ export declare type FindQueryResult = {
1654
+ readonly kind: 'valid';
1655
+ readonly pattern: FindPattern;
1656
+ } | {
1657
+ readonly kind: 'invalid';
1658
+ readonly error: Error;
1659
+ };
1660
+
1661
+ export declare type FindSearchResult = {
1662
+ readonly kind: 'valid';
1663
+ readonly pattern: FindPattern;
1664
+ readonly matches: readonly OffsetRange[];
1665
+ readonly isCapped: boolean;
1666
+ } | {
1667
+ readonly kind: 'invalid';
1668
+ readonly error: Error;
1669
+ };
1670
+
1671
+ export declare class FindWidget extends Disposable {
1672
+ private readonly _view;
1673
+ private readonly _options;
1674
+ readonly element: HTMLElement;
1675
+ readonly panelElement: HTMLElement;
1676
+ readonly focused: ISettableObservable<boolean, void>;
1677
+ private readonly _inputShell;
1678
+ private readonly _input;
1679
+ private readonly _matchesCount;
1680
+ private readonly _previousButton;
1681
+ private readonly _nextButton;
1682
+ private readonly _selectionButton;
1683
+ private readonly _caseButton;
1684
+ private readonly _wholeWordButton;
1685
+ private readonly _regexButton;
1686
+ private readonly _error;
1687
+ constructor(_view: EditorView, _options: FindWidgetOptions);
1688
+ focusAndSelect(): void;
1689
+ private _registerButton;
1690
+ private _render;
1691
+ }
1692
+
1693
+ export declare interface FindWidgetOptions {
1694
+ readonly findModel: FindModel;
1695
+ readonly canFindInSelection: IObservable<boolean>;
1696
+ readonly onNext: () => void;
1697
+ readonly onPrevious: () => void;
1698
+ readonly onToggleFindInSelection: () => void;
1699
+ readonly onClose: () => void;
1700
+ }
1701
+
1702
+ export declare function findWordAt(text: string, offset: number, config?: WordNavigationConfig): {
765
1703
  start: number;
766
1704
  end: number;
767
1705
  };
768
1706
 
769
- export declare function findWordBoundaryLeft(text: string, offset: number): number;
1707
+ export declare function findWordBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
770
1708
 
771
- export declare function findWordBoundaryRight(text: string, offset: number): number;
1709
+ export declare function findWordBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
1710
+
1711
+ export declare function findWordDeleteBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
1712
+
1713
+ export declare function findWordDeleteBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
1714
+
1715
+ /**
1716
+ * A leading YAML front matter block. The YAML value is intentionally opaque:
1717
+ * only the two fences and the exact source between them are modeled.
1718
+ */
1719
+ export declare class FrontMatterAstNode extends BlockAstNodeBase {
1720
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
1721
+ readonly leadingTrivia?: GlueAstNode | undefined;
1722
+ readonly kind = "frontMatter";
1723
+ constructor(content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
1724
+ get children(): readonly AstNode[];
1725
+ get openFence(): MarkerAstNode | undefined;
1726
+ get closeFence(): MarkerAstNode | undefined;
1727
+ get value(): MarkerAstNode | undefined;
1728
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
1729
+ withLeadingTrivia(trivia: GlueAstNode | undefined): FrontMatterAstNode;
1730
+ }
1731
+
1732
+ declare class FrontMatterViewData {
1733
+ readonly ast: FrontMatterAstNode;
1734
+ /** Active: render both fences; inactive: render only the opaque YAML value. */
1735
+ readonly showMarkup: boolean;
1736
+ readonly content: readonly AnyViewData[];
1737
+ readonly kind = "frontMatter";
1738
+ constructor(ast: FrontMatterAstNode,
1739
+ /** Active: render both fences; inactive: render only the opaque YAML value. */
1740
+ showMarkup: boolean, content: readonly AnyViewData[]);
1741
+ }
772
1742
 
773
1743
  export declare function getAnnotatedSource(node: AstNode, source: string, offset?: number): string;
774
1744
 
@@ -845,6 +1815,19 @@ declare class HeadingViewData {
845
1815
  constructor(ast: HeadingAstNode, content: readonly AnyViewData[]);
846
1816
  }
847
1817
 
1818
+ export declare function hiddenCursorRanges(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number): readonly OffsetRange[];
1819
+
1820
+ export declare type HistoryKeyboardAction = 'undo' | 'redo';
1821
+
1822
+ /** A block HTML comment, discriminated by whether its closing delimiter is present. */
1823
+ declare type HtmlCommentSource = OpenHtmlCommentSource | CompleteHtmlCommentSource;
1824
+
1825
+ declare interface HtmlCommentSourceBase {
1826
+ readonly leadingWhitespace: string;
1827
+ readonly opening: '<!--';
1828
+ readonly body: string;
1829
+ }
1830
+
848
1831
  /**
849
1832
  * The editor operations a clipboard strategy drives. The strategy never
850
1833
  * touches the model or the DOM directly — it asks through this seam, so the
@@ -890,6 +1873,87 @@ 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;
1944
+ }
1945
+
1946
+ export declare interface ILinkPresentation extends IDisposable {
1947
+ /** Current presentation, updated without rebuilding the editor. */
1948
+ readonly presentation: IObservable<LinkPresentation | undefined>;
1949
+ }
1950
+
1951
+ export declare interface ILinkPresentationProvider {
1952
+ /**
1953
+ * Returns `undefined` for unsupported links. The caller disposes the returned
1954
+ * reference when the rendered link disappears.
1955
+ */
1956
+ createLinkPresentation(url: string): ILinkPresentation | undefined;
893
1957
  }
894
1958
 
895
1959
  export declare class ImageAstNode extends AstNode {
@@ -926,6 +1990,14 @@ export declare interface IMonarchApi {
926
1990
  MonarchTokenizer: new (languageService: unknown, standaloneThemeService: unknown, languageId: string, lexer: unknown, configurationService: unknown) => MonarchTokenizer;
927
1991
  }
928
1992
 
1993
+ /** Controls tab-stop insertion and non-list line indentation. */
1994
+ export declare interface IndentationConfig {
1995
+ /** Number of visual columns between tab stops. */
1996
+ readonly tabSize: number;
1997
+ /** Whether indentation uses spaces instead of tab characters. */
1998
+ readonly insertSpaces: boolean;
1999
+ }
2000
+
929
2001
  export declare type InlineAstNode = TextAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode;
930
2002
 
931
2003
  export declare class InlineCodeAstNode extends AstNode {
@@ -980,17 +2052,27 @@ export declare const insertParagraph: EditCommand;
980
2052
  * - paragraph / heading / thematic break — the "rich text" thing: at the
981
2053
  * block's end arm a transient empty paragraph (see {@link SmartEnterResult});
982
2054
  * 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.
2055
+ * - fenced code / front matter — insert a newline that preserves the current
2056
+ * line's indentation, staying inside the fences.
985
2057
  * - block quote — continue the quote (`\n> `); an empty quote line exits it.
986
2058
  * - list — continue the list with the next marker (incrementing ordered
987
- * numbers, re-emitting task checkboxes); an empty item exits the list.
2059
+ * numbers, re-emitting task checkboxes); an empty item outdents one level
2060
+ * before exiting the list.
2061
+ * - complete HTML comment — at the comment's end, leave it by arming a
2062
+ * transient paragraph; inside it (or while the comment is open), insert a
2063
+ * normal source line break.
988
2064
  * A non-collapsed selection, or any other block, falls back to a plain soft line
989
2065
  * break, preserving today's behaviour.
990
2066
  */
991
2067
  export declare const insertSmartEnter: (ctx: CursorCommandContext) => SmartEnterResult;
992
2068
 
993
- export declare function insertText(text: string): EditCommand;
2069
+ /**
2070
+ * VS Code-style Tab: insert to the next tab stop for a caret or partial
2071
+ * single-line selection, and indent every selected line for a line selection.
2072
+ */
2073
+ export declare function insertTab(config?: IndentationConfig): EditCommand;
2074
+
2075
+ export declare function insertText(text: string, generatedIndentation?: OffsetRange): EditCommand;
994
2076
 
995
2077
  /**
996
2078
  * An immutable view of one document's tokens at a point in time. It may be a
@@ -1031,6 +2113,29 @@ export declare interface ISyntaxHighlighterDocument extends IDisposable {
1031
2113
  readonly snapshot: IObservableWithChange<ISyntaxHighlightedSnapshot, LengthEdit>;
1032
2114
  }
1033
2115
 
2116
+ export declare interface KeyboardBinding {
2117
+ readonly key: string;
2118
+ readonly modifiers?: KeyboardModifiers;
2119
+ readonly platforms?: readonly KeyboardPlatform[];
2120
+ readonly action: EditorKeyboardAction;
2121
+ }
2122
+
2123
+ export declare interface KeyboardModifiers {
2124
+ readonly shift?: boolean;
2125
+ readonly alt?: boolean;
2126
+ readonly ctrl?: boolean;
2127
+ readonly meta?: boolean;
2128
+ }
2129
+
2130
+ export declare type KeyboardPlatform = 'macos' | 'windows' | 'linux';
2131
+
2132
+ export declare interface KeyboardProfile {
2133
+ /**
2134
+ * Bindings in priority order. The first exact key/modifier/platform match wins.
2135
+ */
2136
+ readonly bindings: readonly KeyboardBinding[];
2137
+ }
2138
+
1034
2139
  declare abstract class LeafAstNode extends AstNode {
1035
2140
  abstract readonly content: string;
1036
2141
  get children(): readonly AstNode[];
@@ -1087,11 +2192,47 @@ export declare class LinkAstNode extends AstNode {
1087
2192
  protected _localEquals(o: this): boolean;
1088
2193
  }
1089
2194
 
2195
+ /**
2196
+ * Declarative rendering data for one link. `kind` selects the package-owned
2197
+ * visual treatment; providers never supply DOM or CSS.
2198
+ */
2199
+ export declare interface LinkPresentation {
2200
+ readonly kind: LinkPresentationKind;
2201
+ readonly title?: string;
2202
+ readonly detail?: string;
2203
+ readonly reference?: string;
2204
+ /** Primary resource state, such as pull-request lifecycle or session state. */
2205
+ readonly status?: LinkPresentationStatus;
2206
+ /** Secondary state, such as pull-request CI status. */
2207
+ readonly secondaryStatus?: LinkPresentationStatus;
2208
+ readonly changes?: LinkPresentationChanges;
2209
+ readonly tooltip?: string;
2210
+ readonly ariaLabel?: string;
2211
+ }
2212
+
2213
+ declare interface LinkPresentationChanges {
2214
+ readonly insertions: number;
2215
+ readonly deletions: number;
2216
+ }
2217
+
2218
+ export declare type LinkPresentationKind = 'resource' | 'issue' | 'pullRequest' | 'commit' | 'file' | 'folder' | 'session' | 'repository' | 'branch';
2219
+
2220
+ export declare interface LinkPresentationStatus {
2221
+ readonly kind: LinkPresentationStatusKind;
2222
+ readonly label: string;
2223
+ }
2224
+
2225
+ export declare type LinkPresentationStatusKind = 'neutral' | 'pending' | 'success' | 'warning' | 'error' | 'open' | 'closed' | 'merged' | 'draft' | 'notPlanned';
2226
+
1090
2227
  declare class LinkViewData {
1091
2228
  readonly ast: LinkAstNode;
2229
+ /** Active: render the Markdown source; inactive: allow a rich presentation. */
2230
+ readonly showMarkup: boolean;
1092
2231
  readonly content: readonly AnyViewData[];
1093
2232
  readonly kind = "link";
1094
- constructor(ast: LinkAstNode, content: readonly AnyViewData[]);
2233
+ constructor(ast: LinkAstNode,
2234
+ /** Active: render the Markdown source; inactive: allow a rich presentation. */
2235
+ showMarkup: boolean, content: readonly AnyViewData[]);
1095
2236
  }
1096
2237
 
1097
2238
  export declare class ListAstNode extends BlockAstNodeBase {
@@ -1128,12 +2269,26 @@ declare class ListItemViewData {
1128
2269
  readonly content: readonly AnyViewData[];
1129
2270
  /** 1-based list nesting depth, used to size the indentation gutter. */
1130
2271
  readonly level: number;
2272
+ /**
2273
+ * Whether this is an inactive task item whose first paragraph begins
2274
+ * with the `:running:` marker (see {@link TextViewData.hiddenPrefixLength}).
2275
+ * Always `false` while the item is active — an active/editing task
2276
+ * reveals the literal marker instead of the progress affordance.
2277
+ */
2278
+ readonly isRunning: boolean;
1131
2279
  readonly kind = "listItem";
1132
2280
  constructor(ast: ListItemAstNode,
1133
2281
  /** Whether the selection reaches this item (reveals its markers). */
1134
2282
  isActive: boolean, content: readonly AnyViewData[],
1135
2283
  /** 1-based list nesting depth, used to size the indentation gutter. */
1136
- level: number);
2284
+ level: number,
2285
+ /**
2286
+ * Whether this is an inactive task item whose first paragraph begins
2287
+ * with the `:running:` marker (see {@link TextViewData.hiddenPrefixLength}).
2288
+ * Always `false` while the item is active — an active/editing task
2289
+ * reveals the literal marker instead of the progress affordance.
2290
+ */
2291
+ isRunning?: boolean);
1137
2292
  }
1138
2293
 
1139
2294
  declare class ListViewData {
@@ -1143,6 +2298,32 @@ declare class ListViewData {
1143
2298
  constructor(ast: ListAstNode, content: readonly AnyViewData[]);
1144
2299
  }
1145
2300
 
2301
+ /**
2302
+ * Compact in-memory history for editors that hold the only copy of the
2303
+ * document, such as a standalone browser page. Where the surrounding host
2304
+ * already records history — a VS Code `TextDocument` — forward to that
2305
+ * instead.
2306
+ */
2307
+ export declare class LocalHistoryStrategy implements IHistoryStrategy {
2308
+ private readonly _model;
2309
+ private readonly _past;
2310
+ private readonly _future;
2311
+ /**
2312
+ * The source text as of the last change this strategy recorded or applied.
2313
+ * Any other value means the document was replaced behind its back, so the
2314
+ * stored edits no longer line up and must be discarded rather than applied.
2315
+ */
2316
+ private _lastKnownText;
2317
+ constructor(_model: EditorModel);
2318
+ record(operation: () => void, edit?: StringEdit): void;
2319
+ undo(): void;
2320
+ redo(): void;
2321
+ /** The entry on top of `stack`, or `undefined` when it cannot be applied. */
2322
+ private _peekApplicable;
2323
+ private _apply;
2324
+ private _clear;
2325
+ }
2326
+
1146
2327
  /**
1147
2328
  * Parses markdown into a {@link DocumentAstNode}.
1148
2329
  *
@@ -1249,8 +2430,8 @@ export declare class MeasuredLayoutDebugRendering {
1249
2430
  * Exposes two DOM nodes the caller can place independently:
1250
2431
  *
1251
2432
  * - {@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.
2433
+ * inside the editor overlay container so dashed line-bands and run-boxes
2434
+ * share the measured editor-local coordinates.
1254
2435
  * - {@link infoElement} — block-flow; the caller mounts it as a sibling
1255
2436
  * *below* the editor. Contains the per-block summary table that used
1256
2437
  * to live on the overlay.
@@ -1261,7 +2442,6 @@ export declare class MeasuredLayoutDebugRendering {
1261
2442
  * the derived subscribed.
1262
2443
  */
1263
2444
  export declare class MeasuredLayoutDebugView extends Disposable {
1264
- private readonly _overlayParent;
1265
2445
  readonly overlayElement: HTMLElement;
1266
2446
  readonly infoElement: HTMLElement;
1267
2447
  readonly rendering: IObservable<MeasuredLayoutDebugRendering>;
@@ -1274,6 +2454,7 @@ export declare class MeasuredLayoutDebugView extends Disposable {
1274
2454
 
1275
2455
  export declare interface MeasuredLayoutDebugViewOptions {
1276
2456
  readonly model: MeasuredLayoutModel;
2457
+ readonly coordinateSpace: EditorCoordinateSpace;
1277
2458
  /**
1278
2459
  * DEBUG ONLY. Maps an absolute source offset to a fill color for that
1279
2460
  * character's glyph rect. The fixture passes the same function to the
@@ -1306,14 +2487,16 @@ export declare interface MeasuredLayoutDebugViewOptions {
1306
2487
  * through this model and never touches view fields directly.
1307
2488
  */
1308
2489
  export declare class MeasuredLayoutModel {
1309
- readonly measurements: ISettableObservable<readonly BlockMeasurement[], void>;
2490
+ private readonly _measurements;
2491
+ readonly measurements: IObservable<readonly BlockMeasurement[]>;
2492
+ private readonly _virtualLines;
1310
2493
  /**
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.
2494
+ * Concatenated visual line map across all mounted blocks. Every per-block
2495
+ * map uses the same editor-local coordinate space, so concatenation is
2496
+ * well-formed without translation or re-sorting.
1315
2497
  */
1316
2498
  readonly visualLineMap: IObservableWithChange<VisualLineMap, void>;
2499
+ setMeasurements(measurements: readonly BlockMeasurement[], virtualLines: readonly VirtualLineMeasurement[]): void;
1317
2500
  }
1318
2501
 
1319
2502
  /**
@@ -1353,14 +2536,25 @@ export declare class NativeClipboardStrategy implements IClipboardStrategy {
1353
2536
  connect(context: IClipboardContext): IDisposable;
1354
2537
  }
1355
2538
 
2539
+ declare interface NestedItem {
2540
+ readonly kind: 'nested';
2541
+ readonly original: AstNode;
2542
+ readonly originalStart: number;
2543
+ readonly modified: AstNode;
2544
+ readonly modifiedStart: number;
2545
+ readonly children: readonly DiffItem[];
2546
+ }
2547
+
1356
2548
  /**
1357
2549
  * Move the cursor one position left or right, skipping over hidden marker
1358
2550
  * ranges in inactive blocks (and inactive items of an active list).
1359
2551
  */
1360
- export declare function nextCursorPosition(doc: DocumentAstNode, activeBlock: BlockAstNode | undefined, cursor: number, direction: 'left' | 'right'): number;
2552
+ export declare function nextCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, direction: 'left' | 'right'): number;
1361
2553
 
1362
2554
  declare const NO_ACTIVE_BLOCKS: unique symbol;
1363
2555
 
2556
+ export declare function normalizeCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, target: number, direction: 'left' | 'right', includeHiddenRangeBoundary?: boolean): number;
2557
+
1364
2558
  export declare class OffsetRange {
1365
2559
  readonly start: number;
1366
2560
  readonly endExclusive: number;
@@ -1388,6 +2582,14 @@ export declare class OffsetRange {
1388
2582
  toString(): string;
1389
2583
  }
1390
2584
 
2585
+ /** The lossless source slices of a block HTML comment whose closer has not been typed. */
2586
+ declare interface OpenHtmlCommentSource extends HtmlCommentSourceBase {
2587
+ readonly kind: 'open';
2588
+ }
2589
+
2590
+ /** Outdent the current line, or every line touched by the selection. */
2591
+ export declare function outdent(config?: IndentationConfig): EditCommand;
2592
+
1391
2593
  export declare class ParagraphAstNode extends BlockAstNodeBase {
1392
2594
  readonly content: readonly (InlineAstNode | GlueAstNode)[];
1393
2595
  readonly leadingTrivia?: GlueAstNode | undefined;
@@ -1406,23 +2608,32 @@ declare class ParagraphViewData {
1406
2608
  }
1407
2609
 
1408
2610
  /**
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).
2611
+ * A *transient* editing state: an empty paragraph adjacent to a real block.
2612
+ * Markdown has no empty-paragraph node, so this never lives in
2613
+ * {@link EditorModel['sourceText']} or the parsed {@link EditorModel.document}
2614
+ * — it is pure edit intent that the view renders as a synthetic blank line and
2615
+ * that the controller either *materializes* (the user types) or *cancels* (the
2616
+ * user navigates away / backspaces).
1415
2617
  */
1416
2618
  declare interface PendingParagraph {
1417
- /** The paragraph the blank line is rendered directly after. */
2619
+ /** The block the blank line is rendered directly after. */
1418
2620
  readonly anchorBlock: BlockAstNode;
1419
2621
  /**
1420
2622
  * Source region rewritten when the pending paragraph is materialized — the
1421
2623
  * gap between {@link anchorBlock}'s text and whatever follows it.
1422
2624
  */
1423
2625
  readonly replaceRange: OffsetRange;
2626
+ /** Whether materialized text needs a blank-line separator before it. */
2627
+ readonly separateFromPreviousBlock: boolean;
1424
2628
  /** Whether {@link replaceRange} ends at the end of the document. */
1425
2629
  readonly atEof: boolean;
2630
+ /**
2631
+ * Horizontal whitespace typed on the source-less line. It remains transient
2632
+ * until other input materializes the paragraph. Contains only spaces and tabs.
2633
+ */
2634
+ readonly text: string;
2635
+ /** The source-less visual line occupied by the pending caret. */
2636
+ readonly cursorLine: VirtualCursorLine;
1426
2637
  /**
1427
2638
  * A throwaway AST node that exists only to give the synthetic view child a
1428
2639
  * stable identity across render frames (the view pairs nodes by `ast.id`).
@@ -1431,21 +2642,51 @@ declare interface PendingParagraph {
1431
2642
  readonly syntheticAst: ParagraphAstNode;
1432
2643
  }
1433
2644
 
2645
+ declare interface PendingParagraphResult {
2646
+ readonly kind: 'pending';
2647
+ readonly anchorBlock: BlockAstNode;
2648
+ readonly replaceRange: OffsetRange;
2649
+ /** Whether materialized text needs a blank-line separator before it. */
2650
+ readonly separateFromPreviousBlock: boolean;
2651
+ readonly atEof: boolean;
2652
+ }
2653
+
1434
2654
  /**
1435
2655
  * View-data for the transient empty paragraph (see `PendingParagraph` in the
1436
- * 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.
2656
+ * model). It carries the throwaway {@link ParagraphAstNode} that gives the
2657
+ * rendered line a stable identity across frames, its anchor block, source-less
2658
+ * cursor line, and transient horizontal whitespace. It has no source content or
2659
+ * selection range.
1440
2660
  */
1441
2661
  declare class PendingParagraphViewData {
1442
2662
  readonly ast: ParagraphAstNode;
2663
+ readonly anchorBlock: BlockAstNode;
2664
+ readonly cursorLine: VirtualCursorLine;
2665
+ readonly text: string;
1443
2666
  readonly kind = "pendingParagraph";
1444
- constructor(ast: ParagraphAstNode);
2667
+ constructor(ast: ParagraphAstNode, anchorBlock: BlockAstNode, cursorLine: VirtualCursorLine, text: string);
2668
+ }
2669
+
2670
+ /**
2671
+ * The mounted transient empty paragraph: a `<p class="md-pending-paragraph">`
2672
+ * holding either a `<br>` or decorated transient horizontal whitespace. It is a
2673
+ * leaf view node with no inline source content; the document view publishes its
2674
+ * element geometry as a virtual visual line.
2675
+ */
2676
+ declare class PendingParagraphViewNode extends ViewNode {
2677
+ readonly element: HTMLElement;
2678
+ readonly anchorBlock: BlockAstNode;
2679
+ readonly cursorLine: VirtualCursorLine;
2680
+ private _text;
2681
+ constructor(view: PendingParagraphViewData);
2682
+ update(text: string): void;
2683
+ getCaretClientRect(): DOMRect;
1445
2684
  }
1446
2685
 
1447
2686
  /**
1448
- * Immutable point in 2D space, in CSS-pixel client coordinates.
2687
+ * Immutable point in a caller-defined 2D CSS-pixel coordinate space.
2688
+ * Coordinate-owning APIs must document whether values are viewport-client or
2689
+ * editor-local; values from different spaces must not be mixed.
1449
2690
  */
1450
2691
  export declare class Point2D {
1451
2692
  readonly x: number;
@@ -1456,8 +2697,8 @@ export declare class Point2D {
1456
2697
  }
1457
2698
 
1458
2699
  /**
1459
- * Immutable axis-aligned rectangle in 2D space, in CSS-pixel client
1460
- * coordinates. `x`/`y` is the top-left corner, growing right/down.
2700
+ * Immutable axis-aligned rectangle in a caller-defined 2D CSS-pixel coordinate
2701
+ * space. `x`/`y` is the top-left corner, growing right/down.
1461
2702
  *
1462
2703
  * Half-open in both dimensions: `right` and `bottom` are excluded.
1463
2704
  */
@@ -1483,6 +2724,48 @@ export declare class Rect2D {
1483
2724
  translate(dx: number, dy: number): Rect2D;
1484
2725
  }
1485
2726
 
2727
+ declare interface RemovedItem {
2728
+ readonly kind: 'removed';
2729
+ readonly node: AstNode;
2730
+ readonly originalStart: number;
2731
+ readonly deletedLocal: readonly AnnotatedRange[];
2732
+ }
2733
+
2734
+ declare interface ReplacedItem {
2735
+ readonly kind: 'replaced';
2736
+ readonly original: AstNode;
2737
+ readonly originalStart: number;
2738
+ readonly modified: AstNode;
2739
+ readonly modifiedStart: number;
2740
+ readonly insertedLocal: readonly AnnotatedRange[];
2741
+ readonly deletedLocal: readonly AnnotatedRange[];
2742
+ }
2743
+
2744
+ export declare class RichLink {
2745
+ static create(options: RichLinkOptions): RichLink;
2746
+ static mount(element: HTMLElement, authoredLabel: HTMLSpanElement): RichLink;
2747
+ static clear(element: HTMLElement): void;
2748
+ readonly element: HTMLElement;
2749
+ readonly authoredLabel: HTMLSpanElement;
2750
+ private readonly _icon;
2751
+ private readonly _title;
2752
+ private readonly _detail;
2753
+ private readonly _reference;
2754
+ private readonly _changes;
2755
+ private readonly _status;
2756
+ private readonly _secondaryStatus;
2757
+ private constructor();
2758
+ update(presentation: LinkPresentation | undefined): void;
2759
+ private _renderUnavailable;
2760
+ private _setDefaultOrder;
2761
+ }
2762
+
2763
+ export declare interface RichLinkOptions {
2764
+ readonly href: string;
2765
+ readonly authoredLabel: string;
2766
+ readonly presentation?: LinkPresentation;
2767
+ }
2768
+
1486
2769
  export declare const selectAll: SelectionCommand;
1487
2770
 
1488
2771
  export declare function selectBlock(ctx: CursorCommandContext, blockRange: OffsetRange): Selection_2;
@@ -1508,8 +2791,13 @@ export { Selection_2 as Selection }
1508
2791
  export declare interface SelectionBlock {
1509
2792
  readonly block: BlockAstNode;
1510
2793
  readonly absoluteStart: number;
1511
- readonly viewNode: ViewNode;
1512
- readonly element: HTMLElement;
2794
+ /** Block border box in editor-local coordinates. */
2795
+ readonly rect: Rect2D;
2796
+ /** Visible horizontal padding-box bounds for a scrolling block. */
2797
+ readonly viewportClip: {
2798
+ readonly left: number;
2799
+ readonly right: number;
2800
+ } | undefined;
1513
2801
  }
1514
2802
 
1515
2803
  export declare type SelectionCommand = (ctx: CursorCommandContext, offset: SourceOffset) => Selection_2;
@@ -1521,6 +2809,9 @@ export declare interface SelectionRect {
1521
2809
  readonly height: number;
1522
2810
  }
1523
2811
 
2812
+ /** The interaction that produced the current editor selection. */
2813
+ export declare type SelectionSource = 'user' | 'find';
2814
+
1524
2815
  /**
1525
2816
  * Owns the SVG overlay that paints the selection.
1526
2817
  *
@@ -1541,11 +2832,10 @@ export declare interface SelectionRect {
1541
2832
  * envelope shape used by IDE selection rendering.
1542
2833
  */
1543
2834
  export declare class SelectionView extends Disposable {
1544
- private readonly _parent;
1545
2835
  readonly element: SVGSVGElement;
1546
2836
  readonly rendering: IObservable<SelectionViewRendering>;
1547
2837
  private readonly _path;
1548
- constructor(_parent: HTMLElement, options: SelectionViewOptions);
2838
+ constructor(options: SelectionViewOptions);
1549
2839
  }
1550
2840
 
1551
2841
  export declare interface SelectionViewOptions {
@@ -1573,12 +2863,9 @@ export declare type SmartEnterResult = {
1573
2863
  readonly kind: 'edit';
1574
2864
  readonly edit: StringEdit;
1575
2865
  readonly selection: Selection_2;
1576
- } | {
1577
- readonly kind: 'pending';
1578
- readonly anchorBlock: BlockAstNode;
1579
- readonly replaceRange: OffsetRange;
1580
- readonly atEof: boolean;
1581
- };
2866
+ /** Post-edit range of indentation copied onto a new fenced-code line. */
2867
+ readonly generatedIndentation?: OffsetRange;
2868
+ } | PendingParagraphResult;
1582
2869
 
1583
2870
  /**
1584
2871
  * A run of {@link Token}s together with the exact {@link OffsetRange} they
@@ -1593,6 +2880,14 @@ export declare interface SnapshotTokens {
1593
2880
  readonly tokens: readonly Token[];
1594
2881
  }
1595
2882
 
2883
+ /** Metadata delivered synchronously immediately before a model-owned source edit is applied. */
2884
+ export declare interface SourceEditEvent {
2885
+ readonly baseSourceTextId: number;
2886
+ readonly resultSourceTextId: number;
2887
+ readonly edit: StringEdit;
2888
+ readonly transaction: ITransaction;
2889
+ }
2890
+
1596
2891
  export declare type SourceOffset = number;
1597
2892
 
1598
2893
  export declare class StrikethroughAstNode extends AstNode {
@@ -1637,6 +2932,11 @@ export declare class StringReplacement {
1637
2932
  constructor(replaceRange: OffsetRange, newText: string);
1638
2933
  get isEmpty(): boolean;
1639
2934
  equals(other: StringReplacement): boolean;
2935
+ /**
2936
+ * Narrows this replacement to the span that actually changes, by trimming
2937
+ * the prefix and suffix it shares with the text it replaces in `source`.
2938
+ */
2939
+ removeCommonSuffixPrefix(source: string): StringReplacement;
1640
2940
  toString(): string;
1641
2941
  }
1642
2942
 
@@ -1665,6 +2965,8 @@ declare class StrongViewData {
1665
2965
  constructor(ast: StrongAstNode, content: readonly AnyViewData[]);
1666
2966
  }
1667
2967
 
2968
+ export declare type TabKeyboardAction = 'insert' | 'outdent';
2969
+
1668
2970
  export declare class TableAstNode extends BlockAstNodeBase {
1669
2971
  readonly content: readonly (TableRowAstNode | GlueAstNode)[];
1670
2972
  readonly leadingTrivia?: GlueAstNode | undefined;
@@ -1747,6 +3049,13 @@ declare class TextViewData {
1747
3049
  readonly showWhitespace: boolean;
1748
3050
  readonly leftWordBoundary: boolean;
1749
3051
  readonly rightWordBoundary: boolean;
3052
+ /**
3053
+ * Number of leading source characters to keep out of the rendered
3054
+ * text (but not out of the source): the `:running:` marker plus its
3055
+ * mandatory leading separator, once
3056
+ * {@link isRunnerMarkerText} has matched this node. Zero otherwise.
3057
+ */
3058
+ readonly hiddenPrefixLength: number;
1750
3059
  readonly kind = "text";
1751
3060
  /**
1752
3061
  * Whether non-obvious whitespace in this text is revealed (block is active).
@@ -1755,7 +3064,14 @@ declare class TextViewData {
1755
3064
  * emphasis); a single space touching such a sibling is obvious and stays
1756
3065
  * undecorated, just like a space between two words within this leaf.
1757
3066
  */
1758
- constructor(ast: TextAstNode, showWhitespace: boolean, leftWordBoundary?: boolean, rightWordBoundary?: boolean);
3067
+ constructor(ast: TextAstNode, showWhitespace: boolean, leftWordBoundary?: boolean, rightWordBoundary?: boolean,
3068
+ /**
3069
+ * Number of leading source characters to keep out of the rendered
3070
+ * text (but not out of the source): the `:running:` marker plus its
3071
+ * mandatory leading separator, once
3072
+ * {@link isRunnerMarkerText} has matched this node. Zero otherwise.
3073
+ */
3074
+ hiddenPrefixLength?: number);
1759
3075
  }
1760
3076
 
1761
3077
  export declare class ThematicBreakAstNode extends BlockAstNodeBase {
@@ -1799,6 +3115,55 @@ export declare class Token {
1799
3115
  className: string | undefined);
1800
3116
  }
1801
3117
 
3118
+ declare interface UnchangedItem {
3119
+ readonly kind: 'unchanged';
3120
+ /** The modified-side node (identical in content to the original). */
3121
+ readonly node: AstNode;
3122
+ readonly modifiedStart: number;
3123
+ }
3124
+
3125
+ /**
3126
+ * A block whose token type the parser does not understand (a setext heading or
3127
+ * any future/extension construct). Rather than dropping the
3128
+ * span — which would demote its text to invisible glue — the parser captures the
3129
+ * whole source range verbatim as a single {@link MarkerAstNode} of kind
3130
+ * `content` and records the originating micromark {@link tokenType}, so the view
3131
+ * can render it as raw, editable text with an "unhandled" affordance. Offsets
3132
+ * stay sound: `content` tiles the block's full source span exactly.
3133
+ */
3134
+ declare class UnhandledBlockAstNode extends BlockAstNodeBase {
3135
+ readonly tokenType: string;
3136
+ readonly content: readonly (MarkerAstNode | GlueAstNode)[];
3137
+ readonly leadingTrivia?: GlueAstNode | undefined;
3138
+ readonly kind = "unhandledBlock";
3139
+ constructor(tokenType: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
3140
+ get children(): readonly AstNode[];
3141
+ get code(): MarkerAstNode | undefined;
3142
+ /**
3143
+ * Lossless slices when this raw HTML block starts one comment after optional
3144
+ * whitespace. An open comment consumes the remaining source as its body. A
3145
+ * complete comment permits only trailing whitespace after its closer.
3146
+ */
3147
+ get htmlComment(): HtmlCommentSource | undefined;
3148
+ mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
3149
+ withLeadingTrivia(trivia: GlueAstNode | undefined): UnhandledBlockAstNode;
3150
+ protected _localEquals(o: this): boolean;
3151
+ }
3152
+
3153
+ /**
3154
+ * View-data for an {@link UnhandledBlockAstNode}. The source remains verbatim
3155
+ * in both states. Complete HTML comments use {@link showMarkup} to switch
3156
+ * between their quiet reading treatment and editable source presentation;
3157
+ * other unhandled blocks ignore the flag and keep their warning treatment.
3158
+ */
3159
+ declare class UnhandledBlockViewData {
3160
+ readonly ast: UnhandledBlockAstNode;
3161
+ readonly showMarkup: boolean;
3162
+ readonly content: readonly AnyViewData[];
3163
+ readonly kind = "unhandledBlock";
3164
+ constructor(ast: UnhandledBlockAstNode, showMarkup: boolean, content: readonly AnyViewData[]);
3165
+ }
3166
+
1802
3167
  /**
1803
3168
  * Immutable view of an AST node. Pairs `ast` with its rendered `dom` and a
1804
3169
  * mirror of `ast.children` as ViewNode children. Source offsets are NEVER
@@ -1863,10 +3228,12 @@ export declare class ViewNode extends Disposable {
1863
3228
  /**
1864
3229
  * Map a DOM hit that lands on THIS node's own representation into a source
1865
3230
  * 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).
3231
+ * leaf maps the caret offset 1:1. For an element hit — an element-only node
3232
+ * (KaTeX math, `<hr>`, an image, a hidden marker) or a wrapper/container
3233
+ * element the platform reports a child-index offset, not a text caret, so
3234
+ * there is no internal mapping to honour: it snaps to the node's nearer
3235
+ * edge, `offset 0` (the "before" side) → start, any `offset >= 1` (the
3236
+ * "after" side) → end. Subclasses may override for finer control.
1870
3237
  */
1871
3238
  getLocalSourceRange(pos: DomPosition): OffsetRange;
1872
3239
  /**
@@ -1888,6 +3255,24 @@ export declare class ViewNode extends Disposable {
1888
3255
  forEachTextLeaf(nodeOffset: number, visitor: (leaf: ViewNode, leafOffset: number) => void): void;
1889
3256
  }
1890
3257
 
3258
+ /**
3259
+ * A visual cursor line that has no representation in the source text.
3260
+ *
3261
+ * The two source offsets are the positions immediately before and after the
3262
+ * virtual line. The object itself is the stable identity of the line.
3263
+ */
3264
+ export declare class VirtualCursorLine {
3265
+ readonly sourceOffsetBefore: SourceOffset;
3266
+ readonly sourceOffsetAfter: SourceOffset;
3267
+ constructor(sourceOffsetBefore: SourceOffset, sourceOffsetAfter: SourceOffset);
3268
+ }
3269
+
3270
+ /** A measured source-less line inserted directly after a source block. */
3271
+ declare interface VirtualLineMeasurement {
3272
+ readonly afterBlock: BlockAstNode;
3273
+ readonly line: VisualLine;
3274
+ }
3275
+
1891
3276
  export declare type VisualCursorCommand = (ctx: VisualCursorCommandContext) => CursorMoveResult;
1892
3277
 
1893
3278
  export declare interface VisualCursorCommandContext extends CursorCommandContext {
@@ -1905,12 +3290,15 @@ export declare function visualizeAst(root: AstNode, source: string): AstVisualiz
1905
3290
  export declare class VisualLine {
1906
3291
  readonly rect: Rect2D;
1907
3292
  readonly runs: readonly VisualRun[];
1908
- constructor(rect: Rect2D, runs: readonly VisualRun[]);
3293
+ readonly virtualCursorLine?: VirtualCursorLine | undefined;
3294
+ static virtual(cursorLine: VirtualCursorLine, rect: Rect2D): VisualLine;
3295
+ constructor(rect: Rect2D, runs: readonly VisualRun[], virtualCursorLine?: VirtualCursorLine | undefined);
1909
3296
  containsOffset(offset: SourceOffset): boolean;
1910
3297
  /**
1911
3298
  * How `offset` relates to this line's runs:
1912
3299
  * - `'covers'`: a run starts at or strictly contains the offset
1913
- * (`start <= offset < endExclusive`) the caret belongs on this line.
3300
+ * (`start <= offset < endExclusive`), or a zero-length visual-line
3301
+ * anchor sits at the offset — the caret belongs on this line.
1914
3302
  * - `'end'`: the offset is only some run's trailing boundary
1915
3303
  * (`offset === endExclusive`) with no run covering it — a line-break
1916
3304
  * boundary the caret should leave for the next line.
@@ -1923,23 +3311,42 @@ export declare class VisualLine {
1923
3311
  */
1924
3312
  sourceDistanceTo(offset: SourceOffset): number;
1925
3313
  /**
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.
3314
+ * x of the caret position before `offset` on this line.
3315
+ *
3316
+ * The runs tile the source but are stored in paint order, not sorted by
3317
+ * source offset (hidden-marker runs are appended last). So this scans all
3318
+ * runs rather than assuming any ordering:
3319
+ *
3320
+ * - A zero-source visual anchor owns its exact offset, so a marker-only line
3321
+ * wins over the preceding line's inclusive end boundary.
3322
+ * - Otherwise a run starting at `offset` owns that seam. This keeps an
3323
+ * out-of-flow prefix from placing the caret at its trailing edge when the
3324
+ * following body starts at a visually separate x.
3325
+ * - Otherwise, if some run *covers* `offset`, its own geometry places the
3326
+ * caret (exact glyph boundary for text runs). In the active,
3327
+ * markers-visible form every interior offset is covered, so this branch
3328
+ * keeps distinct offsets distinct.
3329
+ * - Otherwise `offset` sits in a gap — a hidden inline marker such as the
3330
+ * `**` of `**bold**`, or before/after the painted text. It snaps to the
3331
+ * seam between the source-nearest runs on either side: the right edge of
3332
+ * the closest run ending at/before `offset`, else the left edge of the
3333
+ * closest run starting at/after it. A hidden marker collapses to zero
3334
+ * width, so both edges coincide at the seam.
1930
3335
  */
1931
3336
  xAtOffset(offset: SourceOffset): number;
1932
3337
  /**
1933
3338
  * 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.
3339
+ * run, the run resolves the offset (exact glyph boundary for text runs,
3340
+ * nearer edge for source-less runs); otherwise it snaps to the closer
3341
+ * edge of the nearest run.
1936
3342
  */
1937
3343
  offsetAtX(x: number): SourceOffset;
1938
3344
  }
1939
3345
 
1940
3346
  /**
1941
3347
  * Geometry of the rendered document, as a map from source offsets to 2D
1942
- * positions and back.
3348
+ * positions and back. All geometry is expressed in the editor overlay's local
3349
+ * CSS-pixel coordinate space.
1943
3350
  *
1944
3351
  * Structure (top to bottom):
1945
3352
  *
@@ -1974,7 +3381,9 @@ export declare class VisualLineMap {
1974
3381
  static measure(blockViews: readonly {
1975
3382
  readonly absoluteStart: number;
1976
3383
  readonly viewNode: ViewNode;
1977
- }[]): VisualLineMap;
3384
+ }[], coordinateSpace: EditorCoordinateSpace, transform?: EditorCoordinateTransform): VisualLineMap;
3385
+ /** Lines backed by source ranges, excluding source-less cursor lines. */
3386
+ readonly sourceLines: readonly VisualLine[];
1978
3387
  constructor(lines: readonly VisualLine[]);
1979
3388
  get lineCount(): number;
1980
3389
  get isEmpty(): boolean;
@@ -1999,6 +3408,12 @@ export declare class VisualLineMap {
1999
3408
  * {@link lineIndexOfOffset}. Returns `0` when the map is empty.
2000
3409
  */
2001
3410
  xAtOffset(offset: SourceOffset): number;
3411
+ /**
3412
+ * Line occupied by a source or virtual cursor position. A virtual position
3413
+ * returns `undefined` until its corresponding DOM line has been measured.
3414
+ */
3415
+ lineIndexOfPosition(position: CursorPosition): number | undefined;
3416
+ xAtPosition(position: CursorPosition): number;
2002
3417
  /**
2003
3418
  * Line whose vertical band contains `y`, clamped to the first/last
2004
3419
  * line when `y` is outside the document.
@@ -2012,6 +3427,9 @@ export declare class VisualLineMap {
2012
3427
  offsetAtPoint(point: Point2D): SourceOffset;
2013
3428
  /** Snap `x` to the nearest offset on a specific line. */
2014
3429
  offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
3430
+ positionInLineAtX(lineIndex: number, x: number): CursorPosition;
3431
+ lineStartOffset(lineIndex: number): SourceOffset | undefined;
3432
+ lineEndOffset(lineIndex: number): SourceOffset | undefined;
2015
3433
  }
2016
3434
 
2017
3435
  /**
@@ -2020,14 +3438,22 @@ export declare class VisualLineMap {
2020
3438
  * When constructed with a {@link VisualRunSource}, `xAtOffset` returns the
2021
3439
  * pixel-exact x of the caret before character `offset` by measuring the
2022
3440
  * prefix `[textNodeStart, textNodeStart + (offset - sourceStart))` with a
2023
- * DOM `Range`. Without a source it falls back to linear interpolation
2024
- * across `rect.width`.
3441
+ * DOM `Range`.
3442
+ *
3443
+ * A source-less run has no per-offset geometry: it either represents an
3444
+ * element-only block (KaTeX math, a mermaid/custom diagram, an image, an
3445
+ * inactive `<hr>`) whose box does not correspond to source offsets, or a
3446
+ * hand-built run in a test. Either way it maps between offsets and x by
3447
+ * snapping to the nearer edge of {@link rect} rather than fabricating
3448
+ * interior positions.
2025
3449
  */
2026
3450
  export declare class VisualRun {
2027
3451
  readonly sourceRange: OffsetRange;
2028
3452
  readonly rect: Rect2D;
2029
3453
  readonly source?: VisualRunSource | undefined;
2030
- constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined);
3454
+ readonly isVisualLineAnchor: boolean;
3455
+ static visualLineAnchor(sourceOffset: SourceOffset, rect: Rect2D): VisualRun;
3456
+ constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined, isVisualLineAnchor?: boolean);
2031
3457
  get sourceStart(): SourceOffset;
2032
3458
  get sourceEndExclusive(): SourceOffset;
2033
3459
  get sourceLength(): number;
@@ -2039,19 +3465,32 @@ export declare class VisualRun {
2039
3465
 
2040
3466
  /**
2041
3467
  * 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.
3468
+ * `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`.
3469
+ * This matters for proportional fonts where character widths differ a lot
3470
+ * (e.g. `m` vs `i`): a caret placed by anything coarser than real glyph
3471
+ * measurement lands several pixels inside the wrong character.
2047
3472
  *
2048
- * Hand-built runs (tests) omit this; their `xAtOffset` falls back to
2049
- * linear interpolation.
3473
+ * A run without a source has no per-offset geometry, so it maps between
3474
+ * offsets and x by snapping to the nearer run edge. Real text runs always
3475
+ * carry a source; source-less runs are element-only blocks (see
3476
+ * {@link _appendElementBlockRun}) and hand-built runs in tests.
2050
3477
  */
2051
3478
  declare interface VisualRunSource {
2052
3479
  readonly textNode: Text;
2053
3480
  /** Offset within `textNode.data` corresponding to `sourceRange.start`. */
2054
3481
  readonly textNodeStart: number;
3482
+ readonly coordinateSpace: EditorCoordinateSpace;
3483
+ }
3484
+
3485
+ export declare const vscodeHostKeyboardProfile: KeyboardProfile;
3486
+
3487
+ export declare const vscodeKeyboardProfile: KeyboardProfile;
3488
+
3489
+ export declare const vscodeLocalKeyboardProfile: KeyboardProfile;
3490
+
3491
+ export declare interface WordNavigationConfig {
3492
+ readonly wordSeparators: string;
3493
+ readonly wordSegmenterLocales: readonly string[];
2055
3494
  }
2056
3495
 
2057
3496
  export { }