@meowdown/react 0.75.4 → 0.76.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +182 -155
  2. package/dist/index.js +2720 -2687
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1,7 +1,174 @@
1
+ import { AcceptPendingReplacementOptions, EditorConfig, ExitBoundaryHandler, FileClickHandler, FileInfoResolver, FileLinkResolver, FilePasteOptions, FileViewOptions, ImageClickHandler, ImageOptions, ImageUrlResolver, LinkClickHandler, LinkCopyHandler, LinkPreview, LinkPreviewResolver, LinkPreviewResolver as LinkPreviewResolver$1, ListMarker, MarkMode, PendingReplacement, PendingReplacementOutcome, PlaceholderOptions, ReferenceDefinitions, SearchStatusHandler, StartPendingReplacementOptions, TagClickHandler, TypedEditor, WikiEmbedResolver, WikilinkClickHandler, WikilinkHoverHit, WikilinkResolver, XPostMediaClickHandler, XPostResolver, XPostResolver as XPostResolver$1, YouTubeVideoClickHandler, YouTubeVideoResolver, YouTubeVideoResolver as YouTubeVideoResolver$1 } from "@meowdown/core";
1
2
  import { ComponentProps, ReactElement, ReactNode, Ref } from "react";
2
- import { AcceptPendingReplacementOptions, ExitBoundaryHandler, FileClickHandler, FileInfoResolver, FileLinkResolver, FilePasteOptions, FileViewOptions, ImageClickHandler, ImageOptions, ImageUrlResolver, LinkClickHandler, LinkCopyHandler, LinkPreview, LinkPreviewResolver, LinkPreviewResolver as LinkPreviewResolver$1, ListMarker, MarkMode, PendingReplacement, PendingReplacementOutcome, PlaceholderOptions, SearchStatusHandler, StartPendingReplacementOptions, TagClickHandler, TypedEditor, WikiEmbedResolver, WikilinkClickHandler, WikilinkHoverHit, WikilinkResolver, XPostMediaClickHandler, XPostResolver, XPostResolver as XPostResolver$1, YouTubeVideoClickHandler, YouTubeVideoResolver, YouTubeVideoResolver as YouTubeVideoResolver$1 } from "@meowdown/core";
3
3
  import { SelectionJSON, SelectionJSON as SelectionJSON$1 } from "@prosekit/core";
4
4
  import { ReactNodeViewComponent, ReactNodeViewComponent as ReactNodeViewComponent$1, useEditor, useExtension, useKeymap } from "@prosekit/react";
5
+ //#region src/components/markdown-view.d.ts
6
+ /**
7
+ * Payload for {@link TaskClickHandler}.
8
+ */
9
+ interface TaskClickPayload {
10
+ /**
11
+ * Zero-based position of the clicked checkbox among all the checkboxes this
12
+ * view renders, in document order. Stable for a given `markdown`, so a host
13
+ * can map it back to the corresponding task item in its own parse of the
14
+ * same source.
15
+ */
16
+ index: number;
17
+ /**
18
+ * The checkbox's rendered state. The view never flips it — see the handler doc.
19
+ */
20
+ checked: boolean;
21
+ /**
22
+ * The item's list marker as written (`+` renders a circle checkbox, `-`/`*` a square).
23
+ */
24
+ marker: ListMarker;
25
+ /**
26
+ * First line of the item's own inline content, exactly as it appears in the
27
+ * source after the `[ ]`/`[x]` marker and one space. A host locating the task
28
+ * by {@link index} can cross-check this against its own parse and refuse a
29
+ * mismatch instead of toggling the wrong item.
30
+ */
31
+ text: string;
32
+ /**
33
+ * The originating click. Read modifier keys or position a popover from it.
34
+ */
35
+ event: globalThis.MouseEvent;
36
+ }
37
+ /**
38
+ * Called when a rendered task checkbox is clicked. The view is a pure render
39
+ * of `markdown` and never flips the box itself: apply the toggle to the
40
+ * source and re-render, exactly like the other click handlers.
41
+ */
42
+ type TaskClickHandler = (payload: TaskClickPayload) => void;
43
+ interface MarkdownViewProps {
44
+ /**
45
+ * The Markdown to render. Live: changing it re-renders the content.
46
+ */
47
+ markdown: string;
48
+ /**
49
+ * Interpret content as one paragraph, without block syntax.
50
+ */
51
+ inline?: boolean;
52
+ /**
53
+ * Reference definitions available outside this fragment.
54
+ */
55
+ referenceDefinitions?: ReferenceDefinitions;
56
+ /**
57
+ * Mark mode for the read-only view. Defaults to `'hide'`.
58
+ */
59
+ markMode?: MarkMode;
60
+ /**
61
+ * Peel a leading YAML frontmatter block before rendering. Off by default.
62
+ */
63
+ frontmatter?: boolean;
64
+ /**
65
+ * Whether rendered links, images, file pills, and task checkboxes can be activated.
66
+ * Defaults to `true`. When `false`, callbacks are ignored, the rendered tree
67
+ * contains no anchors or focusable task controls, and recognized tweet and
68
+ * YouTube embeds are omitted before any image resolver runs.
69
+ */
70
+ interactive?: boolean;
71
+ /**
72
+ * Render collapsed (`+`) bullets expanded, ignoring their fold state at any
73
+ * depth. Off by default. For views that show slices of a note (e.g. a
74
+ * backlinks panel), where the source's fold state must not hide the content
75
+ * the view exists to show.
76
+ */
77
+ expandCollapsed?: boolean;
78
+ /**
79
+ * Map an image `src` to a displayable URL, or `undefined` to skip it. May
80
+ * return a `Promise`; the image appears once it resolves, in a box of its
81
+ * persisted size when both dimensions are known.
82
+ */
83
+ resolveImageUrl?: ImageUrlResolver;
84
+ /**
85
+ * Claim a `[label](url)` link as a file pill instead of a regular link.
86
+ * Must be pure; return `false` for links that should render normally.
87
+ */
88
+ resolveFileLink?: FileLinkResolver;
89
+ /**
90
+ * Classify `![[target]]` as an image, file, or note; unresolved source stays literal.
91
+ */
92
+ resolveWikiEmbed?: WikiEmbedResolver;
93
+ /**
94
+ * Resolve a `[[...]]` wikilink into its target and chip label; the bracketed
95
+ * text is both by default. Must be pure.
96
+ */
97
+ resolveWikilink?: WikilinkResolver;
98
+ /**
99
+ * Resolve metadata shown on a file pill.
100
+ */
101
+ resolveFileInfo?: FileInfoResolver;
102
+ /**
103
+ * Resolve the data behind an X post URL, rendered as a `meowdown-embed-x`
104
+ * card. Defaults to `defaultResolveXPost`.
105
+ */
106
+ resolveXPost?: XPostResolver$1;
107
+ /**
108
+ * Additional trusted protocols for X media URLs, such as `reflect-asset:`.
109
+ */
110
+ mediaUrlProtocols?: string[];
111
+ /**
112
+ * Resolve the data behind a YouTube video URL, rendered as a
113
+ * `meowdown-embed-youtube` card. Defaults to `defaultResolveYouTubeVideo`.
114
+ */
115
+ resolveYouTubeVideo?: YouTubeVideoResolver$1;
116
+ /**
117
+ * Called when a rendered wikilink is clicked. Pass a stable function.
118
+ */
119
+ onWikilinkClick?: WikilinkClickHandler;
120
+ /**
121
+ * Called when a rendered Markdown link is clicked. Pass a stable function.
122
+ */
123
+ onLinkClick?: LinkClickHandler;
124
+ /**
125
+ * Called when a rendered image is clicked. Pass a stable function.
126
+ */
127
+ onImageClick?: ImageClickHandler;
128
+ /**
129
+ * Called when a photo or video inside an X post card is activated. Call
130
+ * `event.preventDefault()` to stop the card from opening the photo URL or
131
+ * playing the video in place.
132
+ */
133
+ onXPostMediaClick?: XPostMediaClickHandler;
134
+ /**
135
+ * Called when the poster of a YouTube card is activated. Call
136
+ * `event.preventDefault()` to stop the card from playing the video in place.
137
+ */
138
+ onYouTubeVideoClick?: YouTubeVideoClickHandler;
139
+ /**
140
+ * Called when a rendered file pill is clicked. Pass a stable function.
141
+ */
142
+ onFileClick?: FileClickHandler;
143
+ /**
144
+ * Called when a rendered task checkbox is clicked. Pass a stable function.
145
+ */
146
+ onTaskClick?: TaskClickHandler;
147
+ /**
148
+ * Extra class on the content root (alongside `ProseMirror meowdown-content`).
149
+ */
150
+ className?: string;
151
+ }
152
+ /**
153
+ * Render Markdown to a read-only React tree that looks exactly like the editor
154
+ * in `hide` mark mode: inline marks, wikilink chips, images, tweet/YouTube
155
+ * embeds, and syntax-highlighted code. No editor, no ProseMirror view; just a
156
+ * walk over `markdownToDoc`'s document reusing meowdown's own parse, mark logic,
157
+ * and CSS (the root carries `ProseMirror` + `data-mark-mode` so the existing
158
+ * stylesheet applies). Requires a DOM environment.
159
+ *
160
+ * Callbacks (`onWikilinkClick`, etc.) and resolvers should be stable; pass them via
161
+ * `useCallback` to avoid re-rendering the whole tree.
162
+ */
163
+ export declare function MarkdownView({ markdown, inline, referenceDefinitions: suppliedDefinitions, markMode, frontmatter, interactive, expandCollapsed, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveWikilink, resolveFileInfo, resolveXPost, mediaUrlProtocols, resolveYouTubeVideo, onWikilinkClick, onLinkClick, onImageClick, onXPostMediaClick, onYouTubeVideoClick, onFileClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
164
+ //#endregion
165
+ //#region src/components/markdown-inline-view.d.ts
166
+ type MarkdownInlineViewProps = Omit<MarkdownViewProps, 'inline' | 'frontmatter' | 'onTaskClick'>;
167
+ /**
168
+ * Render paragraph content using the shared inline marks and link handlers.
169
+ */
170
+ export declare function MarkdownInlineView(props: MarkdownInlineViewProps): ReactElement;
171
+ //#endregion
5
172
  //#region src/utils/date-format.d.ts
6
173
  type TimeFormat = '12' | '24';
7
174
  //#endregion
@@ -69,6 +236,10 @@ interface EditorHandle {
69
236
  * Focuses the editor.
70
237
  */
71
238
  focus: () => void;
239
+ /**
240
+ * Whether the selection is at the textblock boundary in this direction; false before mount or after unmount.
241
+ */
242
+ isAtTextblockBoundary: (direction: 'up' | 'down' | 'left' | 'right' | 'forward' | 'backward') => boolean;
72
243
  /**
73
244
  * Scrolls the selection into view.
74
245
  */
@@ -272,6 +443,14 @@ interface EditorProps {
272
443
  * first render is used; later changes are ignored.
273
444
  */
274
445
  initialMarkdown?: string;
446
+ /**
447
+ * Edit a single paragraph of inline Markdown. Read on mount.
448
+ */
449
+ singleParagraph?: boolean;
450
+ /**
451
+ * Definitions supplied by the containing document.
452
+ */
453
+ referenceDefinitions?: EditorConfig['referenceDefinitions'];
275
454
  /**
276
455
  * Called on every user-driven document change. Programmatic `setMarkdown` and
277
456
  * `setState` on the handle do not fire it.
@@ -565,159 +744,7 @@ interface EditorProps {
565
744
  *
566
745
  * Callbacks and resolvers should be stable; pass them via `useCallback`.
567
746
  */
568
- export declare function MeowdownEditor({ mode, initialMarkdown, onDocChange, onSlashMenuSearch, onTagSearch, onWikilinkSearch, onSelectionMenuSearch, selectionMenuAffordance, pendingReplacementActions, onPendingReplacementResolve, onWikilinkClick, onLinkClick, onLinkCopy, resolveLinkPreview, onTagClick, onExitBoundary, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveWikilink, resolveFileInfo, resolveXPost, mediaUrlProtocols, resolveYouTubeVideo, onFileClick, onFilePaste, onFileSaveError, onImageClick, onXPostMediaClick, onYouTubeVideoClick, embedPaste, linkPaste, bulletAfterHeading, substitution, frontmatter, blockHandle, caretGlide, placeholder, readOnly, spellCheck, searchQuery, onSearchChange, timeFormat, editorClassName, wrapperClassName, CodeBlockView, handleRef, children }: EditorProps): ReactElement;
569
- //#endregion
570
- //#region src/components/markdown-view.d.ts
571
- /**
572
- * Payload for {@link TaskClickHandler}.
573
- */
574
- interface TaskClickPayload {
575
- /**
576
- * Zero-based position of the clicked checkbox among all the checkboxes this
577
- * view renders, in document order. Stable for a given `markdown`, so a host
578
- * can map it back to the corresponding task item in its own parse of the
579
- * same source.
580
- */
581
- index: number;
582
- /**
583
- * The checkbox's rendered state. The view never flips it — see the handler doc.
584
- */
585
- checked: boolean;
586
- /**
587
- * The item's list marker as written (`+` renders a circle checkbox, `-`/`*` a square).
588
- */
589
- marker: ListMarker;
590
- /**
591
- * First line of the item's own inline content, exactly as it appears in the
592
- * source after the `[ ]`/`[x]` marker and one space. A host locating the task
593
- * by {@link index} can cross-check this against its own parse and refuse a
594
- * mismatch instead of toggling the wrong item.
595
- */
596
- text: string;
597
- /**
598
- * The originating click. Read modifier keys or position a popover from it.
599
- */
600
- event: globalThis.MouseEvent;
601
- }
602
- /**
603
- * Called when a rendered task checkbox is clicked. The view is a pure render
604
- * of `markdown` and never flips the box itself: apply the toggle to the
605
- * source and re-render, exactly like the other click handlers.
606
- */
607
- type TaskClickHandler = (payload: TaskClickPayload) => void;
608
- interface MarkdownViewProps {
609
- /**
610
- * The Markdown to render. Live: changing it re-renders the content.
611
- */
612
- markdown: string;
613
- /**
614
- * Mark mode for the read-only view. Defaults to `'hide'`.
615
- */
616
- markMode?: MarkMode;
617
- /**
618
- * Peel a leading YAML frontmatter block before rendering. Off by default.
619
- */
620
- frontmatter?: boolean;
621
- /**
622
- * Whether rendered links, images, file pills, and task checkboxes can be activated.
623
- * Defaults to `true`. When `false`, callbacks are ignored, the rendered tree
624
- * contains no anchors or focusable task controls, and recognized tweet and
625
- * YouTube embeds are omitted before any image resolver runs.
626
- */
627
- interactive?: boolean;
628
- /**
629
- * Render collapsed (`+`) bullets expanded, ignoring their fold state at any
630
- * depth. Off by default. For views that show slices of a note (e.g. a
631
- * backlinks panel), where the source's fold state must not hide the content
632
- * the view exists to show.
633
- */
634
- expandCollapsed?: boolean;
635
- /**
636
- * Map an image `src` to a displayable URL, or `undefined` to skip it. May
637
- * return a `Promise`; the image appears once it resolves, in a box of its
638
- * persisted size when both dimensions are known.
639
- */
640
- resolveImageUrl?: ImageUrlResolver;
641
- /**
642
- * Claim a `[label](url)` link as a file pill instead of a regular link.
643
- * Must be pure; return `false` for links that should render normally.
644
- */
645
- resolveFileLink?: FileLinkResolver;
646
- /**
647
- * Classify `![[target]]` as an image, file, or note; unresolved source stays literal.
648
- */
649
- resolveWikiEmbed?: WikiEmbedResolver;
650
- /**
651
- * Resolve a `[[...]]` wikilink into its target and chip label; the bracketed
652
- * text is both by default. Must be pure.
653
- */
654
- resolveWikilink?: WikilinkResolver;
655
- /**
656
- * Resolve metadata shown on a file pill.
657
- */
658
- resolveFileInfo?: FileInfoResolver;
659
- /**
660
- * Resolve the data behind an X post URL, rendered as a `meowdown-embed-x`
661
- * card. Defaults to `defaultResolveXPost`.
662
- */
663
- resolveXPost?: XPostResolver$1;
664
- /**
665
- * Additional trusted protocols for X media URLs, such as `reflect-asset:`.
666
- */
667
- mediaUrlProtocols?: string[];
668
- /**
669
- * Resolve the data behind a YouTube video URL, rendered as a
670
- * `meowdown-embed-youtube` card. Defaults to `defaultResolveYouTubeVideo`.
671
- */
672
- resolveYouTubeVideo?: YouTubeVideoResolver$1;
673
- /**
674
- * Called when a rendered wikilink is clicked. Pass a stable function.
675
- */
676
- onWikilinkClick?: WikilinkClickHandler;
677
- /**
678
- * Called when a rendered Markdown link is clicked. Pass a stable function.
679
- */
680
- onLinkClick?: LinkClickHandler;
681
- /**
682
- * Called when a rendered image is clicked. Pass a stable function.
683
- */
684
- onImageClick?: ImageClickHandler;
685
- /**
686
- * Called when a photo or video inside an X post card is activated. Call
687
- * `event.preventDefault()` to stop the card from opening the photo URL or
688
- * playing the video in place.
689
- */
690
- onXPostMediaClick?: XPostMediaClickHandler;
691
- /**
692
- * Called when the poster of a YouTube card is activated. Call
693
- * `event.preventDefault()` to stop the card from playing the video in place.
694
- */
695
- onYouTubeVideoClick?: YouTubeVideoClickHandler;
696
- /**
697
- * Called when a rendered file pill is clicked. Pass a stable function.
698
- */
699
- onFileClick?: FileClickHandler;
700
- /**
701
- * Called when a rendered task checkbox is clicked. Pass a stable function.
702
- */
703
- onTaskClick?: TaskClickHandler;
704
- /**
705
- * Extra class on the content root (alongside `ProseMirror meowdown-content`).
706
- */
707
- className?: string;
708
- }
709
- /**
710
- * Render Markdown to a read-only React tree that looks exactly like the editor
711
- * in `hide` mark mode: inline marks, wikilink chips, images, tweet/YouTube
712
- * embeds, and syntax-highlighted code. No editor, no ProseMirror view; just a
713
- * walk over `markdownToDoc`'s document reusing meowdown's own parse, mark logic,
714
- * and CSS (the root carries `ProseMirror` + `data-mark-mode` so the existing
715
- * stylesheet applies). Requires a DOM environment.
716
- *
717
- * Callbacks (`onWikilinkClick`, etc.) and resolvers should be stable; pass them via
718
- * `useCallback` to avoid re-rendering the whole tree.
719
- */
720
- export declare function MarkdownView({ markdown, markMode, frontmatter, interactive, expandCollapsed, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveWikilink, resolveFileInfo, resolveXPost, mediaUrlProtocols, resolveYouTubeVideo, onWikilinkClick, onLinkClick, onImageClick, onXPostMediaClick, onYouTubeVideoClick, onFileClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
747
+ export declare function MeowdownEditor({ mode, initialMarkdown, singleParagraph, referenceDefinitions, onDocChange, onSlashMenuSearch, onTagSearch, onWikilinkSearch, onSelectionMenuSearch, selectionMenuAffordance, pendingReplacementActions, onPendingReplacementResolve, onWikilinkClick, onLinkClick, onLinkCopy, resolveLinkPreview, onTagClick, onExitBoundary, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveWikilink, resolveFileInfo, resolveXPost, mediaUrlProtocols, resolveYouTubeVideo, onFileClick, onFilePaste, onFileSaveError, onImageClick, onXPostMediaClick, onYouTubeVideoClick, embedPaste, linkPaste, bulletAfterHeading, substitution, frontmatter, blockHandle, caretGlide, placeholder, readOnly, spellCheck, searchQuery, onSearchChange, timeFormat, editorClassName, wrapperClassName, CodeBlockView, handleRef, children }: EditorProps): ReactElement;
721
748
  //#endregion
722
749
  //#region src/hooks/use-lightbox.d.ts
723
750
  /**
@@ -904,4 +931,4 @@ interface WikilinkHoverCardProps {
904
931
  */
905
932
  export declare function WikilinkHoverCard({ children, className }: WikilinkHoverCardProps): ReactNode;
906
933
  //#endregion
907
- export { type EditorHandle, type EditorMode, type EditorProps, type EditorStateSnapshot, type LightboxCloseOptions, type LightboxController, type LightboxFrameItem, type LightboxFrameProps, type LightboxImageItem, type LightboxImageProps, type LightboxItem, type LightboxRootProps, type LightboxVideoItem, type LightboxVideoProps, type LinkPreview, type LinkPreviewResolver, type MarkdownViewProps, type PendingReplacementResolveHandler, type ReactNodeViewComponent, type SelectionHint, type SelectionJSON, type SelectionMenuContext, type SelectionMenuItem, type SelectionMenuSearchHandler, type SlashMenuItem, type SlashMenuSearchHandler, type TagItem, type TagSearchHandler, type TaskClickHandler, type TaskClickPayload, type TimeFormat, type WikilinkHoverCardProps, type WikilinkItem, type WikilinkSearchHandler, type XPostResolver, type YouTubeVideoResolver, useEditor, useExtension, useKeymap };
934
+ export { type EditorHandle, type EditorMode, type EditorProps, type EditorStateSnapshot, type LightboxCloseOptions, type LightboxController, type LightboxFrameItem, type LightboxFrameProps, type LightboxImageItem, type LightboxImageProps, type LightboxItem, type LightboxRootProps, type LightboxVideoItem, type LightboxVideoProps, type LinkPreview, type LinkPreviewResolver, type MarkdownInlineViewProps, type MarkdownViewProps, type PendingReplacementResolveHandler, type ReactNodeViewComponent, type SelectionHint, type SelectionJSON, type SelectionMenuContext, type SelectionMenuItem, type SelectionMenuSearchHandler, type SlashMenuItem, type SlashMenuSearchHandler, type TagItem, type TagSearchHandler, type TaskClickHandler, type TaskClickPayload, type TimeFormat, type WikilinkHoverCardProps, type WikilinkItem, type WikilinkSearchHandler, type XPostResolver, type YouTubeVideoResolver, useEditor, useExtension, useKeymap };