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

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