@prosekit/solid 0.3.3 → 0.3.5
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-PH5CYJHM.js +20 -0
- package/dist/prosekit-solid-autocomplete.js +1 -1
- package/dist/prosekit-solid-block-handle.js +1 -1
- package/dist/prosekit-solid-inline-popover.js +1 -1
- package/dist/prosekit-solid-popover.js +1 -1
- package/dist/prosekit-solid-resizable.js +1 -1
- package/dist/prosekit-solid-tooltip.js +1 -1
- package/dist/prosekit-solid.js +24 -37
- package/package.json +7 -7
- package/dist/chunk-Z3TWLQOI.js +0 -26
@@ -0,0 +1,20 @@
|
|
1
|
+
import {
|
2
|
+
useEditorContext
|
3
|
+
} from "./chunk-XXXIBXNC.js";
|
4
|
+
|
5
|
+
// src/components/create-component.ts
|
6
|
+
import h from "solid-js/h";
|
7
|
+
function createComponent(tagName, defaultProps) {
|
8
|
+
let propertyNames = Object.keys(defaultProps), hasEditor = Object.hasOwn(defaultProps, "editor");
|
9
|
+
return (props) => {
|
10
|
+
let p = {};
|
11
|
+
for (let key of Object.keys(props))
|
12
|
+
p[propertyNames.includes(key) ? "prop:" + key : key] = () => props[key];
|
13
|
+
let editor = useEditorContext();
|
14
|
+
return hasEditor && editor && (p["prop:editor"] = () => props.editor || editor), h(tagName, p);
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
export {
|
19
|
+
createComponent
|
20
|
+
};
|
package/dist/prosekit-solid.js
CHANGED
@@ -5,16 +5,14 @@ import {
|
|
5
5
|
|
6
6
|
// src/components/prosekit.ts
|
7
7
|
import { createComponent } from "solid-js";
|
8
|
-
var ProseKit = (props) => {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
});
|
17
|
-
};
|
8
|
+
var ProseKit = (props) => createComponent(EditorContextProvider, {
|
9
|
+
get value() {
|
10
|
+
return props.editor;
|
11
|
+
},
|
12
|
+
get children() {
|
13
|
+
return props.children;
|
14
|
+
}
|
15
|
+
});
|
18
16
|
|
19
17
|
// src/hooks/use-editor.ts
|
20
18
|
import {
|
@@ -26,30 +24,24 @@ import {
|
|
26
24
|
import { createEffect, createSignal } from "solid-js";
|
27
25
|
function useEditor(options) {
|
28
26
|
var _a;
|
29
|
-
|
30
|
-
|
31
|
-
if (!editor) {
|
27
|
+
let update = (_a = options == null ? void 0 : options.update) != null ? _a : !1, editor = useEditorContext();
|
28
|
+
if (!editor)
|
32
29
|
throw new ProseKitError(
|
33
30
|
"useEditor must be used within the ProseKit component"
|
34
31
|
);
|
35
|
-
|
36
|
-
|
37
|
-
createEffect(() => {
|
32
|
+
let [depend, forceUpdate] = useForceUpdate();
|
33
|
+
return createEffect(() => {
|
38
34
|
if (update) {
|
39
|
-
|
35
|
+
let extension = union([
|
40
36
|
defineMountHandler(forceUpdate),
|
41
37
|
defineUpdateHandler(forceUpdate)
|
42
38
|
]);
|
43
39
|
return editor.use(extension);
|
44
40
|
}
|
45
|
-
}, [editor, update, forceUpdate]);
|
46
|
-
return () => {
|
47
|
-
depend();
|
48
|
-
return editor;
|
49
|
-
};
|
41
|
+
}, [editor, update, forceUpdate]), () => (depend(), editor);
|
50
42
|
}
|
51
43
|
function useForceUpdate() {
|
52
|
-
return createSignal(void 0, { equals:
|
44
|
+
return createSignal(void 0, { equals: !1 });
|
53
45
|
}
|
54
46
|
|
55
47
|
// src/hooks/use-extension.ts
|
@@ -62,21 +54,17 @@ import { createEffect as createEffect2, onCleanup } from "solid-js";
|
|
62
54
|
|
63
55
|
// src/utils/to-value.ts
|
64
56
|
function toValue(v) {
|
65
|
-
return typeof v
|
57
|
+
return typeof v == "function" && v.length === 0 ? v() : v;
|
66
58
|
}
|
67
59
|
|
68
60
|
// src/hooks/use-editor-extension.ts
|
69
61
|
function useEditorExtension(editorAccessor, extensionAccessor) {
|
70
|
-
|
62
|
+
let editorContext = useEditorContext();
|
71
63
|
createEffect2(() => {
|
72
|
-
|
73
|
-
|
74
|
-
if (!editor) {
|
64
|
+
let editor = toValue(editorAccessor) || toValue(editorContext), extension = extensionAccessor();
|
65
|
+
if (!editor)
|
75
66
|
throw new EditorNotFoundError();
|
76
|
-
|
77
|
-
if (extension) {
|
78
|
-
onCleanup(editor.use(extension));
|
79
|
-
}
|
67
|
+
extension && onCleanup(editor.use(extension));
|
80
68
|
});
|
81
69
|
}
|
82
70
|
|
@@ -84,7 +72,7 @@ function useEditorExtension(editorAccessor, extensionAccessor) {
|
|
84
72
|
import { withPriority } from "@prosekit/core";
|
85
73
|
function usePriorityExtension(extension, priority) {
|
86
74
|
return () => {
|
87
|
-
|
75
|
+
let ext = extension();
|
88
76
|
return ext && priority ? withPriority(ext, priority) : ext;
|
89
77
|
};
|
90
78
|
}
|
@@ -100,21 +88,20 @@ function useExtension(extension, options) {
|
|
100
88
|
// src/hooks/use-keymap.ts
|
101
89
|
import { defineKeymap } from "@prosekit/core";
|
102
90
|
function useKeymap(keymap, options) {
|
103
|
-
|
104
|
-
return useExtension(extension, options);
|
91
|
+
return useExtension(() => defineKeymap(keymap()), options);
|
105
92
|
}
|
106
93
|
|
107
94
|
// src/hooks/use-state-update.ts
|
108
95
|
import { defineUpdateHandler as defineUpdateHandler2 } from "@prosekit/core";
|
109
96
|
function useStateUpdate(handler, options) {
|
110
|
-
|
97
|
+
let extension = defineUpdateHandler2((view) => handler(view.state));
|
111
98
|
return useExtension(() => extension, options);
|
112
99
|
}
|
113
100
|
|
114
101
|
// src/hooks/use-doc-change.ts
|
115
102
|
import { defineDocChangeHandler } from "@prosekit/core";
|
116
103
|
function useDocChange(handler, options) {
|
117
|
-
|
104
|
+
let extension = defineDocChangeHandler((view) => handler(view.state.doc));
|
118
105
|
return useExtension(() => extension, options);
|
119
106
|
}
|
120
107
|
export {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prosekit/solid",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.3.
|
4
|
+
"version": "0.3.5",
|
5
5
|
"private": false,
|
6
6
|
"author": {
|
7
7
|
"name": "ocavue",
|
@@ -65,9 +65,9 @@
|
|
65
65
|
"dist"
|
66
66
|
],
|
67
67
|
"dependencies": {
|
68
|
-
"@prosekit/core": "^0.5.
|
69
|
-
"@prosekit/
|
70
|
-
"@prosekit/
|
68
|
+
"@prosekit/core": "^0.5.5",
|
69
|
+
"@prosekit/web": "^0.1.10",
|
70
|
+
"@prosekit/pm": "^0.1.5"
|
71
71
|
},
|
72
72
|
"peerDependencies": {
|
73
73
|
"solid-js": ">= 1.7.0"
|
@@ -78,11 +78,11 @@
|
|
78
78
|
}
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
|
-
"@prosekit/dev": "*",
|
82
81
|
"solid-js": "^1.8.17",
|
83
|
-
"tsup": "^8.0
|
82
|
+
"tsup": "^8.1.0",
|
84
83
|
"typescript": "^5.4.5",
|
85
|
-
"vitest": "^1.6.0"
|
84
|
+
"vitest": "^1.6.0",
|
85
|
+
"@prosekit/dev": "0.0.0"
|
86
86
|
},
|
87
87
|
"scripts": {
|
88
88
|
"build:tsup": "tsup",
|
package/dist/chunk-Z3TWLQOI.js
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
useEditorContext
|
3
|
-
} from "./chunk-XXXIBXNC.js";
|
4
|
-
|
5
|
-
// src/components/create-component.ts
|
6
|
-
import h from "solid-js/h";
|
7
|
-
function createComponent(tagName, defaultProps) {
|
8
|
-
const propertyNames = Object.keys(defaultProps);
|
9
|
-
const hasEditor = Object.hasOwn(defaultProps, "editor");
|
10
|
-
const Component = (props) => {
|
11
|
-
const p = {};
|
12
|
-
for (const key of Object.keys(props)) {
|
13
|
-
p[propertyNames.includes(key) ? "prop:" + key : key] = () => props[key];
|
14
|
-
}
|
15
|
-
const editor = useEditorContext();
|
16
|
-
if (hasEditor && editor) {
|
17
|
-
p["prop:editor"] = () => props["editor"] || editor;
|
18
|
-
}
|
19
|
-
return h(tagName, p);
|
20
|
-
};
|
21
|
-
return Component;
|
22
|
-
}
|
23
|
-
|
24
|
-
export {
|
25
|
-
createComponent
|
26
|
-
};
|