@vscode/markdown-editor 0.0.2-8 → 0.0.2-80
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.
- package/README.md +31 -0
- package/dist/commands.d.ts +65 -0
- package/dist/commands.js +159 -0
- package/dist/commands.js.map +1 -0
- package/dist/config-BGeaJqWk.js +286 -0
- package/dist/config-BGeaJqWk.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +1600 -119
- package/dist/index.js +6453 -2076
- package/dist/index.js.map +1 -1
- package/dist/markdown-editor.css +1 -0
- package/dist/stringEdit-CVDbCUBY.js +215 -0
- package/dist/stringEdit-CVDbCUBY.js.map +1 -0
- package/dist/web-editors.d.ts +282 -0
- package/dist/web-editors.js +7310 -0
- package/dist/web-editors.js.map +1 -0
- package/package.json +56 -16
- package/src/contrib/comments/commentInput.css +150 -0
- package/src/contrib/comments/comments.css +129 -0
- package/src/contrib/commentsVscode/vscodeCommentWidgetV2.css +171 -0
- package/src/contrib/find/find.css +347 -0
- package/src/view/editor.css +1157 -31
- package/src/view/themes/default.css +13 -4
- package/src/view/themes/github.css +16 -13
- package/src/view/themes/vscode-default.css +397 -0
- package/src/view/themes/{vscode.css → vscode-github.css} +124 -62
- package/dist/_observables/assert.d.ts +0 -2
- package/dist/_observables/deps.d.ts +0 -28
- package/dist/_observables/disposables.d.ts +0 -19
- package/dist/_observables/equals.d.ts +0 -32
- package/dist/_observables/index.d.ts +0 -2
- package/dist/_observables/observableInternal/base.d.ts +0 -172
- package/dist/_observables/observableInternal/changeTracker.d.ts +0 -44
- package/dist/_observables/observableInternal/commonFacade/cancellation.d.ts +0 -24
- package/dist/_observables/observableInternal/commonFacade/deps.d.ts +0 -24
- package/dist/_observables/observableInternal/debugLocation.d.ts +0 -21
- package/dist/_observables/observableInternal/debugName.d.ts +0 -33
- package/dist/_observables/observableInternal/experimental/deferUnobserve.d.ts +0 -16
- package/dist/_observables/observableInternal/experimental/reducer.d.ts +0 -37
- package/dist/_observables/observableInternal/experimental/utils.d.ts +0 -15
- package/dist/_observables/observableInternal/index.d.ts +0 -25
- package/dist/_observables/observableInternal/logging/consoleObservableLogger.d.ts +0 -40
- package/dist/_observables/observableInternal/logging/debugGetDependencyGraph.d.ts +0 -4
- package/dist/_observables/observableInternal/logging/debugger/debuggerRpc.d.ts +0 -4
- package/dist/_observables/observableInternal/logging/debugger/devToolsLogger.d.ts +0 -43
- package/dist/_observables/observableInternal/logging/debugger/rpc.d.ts +0 -41
- package/dist/_observables/observableInternal/logging/debugger/utils.d.ts +0 -13
- package/dist/_observables/observableInternal/logging/logging.d.ts +0 -30
- package/dist/_observables/observableInternal/map.d.ts +0 -18
- package/dist/_observables/observableInternal/observables/baseObservable.d.ts +0 -58
- package/dist/_observables/observableInternal/observables/constObservable.d.ts +0 -5
- package/dist/_observables/observableInternal/observables/derived.d.ts +0 -46
- package/dist/_observables/observableInternal/observables/derivedImpl.d.ts +0 -83
- package/dist/_observables/observableInternal/observables/lazyObservableValue.d.ts +0 -27
- package/dist/_observables/observableInternal/observables/observableFromEvent.d.ts +0 -37
- package/dist/_observables/observableInternal/observables/observableSignal.d.ts +0 -11
- package/dist/_observables/observableInternal/observables/observableSignalFromEvent.d.ts +0 -5
- package/dist/_observables/observableInternal/observables/observableValue.d.ts +0 -37
- package/dist/_observables/observableInternal/observables/observableValueOpts.d.ts +0 -8
- package/dist/_observables/observableInternal/reactions/autorun.d.ts +0 -56
- package/dist/_observables/observableInternal/reactions/autorunImpl.d.ts +0 -53
- package/dist/_observables/observableInternal/set.d.ts +0 -17
- package/dist/_observables/observableInternal/transaction.d.ts +0 -27
- package/dist/_observables/observableInternal/utils/promise.d.ts +0 -75
- package/dist/_observables/observableInternal/utils/runOnChange.d.ts +0 -7
- package/dist/_observables/observableInternal/utils/utils.d.ts +0 -43
- package/dist/_observables/observableInternal/utils/utilsCancellation.d.ts +0 -10
- package/dist/_observables/observableInternal/utils/valueWithChangeEvent.d.ts +0 -10
- package/dist/_observables/utils.d.ts +0 -15
- package/dist/observables.d.ts +0 -4
- package/dist/observables.js +0 -439
- package/dist/observables.js.map +0 -1
- package/dist/runOnChange-C00UIwqQ.js +0 -1538
- package/dist/runOnChange-C00UIwqQ.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
import { Disposable } from '
|
|
2
|
-
import { IDisposable } from '
|
|
3
|
-
import { IObservable } from '
|
|
4
|
-
import { IObservableWithChange } from '
|
|
5
|
-
import { ISettableObservable } from '
|
|
6
|
-
import { ITransaction } from '
|
|
1
|
+
import { Disposable } from '@vscode/observables';
|
|
2
|
+
import { IDisposable } from '@vscode/observables';
|
|
3
|
+
import { IObservable } from '@vscode/observables';
|
|
4
|
+
import { IObservableWithChange } from '@vscode/observables';
|
|
5
|
+
import { ISettableObservable } from '@vscode/observables';
|
|
6
|
+
import { ITransaction } from '@vscode/observables';
|
|
7
7
|
import { MonarchTokenizer } from 'monaco-editor/esm/vs/editor/standalone/common/monarch/monarchLexer.js';
|
|
8
8
|
|
|
9
|
+
declare interface AddedItem {
|
|
10
|
+
readonly kind: 'added';
|
|
11
|
+
readonly node: AstNode;
|
|
12
|
+
readonly modifiedStart: number;
|
|
13
|
+
readonly insertedLocal: readonly AnnotatedRange[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A word/character-level highlight inside a single block, in that block's
|
|
18
|
+
* *local* coordinate space (`0` = block start). `inserted` ranges live on a
|
|
19
|
+
* modified/added block, `deleted` ranges on an original/removed block.
|
|
20
|
+
*/
|
|
21
|
+
declare interface AnnotatedRange {
|
|
22
|
+
readonly range: OffsetRange;
|
|
23
|
+
readonly kind: 'inserted' | 'deleted';
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
/** Every concrete node kind, for exhaustive consumer-side dispatch. */
|
|
10
|
-
export declare type AnyAstNode = TextAstNode | MarkerAstNode | GlueAstNode | ThematicBreakAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode | HeadingAstNode | ParagraphAstNode | CodeBlockAstNode | MathBlockAstNode | BlockQuoteAstNode | ListAstNode | ListItemAstNode | TableAstNode | TableRowAstNode | TableCellAstNode | DocumentAstNode;
|
|
27
|
+
export declare type AnyAstNode = TextAstNode | MarkerAstNode | GlueAstNode | ThematicBreakAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode | HeadingAstNode | ParagraphAstNode | FrontMatterAstNode | CodeBlockAstNode | MathBlockAstNode | BlockQuoteAstNode | ListAstNode | ListItemAstNode | TableAstNode | TableRowAstNode | TableCellAstNode | DocumentAstNode | UnhandledBlockAstNode;
|
|
11
28
|
|
|
12
|
-
declare type AnyViewData = DocumentViewData | BlockViewData | InlineViewData | ListItemViewData | TableRowViewData | TableCellViewData | MarkerViewData | GlueViewData;
|
|
29
|
+
declare type AnyViewData = DocumentViewData | BlockViewData | InlineViewData | ListItemViewData | TableRowViewData | TableCellViewData | MarkerViewData | GlueViewData | DiffHunkViewData | DiffDecorationViewData;
|
|
13
30
|
|
|
14
31
|
export declare abstract class AstNode {
|
|
15
32
|
abstract readonly kind: string;
|
|
@@ -71,7 +88,7 @@ export declare class AsyncClipboardStrategy implements IClipboardStrategy {
|
|
|
71
88
|
connect(context: IClipboardContext): IDisposable;
|
|
72
89
|
}
|
|
73
90
|
|
|
74
|
-
export declare type BlockAstNode = HeadingAstNode | ParagraphAstNode | CodeBlockAstNode | MathBlockAstNode | ThematicBreakAstNode | BlockQuoteAstNode | ListAstNode | TableAstNode;
|
|
91
|
+
export declare type BlockAstNode = HeadingAstNode | ParagraphAstNode | FrontMatterAstNode | CodeBlockAstNode | MathBlockAstNode | ThematicBreakAstNode | BlockQuoteAstNode | ListAstNode | TableAstNode | UnhandledBlockAstNode;
|
|
75
92
|
|
|
76
93
|
/**
|
|
77
94
|
* A block-level node. Every block may carry a {@link leadingTrivia} glue — the
|
|
@@ -92,7 +109,7 @@ declare abstract class BlockAstNodeBase extends AstNode {
|
|
|
92
109
|
/**
|
|
93
110
|
* One block's place in the rendered document.
|
|
94
111
|
*
|
|
95
|
-
*
|
|
112
|
+
* Geometry is in editor-local CSS pixels. `height` is either a real DOM measurement
|
|
96
113
|
* (`isMeasured: true`) or an estimate produced when the block is not
|
|
97
114
|
* currently mounted (`isMeasured: false`). Estimates exist so virtual
|
|
98
115
|
* rendering can size the scroll container without mounting every block.
|
|
@@ -107,6 +124,13 @@ export declare interface BlockMeasurement {
|
|
|
107
124
|
readonly block: BlockAstNode;
|
|
108
125
|
readonly absoluteStart: number;
|
|
109
126
|
readonly height: number;
|
|
127
|
+
/** Local border box when mounted and measured. */
|
|
128
|
+
readonly rect: Rect2D | undefined;
|
|
129
|
+
/** Local horizontal padding-box clip when this block scrolls horizontally. */
|
|
130
|
+
readonly viewportClip: {
|
|
131
|
+
readonly left: number;
|
|
132
|
+
readonly right: number;
|
|
133
|
+
} | undefined;
|
|
110
134
|
readonly isMeasured: boolean;
|
|
111
135
|
readonly visualLineMap: VisualLineMap | undefined;
|
|
112
136
|
readonly viewNode: ViewNode | undefined;
|
|
@@ -126,11 +150,22 @@ export declare class BlockQuoteAstNode extends BlockAstNodeBase {
|
|
|
126
150
|
declare class BlockQuoteViewData {
|
|
127
151
|
readonly ast: BlockQuoteAstNode;
|
|
128
152
|
readonly content: readonly AnyViewData[];
|
|
153
|
+
/** False while a pending paragraph replaces the final marker-only line. */
|
|
154
|
+
readonly showFinalMarkerOnlyLine: boolean;
|
|
129
155
|
readonly kind = "blockQuote";
|
|
130
|
-
constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[]
|
|
156
|
+
constructor(ast: BlockQuoteAstNode, content: readonly AnyViewData[],
|
|
157
|
+
/** False while a pending paragraph replaces the final marker-only line. */
|
|
158
|
+
showFinalMarkerOnlyLine: boolean);
|
|
131
159
|
}
|
|
132
160
|
|
|
133
|
-
|
|
161
|
+
/**
|
|
162
|
+
* All blocks whose source range intersects `[start, endExclusive]`. A
|
|
163
|
+
* collapsed range (start === endExclusive) matches the block containing
|
|
164
|
+
* that offset (with the same boundary rule as {@link findBlockAtOffset}).
|
|
165
|
+
*/
|
|
166
|
+
export declare function blocksIntersecting(doc: DocumentAstNode, start: SourceOffset, endExclusive: SourceOffset): BlockAstNode[];
|
|
167
|
+
|
|
168
|
+
declare type BlockViewData = HeadingViewData | ParagraphViewData | FrontMatterViewData | CodeBlockViewData | MathBlockViewData | ThematicBreakViewData | BlockQuoteViewData | ListViewData | TableViewData | UnhandledBlockViewData;
|
|
134
169
|
|
|
135
170
|
/**
|
|
136
171
|
* Base view node for everything the editor renders, generic over the
|
|
@@ -151,6 +186,17 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
|
|
|
151
186
|
constructor(data: T, dom: globalThis.Node, children: readonly ViewNode[]);
|
|
152
187
|
get block(): BlockAstNode;
|
|
153
188
|
get element(): HTMLElement;
|
|
189
|
+
/**
|
|
190
|
+
* The horizontal scroll viewport for selection/caret clipping
|
|
191
|
+
* ({@link blockViewportClip}). For most blocks the scroller *is*
|
|
192
|
+
* {@link element} — a code / math / unhandled block's `element` is the very
|
|
193
|
+
* `overflow-x: auto` box that scrolls. A table is the exception: its
|
|
194
|
+
* `element` stays the inner `<table>` (so the active/markers classes and
|
|
195
|
+
* `.md-table` theme styling are unaffected), but the box that actually
|
|
196
|
+
* scrolls is the wrapping `.md-table-wrapper`, so {@link TableViewNode}
|
|
197
|
+
* overrides this to return that wrapper.
|
|
198
|
+
*/
|
|
199
|
+
get scrollElement(): HTMLElement;
|
|
154
200
|
/**
|
|
155
201
|
* Whether this already-built node can stand in for `data` unchanged. The
|
|
156
202
|
* builder preserves view-data identity for any subtree whose ast and
|
|
@@ -158,7 +204,7 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
|
|
|
158
204
|
* single identity check captures "nothing in my subtree changed" — and its
|
|
159
205
|
* whole subtree, and any session it owns, are kept as-is.
|
|
160
206
|
*/
|
|
161
|
-
canReuse(data: AnyViewData): boolean;
|
|
207
|
+
canReuse(data: AnyViewData, _options: BlockViewOptions | undefined): boolean;
|
|
162
208
|
/**
|
|
163
209
|
* Called by the view after this block is mounted and measured, with the
|
|
164
210
|
* block's rendered height in px. The default is a no-op; subclasses whose
|
|
@@ -171,12 +217,18 @@ export declare class BlockViewNode<T extends AnyViewData = AnyViewData> extends
|
|
|
171
217
|
export declare interface BlockViewOptions {
|
|
172
218
|
readonly renderCustomCodeBlock?: (language: string, content: string) => HTMLElement | undefined;
|
|
173
219
|
readonly onToggleCheckbox?: (item: ListItemAstNode, newChecked: boolean) => void;
|
|
220
|
+
/**
|
|
221
|
+
* Supplies live, declarative metadata for recognized links. The editor owns
|
|
222
|
+
* the markup and styling; providers own lookup, caching, and updates.
|
|
223
|
+
*/
|
|
224
|
+
readonly linkPresentationProvider?: ILinkPresentationProvider;
|
|
174
225
|
/**
|
|
175
226
|
* Opens a link's URL. Called when the user activates a link: a plain click
|
|
176
227
|
* while the link's block is inactive (rendered), or a Ctrl/Cmd+click while it
|
|
177
|
-
* is active (source shown).
|
|
228
|
+
* is active (source shown). Return `false` to use the anchor's native
|
|
229
|
+
* navigation behavior.
|
|
178
230
|
*/
|
|
179
|
-
readonly onOpenLink?: (url: string, event: MouseEvent) => void;
|
|
231
|
+
readonly onOpenLink?: (url: string, event: MouseEvent) => false | void;
|
|
180
232
|
/**
|
|
181
233
|
* Colours fenced code blocks. When set, a code block's content is rendered
|
|
182
234
|
* as a sequence of token spans instead of one plain text node. This is the
|
|
@@ -196,16 +248,43 @@ export declare interface BlockViewOptions {
|
|
|
196
248
|
* `katexEditableIdentifiers.ts`).
|
|
197
249
|
*/
|
|
198
250
|
readonly renderMath?: (request: MathRenderRequest) => MathRendering | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* Pluggable factory for an in-place, interactive editor that replaces the
|
|
253
|
+
* *rendered* (inactive) form of a fenced code block — see
|
|
254
|
+
* {@link IEmbeddedCodeEditor}. When it returns an editor for the block's
|
|
255
|
+
* language, that editor's element is mounted instead of the highlighted
|
|
256
|
+
* code, and content flows both ways as string edits. Returning `undefined`
|
|
257
|
+
* falls back to the default rendering. EXPERIMENTAL.
|
|
258
|
+
*/
|
|
259
|
+
readonly embeddedCodeEditorFactory?: IEmbeddedCodeEditorFactory;
|
|
260
|
+
/** Current read-only state forwarded to embedded code editors. */
|
|
261
|
+
readonly embeddedCodeEditorReadOnly?: boolean;
|
|
262
|
+
/** Identity used to invalidate previously created embedded editors. */
|
|
263
|
+
readonly embeddedCodeEditorFactoryVersion?: unknown;
|
|
264
|
+
/**
|
|
265
|
+
* Called when an {@link IEmbeddedCodeEditor} edits its content. `contentEdit`
|
|
266
|
+
* is in the block's *content* coordinates; the host translates it to a
|
|
267
|
+
* document edit (via {@link CodeBlockAstNode.codeOffset} and the block's
|
|
268
|
+
* offset) and applies it to the model.
|
|
269
|
+
*/
|
|
270
|
+
readonly onEmbeddedCodeEditorEdit?: (block: CodeBlockAstNode, contentEdit: StringEdit) => void;
|
|
199
271
|
}
|
|
200
272
|
|
|
201
273
|
export declare class CodeBlockAstNode extends BlockAstNodeBase {
|
|
274
|
+
/** First token of the fenced code block info string, used for syntax highlighting. */
|
|
202
275
|
readonly language: string;
|
|
276
|
+
/** Complete fenced code block info string, including metadata after the language token. */
|
|
277
|
+
readonly infoString: string;
|
|
203
278
|
readonly content: readonly (MarkerAstNode | GlueAstNode)[];
|
|
204
279
|
readonly leadingTrivia?: GlueAstNode | undefined;
|
|
205
280
|
readonly kind = "codeBlock";
|
|
206
281
|
private _previous?;
|
|
207
282
|
private _contentEdit?;
|
|
208
|
-
constructor(
|
|
283
|
+
constructor(
|
|
284
|
+
/** First token of the fenced code block info string, used for syntax highlighting. */
|
|
285
|
+
language: string,
|
|
286
|
+
/** Complete fenced code block info string, including metadata after the language token. */
|
|
287
|
+
infoString: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
|
|
209
288
|
get children(): readonly AstNode[];
|
|
210
289
|
get openFence(): MarkerAstNode | undefined;
|
|
211
290
|
get closeFence(): MarkerAstNode | undefined;
|
|
@@ -271,10 +350,260 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
|
|
|
271
350
|
* its predecessor's subscription explicitly.
|
|
272
351
|
*/
|
|
273
352
|
private _snapshotSub;
|
|
353
|
+
/**
|
|
354
|
+
* An in-place interactive editor (e.g. an iframe) mounted instead of the
|
|
355
|
+
* rendered code. Like {@link _session} it is adopted from `previous` across
|
|
356
|
+
* rebuilds so the underlying editor keeps its state, and must be disposed
|
|
357
|
+
* manually (a node reused as `previous` is never {@link dispose}d).
|
|
358
|
+
*/
|
|
359
|
+
private _embeddedEditor;
|
|
360
|
+
private readonly _embeddedEditorFactoryVersion;
|
|
361
|
+
private readonly _embeddedEditorReadOnly;
|
|
362
|
+
canReuse(data: AnyViewData, options: BlockViewOptions | undefined): boolean;
|
|
274
363
|
constructor(data: CodeBlockViewData, options: BlockViewOptions | undefined, previous: ViewNode | undefined);
|
|
275
364
|
dispose(): void;
|
|
276
365
|
}
|
|
277
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Canonical editor command catalog. Standalone keyboard handling and host
|
|
369
|
+
* integrations derive their command registration and default keybindings from
|
|
370
|
+
* this list.
|
|
371
|
+
*/
|
|
372
|
+
export declare const commands: readonly EditorCommandDefinition[];
|
|
373
|
+
|
|
374
|
+
/** A persistent comment anchored to a source range. */
|
|
375
|
+
declare interface Comment_2 {
|
|
376
|
+
readonly id: string;
|
|
377
|
+
/** Source range the comment refers to (its highlighted region). */
|
|
378
|
+
readonly range: OffsetRange;
|
|
379
|
+
/** The comment text. */
|
|
380
|
+
readonly body: string;
|
|
381
|
+
/** Display name of the author, if any. */
|
|
382
|
+
readonly author?: string;
|
|
383
|
+
/** Creation time (epoch ms), used to render a relative timestamp. */
|
|
384
|
+
readonly createdAt?: number;
|
|
385
|
+
}
|
|
386
|
+
export { Comment_2 as Comment }
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* A self-contained comment input box — a rounded panel with an auto-growing
|
|
390
|
+
* textarea and a send button, styled after the gdocs/Word "add a comment"
|
|
391
|
+
* affordance.
|
|
392
|
+
*
|
|
393
|
+
* This widget is *positioning-agnostic*: it only owns its own DOM and state.
|
|
394
|
+
* A host (the comment-mode controller, or a fixture) mounts {@link element}
|
|
395
|
+
* wherever it likes and is responsible for placing it relative to a selection.
|
|
396
|
+
*
|
|
397
|
+
* State is observable-driven (no framework): {@link value} reflects the live
|
|
398
|
+
* textarea content; submit/cancel are reported through the option callbacks.
|
|
399
|
+
*/
|
|
400
|
+
export declare class CommentInputWidget extends Disposable {
|
|
401
|
+
private readonly _options?;
|
|
402
|
+
readonly element: HTMLElement;
|
|
403
|
+
private readonly _textarea;
|
|
404
|
+
private readonly _measure;
|
|
405
|
+
private readonly _submitButton;
|
|
406
|
+
private readonly _value;
|
|
407
|
+
/** Live, untrimmed textarea content. */
|
|
408
|
+
get value(): IObservable<string>;
|
|
409
|
+
/** The raw textarea, exposed so a host can move focus into it (e.g. on Tab). */
|
|
410
|
+
get inputElement(): HTMLTextAreaElement;
|
|
411
|
+
constructor(_options?: CommentInputWidgetOptions | undefined);
|
|
412
|
+
/** Move focus into the textarea (caret at the end). */
|
|
413
|
+
focus(): void;
|
|
414
|
+
/** Replace the textarea content. */
|
|
415
|
+
setText(text: string): void;
|
|
416
|
+
/** Clear the textarea. */
|
|
417
|
+
clear(): void;
|
|
418
|
+
private _submit;
|
|
419
|
+
private _autoSize;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export declare interface CommentInputWidgetOptions {
|
|
423
|
+
/** Placeholder shown while the textarea is empty. Defaults to "Add Comment". */
|
|
424
|
+
readonly placeholder?: string;
|
|
425
|
+
/** Called after the textarea changes size. */
|
|
426
|
+
readonly onDidChangeSize?: () => void;
|
|
427
|
+
/**
|
|
428
|
+
* Called when the user submits a non-empty comment (Enter or the send
|
|
429
|
+
* button). The text is trimmed; never called with an empty string.
|
|
430
|
+
*/
|
|
431
|
+
readonly onSubmit?: (text: string) => void;
|
|
432
|
+
/** Called when the user dismisses the input (Escape). */
|
|
433
|
+
readonly onCancel?: () => void;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Comment mode — a gdocs/Word-style "add a comment" affordance layered on top of
|
|
438
|
+
* the editor *without modifying it*. It reads the editor's public observables
|
|
439
|
+
* ({@link EditorModel.readonlyMode}, {@link EditorModel.selection}) and the
|
|
440
|
+
* exposed {@link EditorView.caretRect} geometry, and mounts a
|
|
441
|
+
* {@link CommentInputWidget} into {@link EditorView.overlayContainer}.
|
|
442
|
+
*
|
|
443
|
+
* Behaviour:
|
|
444
|
+
* - Only active in read-only mode (the "review" view).
|
|
445
|
+
* - When a user-created selection is non-empty, the input box appears next to
|
|
446
|
+
* the caret (the selection's active end) but does NOT take focus, so keyboard
|
|
447
|
+
* selection keeps working. Programmatic selections such as find matches do
|
|
448
|
+
* not summon it. Press Tab to move focus into the box, then type.
|
|
449
|
+
* - The box appears on mouse-up, not mid-drag, so it doesn't flicker/jump
|
|
450
|
+
* while a selection is being dragged out (keyboard selection shows at once).
|
|
451
|
+
* - While the box has focus or holds a draft it is frozen in place (selection
|
|
452
|
+
* changes, drags and clicks no longer move it). It is dismissed by Escape,
|
|
453
|
+
* by submitting, or by blurring an empty box.
|
|
454
|
+
* - The editor's logical caret geometry remains available for anchoring in
|
|
455
|
+
* read-only mode even though the painted caret is hidden. While the box has
|
|
456
|
+
* focus, `.md-comment-active` also suppresses the painted caret in any mode.
|
|
457
|
+
*/
|
|
458
|
+
export declare class CommentModeController extends Disposable {
|
|
459
|
+
private readonly _model;
|
|
460
|
+
private readonly _view;
|
|
461
|
+
private readonly _options?;
|
|
462
|
+
private static _isCommentableSelectionSource;
|
|
463
|
+
private readonly _widget;
|
|
464
|
+
private readonly _gap;
|
|
465
|
+
private _visible;
|
|
466
|
+
private _anchorX;
|
|
467
|
+
private _pinnedRange;
|
|
468
|
+
/**
|
|
469
|
+
* The range a comment was just submitted for. The box stays hidden for it
|
|
470
|
+
* until the selection changes, so submitting doesn't immediately re-summon an
|
|
471
|
+
* empty box on the still-selected text.
|
|
472
|
+
*/
|
|
473
|
+
private _submittedRange;
|
|
474
|
+
constructor(_model: EditorModel, _view: EditorView, _options?: CommentModeControllerOptions | undefined);
|
|
475
|
+
private _update;
|
|
476
|
+
private _show;
|
|
477
|
+
private _layoutHorizontally;
|
|
478
|
+
/** Force-hide and clear the box (used by Escape and submit). */
|
|
479
|
+
private _hide;
|
|
480
|
+
/**
|
|
481
|
+
* Hide unless the user is engaged with the box: it has focus or holds a
|
|
482
|
+
* non-empty draft. This preserves in-progress text and keeps a focused box
|
|
483
|
+
* open (it is dismissed explicitly via Escape/submit, or by blurring it).
|
|
484
|
+
*/
|
|
485
|
+
private _autoHide;
|
|
486
|
+
private _widgetHasFocus;
|
|
487
|
+
/**
|
|
488
|
+
* The visible viewport (client coords) used for the flip-above decision: the
|
|
489
|
+
* nearest scrollable ancestor of the editor. `.md-editor` itself spans the
|
|
490
|
+
* full document height and never clips, so measuring against it would always
|
|
491
|
+
* report room below. Falls back to the window when nothing scrolls.
|
|
492
|
+
*/
|
|
493
|
+
private _getViewportRect;
|
|
494
|
+
private _hideAndRefocus;
|
|
495
|
+
private _submit;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
export declare interface CommentModeControllerOptions {
|
|
499
|
+
/** Called when the user submits a comment for the current selection. */
|
|
500
|
+
readonly onSubmit?: (submission: CommentSubmission) => void;
|
|
501
|
+
/** Gap (px) between the bottom of the selection and the top of the input box. */
|
|
502
|
+
readonly gap?: number;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Human-readable labels (for pickers / dropdowns). */
|
|
506
|
+
export declare const COMMENTS_DESIGN_LABELS: Record<CommentsDesign, string>;
|
|
507
|
+
|
|
508
|
+
/** design id → presenter factory over a shared CommentsModel + EditorView. */
|
|
509
|
+
export declare const COMMENTS_DESIGNS: Record<CommentsDesign, CommentsPresenterFactory>;
|
|
510
|
+
|
|
511
|
+
/** The available comment rendering designs. */
|
|
512
|
+
export declare type CommentsDesign = 'connected' | 'vscode' | 'vscode-v2';
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Seedable store of {@link Comment}s for the comment-mode contribution. Owns the
|
|
516
|
+
* comment list and the shared hover state; it has no opinion on rendering or
|
|
517
|
+
* persistence — a host seeds it via {@link set}/{@link add} and observes
|
|
518
|
+
* {@link comments}.
|
|
519
|
+
*/
|
|
520
|
+
export declare class CommentsModel {
|
|
521
|
+
private readonly _comments;
|
|
522
|
+
/** Monotonic counter for ids of comments created via {@link create}. */
|
|
523
|
+
private _sequence;
|
|
524
|
+
/** The current comments, in insertion order. */
|
|
525
|
+
get comments(): IObservable<readonly Comment_2[]>;
|
|
526
|
+
/**
|
|
527
|
+
* The comment currently hovered (by its card or its highlight), or
|
|
528
|
+
* `undefined`. Shared so the card and the highlight can react together.
|
|
529
|
+
*/
|
|
530
|
+
readonly hoveredId: ISettableObservable<string | undefined>;
|
|
531
|
+
/** Replace the whole comment set. */
|
|
532
|
+
set(comments: readonly Comment_2[]): void;
|
|
533
|
+
/**
|
|
534
|
+
* Create a comment from a user submission and append it, generating its `id`
|
|
535
|
+
* and `createdAt` here so id/time allocation stays the store's concern (the
|
|
536
|
+
* UI only supplies the range and text). Returns the created comment.
|
|
537
|
+
*/
|
|
538
|
+
create(input: {
|
|
539
|
+
range: OffsetRange;
|
|
540
|
+
body: string;
|
|
541
|
+
author?: string;
|
|
542
|
+
}): Comment_2;
|
|
543
|
+
/** Append a comment. */
|
|
544
|
+
add(comment: Comment_2): void;
|
|
545
|
+
/** Remove a comment by id. */
|
|
546
|
+
remove(id: string): void;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** Optional, design-specific context a presenter may use (ignored by others). */
|
|
550
|
+
export declare interface CommentsPresenterContext {
|
|
551
|
+
/** Light/dark hint for the token-wrapped VS Code widget designs. */
|
|
552
|
+
readonly theme?: 'light' | 'dark';
|
|
553
|
+
/**
|
|
554
|
+
* Resolves a source offset to a 1-based line number, for designs that show
|
|
555
|
+
* line info (the VS Code V1 card). Optional because the model itself carries
|
|
556
|
+
* no text; the host (which owns the source) supplies it.
|
|
557
|
+
*/
|
|
558
|
+
readonly resolveLine?: (offset: number) => number;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** Builds a presenter for a given model + editor view. */
|
|
562
|
+
export declare type CommentsPresenterFactory = (model: CommentsModel, view: EditorView, context?: CommentsPresenterContext) => ICommentsPresenter;
|
|
563
|
+
|
|
564
|
+
/** A comment the user submitted, with the source range it was anchored to. */
|
|
565
|
+
export declare interface CommentSubmission {
|
|
566
|
+
readonly text: string;
|
|
567
|
+
readonly range: OffsetRange;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Renders persistent comments as a gdocs-style side rail: each comment's range
|
|
572
|
+
* is highlighted (reusing the editor's selection geometry via
|
|
573
|
+
* {@link EditorView.rangeRects}), a leader line curves from the bottom of that
|
|
574
|
+
* highlight to a card stacked in the right rail, and cards never overlap.
|
|
575
|
+
*
|
|
576
|
+
* Everything is mounted into {@link EditorView.overlayContainer} so it shares
|
|
577
|
+
* the selection/caret coordinate space and scrolls with the document. When the
|
|
578
|
+
* editor's natural right margin is too narrow for the rail, the view reserves
|
|
579
|
+
* proportional space by padding the editor on the right — but only while there
|
|
580
|
+
* are comments.
|
|
581
|
+
*/
|
|
582
|
+
export declare class CommentsView extends Disposable {
|
|
583
|
+
private readonly _model;
|
|
584
|
+
private readonly _view;
|
|
585
|
+
private readonly _layer;
|
|
586
|
+
private readonly _entries;
|
|
587
|
+
constructor(_model: CommentsModel, _view: EditorView);
|
|
588
|
+
private _createLayer;
|
|
589
|
+
private _update;
|
|
590
|
+
/** Create/update/remove per-comment DOM to match `comments`. */
|
|
591
|
+
private _reconcile;
|
|
592
|
+
private _createEntry;
|
|
593
|
+
private _fillCard;
|
|
594
|
+
private _disposeEntry;
|
|
595
|
+
/** Position highlights, cards (stacked) and leader lines. */
|
|
596
|
+
private _layout;
|
|
597
|
+
private _applyHover;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/** The lossless source slices of a complete block HTML comment. */
|
|
601
|
+
declare interface CompleteHtmlCommentSource extends HtmlCommentSourceBase {
|
|
602
|
+
readonly kind: 'complete';
|
|
603
|
+
readonly closing: '-->';
|
|
604
|
+
readonly trailingWhitespace: string;
|
|
605
|
+
}
|
|
606
|
+
|
|
278
607
|
/**
|
|
279
608
|
* A {@link MonacoSyntaxHighlighter} preloaded with a handful of common Monarch
|
|
280
609
|
* grammars (plus the usual short aliases). Unknown languages fall back to an
|
|
@@ -285,13 +614,16 @@ export declare class CodeBlockViewNode extends BlockViewNode<CodeBlockViewData>
|
|
|
285
614
|
*/
|
|
286
615
|
export declare function createDefaultMonacoSyntaxHighlighter(monaco: IMonarchApi, grammars: IDefaultMonarchGrammars): MonacoSyntaxHighlighter;
|
|
287
616
|
|
|
288
|
-
export declare type CursorCommand = (ctx: CursorCommandContext) =>
|
|
617
|
+
export declare type CursorCommand = (ctx: CursorCommandContext) => CursorPosition;
|
|
289
618
|
|
|
290
619
|
export declare interface CursorCommandContext {
|
|
291
620
|
readonly text: string;
|
|
292
621
|
readonly selection: Selection_2;
|
|
293
622
|
readonly document: DocumentAstNode;
|
|
294
623
|
readonly activeBlock: BlockAstNode | undefined;
|
|
624
|
+
readonly markerVisibleBlocks: ReadonlySet<BlockAstNode>;
|
|
625
|
+
readonly wordNavigationConfig: WordNavigationConfig;
|
|
626
|
+
readonly cursorPosition: CursorPosition;
|
|
295
627
|
}
|
|
296
628
|
|
|
297
629
|
export declare const cursorDocumentEnd: CursorCommand;
|
|
@@ -300,6 +632,8 @@ export declare const cursorDocumentStart: CursorCommand;
|
|
|
300
632
|
|
|
301
633
|
export declare const cursorDown: VisualCursorCommand;
|
|
302
634
|
|
|
635
|
+
export declare type CursorKeyboardAction = 'left' | 'right' | 'up' | 'down' | 'wordLeft' | 'wordRight' | 'visualLineStart' | 'visualLineEnd' | 'logicalLineStart' | 'logicalLineEnd' | 'documentStart' | 'documentEnd';
|
|
636
|
+
|
|
303
637
|
export declare const cursorLeft: CursorCommand;
|
|
304
638
|
|
|
305
639
|
export declare const cursorLineEnd: CursorCommand;
|
|
@@ -309,12 +643,26 @@ export declare const cursorLineStart: CursorCommand;
|
|
|
309
643
|
export declare const cursorMoveLeft: CursorCommand;
|
|
310
644
|
|
|
311
645
|
export declare interface CursorMoveResult {
|
|
312
|
-
readonly
|
|
646
|
+
readonly position: CursorPosition;
|
|
313
647
|
readonly desiredColumn: number | undefined;
|
|
314
648
|
}
|
|
315
649
|
|
|
316
650
|
export declare const cursorMoveRight: CursorCommand;
|
|
317
651
|
|
|
652
|
+
/** The cursor's position in either source text or a source-less visual line. */
|
|
653
|
+
export declare type CursorPosition = {
|
|
654
|
+
readonly kind: 'source';
|
|
655
|
+
readonly offset: SourceOffset;
|
|
656
|
+
} | {
|
|
657
|
+
readonly kind: 'virtual';
|
|
658
|
+
readonly line: VirtualCursorLine;
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
export declare namespace CursorPosition {
|
|
662
|
+
export function source(offset: SourceOffset): CursorPosition;
|
|
663
|
+
export function virtual(line: VirtualCursorLine): CursorPosition;
|
|
664
|
+
}
|
|
665
|
+
|
|
318
666
|
export declare const cursorRight: CursorCommand;
|
|
319
667
|
|
|
320
668
|
export declare const cursorUp: VisualCursorCommand;
|
|
@@ -323,49 +671,129 @@ export declare const cursorUp: VisualCursorCommand;
|
|
|
323
671
|
* Owns the blinking cursor DOM element.
|
|
324
672
|
*
|
|
325
673
|
* The rendering pipeline is a single `derived` whose compute callback
|
|
326
|
-
* asks the {@link VisualLineMap} for the caret rect at the current
|
|
327
|
-
*
|
|
674
|
+
* asks the {@link VisualLineMap} for the caret rect at the current source or
|
|
675
|
+
* virtual position, writes it to {@link element}, and returns a
|
|
328
676
|
* {@link CursorViewRendering} value as proof. An autorun keeps the
|
|
329
677
|
* derived subscribed.
|
|
330
678
|
*/
|
|
331
679
|
export declare class CursorView extends Disposable {
|
|
332
|
-
private readonly _parent;
|
|
333
680
|
readonly element: HTMLElement;
|
|
334
681
|
readonly rendering: IObservable<CursorViewRendering>;
|
|
335
|
-
constructor(
|
|
682
|
+
constructor(options: CursorViewOptions);
|
|
336
683
|
}
|
|
337
684
|
|
|
338
685
|
export declare interface CursorViewOptions {
|
|
339
|
-
readonly
|
|
686
|
+
readonly position: IObservable<CursorPosition | undefined>;
|
|
340
687
|
readonly visualLineMap: IObservable<VisualLineMap>;
|
|
341
688
|
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* entry. Takes priority over the normal offset-based placement.
|
|
689
|
+
* The mounted blocks, used to hide the caret when it sits at an offset that
|
|
690
|
+
* has been scrolled out of its (horizontally scrolling) block's viewport —
|
|
691
|
+
* matching how the selection is clipped there.
|
|
346
692
|
*/
|
|
347
|
-
readonly
|
|
693
|
+
readonly blocks?: IObservable<readonly SelectionBlock[]>;
|
|
348
694
|
}
|
|
349
695
|
|
|
350
696
|
export declare class CursorViewRendering {
|
|
351
|
-
readonly
|
|
697
|
+
readonly position: CursorPosition;
|
|
352
698
|
readonly visible: boolean;
|
|
353
699
|
readonly rect: Rect2D;
|
|
354
|
-
constructor(
|
|
700
|
+
constructor(position: CursorPosition, visible: boolean, rect: Rect2D);
|
|
355
701
|
}
|
|
356
702
|
|
|
703
|
+
export declare const cursorVisualLineEnd: VisualCursorCommand;
|
|
704
|
+
|
|
705
|
+
export declare const cursorVisualLineStart: VisualCursorCommand;
|
|
706
|
+
|
|
357
707
|
export declare const cursorWordLeft: CursorCommand;
|
|
358
708
|
|
|
359
709
|
export declare const cursorWordRight: CursorCommand;
|
|
360
710
|
|
|
711
|
+
export declare const DEFAULT_INDENTATION_CONFIG: IndentationConfig;
|
|
712
|
+
|
|
713
|
+
export declare const DEFAULT_WORD_NAVIGATION_CONFIG: WordNavigationConfig;
|
|
714
|
+
|
|
715
|
+
export declare const DEFAULT_WORD_SEPARATORS = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?";
|
|
716
|
+
|
|
361
717
|
export declare const deleteLeft: EditCommand;
|
|
362
718
|
|
|
719
|
+
export declare const deleteLineLeft: EditCommand;
|
|
720
|
+
|
|
721
|
+
export declare const deleteLineRight: EditCommand;
|
|
722
|
+
|
|
363
723
|
export declare const deleteRight: EditCommand;
|
|
364
724
|
|
|
365
725
|
export declare const deleteWordLeft: EditCommand;
|
|
366
726
|
|
|
367
727
|
export declare const deleteWordRight: EditCommand;
|
|
368
728
|
|
|
729
|
+
/**
|
|
730
|
+
* A read-only "removed" decoration: an original block rendered (red) above its
|
|
731
|
+
* place in the modified document, occupying vertical space like a view-zone but
|
|
732
|
+
* contributing **zero** source length, so the editor's source mapping stays the
|
|
733
|
+
* modified document and editing is unaffected. Used for `removed` and the
|
|
734
|
+
* original side of a `replaced` block in editor diff mode.
|
|
735
|
+
*/
|
|
736
|
+
declare class DiffDecorationViewData {
|
|
737
|
+
readonly ast: AstNode;
|
|
738
|
+
readonly side: BlockViewData;
|
|
739
|
+
readonly deletedRanges: readonly DiffHighlightRange[];
|
|
740
|
+
/** True when the whole block was removed: solid red band, no word rects. */
|
|
741
|
+
readonly whole: boolean;
|
|
742
|
+
/** Absolute offset of this block in the *original* document. */
|
|
743
|
+
readonly originalStart: number;
|
|
744
|
+
readonly kind = "diffDecoration";
|
|
745
|
+
constructor(ast: AstNode, side: BlockViewData, deletedRanges: readonly DiffHighlightRange[],
|
|
746
|
+
/** True when the whole block was removed: solid red band, no word rects. */
|
|
747
|
+
whole: boolean,
|
|
748
|
+
/** Absolute offset of this block in the *original* document. */
|
|
749
|
+
originalStart: number);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/** A word/character highlight inside one diff side, in block-local coords. */
|
|
753
|
+
declare interface DiffHighlightRange {
|
|
754
|
+
readonly range: OffsetRange;
|
|
755
|
+
readonly kind: 'inserted' | 'deleted';
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* A changed block rendered as its original form stacked over its modified form
|
|
760
|
+
* (either side may be absent for a pure deletion/insertion). It is itself a
|
|
761
|
+
* document child the renderer mounts like a block; its {@link ast} is the
|
|
762
|
+
* surviving side's ast, used only for view-node identity/reuse.
|
|
763
|
+
*/
|
|
764
|
+
declare class DiffHunkViewData {
|
|
765
|
+
readonly ast: AstNode;
|
|
766
|
+
readonly original: DiffSideViewData | undefined;
|
|
767
|
+
readonly modified: DiffSideViewData | undefined;
|
|
768
|
+
readonly kind = "diffHunk";
|
|
769
|
+
constructor(ast: AstNode, original: DiffSideViewData | undefined, modified: DiffSideViewData | undefined);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* The recursive classification of a diff. Each item describes one aligned
|
|
774
|
+
* position in the merged document:
|
|
775
|
+
*
|
|
776
|
+
* - `unchanged` — render the (modified) node once, neutral.
|
|
777
|
+
* - `added` — exists only in the modified document (green).
|
|
778
|
+
* - `removed` — exists only in the original document (red).
|
|
779
|
+
* - `replaced` — a *leaf* block changed in place → render original over
|
|
780
|
+
* modified, with word-level {@link AnnotatedRange}s on each.
|
|
781
|
+
* - `nested` — a *container* changed → render it once and diff its
|
|
782
|
+
* {@link NestedItem.children} recursively.
|
|
783
|
+
*
|
|
784
|
+
* Offsets ({@link UnchangedItem.modifiedStart} etc.) are absolute in their
|
|
785
|
+
* respective documents, so a renderer/visualizer can slice the source text.
|
|
786
|
+
*/
|
|
787
|
+
declare type DiffItem = UnchangedItem | AddedItem | RemovedItem | ReplacedItem | NestedItem;
|
|
788
|
+
|
|
789
|
+
/** One side (original or modified) of a {@link DiffHunkViewData}. */
|
|
790
|
+
declare interface DiffSideViewData {
|
|
791
|
+
readonly view: BlockViewData;
|
|
792
|
+
/** Render in active form (markers/whitespace visible). */
|
|
793
|
+
readonly active: boolean;
|
|
794
|
+
readonly ranges: readonly DiffHighlightRange[];
|
|
795
|
+
}
|
|
796
|
+
|
|
369
797
|
export declare class DocumentAstNode extends AstNode {
|
|
370
798
|
readonly content: readonly (BlockAstNode | GlueAstNode)[];
|
|
371
799
|
readonly kind = "document";
|
|
@@ -390,14 +818,21 @@ declare interface DocumentBlockViewData {
|
|
|
390
818
|
readonly view: BlockViewData;
|
|
391
819
|
}
|
|
392
820
|
|
|
393
|
-
/** A mounted document child: a block, a run of inter-block glue,
|
|
394
|
-
* transient empty paragraph (see {@link PendingParagraphViewData})
|
|
821
|
+
/** A mounted document child: a block, a run of inter-block glue, the
|
|
822
|
+
* transient empty paragraph (see {@link PendingParagraphViewData}), or a
|
|
823
|
+
* {@link DiffHunkViewData diff hunk} (stacked original/modified blocks). */
|
|
395
824
|
declare interface DocumentChildViewData {
|
|
396
825
|
readonly absoluteStart: number;
|
|
397
826
|
/** For a block: selection reaches it. For glue: always false (unowned, hidden). */
|
|
398
827
|
readonly isActive: boolean;
|
|
399
|
-
readonly view: BlockViewData | GlueViewData | PendingParagraphViewData;
|
|
400
|
-
readonly kind: 'block' | 'glue' | 'pendingParagraph';
|
|
828
|
+
readonly view: BlockViewData | GlueViewData | PendingParagraphViewData | DiffHunkViewData | DiffDecorationViewData;
|
|
829
|
+
readonly kind: 'block' | 'glue' | 'pendingParagraph' | 'diffHunk' | 'diffDecoration';
|
|
830
|
+
/**
|
|
831
|
+
* Diff mode: how this (modified) block changed. `added` = a whole new block
|
|
832
|
+
* (strong green band, no inline rects); `modified` = a partial change (light
|
|
833
|
+
* band + inline rects on the changed words).
|
|
834
|
+
*/
|
|
835
|
+
readonly diffKind?: 'added' | 'modified';
|
|
401
836
|
}
|
|
402
837
|
|
|
403
838
|
/**
|
|
@@ -454,7 +889,7 @@ declare class DocumentViewData {
|
|
|
454
889
|
export declare class DocumentViewNode extends ViewNode {
|
|
455
890
|
readonly blocks: readonly DocumentBlock[];
|
|
456
891
|
/** The transient empty-paragraph element, when one is armed. */
|
|
457
|
-
readonly
|
|
892
|
+
readonly pendingParagraph?: PendingParagraphViewNode | undefined;
|
|
458
893
|
static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
|
|
459
894
|
private constructor();
|
|
460
895
|
/** The stable content element this document mounts its children into. */
|
|
@@ -476,6 +911,26 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
|
|
|
476
911
|
readonly selection: Selection_2;
|
|
477
912
|
} | undefined;
|
|
478
913
|
|
|
914
|
+
export declare type EditKeyboardAction = 'deleteLeft' | 'deleteRight' | 'deleteWordLeft' | 'deleteWordRight' | 'deleteLineLeft' | 'deleteLineRight';
|
|
915
|
+
|
|
916
|
+
export declare interface EditorCommandDefinition {
|
|
917
|
+
readonly id: `markdown.editor.${string}`;
|
|
918
|
+
readonly title: string;
|
|
919
|
+
readonly action: EditorKeyboardAction;
|
|
920
|
+
readonly keybindings: readonly EditorCommandKeybinding[];
|
|
921
|
+
/**
|
|
922
|
+
* Local commands must execute synchronously in the webview instead of being
|
|
923
|
+
* forwarded through the VS Code keybinding service.
|
|
924
|
+
*/
|
|
925
|
+
readonly routing?: 'host' | 'local';
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
export declare interface EditorCommandKeybinding {
|
|
929
|
+
readonly key: string;
|
|
930
|
+
readonly modifiers?: KeyboardModifiers;
|
|
931
|
+
readonly platforms?: readonly KeyboardPlatform[];
|
|
932
|
+
}
|
|
933
|
+
|
|
479
934
|
/**
|
|
480
935
|
* Translates raw browser input (mouse, keyboard, EditContext) into model
|
|
481
936
|
* mutations. Knows about DOM event types but never reads/writes the DOM
|
|
@@ -484,19 +939,41 @@ export declare type EditCommand = (ctx: CursorCommandContext) => {
|
|
|
484
939
|
*
|
|
485
940
|
* Owns the only non-derivable controller state:
|
|
486
941
|
* - `_desiredColumn` — sticky column for up/down navigation
|
|
942
|
+
* - `_clickCount` / `_lastPointerDown` — multi-click detection for pointer
|
|
943
|
+
* input, since `pointerdown` events (unlike `mousedown`) don't populate
|
|
944
|
+
* `detail` with a click count.
|
|
487
945
|
*/
|
|
488
946
|
export declare class EditorController extends Disposable {
|
|
489
947
|
private readonly _model;
|
|
490
948
|
private readonly _view;
|
|
949
|
+
readonly findController: FindController | undefined;
|
|
491
950
|
private _desiredColumn;
|
|
951
|
+
private readonly _keyboardPlatform;
|
|
952
|
+
private readonly _keyboardProfile;
|
|
953
|
+
private readonly _forwardedKeyboardProfile;
|
|
954
|
+
private readonly _historyStrategy;
|
|
955
|
+
private readonly _indentation;
|
|
956
|
+
private readonly _tabFocusStatus;
|
|
957
|
+
private _tabMovesFocus;
|
|
958
|
+
/** Running click count for the current multi-click sequence (1, 2, 3, …). */
|
|
959
|
+
private _clickCount;
|
|
960
|
+
/** Timestamp and position of the previous pointer-down, for multi-click detection. */
|
|
961
|
+
private _lastPointerDown;
|
|
492
962
|
constructor(_model: EditorModel, _view: EditorView, options?: EditorControllerOptions);
|
|
493
963
|
private readonly _handleTextUpdate;
|
|
494
|
-
|
|
964
|
+
/** Handle typed, pasted, or command-generated text while a paragraph is pending. */
|
|
965
|
+
private _handlePendingInput;
|
|
966
|
+
private _deletePendingText;
|
|
967
|
+
private readonly _handlePointerDown;
|
|
495
968
|
private _makeCursorContext;
|
|
496
969
|
private _makeVisualCursorContext;
|
|
497
970
|
private _executeCursorCommand;
|
|
498
971
|
private _executeEditCommand;
|
|
972
|
+
private _runUndoableEdit;
|
|
499
973
|
private _executeVisualCursorCommand;
|
|
974
|
+
private _cursorDown;
|
|
975
|
+
private _setUserSelection;
|
|
976
|
+
private _applyCursorPosition;
|
|
500
977
|
/** Move the cursor down one visual line (Arrow Down). */
|
|
501
978
|
cursorDown(extend?: boolean): void;
|
|
502
979
|
/** Move the cursor up one visual line (Arrow Up). */
|
|
@@ -504,12 +981,34 @@ export declare class EditorController extends Disposable {
|
|
|
504
981
|
private _selectedText;
|
|
505
982
|
private readonly _updateModifierState;
|
|
506
983
|
private readonly _clearModifierState;
|
|
984
|
+
/**
|
|
985
|
+
* Drop any native DOM selection over the rendered text.
|
|
986
|
+
*
|
|
987
|
+
* The editor paints selection from `model.selection`, so a browser
|
|
988
|
+
* selection there is always spurious: nothing reads it (copy/cut read the
|
|
989
|
+
* model, hit-testing uses the measured layout) and nothing clears it, so it
|
|
990
|
+
* lingers as a second highlight even after the caret moves away.
|
|
991
|
+
* {@link isCaretMotionKey} stops the common source synchronously; this is
|
|
992
|
+
* the backstop for the rest of the browser's editing commands, which are
|
|
993
|
+
* platform- and version-specific and cannot be enumerated (Shift+PageDown
|
|
994
|
+
* and macOS Shift+Ctrl+B both reach one today).
|
|
995
|
+
*
|
|
996
|
+
* Scoped twice so it only ever discards selections the editor owns: the
|
|
997
|
+
* range must touch the rendered text (overlays such as comment widgets sit
|
|
998
|
+
* beside it and stay selectable), and input focus must still be inside this
|
|
999
|
+
* editor (so a host find-in-page, which selects while its own input is
|
|
1000
|
+
* focused, is left alone).
|
|
1001
|
+
*/
|
|
1002
|
+
private readonly _discardNativeSelection;
|
|
507
1003
|
private readonly _handleKeyDown;
|
|
1004
|
+
executeCommand(command: EditorCommandDefinition): void;
|
|
1005
|
+
private _executeKeyboardAction;
|
|
508
1006
|
/**
|
|
509
1007
|
* Context-aware Enter: splits / line-breaks via {@link insertSmartEnter}, or
|
|
510
1008
|
* arms a transient empty paragraph when at the end of a paragraph.
|
|
511
1009
|
*/
|
|
512
1010
|
private _smartEnter;
|
|
1011
|
+
private _registerTabFocusAccessibility;
|
|
513
1012
|
}
|
|
514
1013
|
|
|
515
1014
|
/** Options for an {@link EditorController}. */
|
|
@@ -520,10 +1019,79 @@ export declare interface EditorControllerOptions {
|
|
|
520
1019
|
* strategy (e.g. `AsyncClipboardStrategy`) in hosts that swallow them.
|
|
521
1020
|
*/
|
|
522
1021
|
readonly clipboardStrategy?: IClipboardStrategy;
|
|
1022
|
+
/**
|
|
1023
|
+
* Where undo and redo are executed: `LocalHistoryStrategy` for a
|
|
1024
|
+
* self-contained editor, or a strategy that forwards to the host's own
|
|
1025
|
+
* document history. Left unset, the chords are passed on to the host.
|
|
1026
|
+
*/
|
|
1027
|
+
readonly historyStrategy?: IHistoryStrategy;
|
|
1028
|
+
readonly keyboardPlatform?: KeyboardPlatform;
|
|
1029
|
+
readonly keyboardProfile?: KeyboardProfile;
|
|
1030
|
+
/**
|
|
1031
|
+
* Bindings owned by the host. Matching events have their browser default
|
|
1032
|
+
* suppressed but continue propagating so the host keybinding service sees them.
|
|
1033
|
+
*/
|
|
1034
|
+
readonly forwardedKeyboardProfile?: KeyboardProfile;
|
|
1035
|
+
/** Tab-stop settings used outside semantic list indentation. */
|
|
1036
|
+
readonly indentation?: IndentationConfig;
|
|
1037
|
+
readonly find?: false;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* The editor overlay's local CSS-pixel coordinate space.
|
|
1042
|
+
*
|
|
1043
|
+
* Browser geometry and pointer APIs expose viewport client coordinates. This
|
|
1044
|
+
* boundary converts them immediately into the coordinate system shared by the
|
|
1045
|
+
* editor content and its overlays. Range rectangles are axis-aligned, so the
|
|
1046
|
+
* current implementation deliberately supports positive axis-aligned scale and
|
|
1047
|
+
* translation only.
|
|
1048
|
+
*/
|
|
1049
|
+
export declare class EditorCoordinateSpace {
|
|
1050
|
+
private readonly _getLocalToClientMatrix;
|
|
1051
|
+
static forSvgOverlay(overlay: SVGSVGElement): EditorCoordinateSpace;
|
|
1052
|
+
private constructor();
|
|
1053
|
+
capture(): EditorCoordinateTransform;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/** A stable coordinate conversion captured for one measurement operation. */
|
|
1057
|
+
export declare class EditorCoordinateTransform {
|
|
1058
|
+
private readonly _localToClient;
|
|
1059
|
+
private readonly _clientToLocal;
|
|
1060
|
+
constructor(_localToClient: DOMMatrix);
|
|
1061
|
+
toLocalPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
|
|
1062
|
+
toClientPoint(point: Pick<Point2D, 'x' | 'y'>): Point2D;
|
|
1063
|
+
toLocalRect(rect: Pick<DOMRectReadOnly, 'left' | 'top' | 'width' | 'height'>): Rect2D;
|
|
1064
|
+
toClientRect(rect: Pick<Rect2D, 'left' | 'top' | 'width' | 'height'>): Rect2D;
|
|
1065
|
+
private _convertRect;
|
|
523
1066
|
}
|
|
524
1067
|
|
|
1068
|
+
export declare type EditorKeyboardAction = {
|
|
1069
|
+
readonly kind: 'cursor';
|
|
1070
|
+
readonly command: CursorKeyboardAction;
|
|
1071
|
+
readonly extend: boolean;
|
|
1072
|
+
} | {
|
|
1073
|
+
readonly kind: 'edit';
|
|
1074
|
+
readonly command: EditKeyboardAction;
|
|
1075
|
+
} | {
|
|
1076
|
+
readonly kind: 'history';
|
|
1077
|
+
readonly command: HistoryKeyboardAction;
|
|
1078
|
+
} | {
|
|
1079
|
+
readonly kind: 'tab';
|
|
1080
|
+
readonly command: TabKeyboardAction;
|
|
1081
|
+
} | {
|
|
1082
|
+
readonly kind: 'toggleTabFocus';
|
|
1083
|
+
} | {
|
|
1084
|
+
readonly kind: 'selectAll';
|
|
1085
|
+
} | {
|
|
1086
|
+
readonly kind: 'enter';
|
|
1087
|
+
readonly command: 'smartEnter' | 'insertParagraph' | 'insertHardLineBreak';
|
|
1088
|
+
};
|
|
1089
|
+
|
|
525
1090
|
export declare class EditorModel {
|
|
526
1091
|
private readonly _parser;
|
|
1092
|
+
private readonly _sourceEditListeners;
|
|
1093
|
+
private readonly _sourceTextIds;
|
|
1094
|
+
private _lastSourceTextId;
|
|
527
1095
|
/**
|
|
528
1096
|
* The most recent edit applied to {@link sourceText}, used by
|
|
529
1097
|
* {@link document} to let the parser link incrementally edited code
|
|
@@ -532,11 +1100,24 @@ export declare class EditorModel {
|
|
|
532
1100
|
*/
|
|
533
1101
|
private _pendingEdit;
|
|
534
1102
|
readonly sourceText: ISettableObservable<StringValue, void>;
|
|
1103
|
+
readonly wordNavigationConfig: ISettableObservable<WordNavigationConfig, void>;
|
|
1104
|
+
/**
|
|
1105
|
+
* Read-only mode. When `true`, the editor never reveals a block's source
|
|
1106
|
+
* markers (markdown special characters like `**`, `#`, list bullets, code
|
|
1107
|
+
* fences, `$…$`) — every block stays in its clean rendered form regardless of
|
|
1108
|
+
* where the caret/selection is — and text-editing commands are ignored.
|
|
1109
|
+
* Explicit interactions with rendered controls, such as task checkboxes,
|
|
1110
|
+
* remain available. Plain text selection still works everywhere (so the user
|
|
1111
|
+
* can copy). The default (`false`) is the normal editing mode where the active
|
|
1112
|
+
* block reveals its markers.
|
|
1113
|
+
*/
|
|
1114
|
+
readonly readonlyMode: ISettableObservable<boolean, void>;
|
|
535
1115
|
/**
|
|
536
1116
|
* The current selection, or `undefined` when the editor has no caret
|
|
537
1117
|
* (e.g. an inactive/unfocused rendering).
|
|
538
1118
|
*/
|
|
539
1119
|
readonly selection: ISettableObservable<Selection_2 | undefined, void>;
|
|
1120
|
+
readonly selectionSource: ISettableObservable<SelectionSource, void>;
|
|
540
1121
|
/**
|
|
541
1122
|
* Whether a Ctrl/Cmd modifier is currently held. Set by the controller from
|
|
542
1123
|
* live keyboard state; the view reads it to show the link-open affordance
|
|
@@ -544,6 +1125,14 @@ export declare class EditorModel {
|
|
|
544
1125
|
* whose block is active.
|
|
545
1126
|
*/
|
|
546
1127
|
readonly ctrlOrMetaDown: ISettableObservable<boolean, void>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Whether a pointer-driven selection drag is currently in progress. Set by
|
|
1130
|
+
* the controller between the pointer-down that starts the drag and the
|
|
1131
|
+
* pointer-up/cancel that ends it. Contributions read it to defer UI that
|
|
1132
|
+
* would otherwise flicker mid-drag (e.g. the comment input box appears only
|
|
1133
|
+
* once the drag ends).
|
|
1134
|
+
*/
|
|
1135
|
+
readonly isSelecting: ISettableObservable<boolean, void>;
|
|
547
1136
|
/**
|
|
548
1137
|
* Gutter markers (source-control style change indicators) painted in the
|
|
549
1138
|
* left gutter. Each entry maps a source {@link OffsetRange} to a change kind
|
|
@@ -563,16 +1152,17 @@ export declare class EditorModel {
|
|
|
563
1152
|
* The transient empty-paragraph editing state, or `undefined` when none is
|
|
564
1153
|
* armed. See {@link PendingParagraph}. This is *not* document data — it is
|
|
565
1154
|
* cleared by any source edit and lives only between the Enter that armed it
|
|
566
|
-
* and the next
|
|
1155
|
+
* and the next content-producing edit.
|
|
567
1156
|
*/
|
|
568
1157
|
readonly pendingParagraph: ISettableObservable<PendingParagraph | undefined, void>;
|
|
569
1158
|
readonly cursorOffset: IObservableWithChange<number | undefined, void>;
|
|
1159
|
+
readonly cursorPosition: IObservableWithChange<CursorPosition | undefined, void>;
|
|
570
1160
|
/**
|
|
571
1161
|
* The parsed document. Threads the previous document into the parser so
|
|
572
1162
|
* unchanged blocks keep their object identity across reparses (see
|
|
573
1163
|
* {@link MarkdownParser.parse}). Writing `previous` inside the compute is
|
|
574
|
-
*
|
|
575
|
-
*
|
|
1164
|
+
* safe: unchanged source reuses it directly, while changed source produces
|
|
1165
|
+
* a result structurally identical to a full reparse.
|
|
576
1166
|
*/
|
|
577
1167
|
readonly document: IObservableWithChange<DocumentAstNode, void>;
|
|
578
1168
|
/**
|
|
@@ -589,28 +1179,62 @@ export declare class EditorModel {
|
|
|
589
1179
|
* collapsed this is a one-element set holding {@link activeBlock}.
|
|
590
1180
|
*/
|
|
591
1181
|
readonly activeBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
|
|
1182
|
+
/**
|
|
1183
|
+
* The baseline document to diff against. When set, the editor renders in
|
|
1184
|
+
* diff mode: the modified document ({@link document}) stays editable, while
|
|
1185
|
+
* the baseline's removed/changed blocks are shown as read-only decorations.
|
|
1186
|
+
* `undefined` (the default) renders normally.
|
|
1187
|
+
*/
|
|
1188
|
+
readonly baseline: ISettableObservable<StringValue | undefined, void>;
|
|
1189
|
+
private readonly _baselineDocument;
|
|
1190
|
+
/**
|
|
1191
|
+
* The diff of {@link baseline} → {@link document}, or `undefined` when no
|
|
1192
|
+
* baseline is set. The view renders the {@link DiffItem}s as stacked
|
|
1193
|
+
* decorations; `insertedRanges` (modified-side change spans) drive the green
|
|
1194
|
+
* word-level highlight.
|
|
1195
|
+
*/
|
|
1196
|
+
readonly diff: IObservableWithChange< {
|
|
1197
|
+
items: DiffItem[];
|
|
1198
|
+
insertedRanges: OffsetRange[];
|
|
1199
|
+
changedBlocks: Set<BlockAstNode>;
|
|
1200
|
+
} | undefined, void>;
|
|
1201
|
+
readonly markerVisibleBlocks: IObservableWithChange<Set<BlockAstNode>, void>;
|
|
1202
|
+
onWillApplySourceEdit(listener: (event: SourceEditEvent) => void): IDisposable;
|
|
1203
|
+
/** Returns a stable per-object identity without retaining the source text. */
|
|
1204
|
+
getSourceTextId(sourceText: StringValue): number;
|
|
592
1205
|
/**
|
|
593
1206
|
* Arm a {@link PendingParagraph} at the given gap, minting a fresh synthetic
|
|
594
1207
|
* AST node for it, and park the caret at the gap start. No source edit is
|
|
595
1208
|
* applied — the blank line exists only in the view until it is materialized.
|
|
596
1209
|
*/
|
|
597
|
-
armPendingParagraph(req:
|
|
598
|
-
anchorBlock: BlockAstNode;
|
|
599
|
-
replaceRange: OffsetRange;
|
|
600
|
-
atEof: boolean;
|
|
601
|
-
}): void;
|
|
1210
|
+
armPendingParagraph(req: Omit<PendingParagraph, 'syntheticAst' | 'cursorLine' | 'text'>): void;
|
|
602
1211
|
/** Discard the pending paragraph (if any) without touching the source. */
|
|
603
1212
|
cancelPendingParagraph(): void;
|
|
1213
|
+
/**
|
|
1214
|
+
* Replace the source with an authoritative value from the host, mapping the
|
|
1215
|
+
* selection through the changed span and atomically discarding transient
|
|
1216
|
+
* state anchored to the previous parse.
|
|
1217
|
+
*/
|
|
1218
|
+
replaceSourceText(text: StringValue): void;
|
|
1219
|
+
/** Replace the transient horizontal whitespace on the pending line. */
|
|
1220
|
+
setPendingParagraphText(text: string): void;
|
|
604
1221
|
/**
|
|
605
1222
|
* Turn the pending paragraph into real source: rewrite its gap so the typed
|
|
606
|
-
*
|
|
607
|
-
* lines, and place the caret after
|
|
1223
|
+
* text, including any transient indentation, is separated from its neighbours
|
|
1224
|
+
* by blank lines, and place the caret after it.
|
|
608
1225
|
*/
|
|
609
1226
|
materializePendingParagraph(text: string): void;
|
|
610
|
-
|
|
1227
|
+
/** Sets a rendered task checkbox state in either editing or read-only mode. */
|
|
1228
|
+
setTaskCheckboxChecked(item: ListItemAstNode, checked: boolean): void;
|
|
1229
|
+
applyEdit(edit: StringEdit, selection?: Selection_2): void;
|
|
611
1230
|
applyEditForSelection(edit: StringEdit): void;
|
|
1231
|
+
private _applySourceEdit;
|
|
1232
|
+
private _identifySourceEdit;
|
|
1233
|
+
private _emitWillApplySourceEdit;
|
|
612
1234
|
}
|
|
613
1235
|
|
|
1236
|
+
export declare type EditorOverlayPosition = 'top-chrome' | 'below-selection' | 'above-decorations';
|
|
1237
|
+
|
|
614
1238
|
/**
|
|
615
1239
|
* Pure-render view of an {@link EditorModel}.
|
|
616
1240
|
*
|
|
@@ -640,6 +1264,8 @@ export declare class EditorView extends Disposable {
|
|
|
640
1264
|
readonly element: HTMLElement;
|
|
641
1265
|
readonly editContext: EditContext;
|
|
642
1266
|
readonly measuredLayout: MeasuredLayoutModel;
|
|
1267
|
+
readonly coordinateSpace: EditorCoordinateSpace;
|
|
1268
|
+
readonly forcedMarkerVisibleBlocks: ISettableObservable<ReadonlySet<BlockAstNode>, void>;
|
|
643
1269
|
/**
|
|
644
1270
|
* Inner container that holds the rendered document and the cursor/selection
|
|
645
1271
|
* overlays. The outer {@link element} spans the full width; this container
|
|
@@ -647,9 +1273,14 @@ export declare class EditorView extends Disposable {
|
|
|
647
1273
|
* to their parent's box) stay aligned with the content.
|
|
648
1274
|
*/
|
|
649
1275
|
private readonly _contentContainer;
|
|
1276
|
+
private readonly _resizeObserver;
|
|
650
1277
|
private readonly _cursorView;
|
|
651
1278
|
private readonly _selectionView;
|
|
652
1279
|
private readonly _gutterMarkersView;
|
|
1280
|
+
private readonly _diffHighlightsView;
|
|
1281
|
+
private _readonlyToggleButton;
|
|
1282
|
+
private readonly _editContextSuspensions;
|
|
1283
|
+
private readonly _revealOcclusions;
|
|
653
1284
|
/**
|
|
654
1285
|
* The mounted block sequence, in source order. Rebuilt (not mutated) each
|
|
655
1286
|
* frame by {@link DocumentViewNode.create}; the view just swaps one
|
|
@@ -657,8 +1288,11 @@ export declare class EditorView extends Disposable {
|
|
|
657
1288
|
* (those go through the measured-layout model).
|
|
658
1289
|
*/
|
|
659
1290
|
private readonly _document;
|
|
1291
|
+
private readonly _embeddedCodeEditorFactoryVersion;
|
|
660
1292
|
/** The current view-node tree (AST overlaid with rendered DOM), for debugging. */
|
|
661
1293
|
get documentViewNode(): IObservable<DocumentViewNode | undefined>;
|
|
1294
|
+
/** Re-resolves embedded code editors while preserving the surrounding editor view. */
|
|
1295
|
+
refreshEmbeddedCodeEditors(): void;
|
|
662
1296
|
/**
|
|
663
1297
|
* Last frame's view-data overlay, threaded back into
|
|
664
1298
|
* {@link buildDocumentViewData} so any subtree whose ast and selection flags
|
|
@@ -670,18 +1304,44 @@ export declare class EditorView extends Disposable {
|
|
|
670
1304
|
private readonly _viewData;
|
|
671
1305
|
get viewData(): IObservable<DocumentViewData | undefined>;
|
|
672
1306
|
/**
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
1307
|
+
* Whether the editor is genuinely focused: focus rests somewhere inside the
|
|
1308
|
+
* editor subtree *and* its window is focused. Mirrored onto the root as
|
|
1309
|
+
* `.md-focused`, which gates the painted caret — the blinking cursor is only
|
|
1310
|
+
* shown while this is `true`, so it never blinks in an unfocused editor or
|
|
1311
|
+
* after the window loses focus. Only the caret's visibility is affected; the
|
|
1312
|
+
* logical selection and caret geometry ({@link caretRect}) are unchanged.
|
|
677
1313
|
*/
|
|
678
|
-
private readonly
|
|
1314
|
+
private readonly _focused;
|
|
1315
|
+
get focused(): IObservable<boolean>;
|
|
679
1316
|
/**
|
|
680
1317
|
* The block cache projected for views (selection painting) that need to
|
|
681
1318
|
* react to mount/unmount. Derived from {@link _document}, so it stays in
|
|
682
1319
|
* lock-step without any manual bookkeeping.
|
|
683
1320
|
*/
|
|
684
1321
|
private readonly _selectionBlocksObs;
|
|
1322
|
+
/**
|
|
1323
|
+
* The caret rect (zero width) at the selection's active end, in
|
|
1324
|
+
* {@link overlayContainer}-local coordinates, or `undefined` when there is no
|
|
1325
|
+
* caret. This is the same geometry the editor paints its cursor from, so
|
|
1326
|
+
* contributions (e.g. comment mode) can anchor an overlay to the active end of
|
|
1327
|
+
* the selection — where the user's cursor is — without re-deriving geometry.
|
|
1328
|
+
*/
|
|
1329
|
+
private readonly _caretRect;
|
|
1330
|
+
get caretRect(): IObservable<Rect2D | undefined>;
|
|
1331
|
+
/**
|
|
1332
|
+
* The container that establishes the positioning context for the editor's
|
|
1333
|
+
* overlays (cursor, selection, gutter). Contributions mount their own
|
|
1334
|
+
* absolutely-positioned overlays here so they share the coordinate space of
|
|
1335
|
+
* {@link caretRect}.
|
|
1336
|
+
*/
|
|
1337
|
+
get overlayContainer(): HTMLElement;
|
|
1338
|
+
/**
|
|
1339
|
+
* Selection-style rectangles covering `range`, in {@link overlayContainer}-
|
|
1340
|
+
* local coordinates — the same geometry the live selection paints. Exposed so
|
|
1341
|
+
* contributions (e.g. persistent comments) can highlight arbitrary ranges and
|
|
1342
|
+
* anchor overlays to them. Recomputes when the measured layout changes.
|
|
1343
|
+
*/
|
|
1344
|
+
rangeRects(range: OffsetRange): IObservable<readonly SelectionRect[]>;
|
|
685
1345
|
constructor(_model: EditorModel, _options?: EditorViewOptions | undefined);
|
|
686
1346
|
/**
|
|
687
1347
|
* Mirrors the model's live Ctrl/Cmd state onto the editor root as
|
|
@@ -690,13 +1350,92 @@ export declare class EditorView extends Disposable {
|
|
|
690
1350
|
* a plain click, but an active link only opens with the modifier held.
|
|
691
1351
|
*/
|
|
692
1352
|
private _setupModifierTracking;
|
|
1353
|
+
/**
|
|
1354
|
+
* Tracks whether the editor is genuinely focused and mirrors it onto the
|
|
1355
|
+
* root as `.md-focused` so CSS can gate the painted caret. "Focused" means
|
|
1356
|
+
* focus rests somewhere inside the editor subtree *and* the window itself is
|
|
1357
|
+
* focused; either condition failing (focus moving elsewhere, or the window
|
|
1358
|
+
* losing focus) hides the blinking caret while leaving the logical selection
|
|
1359
|
+
* and caret geometry intact.
|
|
1360
|
+
*/
|
|
1361
|
+
private _setupFocusTracking;
|
|
1362
|
+
/**
|
|
1363
|
+
* Renders the edit/read-only mode toggle. It flips the model's
|
|
1364
|
+
* {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
|
|
1365
|
+
* in its clean rendered form (no markdown markers revealed) and edits are
|
|
1366
|
+
* ignored, while text selection still works. The control lives in a
|
|
1367
|
+
* zero-height *sticky* host inside the centered content container, so the
|
|
1368
|
+
* lock follows the content's right edge and remains pinned as the document
|
|
1369
|
+
* scrolls. The current mode is also mirrored onto the root as `.md-readonly`
|
|
1370
|
+
* for any CSS hooks.
|
|
1371
|
+
*/
|
|
1372
|
+
private _setupReadonlyToggle;
|
|
1373
|
+
/** Draws attention to the mode toggle after text input is attempted while locked. */
|
|
1374
|
+
showReadonlyEditingAttempt(): void;
|
|
693
1375
|
focus(): void;
|
|
1376
|
+
mountOverlay(element: HTMLElement | SVGSVGElement, position: EditorOverlayPosition): IDisposable;
|
|
1377
|
+
/** Registers floating editor chrome that should count as covering a range during reveal. */
|
|
1378
|
+
registerRevealOcclusion(element: Element): IDisposable;
|
|
1379
|
+
/**
|
|
1380
|
+
* Temporarily detaches the root {@link EditContext} while focus is inside
|
|
1381
|
+
* nested editor chrome. Chromium otherwise reclaims focus from non-text
|
|
1382
|
+
* controls inside the EditContext host, breaking keyboard access to controls
|
|
1383
|
+
* such as the find actions and read-only toggle.
|
|
1384
|
+
*/
|
|
1385
|
+
suspendEditContextWhileFocused(element: HTMLElement): IDisposable;
|
|
1386
|
+
revealRangeInCenterIfOutsideViewport(range: OffsetRange, behavior?: ScrollBehavior): IDisposable;
|
|
1387
|
+
/**
|
|
1388
|
+
* Samples the ambient focus state that decides whether taking focus on open
|
|
1389
|
+
* would steal it from an explicit user target: whether the window is focused
|
|
1390
|
+
* and whether focus is still unclaimed (no active element, or the `<body>`
|
|
1391
|
+
* fallback).
|
|
1392
|
+
*/
|
|
1393
|
+
private _sampleAutoFocusEnvironment;
|
|
1394
|
+
/**
|
|
1395
|
+
* One-shot guarded focus attempt: focuses the editor only if doing so will
|
|
1396
|
+
* not steal focus from an explicit user target — the window must already be
|
|
1397
|
+
* focused and no other element may have claimed focus yet. Returns whether
|
|
1398
|
+
* focus was taken. A no-op for a background window or when the user has
|
|
1399
|
+
* already focused something else. {@link autoFocusOnOpen} builds the
|
|
1400
|
+
* open-time behavior on top of this primitive.
|
|
1401
|
+
*/
|
|
1402
|
+
tryAutoFocus(): boolean;
|
|
1403
|
+
/**
|
|
1404
|
+
* Focuses the editor when it opens without ever stealing focus from an
|
|
1405
|
+
* explicit user target. Tries once immediately; if the window is not focused
|
|
1406
|
+
* yet — a common open-time race where the editor is mounted before the host
|
|
1407
|
+
* routes focus to its window — the guarded attempt is deferred to the next
|
|
1408
|
+
* time the window gains focus and re-evaluated then. The deferral is
|
|
1409
|
+
* one-shot, so a later, unrelated window refocus never grabs focus, and the
|
|
1410
|
+
* re-check still respects any target the user has claimed in the meantime.
|
|
1411
|
+
*/
|
|
1412
|
+
autoFocusOnOpen(): void;
|
|
1413
|
+
/**
|
|
1414
|
+
* Own point→offset resolution. When `true` (the default),
|
|
1415
|
+
* {@link resolveOffsetFromPoint} ignores the platform DOM hit-test
|
|
1416
|
+
* (`caretPositionFromPoint`) and snaps the point to the nearest offset purely
|
|
1417
|
+
* from the rendered {@link VisualLineMap} geometry — picking the nearest
|
|
1418
|
+
* visual line by `y`, then the nearest offset on it by `x`. Because a table
|
|
1419
|
+
* row's cells share one horizontal line band, this makes the whole width of a
|
|
1420
|
+
* row resolve into that row (rather than only the cell boxes), with no visible
|
|
1421
|
+
* layout change. It also lets a drag keep extending toward off-viewport points
|
|
1422
|
+
* (e.g. the pointer leaving the window), which the platform hit-test cannot
|
|
1423
|
+
* resolve. Set to `false` to fall back to the platform DOM hit-test.
|
|
1424
|
+
*/
|
|
1425
|
+
readonly geometricHitTest: ISettableObservable<boolean, void>;
|
|
694
1426
|
/**
|
|
695
1427
|
* Client coordinates → absolute source offset (any block). Used during
|
|
696
1428
|
* drag to keep extending the selection even when the pointer leaves the
|
|
697
|
-
* original block.
|
|
1429
|
+
* original block. Honours {@link geometricHitTest}.
|
|
698
1430
|
*/
|
|
699
1431
|
resolveOffsetFromPoint(point: Point2D): SourceOffset | undefined;
|
|
1432
|
+
/**
|
|
1433
|
+
* Resolve table-cell hits that have no measurable text run. Empty cells map
|
|
1434
|
+
* from their own box instead of snapping to a neighboring cell; element-only
|
|
1435
|
+
* content (for example an inactive image) maps through the hit element's view
|
|
1436
|
+
* node. Text-bearing cells keep the normal pixel-precise line-map/DOM path.
|
|
1437
|
+
*/
|
|
1438
|
+
private _resolveTableCellOffset;
|
|
700
1439
|
/**
|
|
701
1440
|
* Whether a client point falls on the rendered document content, as
|
|
702
1441
|
* opposed to the surrounding editor padding (the green area). Uses DOM
|
|
@@ -706,6 +1445,14 @@ export declare class EditorView extends Disposable {
|
|
|
706
1445
|
* have `pointer-events: none`, so the hit-test sees through them.
|
|
707
1446
|
*/
|
|
708
1447
|
isPointInContent(point: Point2D): boolean;
|
|
1448
|
+
/**
|
|
1449
|
+
* Whether `range` intersects the rendered source text — the region whose
|
|
1450
|
+
* selection this editor paints itself from `model.selection`. This also
|
|
1451
|
+
* catches select-all ranges whose endpoints surround the rendered content.
|
|
1452
|
+
* Overlays anchored beside the text (comment widgets and the like) are *not*
|
|
1453
|
+
* part of it and keep their own native selection behaviour.
|
|
1454
|
+
*/
|
|
1455
|
+
intersectsRenderedContent(range: Range): boolean;
|
|
709
1456
|
private readonly _renderAutorun;
|
|
710
1457
|
/** Current mounted blocks, or empty before the first render. */
|
|
711
1458
|
private get _blocks();
|
|
@@ -715,6 +1462,18 @@ export declare class EditorView extends Disposable {
|
|
|
715
1462
|
* is not read here, so there is no feedback loop into the render autorun.
|
|
716
1463
|
*/
|
|
717
1464
|
private _publishMeasurements;
|
|
1465
|
+
/**
|
|
1466
|
+
* Paint the diff highlights via the CSS Custom Highlight API: green over the
|
|
1467
|
+
* inserted/changed modified ranges (mapped on the document's own DOM), and
|
|
1468
|
+
* red over each {@link DiffDecorationViewNode}'s deleted ranges (mapped on
|
|
1469
|
+
* the decoration's own subtree). No DOM is mutated, so reconciliation and
|
|
1470
|
+
* editing are unaffected.
|
|
1471
|
+
*/
|
|
1472
|
+
private _paintDiff;
|
|
1473
|
+
private _clearDiff;
|
|
1474
|
+
private _syncEditContextAttachment;
|
|
1475
|
+
private _revealRange;
|
|
1476
|
+
private _isRevealOccluded;
|
|
718
1477
|
}
|
|
719
1478
|
|
|
720
1479
|
export declare interface EditorViewOptions extends BlockViewOptions {
|
|
@@ -725,6 +1484,12 @@ export declare interface EditorViewOptions extends BlockViewOptions {
|
|
|
725
1484
|
* only) unless a theme class is supplied.
|
|
726
1485
|
*/
|
|
727
1486
|
readonly classNames?: readonly string[];
|
|
1487
|
+
/**
|
|
1488
|
+
* Whether to render the sticky edit/read-only toggle at the top-right edge
|
|
1489
|
+
* of the content. Defaults to `true`; set to `false` to omit it (e.g. in
|
|
1490
|
+
* fixtures that focus on selection rendering).
|
|
1491
|
+
*/
|
|
1492
|
+
readonly showReadonlyToggle?: boolean;
|
|
728
1493
|
/**
|
|
729
1494
|
* Controls "limited width mode". The observable yields the maximum content
|
|
730
1495
|
* width in pixels, or `undefined` to let the content fill the available
|
|
@@ -735,6 +1500,14 @@ export declare interface EditorViewOptions extends BlockViewOptions {
|
|
|
735
1500
|
* root ({@link element}) always spans the full available width.
|
|
736
1501
|
*/
|
|
737
1502
|
readonly limitedWidth?: IObservable<number | undefined>;
|
|
1503
|
+
/**
|
|
1504
|
+
* Diff mode only: render every read-only original decoration in active
|
|
1505
|
+
* (source) form, so even whole-block removals expose their markdown markers
|
|
1506
|
+
* as real text. Used by the diff-coverage fixture to verify that every
|
|
1507
|
+
* changed original character is rendered somewhere; off in normal use, where
|
|
1508
|
+
* whole removals show a clean solid band.
|
|
1509
|
+
*/
|
|
1510
|
+
readonly diffDecorationsActive?: boolean;
|
|
738
1511
|
}
|
|
739
1512
|
|
|
740
1513
|
export declare class EmphasisAstNode extends AstNode {
|
|
@@ -754,6 +1527,111 @@ declare class EmphasisViewData {
|
|
|
754
1527
|
constructor(ast: EmphasisAstNode, content: readonly AnyViewData[]);
|
|
755
1528
|
}
|
|
756
1529
|
|
|
1530
|
+
export declare function escapeFindRegex(value: string): string;
|
|
1531
|
+
|
|
1532
|
+
export declare const FIND_MATCH_LIMIT = 19999;
|
|
1533
|
+
|
|
1534
|
+
export declare function findBlockAtOffset(doc: DocumentAstNode, offset: SourceOffset): BlockAstNode | undefined;
|
|
1535
|
+
|
|
1536
|
+
export declare class FindController extends Disposable {
|
|
1537
|
+
private readonly _editorModel;
|
|
1538
|
+
private readonly _view;
|
|
1539
|
+
private readonly _options;
|
|
1540
|
+
readonly model: FindModel;
|
|
1541
|
+
readonly widget: FindWidget;
|
|
1542
|
+
private readonly _selectionForScope;
|
|
1543
|
+
private _forcedMatch;
|
|
1544
|
+
private _selectedMatch;
|
|
1545
|
+
private _observedSourceTextId;
|
|
1546
|
+
private readonly _sourceEditTracker;
|
|
1547
|
+
private _revealRequest;
|
|
1548
|
+
constructor(_editorModel: EditorModel, _view: EditorView, _options: FindControllerOptions);
|
|
1549
|
+
private _setForcedMarkerVisibleBlocks;
|
|
1550
|
+
openAndFocus(): void;
|
|
1551
|
+
close(): void;
|
|
1552
|
+
private _handleKeyDown;
|
|
1553
|
+
private _cancelRevealRequest;
|
|
1554
|
+
private _findByKeyboard;
|
|
1555
|
+
private _querySeed;
|
|
1556
|
+
private _prepareSeed;
|
|
1557
|
+
private _selectedSingleLineText;
|
|
1558
|
+
private _toggleFindInSelection;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
export declare interface FindControllerOptions {
|
|
1562
|
+
readonly keyboardPlatform: KeyboardPlatform;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
export declare type FindDirection = 'next' | 'previous';
|
|
1566
|
+
|
|
1567
|
+
export declare class FindHighlightsView extends Disposable {
|
|
1568
|
+
private readonly _view;
|
|
1569
|
+
private readonly _matchesLayer;
|
|
1570
|
+
private readonly _currentLayer;
|
|
1571
|
+
private readonly _highlightRegistration;
|
|
1572
|
+
private readonly _resizeObserver;
|
|
1573
|
+
private readonly _resizeObservedElements;
|
|
1574
|
+
private _snapshot;
|
|
1575
|
+
private _paintRaf;
|
|
1576
|
+
constructor(_view: EditorView, findModel: FindModel);
|
|
1577
|
+
private _schedulePaint;
|
|
1578
|
+
private _paint;
|
|
1579
|
+
private _observeResizeAncestors;
|
|
1580
|
+
private _paintRanges;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
export declare interface FindMatchesResult {
|
|
1584
|
+
readonly matches: readonly OffsetRange[];
|
|
1585
|
+
readonly isCapped: boolean;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
export declare class FindModel extends Disposable {
|
|
1589
|
+
private readonly _editorModel;
|
|
1590
|
+
readonly isRevealed: ISettableObservable<boolean, void>;
|
|
1591
|
+
readonly searchString: ISettableObservable<string, void>;
|
|
1592
|
+
readonly isRegex: ISettableObservable<boolean, void>;
|
|
1593
|
+
readonly matchCase: ISettableObservable<boolean, void>;
|
|
1594
|
+
readonly wholeWord: ISettableObservable<boolean, void>;
|
|
1595
|
+
readonly searchScope: ISettableObservable<OffsetRange | undefined, void>;
|
|
1596
|
+
readonly currentMatch: ISettableObservable<OffsetRange | undefined, void>;
|
|
1597
|
+
readonly loop: ISettableObservable<boolean, void>;
|
|
1598
|
+
readonly searchResult: IObservableWithChange< {
|
|
1599
|
+
kind: "invalid";
|
|
1600
|
+
error: Error;
|
|
1601
|
+
pattern?: undefined;
|
|
1602
|
+
matches?: undefined;
|
|
1603
|
+
isCapped?: undefined;
|
|
1604
|
+
} | {
|
|
1605
|
+
kind: "valid";
|
|
1606
|
+
pattern: FindPattern;
|
|
1607
|
+
matches: readonly OffsetRange[];
|
|
1608
|
+
isCapped: boolean;
|
|
1609
|
+
error?: undefined;
|
|
1610
|
+
}, void>;
|
|
1611
|
+
readonly matchesCount: IObservableWithChange<number, void>;
|
|
1612
|
+
readonly isCapped: IObservableWithChange<boolean, void>;
|
|
1613
|
+
readonly currentMatchPosition: IObservableWithChange<number, void>;
|
|
1614
|
+
private _searchOrigin;
|
|
1615
|
+
private readonly _sourceEditTracker;
|
|
1616
|
+
private _pendingInitialDirection;
|
|
1617
|
+
constructor(_editorModel: EditorModel);
|
|
1618
|
+
reveal(options: {
|
|
1619
|
+
readonly origin: number;
|
|
1620
|
+
readonly searchString?: string;
|
|
1621
|
+
readonly direction?: FindDirection;
|
|
1622
|
+
}): void;
|
|
1623
|
+
hide(): void;
|
|
1624
|
+
setSearchOrigin(offset: number): void;
|
|
1625
|
+
setSearchScope(scope: OffsetRange | undefined): void;
|
|
1626
|
+
moveToNextMatch(): OffsetRange | undefined;
|
|
1627
|
+
moveToPreviousMatch(): OffsetRange | undefined;
|
|
1628
|
+
private _move;
|
|
1629
|
+
private _selectFromOrigin;
|
|
1630
|
+
private _mapStateThroughEdit;
|
|
1631
|
+
private _inputSnapshot;
|
|
1632
|
+
private _readInputSnapshot;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
757
1635
|
/**
|
|
758
1636
|
* Source offset (relative to `root`) of the node with `target`'s id, or
|
|
759
1637
|
* `undefined` when it is not in the tree. Ids are stable across edits, so this
|
|
@@ -761,14 +1639,117 @@ declare class EmphasisViewData {
|
|
|
761
1639
|
*/
|
|
762
1640
|
export declare function findNodeOffsetById(root: AstNode, target: AstNode): number | undefined;
|
|
763
1641
|
|
|
764
|
-
export declare
|
|
1642
|
+
export declare class FindPattern {
|
|
1643
|
+
private readonly _source;
|
|
1644
|
+
private readonly _flags;
|
|
1645
|
+
private readonly _wholeWord;
|
|
1646
|
+
private readonly _wordSeparators;
|
|
1647
|
+
readonly isEmpty: boolean;
|
|
1648
|
+
private constructor();
|
|
1649
|
+
static create(query: FindQuery): FindQueryResult;
|
|
1650
|
+
findMatches(text: string, scope?: OffsetRange, limit?: number): FindMatchesResult;
|
|
1651
|
+
findNextMatch(text: string, after: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
|
|
1652
|
+
findPreviousMatch(text: string, before: number, scope?: OffsetRange, loop?: boolean, skip?: OffsetRange): OffsetRange | undefined;
|
|
1653
|
+
private _forEachMatch;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
export declare interface FindQuery {
|
|
1657
|
+
readonly searchString: string;
|
|
1658
|
+
readonly isRegex: boolean;
|
|
1659
|
+
readonly matchCase: boolean;
|
|
1660
|
+
readonly wholeWord: boolean;
|
|
1661
|
+
readonly wordSeparators: string;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
export declare type FindQueryResult = {
|
|
1665
|
+
readonly kind: 'valid';
|
|
1666
|
+
readonly pattern: FindPattern;
|
|
1667
|
+
} | {
|
|
1668
|
+
readonly kind: 'invalid';
|
|
1669
|
+
readonly error: Error;
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
export declare type FindSearchResult = {
|
|
1673
|
+
readonly kind: 'valid';
|
|
1674
|
+
readonly pattern: FindPattern;
|
|
1675
|
+
readonly matches: readonly OffsetRange[];
|
|
1676
|
+
readonly isCapped: boolean;
|
|
1677
|
+
} | {
|
|
1678
|
+
readonly kind: 'invalid';
|
|
1679
|
+
readonly error: Error;
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1682
|
+
export declare class FindWidget extends Disposable {
|
|
1683
|
+
private readonly _view;
|
|
1684
|
+
private readonly _options;
|
|
1685
|
+
readonly element: HTMLElement;
|
|
1686
|
+
readonly panelElement: HTMLElement;
|
|
1687
|
+
readonly focused: ISettableObservable<boolean, void>;
|
|
1688
|
+
private readonly _inputShell;
|
|
1689
|
+
private readonly _input;
|
|
1690
|
+
private readonly _matchesCount;
|
|
1691
|
+
private readonly _previousButton;
|
|
1692
|
+
private readonly _nextButton;
|
|
1693
|
+
private readonly _selectionButton;
|
|
1694
|
+
private readonly _caseButton;
|
|
1695
|
+
private readonly _wholeWordButton;
|
|
1696
|
+
private readonly _regexButton;
|
|
1697
|
+
private readonly _error;
|
|
1698
|
+
constructor(_view: EditorView, _options: FindWidgetOptions);
|
|
1699
|
+
focusAndSelect(): void;
|
|
1700
|
+
private _registerButton;
|
|
1701
|
+
private _render;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
export declare interface FindWidgetOptions {
|
|
1705
|
+
readonly findModel: FindModel;
|
|
1706
|
+
readonly canFindInSelection: IObservable<boolean>;
|
|
1707
|
+
readonly onNext: () => void;
|
|
1708
|
+
readonly onPrevious: () => void;
|
|
1709
|
+
readonly onToggleFindInSelection: () => void;
|
|
1710
|
+
readonly onClose: () => void;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
export declare function findWordAt(text: string, offset: number, config?: WordNavigationConfig): {
|
|
765
1714
|
start: number;
|
|
766
1715
|
end: number;
|
|
767
1716
|
};
|
|
768
1717
|
|
|
769
|
-
export declare function findWordBoundaryLeft(text: string, offset: number): number;
|
|
1718
|
+
export declare function findWordBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
|
|
1719
|
+
|
|
1720
|
+
export declare function findWordBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
|
|
1721
|
+
|
|
1722
|
+
export declare function findWordDeleteBoundaryLeft(text: string, offset: number, config?: WordNavigationConfig): number;
|
|
770
1723
|
|
|
771
|
-
export declare function
|
|
1724
|
+
export declare function findWordDeleteBoundaryRight(text: string, offset: number, config?: WordNavigationConfig): number;
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* A leading YAML front matter block. The YAML value is intentionally opaque:
|
|
1728
|
+
* only the two fences and the exact source between them are modeled.
|
|
1729
|
+
*/
|
|
1730
|
+
export declare class FrontMatterAstNode extends BlockAstNodeBase {
|
|
1731
|
+
readonly content: readonly (MarkerAstNode | GlueAstNode)[];
|
|
1732
|
+
readonly leadingTrivia?: GlueAstNode | undefined;
|
|
1733
|
+
readonly kind = "frontMatter";
|
|
1734
|
+
constructor(content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
|
|
1735
|
+
get children(): readonly AstNode[];
|
|
1736
|
+
get openFence(): MarkerAstNode | undefined;
|
|
1737
|
+
get closeFence(): MarkerAstNode | undefined;
|
|
1738
|
+
get value(): MarkerAstNode | undefined;
|
|
1739
|
+
mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
|
|
1740
|
+
withLeadingTrivia(trivia: GlueAstNode | undefined): FrontMatterAstNode;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
declare class FrontMatterViewData {
|
|
1744
|
+
readonly ast: FrontMatterAstNode;
|
|
1745
|
+
/** Active: render both fences; inactive: render only the opaque YAML value. */
|
|
1746
|
+
readonly showMarkup: boolean;
|
|
1747
|
+
readonly content: readonly AnyViewData[];
|
|
1748
|
+
readonly kind = "frontMatter";
|
|
1749
|
+
constructor(ast: FrontMatterAstNode,
|
|
1750
|
+
/** Active: render both fences; inactive: render only the opaque YAML value. */
|
|
1751
|
+
showMarkup: boolean, content: readonly AnyViewData[]);
|
|
1752
|
+
}
|
|
772
1753
|
|
|
773
1754
|
export declare function getAnnotatedSource(node: AstNode, source: string, offset?: number): string;
|
|
774
1755
|
|
|
@@ -845,6 +1826,19 @@ declare class HeadingViewData {
|
|
|
845
1826
|
constructor(ast: HeadingAstNode, content: readonly AnyViewData[]);
|
|
846
1827
|
}
|
|
847
1828
|
|
|
1829
|
+
export declare function hiddenCursorRanges(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number): readonly OffsetRange[];
|
|
1830
|
+
|
|
1831
|
+
export declare type HistoryKeyboardAction = 'undo' | 'redo';
|
|
1832
|
+
|
|
1833
|
+
/** A block HTML comment, discriminated by whether its closing delimiter is present. */
|
|
1834
|
+
declare type HtmlCommentSource = OpenHtmlCommentSource | CompleteHtmlCommentSource;
|
|
1835
|
+
|
|
1836
|
+
declare interface HtmlCommentSourceBase {
|
|
1837
|
+
readonly leadingWhitespace: string;
|
|
1838
|
+
readonly opening: '<!--';
|
|
1839
|
+
readonly body: string;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
848
1842
|
/**
|
|
849
1843
|
* The editor operations a clipboard strategy drives. The strategy never
|
|
850
1844
|
* touches the model or the DOM directly — it asks through this seam, so the
|
|
@@ -881,6 +1875,9 @@ export declare interface IClipboardStrategy {
|
|
|
881
1875
|
connect(context: IClipboardContext): IDisposable;
|
|
882
1876
|
}
|
|
883
1877
|
|
|
1878
|
+
/** A live rendering of a {@link CommentsModel}. Dispose to unmount it. */
|
|
1879
|
+
export declare type ICommentsPresenter = IDisposable;
|
|
1880
|
+
|
|
884
1881
|
/** The Monarch language definitions the default highlighter wires up. */
|
|
885
1882
|
export declare interface IDefaultMonarchGrammars {
|
|
886
1883
|
typescript: unknown;
|
|
@@ -890,6 +1887,87 @@ export declare interface IDefaultMonarchGrammars {
|
|
|
890
1887
|
python: unknown;
|
|
891
1888
|
rust: unknown;
|
|
892
1889
|
shell: unknown;
|
|
1890
|
+
yaml: unknown;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/**
|
|
1894
|
+
* A live editor embedded in place of a fenced code block's *rendered* form.
|
|
1895
|
+
*
|
|
1896
|
+
* This is the internal seam between the block view and a concrete embedded
|
|
1897
|
+
* editor (e.g. an `<iframe>` speaking the web-editor protocol). The block view
|
|
1898
|
+
* only speaks string edits: it pushes the block's content down via
|
|
1899
|
+
* {@link setContent} and receives the editor's own changes back through
|
|
1900
|
+
* {@link onEdit} (set by the block view on each (re)construction, so it always
|
|
1901
|
+
* routes to the current AST node). The concrete implementation owns its DOM,
|
|
1902
|
+
* transport, and lifecycle.
|
|
1903
|
+
*
|
|
1904
|
+
* A single instance is adopted across re-renders (like the highlighter session)
|
|
1905
|
+
* so the underlying editor keeps its state across edits — see
|
|
1906
|
+
* {@link CodeBlockViewNode}.
|
|
1907
|
+
*/
|
|
1908
|
+
declare interface IEmbeddedCodeEditor {
|
|
1909
|
+
/** The element mounted as the block's rendered form. */
|
|
1910
|
+
readonly element: HTMLElement;
|
|
1911
|
+
/**
|
|
1912
|
+
* Document → editor. The block's content changed (from any source). Must be
|
|
1913
|
+
* idempotent: pushing the content the editor already holds is a no-op, which
|
|
1914
|
+
* is how edits the editor itself originated are prevented from echoing back.
|
|
1915
|
+
*/
|
|
1916
|
+
setContent(content: string): void;
|
|
1917
|
+
/** Update whether the embedded editor may change its content. */
|
|
1918
|
+
setReadOnly?(readOnly: boolean): void;
|
|
1919
|
+
/**
|
|
1920
|
+
* Optional synchronous height (px) to reserve for `content` *before* the
|
|
1921
|
+
* editor has laid out. Return `undefined` to let the editor size itself
|
|
1922
|
+
* (the implementation may report its real height later). Lets a registration
|
|
1923
|
+
* avoid a layout jump when it can cheaply estimate the size from content.
|
|
1924
|
+
*/
|
|
1925
|
+
estimateHeight?(content: string): number | undefined;
|
|
1926
|
+
/**
|
|
1927
|
+
* Editor → document. Set by the block view on every (re)construction to
|
|
1928
|
+
* route the editor's own edits, expressed in the block's *content*
|
|
1929
|
+
* coordinates, to the current AST node.
|
|
1930
|
+
*/
|
|
1931
|
+
onEdit?: (edit: StringEdit) => void;
|
|
1932
|
+
dispose(): void;
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
/** Creates an {@link IEmbeddedCodeEditor} for a fenced block, or opts out. */
|
|
1936
|
+
declare interface IEmbeddedCodeEditorFactory {
|
|
1937
|
+
/**
|
|
1938
|
+
* Return an editor for a fenced block, or `undefined` to fall
|
|
1939
|
+
* back to the default (highlighting / {@link BlockViewOptions.renderCustomCodeBlock}).
|
|
1940
|
+
*/
|
|
1941
|
+
create(language: string, infoString: string, initialContent: string): IEmbeddedCodeEditor | undefined;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
/**
|
|
1945
|
+
* Routes undo and redo to whatever owns the document's history: the editor
|
|
1946
|
+
* itself on a standalone page, or the enclosing document in a host like
|
|
1947
|
+
* VS Code.
|
|
1948
|
+
*/
|
|
1949
|
+
export declare interface IHistoryStrategy {
|
|
1950
|
+
undo(): void;
|
|
1951
|
+
redo(): void;
|
|
1952
|
+
/**
|
|
1953
|
+
* Invoked around each source mutation so the strategy can record it.
|
|
1954
|
+
* Implemented only by strategies that build their own history; a host that
|
|
1955
|
+
* forwards edits to a VS Code `TextDocument` lets it record them instead.
|
|
1956
|
+
*/
|
|
1957
|
+
record?(operation: () => void, edit?: StringEdit): void;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
export declare interface ILinkPresentation extends IDisposable {
|
|
1961
|
+
/** Current presentation, updated without rebuilding the editor. */
|
|
1962
|
+
readonly presentation: IObservable<LinkPresentation | undefined>;
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
export declare interface ILinkPresentationProvider {
|
|
1966
|
+
/**
|
|
1967
|
+
* Returns `undefined` for unsupported links. The caller disposes the returned
|
|
1968
|
+
* reference when the rendered link disappears.
|
|
1969
|
+
*/
|
|
1970
|
+
createLinkPresentation(url: string): ILinkPresentation | undefined;
|
|
893
1971
|
}
|
|
894
1972
|
|
|
895
1973
|
export declare class ImageAstNode extends AstNode {
|
|
@@ -926,6 +2004,14 @@ export declare interface IMonarchApi {
|
|
|
926
2004
|
MonarchTokenizer: new (languageService: unknown, standaloneThemeService: unknown, languageId: string, lexer: unknown, configurationService: unknown) => MonarchTokenizer;
|
|
927
2005
|
}
|
|
928
2006
|
|
|
2007
|
+
/** Controls tab-stop insertion and non-list line indentation. */
|
|
2008
|
+
export declare interface IndentationConfig {
|
|
2009
|
+
/** Number of visual columns between tab stops. */
|
|
2010
|
+
readonly tabSize: number;
|
|
2011
|
+
/** Whether indentation uses spaces instead of tab characters. */
|
|
2012
|
+
readonly insertSpaces: boolean;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
929
2015
|
export declare type InlineAstNode = TextAstNode | StrongAstNode | EmphasisAstNode | StrikethroughAstNode | InlineCodeAstNode | InlineMathAstNode | LinkAstNode | ImageAstNode;
|
|
930
2016
|
|
|
931
2017
|
export declare class InlineCodeAstNode extends AstNode {
|
|
@@ -980,16 +2066,25 @@ export declare const insertParagraph: EditCommand;
|
|
|
980
2066
|
* - paragraph / heading / thematic break — the "rich text" thing: at the
|
|
981
2067
|
* block's end arm a transient empty paragraph (see {@link SmartEnterResult});
|
|
982
2068
|
* elsewhere split into two paragraphs (`\n\n`).
|
|
983
|
-
* - code
|
|
984
|
-
* staying inside the
|
|
2069
|
+
* - fenced code / front matter — insert a newline that preserves the current
|
|
2070
|
+
* line's indentation, staying inside the fences.
|
|
985
2071
|
* - block quote — continue the quote (`\n> `); an empty quote line exits it.
|
|
986
2072
|
* - list — continue the list with the next marker (incrementing ordered
|
|
987
2073
|
* numbers, re-emitting task checkboxes); an empty item exits the list.
|
|
2074
|
+
* - complete HTML comment — at the comment's end, leave it by arming a
|
|
2075
|
+
* transient paragraph; inside it (or while the comment is open), insert a
|
|
2076
|
+
* normal source line break.
|
|
988
2077
|
* A non-collapsed selection, or any other block, falls back to a plain soft line
|
|
989
2078
|
* break, preserving today's behaviour.
|
|
990
2079
|
*/
|
|
991
2080
|
export declare const insertSmartEnter: (ctx: CursorCommandContext) => SmartEnterResult;
|
|
992
2081
|
|
|
2082
|
+
/**
|
|
2083
|
+
* VS Code-style Tab: insert to the next tab stop for a caret or partial
|
|
2084
|
+
* single-line selection, and indent every selected line for a line selection.
|
|
2085
|
+
*/
|
|
2086
|
+
export declare function insertTab(config?: IndentationConfig): EditCommand;
|
|
2087
|
+
|
|
993
2088
|
export declare function insertText(text: string): EditCommand;
|
|
994
2089
|
|
|
995
2090
|
/**
|
|
@@ -1031,6 +2126,29 @@ export declare interface ISyntaxHighlighterDocument extends IDisposable {
|
|
|
1031
2126
|
readonly snapshot: IObservableWithChange<ISyntaxHighlightedSnapshot, LengthEdit>;
|
|
1032
2127
|
}
|
|
1033
2128
|
|
|
2129
|
+
export declare interface KeyboardBinding {
|
|
2130
|
+
readonly key: string;
|
|
2131
|
+
readonly modifiers?: KeyboardModifiers;
|
|
2132
|
+
readonly platforms?: readonly KeyboardPlatform[];
|
|
2133
|
+
readonly action: EditorKeyboardAction;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
export declare interface KeyboardModifiers {
|
|
2137
|
+
readonly shift?: boolean;
|
|
2138
|
+
readonly alt?: boolean;
|
|
2139
|
+
readonly ctrl?: boolean;
|
|
2140
|
+
readonly meta?: boolean;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
export declare type KeyboardPlatform = 'macos' | 'windows' | 'linux';
|
|
2144
|
+
|
|
2145
|
+
export declare interface KeyboardProfile {
|
|
2146
|
+
/**
|
|
2147
|
+
* Bindings in priority order. The first exact key/modifier/platform match wins.
|
|
2148
|
+
*/
|
|
2149
|
+
readonly bindings: readonly KeyboardBinding[];
|
|
2150
|
+
}
|
|
2151
|
+
|
|
1034
2152
|
declare abstract class LeafAstNode extends AstNode {
|
|
1035
2153
|
abstract readonly content: string;
|
|
1036
2154
|
get children(): readonly AstNode[];
|
|
@@ -1087,11 +2205,47 @@ export declare class LinkAstNode extends AstNode {
|
|
|
1087
2205
|
protected _localEquals(o: this): boolean;
|
|
1088
2206
|
}
|
|
1089
2207
|
|
|
2208
|
+
/**
|
|
2209
|
+
* Declarative rendering data for one link. `kind` selects the package-owned
|
|
2210
|
+
* visual treatment; providers never supply DOM or CSS.
|
|
2211
|
+
*/
|
|
2212
|
+
export declare interface LinkPresentation {
|
|
2213
|
+
readonly kind: LinkPresentationKind;
|
|
2214
|
+
readonly title?: string;
|
|
2215
|
+
readonly detail?: string;
|
|
2216
|
+
readonly reference?: string;
|
|
2217
|
+
/** Primary resource state, such as pull-request lifecycle or session state. */
|
|
2218
|
+
readonly status?: LinkPresentationStatus;
|
|
2219
|
+
/** Secondary state, such as pull-request CI status. */
|
|
2220
|
+
readonly secondaryStatus?: LinkPresentationStatus;
|
|
2221
|
+
readonly changes?: LinkPresentationChanges;
|
|
2222
|
+
readonly tooltip?: string;
|
|
2223
|
+
readonly ariaLabel?: string;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
declare interface LinkPresentationChanges {
|
|
2227
|
+
readonly insertions: number;
|
|
2228
|
+
readonly deletions: number;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
export declare type LinkPresentationKind = 'resource' | 'issue' | 'pullRequest' | 'commit' | 'file' | 'folder' | 'session' | 'repository' | 'branch';
|
|
2232
|
+
|
|
2233
|
+
export declare interface LinkPresentationStatus {
|
|
2234
|
+
readonly kind: LinkPresentationStatusKind;
|
|
2235
|
+
readonly label: string;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
export declare type LinkPresentationStatusKind = 'neutral' | 'pending' | 'success' | 'warning' | 'error' | 'open' | 'closed' | 'merged' | 'draft' | 'notPlanned';
|
|
2239
|
+
|
|
1090
2240
|
declare class LinkViewData {
|
|
1091
2241
|
readonly ast: LinkAstNode;
|
|
2242
|
+
/** Active: render the Markdown source; inactive: allow a rich presentation. */
|
|
2243
|
+
readonly showMarkup: boolean;
|
|
1092
2244
|
readonly content: readonly AnyViewData[];
|
|
1093
2245
|
readonly kind = "link";
|
|
1094
|
-
constructor(ast: LinkAstNode,
|
|
2246
|
+
constructor(ast: LinkAstNode,
|
|
2247
|
+
/** Active: render the Markdown source; inactive: allow a rich presentation. */
|
|
2248
|
+
showMarkup: boolean, content: readonly AnyViewData[]);
|
|
1095
2249
|
}
|
|
1096
2250
|
|
|
1097
2251
|
export declare class ListAstNode extends BlockAstNodeBase {
|
|
@@ -1128,12 +2282,26 @@ declare class ListItemViewData {
|
|
|
1128
2282
|
readonly content: readonly AnyViewData[];
|
|
1129
2283
|
/** 1-based list nesting depth, used to size the indentation gutter. */
|
|
1130
2284
|
readonly level: number;
|
|
2285
|
+
/**
|
|
2286
|
+
* Whether this is an inactive task item whose first paragraph begins
|
|
2287
|
+
* with the `:running:` marker (see {@link TextViewData.hiddenPrefixLength}).
|
|
2288
|
+
* Always `false` while the item is active — an active/editing task
|
|
2289
|
+
* reveals the literal marker instead of the progress affordance.
|
|
2290
|
+
*/
|
|
2291
|
+
readonly isRunning: boolean;
|
|
1131
2292
|
readonly kind = "listItem";
|
|
1132
2293
|
constructor(ast: ListItemAstNode,
|
|
1133
2294
|
/** Whether the selection reaches this item (reveals its markers). */
|
|
1134
2295
|
isActive: boolean, content: readonly AnyViewData[],
|
|
1135
2296
|
/** 1-based list nesting depth, used to size the indentation gutter. */
|
|
1136
|
-
level: number
|
|
2297
|
+
level: number,
|
|
2298
|
+
/**
|
|
2299
|
+
* Whether this is an inactive task item whose first paragraph begins
|
|
2300
|
+
* with the `:running:` marker (see {@link TextViewData.hiddenPrefixLength}).
|
|
2301
|
+
* Always `false` while the item is active — an active/editing task
|
|
2302
|
+
* reveals the literal marker instead of the progress affordance.
|
|
2303
|
+
*/
|
|
2304
|
+
isRunning?: boolean);
|
|
1137
2305
|
}
|
|
1138
2306
|
|
|
1139
2307
|
declare class ListViewData {
|
|
@@ -1143,6 +2311,32 @@ declare class ListViewData {
|
|
|
1143
2311
|
constructor(ast: ListAstNode, content: readonly AnyViewData[]);
|
|
1144
2312
|
}
|
|
1145
2313
|
|
|
2314
|
+
/**
|
|
2315
|
+
* Compact in-memory history for editors that hold the only copy of the
|
|
2316
|
+
* document, such as a standalone browser page. Where the surrounding host
|
|
2317
|
+
* already records history — a VS Code `TextDocument` — forward to that
|
|
2318
|
+
* instead.
|
|
2319
|
+
*/
|
|
2320
|
+
export declare class LocalHistoryStrategy implements IHistoryStrategy {
|
|
2321
|
+
private readonly _model;
|
|
2322
|
+
private readonly _past;
|
|
2323
|
+
private readonly _future;
|
|
2324
|
+
/**
|
|
2325
|
+
* The source text as of the last change this strategy recorded or applied.
|
|
2326
|
+
* Any other value means the document was replaced behind its back, so the
|
|
2327
|
+
* stored edits no longer line up and must be discarded rather than applied.
|
|
2328
|
+
*/
|
|
2329
|
+
private _lastKnownText;
|
|
2330
|
+
constructor(_model: EditorModel);
|
|
2331
|
+
record(operation: () => void, edit?: StringEdit): void;
|
|
2332
|
+
undo(): void;
|
|
2333
|
+
redo(): void;
|
|
2334
|
+
/** The entry on top of `stack`, or `undefined` when it cannot be applied. */
|
|
2335
|
+
private _peekApplicable;
|
|
2336
|
+
private _apply;
|
|
2337
|
+
private _clear;
|
|
2338
|
+
}
|
|
2339
|
+
|
|
1146
2340
|
/**
|
|
1147
2341
|
* Parses markdown into a {@link DocumentAstNode}.
|
|
1148
2342
|
*
|
|
@@ -1249,8 +2443,8 @@ export declare class MeasuredLayoutDebugRendering {
|
|
|
1249
2443
|
* Exposes two DOM nodes the caller can place independently:
|
|
1250
2444
|
*
|
|
1251
2445
|
* - {@link overlayElement} — absolutely positioned; the caller mounts it
|
|
1252
|
-
* inside the editor
|
|
1253
|
-
*
|
|
2446
|
+
* inside the editor overlay container so dashed line-bands and run-boxes
|
|
2447
|
+
* share the measured editor-local coordinates.
|
|
1254
2448
|
* - {@link infoElement} — block-flow; the caller mounts it as a sibling
|
|
1255
2449
|
* *below* the editor. Contains the per-block summary table that used
|
|
1256
2450
|
* to live on the overlay.
|
|
@@ -1261,7 +2455,6 @@ export declare class MeasuredLayoutDebugRendering {
|
|
|
1261
2455
|
* the derived subscribed.
|
|
1262
2456
|
*/
|
|
1263
2457
|
export declare class MeasuredLayoutDebugView extends Disposable {
|
|
1264
|
-
private readonly _overlayParent;
|
|
1265
2458
|
readonly overlayElement: HTMLElement;
|
|
1266
2459
|
readonly infoElement: HTMLElement;
|
|
1267
2460
|
readonly rendering: IObservable<MeasuredLayoutDebugRendering>;
|
|
@@ -1274,6 +2467,7 @@ export declare class MeasuredLayoutDebugView extends Disposable {
|
|
|
1274
2467
|
|
|
1275
2468
|
export declare interface MeasuredLayoutDebugViewOptions {
|
|
1276
2469
|
readonly model: MeasuredLayoutModel;
|
|
2470
|
+
readonly coordinateSpace: EditorCoordinateSpace;
|
|
1277
2471
|
/**
|
|
1278
2472
|
* DEBUG ONLY. Maps an absolute source offset to a fill color for that
|
|
1279
2473
|
* character's glyph rect. The fixture passes the same function to the
|
|
@@ -1306,14 +2500,16 @@ export declare interface MeasuredLayoutDebugViewOptions {
|
|
|
1306
2500
|
* through this model and never touches view fields directly.
|
|
1307
2501
|
*/
|
|
1308
2502
|
export declare class MeasuredLayoutModel {
|
|
1309
|
-
|
|
2503
|
+
private readonly _measurements;
|
|
2504
|
+
readonly measurements: IObservable<readonly BlockMeasurement[]>;
|
|
2505
|
+
private readonly _virtualLines;
|
|
1310
2506
|
/**
|
|
1311
|
-
* Concatenated visual line map across all mounted blocks.
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
* concatenation is well-formed without re-sorting.
|
|
2507
|
+
* Concatenated visual line map across all mounted blocks. Every per-block
|
|
2508
|
+
* map uses the same editor-local coordinate space, so concatenation is
|
|
2509
|
+
* well-formed without translation or re-sorting.
|
|
1315
2510
|
*/
|
|
1316
2511
|
readonly visualLineMap: IObservableWithChange<VisualLineMap, void>;
|
|
2512
|
+
setMeasurements(measurements: readonly BlockMeasurement[], virtualLines: readonly VirtualLineMeasurement[]): void;
|
|
1317
2513
|
}
|
|
1318
2514
|
|
|
1319
2515
|
/**
|
|
@@ -1353,14 +2549,25 @@ export declare class NativeClipboardStrategy implements IClipboardStrategy {
|
|
|
1353
2549
|
connect(context: IClipboardContext): IDisposable;
|
|
1354
2550
|
}
|
|
1355
2551
|
|
|
2552
|
+
declare interface NestedItem {
|
|
2553
|
+
readonly kind: 'nested';
|
|
2554
|
+
readonly original: AstNode;
|
|
2555
|
+
readonly originalStart: number;
|
|
2556
|
+
readonly modified: AstNode;
|
|
2557
|
+
readonly modifiedStart: number;
|
|
2558
|
+
readonly children: readonly DiffItem[];
|
|
2559
|
+
}
|
|
2560
|
+
|
|
1356
2561
|
/**
|
|
1357
2562
|
* Move the cursor one position left or right, skipping over hidden marker
|
|
1358
2563
|
* ranges in inactive blocks (and inactive items of an active list).
|
|
1359
2564
|
*/
|
|
1360
|
-
export declare function nextCursorPosition(doc: DocumentAstNode,
|
|
2565
|
+
export declare function nextCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, direction: 'left' | 'right'): number;
|
|
1361
2566
|
|
|
1362
2567
|
declare const NO_ACTIVE_BLOCKS: unique symbol;
|
|
1363
2568
|
|
|
2569
|
+
export declare function normalizeCursorPosition(doc: DocumentAstNode, markerVisibleBlocks: ReadonlySet<BlockAstNode>, cursor: number, target: number, direction: 'left' | 'right', includeHiddenRangeBoundary?: boolean): number;
|
|
2570
|
+
|
|
1364
2571
|
export declare class OffsetRange {
|
|
1365
2572
|
readonly start: number;
|
|
1366
2573
|
readonly endExclusive: number;
|
|
@@ -1388,6 +2595,14 @@ export declare class OffsetRange {
|
|
|
1388
2595
|
toString(): string;
|
|
1389
2596
|
}
|
|
1390
2597
|
|
|
2598
|
+
/** The lossless source slices of a block HTML comment whose closer has not been typed. */
|
|
2599
|
+
declare interface OpenHtmlCommentSource extends HtmlCommentSourceBase {
|
|
2600
|
+
readonly kind: 'open';
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
/** Outdent the current line, or every line touched by the selection. */
|
|
2604
|
+
export declare function outdent(config?: IndentationConfig): EditCommand;
|
|
2605
|
+
|
|
1391
2606
|
export declare class ParagraphAstNode extends BlockAstNodeBase {
|
|
1392
2607
|
readonly content: readonly (InlineAstNode | GlueAstNode)[];
|
|
1393
2608
|
readonly leadingTrivia?: GlueAstNode | undefined;
|
|
@@ -1406,23 +2621,32 @@ declare class ParagraphViewData {
|
|
|
1406
2621
|
}
|
|
1407
2622
|
|
|
1408
2623
|
/**
|
|
1409
|
-
* A *transient* editing state:
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
* user
|
|
2624
|
+
* A *transient* editing state: an empty paragraph adjacent to a real block.
|
|
2625
|
+
* Markdown has no empty-paragraph node, so this never lives in
|
|
2626
|
+
* {@link EditorModel['sourceText']} or the parsed {@link EditorModel.document}
|
|
2627
|
+
* — it is pure edit intent that the view renders as a synthetic blank line and
|
|
2628
|
+
* that the controller either *materializes* (the user types) or *cancels* (the
|
|
2629
|
+
* user navigates away / backspaces).
|
|
1415
2630
|
*/
|
|
1416
2631
|
declare interface PendingParagraph {
|
|
1417
|
-
/** The
|
|
2632
|
+
/** The block the blank line is rendered directly after. */
|
|
1418
2633
|
readonly anchorBlock: BlockAstNode;
|
|
1419
2634
|
/**
|
|
1420
2635
|
* Source region rewritten when the pending paragraph is materialized — the
|
|
1421
2636
|
* gap between {@link anchorBlock}'s text and whatever follows it.
|
|
1422
2637
|
*/
|
|
1423
2638
|
readonly replaceRange: OffsetRange;
|
|
2639
|
+
/** Whether materialized text needs a blank-line separator before it. */
|
|
2640
|
+
readonly separateFromPreviousBlock: boolean;
|
|
1424
2641
|
/** Whether {@link replaceRange} ends at the end of the document. */
|
|
1425
2642
|
readonly atEof: boolean;
|
|
2643
|
+
/**
|
|
2644
|
+
* Horizontal whitespace typed on the source-less line. It remains transient
|
|
2645
|
+
* until other input materializes the paragraph. Contains only spaces and tabs.
|
|
2646
|
+
*/
|
|
2647
|
+
readonly text: string;
|
|
2648
|
+
/** The source-less visual line occupied by the pending caret. */
|
|
2649
|
+
readonly cursorLine: VirtualCursorLine;
|
|
1426
2650
|
/**
|
|
1427
2651
|
* A throwaway AST node that exists only to give the synthetic view child a
|
|
1428
2652
|
* stable identity across render frames (the view pairs nodes by `ast.id`).
|
|
@@ -1431,21 +2655,51 @@ declare interface PendingParagraph {
|
|
|
1431
2655
|
readonly syntheticAst: ParagraphAstNode;
|
|
1432
2656
|
}
|
|
1433
2657
|
|
|
2658
|
+
declare interface PendingParagraphResult {
|
|
2659
|
+
readonly kind: 'pending';
|
|
2660
|
+
readonly anchorBlock: BlockAstNode;
|
|
2661
|
+
readonly replaceRange: OffsetRange;
|
|
2662
|
+
/** Whether materialized text needs a blank-line separator before it. */
|
|
2663
|
+
readonly separateFromPreviousBlock: boolean;
|
|
2664
|
+
readonly atEof: boolean;
|
|
2665
|
+
}
|
|
2666
|
+
|
|
1434
2667
|
/**
|
|
1435
2668
|
* View-data for the transient empty paragraph (see `PendingParagraph` in the
|
|
1436
|
-
* model). It carries
|
|
1437
|
-
* rendered
|
|
1438
|
-
*
|
|
1439
|
-
*
|
|
2669
|
+
* model). It carries the throwaway {@link ParagraphAstNode} that gives the
|
|
2670
|
+
* rendered line a stable identity across frames, its anchor block, source-less
|
|
2671
|
+
* cursor line, and transient horizontal whitespace. It has no source content or
|
|
2672
|
+
* selection range.
|
|
1440
2673
|
*/
|
|
1441
2674
|
declare class PendingParagraphViewData {
|
|
1442
2675
|
readonly ast: ParagraphAstNode;
|
|
2676
|
+
readonly anchorBlock: BlockAstNode;
|
|
2677
|
+
readonly cursorLine: VirtualCursorLine;
|
|
2678
|
+
readonly text: string;
|
|
1443
2679
|
readonly kind = "pendingParagraph";
|
|
1444
|
-
constructor(ast: ParagraphAstNode);
|
|
2680
|
+
constructor(ast: ParagraphAstNode, anchorBlock: BlockAstNode, cursorLine: VirtualCursorLine, text: string);
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
/**
|
|
2684
|
+
* The mounted transient empty paragraph: a `<p class="md-pending-paragraph">`
|
|
2685
|
+
* holding either a `<br>` or decorated transient horizontal whitespace. It is a
|
|
2686
|
+
* leaf view node with no inline source content; the document view publishes its
|
|
2687
|
+
* element geometry as a virtual visual line.
|
|
2688
|
+
*/
|
|
2689
|
+
declare class PendingParagraphViewNode extends ViewNode {
|
|
2690
|
+
readonly element: HTMLElement;
|
|
2691
|
+
readonly anchorBlock: BlockAstNode;
|
|
2692
|
+
readonly cursorLine: VirtualCursorLine;
|
|
2693
|
+
private _text;
|
|
2694
|
+
constructor(view: PendingParagraphViewData);
|
|
2695
|
+
update(text: string): void;
|
|
2696
|
+
getCaretClientRect(): DOMRect;
|
|
1445
2697
|
}
|
|
1446
2698
|
|
|
1447
2699
|
/**
|
|
1448
|
-
* Immutable point in
|
|
2700
|
+
* Immutable point in a caller-defined 2D CSS-pixel coordinate space.
|
|
2701
|
+
* Coordinate-owning APIs must document whether values are viewport-client or
|
|
2702
|
+
* editor-local; values from different spaces must not be mixed.
|
|
1449
2703
|
*/
|
|
1450
2704
|
export declare class Point2D {
|
|
1451
2705
|
readonly x: number;
|
|
@@ -1456,8 +2710,8 @@ export declare class Point2D {
|
|
|
1456
2710
|
}
|
|
1457
2711
|
|
|
1458
2712
|
/**
|
|
1459
|
-
* Immutable axis-aligned rectangle in
|
|
1460
|
-
*
|
|
2713
|
+
* Immutable axis-aligned rectangle in a caller-defined 2D CSS-pixel coordinate
|
|
2714
|
+
* space. `x`/`y` is the top-left corner, growing right/down.
|
|
1461
2715
|
*
|
|
1462
2716
|
* Half-open in both dimensions: `right` and `bottom` are excluded.
|
|
1463
2717
|
*/
|
|
@@ -1483,6 +2737,48 @@ export declare class Rect2D {
|
|
|
1483
2737
|
translate(dx: number, dy: number): Rect2D;
|
|
1484
2738
|
}
|
|
1485
2739
|
|
|
2740
|
+
declare interface RemovedItem {
|
|
2741
|
+
readonly kind: 'removed';
|
|
2742
|
+
readonly node: AstNode;
|
|
2743
|
+
readonly originalStart: number;
|
|
2744
|
+
readonly deletedLocal: readonly AnnotatedRange[];
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
declare interface ReplacedItem {
|
|
2748
|
+
readonly kind: 'replaced';
|
|
2749
|
+
readonly original: AstNode;
|
|
2750
|
+
readonly originalStart: number;
|
|
2751
|
+
readonly modified: AstNode;
|
|
2752
|
+
readonly modifiedStart: number;
|
|
2753
|
+
readonly insertedLocal: readonly AnnotatedRange[];
|
|
2754
|
+
readonly deletedLocal: readonly AnnotatedRange[];
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
export declare class RichLink {
|
|
2758
|
+
static create(options: RichLinkOptions): RichLink;
|
|
2759
|
+
static mount(element: HTMLElement, authoredLabel: HTMLSpanElement): RichLink;
|
|
2760
|
+
static clear(element: HTMLElement): void;
|
|
2761
|
+
readonly element: HTMLElement;
|
|
2762
|
+
readonly authoredLabel: HTMLSpanElement;
|
|
2763
|
+
private readonly _icon;
|
|
2764
|
+
private readonly _title;
|
|
2765
|
+
private readonly _detail;
|
|
2766
|
+
private readonly _reference;
|
|
2767
|
+
private readonly _changes;
|
|
2768
|
+
private readonly _status;
|
|
2769
|
+
private readonly _secondaryStatus;
|
|
2770
|
+
private constructor();
|
|
2771
|
+
update(presentation: LinkPresentation | undefined): void;
|
|
2772
|
+
private _renderUnavailable;
|
|
2773
|
+
private _setDefaultOrder;
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
export declare interface RichLinkOptions {
|
|
2777
|
+
readonly href: string;
|
|
2778
|
+
readonly authoredLabel: string;
|
|
2779
|
+
readonly presentation?: LinkPresentation;
|
|
2780
|
+
}
|
|
2781
|
+
|
|
1486
2782
|
export declare const selectAll: SelectionCommand;
|
|
1487
2783
|
|
|
1488
2784
|
export declare function selectBlock(ctx: CursorCommandContext, blockRange: OffsetRange): Selection_2;
|
|
@@ -1508,8 +2804,13 @@ export { Selection_2 as Selection }
|
|
|
1508
2804
|
export declare interface SelectionBlock {
|
|
1509
2805
|
readonly block: BlockAstNode;
|
|
1510
2806
|
readonly absoluteStart: number;
|
|
1511
|
-
|
|
1512
|
-
readonly
|
|
2807
|
+
/** Block border box in editor-local coordinates. */
|
|
2808
|
+
readonly rect: Rect2D;
|
|
2809
|
+
/** Visible horizontal padding-box bounds for a scrolling block. */
|
|
2810
|
+
readonly viewportClip: {
|
|
2811
|
+
readonly left: number;
|
|
2812
|
+
readonly right: number;
|
|
2813
|
+
} | undefined;
|
|
1513
2814
|
}
|
|
1514
2815
|
|
|
1515
2816
|
export declare type SelectionCommand = (ctx: CursorCommandContext, offset: SourceOffset) => Selection_2;
|
|
@@ -1521,6 +2822,9 @@ export declare interface SelectionRect {
|
|
|
1521
2822
|
readonly height: number;
|
|
1522
2823
|
}
|
|
1523
2824
|
|
|
2825
|
+
/** The interaction that produced the current editor selection. */
|
|
2826
|
+
export declare type SelectionSource = 'user' | 'find';
|
|
2827
|
+
|
|
1524
2828
|
/**
|
|
1525
2829
|
* Owns the SVG overlay that paints the selection.
|
|
1526
2830
|
*
|
|
@@ -1541,11 +2845,10 @@ export declare interface SelectionRect {
|
|
|
1541
2845
|
* envelope shape used by IDE selection rendering.
|
|
1542
2846
|
*/
|
|
1543
2847
|
export declare class SelectionView extends Disposable {
|
|
1544
|
-
private readonly _parent;
|
|
1545
2848
|
readonly element: SVGSVGElement;
|
|
1546
2849
|
readonly rendering: IObservable<SelectionViewRendering>;
|
|
1547
2850
|
private readonly _path;
|
|
1548
|
-
constructor(
|
|
2851
|
+
constructor(options: SelectionViewOptions);
|
|
1549
2852
|
}
|
|
1550
2853
|
|
|
1551
2854
|
export declare interface SelectionViewOptions {
|
|
@@ -1573,12 +2876,7 @@ export declare type SmartEnterResult = {
|
|
|
1573
2876
|
readonly kind: 'edit';
|
|
1574
2877
|
readonly edit: StringEdit;
|
|
1575
2878
|
readonly selection: Selection_2;
|
|
1576
|
-
} |
|
|
1577
|
-
readonly kind: 'pending';
|
|
1578
|
-
readonly anchorBlock: BlockAstNode;
|
|
1579
|
-
readonly replaceRange: OffsetRange;
|
|
1580
|
-
readonly atEof: boolean;
|
|
1581
|
-
};
|
|
2879
|
+
} | PendingParagraphResult;
|
|
1582
2880
|
|
|
1583
2881
|
/**
|
|
1584
2882
|
* A run of {@link Token}s together with the exact {@link OffsetRange} they
|
|
@@ -1593,8 +2891,39 @@ export declare interface SnapshotTokens {
|
|
|
1593
2891
|
readonly tokens: readonly Token[];
|
|
1594
2892
|
}
|
|
1595
2893
|
|
|
2894
|
+
/** Metadata delivered synchronously immediately before a model-owned source edit is applied. */
|
|
2895
|
+
export declare interface SourceEditEvent {
|
|
2896
|
+
readonly baseSourceTextId: number;
|
|
2897
|
+
readonly resultSourceTextId: number;
|
|
2898
|
+
readonly edit: StringEdit;
|
|
2899
|
+
readonly transaction: ITransaction;
|
|
2900
|
+
}
|
|
2901
|
+
|
|
1596
2902
|
export declare type SourceOffset = number;
|
|
1597
2903
|
|
|
2904
|
+
export declare abstract class StackedCommentsPresenter extends Disposable implements ICommentsPresenter {
|
|
2905
|
+
protected readonly model: CommentsModel;
|
|
2906
|
+
protected readonly view: EditorView;
|
|
2907
|
+
protected readonly context?: CommentsPresenterContext | undefined;
|
|
2908
|
+
private readonly _layer;
|
|
2909
|
+
private readonly _entries;
|
|
2910
|
+
private _order;
|
|
2911
|
+
private _pendingRevealCommentId;
|
|
2912
|
+
constructor(model: CommentsModel, view: EditorView, context?: CommentsPresenterContext | undefined);
|
|
2913
|
+
/** Build the card DOM for a comment. Called once per new comment. */
|
|
2914
|
+
protected abstract createWidget(comment: Comment_2): StackWidget;
|
|
2915
|
+
revealComment(id: string): void;
|
|
2916
|
+
private _reconcile;
|
|
2917
|
+
private _relayout;
|
|
2918
|
+
private _revealPendingComment;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
/** The minimal widget contract a subclass must produce. */
|
|
2922
|
+
export declare interface StackWidget {
|
|
2923
|
+
readonly element: HTMLElement;
|
|
2924
|
+
dispose(): void;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
1598
2927
|
export declare class StrikethroughAstNode extends AstNode {
|
|
1599
2928
|
readonly openMarker: MarkerAstNode;
|
|
1600
2929
|
readonly content: readonly (InlineAstNode | GlueAstNode)[];
|
|
@@ -1637,6 +2966,11 @@ export declare class StringReplacement {
|
|
|
1637
2966
|
constructor(replaceRange: OffsetRange, newText: string);
|
|
1638
2967
|
get isEmpty(): boolean;
|
|
1639
2968
|
equals(other: StringReplacement): boolean;
|
|
2969
|
+
/**
|
|
2970
|
+
* Narrows this replacement to the span that actually changes, by trimming
|
|
2971
|
+
* the prefix and suffix it shares with the text it replaces in `source`.
|
|
2972
|
+
*/
|
|
2973
|
+
removeCommonSuffixPrefix(source: string): StringReplacement;
|
|
1640
2974
|
toString(): string;
|
|
1641
2975
|
}
|
|
1642
2976
|
|
|
@@ -1665,6 +2999,8 @@ declare class StrongViewData {
|
|
|
1665
2999
|
constructor(ast: StrongAstNode, content: readonly AnyViewData[]);
|
|
1666
3000
|
}
|
|
1667
3001
|
|
|
3002
|
+
export declare type TabKeyboardAction = 'insert' | 'outdent';
|
|
3003
|
+
|
|
1668
3004
|
export declare class TableAstNode extends BlockAstNodeBase {
|
|
1669
3005
|
readonly content: readonly (TableRowAstNode | GlueAstNode)[];
|
|
1670
3006
|
readonly leadingTrivia?: GlueAstNode | undefined;
|
|
@@ -1747,6 +3083,13 @@ declare class TextViewData {
|
|
|
1747
3083
|
readonly showWhitespace: boolean;
|
|
1748
3084
|
readonly leftWordBoundary: boolean;
|
|
1749
3085
|
readonly rightWordBoundary: boolean;
|
|
3086
|
+
/**
|
|
3087
|
+
* Number of leading source characters to keep out of the rendered
|
|
3088
|
+
* text (but not out of the source): the `:running:` marker plus its
|
|
3089
|
+
* mandatory leading separator, once
|
|
3090
|
+
* {@link isRunnerMarkerText} has matched this node. Zero otherwise.
|
|
3091
|
+
*/
|
|
3092
|
+
readonly hiddenPrefixLength: number;
|
|
1750
3093
|
readonly kind = "text";
|
|
1751
3094
|
/**
|
|
1752
3095
|
* Whether non-obvious whitespace in this text is revealed (block is active).
|
|
@@ -1755,7 +3098,14 @@ declare class TextViewData {
|
|
|
1755
3098
|
* emphasis); a single space touching such a sibling is obvious and stays
|
|
1756
3099
|
* undecorated, just like a space between two words within this leaf.
|
|
1757
3100
|
*/
|
|
1758
|
-
constructor(ast: TextAstNode, showWhitespace: boolean, leftWordBoundary?: boolean, rightWordBoundary?: boolean
|
|
3101
|
+
constructor(ast: TextAstNode, showWhitespace: boolean, leftWordBoundary?: boolean, rightWordBoundary?: boolean,
|
|
3102
|
+
/**
|
|
3103
|
+
* Number of leading source characters to keep out of the rendered
|
|
3104
|
+
* text (but not out of the source): the `:running:` marker plus its
|
|
3105
|
+
* mandatory leading separator, once
|
|
3106
|
+
* {@link isRunnerMarkerText} has matched this node. Zero otherwise.
|
|
3107
|
+
*/
|
|
3108
|
+
hiddenPrefixLength?: number);
|
|
1759
3109
|
}
|
|
1760
3110
|
|
|
1761
3111
|
export declare class ThematicBreakAstNode extends BlockAstNodeBase {
|
|
@@ -1799,6 +3149,55 @@ export declare class Token {
|
|
|
1799
3149
|
className: string | undefined);
|
|
1800
3150
|
}
|
|
1801
3151
|
|
|
3152
|
+
declare interface UnchangedItem {
|
|
3153
|
+
readonly kind: 'unchanged';
|
|
3154
|
+
/** The modified-side node (identical in content to the original). */
|
|
3155
|
+
readonly node: AstNode;
|
|
3156
|
+
readonly modifiedStart: number;
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
/**
|
|
3160
|
+
* A block whose token type the parser does not understand (a setext heading or
|
|
3161
|
+
* any future/extension construct). Rather than dropping the
|
|
3162
|
+
* span — which would demote its text to invisible glue — the parser captures the
|
|
3163
|
+
* whole source range verbatim as a single {@link MarkerAstNode} of kind
|
|
3164
|
+
* `content` and records the originating micromark {@link tokenType}, so the view
|
|
3165
|
+
* can render it as raw, editable text with an "unhandled" affordance. Offsets
|
|
3166
|
+
* stay sound: `content` tiles the block's full source span exactly.
|
|
3167
|
+
*/
|
|
3168
|
+
declare class UnhandledBlockAstNode extends BlockAstNodeBase {
|
|
3169
|
+
readonly tokenType: string;
|
|
3170
|
+
readonly content: readonly (MarkerAstNode | GlueAstNode)[];
|
|
3171
|
+
readonly leadingTrivia?: GlueAstNode | undefined;
|
|
3172
|
+
readonly kind = "unhandledBlock";
|
|
3173
|
+
constructor(tokenType: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
|
|
3174
|
+
get children(): readonly AstNode[];
|
|
3175
|
+
get code(): MarkerAstNode | undefined;
|
|
3176
|
+
/**
|
|
3177
|
+
* Lossless slices when this raw HTML block starts one comment after optional
|
|
3178
|
+
* whitespace. An open comment consumes the remaining source as its body. A
|
|
3179
|
+
* complete comment permits only trailing whitespace after its closer.
|
|
3180
|
+
*/
|
|
3181
|
+
get htmlComment(): HtmlCommentSource | undefined;
|
|
3182
|
+
mapChildren(m: ReadonlyMap<AstNode, AstNode>): AstNode;
|
|
3183
|
+
withLeadingTrivia(trivia: GlueAstNode | undefined): UnhandledBlockAstNode;
|
|
3184
|
+
protected _localEquals(o: this): boolean;
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3187
|
+
/**
|
|
3188
|
+
* View-data for an {@link UnhandledBlockAstNode}. The source remains verbatim
|
|
3189
|
+
* in both states. Complete HTML comments use {@link showMarkup} to switch
|
|
3190
|
+
* between their quiet reading treatment and editable source presentation;
|
|
3191
|
+
* other unhandled blocks ignore the flag and keep their warning treatment.
|
|
3192
|
+
*/
|
|
3193
|
+
declare class UnhandledBlockViewData {
|
|
3194
|
+
readonly ast: UnhandledBlockAstNode;
|
|
3195
|
+
readonly showMarkup: boolean;
|
|
3196
|
+
readonly content: readonly AnyViewData[];
|
|
3197
|
+
readonly kind = "unhandledBlock";
|
|
3198
|
+
constructor(ast: UnhandledBlockAstNode, showMarkup: boolean, content: readonly AnyViewData[]);
|
|
3199
|
+
}
|
|
3200
|
+
|
|
1802
3201
|
/**
|
|
1803
3202
|
* Immutable view of an AST node. Pairs `ast` with its rendered `dom` and a
|
|
1804
3203
|
* mirror of `ast.children` as ViewNode children. Source offsets are NEVER
|
|
@@ -1863,10 +3262,12 @@ export declare class ViewNode extends Disposable {
|
|
|
1863
3262
|
/**
|
|
1864
3263
|
* Map a DOM hit that lands on THIS node's own representation into a source
|
|
1865
3264
|
* range in this node's local space `[0, ast.length)`. Polymorphic: a text
|
|
1866
|
-
* leaf maps the caret offset 1:1
|
|
1867
|
-
* an image, a hidden marker)
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
3265
|
+
* leaf maps the caret offset 1:1. For an element hit — an element-only node
|
|
3266
|
+
* (KaTeX math, `<hr>`, an image, a hidden marker) or a wrapper/container
|
|
3267
|
+
* element — the platform reports a child-index offset, not a text caret, so
|
|
3268
|
+
* there is no internal mapping to honour: it snaps to the node's nearer
|
|
3269
|
+
* edge, `offset 0` (the "before" side) → start, any `offset >= 1` (the
|
|
3270
|
+
* "after" side) → end. Subclasses may override for finer control.
|
|
1870
3271
|
*/
|
|
1871
3272
|
getLocalSourceRange(pos: DomPosition): OffsetRange;
|
|
1872
3273
|
/**
|
|
@@ -1888,6 +3289,24 @@ export declare class ViewNode extends Disposable {
|
|
|
1888
3289
|
forEachTextLeaf(nodeOffset: number, visitor: (leaf: ViewNode, leafOffset: number) => void): void;
|
|
1889
3290
|
}
|
|
1890
3291
|
|
|
3292
|
+
/**
|
|
3293
|
+
* A visual cursor line that has no representation in the source text.
|
|
3294
|
+
*
|
|
3295
|
+
* The two source offsets are the positions immediately before and after the
|
|
3296
|
+
* virtual line. The object itself is the stable identity of the line.
|
|
3297
|
+
*/
|
|
3298
|
+
export declare class VirtualCursorLine {
|
|
3299
|
+
readonly sourceOffsetBefore: SourceOffset;
|
|
3300
|
+
readonly sourceOffsetAfter: SourceOffset;
|
|
3301
|
+
constructor(sourceOffsetBefore: SourceOffset, sourceOffsetAfter: SourceOffset);
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
/** A measured source-less line inserted directly after a source block. */
|
|
3305
|
+
declare interface VirtualLineMeasurement {
|
|
3306
|
+
readonly afterBlock: BlockAstNode;
|
|
3307
|
+
readonly line: VisualLine;
|
|
3308
|
+
}
|
|
3309
|
+
|
|
1891
3310
|
export declare type VisualCursorCommand = (ctx: VisualCursorCommandContext) => CursorMoveResult;
|
|
1892
3311
|
|
|
1893
3312
|
export declare interface VisualCursorCommandContext extends CursorCommandContext {
|
|
@@ -1905,12 +3324,15 @@ export declare function visualizeAst(root: AstNode, source: string): AstVisualiz
|
|
|
1905
3324
|
export declare class VisualLine {
|
|
1906
3325
|
readonly rect: Rect2D;
|
|
1907
3326
|
readonly runs: readonly VisualRun[];
|
|
1908
|
-
|
|
3327
|
+
readonly virtualCursorLine?: VirtualCursorLine | undefined;
|
|
3328
|
+
static virtual(cursorLine: VirtualCursorLine, rect: Rect2D): VisualLine;
|
|
3329
|
+
constructor(rect: Rect2D, runs: readonly VisualRun[], virtualCursorLine?: VirtualCursorLine | undefined);
|
|
1909
3330
|
containsOffset(offset: SourceOffset): boolean;
|
|
1910
3331
|
/**
|
|
1911
3332
|
* How `offset` relates to this line's runs:
|
|
1912
3333
|
* - `'covers'`: a run starts at or strictly contains the offset
|
|
1913
|
-
* (`start <= offset < endExclusive`)
|
|
3334
|
+
* (`start <= offset < endExclusive`), or a zero-length visual-line
|
|
3335
|
+
* anchor sits at the offset — the caret belongs on this line.
|
|
1914
3336
|
* - `'end'`: the offset is only some run's trailing boundary
|
|
1915
3337
|
* (`offset === endExclusive`) with no run covering it — a line-break
|
|
1916
3338
|
* boundary the caret should leave for the next line.
|
|
@@ -1923,23 +3345,42 @@ export declare class VisualLine {
|
|
|
1923
3345
|
*/
|
|
1924
3346
|
sourceDistanceTo(offset: SourceOffset): number;
|
|
1925
3347
|
/**
|
|
1926
|
-
* x of the caret position before `offset` on this line.
|
|
1927
|
-
*
|
|
1928
|
-
*
|
|
1929
|
-
*
|
|
3348
|
+
* x of the caret position before `offset` on this line.
|
|
3349
|
+
*
|
|
3350
|
+
* The runs tile the source but are stored in paint order, not sorted by
|
|
3351
|
+
* source offset (hidden-marker runs are appended last). So this scans all
|
|
3352
|
+
* runs rather than assuming any ordering:
|
|
3353
|
+
*
|
|
3354
|
+
* - A zero-source visual anchor owns its exact offset, so a marker-only line
|
|
3355
|
+
* wins over the preceding line's inclusive end boundary.
|
|
3356
|
+
* - Otherwise a run starting at `offset` owns that seam. This keeps an
|
|
3357
|
+
* out-of-flow prefix from placing the caret at its trailing edge when the
|
|
3358
|
+
* following body starts at a visually separate x.
|
|
3359
|
+
* - Otherwise, if some run *covers* `offset`, its own geometry places the
|
|
3360
|
+
* caret (exact glyph boundary for text runs). In the active,
|
|
3361
|
+
* markers-visible form every interior offset is covered, so this branch
|
|
3362
|
+
* keeps distinct offsets distinct.
|
|
3363
|
+
* - Otherwise `offset` sits in a gap — a hidden inline marker such as the
|
|
3364
|
+
* `**` of `**bold**`, or before/after the painted text. It snaps to the
|
|
3365
|
+
* seam between the source-nearest runs on either side: the right edge of
|
|
3366
|
+
* the closest run ending at/before `offset`, else the left edge of the
|
|
3367
|
+
* closest run starting at/after it. A hidden marker collapses to zero
|
|
3368
|
+
* width, so both edges coincide at the seam.
|
|
1930
3369
|
*/
|
|
1931
3370
|
xAtOffset(offset: SourceOffset): number;
|
|
1932
3371
|
/**
|
|
1933
3372
|
* Snap `x` to the nearest offset on this line. If `x` falls inside a
|
|
1934
|
-
* run, the offset
|
|
1935
|
-
*
|
|
3373
|
+
* run, the run resolves the offset (exact glyph boundary for text runs,
|
|
3374
|
+
* nearer edge for source-less runs); otherwise it snaps to the closer
|
|
3375
|
+
* edge of the nearest run.
|
|
1936
3376
|
*/
|
|
1937
3377
|
offsetAtX(x: number): SourceOffset;
|
|
1938
3378
|
}
|
|
1939
3379
|
|
|
1940
3380
|
/**
|
|
1941
3381
|
* Geometry of the rendered document, as a map from source offsets to 2D
|
|
1942
|
-
* positions and back.
|
|
3382
|
+
* positions and back. All geometry is expressed in the editor overlay's local
|
|
3383
|
+
* CSS-pixel coordinate space.
|
|
1943
3384
|
*
|
|
1944
3385
|
* Structure (top to bottom):
|
|
1945
3386
|
*
|
|
@@ -1974,7 +3415,9 @@ export declare class VisualLineMap {
|
|
|
1974
3415
|
static measure(blockViews: readonly {
|
|
1975
3416
|
readonly absoluteStart: number;
|
|
1976
3417
|
readonly viewNode: ViewNode;
|
|
1977
|
-
}[]): VisualLineMap;
|
|
3418
|
+
}[], coordinateSpace: EditorCoordinateSpace, transform?: EditorCoordinateTransform): VisualLineMap;
|
|
3419
|
+
/** Lines backed by source ranges, excluding source-less cursor lines. */
|
|
3420
|
+
readonly sourceLines: readonly VisualLine[];
|
|
1978
3421
|
constructor(lines: readonly VisualLine[]);
|
|
1979
3422
|
get lineCount(): number;
|
|
1980
3423
|
get isEmpty(): boolean;
|
|
@@ -1999,6 +3442,12 @@ export declare class VisualLineMap {
|
|
|
1999
3442
|
* {@link lineIndexOfOffset}. Returns `0` when the map is empty.
|
|
2000
3443
|
*/
|
|
2001
3444
|
xAtOffset(offset: SourceOffset): number;
|
|
3445
|
+
/**
|
|
3446
|
+
* Line occupied by a source or virtual cursor position. A virtual position
|
|
3447
|
+
* returns `undefined` until its corresponding DOM line has been measured.
|
|
3448
|
+
*/
|
|
3449
|
+
lineIndexOfPosition(position: CursorPosition): number | undefined;
|
|
3450
|
+
xAtPosition(position: CursorPosition): number;
|
|
2002
3451
|
/**
|
|
2003
3452
|
* Line whose vertical band contains `y`, clamped to the first/last
|
|
2004
3453
|
* line when `y` is outside the document.
|
|
@@ -2012,6 +3461,9 @@ export declare class VisualLineMap {
|
|
|
2012
3461
|
offsetAtPoint(point: Point2D): SourceOffset;
|
|
2013
3462
|
/** Snap `x` to the nearest offset on a specific line. */
|
|
2014
3463
|
offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
|
|
3464
|
+
positionInLineAtX(lineIndex: number, x: number): CursorPosition;
|
|
3465
|
+
lineStartOffset(lineIndex: number): SourceOffset | undefined;
|
|
3466
|
+
lineEndOffset(lineIndex: number): SourceOffset | undefined;
|
|
2015
3467
|
}
|
|
2016
3468
|
|
|
2017
3469
|
/**
|
|
@@ -2020,14 +3472,22 @@ export declare class VisualLineMap {
|
|
|
2020
3472
|
* When constructed with a {@link VisualRunSource}, `xAtOffset` returns the
|
|
2021
3473
|
* pixel-exact x of the caret before character `offset` by measuring the
|
|
2022
3474
|
* prefix `[textNodeStart, textNodeStart + (offset - sourceStart))` with a
|
|
2023
|
-
* DOM `Range`.
|
|
2024
|
-
*
|
|
3475
|
+
* DOM `Range`.
|
|
3476
|
+
*
|
|
3477
|
+
* A source-less run has no per-offset geometry: it either represents an
|
|
3478
|
+
* element-only block (KaTeX math, a mermaid/custom diagram, an image, an
|
|
3479
|
+
* inactive `<hr>`) whose box does not correspond to source offsets, or a
|
|
3480
|
+
* hand-built run in a test. Either way it maps between offsets and x by
|
|
3481
|
+
* snapping to the nearer edge of {@link rect} rather than fabricating
|
|
3482
|
+
* interior positions.
|
|
2025
3483
|
*/
|
|
2026
3484
|
export declare class VisualRun {
|
|
2027
3485
|
readonly sourceRange: OffsetRange;
|
|
2028
3486
|
readonly rect: Rect2D;
|
|
2029
3487
|
readonly source?: VisualRunSource | undefined;
|
|
2030
|
-
|
|
3488
|
+
readonly isVisualLineAnchor: boolean;
|
|
3489
|
+
static visualLineAnchor(sourceOffset: SourceOffset, rect: Rect2D): VisualRun;
|
|
3490
|
+
constructor(sourceRange: OffsetRange, rect: Rect2D, source?: VisualRunSource | undefined, isVisualLineAnchor?: boolean);
|
|
2031
3491
|
get sourceStart(): SourceOffset;
|
|
2032
3492
|
get sourceEndExclusive(): SourceOffset;
|
|
2033
3493
|
get sourceLength(): number;
|
|
@@ -2039,19 +3499,40 @@ export declare class VisualRun {
|
|
|
2039
3499
|
|
|
2040
3500
|
/**
|
|
2041
3501
|
* The DOM source of a {@link VisualRun}. When set, `xAtOffset` and
|
|
2042
|
-
* `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect
|
|
2043
|
-
*
|
|
2044
|
-
*
|
|
2045
|
-
*
|
|
2046
|
-
* wrong character.
|
|
3502
|
+
* `offsetAtX` measure exact glyph positions via `Range.getBoundingClientRect`.
|
|
3503
|
+
* This matters for proportional fonts where character widths differ a lot
|
|
3504
|
+
* (e.g. `m` vs `i`): a caret placed by anything coarser than real glyph
|
|
3505
|
+
* measurement lands several pixels inside the wrong character.
|
|
2047
3506
|
*
|
|
2048
|
-
*
|
|
2049
|
-
*
|
|
3507
|
+
* A run without a source has no per-offset geometry, so it maps between
|
|
3508
|
+
* offsets and x by snapping to the nearer run edge. Real text runs always
|
|
3509
|
+
* carry a source; source-less runs are element-only blocks (see
|
|
3510
|
+
* {@link _appendElementBlockRun}) and hand-built runs in tests.
|
|
2050
3511
|
*/
|
|
2051
3512
|
declare interface VisualRunSource {
|
|
2052
3513
|
readonly textNode: Text;
|
|
2053
3514
|
/** Offset within `textNode.data` corresponding to `sourceRange.start`. */
|
|
2054
3515
|
readonly textNodeStart: number;
|
|
3516
|
+
readonly coordinateSpace: EditorCoordinateSpace;
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
export declare const vscodeHostKeyboardProfile: KeyboardProfile;
|
|
3520
|
+
|
|
3521
|
+
export declare const vscodeKeyboardProfile: KeyboardProfile;
|
|
3522
|
+
|
|
3523
|
+
export declare const vscodeLocalKeyboardProfile: KeyboardProfile;
|
|
3524
|
+
|
|
3525
|
+
export declare class VscodeStackedCommentsView extends StackedCommentsPresenter {
|
|
3526
|
+
protected createWidget(comment: Comment_2): StackWidget;
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
export declare class VsCodeV2CommentsView extends StackedCommentsPresenter {
|
|
3530
|
+
protected createWidget(comment: Comment_2): StackWidget;
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
export declare interface WordNavigationConfig {
|
|
3534
|
+
readonly wordSeparators: string;
|
|
3535
|
+
readonly wordSegmenterLocales: readonly string[];
|
|
2055
3536
|
}
|
|
2056
3537
|
|
|
2057
3538
|
export { }
|