@vscode/markdown-editor 0.0.2-58 → 0.0.2-59
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/dist/index.d.ts +80 -29
- package/dist/index.js +2899 -2723
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -609,7 +609,7 @@ declare interface CompleteHtmlCommentSource extends HtmlCommentSourceBase {
|
|
|
609
609
|
*/
|
|
610
610
|
export declare function createDefaultMonacoSyntaxHighlighter(monaco: IMonarchApi, grammars: IDefaultMonarchGrammars): MonacoSyntaxHighlighter;
|
|
611
611
|
|
|
612
|
-
export declare type CursorCommand = (ctx: CursorCommandContext) =>
|
|
612
|
+
export declare type CursorCommand = (ctx: CursorCommandContext) => CursorPosition;
|
|
613
613
|
|
|
614
614
|
export declare interface CursorCommandContext {
|
|
615
615
|
readonly text: string;
|
|
@@ -618,6 +618,7 @@ export declare interface CursorCommandContext {
|
|
|
618
618
|
readonly activeBlock: BlockAstNode | undefined;
|
|
619
619
|
readonly markerVisibleBlocks: ReadonlySet<BlockAstNode>;
|
|
620
620
|
readonly wordNavigationConfig: WordNavigationConfig;
|
|
621
|
+
readonly cursorPosition: CursorPosition;
|
|
621
622
|
}
|
|
622
623
|
|
|
623
624
|
export declare const cursorDocumentEnd: CursorCommand;
|
|
@@ -637,12 +638,26 @@ export declare const cursorLineStart: CursorCommand;
|
|
|
637
638
|
export declare const cursorMoveLeft: CursorCommand;
|
|
638
639
|
|
|
639
640
|
export declare interface CursorMoveResult {
|
|
640
|
-
readonly
|
|
641
|
+
readonly position: CursorPosition;
|
|
641
642
|
readonly desiredColumn: number | undefined;
|
|
642
643
|
}
|
|
643
644
|
|
|
644
645
|
export declare const cursorMoveRight: CursorCommand;
|
|
645
646
|
|
|
647
|
+
/** The cursor's position in either source text or a source-less visual line. */
|
|
648
|
+
export declare type CursorPosition = {
|
|
649
|
+
readonly kind: 'source';
|
|
650
|
+
readonly offset: SourceOffset;
|
|
651
|
+
} | {
|
|
652
|
+
readonly kind: 'virtual';
|
|
653
|
+
readonly line: VirtualCursorLine;
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
export declare namespace CursorPosition {
|
|
657
|
+
export function source(offset: SourceOffset): CursorPosition;
|
|
658
|
+
export function virtual(line: VirtualCursorLine): CursorPosition;
|
|
659
|
+
}
|
|
660
|
+
|
|
646
661
|
export declare const cursorRight: CursorCommand;
|
|
647
662
|
|
|
648
663
|
export declare const cursorUp: VisualCursorCommand;
|
|
@@ -651,8 +666,8 @@ export declare const cursorUp: VisualCursorCommand;
|
|
|
651
666
|
* Owns the blinking cursor DOM element.
|
|
652
667
|
*
|
|
653
668
|
* The rendering pipeline is a single `derived` whose compute callback
|
|
654
|
-
* asks the {@link VisualLineMap} for the caret rect at the current
|
|
655
|
-
*
|
|
669
|
+
* asks the {@link VisualLineMap} for the caret rect at the current source or
|
|
670
|
+
* virtual position, writes it to {@link element}, and returns a
|
|
656
671
|
* {@link CursorViewRendering} value as proof. An autorun keeps the
|
|
657
672
|
* derived subscribed.
|
|
658
673
|
*/
|
|
@@ -663,7 +678,7 @@ export declare class CursorView extends Disposable {
|
|
|
663
678
|
}
|
|
664
679
|
|
|
665
680
|
export declare interface CursorViewOptions {
|
|
666
|
-
readonly
|
|
681
|
+
readonly position: IObservable<CursorPosition | undefined>;
|
|
667
682
|
readonly visualLineMap: IObservable<VisualLineMap>;
|
|
668
683
|
/**
|
|
669
684
|
* The mounted blocks, used to hide the caret when it sits at an offset that
|
|
@@ -671,20 +686,13 @@ export declare interface CursorViewOptions {
|
|
|
671
686
|
* matching how the selection is clipped there.
|
|
672
687
|
*/
|
|
673
688
|
readonly blocks?: IObservable<readonly SelectionBlock[]>;
|
|
674
|
-
/**
|
|
675
|
-
* When set, the caret is drawn over the transient empty paragraph instead
|
|
676
|
-
* of at {@link offset} — its editor-local rect comes straight
|
|
677
|
-
* from that synthetic element's geometry, since it has no visual-line-map
|
|
678
|
-
* entry. Takes priority over the normal offset-based placement.
|
|
679
|
-
*/
|
|
680
|
-
readonly pendingCaretRect?: IObservable<Rect2D | undefined>;
|
|
681
689
|
}
|
|
682
690
|
|
|
683
691
|
export declare class CursorViewRendering {
|
|
684
|
-
readonly
|
|
692
|
+
readonly position: CursorPosition;
|
|
685
693
|
readonly visible: boolean;
|
|
686
694
|
readonly rect: Rect2D;
|
|
687
|
-
constructor(
|
|
695
|
+
constructor(position: CursorPosition, visible: boolean, rect: Rect2D);
|
|
688
696
|
}
|
|
689
697
|
|
|
690
698
|
export declare const cursorVisualLineEnd: VisualCursorCommand;
|
|
@@ -876,7 +884,7 @@ declare class DocumentViewData {
|
|
|
876
884
|
export declare class DocumentViewNode extends ViewNode {
|
|
877
885
|
readonly blocks: readonly DocumentBlock[];
|
|
878
886
|
/** The transient empty-paragraph element, when one is armed. */
|
|
879
|
-
readonly
|
|
887
|
+
readonly pendingParagraph?: PendingParagraphViewNode | undefined;
|
|
880
888
|
static create(viewData: DocumentViewData, options: BlockViewOptions | undefined, previous: DocumentViewNode | undefined): DocumentViewNode;
|
|
881
889
|
private constructor();
|
|
882
890
|
/** The stable content element this document mounts its children into. */
|
|
@@ -957,6 +965,7 @@ export declare class EditorController extends Disposable {
|
|
|
957
965
|
private _executeVisualCursorCommand;
|
|
958
966
|
private _cursorDown;
|
|
959
967
|
private _setUserSelection;
|
|
968
|
+
private _applyCursorPosition;
|
|
960
969
|
/** Move the cursor down one visual line (Arrow Down). */
|
|
961
970
|
cursorDown(extend?: boolean): void;
|
|
962
971
|
/** Move the cursor up one visual line (Arrow Up). */
|
|
@@ -1138,6 +1147,7 @@ export declare class EditorModel {
|
|
|
1138
1147
|
*/
|
|
1139
1148
|
readonly pendingParagraph: ISettableObservable<PendingParagraph | undefined, void>;
|
|
1140
1149
|
readonly cursorOffset: IObservableWithChange<number | undefined, void>;
|
|
1150
|
+
readonly cursorPosition: IObservableWithChange<CursorPosition | undefined, void>;
|
|
1141
1151
|
/**
|
|
1142
1152
|
* The parsed document. Threads the previous document into the parser so
|
|
1143
1153
|
* unchanged blocks keep their object identity across reparses (see
|
|
@@ -1188,7 +1198,7 @@ export declare class EditorModel {
|
|
|
1188
1198
|
* AST node for it, and park the caret at the gap start. No source edit is
|
|
1189
1199
|
* applied — the blank line exists only in the view until it is materialized.
|
|
1190
1200
|
*/
|
|
1191
|
-
armPendingParagraph(req: Omit<PendingParagraph, 'syntheticAst'>): void;
|
|
1201
|
+
armPendingParagraph(req: Omit<PendingParagraph, 'syntheticAst' | 'cursorLine'>): void;
|
|
1192
1202
|
/** Discard the pending paragraph (if any) without touching the source. */
|
|
1193
1203
|
cancelPendingParagraph(): void;
|
|
1194
1204
|
/**
|
|
@@ -1290,13 +1300,6 @@ export declare class EditorView extends Disposable {
|
|
|
1290
1300
|
*/
|
|
1291
1301
|
private readonly _focused;
|
|
1292
1302
|
get focused(): IObservable<boolean>;
|
|
1293
|
-
/**
|
|
1294
|
-
* Caret rect (editor-local coordinates) for the transient empty paragraph, or
|
|
1295
|
-
* `undefined` when none is armed. Set each frame from the synthetic
|
|
1296
|
-
* paragraph element's geometry and fed to the {@link CursorView}, which has
|
|
1297
|
-
* no visual-line-map entry to place the caret from otherwise.
|
|
1298
|
-
*/
|
|
1299
|
-
private readonly _pendingCaretRect;
|
|
1300
1303
|
/**
|
|
1301
1304
|
* The block cache projected for views (selection painting) that need to
|
|
1302
1305
|
* react to mount/unmount. Derived from {@link _document}, so it stays in
|
|
@@ -2420,13 +2423,16 @@ export declare interface MeasuredLayoutDebugViewOptions {
|
|
|
2420
2423
|
* through this model and never touches view fields directly.
|
|
2421
2424
|
*/
|
|
2422
2425
|
export declare class MeasuredLayoutModel {
|
|
2423
|
-
|
|
2426
|
+
private readonly _measurements;
|
|
2427
|
+
readonly measurements: IObservable<readonly BlockMeasurement[]>;
|
|
2428
|
+
private readonly _virtualLines;
|
|
2424
2429
|
/**
|
|
2425
2430
|
* Concatenated visual line map across all mounted blocks. Every per-block
|
|
2426
2431
|
* map uses the same editor-local coordinate space, so concatenation is
|
|
2427
2432
|
* well-formed without translation or re-sorting.
|
|
2428
2433
|
*/
|
|
2429
2434
|
readonly visualLineMap: IObservableWithChange<VisualLineMap, void>;
|
|
2435
|
+
setMeasurements(measurements: readonly BlockMeasurement[], virtualLines: readonly VirtualLineMeasurement[]): void;
|
|
2430
2436
|
}
|
|
2431
2437
|
|
|
2432
2438
|
/**
|
|
@@ -2557,6 +2563,8 @@ declare interface PendingParagraph {
|
|
|
2557
2563
|
readonly separateFromPreviousBlock: boolean;
|
|
2558
2564
|
/** Whether {@link replaceRange} ends at the end of the document. */
|
|
2559
2565
|
readonly atEof: boolean;
|
|
2566
|
+
/** The source-less visual line occupied by the pending caret. */
|
|
2567
|
+
readonly cursorLine: VirtualCursorLine;
|
|
2560
2568
|
/**
|
|
2561
2569
|
* A throwaway AST node that exists only to give the synthetic view child a
|
|
2562
2570
|
* stable identity across render frames (the view pairs nodes by `ast.id`).
|
|
@@ -2577,14 +2585,28 @@ declare interface PendingParagraphResult {
|
|
|
2577
2585
|
/**
|
|
2578
2586
|
* View-data for the transient empty paragraph (see `PendingParagraph` in the
|
|
2579
2587
|
* model). It carries only the throwaway {@link ParagraphAstNode} that gives the
|
|
2580
|
-
* rendered blank line a stable identity across frames
|
|
2581
|
-
*
|
|
2582
|
-
* over it via a dedicated rect, not via the visual-line map.
|
|
2588
|
+
* rendered blank line a stable identity across frames, its anchor block, and
|
|
2589
|
+
* its source-less cursor line. It has no source content or selection range.
|
|
2583
2590
|
*/
|
|
2584
2591
|
declare class PendingParagraphViewData {
|
|
2585
2592
|
readonly ast: ParagraphAstNode;
|
|
2593
|
+
readonly anchorBlock: BlockAstNode;
|
|
2594
|
+
readonly cursorLine: VirtualCursorLine;
|
|
2586
2595
|
readonly kind = "pendingParagraph";
|
|
2587
|
-
constructor(ast: ParagraphAstNode);
|
|
2596
|
+
constructor(ast: ParagraphAstNode, anchorBlock: BlockAstNode, cursorLine: VirtualCursorLine);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
/**
|
|
2600
|
+
* The mounted transient empty paragraph: a `<p class="md-pending-paragraph">`
|
|
2601
|
+
* holding a single `<br>` so it occupies a line's height. It is a leaf view
|
|
2602
|
+
* node with no inline source content; the document view publishes its element
|
|
2603
|
+
* geometry as a virtual visual line.
|
|
2604
|
+
*/
|
|
2605
|
+
declare class PendingParagraphViewNode extends ViewNode {
|
|
2606
|
+
readonly element: HTMLElement;
|
|
2607
|
+
readonly anchorBlock: BlockAstNode;
|
|
2608
|
+
readonly cursorLine: VirtualCursorLine;
|
|
2609
|
+
constructor(view: PendingParagraphViewData);
|
|
2588
2610
|
}
|
|
2589
2611
|
|
|
2590
2612
|
/**
|
|
@@ -3141,6 +3163,24 @@ export declare class ViewNode extends Disposable {
|
|
|
3141
3163
|
forEachTextLeaf(nodeOffset: number, visitor: (leaf: ViewNode, leafOffset: number) => void): void;
|
|
3142
3164
|
}
|
|
3143
3165
|
|
|
3166
|
+
/**
|
|
3167
|
+
* A visual cursor line that has no representation in the source text.
|
|
3168
|
+
*
|
|
3169
|
+
* The two source offsets are the positions immediately before and after the
|
|
3170
|
+
* virtual line. The object itself is the stable identity of the line.
|
|
3171
|
+
*/
|
|
3172
|
+
export declare class VirtualCursorLine {
|
|
3173
|
+
readonly sourceOffsetBefore: SourceOffset;
|
|
3174
|
+
readonly sourceOffsetAfter: SourceOffset;
|
|
3175
|
+
constructor(sourceOffsetBefore: SourceOffset, sourceOffsetAfter: SourceOffset);
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
/** A measured source-less line inserted directly after a source block. */
|
|
3179
|
+
declare interface VirtualLineMeasurement {
|
|
3180
|
+
readonly afterBlock: BlockAstNode;
|
|
3181
|
+
readonly line: VisualLine;
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3144
3184
|
export declare type VisualCursorCommand = (ctx: VisualCursorCommandContext) => CursorMoveResult;
|
|
3145
3185
|
|
|
3146
3186
|
export declare interface VisualCursorCommandContext extends CursorCommandContext {
|
|
@@ -3158,7 +3198,9 @@ export declare function visualizeAst(root: AstNode, source: string): AstVisualiz
|
|
|
3158
3198
|
export declare class VisualLine {
|
|
3159
3199
|
readonly rect: Rect2D;
|
|
3160
3200
|
readonly runs: readonly VisualRun[];
|
|
3161
|
-
|
|
3201
|
+
readonly virtualCursorLine?: VirtualCursorLine | undefined;
|
|
3202
|
+
static virtual(cursorLine: VirtualCursorLine, rect: Rect2D): VisualLine;
|
|
3203
|
+
constructor(rect: Rect2D, runs: readonly VisualRun[], virtualCursorLine?: VirtualCursorLine | undefined);
|
|
3162
3204
|
containsOffset(offset: SourceOffset): boolean;
|
|
3163
3205
|
/**
|
|
3164
3206
|
* How `offset` relates to this line's runs:
|
|
@@ -3248,6 +3290,8 @@ export declare class VisualLineMap {
|
|
|
3248
3290
|
readonly absoluteStart: number;
|
|
3249
3291
|
readonly viewNode: ViewNode;
|
|
3250
3292
|
}[], coordinateSpace: EditorCoordinateSpace, transform?: EditorCoordinateTransform): VisualLineMap;
|
|
3293
|
+
/** Lines backed by source ranges, excluding source-less cursor lines. */
|
|
3294
|
+
readonly sourceLines: readonly VisualLine[];
|
|
3251
3295
|
constructor(lines: readonly VisualLine[]);
|
|
3252
3296
|
get lineCount(): number;
|
|
3253
3297
|
get isEmpty(): boolean;
|
|
@@ -3272,6 +3316,12 @@ export declare class VisualLineMap {
|
|
|
3272
3316
|
* {@link lineIndexOfOffset}. Returns `0` when the map is empty.
|
|
3273
3317
|
*/
|
|
3274
3318
|
xAtOffset(offset: SourceOffset): number;
|
|
3319
|
+
/**
|
|
3320
|
+
* Line occupied by a source or virtual cursor position. A virtual position
|
|
3321
|
+
* returns `undefined` until its corresponding DOM line has been measured.
|
|
3322
|
+
*/
|
|
3323
|
+
lineIndexOfPosition(position: CursorPosition): number | undefined;
|
|
3324
|
+
xAtPosition(position: CursorPosition): number;
|
|
3275
3325
|
/**
|
|
3276
3326
|
* Line whose vertical band contains `y`, clamped to the first/last
|
|
3277
3327
|
* line when `y` is outside the document.
|
|
@@ -3285,6 +3335,7 @@ export declare class VisualLineMap {
|
|
|
3285
3335
|
offsetAtPoint(point: Point2D): SourceOffset;
|
|
3286
3336
|
/** Snap `x` to the nearest offset on a specific line. */
|
|
3287
3337
|
offsetInLineAtX(lineIndex: number, x: number): SourceOffset;
|
|
3338
|
+
positionInLineAtX(lineIndex: number, x: number): CursorPosition;
|
|
3288
3339
|
lineStartOffset(lineIndex: number): SourceOffset | undefined;
|
|
3289
3340
|
lineEndOffset(lineIndex: number): SourceOffset | undefined;
|
|
3290
3341
|
}
|