@meowdown/core 0.70.0 → 0.71.0
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 +617 -604
- package/dist/index.js +5316 -5245
- package/dist/style.css +9 -51
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Editor, Extension, ExtractMarkBuilders, ExtractNodeBuilders, PlainExtension, Priority, Union, withPriority } from "@prosekit/core";
|
|
2
2
|
import { CodeBlockAttrs, CodeBlockAttrs as CodeBlockAttrs$1, defineCodeBlockPreviewPlugin, isCodeBlockPreviewHiddenDecoration } from "@prosekit/extensions/code-block";
|
|
3
|
-
import { PlaceholderOptions, definePlaceholder } from "@prosekit/extensions/placeholder";
|
|
4
|
-
import { defineReadonly } from "@prosekit/extensions/readonly";
|
|
5
|
-
import { SearchStatus, SearchStatusHandler, defineSearchStatusHandler, getSearchStatus } from "@prosekit/extensions/search";
|
|
3
|
+
import { PlaceholderOptions, PlaceholderOptions as PlaceholderOptions$1, definePlaceholder } from "@prosekit/extensions/placeholder";
|
|
6
4
|
import { Command, EditorState, PluginKey } from "@prosekit/pm/state";
|
|
5
|
+
import { SearchStatus, SearchStatusHandler, defineSearchStatusHandler, getSearchStatus } from "@prosekit/extensions/search";
|
|
7
6
|
import { EditorView } from "@prosekit/pm/view";
|
|
8
7
|
import { EditorNode, Mark, ProseMirrorNode } from "@prosekit/pm/model";
|
|
9
8
|
import { ListAttrs } from "@prosekit/extensions/list";
|
|
9
|
+
import { parseXPostId } from "@post-embed/schema";
|
|
10
10
|
import { HorizontalRuleExtension } from "@prosekit/extensions/horizontal-rule";
|
|
11
11
|
import { Resolver } from "@post-embed/elements/x";
|
|
12
12
|
import { render } from "katex";
|
|
13
13
|
import { XPost, YouTubeVideo } from "@post-embed/types";
|
|
14
14
|
import { VirtualElement } from "@floating-ui/dom";
|
|
15
|
+
//#region src/extensions/readonly.d.ts
|
|
16
|
+
export declare function defineReadonly(getReadonly?: (state: EditorState) => boolean): PlainExtension;
|
|
17
|
+
//#endregion
|
|
15
18
|
//#region src/converters/check-roundtrip.d.ts
|
|
16
19
|
/**
|
|
17
20
|
* How faithfully markdown survives a parse-then-serialize round trip:
|
|
@@ -502,212 +505,554 @@ type PendingReplacementHandler = (event: PendingReplacementEvent) => void;
|
|
|
502
505
|
*/
|
|
503
506
|
export declare function definePendingReplacementHandler(handler: PendingReplacementHandler): PlainExtension;
|
|
504
507
|
//#endregion
|
|
505
|
-
//#region src/extensions/
|
|
506
|
-
/**
|
|
507
|
-
* Contiguous range with a uniform inline-mark set.
|
|
508
|
-
*/
|
|
509
|
-
type MarkChunk = readonly [from: number, to: number, marks: readonly Mark[]];
|
|
510
|
-
//#endregion
|
|
511
|
-
//#region src/extensions/reference-links.d.ts
|
|
512
|
-
interface ReferenceDefinition {
|
|
513
|
-
key: string;
|
|
514
|
-
href: string;
|
|
515
|
-
title: string;
|
|
516
|
-
}
|
|
517
|
-
type ReferenceDefinitions = ReadonlyMap<string, ReferenceDefinition>;
|
|
518
|
-
interface ReferenceDefinitionIndex {
|
|
519
|
-
definitions: ReferenceDefinitions;
|
|
520
|
-
nodes: ReadonlySet<EditorNode>;
|
|
521
|
-
}
|
|
522
|
-
export declare function isReferenceDefinitionNode(node: EditorNode, parent: EditorNode | null, index: number): boolean;
|
|
523
|
-
export declare function collectReferenceDefinitions(doc: EditorNode): ReferenceDefinitionIndex;
|
|
524
|
-
//#endregion
|
|
525
|
-
//#region src/extensions/wiki-embed.d.ts
|
|
508
|
+
//#region src/extensions/exit-boundary.d.ts
|
|
526
509
|
/**
|
|
527
|
-
*
|
|
510
|
+
* Payload for {@link ExitBoundaryHandler}.
|
|
528
511
|
*/
|
|
529
|
-
interface
|
|
530
|
-
/**
|
|
531
|
-
* Target before an optional alias or size suffix.
|
|
532
|
-
*/
|
|
533
|
-
target: string;
|
|
534
|
-
/**
|
|
535
|
-
* Non-size suffix after `|`, or `''` when absent.
|
|
536
|
-
*/
|
|
537
|
-
display: string;
|
|
512
|
+
interface ExitBoundaryOptions {
|
|
538
513
|
/**
|
|
539
|
-
*
|
|
514
|
+
* The boundary the caret would leave: `up` at the document start, `down` at the end.
|
|
540
515
|
*/
|
|
541
|
-
|
|
516
|
+
direction: 'up' | 'down';
|
|
542
517
|
/**
|
|
543
|
-
*
|
|
518
|
+
* The originating arrow key press.
|
|
544
519
|
*/
|
|
545
|
-
|
|
520
|
+
event: KeyboardEvent;
|
|
546
521
|
}
|
|
547
522
|
/**
|
|
548
|
-
*
|
|
523
|
+
* Called when an arrow key press would move the caret past the document
|
|
524
|
+
* boundary. Return `false` to let the editor handle the key normally; any
|
|
525
|
+
* other return value consumes it.
|
|
549
526
|
*/
|
|
550
|
-
type
|
|
551
|
-
kind: 'image';
|
|
552
|
-
/**
|
|
553
|
-
* Source passed to `resolveImageUrl` and image click handlers. Defaults to `target`.
|
|
554
|
-
*/
|
|
555
|
-
src?: string;
|
|
556
|
-
/**
|
|
557
|
-
* Image alt text. Defaults to the alias or target basename.
|
|
558
|
-
*/
|
|
559
|
-
alt?: string;
|
|
560
|
-
} | {
|
|
561
|
-
kind: 'file';
|
|
562
|
-
/**
|
|
563
|
-
* Destination passed to file metadata and click handlers. Defaults to `target`.
|
|
564
|
-
*/
|
|
565
|
-
href?: string;
|
|
566
|
-
/**
|
|
567
|
-
* File pill label. Defaults to the alias or target basename.
|
|
568
|
-
*/
|
|
569
|
-
name?: string;
|
|
570
|
-
/**
|
|
571
|
-
* Optional file title.
|
|
572
|
-
*/
|
|
573
|
-
title?: string;
|
|
574
|
-
} | {
|
|
575
|
-
kind: 'note';
|
|
576
|
-
/**
|
|
577
|
-
* Target passed to wikilink click handlers. Defaults to the source target.
|
|
578
|
-
*/
|
|
579
|
-
target?: string;
|
|
580
|
-
/**
|
|
581
|
-
* Chip label. Defaults to the source alias or resolved target.
|
|
582
|
-
*/
|
|
583
|
-
display?: string;
|
|
584
|
-
};
|
|
527
|
+
type ExitBoundaryHandler = (options: ExitBoundaryOptions) => boolean | void;
|
|
585
528
|
/**
|
|
586
|
-
*
|
|
587
|
-
* source literal and editable. The resolver participates in the parse cache,
|
|
588
|
-
* so it must be pure: the same payload must always return the same result.
|
|
529
|
+
* Call `onExitBoundary` when an arrow key press would leave the document boundary.
|
|
589
530
|
*/
|
|
590
|
-
|
|
531
|
+
export declare function defineExitBoundaryHandler(getExitBoundaryHandler?: (state: EditorState) => ExitBoundaryHandler | undefined): PlainExtension;
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/extensions/file-paste.d.ts
|
|
534
|
+
type FilePasteHandler = (file: File) => string | undefined | Promise<string | undefined>;
|
|
535
|
+
type FileSaveErrorHandler = (error: unknown, file: File) => void;
|
|
591
536
|
/**
|
|
592
|
-
*
|
|
537
|
+
* Options for {@link defineFilePaste}.
|
|
593
538
|
*/
|
|
594
|
-
interface
|
|
595
|
-
|
|
539
|
+
interface FilePasteOptions {
|
|
540
|
+
/**
|
|
541
|
+
* Persist a pasted/dropped file and return its markdown destination, or
|
|
542
|
+
* `undefined` to decline (nothing is inserted, but the event is consumed).
|
|
543
|
+
* An image (`image/*` MIME type or a recognized image filename extension)
|
|
544
|
+
* inserts ``; any other file inserts a `[name](src)` link.
|
|
545
|
+
*/
|
|
546
|
+
onFilePaste?: FilePasteHandler;
|
|
547
|
+
/**
|
|
548
|
+
* Called when persisting a pasted/dropped file throws. Defaults to `console.error`.
|
|
549
|
+
*/
|
|
550
|
+
onFileSaveError?: FileSaveErrorHandler;
|
|
596
551
|
}
|
|
597
552
|
/**
|
|
598
|
-
*
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
*
|
|
553
|
+
* The markdown a saved file becomes: `` for an image (a
|
|
554
|
+
* `type` starting with `image/` or a recognized image filename extension), a
|
|
555
|
+
* `[name](destination)` link otherwise, with `\`, `[`, and `]` escaped in the
|
|
556
|
+
* name. Exported so a host command that inserts file links itself (e.g. an
|
|
557
|
+
* attach-file picker) produces markdown byte-identical to a paste/drop.
|
|
603
558
|
*/
|
|
604
|
-
export declare function
|
|
559
|
+
export declare function buildFileMarkdown(file: {
|
|
560
|
+
name: string;
|
|
561
|
+
type?: string;
|
|
562
|
+
}, destination: string): string;
|
|
605
563
|
/**
|
|
606
|
-
*
|
|
564
|
+
* Persist pasted/dropped files via `onFilePaste` and insert the returned
|
|
565
|
+
* markdown destination: `` for an image, a `[name](src)` link for any
|
|
566
|
+
* other file. Multiple files insert one link per line, in DataTransfer order.
|
|
607
567
|
*/
|
|
608
|
-
export declare function
|
|
568
|
+
export declare function defineFilePaste(getOptions?: (state: EditorState) => FilePasteOptions | undefined): PlainExtension;
|
|
609
569
|
//#endregion
|
|
610
|
-
//#region src/extensions/
|
|
570
|
+
//#region src/extensions/file-view.d.ts
|
|
611
571
|
/**
|
|
612
|
-
*
|
|
572
|
+
* Metadata a host resolves for one file link, shown on its pill.
|
|
613
573
|
*/
|
|
614
|
-
interface
|
|
574
|
+
interface FileInfo {
|
|
615
575
|
/**
|
|
616
|
-
*
|
|
617
|
-
* it: an alias form such as `[[target|alias]]` arrives here whole.
|
|
576
|
+
* File size in bytes, shown as a human-readable suffix (e.g. `1.4 MB`).
|
|
618
577
|
*/
|
|
619
|
-
|
|
578
|
+
size?: number;
|
|
620
579
|
}
|
|
621
580
|
/**
|
|
622
|
-
*
|
|
581
|
+
* Resolve display metadata for a file `href`, directly or as a promise; the
|
|
582
|
+
* pill renders immediately and fills the metadata in when the promise
|
|
583
|
+
* settles. Return `undefined` for a file without metadata (e.g. one that no
|
|
584
|
+
* longer exists). Called once per rendered pill, so the same `href` may
|
|
585
|
+
* resolve repeatedly: cache in the host when resolving is expensive.
|
|
623
586
|
*/
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
587
|
+
type FileInfoResolver = (href: string) => FileInfo | undefined | Promise<FileInfo | undefined>;
|
|
588
|
+
/**
|
|
589
|
+
* Options for {@link defineFileView}.
|
|
590
|
+
*/
|
|
591
|
+
interface FileViewOptions {
|
|
629
592
|
/**
|
|
630
|
-
*
|
|
593
|
+
* Resolve the metadata (file size) shown on a pill. Omit to show none.
|
|
631
594
|
*/
|
|
632
|
-
|
|
595
|
+
resolveFileInfo?: FileInfoResolver;
|
|
633
596
|
}
|
|
634
597
|
/**
|
|
635
|
-
*
|
|
636
|
-
* the label its chip shows; the Markdown source stays as written. Return
|
|
637
|
-
* `undefined` to use the bracketed text as both. The resolver participates
|
|
638
|
-
* in the parse cache, so it must be pure: the same payload must always
|
|
639
|
-
* return the same result.
|
|
598
|
+
* Classify a file destination for the pill's `data-file-kind` attribute.
|
|
640
599
|
*/
|
|
641
|
-
|
|
600
|
+
export declare function getFileKind(href: string): string;
|
|
642
601
|
/**
|
|
643
|
-
*
|
|
602
|
+
* Render a claimed file link or wiki embed (the `mdFile` mark) as an inline
|
|
603
|
+
* pill: a file-kind icon, the file name, and the size once
|
|
604
|
+
* `resolveFileInfo` supplies it. The pill never loads the file's content;
|
|
605
|
+
* clicks are reported through `defineFileClickHandler`.
|
|
644
606
|
*/
|
|
645
|
-
|
|
646
|
-
resolveWikilink?: WikilinkResolver;
|
|
647
|
-
}
|
|
607
|
+
export declare function defineFileView(getOptions?: (state: EditorState) => FileViewOptions): PlainExtension;
|
|
648
608
|
//#endregion
|
|
649
|
-
//#region src/extensions/
|
|
609
|
+
//#region src/extensions/file-click.d.ts
|
|
650
610
|
/**
|
|
651
|
-
*
|
|
611
|
+
* Payload for {@link FileClickHandler}.
|
|
652
612
|
*/
|
|
653
|
-
interface
|
|
613
|
+
interface FileClickPayload {
|
|
654
614
|
/**
|
|
655
|
-
* The
|
|
615
|
+
* The resolved destination from `[name](href)` or a claimed `![[target]]`.
|
|
656
616
|
*/
|
|
657
617
|
href: string;
|
|
658
618
|
/**
|
|
659
|
-
* The
|
|
619
|
+
* The file name shown on the pill.
|
|
660
620
|
*/
|
|
661
|
-
|
|
621
|
+
name: string;
|
|
662
622
|
/**
|
|
663
|
-
* The
|
|
623
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the
|
|
624
|
+
* pill. Read modifier keys or position a popover from it.
|
|
664
625
|
*/
|
|
665
|
-
|
|
626
|
+
event: MouseEvent | KeyboardEvent;
|
|
627
|
+
/**
|
|
628
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
629
|
+
* beyond the gesture that triggered the activation.
|
|
630
|
+
*/
|
|
631
|
+
mod: boolean;
|
|
666
632
|
}
|
|
633
|
+
type FileClickHandler = (payload: FileClickPayload) => void;
|
|
667
634
|
/**
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
* no longer apply to it. Must be pure: parse results are cached and diffed,
|
|
672
|
-
* so the same input must always produce the same answer.
|
|
635
|
+
* Call `onClick` when the user clicks a rendered file pill, with the file's
|
|
636
|
+
* `href`, `name`, and the originating `MouseEvent`. The host decides what a
|
|
637
|
+
* click does (e.g. open the file in the OS default app).
|
|
673
638
|
*/
|
|
674
|
-
|
|
639
|
+
export declare function defineFileClickHandler(getOnClick?: (state: EditorState) => FileClickHandler | undefined): PlainExtension;
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/extensions/image-click.d.ts
|
|
675
642
|
/**
|
|
676
|
-
*
|
|
643
|
+
* Payload for {@link ImageClickHandler}.
|
|
677
644
|
*/
|
|
678
|
-
interface
|
|
645
|
+
interface ImageClickPayload {
|
|
679
646
|
/**
|
|
680
|
-
*
|
|
681
|
-
* Read once when the editor is created.
|
|
647
|
+
* The resolved source from `` or a claimed `![[target]]`.
|
|
682
648
|
*/
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Host options that influence source-backed inline atom parsing.
|
|
687
|
-
*/
|
|
688
|
-
type InlineMarkOptions = FileLinkOptions & WikiEmbedOptions & WikilinkOptions;
|
|
689
|
-
interface InlineMarkContext {
|
|
649
|
+
src: string;
|
|
690
650
|
/**
|
|
691
|
-
*
|
|
651
|
+
* The image alt text.
|
|
692
652
|
*/
|
|
693
|
-
|
|
653
|
+
alt: string;
|
|
694
654
|
/**
|
|
695
|
-
*
|
|
655
|
+
* The originating click or touch tap, or the `Enter`/`Mod-Enter` key press
|
|
656
|
+
* that followed the selected image. Read the target or position a popover
|
|
657
|
+
* from it; a touch surface delivers the `touchend` instead of a click.
|
|
696
658
|
*/
|
|
697
|
-
|
|
659
|
+
event: MouseEvent | TouchEvent | KeyboardEvent;
|
|
698
660
|
/**
|
|
699
|
-
*
|
|
661
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
662
|
+
* beyond the gesture that triggered the activation.
|
|
700
663
|
*/
|
|
701
|
-
|
|
664
|
+
mod: boolean;
|
|
702
665
|
}
|
|
666
|
+
type ImageClickHandler = (payload: ImageClickPayload) => void;
|
|
703
667
|
/**
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
668
|
+
* Call `onClick` when the user clicks or taps a rendered image preview, with
|
|
669
|
+
* the image's markdown `src`, `alt`, and the originating event.
|
|
670
|
+
*
|
|
671
|
+
* Touch taps are handled from `touchend` rather than the synthetic click:
|
|
672
|
+
* previews live inside the editor contenteditable, and iOS WebKit's
|
|
673
|
+
* tap-to-focus is a native gesture default action that only cancelling the
|
|
674
|
+
* `touchend` can suppress — otherwise a tap briefly focuses the editor and
|
|
675
|
+
* raises the software keyboard before the handler opens its own surface
|
|
676
|
+
* (such as a lightbox).
|
|
707
677
|
*/
|
|
708
|
-
export declare function
|
|
709
|
-
|
|
710
|
-
|
|
678
|
+
export declare function defineImageClickHandler(getOnClick?: (state: EditorState) => ImageClickHandler | undefined): PlainExtension;
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/extensions/link-click.d.ts
|
|
681
|
+
interface LinkClickPayload {
|
|
682
|
+
href: string;
|
|
683
|
+
/**
|
|
684
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
685
|
+
*/
|
|
686
|
+
event: MouseEvent | KeyboardEvent;
|
|
687
|
+
/**
|
|
688
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
689
|
+
* beyond the gesture that triggered the activation.
|
|
690
|
+
*/
|
|
691
|
+
mod: boolean;
|
|
692
|
+
}
|
|
693
|
+
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
694
|
+
interface LinkCopyPayload {
|
|
695
|
+
href: string;
|
|
696
|
+
}
|
|
697
|
+
type LinkCopyHandler = (payload: LinkCopyPayload) => void;
|
|
698
|
+
/**
|
|
699
|
+
* Call `onClick` when the user clicks a rendered Markdown link
|
|
700
|
+
* (`[text](url)`), or presses `Mod-Enter` with the caret on one. The `event`
|
|
701
|
+
* is the originating `MouseEvent` or `KeyboardEvent`.
|
|
702
|
+
*/
|
|
703
|
+
export declare function defineLinkClickHandler(getOnClick?: (state: EditorState) => LinkClickHandler | undefined): PlainExtension;
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/extensions/tag-click.d.ts
|
|
706
|
+
interface TagClickPayload {
|
|
707
|
+
/**
|
|
708
|
+
* The tag name, without the leading `#`.
|
|
709
|
+
*/
|
|
710
|
+
tag: string;
|
|
711
|
+
/**
|
|
712
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the tag.
|
|
713
|
+
* Read modifier keys or position a popover from it.
|
|
714
|
+
*/
|
|
715
|
+
event: MouseEvent | KeyboardEvent;
|
|
716
|
+
/**
|
|
717
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
718
|
+
* beyond the gesture that triggered the activation.
|
|
719
|
+
*/
|
|
720
|
+
mod: boolean;
|
|
721
|
+
}
|
|
722
|
+
type TagClickHandler = (payload: TagClickPayload) => void;
|
|
723
|
+
/**
|
|
724
|
+
* Call `onClick` when the user clicks a rendered `#tag`, or presses
|
|
725
|
+
* `Mod-Enter` with the caret on one. The `tag` is read from the rendered text
|
|
726
|
+
* without the leading `#`.
|
|
727
|
+
*/
|
|
728
|
+
export declare function defineTagClickHandler(getOnClick?: (state: EditorState) => TagClickHandler | undefined): PlainExtension;
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/extensions/wikilink-click.d.ts
|
|
731
|
+
interface WikilinkHit {
|
|
732
|
+
from: number;
|
|
733
|
+
to: number;
|
|
734
|
+
target: string;
|
|
735
|
+
}
|
|
736
|
+
interface WikilinkClickPayload {
|
|
737
|
+
target: string;
|
|
738
|
+
/**
|
|
739
|
+
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
740
|
+
*/
|
|
741
|
+
event: MouseEvent | KeyboardEvent;
|
|
742
|
+
/**
|
|
743
|
+
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
744
|
+
* beyond the gesture that triggered the activation.
|
|
745
|
+
*/
|
|
746
|
+
mod: boolean;
|
|
747
|
+
}
|
|
748
|
+
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
749
|
+
/**
|
|
750
|
+
* Call `onClick` when the user clicks a rendered wikilink label, or presses
|
|
751
|
+
* `Mod-Enter` with the caret on one. The `event` is the originating
|
|
752
|
+
* `MouseEvent` or `KeyboardEvent`.
|
|
753
|
+
*/
|
|
754
|
+
export declare function defineWikilinkClickHandler(getOnClick?: (state: EditorState) => WikilinkClickHandler | undefined): PlainExtension;
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/extensions/follow-link.d.ts
|
|
757
|
+
interface FollowLinkHandlers {
|
|
758
|
+
onWikilinkClick?: WikilinkClickHandler;
|
|
759
|
+
onTagClick?: TagClickHandler;
|
|
760
|
+
onFileClick?: FileClickHandler;
|
|
761
|
+
onLinkClick?: LinkClickHandler;
|
|
762
|
+
onImageClick?: ImageClickHandler;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Binds `Mod-Enter` to follow the wikilink, tag, file pill, or Markdown link
|
|
766
|
+
* under the caret, and plain `Enter` to follow a selected atom unit (a
|
|
767
|
+
* wikilink, file pill, or image), firing the same handlers a click does.
|
|
768
|
+
* "Under the caret" means strictly inside the unit: a caret merely touching
|
|
769
|
+
* a unit's edge is next to it, not on it.
|
|
770
|
+
* Off a link, `Mod-Enter` falls through so the list keymap keeps cycling
|
|
771
|
+
* checkbox tasks; off a selected unit, `Enter` falls through to the regular
|
|
772
|
+
* split. High priority puts this ahead of every keymap binding.
|
|
773
|
+
*
|
|
774
|
+
* A selected-unit follow reports `mod: true` when the platform's mod key
|
|
775
|
+
* (`⌘` on Apple, `Ctrl` elsewhere) was held beyond its plain-`Enter` trigger;
|
|
776
|
+
* a caret follow always reports `mod: false`, its mod key being the trigger
|
|
777
|
+
* itself.
|
|
778
|
+
*/
|
|
779
|
+
export declare function defineFollowLinkHandler(getHandlers?: (state: EditorState) => FollowLinkHandlers): PlainExtension;
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region src/extensions/post-embed.d.ts
|
|
782
|
+
type XPostResolver = Resolver<XPost>;
|
|
783
|
+
type YouTubeVideoResolver = Resolver<YouTubeVideo>;
|
|
784
|
+
type PostEmbedKind = 'x-post' | 'youtube-video';
|
|
785
|
+
/**
|
|
786
|
+
* The post-embed card an image `src` renders as, or `undefined` for a plain image.
|
|
787
|
+
*/
|
|
788
|
+
export declare function matchPostEmbed(src: string): PostEmbedKind | undefined;
|
|
789
|
+
export declare const defaultResolveXPost: XPostResolver;
|
|
790
|
+
export declare const defaultResolveYouTubeVideo: YouTubeVideoResolver;
|
|
791
|
+
/**
|
|
792
|
+
* The `snapshot` field of an image's magic comment: the card kind and the
|
|
793
|
+
* data post-embed renders. The kind is stored explicitly, so a saved snapshot
|
|
794
|
+
* is validated once, against the schema it names.
|
|
795
|
+
*/
|
|
796
|
+
type PostEmbedSnapshot = {
|
|
797
|
+
kind: 'x-post';
|
|
798
|
+
data: XPost;
|
|
799
|
+
} | {
|
|
800
|
+
kind: 'youtube-video';
|
|
801
|
+
data: YouTubeVideo;
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
804
|
+
* The snapshot a card renders from a saved JSON object, or `undefined` when
|
|
805
|
+
* the object does not validate. Unknown fields are dropped, so a persisted
|
|
806
|
+
* snapshot is exactly what the card needs.
|
|
807
|
+
*/
|
|
808
|
+
export declare function parsePostEmbedSnapshot(value: unknown): PostEmbedSnapshot | undefined;
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region src/extensions/image.d.ts
|
|
811
|
+
type ImageUrlResolver = (src: string) => string | undefined;
|
|
812
|
+
/**
|
|
813
|
+
* Options for {@link defineImage}.
|
|
814
|
+
*/
|
|
815
|
+
interface ImageOptions {
|
|
816
|
+
/**
|
|
817
|
+
* Map a markdown `src` to a displayable URL, or `undefined` to skip rendering
|
|
818
|
+
* that image. Defaults to `defaultResolveImageUrl`.
|
|
819
|
+
*/
|
|
820
|
+
resolveImageUrl?: ImageUrlResolver;
|
|
821
|
+
/**
|
|
822
|
+
* Resolve the data behind an X post URL.
|
|
823
|
+
* When omitted, public posts use `defaultResolveXPost`.
|
|
824
|
+
*/
|
|
825
|
+
resolveXPost?: XPostResolver;
|
|
826
|
+
/**
|
|
827
|
+
* Additional trusted protocols for X media URLs, such as `reflect-asset:`.
|
|
828
|
+
*/
|
|
829
|
+
mediaUrlProtocols?: string[];
|
|
830
|
+
/**
|
|
831
|
+
* Resolve the data behind a YouTube video URL, rendered as a
|
|
832
|
+
* `post-embed-youtube-video` card. Defaults to `defaultResolveYouTubeVideo`,
|
|
833
|
+
* which reads YouTube's oEmbed endpoint.
|
|
834
|
+
*/
|
|
835
|
+
resolveYouTubeVideo?: YouTubeVideoResolver;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Show an `src` as-is when it is an http(s) URL, otherwise skip rendering it.
|
|
839
|
+
*/
|
|
840
|
+
export declare function defaultResolveImageUrl(src: string): string | undefined;
|
|
841
|
+
/**
|
|
842
|
+
* Inline image/embed rendering: a mark view on the `mdImage` mark. Images
|
|
843
|
+
* render in place from their literal Markdown source. Drag a rendered image's
|
|
844
|
+
* corner handle to write the size back into the source as a trailing comment,
|
|
845
|
+
* `<!-- {"width":320,"height":240} -->`, which round-trips as
|
|
846
|
+
* plain Markdown.
|
|
847
|
+
*/
|
|
848
|
+
export declare function defineImage(getOptions?: (state: EditorState) => ImageOptions | undefined): PlainExtension;
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/extensions/mark-chunk.d.ts
|
|
851
|
+
/**
|
|
852
|
+
* Contiguous range with a uniform inline-mark set.
|
|
853
|
+
*/
|
|
854
|
+
type MarkChunk = readonly [from: number, to: number, marks: readonly Mark[]];
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region src/extensions/reference-links.d.ts
|
|
857
|
+
interface ReferenceDefinition {
|
|
858
|
+
key: string;
|
|
859
|
+
href: string;
|
|
860
|
+
title: string;
|
|
861
|
+
}
|
|
862
|
+
type ReferenceDefinitions = ReadonlyMap<string, ReferenceDefinition>;
|
|
863
|
+
interface ReferenceDefinitionIndex {
|
|
864
|
+
definitions: ReferenceDefinitions;
|
|
865
|
+
nodes: ReadonlySet<EditorNode>;
|
|
866
|
+
}
|
|
867
|
+
export declare function isReferenceDefinitionNode(node: EditorNode, parent: EditorNode | null, index: number): boolean;
|
|
868
|
+
export declare function collectReferenceDefinitions(doc: EditorNode): ReferenceDefinitionIndex;
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/extensions/wiki-embed.d.ts
|
|
871
|
+
/**
|
|
872
|
+
* The parsed source payload of an Obsidian-style `![[target]]` embed.
|
|
873
|
+
*/
|
|
874
|
+
interface ParsedWikiEmbed {
|
|
875
|
+
/**
|
|
876
|
+
* Target before an optional alias or size suffix.
|
|
877
|
+
*/
|
|
878
|
+
target: string;
|
|
879
|
+
/**
|
|
880
|
+
* Non-size suffix after `|`, or `''` when absent.
|
|
881
|
+
*/
|
|
882
|
+
display: string;
|
|
883
|
+
/**
|
|
884
|
+
* Requested display width in CSS pixels, or `null`.
|
|
885
|
+
*/
|
|
886
|
+
width: number | null;
|
|
887
|
+
/**
|
|
888
|
+
* Requested display height in CSS pixels, or `null`.
|
|
889
|
+
*/
|
|
890
|
+
height: number | null;
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* A resolved wiki embed rendered through Meowdown's existing atom views.
|
|
894
|
+
*/
|
|
895
|
+
type WikiEmbedResolution = {
|
|
896
|
+
kind: 'image';
|
|
897
|
+
/**
|
|
898
|
+
* Source passed to `resolveImageUrl` and image click handlers. Defaults to `target`.
|
|
899
|
+
*/
|
|
900
|
+
src?: string;
|
|
901
|
+
/**
|
|
902
|
+
* Image alt text. Defaults to the alias or target basename.
|
|
903
|
+
*/
|
|
904
|
+
alt?: string;
|
|
905
|
+
} | {
|
|
906
|
+
kind: 'file';
|
|
907
|
+
/**
|
|
908
|
+
* Destination passed to file metadata and click handlers. Defaults to `target`.
|
|
909
|
+
*/
|
|
910
|
+
href?: string;
|
|
911
|
+
/**
|
|
912
|
+
* File pill label. Defaults to the alias or target basename.
|
|
913
|
+
*/
|
|
914
|
+
name?: string;
|
|
915
|
+
/**
|
|
916
|
+
* Optional file title.
|
|
917
|
+
*/
|
|
918
|
+
title?: string;
|
|
919
|
+
} | {
|
|
920
|
+
kind: 'note';
|
|
921
|
+
/**
|
|
922
|
+
* Target passed to wikilink click handlers. Defaults to the source target.
|
|
923
|
+
*/
|
|
924
|
+
target?: string;
|
|
925
|
+
/**
|
|
926
|
+
* Chip label. Defaults to the source alias or resolved target.
|
|
927
|
+
*/
|
|
928
|
+
display?: string;
|
|
929
|
+
};
|
|
930
|
+
/**
|
|
931
|
+
* Classifies one wiki embed for rendering. Return `undefined` to leave the
|
|
932
|
+
* source literal and editable. The resolver participates in the parse cache,
|
|
933
|
+
* so it must be pure: the same payload must always return the same result.
|
|
934
|
+
*/
|
|
935
|
+
type WikiEmbedResolver = (embed: ParsedWikiEmbed) => WikiEmbedResolution | undefined;
|
|
936
|
+
/**
|
|
937
|
+
* Host options for wiki-embed parsing.
|
|
938
|
+
*/
|
|
939
|
+
interface WikiEmbedOptions {
|
|
940
|
+
resolveWikiEmbed?: WikiEmbedResolver;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Parse `![[target]]`, `![[target|alias]]`, `![[target|width]]`, or `![[target|widthxheight]]`.
|
|
944
|
+
*/
|
|
945
|
+
export declare function parseWikiEmbed(source: string): ParsedWikiEmbed;
|
|
946
|
+
/**
|
|
947
|
+
* Rewrite a wiki image embed with a persisted display size.
|
|
948
|
+
*/
|
|
949
|
+
export declare function formatSizedWikiEmbed(target: string, width: number, height: number): string;
|
|
950
|
+
/**
|
|
951
|
+
* Last path component of a target, with a note heading/block fragment removed.
|
|
952
|
+
*/
|
|
953
|
+
export declare function wikiEmbedBasename(target: string): string;
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/extensions/wikilink.d.ts
|
|
956
|
+
/**
|
|
957
|
+
* What {@link WikilinkResolver} sees for one `[[...]]` wikilink.
|
|
958
|
+
*/
|
|
959
|
+
interface WikilinkPayload {
|
|
960
|
+
/**
|
|
961
|
+
* The text between the brackets, trimmed. Meowdown reads no syntax inside
|
|
962
|
+
* it: an alias form such as `[[target|alias]]` arrives here whole.
|
|
963
|
+
*/
|
|
964
|
+
target: string;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* A resolved wikilink.
|
|
968
|
+
*/
|
|
969
|
+
interface WikilinkResolution {
|
|
970
|
+
/**
|
|
971
|
+
* Target passed to click and hover handlers. Defaults to the bracketed text.
|
|
972
|
+
*/
|
|
973
|
+
target?: string;
|
|
974
|
+
/**
|
|
975
|
+
* Label shown in place of the source. Defaults to the target.
|
|
976
|
+
*/
|
|
977
|
+
display?: string;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Resolves one `[[...]]` wikilink into the target its handlers receive and
|
|
981
|
+
* the label its chip shows; the Markdown source stays as written. Return
|
|
982
|
+
* `undefined` to use the bracketed text as both. The resolver participates
|
|
983
|
+
* in the parse cache, so it must be pure: the same payload must always
|
|
984
|
+
* return the same result.
|
|
985
|
+
*/
|
|
986
|
+
type WikilinkResolver = (link: WikilinkPayload) => WikilinkResolution | undefined;
|
|
987
|
+
/**
|
|
988
|
+
* Host options for wikilink parsing.
|
|
989
|
+
*/
|
|
990
|
+
interface WikilinkOptions {
|
|
991
|
+
resolveWikilink?: WikilinkResolver;
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/extensions/inline-text-to-mark-chunks.d.ts
|
|
995
|
+
/**
|
|
996
|
+
* What {@link FileLinkResolver} sees for one `[label](url)` link.
|
|
997
|
+
*/
|
|
998
|
+
interface FileLinkPayload {
|
|
999
|
+
/**
|
|
1000
|
+
* The link destination, exactly as written in the source.
|
|
1001
|
+
*/
|
|
1002
|
+
href: string;
|
|
1003
|
+
/**
|
|
1004
|
+
* The raw label slice between the brackets; may be empty or contain nested syntax.
|
|
1005
|
+
*/
|
|
1006
|
+
label: string;
|
|
1007
|
+
/**
|
|
1008
|
+
* The link title, or `''` when the source has none.
|
|
1009
|
+
*/
|
|
1010
|
+
title: string;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Claims a `[label](url)` link as a file attachment. A claimed link carries a
|
|
1014
|
+
* single `mdFile` mark over its whole source (rendered as a file pill by
|
|
1015
|
+
* `defineFileView`) instead of the usual link marks, so link click/hover/menu
|
|
1016
|
+
* no longer apply to it. Must be pure: parse results are cached and diffed,
|
|
1017
|
+
* so the same input must always produce the same answer.
|
|
1018
|
+
*/
|
|
1019
|
+
type FileLinkResolver = (link: FileLinkPayload) => boolean;
|
|
1020
|
+
/**
|
|
1021
|
+
* Host options that influence inline parsing.
|
|
1022
|
+
*/
|
|
1023
|
+
interface FileLinkOptions {
|
|
1024
|
+
/**
|
|
1025
|
+
* Claim `[label](url)` links as file attachments; see {@link FileLinkResolver}.
|
|
1026
|
+
* Updates existing content when the configured resolver changes.
|
|
1027
|
+
*/
|
|
1028
|
+
resolveFileLink?: FileLinkResolver;
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Host options that influence source-backed inline atom parsing.
|
|
1032
|
+
*/
|
|
1033
|
+
type InlineMarkOptions = FileLinkOptions & WikiEmbedOptions & WikilinkOptions;
|
|
1034
|
+
interface InlineMarkContext {
|
|
1035
|
+
/**
|
|
1036
|
+
* Effective document-wide definitions, keyed by normalized reference label.
|
|
1037
|
+
*/
|
|
1038
|
+
referenceDefinitions?: ReferenceDefinitions;
|
|
1039
|
+
/**
|
|
1040
|
+
* Prevent this definition block's own label from resolving as a shortcut reference.
|
|
1041
|
+
*/
|
|
1042
|
+
isReferenceDefinition?: boolean;
|
|
1043
|
+
/**
|
|
1044
|
+
* Receives every normalized key read by this block, including unresolved references.
|
|
1045
|
+
*/
|
|
1046
|
+
referencedKeys?: Set<string>;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Walk a textblock's inline content and produce a list of mark chunks
|
|
1050
|
+
* with positions relative to the start of `text` (i.e. zero-based).
|
|
1051
|
+
* Callers shift the chunks into the document's coordinate space.
|
|
1052
|
+
*/
|
|
1053
|
+
export declare function inlineTextToMarkChunks(
|
|
1054
|
+
/**
|
|
1055
|
+
* Typed mark builders bound to the target schema.
|
|
711
1056
|
*/
|
|
712
1057
|
marks: TypedMarkBuilders,
|
|
713
1058
|
/**
|
|
@@ -731,6 +1076,21 @@ export declare function inlineTextToMarkChunksWithContext(marks: TypedMarkBuilde
|
|
|
731
1076
|
*/
|
|
732
1077
|
type MarkMode = 'hide' | 'focus' | 'show';
|
|
733
1078
|
//#endregion
|
|
1079
|
+
//#region src/extensions/editor-config-types.d.ts
|
|
1080
|
+
interface EditorConfig extends InlineMarkOptions, FollowLinkHandlers, FilePasteOptions, FileViewOptions, ImageOptions {
|
|
1081
|
+
markMode?: MarkMode;
|
|
1082
|
+
onExitBoundary?: ExitBoundaryHandler;
|
|
1083
|
+
embedPaste?: boolean;
|
|
1084
|
+
linkPaste?: boolean;
|
|
1085
|
+
bulletAfterHeading?: boolean;
|
|
1086
|
+
substitution?: boolean;
|
|
1087
|
+
wikilinkEnabled?: boolean;
|
|
1088
|
+
placeholder?: PlaceholderOptions$1['placeholder'];
|
|
1089
|
+
readOnly?: boolean;
|
|
1090
|
+
spellCheck?: boolean;
|
|
1091
|
+
editorClassName?: string;
|
|
1092
|
+
}
|
|
1093
|
+
//#endregion
|
|
734
1094
|
//#region src/extensions/extension.d.ts
|
|
735
1095
|
declare function defineEditorExtensionImpl(options: EditorExtensionOptions): import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
736
1096
|
Nodes: import("@prosekit/core").SimplifyDeeper<{
|
|
@@ -872,7 +1232,7 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
872
1232
|
Marks: {
|
|
873
1233
|
mdPack: MdPackAttrs;
|
|
874
1234
|
};
|
|
875
|
-
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<import("@prosekit/core").ExtensionTyping<any, any, any>>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
1235
|
+
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<import("@prosekit/core").ExtensionTyping<any, any, any>>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
876
1236
|
Commands: {
|
|
877
1237
|
insertSoftBreak: [];
|
|
878
1238
|
};
|
|
@@ -890,498 +1250,151 @@ declare function defineEditorExtensionImpl(options: EditorExtensionOptions): imp
|
|
|
890
1250
|
updateLink: [attrs: LinkAttrs];
|
|
891
1251
|
removeLink: [];
|
|
892
1252
|
};
|
|
893
|
-
}>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").
|
|
894
|
-
Commands: {
|
|
895
|
-
setMarkMode: [mode: MarkMode];
|
|
896
|
-
};
|
|
897
|
-
}>]>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").BaseCommandsExtension, import("@prosekit/core").HistoryExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
1253
|
+
}>, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").BaseCommandsExtension, import("@prosekit/core").HistoryExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
898
1254
|
Commands: {
|
|
899
1255
|
insertMarkdown: [markdown: string];
|
|
900
1256
|
insertTrigger: [text: string];
|
|
901
1257
|
scrollIntoView: [];
|
|
902
|
-
selectText: [anchor: number, head?: number | undefined];
|
|
903
|
-
selectTextBetween: [$anchor: import("@prosekit/pm/model").ResolvedPos, $head: import("@prosekit/pm/model").ResolvedPos, bias?: number | undefined];
|
|
904
|
-
turnIntoText: [];
|
|
905
|
-
};
|
|
906
|
-
}>, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
907
|
-
Commands: {
|
|
908
|
-
startPendingReplacement: [options: StartPendingReplacementOptions];
|
|
909
|
-
appendPendingReplacementText: [text: string];
|
|
910
|
-
acceptPendingReplacement: [options?: AcceptPendingReplacementOptions | undefined];
|
|
911
|
-
discardPendingReplacement: [];
|
|
912
|
-
};
|
|
913
|
-
}>, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/extensions/search").SearchCommandsExtension, import("@prosekit/core").PlainExtension]>]>;
|
|
914
|
-
type EditorExtension = ReturnType<typeof defineEditorExtensionImpl>;
|
|
915
|
-
/**
|
|
916
|
-
* Options for {@link defineEditorExtension}. Creation-time configuration:
|
|
917
|
-
* `resolveFileLink`, `resolveWikiEmbed`, and `resolveWikilink` are baked into
|
|
918
|
-
* the editor's parse pipeline, so changing them requires rebuilding the
|
|
919
|
-
* editor; `markMode` is only the initial value.
|
|
920
|
-
*/
|
|
921
|
-
type EditorExtensionOptions = InlineMarkOptions & {
|
|
922
|
-
/**
|
|
923
|
-
* The initial mark mode, applied from the first paint. Defaults to
|
|
924
|
-
* `'focus'`. Switch later with the `setMarkMode` command.
|
|
925
|
-
*/
|
|
926
|
-
markMode?: MarkMode;
|
|
927
|
-
};
|
|
928
|
-
export declare function defineEditorExtension(options?: EditorExtensionOptions): EditorExtension;
|
|
929
|
-
type TypedEditor = Editor<EditorExtension>;
|
|
930
|
-
//#endregion
|
|
931
|
-
//#region src/extensions/schema.d.ts
|
|
932
|
-
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
933
|
-
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
934
|
-
/**
|
|
935
|
-
* Typed mark builders bound to the shared schema.
|
|
936
|
-
*/
|
|
937
|
-
export declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
938
|
-
//#endregion
|
|
939
|
-
//#region src/converters/md-to-pm.d.ts
|
|
940
|
-
/**
|
|
941
|
-
* Options for {@link markdownToDoc}.
|
|
942
|
-
*/
|
|
943
|
-
interface MarkdownToDocOptions {
|
|
944
|
-
/**
|
|
945
|
-
* Node builders to build the document with. Defaults to the shared schema's builders.
|
|
946
|
-
*/
|
|
947
|
-
nodes?: TypedNodeBuilders;
|
|
948
|
-
/**
|
|
949
|
-
* Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default.
|
|
950
|
-
*/
|
|
951
|
-
frontmatter?: boolean;
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Convert a markdown string into a ProseMirror document node.
|
|
955
|
-
*
|
|
956
|
-
* By default the document is built with the shared schema's node builders, so
|
|
957
|
-
* no editor is required. When the result will be loaded into a specific editor,
|
|
958
|
-
* pass that editor's `nodes` so the document uses the editor's own schema
|
|
959
|
-
* instance and can be inserted without a JSON round trip.
|
|
960
|
-
*
|
|
961
|
-
* The output follows the extension set defined in `../extensions/extension.ts`
|
|
962
|
-
* (doc, paragraph, text, heading, blockquote, list, codeBlock, table, tableRow,
|
|
963
|
-
* tableCell, tableHeaderCell, horizontalRule). The function does not produce
|
|
964
|
-
* inline marks because the markdown stays literal text - emphasis / link /
|
|
965
|
-
* inline-code characters survive verbatim.
|
|
966
|
-
*/
|
|
967
|
-
export declare function markdownToDoc(markdown: string, options?: MarkdownToDocOptions): ProseMirrorNode;
|
|
968
|
-
//#endregion
|
|
969
|
-
//#region src/converters/pm-to-md.d.ts
|
|
970
|
-
/**
|
|
971
|
-
* Options for {@link docToMarkdown}.
|
|
972
|
-
*/
|
|
973
|
-
interface DocToMarkdownOptions {
|
|
974
|
-
/**
|
|
975
|
-
* Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default.
|
|
976
|
-
*/
|
|
977
|
-
frontmatter?: boolean;
|
|
978
|
-
}
|
|
979
|
-
/**
|
|
980
|
-
* Convert a ProseMirror document into a Markdown string.
|
|
981
|
-
*
|
|
982
|
-
* Performance design:
|
|
983
|
-
* - Output accumulates in a `string[]` buffer; joined once at the end.
|
|
984
|
-
* Avoids per-block intermediate strings while keeping the
|
|
985
|
-
* function-per-node-type readability of a switch dispatch.
|
|
986
|
-
* - Indent stack lives as a mutable `linePrefix` on the buffer object,
|
|
987
|
-
* restored via local variables across nested calls - no fresh
|
|
988
|
-
* context objects per recursion.
|
|
989
|
-
* - Inline content is walked directly (not via `node.textContent`) to
|
|
990
|
-
* skip one intermediate string allocation per leaf block.
|
|
991
|
-
* - Backtick fence width and cell escaping use single linear loops, no
|
|
992
|
-
* regex on the hot path.
|
|
993
|
-
*/
|
|
994
|
-
export declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
|
|
995
|
-
//#endregion
|
|
996
|
-
//#region src/extensions/bullet-after-heading.d.ts
|
|
997
|
-
/**
|
|
998
|
-
* "Type a title, press Return, start bullets." When this extension is applied,
|
|
999
|
-
* pressing Enter at the end of the document's first heading (the title line)
|
|
1000
|
-
* drops the caret into a fresh empty bullet instead of a plain paragraph.
|
|
1001
|
-
*/
|
|
1002
|
-
export declare function defineBulletAfterHeading(): PlainExtension;
|
|
1003
|
-
//#endregion
|
|
1004
|
-
//#region src/extensions/code-block-highlight.d.ts
|
|
1005
|
-
/**
|
|
1006
|
-
* Adds syntax highlighting to `codeBlock` nodes, parsing each block with the
|
|
1007
|
-
* matching CodeMirror/Lezer grammar (loaded on demand from
|
|
1008
|
-
* `@codemirror/language-data`). Tokens are tagged with `@lezer/highlight`
|
|
1009
|
-
* `tok-*` classes; the default theme colors them per color scheme.
|
|
1010
|
-
*/
|
|
1011
|
-
export declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
1012
|
-
/**
|
|
1013
|
-
* A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes.
|
|
1014
|
-
*/
|
|
1015
|
-
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
1016
|
-
/**
|
|
1017
|
-
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
1018
|
-
* editor's decorations use. Returns synchronously when the grammar is already
|
|
1019
|
-
* loaded (the common path, no render flash), and a `Promise` only when a grammar
|
|
1020
|
-
* must load on demand. Returns `[]` for an empty or unsupported language.
|
|
1021
|
-
*/
|
|
1022
|
-
export declare function getCodeTokens(code: string, language: string): CodeToken[] | Promise<CodeToken[]>;
|
|
1023
|
-
//#endregion
|
|
1024
|
-
//#region src/extensions/code-block-languages.d.ts
|
|
1025
|
-
type LanguageItem = {
|
|
1026
|
-
label: string;
|
|
1027
|
-
value: string;
|
|
1028
|
-
};
|
|
1029
|
-
/**
|
|
1030
|
-
* A list of languages for code block syntax-highlight.
|
|
1031
|
-
*/
|
|
1032
|
-
export declare const codeBlockLanguages: ReadonlyArray<LanguageItem>;
|
|
1033
|
-
//#endregion
|
|
1034
|
-
//#region src/extensions/embed-paste.d.ts
|
|
1035
|
-
/**
|
|
1036
|
-
* Auto-embed a pasted tweet or YouTube link. When the clipboard holds exactly
|
|
1037
|
-
* one such URL, the link is rewritten to ``, which the image pipeline
|
|
1038
|
-
* renders as a rich embed. Not part of `defineEditorExtension`; the React
|
|
1039
|
-
* package applies it via the `embedPaste` prop (on by default).
|
|
1040
|
-
*/
|
|
1041
|
-
export declare function defineEmbedPaste(): PlainExtension;
|
|
1042
|
-
//#endregion
|
|
1043
|
-
//#region src/extensions/exit-boundary.d.ts
|
|
1044
|
-
/**
|
|
1045
|
-
* Payload for {@link ExitBoundaryHandler}.
|
|
1046
|
-
*/
|
|
1047
|
-
interface ExitBoundaryOptions {
|
|
1048
|
-
/**
|
|
1049
|
-
* The boundary the caret would leave: `up` at the document start, `down` at the end.
|
|
1050
|
-
*/
|
|
1051
|
-
direction: 'up' | 'down';
|
|
1052
|
-
/**
|
|
1053
|
-
* The originating arrow key press.
|
|
1054
|
-
*/
|
|
1055
|
-
event: KeyboardEvent;
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Called when an arrow key press would move the caret past the document
|
|
1059
|
-
* boundary. Return `false` to let the editor handle the key normally; any
|
|
1060
|
-
* other return value consumes it.
|
|
1061
|
-
*/
|
|
1062
|
-
type ExitBoundaryHandler = (options: ExitBoundaryOptions) => boolean | void;
|
|
1063
|
-
/**
|
|
1064
|
-
* Call `onExitBoundary` when an arrow key press would leave the document boundary.
|
|
1065
|
-
*/
|
|
1066
|
-
export declare function defineExitBoundaryHandler(onExitBoundary: ExitBoundaryHandler): PlainExtension;
|
|
1067
|
-
//#endregion
|
|
1068
|
-
//#region src/extensions/file-click.d.ts
|
|
1069
|
-
/**
|
|
1070
|
-
* Payload for {@link FileClickHandler}.
|
|
1071
|
-
*/
|
|
1072
|
-
interface FileClickPayload {
|
|
1073
|
-
/**
|
|
1074
|
-
* The resolved destination from `[name](href)` or a claimed `![[target]]`.
|
|
1075
|
-
*/
|
|
1076
|
-
href: string;
|
|
1077
|
-
/**
|
|
1078
|
-
* The file name shown on the pill.
|
|
1079
|
-
*/
|
|
1080
|
-
name: string;
|
|
1081
|
-
/**
|
|
1082
|
-
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the
|
|
1083
|
-
* pill. Read modifier keys or position a popover from it.
|
|
1084
|
-
*/
|
|
1085
|
-
event: MouseEvent | KeyboardEvent;
|
|
1086
|
-
/**
|
|
1087
|
-
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1088
|
-
* beyond the gesture that triggered the activation.
|
|
1089
|
-
*/
|
|
1090
|
-
mod: boolean;
|
|
1091
|
-
}
|
|
1092
|
-
type FileClickHandler = (payload: FileClickPayload) => void;
|
|
1093
|
-
/**
|
|
1094
|
-
* Call `onClick` when the user clicks a rendered file pill, with the file's
|
|
1095
|
-
* `href`, `name`, and the originating `MouseEvent`. The host decides what a
|
|
1096
|
-
* click does (e.g. open the file in the OS default app).
|
|
1097
|
-
*/
|
|
1098
|
-
export declare function defineFileClickHandler(onClick: FileClickHandler): PlainExtension;
|
|
1099
|
-
//#endregion
|
|
1100
|
-
//#region src/extensions/file-paste.d.ts
|
|
1101
|
-
type FilePasteHandler = (file: File) => string | undefined | Promise<string | undefined>;
|
|
1102
|
-
type FileSaveErrorHandler = (error: unknown, file: File) => void;
|
|
1103
|
-
/**
|
|
1104
|
-
* Options for {@link defineFilePaste}.
|
|
1105
|
-
*/
|
|
1106
|
-
interface FilePasteOptions {
|
|
1107
|
-
/**
|
|
1108
|
-
* Persist a pasted/dropped file and return its markdown destination, or
|
|
1109
|
-
* `undefined` to decline (nothing is inserted, but the event is consumed).
|
|
1110
|
-
* An image (`image/*` MIME type or a recognized image filename extension)
|
|
1111
|
-
* inserts ``; any other file inserts a `[name](src)` link.
|
|
1112
|
-
*/
|
|
1113
|
-
onFilePaste?: FilePasteHandler;
|
|
1114
|
-
/**
|
|
1115
|
-
* Called when persisting a pasted/dropped file throws. Defaults to `console.error`.
|
|
1116
|
-
*/
|
|
1117
|
-
onFileSaveError?: FileSaveErrorHandler;
|
|
1118
|
-
}
|
|
1119
|
-
/**
|
|
1120
|
-
* The markdown a saved file becomes: `` for an image (a
|
|
1121
|
-
* `type` starting with `image/` or a recognized image filename extension), a
|
|
1122
|
-
* `[name](destination)` link otherwise, with `\`, `[`, and `]` escaped in the
|
|
1123
|
-
* name. Exported so a host command that inserts file links itself (e.g. an
|
|
1124
|
-
* attach-file picker) produces markdown byte-identical to a paste/drop.
|
|
1125
|
-
*/
|
|
1126
|
-
export declare function buildFileMarkdown(file: {
|
|
1127
|
-
name: string;
|
|
1128
|
-
type?: string;
|
|
1129
|
-
}, destination: string): string;
|
|
1130
|
-
/**
|
|
1131
|
-
* Persist pasted/dropped files via `onFilePaste` and insert the returned
|
|
1132
|
-
* markdown destination: `` for an image, a `[name](src)` link for any
|
|
1133
|
-
* other file. Multiple files insert one link per line, in DataTransfer order.
|
|
1134
|
-
*/
|
|
1135
|
-
export declare function defineFilePaste(options?: FilePasteOptions): PlainExtension;
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region src/extensions/file-view.d.ts
|
|
1138
|
-
/**
|
|
1139
|
-
* Metadata a host resolves for one file link, shown on its pill.
|
|
1140
|
-
*/
|
|
1141
|
-
interface FileInfo {
|
|
1142
|
-
/**
|
|
1143
|
-
* File size in bytes, shown as a human-readable suffix (e.g. `1.4 MB`).
|
|
1144
|
-
*/
|
|
1145
|
-
size?: number;
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Resolve display metadata for a file `href`, directly or as a promise; the
|
|
1149
|
-
* pill renders immediately and fills the metadata in when the promise
|
|
1150
|
-
* settles. Return `undefined` for a file without metadata (e.g. one that no
|
|
1151
|
-
* longer exists). Called once per rendered pill, so the same `href` may
|
|
1152
|
-
* resolve repeatedly: cache in the host when resolving is expensive.
|
|
1153
|
-
*/
|
|
1154
|
-
type FileInfoResolver = (href: string) => FileInfo | undefined | Promise<FileInfo | undefined>;
|
|
1155
|
-
/**
|
|
1156
|
-
* Options for {@link defineFileView}.
|
|
1157
|
-
*/
|
|
1158
|
-
interface FileViewOptions {
|
|
1159
|
-
/**
|
|
1160
|
-
* Resolve the metadata (file size) shown on a pill. Omit to show none.
|
|
1161
|
-
*/
|
|
1162
|
-
resolveFileInfo?: FileInfoResolver;
|
|
1163
|
-
}
|
|
1258
|
+
selectText: [anchor: number, head?: number | undefined];
|
|
1259
|
+
selectTextBetween: [$anchor: import("@prosekit/pm/model").ResolvedPos, $head: import("@prosekit/pm/model").ResolvedPos, bias?: number | undefined];
|
|
1260
|
+
turnIntoText: [];
|
|
1261
|
+
};
|
|
1262
|
+
}>, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/core").Extension<{
|
|
1263
|
+
Commands: {
|
|
1264
|
+
startPendingReplacement: [options: StartPendingReplacementOptions];
|
|
1265
|
+
appendPendingReplacementText: [text: string];
|
|
1266
|
+
acceptPendingReplacement: [options?: AcceptPendingReplacementOptions | undefined];
|
|
1267
|
+
discardPendingReplacement: [];
|
|
1268
|
+
};
|
|
1269
|
+
}>, import("@prosekit/core").PlainExtension]>, import("@prosekit/core").Union<readonly [import("@prosekit/core").PlainExtension, import("@prosekit/extensions/search").SearchCommandsExtension, import("@prosekit/core").PlainExtension]>]>;
|
|
1270
|
+
type EditorExtension = ReturnType<typeof defineEditorExtensionImpl>;
|
|
1164
1271
|
/**
|
|
1165
|
-
*
|
|
1272
|
+
* Initial configuration, updatable with `updateEditorConfig`.
|
|
1166
1273
|
*/
|
|
1167
|
-
|
|
1274
|
+
type EditorExtensionOptions = EditorConfig;
|
|
1275
|
+
export declare function defineEditorExtension(options?: EditorExtensionOptions): EditorExtension;
|
|
1276
|
+
type TypedEditor = Editor<EditorExtension>;
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region src/extensions/schema.d.ts
|
|
1279
|
+
type TypedNodeBuilders = ExtractNodeBuilders<EditorExtension>;
|
|
1280
|
+
type TypedMarkBuilders = ExtractMarkBuilders<EditorExtension>;
|
|
1168
1281
|
/**
|
|
1169
|
-
*
|
|
1170
|
-
* pill: a file-kind icon, the file name, and the size once
|
|
1171
|
-
* `resolveFileInfo` supplies it. The pill never loads the file's content;
|
|
1172
|
-
* clicks are reported through `defineFileClickHandler`.
|
|
1282
|
+
* Typed mark builders bound to the shared schema.
|
|
1173
1283
|
*/
|
|
1174
|
-
export declare
|
|
1284
|
+
export declare const getMarkBuilders: () => TypedMarkBuilders;
|
|
1175
1285
|
//#endregion
|
|
1176
|
-
//#region src/
|
|
1286
|
+
//#region src/converters/md-to-pm.d.ts
|
|
1177
1287
|
/**
|
|
1178
|
-
*
|
|
1288
|
+
* Options for {@link markdownToDoc}.
|
|
1179
1289
|
*/
|
|
1180
|
-
interface
|
|
1181
|
-
/**
|
|
1182
|
-
* The resolved source from `` or a claimed `![[target]]`.
|
|
1183
|
-
*/
|
|
1184
|
-
src: string;
|
|
1185
|
-
/**
|
|
1186
|
-
* The image alt text.
|
|
1187
|
-
*/
|
|
1188
|
-
alt: string;
|
|
1290
|
+
interface MarkdownToDocOptions {
|
|
1189
1291
|
/**
|
|
1190
|
-
*
|
|
1191
|
-
* that followed the selected image. Read the target or position a popover
|
|
1192
|
-
* from it; a touch surface delivers the `touchend` instead of a click.
|
|
1292
|
+
* Node builders to build the document with. Defaults to the shared schema's builders.
|
|
1193
1293
|
*/
|
|
1194
|
-
|
|
1294
|
+
nodes?: TypedNodeBuilders;
|
|
1195
1295
|
/**
|
|
1196
|
-
* Whether
|
|
1197
|
-
* beyond the gesture that triggered the activation.
|
|
1296
|
+
* Whether to peel a leading `---` frontmatter block onto the doc's `frontmatter` attribute. Off by default.
|
|
1198
1297
|
*/
|
|
1199
|
-
|
|
1298
|
+
frontmatter?: boolean;
|
|
1200
1299
|
}
|
|
1201
|
-
type ImageClickHandler = (payload: ImageClickPayload) => void;
|
|
1202
1300
|
/**
|
|
1203
|
-
*
|
|
1204
|
-
* the image's markdown `src`, `alt`, and the originating event.
|
|
1301
|
+
* Convert a markdown string into a ProseMirror document node.
|
|
1205
1302
|
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
*
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
interface LinkClickPayload {
|
|
1217
|
-
href: string;
|
|
1218
|
-
/**
|
|
1219
|
-
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1220
|
-
*/
|
|
1221
|
-
event: MouseEvent | KeyboardEvent;
|
|
1222
|
-
/**
|
|
1223
|
-
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1224
|
-
* beyond the gesture that triggered the activation.
|
|
1225
|
-
*/
|
|
1226
|
-
mod: boolean;
|
|
1227
|
-
}
|
|
1228
|
-
type LinkClickHandler = (payload: LinkClickPayload) => void;
|
|
1229
|
-
interface LinkCopyPayload {
|
|
1230
|
-
href: string;
|
|
1231
|
-
}
|
|
1232
|
-
type LinkCopyHandler = (payload: LinkCopyPayload) => void;
|
|
1233
|
-
/**
|
|
1234
|
-
* Call `onClick` when the user clicks a rendered Markdown link
|
|
1235
|
-
* (`[text](url)`), or presses `Mod-Enter` with the caret on one. The `event`
|
|
1236
|
-
* is the originating `MouseEvent` or `KeyboardEvent`.
|
|
1303
|
+
* By default the document is built with the shared schema's node builders, so
|
|
1304
|
+
* no editor is required. When the result will be loaded into a specific editor,
|
|
1305
|
+
* pass that editor's `nodes` so the document uses the editor's own schema
|
|
1306
|
+
* instance and can be inserted without a JSON round trip.
|
|
1307
|
+
*
|
|
1308
|
+
* The output follows the extension set defined in `../extensions/extension.ts`
|
|
1309
|
+
* (doc, paragraph, text, heading, blockquote, list, codeBlock, table, tableRow,
|
|
1310
|
+
* tableCell, tableHeaderCell, horizontalRule). The function does not produce
|
|
1311
|
+
* inline marks because the markdown stays literal text - emphasis / link /
|
|
1312
|
+
* inline-code characters survive verbatim.
|
|
1237
1313
|
*/
|
|
1238
|
-
export declare function
|
|
1314
|
+
export declare function markdownToDoc(markdown: string, options?: MarkdownToDocOptions): ProseMirrorNode;
|
|
1239
1315
|
//#endregion
|
|
1240
|
-
//#region src/
|
|
1241
|
-
interface TagClickPayload {
|
|
1242
|
-
/**
|
|
1243
|
-
* The tag name, without the leading `#`.
|
|
1244
|
-
*/
|
|
1245
|
-
tag: string;
|
|
1246
|
-
/**
|
|
1247
|
-
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the tag.
|
|
1248
|
-
* Read modifier keys or position a popover from it.
|
|
1249
|
-
*/
|
|
1250
|
-
event: MouseEvent | KeyboardEvent;
|
|
1251
|
-
/**
|
|
1252
|
-
* Whether the platform's mod key (`Command` on Apple, `Ctrl` elsewhere) was held
|
|
1253
|
-
* beyond the gesture that triggered the activation.
|
|
1254
|
-
*/
|
|
1255
|
-
mod: boolean;
|
|
1256
|
-
}
|
|
1257
|
-
type TagClickHandler = (payload: TagClickPayload) => void;
|
|
1316
|
+
//#region src/converters/pm-to-md.d.ts
|
|
1258
1317
|
/**
|
|
1259
|
-
*
|
|
1260
|
-
* `Mod-Enter` with the caret on one. The `tag` is read from the rendered text
|
|
1261
|
-
* without the leading `#`.
|
|
1318
|
+
* Options for {@link docToMarkdown}.
|
|
1262
1319
|
*/
|
|
1263
|
-
|
|
1264
|
-
//#endregion
|
|
1265
|
-
//#region src/extensions/wikilink-click.d.ts
|
|
1266
|
-
interface WikilinkHit {
|
|
1267
|
-
from: number;
|
|
1268
|
-
to: number;
|
|
1269
|
-
target: string;
|
|
1270
|
-
}
|
|
1271
|
-
interface WikilinkClickPayload {
|
|
1272
|
-
target: string;
|
|
1273
|
-
/**
|
|
1274
|
-
* The originating click, or the `Enter`/`Mod-Enter` key press that followed the link.
|
|
1275
|
-
*/
|
|
1276
|
-
event: MouseEvent | KeyboardEvent;
|
|
1320
|
+
interface DocToMarkdownOptions {
|
|
1277
1321
|
/**
|
|
1278
|
-
* Whether the
|
|
1279
|
-
* beyond the gesture that triggered the activation.
|
|
1322
|
+
* Whether to serialize the doc's `frontmatter` attribute as a leading `---` block. Off by default.
|
|
1280
1323
|
*/
|
|
1281
|
-
|
|
1324
|
+
frontmatter?: boolean;
|
|
1282
1325
|
}
|
|
1283
|
-
type WikilinkClickHandler = (payload: WikilinkClickPayload) => void;
|
|
1284
1326
|
/**
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1327
|
+
* Convert a ProseMirror document into a Markdown string.
|
|
1328
|
+
*
|
|
1329
|
+
* Performance design:
|
|
1330
|
+
* - Output accumulates in a `string[]` buffer; joined once at the end.
|
|
1331
|
+
* Avoids per-block intermediate strings while keeping the
|
|
1332
|
+
* function-per-node-type readability of a switch dispatch.
|
|
1333
|
+
* - Indent stack lives as a mutable `linePrefix` on the buffer object,
|
|
1334
|
+
* restored via local variables across nested calls - no fresh
|
|
1335
|
+
* context objects per recursion.
|
|
1336
|
+
* - Inline content is walked directly (not via `node.textContent`) to
|
|
1337
|
+
* skip one intermediate string allocation per leaf block.
|
|
1338
|
+
* - Backtick fence width and cell escaping use single linear loops, no
|
|
1339
|
+
* regex on the hot path.
|
|
1288
1340
|
*/
|
|
1289
|
-
export declare function
|
|
1341
|
+
export declare function docToMarkdown(node: ProseMirrorNode, options?: DocToMarkdownOptions): string;
|
|
1290
1342
|
//#endregion
|
|
1291
|
-
//#region src/extensions/
|
|
1292
|
-
interface FollowLinkHandlers {
|
|
1293
|
-
onWikilinkClick?: WikilinkClickHandler;
|
|
1294
|
-
onTagClick?: TagClickHandler;
|
|
1295
|
-
onFileClick?: FileClickHandler;
|
|
1296
|
-
onLinkClick?: LinkClickHandler;
|
|
1297
|
-
onImageClick?: ImageClickHandler;
|
|
1298
|
-
}
|
|
1343
|
+
//#region src/extensions/bullet-after-heading.d.ts
|
|
1299
1344
|
/**
|
|
1300
|
-
*
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1303
|
-
* "Under the caret" means strictly inside the unit: a caret merely touching
|
|
1304
|
-
* a unit's edge is next to it, not on it.
|
|
1305
|
-
* Off a link, `Mod-Enter` falls through so the list keymap keeps cycling
|
|
1306
|
-
* checkbox tasks; off a selected unit, `Enter` falls through to the regular
|
|
1307
|
-
* split. High priority puts this ahead of every keymap binding.
|
|
1308
|
-
*
|
|
1309
|
-
* A selected-unit follow reports `mod: true` when the platform's mod key
|
|
1310
|
-
* (`⌘` on Apple, `Ctrl` elsewhere) was held beyond its plain-`Enter` trigger;
|
|
1311
|
-
* a caret follow always reports `mod: false`, its mod key being the trigger
|
|
1312
|
-
* itself.
|
|
1345
|
+
* "Type a title, press Return, start bullets." When this extension is applied,
|
|
1346
|
+
* pressing Enter at the end of the document's first heading (the title line)
|
|
1347
|
+
* drops the caret into a fresh empty bullet instead of a plain paragraph.
|
|
1313
1348
|
*/
|
|
1314
|
-
export declare function
|
|
1349
|
+
export declare function defineBulletAfterHeading(enabled?: (state: EditorState) => boolean): PlainExtension;
|
|
1315
1350
|
//#endregion
|
|
1316
|
-
//#region src/extensions/
|
|
1317
|
-
type XPostResolver = Resolver<XPost>;
|
|
1318
|
-
type YouTubeVideoResolver = Resolver<YouTubeVideo>;
|
|
1319
|
-
type PostEmbedKind = 'x-post' | 'youtube-video';
|
|
1351
|
+
//#region src/extensions/code-block-highlight.d.ts
|
|
1320
1352
|
/**
|
|
1321
|
-
*
|
|
1353
|
+
* Adds syntax highlighting to `codeBlock` nodes, parsing each block with the
|
|
1354
|
+
* matching CodeMirror/Lezer grammar (loaded on demand from
|
|
1355
|
+
* `@codemirror/language-data`). Tokens are tagged with `@lezer/highlight`
|
|
1356
|
+
* `tok-*` classes; the default theme colors them per color scheme.
|
|
1322
1357
|
*/
|
|
1323
|
-
export declare function
|
|
1358
|
+
export declare function defineCodeBlockSyntaxHighlight(): Extension;
|
|
1324
1359
|
/**
|
|
1325
|
-
*
|
|
1360
|
+
* A highlighted span of code: `[from, to)` carries the `@lezer/highlight` classes.
|
|
1326
1361
|
*/
|
|
1327
|
-
|
|
1328
|
-
export declare const defaultResolveXPost: XPostResolver;
|
|
1329
|
-
export declare const defaultResolveYouTubeVideo: YouTubeVideoResolver;
|
|
1362
|
+
type CodeToken = readonly [from: number, to: number, classes: string];
|
|
1330
1363
|
/**
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1364
|
+
* Highlight `code` in `language` into `tok-*` token spans, the same classes the
|
|
1365
|
+
* editor's decorations use. Returns synchronously when the grammar is already
|
|
1366
|
+
* loaded (the common path, no render flash), and a `Promise` only when a grammar
|
|
1367
|
+
* must load on demand. Returns `[]` for an empty or unsupported language.
|
|
1334
1368
|
*/
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1369
|
+
export declare function getCodeTokens(code: string, language: string): CodeToken[] | Promise<CodeToken[]>;
|
|
1370
|
+
//#endregion
|
|
1371
|
+
//#region src/extensions/code-block-languages.d.ts
|
|
1372
|
+
type LanguageItem = {
|
|
1373
|
+
label: string;
|
|
1374
|
+
value: string;
|
|
1341
1375
|
};
|
|
1342
1376
|
/**
|
|
1343
|
-
*
|
|
1344
|
-
* the object does not validate. Unknown fields are dropped, so a persisted
|
|
1345
|
-
* snapshot is exactly what the card needs.
|
|
1377
|
+
* A list of languages for code block syntax-highlight.
|
|
1346
1378
|
*/
|
|
1347
|
-
export declare
|
|
1379
|
+
export declare const codeBlockLanguages: ReadonlyArray<LanguageItem>;
|
|
1348
1380
|
//#endregion
|
|
1349
|
-
//#region src/extensions/
|
|
1350
|
-
type ImageUrlResolver = (src: string) => string | undefined;
|
|
1351
|
-
/**
|
|
1352
|
-
* Options for {@link defineImage}.
|
|
1353
|
-
*/
|
|
1354
|
-
interface ImageOptions {
|
|
1355
|
-
/**
|
|
1356
|
-
* Map a markdown `src` to a displayable URL, or `undefined` to skip rendering
|
|
1357
|
-
* that image. Defaults to `defaultResolveImageUrl`.
|
|
1358
|
-
*/
|
|
1359
|
-
resolveImageUrl?: ImageUrlResolver;
|
|
1360
|
-
/**
|
|
1361
|
-
* Resolve the data behind an X post URL, rendered as a `post-embed-x-post`
|
|
1362
|
-
* card. Defaults to `defaultResolveXPost`, which fetches through
|
|
1363
|
-
* react-tweet's hosted proxy.
|
|
1364
|
-
*/
|
|
1365
|
-
resolveXPost?: XPostResolver;
|
|
1366
|
-
/**
|
|
1367
|
-
* Resolve the data behind a YouTube video URL, rendered as a
|
|
1368
|
-
* `post-embed-youtube-video` card. Defaults to `defaultResolveYouTubeVideo`,
|
|
1369
|
-
* which reads YouTube's oEmbed endpoint.
|
|
1370
|
-
*/
|
|
1371
|
-
resolveYouTubeVideo?: YouTubeVideoResolver;
|
|
1372
|
-
}
|
|
1381
|
+
//#region src/extensions/editor-config-getter.d.ts
|
|
1373
1382
|
/**
|
|
1374
|
-
*
|
|
1383
|
+
* Read the current configuration. Callback values are live, not historical state snapshots.
|
|
1375
1384
|
*/
|
|
1376
|
-
export declare function
|
|
1385
|
+
export declare function getEditorConfig(state: EditorState): Readonly<EditorConfig>;
|
|
1386
|
+
//#endregion
|
|
1387
|
+
//#region src/extensions/editor-config.d.ts
|
|
1388
|
+
export declare function updateEditorConfig(editor: Pick<Editor, 'state' | 'view' | 'mounted' | 'updateState'>, patch: Partial<EditorConfig>): void;
|
|
1389
|
+
//#endregion
|
|
1390
|
+
//#region src/extensions/embed-paste.d.ts
|
|
1377
1391
|
/**
|
|
1378
|
-
*
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
* plain Markdown.
|
|
1392
|
+
* Auto-embed a pasted tweet or YouTube link. When the clipboard holds exactly
|
|
1393
|
+
* one such URL, the link is rewritten to ``, which the image pipeline
|
|
1394
|
+
* renders as a rich embed. Enable it through the `embedPaste` configuration
|
|
1395
|
+
* or install this standalone extension.
|
|
1383
1396
|
*/
|
|
1384
|
-
export declare function
|
|
1397
|
+
export declare function defineEmbedPaste(enabled?: (state: EditorState) => boolean): PlainExtension;
|
|
1385
1398
|
//#endregion
|
|
1386
1399
|
//#region src/extensions/key-bindings.d.ts
|
|
1387
1400
|
/**
|
|
@@ -1452,10 +1465,10 @@ export declare function defineLinkHoverHandler(onHoverChange: LinkHoverHandler,
|
|
|
1452
1465
|
* Registered with `Priority.high` so its `handlePaste` runs before
|
|
1453
1466
|
* `defineEmbedPaste`'s: pasting an embeddable URL (tweet/YouTube) over a
|
|
1454
1467
|
* selection keeps the selected text as a link instead of discarding it for an
|
|
1455
|
-
* embed.
|
|
1456
|
-
*
|
|
1468
|
+
* embed. Enable it through the `linkPaste` configuration or install this
|
|
1469
|
+
* standalone extension.
|
|
1457
1470
|
*/
|
|
1458
|
-
export declare function defineLinkPaste(): PlainExtension;
|
|
1471
|
+
export declare function defineLinkPaste(enabled?: (state: EditorState) => boolean): PlainExtension;
|
|
1459
1472
|
//#endregion
|
|
1460
1473
|
//#region src/extensions/link-preview.d.ts
|
|
1461
1474
|
/**
|
|
@@ -1496,7 +1509,7 @@ export declare function isNodeOfType(node: ProseMirrorNode, name: NodeName): boo
|
|
|
1496
1509
|
/**
|
|
1497
1510
|
* Apply the editor's automatic plain-text substitutions.
|
|
1498
1511
|
*/
|
|
1499
|
-
export declare function defineSubstitution(): PlainExtension;
|
|
1512
|
+
export declare function defineSubstitution(enabled?: (state: EditorState) => boolean): PlainExtension;
|
|
1500
1513
|
//#endregion
|
|
1501
1514
|
//#region src/extensions/table.d.ts
|
|
1502
1515
|
/**
|
|
@@ -1564,7 +1577,7 @@ export declare function defineWikilinkHoverHandler(onHoverChange: WikilinkHoverH
|
|
|
1564
1577
|
* Binds `Mod-Shift-k` to open the wikilink menu, and `[` to wrap a selected
|
|
1565
1578
|
* phrase into an open wikilink (`[[phrase`) with the menu searching it.
|
|
1566
1579
|
*/
|
|
1567
|
-
export declare function defineWikilinkTrigger(): PlainExtension;
|
|
1580
|
+
export declare function defineWikilinkTrigger(enabled?: (state: EditorState) => boolean): PlainExtension;
|
|
1568
1581
|
//#endregion
|
|
1569
1582
|
//#region src/utils/composition.d.ts
|
|
1570
1583
|
export declare function getIsComposing(): boolean;
|
|
@@ -1629,4 +1642,4 @@ export declare function getSelectedText(state: EditorState): string;
|
|
|
1629
1642
|
*/
|
|
1630
1643
|
export declare function getVirtualElementFromRange(view: EditorView, range: PositionRange): VirtualElement;
|
|
1631
1644
|
//#endregion
|
|
1632
|
-
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, type EditorExtension, type EditorExtensionOptions, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkHoverOptions, type LinkPreview, type LinkPreviewResolver, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, type PostEmbedKind, type PostEmbedSnapshot, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, type WikilinkOptions, type WikilinkPayload, type WikilinkResolution, type WikilinkResolver, type XPostResolver, type YouTubeVideoResolver, defineCodeBlockPreviewPlugin, definePlaceholder,
|
|
1645
|
+
export { type AcceptPendingReplacementOptions, type CheckRoundTripOptions, type CodeBlockAttrs, type CodeBlockFenceStyle, type CodeToken, type DocToMarkdownOptions, type EditorConfig, type EditorExtension, type EditorExtensionOptions, type ExitBoundaryHandler, type ExitBoundaryOptions, type FileClickHandler, type FileClickPayload, type FileInfo, type FileInfoResolver, type FileLinkOptions, type FileLinkPayload, type FileLinkResolver, type FilePasteHandler, type FilePasteOptions, type FileSaveErrorHandler, type FileViewOptions, type FollowLinkHandlers, type ImageClickHandler, type ImageClickPayload, type ImageOptions, type InlineMarkContext, type InlineMarkOptions, type KaTeXRender, type LanguageItem, type LinkAttrs, type LinkClickHandler, type LinkClickPayload, type LinkCopyHandler, type LinkCopyPayload, type LinkEditHandler, type LinkEditOptions, type LinkHoverHandler, type LinkHoverOptions, type LinkPreview, type LinkPreviewResolver, type LinkUnit, type ListMarker, type MarkChunk, type MarkMode, type MarkName, type MarkdownToDocOptions, type MdFileAttrs, type MdImageAttrs, type MdLinkTextAttrs, type MdMathAttrs, type MdWikilinkAttrs, type MeowdownCodeBlockAttrs, type MeowdownHTMLCommentAttrs, type MeowdownListAttrs, type MeowdownTableCellAttrs, type NodeName, type ParsedWikiEmbed, type PendingReplacement, type PendingReplacementEvent, type PendingReplacementHandler, type PendingReplacementMode, type PendingReplacementOutcome, type PlaceholderOptions, type PositionRange, type PostEmbedKind, type PostEmbedSnapshot, Priority, type ReferenceDefinition, type ReferenceDefinitionIndex, type ReferenceDefinitions, type RoundTripFidelity, type SearchStatus, type SearchStatusHandler, type StartPendingReplacementOptions, type TableColumnAlign, type TagClickHandler, type TagClickPayload, type TypedEditor, type TypedMarkBuilders, type VirtualElement, type WikiEmbedOptions, type WikiEmbedResolution, type WikiEmbedResolver, type WikilinkClickHandler, type WikilinkClickPayload, type WikilinkHoverHandler, type WikilinkHoverHit, type WikilinkOptions, type WikilinkPayload, type WikilinkResolution, type WikilinkResolver, type XPostResolver, type YouTubeVideoResolver, defineCodeBlockPreviewPlugin, definePlaceholder, defineSearchStatusHandler, getSearchStatus, isCodeBlockPreviewHiddenDecoration, parseXPostId, withPriority };
|