@prosekit/vue 0.0.21 → 0.0.23

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.
@@ -132,14 +132,16 @@ export { ProseKitProps as ProseKitProps_alias_1 }
132
132
 
133
133
  export declare function provideEditor(editor: Editor): void;
134
134
 
135
- declare function useEditor<E extends Extension = any>(): Editor<E>;
135
+ /**
136
+ * Returns a shallow ref to the editor. If `update` is `true`, any editor update
137
+ * will trigger an effect.
138
+ */
139
+ declare function useEditor<E extends Extension = any>(options?: {
140
+ update?: boolean;
141
+ }): ShallowRef<Editor<E>>;
136
142
  export { useEditor }
137
143
  export { useEditor as useEditor_alias_1 }
138
144
 
139
- declare function useEditorRef<E extends Extension = any>(): ShallowRef<Editor<E>>;
140
- export { useEditorRef }
141
- export { useEditorRef as useEditorRef_alias_1 }
142
-
143
145
  export declare function useExtension({ extension }: UseExtensionProps): void;
144
146
 
145
147
  declare interface UseExtensionProps<T extends Extension = Extension> {
@@ -2,4 +2,3 @@ export { ProseKit } from './_tsup-dts-rollup';
2
2
  export { ProseKitProps } from './_tsup-dts-rollup';
3
3
  export { useKeymap } from './_tsup-dts-rollup';
4
4
  export { useEditor } from './_tsup-dts-rollup';
5
- export { useEditorRef } from './_tsup-dts-rollup';
@@ -35,20 +35,37 @@ import { computed } from "vue";
35
35
 
36
36
  // src/hooks/use-extension.ts
37
37
  import "@prosekit/core";
38
- import { onMounted, onUnmounted } from "vue";
38
+ import { onMounted as onMounted2, onUnmounted as onUnmounted2 } from "vue";
39
39
 
40
40
  // src/hooks/use-editor.ts
41
- import "@prosekit/core";
42
- function useEditor() {
43
- return injectEditor();
41
+ import { defineEventHandler } from "@prosekit/core";
42
+ import {
43
+ onMounted,
44
+ onUnmounted,
45
+ shallowRef,
46
+ triggerRef
47
+ } from "vue";
48
+ function useEditor(options) {
49
+ var _a;
50
+ const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
51
+ const editor = injectEditor();
52
+ const editorRef = shallowRef(editor);
53
+ if (update) {
54
+ onMounted(() => {
55
+ const forceUpdate = () => triggerRef(editorRef);
56
+ const dispose = editor.use(defineEventHandler({ update: forceUpdate }));
57
+ onUnmounted(dispose);
58
+ });
59
+ }
60
+ return editorRef;
44
61
  }
45
62
 
46
63
  // src/hooks/use-extension.ts
47
64
  function useExtension({ extension }) {
48
65
  const editor = useEditor();
49
- onMounted(() => {
50
- const dispose = editor.use(extension);
51
- onUnmounted(dispose);
66
+ onMounted2(() => {
67
+ const dispose = editor.value.use(extension);
68
+ onUnmounted2(dispose);
52
69
  });
53
70
  }
54
71
 
@@ -57,28 +74,8 @@ function useKeymap({ keymap }) {
57
74
  const extension = computed(() => defineKeymap(keymap));
58
75
  useExtension({ extension: extension.value });
59
76
  }
60
-
61
- // src/hooks/use-editor-ref.ts
62
- import { defineEventHandler } from "@prosekit/core";
63
- import {
64
- onMounted as onMounted2,
65
- onUnmounted as onUnmounted2,
66
- shallowRef,
67
- triggerRef
68
- } from "vue";
69
- function useEditorRef() {
70
- const editor = useEditor();
71
- const editorRef = shallowRef(editor);
72
- onMounted2(() => {
73
- const forceUpdate = () => triggerRef(editorRef);
74
- const dispose = editor.use(defineEventHandler({ update: forceUpdate }));
75
- onUnmounted2(dispose);
76
- });
77
- return editorRef;
78
- }
79
77
  export {
80
78
  ProseKit,
81
79
  useEditor,
82
- useEditorRef,
83
80
  useKeymap
84
81
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/vue",
3
3
  "type": "module",
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
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.16",
89
- "@prosekit/lit": "^0.0.20"
88
+ "@prosekit/core": "^0.0.18",
89
+ "@prosekit/lit": "^0.0.22"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "vue": ">= 3.0.0"
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export { ProseKit, type ProseKitProps } from './components/prosekit'
2
- export { useKeymap } from './hooks/use-keymap'
3
- export { useEditor } from './hooks/use-editor'
4
- export { useEditorRef } from './hooks/use-editor-ref'