@prosekit/svelte 0.8.5 → 0.8.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE3H,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIhE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CA0BtB"}
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE3H,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAIhE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;IAC7D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CA8BtB"}
@@ -16,8 +16,12 @@ export function useEditor(options) {
16
16
  const editorStore = writable(editor);
17
17
  if (update) {
18
18
  onMount(() => {
19
+ // We need `queueMicrotask` here to avoid `state_unsafe_mutation` errors.
20
+ // See https://github.com/prosekit/prosekit/issues/1439
19
21
  const forceUpdate = () => {
20
- editorStore.set(editor);
22
+ queueMicrotask(() => {
23
+ editorStore.set(editor);
24
+ });
21
25
  };
22
26
  const extension = union(defineMountHandler(forceUpdate), defineUpdateHandler(forceUpdate));
23
27
  return editor.use(extension);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/svelte",
3
3
  "type": "module",
4
- "version": "0.8.5",
4
+ "version": "0.8.6",
5
5
  "private": false,
6
6
  "description": "Svelte components and utilities for ProseKit",
7
7
  "author": {
@@ -79,8 +79,8 @@
79
79
  "@prosemirror-adapter/core": "^0.4.6",
80
80
  "@prosemirror-adapter/svelte": "^0.5.0",
81
81
  "@prosekit/core": "^0.10.0",
82
- "@prosekit/web": "^0.7.10",
83
- "@prosekit/pm": "^0.1.15"
82
+ "@prosekit/pm": "^0.1.15",
83
+ "@prosekit/web": "^0.7.10"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "svelte": ">= 5.0.0"
@@ -31,8 +31,12 @@ export function useEditor<E extends Extension = any>(options?: {
31
31
 
32
32
  if (update) {
33
33
  onMount(() => {
34
+ // We need `queueMicrotask` here to avoid `state_unsafe_mutation` errors.
35
+ // See https://github.com/prosekit/prosekit/issues/1439
34
36
  const forceUpdate = () => {
35
- editorStore.set(editor)
37
+ queueMicrotask(() => {
38
+ editorStore.set(editor)
39
+ })
36
40
  }
37
41
  const extension = union(
38
42
  defineMountHandler(forceUpdate),