@prosekit/vue 0.3.12 → 0.3.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/chunk-7DYF3H5Q.js +47 -0
- package/dist/prosekit-vue-autocomplete.js +1 -1
- package/dist/prosekit-vue-block-handle.js +1 -1
- package/dist/prosekit-vue-inline-popover.js +1 -1
- package/dist/prosekit-vue-popover.js +1 -1
- package/dist/prosekit-vue-resizable.js +1 -1
- package/dist/prosekit-vue-tooltip.js +1 -1
- package/dist/prosekit-vue.js +50 -29
- package/package.json +4 -4
- package/dist/chunk-DJHAZPRE.js +0 -32
@@ -0,0 +1,47 @@
|
|
1
|
+
import {
|
2
|
+
useEditorContext
|
3
|
+
} from "./chunk-KCTUNTM2.js";
|
4
|
+
|
5
|
+
// src/components/create-component.ts
|
6
|
+
import {
|
7
|
+
defineComponent,
|
8
|
+
h,
|
9
|
+
onMounted,
|
10
|
+
ref
|
11
|
+
} from "vue";
|
12
|
+
function createComponent(tagName, displayName, defaultProps) {
|
13
|
+
const propertyNames = Object.keys(defaultProps);
|
14
|
+
const hasEditor = Object.hasOwn(defaultProps, "editor");
|
15
|
+
const Component = defineComponent(
|
16
|
+
(props, { slots }) => {
|
17
|
+
const editor = useEditorContext();
|
18
|
+
const mounted = ref(false);
|
19
|
+
onMounted(() => {
|
20
|
+
mounted.value = true;
|
21
|
+
});
|
22
|
+
return () => {
|
23
|
+
var _a;
|
24
|
+
const properties = {};
|
25
|
+
for (const [key, value] of Object.entries(props)) {
|
26
|
+
if (value !== void 0 && !key.startsWith(".")) {
|
27
|
+
properties[propertyNames.includes(key) ? "." + key : key] = value;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
if (hasEditor && editor && !properties["editor"]) {
|
31
|
+
properties.editor = editor;
|
32
|
+
}
|
33
|
+
properties.key = mounted.value ? 1 : 0;
|
34
|
+
return h(tagName, properties, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
35
|
+
};
|
36
|
+
},
|
37
|
+
{
|
38
|
+
props: propertyNames,
|
39
|
+
name: displayName
|
40
|
+
}
|
41
|
+
);
|
42
|
+
return Component;
|
43
|
+
}
|
44
|
+
|
45
|
+
export {
|
46
|
+
createComponent
|
47
|
+
};
|
package/dist/prosekit-vue.js
CHANGED
@@ -31,12 +31,16 @@ import "vue";
|
|
31
31
|
import { EditorNotFoundError } from "@prosekit/core";
|
32
32
|
import { toValue, watchPostEffect } from "vue";
|
33
33
|
function useEditorExtension(editorRef, extensionRef) {
|
34
|
-
|
34
|
+
const editorContext = useEditorContext();
|
35
35
|
watchPostEffect((onCleanup) => {
|
36
|
-
|
37
|
-
|
36
|
+
const editor = toValue(editorRef) || toValue(editorContext);
|
37
|
+
const extension = toValue(extensionRef);
|
38
|
+
if (!editor) {
|
38
39
|
throw new EditorNotFoundError();
|
39
|
-
|
40
|
+
}
|
41
|
+
if (extension) {
|
42
|
+
onCleanup(editor.use(extension));
|
43
|
+
}
|
40
44
|
});
|
41
45
|
}
|
42
46
|
|
@@ -45,7 +49,7 @@ import { withPriority } from "@prosekit/core";
|
|
45
49
|
import { computed, toValue as toValue2 } from "vue";
|
46
50
|
function usePriorityExtension(extension, priority) {
|
47
51
|
return computed(() => {
|
48
|
-
|
52
|
+
const ext = toValue2(extension);
|
49
53
|
return ext && priority ? withPriority(ext, priority) : ext;
|
50
54
|
});
|
51
55
|
}
|
@@ -63,7 +67,7 @@ function withNodeViewProps(component) {
|
|
63
67
|
return defineComponent({
|
64
68
|
name: "NodeViewPropsWrapper",
|
65
69
|
setup: () => {
|
66
|
-
|
70
|
+
const props = useNodeViewContext();
|
67
71
|
return () => h(component, props);
|
68
72
|
}
|
69
73
|
});
|
@@ -71,12 +75,17 @@ function withNodeViewProps(component) {
|
|
71
75
|
var VueViewsConsumer = /* @__PURE__ */ defineComponent({
|
72
76
|
name: "VueViewsConsumer",
|
73
77
|
setup: () => {
|
74
|
-
|
75
|
-
|
78
|
+
const nodeViewFactory = useNodeViewFactory();
|
79
|
+
const extension = computed2(() => {
|
80
|
+
return defineVueNodeViewFactory(nodeViewFactory);
|
81
|
+
});
|
82
|
+
useExtension(extension);
|
83
|
+
return () => null;
|
76
84
|
}
|
77
85
|
});
|
78
86
|
function defineVueNodeView(options) {
|
79
|
-
|
87
|
+
const { name, component, ...userOptions } = options;
|
88
|
+
const args = {
|
80
89
|
...userOptions,
|
81
90
|
component: withNodeViewProps(component)
|
82
91
|
};
|
@@ -95,20 +104,25 @@ function defineVueNodeViewFactory(factory) {
|
|
95
104
|
|
96
105
|
// src/components/prosekit.ts
|
97
106
|
var ProseKit = defineComponent2(
|
98
|
-
(props, { slots }) =>
|
99
|
-
|
100
|
-
return
|
101
|
-
h2(
|
102
|
-
|
103
|
-
|
104
|
-
|
107
|
+
(props, { slots }) => {
|
108
|
+
provideEditor(props.editor);
|
109
|
+
return () => {
|
110
|
+
return h2(ProsemirrorAdapterProvider, null, () => {
|
111
|
+
var _a;
|
112
|
+
return [
|
113
|
+
h2(VueViewsConsumer),
|
114
|
+
(_a = slots.default) == null ? void 0 : _a.call(slots)
|
115
|
+
];
|
116
|
+
});
|
117
|
+
};
|
118
|
+
},
|
105
119
|
{ props: ["editor"] }
|
106
120
|
);
|
107
121
|
|
108
122
|
// src/hooks/use-doc-change.ts
|
109
123
|
import { defineDocChangeHandler } from "@prosekit/core";
|
110
124
|
function useDocChange(handler, options) {
|
111
|
-
|
125
|
+
const extension = defineDocChangeHandler((view) => handler(view.state.doc));
|
112
126
|
return useExtension(extension, options);
|
113
127
|
}
|
114
128
|
|
@@ -127,33 +141,40 @@ import {
|
|
127
141
|
} from "vue";
|
128
142
|
function useEditor(options) {
|
129
143
|
var _a;
|
130
|
-
|
131
|
-
|
144
|
+
const update = (_a = options == null ? void 0 : options.update) != null ? _a : false;
|
145
|
+
const editor = useEditorContext();
|
146
|
+
if (!editor) {
|
132
147
|
throw new ProseKitError(
|
133
148
|
"useEditor must be used within the ProseKit component"
|
134
149
|
);
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
150
|
+
}
|
151
|
+
const editorRef = shallowRef(editor);
|
152
|
+
if (update) {
|
153
|
+
onMounted(() => {
|
154
|
+
const forceUpdate = () => triggerRef(editorRef);
|
155
|
+
const extension = union([
|
156
|
+
defineMountHandler(forceUpdate),
|
157
|
+
defineUpdateHandler(forceUpdate)
|
158
|
+
]);
|
159
|
+
const dispose = editor.use(extension);
|
160
|
+
onUnmounted(dispose);
|
161
|
+
});
|
162
|
+
}
|
163
|
+
return editorRef;
|
143
164
|
}
|
144
165
|
|
145
166
|
// src/hooks/use-keymap.ts
|
146
167
|
import { defineKeymap } from "@prosekit/core";
|
147
168
|
import { computed as computed3, toValue as toValue3 } from "vue";
|
148
169
|
function useKeymap(keymap, options) {
|
149
|
-
|
170
|
+
const extension = computed3(() => defineKeymap(toValue3(keymap)));
|
150
171
|
return useExtension(extension, options);
|
151
172
|
}
|
152
173
|
|
153
174
|
// src/hooks/use-state-update.ts
|
154
175
|
import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
|
155
176
|
function useStateUpdate(handler, options) {
|
156
|
-
|
177
|
+
const extension = defineUpdateHandler2((view) => handler(view.state));
|
157
178
|
return useExtension(extension, options);
|
158
179
|
}
|
159
180
|
export {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/vue",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.3.
|
4
|
+
"version": "0.3.14",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -66,9 +66,9 @@
|
|
66
66
|
],
|
67
67
|
"dependencies": {
|
68
68
|
"@prosemirror-adapter/vue": "^0.2.6",
|
69
|
-
"@prosekit/
|
70
|
-
"@prosekit/
|
71
|
-
"@prosekit/web": "^0.3.
|
69
|
+
"@prosekit/core": "^0.7.3",
|
70
|
+
"@prosekit/pm": "^0.1.6",
|
71
|
+
"@prosekit/web": "^0.3.3"
|
72
72
|
},
|
73
73
|
"peerDependencies": {
|
74
74
|
"vue": ">= 3.0.0"
|
package/dist/chunk-DJHAZPRE.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
useEditorContext
|
3
|
-
} from "./chunk-KCTUNTM2.js";
|
4
|
-
|
5
|
-
// src/components/create-component.ts
|
6
|
-
import {
|
7
|
-
defineComponent,
|
8
|
-
h
|
9
|
-
} from "vue";
|
10
|
-
function createComponent(tagName, displayName, defaultProps) {
|
11
|
-
let propertyNames = Object.keys(defaultProps), hasEditor = Object.hasOwn(defaultProps, "editor");
|
12
|
-
return defineComponent(
|
13
|
-
(props, { slots }) => {
|
14
|
-
let editor = useEditorContext();
|
15
|
-
return () => {
|
16
|
-
var _a;
|
17
|
-
let p = {};
|
18
|
-
for (let [key, value] of Object.entries(props))
|
19
|
-
value !== void 0 && (p[propertyNames.includes(key) ? "." + key : key] = value);
|
20
|
-
return hasEditor && editor && !p.editor && (p.editor = editor), h(tagName, p, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
21
|
-
};
|
22
|
-
},
|
23
|
-
{
|
24
|
-
props: propertyNames,
|
25
|
-
name: displayName
|
26
|
-
}
|
27
|
-
);
|
28
|
-
}
|
29
|
-
|
30
|
-
export {
|
31
|
-
createComponent
|
32
|
-
};
|