@meowdown/react 0.59.0 → 0.60.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 CHANGED
@@ -105,8 +105,9 @@ file embeds; return `false` to keep it as a normal link.
105
105
 
106
106
  `searchQuery` highlights every match and selects the first one at or after the
107
107
  caret; changing it re-anchors from wherever the selection is, so refining a
108
- query keeps the match the user is looking at. An empty string (the default)
109
- clears the highlights and leaves the selection alone. `onSearchChange` reports
108
+ query keeps the match the user is looking at. A query that matches nothing
109
+ collapses the previous match selection to a caret, and an empty string (the
110
+ default) clears the highlights and leaves the selection alone. `onSearchChange` reports
110
111
  `{ total, active }` for a match counter (`active` is one-based; `0` means the
111
112
  selection is not on a match), and `EditorHandle.findNext()` /
112
113
  `EditorHandle.findPrevious()` walk the matches and wrap at the document edges.
package/dist/index.d.ts CHANGED
@@ -20,10 +20,8 @@ type EditorStateSnapshot = [markdown: string, selection: SelectionJSON$1];
20
20
  */
21
21
  interface EditorHandle {
22
22
  /**
23
- * Reconciles pending native input, then serializes the current document to
24
- * Markdown. If reconciliation changes the document, `onDocChange` runs
25
- * before this method returns. Can be expensive on large documents; call it
26
- * on demand (e.g. throttled) instead of on every change.
23
+ * Serializes the current document to Markdown. Can be expensive on large
24
+ * documents; call it on demand (e.g. throttled) instead of on every change.
27
25
  */
28
26
  getMarkdown: () => string;
29
27
  /** Replaces the whole document as a single undoable edit. */
@@ -38,10 +36,7 @@ interface EditorHandle {
38
36
  * `onDocChange`: the host cannot know the resulting document.
39
37
  */
40
38
  insertMarkdown: (markdown: string) => void;
41
- /**
42
- * Returns the current Markdown and selection, with the same pending-input
43
- * reconciliation (and possible synchronous `onDocChange`) as `getMarkdown`.
44
- */
39
+ /** Returns the current Markdown and selection. */
45
40
  getState: () => EditorStateSnapshot;
46
41
  /**
47
42
  * Replaces the document (if `markdown` is given) and restores `selection`:
package/dist/index.js CHANGED
@@ -393,12 +393,20 @@ function DropIndicator$1() {
393
393
  //#region src/components/editor-extensions.tsx
394
394
  function EditorExtensions({ markMode, onDocChange, onWikilinkClick, onLinkClick, onTagClick, onExitBoundary, resolveImageUrl, resolveFileInfo, onFileClick, onFilePaste, onFileSaveError, onImageClick, embedPaste, linkPaste, bulletAfterHeading, substitution, placeholder, readOnly, wikilinkEnabled, spellCheck, searchQuery, onSearchChange, editorClassName }) {
395
395
  const editor = useEditor$1();
396
- useEffect(() => {
396
+ useLayoutEffect(() => {
397
397
  editor.commands.setMarkMode(markMode);
398
398
  }, [editor, markMode]);
399
+ useLayoutEffect(() => {
400
+ if (!editorClassName) return;
401
+ const extension = defineViewAttributes({ class: editorClassName });
402
+ return editor.use(extension);
403
+ }, [editor, editorClassName]);
399
404
  const deferredSearchQuery = useDeferredValue(searchQuery);
400
405
  useEffect(() => {
401
- editor.commands.setSearchQuery(deferredSearchQuery);
406
+ editor.commands.setSearchQuery({
407
+ search: deferredSearchQuery,
408
+ literal: true
409
+ });
402
410
  }, [editor, deferredSearchQuery]);
403
411
  useExtension$1(useMemo(() => onSearchChange ? defineSearchStatusHandler(onSearchChange) : null, [onSearchChange]));
404
412
  useExtension$1(useMemo(() => {
@@ -474,9 +482,6 @@ function EditorExtensions({ markMode, onDocChange, onWikilinkClick, onLinkClick,
474
482
  useExtension$1(useMemo(() => {
475
483
  return spellCheck == null ? null : defineSpellCheckPlugin(spellCheck);
476
484
  }, [spellCheck]));
477
- useExtension$1(useMemo(() => {
478
- return editorClassName ? defineViewAttributes({ class: editorClassName }) : null;
479
- }, [editorClassName]));
480
485
  return null;
481
486
  }
482
487
 
@@ -1631,18 +1636,6 @@ function WikilinkMenu({ onWikilinkSearch }) {
1631
1636
 
1632
1637
  //#endregion
1633
1638
  //#region src/components/prosekit-editor.tsx
1634
- function isFlushableDOMObserver(value) {
1635
- if (typeof value !== "object" || value === null) return false;
1636
- const forceFlush = Reflect.get(value, "forceFlush");
1637
- return typeof Reflect.get(value, "flush") === "function" && (forceFlush === void 0 || typeof forceFlush === "function");
1638
- }
1639
- function flushPendingDOMChanges(editor) {
1640
- if (!editor.mounted) return;
1641
- const observer = Reflect.get(editor.view, "domObserver");
1642
- if (!isFlushableDOMObserver(observer)) return;
1643
- observer.forceFlush?.();
1644
- observer.flush();
1645
- }
1646
1639
  function resolveSelection(doc, selection) {
1647
1640
  if (selection === "start") return Selection.atStart(doc);
1648
1641
  if (selection === "end") return Selection.atEnd(doc);
@@ -1717,7 +1710,6 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
1717
1710
  }, []);
1718
1711
  useImperativeHandle(ref, () => {
1719
1712
  function getMarkdown() {
1720
- flushPendingDOMChanges(editor);
1721
1713
  return docToMarkdown(editor.state.doc, { frontmatter });
1722
1714
  }
1723
1715
  function getSelection() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/react",
3
3
  "type": "module",
4
- "version": "0.59.0",
4
+ "version": "0.60.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -25,13 +25,13 @@
25
25
  "@ocavue/utils": "^1.7.0",
26
26
  "@prosekit/core": "^0.13.0-beta.7",
27
27
  "@prosekit/pm": "^0.1.19-beta.4",
28
- "@prosekit/react": "^0.8.0-beta.23",
28
+ "@prosekit/react": "^0.8.0-beta.24",
29
29
  "beautiful-mermaid": "^1.1.3",
30
30
  "clsx": "^2.1.1",
31
31
  "github-slugger": "^2.0.0",
32
- "lucide-react": "^1.24.0",
32
+ "lucide-react": "^1.27.0",
33
33
  "react-property": "^2.0.2",
34
- "@meowdown/core": "0.59.0"
34
+ "@meowdown/core": "0.60.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^19.0.0",
@@ -48,14 +48,14 @@
48
48
  "devDependencies": {
49
49
  "@css-modules-kit/codegen": "^1.4.0",
50
50
  "@ocavue/tsconfig": "^0.7.1",
51
- "@tsdown/css": "^0.22.8",
51
+ "@tsdown/css": "^0.22.14",
52
52
  "@types/react": "^19.2.17",
53
53
  "@types/react-dom": "^19.2.3",
54
54
  "@vitest/browser-playwright": "^4.1.10",
55
55
  "dedent": "^1.7.2",
56
56
  "react": "^19.2.8",
57
57
  "react-dom": "^19.2.8",
58
- "tsdown": "^0.22.8",
58
+ "tsdown": "^0.22.14",
59
59
  "vitest": "^4.1.10",
60
60
  "vitest-browser-commands": "^0.2.1",
61
61
  "vitest-browser-react": "^2.2.0",