@prosekit/vue 0.0.13 → 0.0.14
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/_tsup-dts-rollup.d.ts +5 -0
- package/dist/prosekit-vue.d.ts +1 -0
- package/dist/prosekit-vue.js +25 -2
- package/package.json +2 -2
- package/src/index.ts +1 -0
@@ -12,6 +12,7 @@ import { Extension } from '@prosekit/core';
|
|
12
12
|
import { Keymap } from '@prosekit/core';
|
13
13
|
import { Options } from 'tsup';
|
14
14
|
import { PopoverOptions } from '@prosekit/lit/components/autocomplete-popover';
|
15
|
+
import { ShallowRef } from 'vue';
|
15
16
|
import { UserProjectConfigExport } from 'vitest/dist/config.js';
|
16
17
|
|
17
18
|
declare const AutocompleteEmpty: (props: {
|
@@ -126,6 +127,10 @@ declare function useEditor<E extends Extension = any>(): Editor<E>;
|
|
126
127
|
export { useEditor }
|
127
128
|
export { useEditor as useEditor_alias_1 }
|
128
129
|
|
130
|
+
declare function useEditorRef<E extends Extension = any>(): ShallowRef<Editor<E>>;
|
131
|
+
export { useEditorRef }
|
132
|
+
export { useEditorRef as useEditorRef_alias_1 }
|
133
|
+
|
129
134
|
export declare function useExtension({ extension }: UseExtensionProps): void;
|
130
135
|
|
131
136
|
declare interface UseExtensionProps<T extends Extension = Extension> {
|
package/dist/prosekit-vue.d.ts
CHANGED
package/dist/prosekit-vue.js
CHANGED
@@ -35,7 +35,7 @@ import { computed } from "vue";
|
|
35
35
|
|
36
36
|
// src/hooks/use-extension.ts
|
37
37
|
import "@prosekit/core";
|
38
|
-
import {
|
38
|
+
import { onMounted, onUnmounted } from "vue";
|
39
39
|
|
40
40
|
// src/hooks/use-editor.ts
|
41
41
|
import "@prosekit/core";
|
@@ -46,7 +46,10 @@ function useEditor() {
|
|
46
46
|
// src/hooks/use-extension.ts
|
47
47
|
function useExtension({ extension }) {
|
48
48
|
const editor = useEditor();
|
49
|
-
|
49
|
+
onMounted(() => {
|
50
|
+
const dispose = editor.use(extension);
|
51
|
+
onUnmounted(dispose);
|
52
|
+
});
|
50
53
|
}
|
51
54
|
|
52
55
|
// src/hooks/use-keymap.ts
|
@@ -54,8 +57,28 @@ function useKeymap({ keymap }) {
|
|
54
57
|
const extension = computed(() => addKeymap(keymap));
|
55
58
|
useExtension({ extension: extension.value });
|
56
59
|
}
|
60
|
+
|
61
|
+
// src/hooks/use-editor-ref.ts
|
62
|
+
import { addEventHandler } 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(addEventHandler({ update: forceUpdate }));
|
75
|
+
onUnmounted2(dispose);
|
76
|
+
});
|
77
|
+
return editorRef;
|
78
|
+
}
|
57
79
|
export {
|
58
80
|
ProseKit,
|
59
81
|
useEditor,
|
82
|
+
useEditorRef,
|
60
83
|
useKeymap
|
61
84
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/vue",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.14",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -95,7 +95,7 @@
|
|
95
95
|
"@prosekit/dev": "*",
|
96
96
|
"tsup": "^7.2.0",
|
97
97
|
"typescript": "^5.2.2",
|
98
|
-
"vitest": "^0.34.
|
98
|
+
"vitest": "^0.34.4",
|
99
99
|
"vue": "^3.3.4"
|
100
100
|
},
|
101
101
|
"scripts": {
|
package/src/index.ts
CHANGED