@meowdown/react 0.43.0 → 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 CHANGED
@@ -15,8 +15,10 @@ type SelectionHint = SelectionJSON$1 | 'start' | 'end';
15
15
  type EditorStateSnapshot = [markdown: string, selection: SelectionJSON$1];
16
16
  interface EditorHandle {
17
17
  /**
18
- * Serializes the current document to Markdown. Can be expensive on large
19
- * documents; call it on demand (e.g. throttled) instead of on every change.
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.
20
22
  */
21
23
  getMarkdown: () => string;
22
24
  /** Replaces the whole document as a single undoable edit. */
@@ -31,7 +33,10 @@ interface EditorHandle {
31
33
  * `onDocChange`: the host cannot know the resulting document.
32
34
  */
33
35
  insertMarkdown: (markdown: string) => void;
34
- /** Returns the current Markdown and selection. */
36
+ /**
37
+ * Returns the current Markdown and selection, with the same pending-input
38
+ * reconciliation (and possible synchronous `onDocChange`) as `getMarkdown`.
39
+ */
35
40
  getState: () => EditorStateSnapshot;
36
41
  /**
37
42
  * Replaces the document (if `markdown` is given) and restores `selection`:
package/dist/index.js CHANGED
@@ -1523,6 +1523,18 @@ function WikilinkMenu({ onWikilinkSearch }) {
1523
1523
 
1524
1524
  //#endregion
1525
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
+ }
1526
1538
  function resolveSelection(doc, selection) {
1527
1539
  if (selection === "start") return Selection.atStart(doc);
1528
1540
  if (selection === "end") return Selection.atEnd(doc);
@@ -1565,6 +1577,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
1565
1577
  }, []);
1566
1578
  useImperativeHandle(ref, () => {
1567
1579
  function getMarkdown() {
1580
+ flushPendingDOMChanges(editor);
1568
1581
  return docToMarkdown(editor.state.doc, { frontmatter });
1569
1582
  }
1570
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.43.0",
4
+ "version": "0.43.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "clsx": "^2.1.1",
27
27
  "lucide-react": "^1.21.0",
28
28
  "react-property": "^2.0.2",
29
- "@meowdown/core": "0.43.0"
29
+ "@meowdown/core": "0.43.1"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": "^19.0.0",