@meowdown/react 0.64.0 → 0.64.2
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 +186 -62
- package/dist/index.js +46 -18
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { useEditor, useExtension, useKeymap } from "@prosekit/react";
|
|
|
6
6
|
type TimeFormat = '12' | '24';
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/components/types.d.ts
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* A selection to restore: an exact JSON selection, or a document edge.
|
|
11
|
+
*/
|
|
10
12
|
type SelectionHint = SelectionJSON$1 | 'start' | 'end';
|
|
11
13
|
/**
|
|
12
14
|
* The current Markdown and selection. Selection positions are in the mounted
|
|
@@ -24,7 +26,9 @@ interface EditorHandle {
|
|
|
24
26
|
* documents; call it on demand (e.g. throttled) instead of on every change.
|
|
25
27
|
*/
|
|
26
28
|
getMarkdown: () => string;
|
|
27
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Replaces the whole document as a single undoable edit.
|
|
31
|
+
*/
|
|
28
32
|
setMarkdown: (markdown: string) => void;
|
|
29
33
|
/**
|
|
30
34
|
* Parses `markdown` and inserts it at the current selection as a single
|
|
@@ -36,7 +40,9 @@ interface EditorHandle {
|
|
|
36
40
|
* `onDocChange`: the host cannot know the resulting document.
|
|
37
41
|
*/
|
|
38
42
|
insertMarkdown: (markdown: string) => void;
|
|
39
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Returns the current Markdown and selection.
|
|
45
|
+
*/
|
|
40
46
|
getState: () => EditorStateSnapshot;
|
|
41
47
|
/**
|
|
42
48
|
* Replaces the document (if `markdown` is given) and restores `selection`:
|
|
@@ -51,13 +57,21 @@ interface EditorHandle {
|
|
|
51
57
|
* this when data consulted by a stable resolver changes out of band.
|
|
52
58
|
*/
|
|
53
59
|
refreshMarkdownRendering: () => void;
|
|
54
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Returns the current selection.
|
|
62
|
+
*/
|
|
55
63
|
getSelection: () => SelectionJSON$1;
|
|
56
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Restores a selection with the same hint semantics as `setState`.
|
|
66
|
+
*/
|
|
57
67
|
setSelection: (selection: SelectionHint) => void;
|
|
58
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Focuses the editor.
|
|
70
|
+
*/
|
|
59
71
|
focus: () => void;
|
|
60
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Scrolls the selection into view.
|
|
74
|
+
*/
|
|
61
75
|
scrollIntoView: () => void;
|
|
62
76
|
/**
|
|
63
77
|
* Moves the selection to the first heading matching a decoded `#fragment`
|
|
@@ -82,7 +96,9 @@ interface EditorHandle {
|
|
|
82
96
|
* is how a retry starts.
|
|
83
97
|
*/
|
|
84
98
|
startPendingReplacement: (options: StartPendingReplacementOptions) => boolean;
|
|
85
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Appends streamed text to the staged replacement.
|
|
101
|
+
*/
|
|
86
102
|
appendPendingReplacementText: (text: string) => void;
|
|
87
103
|
/**
|
|
88
104
|
* Applies the staged replacement to the document as a single edit. Pass a
|
|
@@ -90,11 +106,17 @@ interface EditorHandle {
|
|
|
90
106
|
* below" on a replace stage).
|
|
91
107
|
*/
|
|
92
108
|
acceptPendingReplacement: (options?: AcceptPendingReplacementOptions) => void;
|
|
93
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Clears the staged replacement without touching the document.
|
|
111
|
+
*/
|
|
94
112
|
discardPendingReplacement: () => void;
|
|
95
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Selects the next match of the current search query, wrapping at the document end.
|
|
115
|
+
*/
|
|
96
116
|
findNext: () => void;
|
|
97
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Selects the previous match of the current search query, wrapping at the document start.
|
|
119
|
+
*/
|
|
98
120
|
findPrevious: () => void;
|
|
99
121
|
/**
|
|
100
122
|
* Escape hatch: the underlying ProseKit editor, or `undefined` when the
|
|
@@ -102,17 +124,29 @@ interface EditorHandle {
|
|
|
102
124
|
*/
|
|
103
125
|
readonly editor: TypedEditor | undefined;
|
|
104
126
|
}
|
|
105
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* One row of host items in the slash menu. The host ranks the rows; the menu does not re-sort.
|
|
129
|
+
*/
|
|
106
130
|
interface SlashMenuItem {
|
|
107
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Stable row key; defaults to `label`.
|
|
133
|
+
*/
|
|
108
134
|
id?: string;
|
|
109
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Display text, matched against the typed query like the built-in items.
|
|
137
|
+
*/
|
|
110
138
|
label: string;
|
|
111
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Extra match terms beyond the label; never displayed.
|
|
141
|
+
*/
|
|
112
142
|
keywords?: string[];
|
|
113
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Secondary text shown beside the label.
|
|
145
|
+
*/
|
|
114
146
|
detail?: string;
|
|
115
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Runs after the menu closes and the typed `/query` text is removed.
|
|
149
|
+
*/
|
|
116
150
|
onSelect: () => void;
|
|
117
151
|
}
|
|
118
152
|
/**
|
|
@@ -121,15 +155,25 @@ interface SlashMenuItem {
|
|
|
121
155
|
* show after the built-in items, either synchronously or as a promise.
|
|
122
156
|
*/
|
|
123
157
|
type SlashMenuSearchHandler = (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
|
|
124
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* One row in the tag menu. The host ranks the rows; the menu does not re-sort.
|
|
160
|
+
*/
|
|
125
161
|
interface TagItem {
|
|
126
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* Inserted as `#tag `.
|
|
164
|
+
*/
|
|
127
165
|
tag: string;
|
|
128
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Display text; defaults to `#tag`.
|
|
168
|
+
*/
|
|
129
169
|
label?: string;
|
|
130
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Secondary text shown beside the label.
|
|
172
|
+
*/
|
|
131
173
|
detail?: string;
|
|
132
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* Side effect run after the tag is inserted (e.g. create the tag).
|
|
176
|
+
*/
|
|
133
177
|
onSelect?: () => void;
|
|
134
178
|
}
|
|
135
179
|
/**
|
|
@@ -138,15 +182,25 @@ interface TagItem {
|
|
|
138
182
|
* synchronously or as a promise.
|
|
139
183
|
*/
|
|
140
184
|
type TagSearchHandler = (query: string) => TagItem[] | Promise<TagItem[]>;
|
|
141
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* One row in the wikilink menu. The host ranks the rows; the menu does not re-sort.
|
|
187
|
+
*/
|
|
142
188
|
interface WikilinkItem {
|
|
143
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Inserted as `[[target]]`.
|
|
191
|
+
*/
|
|
144
192
|
target: string;
|
|
145
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Display text; defaults to `target`.
|
|
195
|
+
*/
|
|
146
196
|
label?: string;
|
|
147
|
-
/**
|
|
197
|
+
/**
|
|
198
|
+
* Secondary text shown beside the label.
|
|
199
|
+
*/
|
|
148
200
|
detail?: string;
|
|
149
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Side effect run after the link is inserted (e.g. create the note).
|
|
203
|
+
*/
|
|
150
204
|
onSelect?: () => void;
|
|
151
205
|
}
|
|
152
206
|
/**
|
|
@@ -156,24 +210,42 @@ interface WikilinkItem {
|
|
|
156
210
|
* a promise.
|
|
157
211
|
*/
|
|
158
212
|
type WikilinkSearchHandler = (query: string) => WikilinkItem[] | Promise<WikilinkItem[]>;
|
|
159
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* The selection the selection menu was opened over.
|
|
215
|
+
*/
|
|
160
216
|
interface SelectionMenuContext {
|
|
161
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* The selected text, with block boundaries as blank lines.
|
|
219
|
+
*/
|
|
162
220
|
selectedText: string;
|
|
163
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Start of the selection.
|
|
223
|
+
*/
|
|
164
224
|
from: number;
|
|
165
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* End of the selection.
|
|
227
|
+
*/
|
|
166
228
|
to: number;
|
|
167
229
|
}
|
|
168
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* One row in the selection menu. The host ranks the rows; the menu does not re-sort.
|
|
232
|
+
*/
|
|
169
233
|
interface SelectionMenuItem {
|
|
170
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Stable identity for the row.
|
|
236
|
+
*/
|
|
171
237
|
id: string;
|
|
172
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Display text.
|
|
240
|
+
*/
|
|
173
241
|
label: string;
|
|
174
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* Secondary text shown beside the label.
|
|
244
|
+
*/
|
|
175
245
|
detail?: string;
|
|
176
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* Runs when the row is picked, with the selection the menu was opened over.
|
|
248
|
+
*/
|
|
177
249
|
onSelect: (context: SelectionMenuContext) => void;
|
|
178
250
|
}
|
|
179
251
|
/**
|
|
@@ -182,7 +254,9 @@ interface SelectionMenuItem {
|
|
|
182
254
|
* returns the rows to show, either synchronously or as a promise.
|
|
183
255
|
*/
|
|
184
256
|
type SelectionMenuSearchHandler = (query: string, context: SelectionMenuContext) => SelectionMenuItem[] | Promise<SelectionMenuItem[]>;
|
|
185
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* Reports how a pending replacement ended and its final staged value.
|
|
259
|
+
*/
|
|
186
260
|
type PendingReplacementResolveHandler = (outcome: PendingReplacementOutcome, pending: PendingReplacement) => void;
|
|
187
261
|
//#endregion
|
|
188
262
|
//#region src/components/editor.d.ts
|
|
@@ -331,7 +405,9 @@ interface EditorProps {
|
|
|
331
405
|
* other file. Return `undefined` to decline. Pass a stable function.
|
|
332
406
|
*/
|
|
333
407
|
onFilePaste?: FilePasteOptions['onFilePaste'];
|
|
334
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* Called when persisting a pasted/dropped file throws.
|
|
410
|
+
*/
|
|
335
411
|
onFileSaveError?: FilePasteOptions['onFileSaveError'];
|
|
336
412
|
/**
|
|
337
413
|
* Called when the user clicks a rendered image, with its markdown `src`,
|
|
@@ -360,7 +436,9 @@ interface EditorProps {
|
|
|
360
436
|
* e.g. `->` with `→` and `(c)` with `©`. On by default.
|
|
361
437
|
*/
|
|
362
438
|
substitution?: boolean;
|
|
363
|
-
/**
|
|
439
|
+
/**
|
|
440
|
+
* Handles a leading `---` frontmatter block (off by default).
|
|
441
|
+
*/
|
|
364
442
|
frontmatter?: boolean;
|
|
365
443
|
/**
|
|
366
444
|
* Shows the per-block gutter handle: a drag grip for reordering blocks and a
|
|
@@ -381,7 +459,9 @@ interface EditorProps {
|
|
|
381
459
|
* receives the editor state. Pass a stable function.
|
|
382
460
|
*/
|
|
383
461
|
placeholder?: PlaceholderOptions['placeholder'];
|
|
384
|
-
/**
|
|
462
|
+
/**
|
|
463
|
+
* Makes the editor read-only.
|
|
464
|
+
*/
|
|
385
465
|
readOnly?: boolean;
|
|
386
466
|
/**
|
|
387
467
|
* Enables the browser's native spell checking. Defaults to the browser's
|
|
@@ -405,13 +485,21 @@ interface EditorProps {
|
|
|
405
485
|
* for "15:45". Defaults to '12'.
|
|
406
486
|
*/
|
|
407
487
|
timeFormat?: TimeFormat;
|
|
408
|
-
/**
|
|
488
|
+
/**
|
|
489
|
+
* Class on the editable root (the contenteditable).
|
|
490
|
+
*/
|
|
409
491
|
editorClassName?: string;
|
|
410
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* Class on the outer `.meowdown` wrapper div.
|
|
494
|
+
*/
|
|
411
495
|
wrapperClassName?: string;
|
|
412
|
-
/**
|
|
496
|
+
/**
|
|
497
|
+
* Imperative handle for the editor.
|
|
498
|
+
*/
|
|
413
499
|
handleRef?: Ref<EditorHandle>;
|
|
414
|
-
/**
|
|
500
|
+
/**
|
|
501
|
+
* Nodes rendered inside the editor's ProseKit context.
|
|
502
|
+
*/
|
|
415
503
|
children?: ReactNode;
|
|
416
504
|
}
|
|
417
505
|
/**
|
|
@@ -423,7 +511,9 @@ interface EditorProps {
|
|
|
423
511
|
declare function MeowdownEditor({ mode, initialMarkdown, onDocChange, onSlashMenuSearch, onTagSearch, onWikilinkSearch, onSelectionMenuSearch, selectionMenuAffordance, pendingReplacementActions, onPendingReplacementResolve, onWikilinkClick, onLinkClick, onLinkCopy, onTagClick, onExitBoundary, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveFileInfo, onFileClick, onFilePaste, onFileSaveError, onImageClick, embedPaste, linkPaste, bulletAfterHeading, substitution, frontmatter, blockHandle, caretGlide, placeholder, readOnly, spellCheck, searchQuery, onSearchChange, timeFormat, editorClassName, wrapperClassName, handleRef, children }: EditorProps): ReactElement;
|
|
424
512
|
//#endregion
|
|
425
513
|
//#region src/components/markdown-view.d.ts
|
|
426
|
-
/**
|
|
514
|
+
/**
|
|
515
|
+
* Payload for {@link TaskClickHandler}.
|
|
516
|
+
*/
|
|
427
517
|
interface TaskClickPayload {
|
|
428
518
|
/**
|
|
429
519
|
* Zero-based position of the clicked checkbox among all the checkboxes this
|
|
@@ -432,9 +522,13 @@ interface TaskClickPayload {
|
|
|
432
522
|
* same source.
|
|
433
523
|
*/
|
|
434
524
|
index: number;
|
|
435
|
-
/**
|
|
525
|
+
/**
|
|
526
|
+
* The checkbox's rendered state. The view never flips it — see the handler doc.
|
|
527
|
+
*/
|
|
436
528
|
checked: boolean;
|
|
437
|
-
/**
|
|
529
|
+
/**
|
|
530
|
+
* The item's list marker as written (`+` renders a circle checkbox, `-`/`*` a square).
|
|
531
|
+
*/
|
|
438
532
|
marker: ListMarker;
|
|
439
533
|
/**
|
|
440
534
|
* First line of the item's own inline content, exactly as it appears in the
|
|
@@ -443,7 +537,9 @@ interface TaskClickPayload {
|
|
|
443
537
|
* mismatch instead of toggling the wrong item.
|
|
444
538
|
*/
|
|
445
539
|
text: string;
|
|
446
|
-
/**
|
|
540
|
+
/**
|
|
541
|
+
* The originating click. Read modifier keys or position a popover from it.
|
|
542
|
+
*/
|
|
447
543
|
event: globalThis.MouseEvent;
|
|
448
544
|
}
|
|
449
545
|
/**
|
|
@@ -453,11 +549,17 @@ interface TaskClickPayload {
|
|
|
453
549
|
*/
|
|
454
550
|
type TaskClickHandler = (payload: TaskClickPayload) => void;
|
|
455
551
|
interface MarkdownViewProps {
|
|
456
|
-
/**
|
|
552
|
+
/**
|
|
553
|
+
* The Markdown to render. Live: changing it re-renders the content.
|
|
554
|
+
*/
|
|
457
555
|
markdown: string;
|
|
458
|
-
/**
|
|
556
|
+
/**
|
|
557
|
+
* Mark mode for the read-only view. Defaults to `'hide'`.
|
|
558
|
+
*/
|
|
459
559
|
markMode?: MarkMode;
|
|
460
|
-
/**
|
|
560
|
+
/**
|
|
561
|
+
* Peel a leading YAML frontmatter block before rendering. Off by default.
|
|
562
|
+
*/
|
|
461
563
|
frontmatter?: boolean;
|
|
462
564
|
/**
|
|
463
565
|
* Whether rendered links, images, file pills, and task checkboxes can be activated.
|
|
@@ -473,28 +575,46 @@ interface MarkdownViewProps {
|
|
|
473
575
|
* the view exists to show.
|
|
474
576
|
*/
|
|
475
577
|
expandCollapsed?: boolean;
|
|
476
|
-
/**
|
|
578
|
+
/**
|
|
579
|
+
* Map an image `src` to a displayable URL, or `undefined` to skip it.
|
|
580
|
+
*/
|
|
477
581
|
resolveImageUrl?: (src: string) => string | undefined;
|
|
478
582
|
/**
|
|
479
583
|
* Claim a `[label](url)` link as a file pill instead of a regular link.
|
|
480
584
|
* Must be pure; return `false` for links that should render normally.
|
|
481
585
|
*/
|
|
482
586
|
resolveFileLink?: FileLinkResolver;
|
|
483
|
-
/**
|
|
587
|
+
/**
|
|
588
|
+
* Classify `![[target]]` as an image, file, or note; unresolved source stays literal.
|
|
589
|
+
*/
|
|
484
590
|
resolveWikiEmbed?: WikiEmbedResolver;
|
|
485
|
-
/**
|
|
591
|
+
/**
|
|
592
|
+
* Resolve metadata shown on a file pill.
|
|
593
|
+
*/
|
|
486
594
|
resolveFileInfo?: FileInfoResolver;
|
|
487
|
-
/**
|
|
595
|
+
/**
|
|
596
|
+
* Called when a rendered wikilink is clicked. Pass a stable function.
|
|
597
|
+
*/
|
|
488
598
|
onWikilinkClick?: WikilinkClickHandler;
|
|
489
|
-
/**
|
|
599
|
+
/**
|
|
600
|
+
* Called when a rendered Markdown link is clicked. Pass a stable function.
|
|
601
|
+
*/
|
|
490
602
|
onLinkClick?: LinkClickHandler;
|
|
491
|
-
/**
|
|
603
|
+
/**
|
|
604
|
+
* Called when a rendered image is clicked. Pass a stable function.
|
|
605
|
+
*/
|
|
492
606
|
onImageClick?: ImageClickHandler;
|
|
493
|
-
/**
|
|
607
|
+
/**
|
|
608
|
+
* Called when a rendered file pill is clicked. Pass a stable function.
|
|
609
|
+
*/
|
|
494
610
|
onFileClick?: FileClickHandler;
|
|
495
|
-
/**
|
|
611
|
+
/**
|
|
612
|
+
* Called when a rendered task checkbox is clicked. Pass a stable function.
|
|
613
|
+
*/
|
|
496
614
|
onTaskClick?: TaskClickHandler;
|
|
497
|
-
/**
|
|
615
|
+
/**
|
|
616
|
+
* Extra class on the content root (alongside `ProseMirror meowdown-content`).
|
|
617
|
+
*/
|
|
498
618
|
className?: string;
|
|
499
619
|
}
|
|
500
620
|
/**
|
|
@@ -511,7 +631,9 @@ interface MarkdownViewProps {
|
|
|
511
631
|
declare function MarkdownView({ markdown, markMode, frontmatter, interactive, expandCollapsed, resolveImageUrl, resolveFileLink, resolveWikiEmbed, resolveFileInfo, onWikilinkClick, onLinkClick, onImageClick, onFileClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
|
|
512
632
|
//#endregion
|
|
513
633
|
//#region src/components/wikilink-hover-card.d.ts
|
|
514
|
-
/**
|
|
634
|
+
/**
|
|
635
|
+
* Props for {@link WikilinkHoverCard}.
|
|
636
|
+
*/
|
|
515
637
|
interface WikilinkHoverCardProps {
|
|
516
638
|
/**
|
|
517
639
|
* Render the card body from the hovered wiki link. Returning `null` renders
|
|
@@ -522,7 +644,9 @@ interface WikilinkHoverCardProps {
|
|
|
522
644
|
* re-runs it for the current link.
|
|
523
645
|
*/
|
|
524
646
|
readonly children: (hit: WikilinkHoverHit) => ReactNode | Promise<ReactNode>;
|
|
525
|
-
/**
|
|
647
|
+
/**
|
|
648
|
+
* Optional class applied to the popup, after the default card surface.
|
|
649
|
+
*/
|
|
526
650
|
readonly className?: string;
|
|
527
651
|
}
|
|
528
652
|
/**
|
package/dist/index.js
CHANGED
|
@@ -487,10 +487,14 @@ function EditorExtensions({ markMode, onDocChange, onWikilinkClick, onLinkClick,
|
|
|
487
487
|
|
|
488
488
|
//#endregion
|
|
489
489
|
//#region src/hooks/use-delayed-flag.ts
|
|
490
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* Delay before the flag opens, in ms.
|
|
492
|
+
*/
|
|
491
493
|
const OPEN_DELAY$1 = 400;
|
|
492
|
-
/**
|
|
493
|
-
*
|
|
494
|
+
/**
|
|
495
|
+
* Grace before the flag closes, in ms. The window lets a pointer travel from
|
|
496
|
+
* the hovered link onto the popover it anchors.
|
|
497
|
+
*/
|
|
494
498
|
const CLOSE_DELAY$1 = 300;
|
|
495
499
|
/**
|
|
496
500
|
* Mirrors `value` into a boolean that flips true `openDelay`ms after `value`
|
|
@@ -527,14 +531,18 @@ var link_menu_module_default = {
|
|
|
527
531
|
|
|
528
532
|
//#endregion
|
|
529
533
|
//#region src/components/link-menu.tsx
|
|
530
|
-
/**
|
|
531
|
-
*
|
|
534
|
+
/**
|
|
535
|
+
* Select the link unit so the text-backed commands target it, and keep the
|
|
536
|
+
* editor focused so its virtual selection stays visible behind the popover.
|
|
537
|
+
*/
|
|
532
538
|
function selectLinkUnit(editor, link) {
|
|
533
539
|
editor.commands.selectText(link.unit.from, link.unit.to);
|
|
534
540
|
editor.focus();
|
|
535
541
|
}
|
|
536
|
-
/**
|
|
537
|
-
*
|
|
542
|
+
/**
|
|
543
|
+
* A Base UI popover anchored at `anchor`. Base UI dismisses it on an outside
|
|
544
|
+
* press or Escape, both routed through `onClose`.
|
|
545
|
+
*/
|
|
538
546
|
function LinkPopover({ anchor, onClose, onPopupHover, children }) {
|
|
539
547
|
return /* @__PURE__ */ jsx(Popover.Root, {
|
|
540
548
|
open: true,
|
|
@@ -558,7 +566,9 @@ function LinkPopover({ anchor, onClose, onPopupHover, children }) {
|
|
|
558
566
|
}) })
|
|
559
567
|
});
|
|
560
568
|
}
|
|
561
|
-
/**
|
|
569
|
+
/**
|
|
570
|
+
* The hover preview: the url plus copy, edit, and remove actions.
|
|
571
|
+
*/
|
|
562
572
|
function LinkInfoContent({ href, onLinkClick, onLinkCopy, onEdit, onRemove }) {
|
|
563
573
|
return /* @__PURE__ */ jsxs("div", {
|
|
564
574
|
className: link_menu_module_default.Row,
|
|
@@ -605,7 +615,9 @@ function LinkInfoContent({ href, onLinkClick, onLinkCopy, onEdit, onRemove }) {
|
|
|
605
615
|
]
|
|
606
616
|
});
|
|
607
617
|
}
|
|
608
|
-
/**
|
|
618
|
+
/**
|
|
619
|
+
* The url and title form, opened by `Mod-k` or the preview's edit button.
|
|
620
|
+
*/
|
|
609
621
|
function LinkEditContent({ link, onSubmit }) {
|
|
610
622
|
const hrefInputRef = useRef(null);
|
|
611
623
|
const titleInputRef = useRef(null);
|
|
@@ -773,9 +785,13 @@ var pending_replacement_preview_module_default = {
|
|
|
773
785
|
* 14rem max-height plus the footer, borders, and the anchor offset.
|
|
774
786
|
*/
|
|
775
787
|
const PREVIEW_CLEARANCE = 320;
|
|
776
|
-
/**
|
|
788
|
+
/**
|
|
789
|
+
* Minimum gap (px) kept above the anchor line when scrolling to make room.
|
|
790
|
+
*/
|
|
777
791
|
const SCROLL_TOP_MARGIN = 16;
|
|
778
|
-
/**
|
|
792
|
+
/**
|
|
793
|
+
* The nearest ancestor that can scroll vertically, or the page scroller.
|
|
794
|
+
*/
|
|
779
795
|
function closestScrollable(element) {
|
|
780
796
|
for (let node = element.parentElement; node; node = node.parentElement) {
|
|
781
797
|
const { overflowY } = getComputedStyle(node);
|
|
@@ -1004,8 +1020,10 @@ function SelectionMenu({ onSelectionMenuSearch, context, onOpen, onClose, afford
|
|
|
1004
1020
|
});
|
|
1005
1021
|
return null;
|
|
1006
1022
|
}
|
|
1007
|
-
/**
|
|
1008
|
-
*
|
|
1023
|
+
/**
|
|
1024
|
+
* The menu content. Mounted only while the menu is open, so its filter state
|
|
1025
|
+
* resets naturally on close.
|
|
1026
|
+
*/
|
|
1009
1027
|
function SelectionMenuPopup({ onSelectionMenuSearch, context, onClose }) {
|
|
1010
1028
|
const [query, setQuery] = useState("");
|
|
1011
1029
|
const [items, setItems] = useState([]);
|
|
@@ -1081,11 +1099,15 @@ function SelectionMenuPopup({ onSelectionMenuSearch, context, onClose }) {
|
|
|
1081
1099
|
|
|
1082
1100
|
//#endregion
|
|
1083
1101
|
//#region src/utils/date-format.ts
|
|
1084
|
-
/**
|
|
1102
|
+
/**
|
|
1103
|
+
* Formats the current wall-clock time for the `/now` slash command.
|
|
1104
|
+
*/
|
|
1085
1105
|
function formatNowTime(timeFormat) {
|
|
1086
1106
|
return formatTime(/* @__PURE__ */ new Date(), timeFormat);
|
|
1087
1107
|
}
|
|
1088
|
-
/**
|
|
1108
|
+
/**
|
|
1109
|
+
* Formats a given time as `3:45pm` ('12') or `15:45` ('24').
|
|
1110
|
+
*/
|
|
1089
1111
|
function formatTime(date, timeFormat) {
|
|
1090
1112
|
return timeFormat === "12" ? formatTime12(date) : formatTime24(date);
|
|
1091
1113
|
}
|
|
@@ -2384,7 +2406,9 @@ function MathView(props) {
|
|
|
2384
2406
|
})]
|
|
2385
2407
|
});
|
|
2386
2408
|
}
|
|
2387
|
-
/**
|
|
2409
|
+
/**
|
|
2410
|
+
* A `math` code block: the rendered formula alone, the source while KaTeX loads.
|
|
2411
|
+
*/
|
|
2388
2412
|
function MathCodeBlock({ code }) {
|
|
2389
2413
|
const katex = useKaTeX(true);
|
|
2390
2414
|
if (!katex) return /* @__PURE__ */ jsx(CodeBlock, {
|
|
@@ -2412,7 +2436,9 @@ function MermaidCodeBlock({ code }) {
|
|
|
2412
2436
|
"data-testid": "code-block-mermaid-preview"
|
|
2413
2437
|
});
|
|
2414
2438
|
}
|
|
2415
|
-
/**
|
|
2439
|
+
/**
|
|
2440
|
+
* Wrap inline `children` in one mark, special-casing the view/link marks.
|
|
2441
|
+
*/
|
|
2416
2442
|
function wrapMark(mark, children, context) {
|
|
2417
2443
|
switch (mark.type.name) {
|
|
2418
2444
|
case "mdWikilink": {
|
|
@@ -2518,7 +2544,9 @@ function renderInline(node, context) {
|
|
|
2518
2544
|
marks: Mark.setFrom(marks)
|
|
2519
2545
|
})), 0, context);
|
|
2520
2546
|
}
|
|
2521
|
-
/**
|
|
2547
|
+
/**
|
|
2548
|
+
* A collapsed list renders as an expanded one
|
|
2549
|
+
*/
|
|
2522
2550
|
function expandCollapsedList(node) {
|
|
2523
2551
|
const attrs = node.attrs;
|
|
2524
2552
|
if (!attrs.collapsed) return node;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.64.
|
|
4
|
+
"version": "0.64.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"github-slugger": "^2.0.0",
|
|
32
32
|
"lucide-react": "^1.28.0",
|
|
33
33
|
"react-property": "^2.0.2",
|
|
34
|
-
"@meowdown/core": "0.64.
|
|
34
|
+
"@meowdown/core": "0.64.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^19.0.0",
|