@meowdown/react 0.56.0 → 0.57.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.
Files changed (2) hide show
  1. package/dist/index.js +6 -3
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1708,7 +1708,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
1708
1708
  function getState() {
1709
1709
  return [getMarkdown(), getSelection()];
1710
1710
  }
1711
- function replaceState(markdown, selection, addToHistory = true) {
1711
+ function replaceState(markdown, selection, addToHistory = true, forceMarkdown = false) {
1712
1712
  if (markdown == null && !selection) return;
1713
1713
  const transaction = editor.state.tr;
1714
1714
  if (markdown != null) {
@@ -1716,7 +1716,10 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
1716
1716
  nodes: editor.nodes,
1717
1717
  frontmatter
1718
1718
  });
1719
- transaction.replaceWith(0, transaction.doc.content.size, doc.content);
1719
+ const currentMarkdown = docToMarkdown(transaction.doc, { frontmatter });
1720
+ const nextMarkdown = docToMarkdown(doc, { frontmatter });
1721
+ if (forceMarkdown || currentMarkdown !== nextMarkdown) transaction.replaceWith(0, transaction.doc.content.size, doc.content);
1722
+ else if (!selection) return;
1720
1723
  }
1721
1724
  if (selection) transaction.setSelection(resolveSelection(transaction.doc, selection)).scrollIntoView();
1722
1725
  if (!addToHistory) transaction.setMeta("addToHistory", false);
@@ -1735,7 +1738,7 @@ function ProseKitEditor({ markMode = "focus", initialMarkdown, onDocChange, onSl
1735
1738
  }
1736
1739
  function refreshMarkdownRendering() {
1737
1740
  const [markdown, selection] = getState();
1738
- replaceState(markdown, selection, false);
1741
+ replaceState(markdown, selection, false, true);
1739
1742
  }
1740
1743
  function insertMarkdown(markdown) {
1741
1744
  editor.commands.insertMarkdown(markdown);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meowdown/react",
3
3
  "type": "module",
4
- "version": "0.56.0",
4
+ "version": "0.57.1",
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.6",
27
27
  "@prosekit/pm": "^0.1.19-beta.3",
28
- "@prosekit/react": "^0.8.0-beta.21",
28
+ "@prosekit/react": "^0.8.0-beta.22",
29
29
  "beautiful-mermaid": "^1.1.3",
30
30
  "clsx": "^2.1.1",
31
31
  "github-slugger": "^2.0.0",
32
32
  "lucide-react": "^1.24.0",
33
33
  "react-property": "^2.0.2",
34
- "@meowdown/core": "0.56.0"
34
+ "@meowdown/core": "0.57.1"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^19.0.0",