@vscode/markdown-editor 0.0.2-82 → 0.0.2-84
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 +63 -106
- package/dist/index.js +1902 -2192
- package/dist/index.js.map +1 -1
- package/dist/markdown-editor.css +1 -1
- package/package.json +5 -7
- package/src/contrib/comments/commentInput.css +37 -98
- package/src/contrib/comments/commentWidget.css +60 -0
- package/src/contrib/comments/comments.css +0 -129
- package/src/contrib/commentsVscode/vscodeCommentWidgetV2.css +0 -171
package/dist/index.d.ts
CHANGED
|
@@ -386,16 +386,10 @@ declare interface Comment_2 {
|
|
|
386
386
|
export { Comment_2 as Comment }
|
|
387
387
|
|
|
388
388
|
/**
|
|
389
|
-
*
|
|
390
|
-
* textarea and a send button, styled after the gdocs/Word "add a comment"
|
|
391
|
-
* affordance.
|
|
389
|
+
* The compact editing state for a markdown comment.
|
|
392
390
|
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
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.
|
|
391
|
+
* The widget owns its DOM and draft state but not its position. The comment-mode
|
|
392
|
+
* controller mounts it next to the active selection.
|
|
399
393
|
*/
|
|
400
394
|
export declare class CommentInputWidget extends Disposable {
|
|
401
395
|
private readonly _options?;
|
|
@@ -406,27 +400,24 @@ export declare class CommentInputWidget extends Disposable {
|
|
|
406
400
|
private readonly _value;
|
|
407
401
|
/** Live, untrimmed textarea content. */
|
|
408
402
|
get value(): IObservable<string>;
|
|
409
|
-
/** The raw textarea, exposed so a host can move focus into it
|
|
403
|
+
/** The raw textarea, exposed so a host can move focus into it. */
|
|
410
404
|
get inputElement(): HTMLTextAreaElement;
|
|
411
405
|
constructor(_options?: CommentInputWidgetOptions | undefined);
|
|
412
|
-
/** Move focus into the textarea (caret at the end). */
|
|
413
406
|
focus(): void;
|
|
414
|
-
/** Replace the textarea content. */
|
|
415
407
|
setText(text: string): void;
|
|
416
|
-
/** Clear the textarea. */
|
|
417
408
|
clear(): void;
|
|
418
409
|
private _submit;
|
|
419
410
|
private _autoSize;
|
|
420
411
|
}
|
|
421
412
|
|
|
422
413
|
export declare interface CommentInputWidgetOptions {
|
|
423
|
-
/** Placeholder shown while the textarea is empty. Defaults to "Add
|
|
414
|
+
/** Placeholder shown while the textarea is empty. Defaults to "Add comment". */
|
|
424
415
|
readonly placeholder?: string;
|
|
425
416
|
/** Called after the textarea changes size. */
|
|
426
417
|
readonly onDidChangeSize?: () => void;
|
|
427
418
|
/**
|
|
428
|
-
* Called when the user submits a non-empty comment (Enter or the
|
|
429
|
-
*
|
|
419
|
+
* Called when the user submits a non-empty comment (Enter or the add button).
|
|
420
|
+
* The text is trimmed; never called with an empty string.
|
|
430
421
|
*/
|
|
431
422
|
readonly onSubmit?: (text: string) => void;
|
|
432
423
|
/** Called when the user dismisses the input (Escape). */
|
|
@@ -434,7 +425,7 @@ export declare interface CommentInputWidgetOptions {
|
|
|
434
425
|
}
|
|
435
426
|
|
|
436
427
|
/**
|
|
437
|
-
* Comment mode — a
|
|
428
|
+
* Comment mode — a compact "add a comment" affordance layered on top of
|
|
438
429
|
* the editor *without modifying it*. It reads the editor's public observables
|
|
439
430
|
* ({@link EditorModel.readonlyMode}, {@link EditorModel.selection}) and the
|
|
440
431
|
* exposed {@link EditorView.caretRect} geometry, and mounts a
|
|
@@ -502,20 +493,10 @@ export declare interface CommentModeControllerOptions {
|
|
|
502
493
|
readonly gap?: number;
|
|
503
494
|
}
|
|
504
495
|
|
|
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
496
|
/**
|
|
515
|
-
* Seedable store of {@link Comment}s for the comment-mode contribution.
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
* {@link comments}.
|
|
497
|
+
* Seedable store of {@link Comment}s for the comment-mode contribution. It has
|
|
498
|
+
* no opinion on rendering or persistence — a host seeds it via
|
|
499
|
+
* {@link set}/{@link add} and observes {@link comments}.
|
|
519
500
|
*/
|
|
520
501
|
export declare class CommentsModel {
|
|
521
502
|
private readonly _comments;
|
|
@@ -523,11 +504,6 @@ export declare class CommentsModel {
|
|
|
523
504
|
private _sequence;
|
|
524
505
|
/** The current comments, in insertion order. */
|
|
525
506
|
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
507
|
/** Replace the whole comment set. */
|
|
532
508
|
set(comments: readonly Comment_2[]): void;
|
|
533
509
|
/**
|
|
@@ -546,55 +522,41 @@ export declare class CommentsModel {
|
|
|
546
522
|
remove(id: string): void;
|
|
547
523
|
}
|
|
548
524
|
|
|
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
525
|
/** A comment the user submitted, with the source range it was anchored to. */
|
|
565
526
|
export declare interface CommentSubmission {
|
|
566
527
|
readonly text: string;
|
|
567
528
|
readonly range: OffsetRange;
|
|
568
529
|
}
|
|
569
530
|
|
|
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
|
-
*/
|
|
531
|
+
/** Displays posted comments beside their source ranges. */
|
|
582
532
|
export declare class CommentsView extends Disposable {
|
|
583
533
|
private readonly _model;
|
|
584
534
|
private readonly _view;
|
|
585
535
|
private readonly _layer;
|
|
586
536
|
private readonly _entries;
|
|
537
|
+
private _order;
|
|
538
|
+
private _pendingRevealCommentId;
|
|
587
539
|
constructor(_model: CommentsModel, _view: EditorView);
|
|
588
|
-
|
|
589
|
-
private _update;
|
|
590
|
-
/** Create/update/remove per-comment DOM to match `comments`. */
|
|
540
|
+
revealComment(id: string): void;
|
|
591
541
|
private _reconcile;
|
|
592
|
-
private
|
|
593
|
-
private
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
542
|
+
private _relayout;
|
|
543
|
+
private _revealPendingComment;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** Compact posted state for a markdown comment. */
|
|
547
|
+
export declare class CommentWidget {
|
|
548
|
+
private readonly _domNode;
|
|
549
|
+
private readonly _disposables;
|
|
550
|
+
get element(): HTMLElement;
|
|
551
|
+
constructor(options: CommentWidgetOptions);
|
|
552
|
+
dispose(): void;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export declare interface CommentWidgetOptions {
|
|
556
|
+
/** The posted comment body. */
|
|
557
|
+
readonly body: string;
|
|
558
|
+
/** If provided, shows a delete action and invokes it when activated. */
|
|
559
|
+
readonly onDelete?: () => void;
|
|
598
560
|
}
|
|
599
561
|
|
|
600
562
|
/** The lossless source slices of a complete block HTML comment. */
|
|
@@ -955,12 +917,16 @@ export declare class EditorController extends Disposable {
|
|
|
955
917
|
private readonly _indentation;
|
|
956
918
|
private readonly _tabFocusStatus;
|
|
957
919
|
private _tabMovesFocus;
|
|
920
|
+
/** Indentation copied by the most recent fenced-code Enter, while still untouched. */
|
|
921
|
+
private _generatedIndentation;
|
|
958
922
|
/** Running click count for the current multi-click sequence (1, 2, 3, …). */
|
|
959
923
|
private _clickCount;
|
|
960
924
|
/** Timestamp and position of the previous pointer-down, for multi-click detection. */
|
|
961
925
|
private _lastPointerDown;
|
|
962
926
|
constructor(_model: EditorModel, _view: EditorView, options?: EditorControllerOptions);
|
|
963
927
|
private readonly _handleTextUpdate;
|
|
928
|
+
private _insertText;
|
|
929
|
+
private _remainingGeneratedIndentation;
|
|
964
930
|
/** Handle typed, pasted, or command-generated text while a paragraph is pending. */
|
|
965
931
|
private _handlePendingInput;
|
|
966
932
|
private _deletePendingText;
|
|
@@ -1281,6 +1247,9 @@ export declare class EditorView extends Disposable {
|
|
|
1281
1247
|
private _readonlyToggleButton;
|
|
1282
1248
|
private readonly _editContextSuspensions;
|
|
1283
1249
|
private readonly _revealOcclusions;
|
|
1250
|
+
private _caretRevealRaf;
|
|
1251
|
+
private _followedCaretBlock;
|
|
1252
|
+
private _followCaretAfterEdit;
|
|
1284
1253
|
/**
|
|
1285
1254
|
* The mounted block sequence, in source order. Rebuilt (not mutated) each
|
|
1286
1255
|
* frame by {@link DocumentViewNode.create}; the view just swaps one
|
|
@@ -1359,6 +1328,7 @@ export declare class EditorView extends Disposable {
|
|
|
1359
1328
|
* and caret geometry intact.
|
|
1360
1329
|
*/
|
|
1361
1330
|
private _setupFocusTracking;
|
|
1331
|
+
private _setupCaretScrollPadding;
|
|
1362
1332
|
/**
|
|
1363
1333
|
* Renders the edit/read-only mode toggle. It flips the model's
|
|
1364
1334
|
* {@link EditorModel.readonlyMode}: when locked (read-only) every block stays
|
|
@@ -1384,6 +1354,18 @@ export declare class EditorView extends Disposable {
|
|
|
1384
1354
|
*/
|
|
1385
1355
|
suspendEditContextWhileFocused(element: HTMLElement): IDisposable;
|
|
1386
1356
|
revealRangeInCenterIfOutsideViewport(range: OffsetRange, behavior?: ScrollBehavior): IDisposable;
|
|
1357
|
+
/**
|
|
1358
|
+
* Keeps the caret visible after an editor-driven text edit. The reveal is
|
|
1359
|
+
* deferred until the rebuilt document has been laid out and uses nearest-edge
|
|
1360
|
+
* scrolling so ordinary typing only moves the containing viewport as far as
|
|
1361
|
+
* needed. While this mode is active, a later resize of the same active block
|
|
1362
|
+
* also re-reveals the caret (for asynchronous code, math, or diagram layout).
|
|
1363
|
+
*/
|
|
1364
|
+
revealCaretAfterEdit(): void;
|
|
1365
|
+
/** Keeps a keyboard-moved caret visible without enabling edit-resize following. */
|
|
1366
|
+
revealCaretAfterKeyboardNavigation(): void;
|
|
1367
|
+
/** Stops edit-driven caret following before pointer-based selection begins. */
|
|
1368
|
+
stopFollowingCaret(): void;
|
|
1387
1369
|
/**
|
|
1388
1370
|
* Samples the ambient focus state that decides whether taking focus on open
|
|
1389
1371
|
* would steal it from an explicit user target: whether the window is focused
|
|
@@ -1473,6 +1455,13 @@ export declare class EditorView extends Disposable {
|
|
|
1473
1455
|
private _clearDiff;
|
|
1474
1456
|
private _syncEditContextAttachment;
|
|
1475
1457
|
private _revealRange;
|
|
1458
|
+
private _revealTarget;
|
|
1459
|
+
private _scheduleCaretReveal;
|
|
1460
|
+
private _revealCaretNearest;
|
|
1461
|
+
private _revealCaretAfterActiveBlockResize;
|
|
1462
|
+
private _caretBlockAt;
|
|
1463
|
+
private _measurementAt;
|
|
1464
|
+
private _stopFollowingCaret;
|
|
1476
1465
|
private _isRevealOccluded;
|
|
1477
1466
|
}
|
|
1478
1467
|
|
|
@@ -1875,9 +1864,6 @@ export declare interface IClipboardStrategy {
|
|
|
1875
1864
|
connect(context: IClipboardContext): IDisposable;
|
|
1876
1865
|
}
|
|
1877
1866
|
|
|
1878
|
-
/** A live rendering of a {@link CommentsModel}. Dispose to unmount it. */
|
|
1879
|
-
export declare type ICommentsPresenter = IDisposable;
|
|
1880
|
-
|
|
1881
1867
|
/** The Monarch language definitions the default highlighter wires up. */
|
|
1882
1868
|
export declare interface IDefaultMonarchGrammars {
|
|
1883
1869
|
typescript: unknown;
|
|
@@ -2086,7 +2072,7 @@ export declare const insertSmartEnter: (ctx: CursorCommandContext) => SmartEnter
|
|
|
2086
2072
|
*/
|
|
2087
2073
|
export declare function insertTab(config?: IndentationConfig): EditCommand;
|
|
2088
2074
|
|
|
2089
|
-
export declare function insertText(text: string): EditCommand;
|
|
2075
|
+
export declare function insertText(text: string, generatedIndentation?: OffsetRange): EditCommand;
|
|
2090
2076
|
|
|
2091
2077
|
/**
|
|
2092
2078
|
* An immutable view of one document's tokens at a point in time. It may be a
|
|
@@ -2877,6 +2863,8 @@ export declare type SmartEnterResult = {
|
|
|
2877
2863
|
readonly kind: 'edit';
|
|
2878
2864
|
readonly edit: StringEdit;
|
|
2879
2865
|
readonly selection: Selection_2;
|
|
2866
|
+
/** Post-edit range of indentation copied onto a new fenced-code line. */
|
|
2867
|
+
readonly generatedIndentation?: OffsetRange;
|
|
2880
2868
|
} | PendingParagraphResult;
|
|
2881
2869
|
|
|
2882
2870
|
/**
|
|
@@ -2902,29 +2890,6 @@ export declare interface SourceEditEvent {
|
|
|
2902
2890
|
|
|
2903
2891
|
export declare type SourceOffset = number;
|
|
2904
2892
|
|
|
2905
|
-
export declare abstract class StackedCommentsPresenter extends Disposable implements ICommentsPresenter {
|
|
2906
|
-
protected readonly model: CommentsModel;
|
|
2907
|
-
protected readonly view: EditorView;
|
|
2908
|
-
protected readonly context?: CommentsPresenterContext | undefined;
|
|
2909
|
-
private readonly _layer;
|
|
2910
|
-
private readonly _entries;
|
|
2911
|
-
private _order;
|
|
2912
|
-
private _pendingRevealCommentId;
|
|
2913
|
-
constructor(model: CommentsModel, view: EditorView, context?: CommentsPresenterContext | undefined);
|
|
2914
|
-
/** Build the card DOM for a comment. Called once per new comment. */
|
|
2915
|
-
protected abstract createWidget(comment: Comment_2): StackWidget;
|
|
2916
|
-
revealComment(id: string): void;
|
|
2917
|
-
private _reconcile;
|
|
2918
|
-
private _relayout;
|
|
2919
|
-
private _revealPendingComment;
|
|
2920
|
-
}
|
|
2921
|
-
|
|
2922
|
-
/** The minimal widget contract a subclass must produce. */
|
|
2923
|
-
export declare interface StackWidget {
|
|
2924
|
-
readonly element: HTMLElement;
|
|
2925
|
-
dispose(): void;
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
2893
|
export declare class StrikethroughAstNode extends AstNode {
|
|
2929
2894
|
readonly openMarker: MarkerAstNode;
|
|
2930
2895
|
readonly content: readonly (InlineAstNode | GlueAstNode)[];
|
|
@@ -3523,14 +3488,6 @@ export declare const vscodeKeyboardProfile: KeyboardProfile;
|
|
|
3523
3488
|
|
|
3524
3489
|
export declare const vscodeLocalKeyboardProfile: KeyboardProfile;
|
|
3525
3490
|
|
|
3526
|
-
export declare class VscodeStackedCommentsView extends StackedCommentsPresenter {
|
|
3527
|
-
protected createWidget(comment: Comment_2): StackWidget;
|
|
3528
|
-
}
|
|
3529
|
-
|
|
3530
|
-
export declare class VsCodeV2CommentsView extends StackedCommentsPresenter {
|
|
3531
|
-
protected createWidget(comment: Comment_2): StackWidget;
|
|
3532
|
-
}
|
|
3533
|
-
|
|
3534
3491
|
export declare interface WordNavigationConfig {
|
|
3535
3492
|
readonly wordSeparators: string;
|
|
3536
3493
|
readonly wordSegmenterLocales: readonly string[];
|