@meowdown/react 0.42.1 → 0.43.1
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 +10 -52
- package/dist/index.js +14 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { ReactElement, ReactNode, Ref } from "react";
|
|
|
2
2
|
import { AcceptPendingReplacementOptions, ExitBoundaryHandler, FileClickHandler, FileLinkResolver, FilePasteOptions, FileViewOptions, ImageClickHandler, ImageOptions, LinkClickHandler, LinkCopyHandler, ListMarker, MarkMode, PendingReplacement, PendingReplacementOutcome, PlaceholderOptions, StartPendingReplacementOptions, TagClickHandler, TypedEditor, WikilinkClickHandler } from "@meowdown/core";
|
|
3
3
|
import { SelectionJSON, SelectionJSON as SelectionJSON$1 } from "@prosekit/core";
|
|
4
4
|
import { useEditor, useExtension, useKeymap } from "@prosekit/react";
|
|
5
|
-
|
|
6
5
|
//#region src/utils/date-format.d.ts
|
|
7
6
|
type TimeFormat = '12' | '24';
|
|
8
7
|
//#endregion
|
|
@@ -16,8 +15,10 @@ type SelectionHint = SelectionJSON$1 | 'start' | 'end';
|
|
|
16
15
|
type EditorStateSnapshot = [markdown: string, selection: SelectionJSON$1];
|
|
17
16
|
interface EditorHandle {
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Reconciles pending native input, then serializes the current document to
|
|
19
|
+
* Markdown. If reconciliation changes the document, `onDocChange` runs
|
|
20
|
+
* before this method returns. Can be expensive on large documents; call it
|
|
21
|
+
* on demand (e.g. throttled) instead of on every change.
|
|
21
22
|
*/
|
|
22
23
|
getMarkdown: () => string;
|
|
23
24
|
/** Replaces the whole document as a single undoable edit. */
|
|
@@ -32,7 +33,10 @@ interface EditorHandle {
|
|
|
32
33
|
* `onDocChange`: the host cannot know the resulting document.
|
|
33
34
|
*/
|
|
34
35
|
insertMarkdown: (markdown: string) => void;
|
|
35
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Returns the current Markdown and selection, with the same pending-input
|
|
38
|
+
* reconciliation (and possible synchronous `onDocChange`) as `getMarkdown`.
|
|
39
|
+
*/
|
|
36
40
|
getState: () => EditorStateSnapshot;
|
|
37
41
|
/**
|
|
38
42
|
* Replaces the document (if `markdown` is given) and restores `selection`:
|
|
@@ -365,43 +369,7 @@ interface EditorProps {
|
|
|
365
369
|
/** Nodes rendered inside the editor's ProseKit context. */
|
|
366
370
|
children?: ReactNode;
|
|
367
371
|
}
|
|
368
|
-
declare function MeowdownEditor({
|
|
369
|
-
mode,
|
|
370
|
-
initialMarkdown,
|
|
371
|
-
onDocChange,
|
|
372
|
-
onSlashMenuSearch,
|
|
373
|
-
onTagSearch,
|
|
374
|
-
onWikilinkSearch,
|
|
375
|
-
onSelectionMenuSearch,
|
|
376
|
-
selectionMenuAffordance,
|
|
377
|
-
pendingReplacementActions,
|
|
378
|
-
onPendingReplacementResolve,
|
|
379
|
-
onWikilinkClick,
|
|
380
|
-
onLinkClick,
|
|
381
|
-
onLinkCopy,
|
|
382
|
-
onTagClick,
|
|
383
|
-
onExitBoundary,
|
|
384
|
-
resolveImageUrl,
|
|
385
|
-
resolveFileLink,
|
|
386
|
-
resolveFileInfo,
|
|
387
|
-
onFileClick,
|
|
388
|
-
onFilePaste,
|
|
389
|
-
onFileSaveError,
|
|
390
|
-
onImageClick,
|
|
391
|
-
embedPaste,
|
|
392
|
-
linkPaste,
|
|
393
|
-
bulletAfterHeading,
|
|
394
|
-
frontmatter,
|
|
395
|
-
blockHandle,
|
|
396
|
-
placeholder,
|
|
397
|
-
readOnly,
|
|
398
|
-
spellCheck,
|
|
399
|
-
timeFormat,
|
|
400
|
-
editorClassName,
|
|
401
|
-
wrapperClassName,
|
|
402
|
-
handleRef,
|
|
403
|
-
children
|
|
404
|
-
}: EditorProps): import("react").JSX.Element;
|
|
372
|
+
declare function MeowdownEditor({ mode, initialMarkdown, onDocChange, onSlashMenuSearch, onTagSearch, onWikilinkSearch, onSelectionMenuSearch, selectionMenuAffordance, pendingReplacementActions, onPendingReplacementResolve, onWikilinkClick, onLinkClick, onLinkCopy, onTagClick, onExitBoundary, resolveImageUrl, resolveFileLink, resolveFileInfo, onFileClick, onFilePaste, onFileSaveError, onImageClick, embedPaste, linkPaste, bulletAfterHeading, frontmatter, blockHandle, placeholder, readOnly, spellCheck, timeFormat, editorClassName, wrapperClassName, handleRef, children }: EditorProps): import("react").JSX.Element;
|
|
405
373
|
//#endregion
|
|
406
374
|
//#region src/components/markdown-view.d.ts
|
|
407
375
|
/** Payload for {@link TaskClickHandler}. */
|
|
@@ -464,16 +432,6 @@ interface MarkdownViewProps {
|
|
|
464
432
|
* Callbacks (`onWikilinkClick`, etc.) should be stable; pass them via
|
|
465
433
|
* `useCallback` to avoid re-rendering the whole tree.
|
|
466
434
|
*/
|
|
467
|
-
declare function MarkdownView({
|
|
468
|
-
markdown,
|
|
469
|
-
markMode,
|
|
470
|
-
frontmatter,
|
|
471
|
-
resolveImageUrl,
|
|
472
|
-
onWikilinkClick,
|
|
473
|
-
onLinkClick,
|
|
474
|
-
onImageClick,
|
|
475
|
-
onTaskClick,
|
|
476
|
-
className
|
|
477
|
-
}: MarkdownViewProps): ReactElement;
|
|
435
|
+
declare function MarkdownView({ markdown, markMode, frontmatter, resolveImageUrl, onWikilinkClick, onLinkClick, onImageClick, onTaskClick, className }: MarkdownViewProps): ReactElement;
|
|
478
436
|
//#endregion
|
|
479
437
|
export { type EditorHandle, type EditorMode, type EditorProps, type EditorStateSnapshot, MarkdownView, type MarkdownViewProps, MeowdownEditor, type PendingReplacementResolveHandler, 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 WikilinkItem, type WikilinkSearchHandler, useEditor, useExtension, useKeymap };
|
package/dist/index.js
CHANGED
|
@@ -1490,6 +1490,7 @@ function WikilinkMenu({ onWikilinkSearch }) {
|
|
|
1490
1490
|
return /* @__PURE__ */ jsx(AutocompleteRoot, {
|
|
1491
1491
|
regex,
|
|
1492
1492
|
filter: returnsTrue,
|
|
1493
|
+
followCursor: true,
|
|
1493
1494
|
queryBuilder: queryFromRegexMatch,
|
|
1494
1495
|
onOpenChange: (event) => setOpen(event.detail),
|
|
1495
1496
|
onQueryChange: (event) => setQuery(event.detail),
|
|
@@ -1522,6 +1523,18 @@ function WikilinkMenu({ onWikilinkSearch }) {
|
|
|
1522
1523
|
|
|
1523
1524
|
//#endregion
|
|
1524
1525
|
//#region src/components/prosekit-editor.tsx
|
|
1526
|
+
function isFlushableDOMObserver(value) {
|
|
1527
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1528
|
+
const forceFlush = Reflect.get(value, "forceFlush");
|
|
1529
|
+
return typeof Reflect.get(value, "flush") === "function" && (forceFlush === void 0 || typeof forceFlush === "function");
|
|
1530
|
+
}
|
|
1531
|
+
function flushPendingDOMChanges(editor) {
|
|
1532
|
+
if (!editor.mounted) return;
|
|
1533
|
+
const observer = Reflect.get(editor.view, "domObserver");
|
|
1534
|
+
if (!isFlushableDOMObserver(observer)) return;
|
|
1535
|
+
observer.forceFlush?.();
|
|
1536
|
+
observer.flush();
|
|
1537
|
+
}
|
|
1525
1538
|
function resolveSelection(doc, selection) {
|
|
1526
1539
|
if (selection === "start") return Selection.atStart(doc);
|
|
1527
1540
|
if (selection === "end") return Selection.atEnd(doc);
|
|
@@ -1564,6 +1577,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
|
|
|
1564
1577
|
}, []);
|
|
1565
1578
|
useImperativeHandle(ref, () => {
|
|
1566
1579
|
function getMarkdown() {
|
|
1580
|
+
flushPendingDOMChanges(editor);
|
|
1567
1581
|
return docToMarkdown(editor.state.doc, { frontmatter });
|
|
1568
1582
|
}
|
|
1569
1583
|
function getSelection() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.43.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"@ocavue/utils": "^1.7.0",
|
|
23
23
|
"@prosekit/core": "^0.13.0-beta.5",
|
|
24
24
|
"@prosekit/pm": "^0.1.19-beta.2",
|
|
25
|
-
"@prosekit/react": "^0.8.0-beta.
|
|
25
|
+
"@prosekit/react": "^0.8.0-beta.20",
|
|
26
26
|
"clsx": "^2.1.1",
|
|
27
27
|
"lucide-react": "^1.21.0",
|
|
28
28
|
"react-property": "^2.0.2",
|
|
29
|
-
"@meowdown/core": "0.
|
|
29
|
+
"@meowdown/core": "0.43.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^19.0.0",
|