@prosekit/solid 0.0.17 → 0.0.19

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.
@@ -127,10 +127,14 @@ declare type ProseKitProps = ParentProps<{
127
127
  export { ProseKitProps }
128
128
  export { ProseKitProps as ProseKitProps_alias_1 }
129
129
 
130
- declare function useEditor<E extends Extension = any>(): Editor<E>;
130
+ declare function useEditor<E extends Extension = any>(options?: UseEditorOptions): () => Editor<E>;
131
131
  export { useEditor }
132
132
  export { useEditor as useEditor_alias_1 }
133
133
 
134
+ export declare interface UseEditorOptions {
135
+ update?: boolean;
136
+ }
137
+
134
138
  declare function useExtension({ extension }: UseExtensionProps): void;
135
139
  export { useExtension }
136
140
  export { useExtension as useExtension_alias_1 }
@@ -20,16 +20,34 @@ var ProseKit = (props) => {
20
20
  };
21
21
 
22
22
  // src/hooks/use-editor.ts
23
- import { ProseKitError } from "@prosekit/core";
24
- import { useContext } from "solid-js";
25
- function useEditor() {
23
+ import {
24
+ ProseKitError,
25
+ defineEventHandler
26
+ } from "@prosekit/core";
27
+ import { useContext, createEffect, createSignal } from "solid-js";
28
+ function useEditor(options) {
29
+ var _a;
30
+ const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
26
31
  const value = useContext(editorContext);
27
32
  if (!value) {
28
33
  throw new ProseKitError(
29
34
  "useEditor must be used within the ProseKit component"
30
35
  );
31
36
  }
32
- return value.editor;
37
+ const editor = value.editor;
38
+ const [depend, forceUpdate] = useForceUpdate();
39
+ createEffect(() => {
40
+ if (update) {
41
+ return editor.use(defineEventHandler({ update: forceUpdate }));
42
+ }
43
+ }, [editor, update, forceUpdate]);
44
+ return () => {
45
+ depend();
46
+ return editor;
47
+ };
48
+ }
49
+ function useForceUpdate() {
50
+ return createSignal(void 0, { equals: false });
33
51
  }
34
52
 
35
53
  // src/hooks/use-extension.ts
@@ -38,7 +56,7 @@ import { onCleanup, onMount } from "solid-js";
38
56
  function useExtension({ extension }) {
39
57
  const editor = useEditor();
40
58
  onMount(() => {
41
- const cleanup = editor.use(extension);
59
+ const cleanup = editor().use(extension);
42
60
  onCleanup(cleanup);
43
61
  });
44
62
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/solid",
3
3
  "type": "module",
4
- "version": "0.0.17",
4
+ "version": "0.0.19",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -85,8 +85,8 @@
85
85
  "dist"
86
86
  ],
87
87
  "dependencies": {
88
- "@prosekit/core": "^0.0.15",
89
- "@prosekit/lit": "^0.0.19"
88
+ "@prosekit/core": "^0.0.17",
89
+ "@prosekit/lit": "^0.0.21"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "solid-js": ">= 1.7.0"
@@ -98,7 +98,7 @@
98
98
  },
99
99
  "devDependencies": {
100
100
  "@prosekit/dev": "*",
101
- "solid-js": "^1.8.3",
101
+ "solid-js": "^1.8.5",
102
102
  "tsup": "^7.2.0",
103
103
  "typescript": "^5.2.2",
104
104
  "vitest": "^0.34.6"
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export { ProseKit, type ProseKitProps } from './components/prosekit'
2
- export { useEditor } from './hooks/use-editor'
3
- export { useExtension } from './hooks/use-extension'
4
- export { useKeymap } from './hooks/use-keymap'