@meowdown/react 0.76.4 → 0.78.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/README.md +18 -18
- package/dist/index.d.ts +175 -170
- package/dist/index.js +2611 -2613
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,17 +17,17 @@ Import both stylesheets and render the editor:
|
|
|
17
17
|
```tsx
|
|
18
18
|
import '@meowdown/core/style.css'
|
|
19
19
|
import '@meowdown/react/style.css'
|
|
20
|
-
import {
|
|
20
|
+
import { MarkdownEditor } from '@meowdown/react'
|
|
21
21
|
|
|
22
22
|
export function App() {
|
|
23
|
-
return <
|
|
23
|
+
return <MarkdownEditor initialMarkdown="# Hello" />
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
|
-
import {
|
|
30
|
+
import { MarkdownEditor, type EditorHandle } from '@meowdown/react'
|
|
31
31
|
import { useRef, useCallback } from 'react'
|
|
32
32
|
|
|
33
33
|
export function App() {
|
|
@@ -37,7 +37,7 @@ export function App() {
|
|
|
37
37
|
}, [])
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
|
-
<
|
|
40
|
+
<MarkdownEditor
|
|
41
41
|
handleRef={ref}
|
|
42
42
|
mode="focus"
|
|
43
43
|
initialMarkdown="# Hello"
|
|
@@ -51,23 +51,23 @@ export function App() {
|
|
|
51
51
|
|
|
52
52
|
| Component | Description |
|
|
53
53
|
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
54
|
-
| `
|
|
54
|
+
| `MarkdownEditor` | The editor. Callbacks and resolvers must be stable; pass them via `useCallback`. |
|
|
55
55
|
| `MarkdownView` | Read-only Markdown renderer. `interactive={false}` renders passive content for previews. |
|
|
56
|
-
| `WikilinkHoverCard` | Mount inside `
|
|
56
|
+
| `WikilinkHoverCard` | Mount inside `MarkdownEditor`; renders host content for the hovered wiki link's `target`. Return `null` to render no card. |
|
|
57
57
|
| `LightboxRoot` / `LightboxImage` / `LightboxVideo` / `LightboxFrame` | Full-window image, video, and embedded player preview driven by `useLightbox()`. Compose your own close controls inside `LightboxRoot`, and call `lightbox.open(item, element)` from `onImageClick`, `onXPostMediaClick`, or `onYouTubeVideoClick` to zoom from the clicked element. |
|
|
58
58
|
|
|
59
|
-
Common `
|
|
60
|
-
|
|
61
|
-
| Prop
|
|
62
|
-
|
|
|
63
|
-
| `mode`
|
|
64
|
-
| `searchQuery` / `onSearchChange`
|
|
65
|
-
| `onWikilinkClick` / `onLinkClick` / `onTagClick` / `onImageClick` / `onFileClick` / `onXPostMediaClick` / `onYouTubeVideoClick`
|
|
66
|
-
| `resolveImageUrl` / `resolveWikiEmbed` / `resolveWikilink` / `resolveFileLink` / `resolveFileInfo`
|
|
67
|
-
| `onFilePaste`
|
|
68
|
-
| `onSlashMenuSearch` / `onTagSearch` / `onWikilinkSearch` / `onSelectionMenuSearch`
|
|
69
|
-
| `readOnly` / `placeholder` / `blockHandle` / `caretGlide` / `embedPaste` / `linkPaste` / `bulletAfterHeading`
|
|
70
|
-
| `CodeBlockView`
|
|
59
|
+
Common `MarkdownEditor` props:
|
|
60
|
+
|
|
61
|
+
| Prop | What it does |
|
|
62
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
63
|
+
| `mode` | `'focus'` (default), `'show'`, or `'hide'`: how much Markdown syntax stays in view |
|
|
64
|
+
| `searchQuery` / `onSearchChange` | Find in document, with `EditorHandle.findNext()` / `findPrevious()` |
|
|
65
|
+
| `onWikilinkClick` / `onLinkClick` / `onTagClick` / `onImageClick` / `onFileClick` / `onXPostMediaClick` / `onYouTubeVideoClick` | Click handling for the rendered atoms |
|
|
66
|
+
| `resolveImageUrl` / `resolveWikiEmbed` / `resolveWikilink` / `resolveFileLink` / `resolveFileInfo` | Resolve and classify local content |
|
|
67
|
+
| `onFilePaste` | Persist pasted or dropped files |
|
|
68
|
+
| `onSlashMenuSearch` / `onTagSearch` / `onWikilinkSearch` / `onSelectionMenuSearch` | Search menus for `/`, `#`, `[[`, and selection commands |
|
|
69
|
+
| `readOnly` / `placeholder` / `blockHandle` / `caretGlide` / `embedPaste` / `linkPaste` / `bulletAfterHeading` / `backspaceDeletesEmptyFirstBlock` | Behavior toggles |
|
|
70
|
+
| `CodeBlockView` | Custom React node view component for code blocks |
|
|
71
71
|
|
|
72
72
|
Every prop, callback, and `EditorHandle` method is documented in the [API reference](https://npmx.dev/package-docs/@meowdown%2Freact/).
|
|
73
73
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,174 +1,7 @@
|
|
|
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";
|
|
2
1
|
import { ComponentProps, ReactElement, ReactNode, Ref } from "react";
|
|
2
|
+
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";
|
|
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
|
|
172
5
|
//#region src/utils/date-format.d.ts
|
|
173
6
|
type TimeFormat = '12' | '24';
|
|
174
7
|
//#endregion
|
|
@@ -662,6 +495,12 @@ interface EditorProps {
|
|
|
662
495
|
* Off by default.
|
|
663
496
|
*/
|
|
664
497
|
bulletAfterHeading?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Pressing Backspace in an empty paragraph that is the document's first
|
|
500
|
+
* block deletes that paragraph, so the rest of the document moves up one
|
|
501
|
+
* line. The block after it keeps its type. Off by default.
|
|
502
|
+
*/
|
|
503
|
+
backspaceDeletesEmptyFirstBlock?: boolean;
|
|
665
504
|
/**
|
|
666
505
|
* Replaces typed character sequences with their typographic equivalents,
|
|
667
506
|
* e.g. `->` with `→` and `(c)` with `©`. On by default.
|
|
@@ -744,7 +583,167 @@ interface EditorProps {
|
|
|
744
583
|
*
|
|
745
584
|
* Callbacks and resolvers should be stable; pass them via `useCallback`.
|
|
746
585
|
*/
|
|
747
|
-
export declare function
|
|
586
|
+
export declare function MarkdownEditor({ 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, backspaceDeletesEmptyFirstBlock, substitution, frontmatter, blockHandle, caretGlide, placeholder, readOnly, spellCheck, searchQuery, onSearchChange, timeFormat, editorClassName, wrapperClassName, CodeBlockView, handleRef, children }: EditorProps): ReactElement;
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/components/markdown-view.d.ts
|
|
589
|
+
/**
|
|
590
|
+
* Payload for {@link TaskClickHandler}.
|
|
591
|
+
*/
|
|
592
|
+
interface TaskClickPayload {
|
|
593
|
+
/**
|
|
594
|
+
* Zero-based position of the clicked checkbox among all the checkboxes this
|
|
595
|
+
* view renders, in document order. Stable for a given `markdown`, so a host
|
|
596
|
+
* can map it back to the corresponding task item in its own parse of the
|
|
597
|
+
* same source.
|
|
598
|
+
*/
|
|
599
|
+
index: number;
|
|
600
|
+
/**
|
|
601
|
+
* The checkbox's rendered state. The view never flips it — see the handler doc.
|
|
602
|
+
*/
|
|
603
|
+
checked: boolean;
|
|
604
|
+
/**
|
|
605
|
+
* The item's list marker as written (`+` renders a circle checkbox, `-`/`*` a square).
|
|
606
|
+
*/
|
|
607
|
+
marker: ListMarker;
|
|
608
|
+
/**
|
|
609
|
+
* First line of the item's own inline content, exactly as it appears in the
|
|
610
|
+
* source after the `[ ]`/`[x]` marker and one space. A host locating the task
|
|
611
|
+
* by {@link index} can cross-check this against its own parse and refuse a
|
|
612
|
+
* mismatch instead of toggling the wrong item.
|
|
613
|
+
*/
|
|
614
|
+
text: string;
|
|
615
|
+
/**
|
|
616
|
+
* The originating click. Read modifier keys or position a popover from it.
|
|
617
|
+
*/
|
|
618
|
+
event: globalThis.MouseEvent;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Called when a rendered task checkbox is clicked. The view is a pure render
|
|
622
|
+
* of `markdown` and never flips the box itself: apply the toggle to the
|
|
623
|
+
* source and re-render, exactly like the other click handlers.
|
|
624
|
+
*/
|
|
625
|
+
type TaskClickHandler = (payload: TaskClickPayload) => void;
|
|
626
|
+
interface MarkdownViewProps {
|
|
627
|
+
/**
|
|
628
|
+
* The Markdown to render. Live: changing it re-renders the content.
|
|
629
|
+
*/
|
|
630
|
+
markdown: string;
|
|
631
|
+
/**
|
|
632
|
+
* Interpret content as one paragraph, without block syntax.
|
|
633
|
+
*/
|
|
634
|
+
singleParagraph?: boolean;
|
|
635
|
+
/**
|
|
636
|
+
* Reference definitions available outside this fragment.
|
|
637
|
+
*/
|
|
638
|
+
referenceDefinitions?: ReferenceDefinitions;
|
|
639
|
+
/**
|
|
640
|
+
* Mark mode for the read-only view. Defaults to `'hide'`.
|
|
641
|
+
*/
|
|
642
|
+
markMode?: MarkMode;
|
|
643
|
+
/**
|
|
644
|
+
* Peel a leading YAML frontmatter block before rendering. Off by default.
|
|
645
|
+
*/
|
|
646
|
+
frontmatter?: boolean;
|
|
647
|
+
/**
|
|
648
|
+
* Whether rendered links, images, file pills, and task checkboxes can be activated.
|
|
649
|
+
* Defaults to `true`. When `false`, callbacks are ignored, the rendered tree
|
|
650
|
+
* contains no anchors or focusable task controls, and recognized tweet and
|
|
651
|
+
* YouTube embeds are omitted before any image resolver runs.
|
|
652
|
+
*/
|
|
653
|
+
interactive?: boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Render collapsed (`+`) bullets expanded, ignoring their fold state at any
|
|
656
|
+
* depth. Off by default. For views that show slices of a note (e.g. a
|
|
657
|
+
* backlinks panel), where the source's fold state must not hide the content
|
|
658
|
+
* the view exists to show.
|
|
659
|
+
*/
|
|
660
|
+
expandCollapsed?: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* Map an image `src` to a displayable URL, or `undefined` to skip it. May
|
|
663
|
+
* return a `Promise`; the image appears once it resolves, in a box of its
|
|
664
|
+
* persisted size when both dimensions are known.
|
|
665
|
+
*/
|
|
666
|
+
resolveImageUrl?: ImageUrlResolver;
|
|
667
|
+
/**
|
|
668
|
+
* Claim a `[label](url)` link as a file pill instead of a regular link.
|
|
669
|
+
* Must be pure; return `false` for links that should render normally.
|
|
670
|
+
*/
|
|
671
|
+
resolveFileLink?: FileLinkResolver;
|
|
672
|
+
/**
|
|
673
|
+
* Classify `![[target]]` as an image, file, or note; unresolved source stays literal.
|
|
674
|
+
*/
|
|
675
|
+
resolveWikiEmbed?: WikiEmbedResolver;
|
|
676
|
+
/**
|
|
677
|
+
* Resolve a `[[...]]` wikilink into its target and chip label; the bracketed
|
|
678
|
+
* text is both by default. Must be pure.
|
|
679
|
+
*/
|
|
680
|
+
resolveWikilink?: WikilinkResolver;
|
|
681
|
+
/**
|
|
682
|
+
* Resolve metadata shown on a file pill.
|
|
683
|
+
*/
|
|
684
|
+
resolveFileInfo?: FileInfoResolver;
|
|
685
|
+
/**
|
|
686
|
+
* Resolve the data behind an X post URL, rendered as a `meowdown-embed-x`
|
|
687
|
+
* card. Defaults to `defaultResolveXPost`.
|
|
688
|
+
*/
|
|
689
|
+
resolveXPost?: XPostResolver$1;
|
|
690
|
+
/**
|
|
691
|
+
* Additional trusted protocols for X media URLs, such as `reflect-asset:`.
|
|
692
|
+
*/
|
|
693
|
+
mediaUrlProtocols?: string[];
|
|
694
|
+
/**
|
|
695
|
+
* Resolve the data behind a YouTube video URL, rendered as a
|
|
696
|
+
* `meowdown-embed-youtube` card. Defaults to `defaultResolveYouTubeVideo`.
|
|
697
|
+
*/
|
|
698
|
+
resolveYouTubeVideo?: YouTubeVideoResolver$1;
|
|
699
|
+
/**
|
|
700
|
+
* Called when a rendered wikilink is clicked. Pass a stable function.
|
|
701
|
+
*/
|
|
702
|
+
onWikilinkClick?: WikilinkClickHandler;
|
|
703
|
+
/**
|
|
704
|
+
* Called when a rendered Markdown link is clicked. Pass a stable function.
|
|
705
|
+
*/
|
|
706
|
+
onLinkClick?: LinkClickHandler;
|
|
707
|
+
/**
|
|
708
|
+
* Called when a rendered image is clicked. Pass a stable function.
|
|
709
|
+
*/
|
|
710
|
+
onImageClick?: ImageClickHandler;
|
|
711
|
+
/**
|
|
712
|
+
* Called when a photo or video inside an X post card is activated. Call
|
|
713
|
+
* `event.preventDefault()` to stop the card from opening the photo URL or
|
|
714
|
+
* playing the video in place.
|
|
715
|
+
*/
|
|
716
|
+
onXPostMediaClick?: XPostMediaClickHandler;
|
|
717
|
+
/**
|
|
718
|
+
* Called when the poster of a YouTube card is activated. Call
|
|
719
|
+
* `event.preventDefault()` to stop the card from playing the video in place.
|
|
720
|
+
*/
|
|
721
|
+
onYouTubeVideoClick?: YouTubeVideoClickHandler;
|
|
722
|
+
/**
|
|
723
|
+
* Called when a rendered file pill is clicked. Pass a stable function.
|
|
724
|
+
*/
|
|
725
|
+
onFileClick?: FileClickHandler;
|
|
726
|
+
/**
|
|
727
|
+
* Called when a rendered task checkbox is clicked. Pass a stable function.
|
|
728
|
+
*/
|
|
729
|
+
onTaskClick?: TaskClickHandler;
|
|
730
|
+
/**
|
|
731
|
+
* Extra class on the content root (alongside `ProseMirror meowdown-content`).
|
|
732
|
+
*/
|
|
733
|
+
className?: string;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Render Markdown to a read-only React tree that looks exactly like the editor
|
|
737
|
+
* in `hide` mark mode: inline marks, wikilink chips, images, tweet/YouTube
|
|
738
|
+
* embeds, and syntax-highlighted code. No editor, no ProseMirror view; just a
|
|
739
|
+
* walk over `markdownToDoc`'s document reusing meowdown's own parse, mark logic,
|
|
740
|
+
* and CSS (the root carries `ProseMirror` + `data-mark-mode` so the existing
|
|
741
|
+
* stylesheet applies). Requires a DOM environment.
|
|
742
|
+
*
|
|
743
|
+
* Callbacks (`onWikilinkClick`, etc.) and resolvers should be stable; pass them via
|
|
744
|
+
* `useCallback` to avoid re-rendering the whole tree.
|
|
745
|
+
*/
|
|
746
|
+
export declare function MarkdownView({ markdown, singleParagraph, referenceDefinitions: suppliedDefinitions, markMode, frontmatter, interactive, expandCollapsed, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveWikilink, resolveFileInfo, resolveXPost, mediaUrlProtocols, resolveYouTubeVideo, onWikilinkClick, onLinkClick, onImageClick, onXPostMediaClick, onYouTubeVideoClick, onFileClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
|
|
748
747
|
//#endregion
|
|
749
748
|
//#region src/hooks/use-lightbox.d.ts
|
|
750
749
|
/**
|
|
@@ -931,4 +930,10 @@ interface WikilinkHoverCardProps {
|
|
|
931
930
|
*/
|
|
932
931
|
export declare function WikilinkHoverCard({ children, className }: WikilinkHoverCardProps): ReactNode;
|
|
933
932
|
//#endregion
|
|
934
|
-
|
|
933
|
+
//#region src/index.d.ts
|
|
934
|
+
/**
|
|
935
|
+
* @deprecated Use `MarkdownEditor` instead.
|
|
936
|
+
*/
|
|
937
|
+
export declare const MeowdownEditor: typeof MarkdownEditor;
|
|
938
|
+
//#endregion
|
|
939
|
+
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 };
|