@prosekit/vue 0.3.11 → 0.3.13

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.
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-DJHAZPRE.js";
3
+ } from "./chunk-7DYF3H5Q.js";
4
4
  import "./chunk-KCTUNTM2.js";
5
5
 
6
6
  // src/components/autocomplete/autocomplete-empty.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-DJHAZPRE.js";
3
+ } from "./chunk-7DYF3H5Q.js";
4
4
  import "./chunk-KCTUNTM2.js";
5
5
 
6
6
  // src/components/block-handle/block-drag-handle.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-DJHAZPRE.js";
3
+ } from "./chunk-7DYF3H5Q.js";
4
4
  import "./chunk-KCTUNTM2.js";
5
5
 
6
6
  // src/components/inline-popover/inline-popover.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-DJHAZPRE.js";
3
+ } from "./chunk-7DYF3H5Q.js";
4
4
  import "./chunk-KCTUNTM2.js";
5
5
 
6
6
  // src/components/popover/popover-content.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-DJHAZPRE.js";
3
+ } from "./chunk-7DYF3H5Q.js";
4
4
  import "./chunk-KCTUNTM2.js";
5
5
 
6
6
  // src/components/resizable/resizable-handle.gen.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createComponent
3
- } from "./chunk-DJHAZPRE.js";
3
+ } from "./chunk-7DYF3H5Q.js";
4
4
  import "./chunk-KCTUNTM2.js";
5
5
 
6
6
  // src/components/tooltip/tooltip-content.gen.ts
@@ -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
- let editorContext = useEditorContext();
34
+ const editorContext = useEditorContext();
35
35
  watchPostEffect((onCleanup) => {
36
- let editor = toValue(editorRef) || toValue(editorContext), extension = toValue(extensionRef);
37
- if (!editor)
36
+ const editor = toValue(editorRef) || toValue(editorContext);
37
+ const extension = toValue(extensionRef);
38
+ if (!editor) {
38
39
  throw new EditorNotFoundError();
39
- extension && onCleanup(editor.use(extension));
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
- let ext = toValue2(extension);
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
- let props = useNodeViewContext();
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
- let nodeViewFactory = useNodeViewFactory(), extension = computed2(() => defineVueNodeViewFactory(nodeViewFactory));
75
- return useExtension(extension), () => null;
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
- let { name, component, ...userOptions } = options, args = {
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 }) => (provideEditor(props.editor), () => h2(ProsemirrorAdapterProvider, null, () => {
99
- var _a;
100
- return [
101
- h2(VueViewsConsumer),
102
- (_a = slots.default) == null ? void 0 : _a.call(slots)
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
- let extension = defineDocChangeHandler((view) => handler(view.state.doc));
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
- let update = (_a = options == null ? void 0 : options.update) != null ? _a : !1, editor = useEditorContext();
131
- if (!editor)
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
- let editorRef = shallowRef(editor);
136
- return update && onMounted(() => {
137
- let forceUpdate = () => triggerRef(editorRef), extension = union([
138
- defineMountHandler(forceUpdate),
139
- defineUpdateHandler(forceUpdate)
140
- ]), dispose = editor.use(extension);
141
- onUnmounted(dispose);
142
- }), editorRef;
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
- let extension = computed3(() => defineKeymap(toValue3(keymap)));
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
- let extension = defineUpdateHandler2((view) => handler(view.state));
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.11",
4
+ "version": "0.3.13",
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/core": "^0.7.1",
70
- "@prosekit/pm": "^0.1.5",
71
- "@prosekit/web": "^0.3.0"
69
+ "@prosekit/pm": "^0.1.6",
70
+ "@prosekit/core": "^0.7.3",
71
+ "@prosekit/web": "^0.3.2"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "vue": ">= 3.0.0"
@@ -82,7 +82,7 @@
82
82
  "@vue/test-utils": "^2.4.6",
83
83
  "tsup": "^8.1.0",
84
84
  "typescript": "^5.5.3",
85
- "vitest": "^2.0.0-beta.13",
85
+ "vitest": "^2.0.2",
86
86
  "vue": "^3.4.31",
87
87
  "@prosekit/dev": "0.0.0"
88
88
  },
@@ -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
- };