@prosekit/solid 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 ocavue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
@@ -0,0 +1,10 @@
1
+ import { AutocompleteEmptyProps as AutocompleteEmptyProps$1 } from '@prosekit/lit/components/autocomplete-empty';
2
+ import { JSXElement, Component } from 'solid-js';
3
+
4
+ type AutocompleteEmptyProps = {
5
+ class?: string;
6
+ children?: JSXElement;
7
+ } & AutocompleteEmptyProps$1;
8
+ declare const AutocompleteEmpty: Component<AutocompleteEmptyProps>;
9
+
10
+ export { AutocompleteEmpty, AutocompleteEmptyProps };
@@ -0,0 +1,9 @@
1
+ // src/components/autocomplete-empty.gen.ts
2
+ import "@prosekit/lit/components/autocomplete-empty";
3
+ import h from "solid-js/h";
4
+ var AutocompleteEmpty = (props) => {
5
+ return h("prosekit-autocomplete-empty", props);
6
+ };
7
+ export {
8
+ AutocompleteEmpty
9
+ };
@@ -0,0 +1,10 @@
1
+ import { AutocompleteItemProps as AutocompleteItemProps$1 } from '@prosekit/lit/components/autocomplete-item';
2
+ import { JSXElement, Component } from 'solid-js';
3
+
4
+ type AutocompleteItemProps = {
5
+ class?: string;
6
+ children?: JSXElement;
7
+ } & AutocompleteItemProps$1;
8
+ declare const AutocompleteItem: Component<AutocompleteItemProps>;
9
+
10
+ export { AutocompleteItem, AutocompleteItemProps };
@@ -0,0 +1,9 @@
1
+ // src/components/autocomplete-item.gen.ts
2
+ import "@prosekit/lit/components/autocomplete-item";
3
+ import h from "solid-js/h";
4
+ var AutocompleteItem = (props) => {
5
+ return h("prosekit-autocomplete-item", props);
6
+ };
7
+ export {
8
+ AutocompleteItem
9
+ };
@@ -0,0 +1,10 @@
1
+ import { AutocompleteListProps as AutocompleteListProps$1 } from '@prosekit/lit/components/autocomplete-list';
2
+ import { JSXElement, Component } from 'solid-js';
3
+
4
+ type AutocompleteListProps = {
5
+ class?: string;
6
+ children?: JSXElement;
7
+ } & AutocompleteListProps$1;
8
+ declare const AutocompleteList: Component<AutocompleteListProps>;
9
+
10
+ export { AutocompleteList, AutocompleteListProps };
@@ -0,0 +1,9 @@
1
+ // src/components/autocomplete-list.gen.ts
2
+ import "@prosekit/lit/components/autocomplete-list";
3
+ import h from "solid-js/h";
4
+ var AutocompleteList = (props) => {
5
+ return h("prosekit-autocomplete-list", props);
6
+ };
7
+ export {
8
+ AutocompleteList
9
+ };
@@ -0,0 +1,11 @@
1
+ import { AutocompletePopoverProps as AutocompletePopoverProps$1 } from '@prosekit/lit/components/autocomplete-popover';
2
+ export { PopoverOptions } from '@prosekit/lit/components/autocomplete-popover';
3
+ import { JSXElement, Component } from 'solid-js';
4
+
5
+ type AutocompletePopoverProps = {
6
+ class?: string;
7
+ children?: JSXElement;
8
+ } & AutocompletePopoverProps$1;
9
+ declare const AutocompletePopover: Component<AutocompletePopoverProps>;
10
+
11
+ export { AutocompletePopover, AutocompletePopoverProps };
@@ -0,0 +1,9 @@
1
+ // src/components/autocomplete-popover.gen.ts
2
+ import "@prosekit/lit/components/autocomplete-popover";
3
+ import h from "solid-js/h";
4
+ var AutocompletePopover = (props) => {
5
+ return h("prosekit-autocomplete-popover", props);
6
+ };
7
+ export {
8
+ AutocompletePopover
9
+ };
@@ -0,0 +1,20 @@
1
+ import { Editor, Extension, Keymap } from '@prosekit/core';
2
+ import { ParentProps, Component } from 'solid-js';
3
+
4
+ type ProseKitProps = ParentProps<{
5
+ editor: Editor;
6
+ }>;
7
+ declare const ProseKit: Component<ProseKitProps>;
8
+
9
+ declare function useEditor<E extends Extension = any>(): Editor<E>;
10
+
11
+ interface UseExtensionProps<T extends Extension = Extension> {
12
+ extension: T;
13
+ }
14
+ declare function useExtension({ extension }: UseExtensionProps): void;
15
+
16
+ declare function useKeymap({ keymap }: {
17
+ keymap: Keymap;
18
+ }): void;
19
+
20
+ export { ProseKit, ProseKitProps, useEditor, useExtension, useKeymap };
@@ -0,0 +1,50 @@
1
+ // src/components/prosekit.ts
2
+ import h from "solid-js/h";
3
+
4
+ // src/contexts/editor-context.ts
5
+ import { createContext } from "solid-js";
6
+ var editorContext = createContext(null);
7
+
8
+ // src/components/prosekit.ts
9
+ var ProseKit = (props) => {
10
+ const { editor, children } = props;
11
+ return h(EditorContextProvider, { value: { editor } }, children);
12
+ };
13
+ var EditorContextProvider = editorContext.Provider;
14
+
15
+ // src/hooks/use-editor.ts
16
+ import { ProseKitError } from "@prosekit/core";
17
+ import { useContext } from "solid-js";
18
+ function useEditor() {
19
+ const value = useContext(editorContext);
20
+ if (!value) {
21
+ throw new ProseKitError(
22
+ "useEditor must be used within the ProseKit component"
23
+ );
24
+ }
25
+ return value.editor;
26
+ }
27
+
28
+ // src/hooks/use-extension.ts
29
+ import "@prosekit/core";
30
+ import { onCleanup, onMount } from "solid-js";
31
+ function useExtension({ extension }) {
32
+ const editor = useEditor();
33
+ onMount(() => {
34
+ const cleanup = editor.use(extension);
35
+ onCleanup(cleanup);
36
+ });
37
+ }
38
+
39
+ // src/hooks/use-keymap.ts
40
+ import { addKeymap } from "@prosekit/core";
41
+ function useKeymap({ keymap }) {
42
+ const extension = addKeymap(keymap);
43
+ useExtension({ extension });
44
+ }
45
+ export {
46
+ ProseKit,
47
+ useEditor,
48
+ useExtension,
49
+ useKeymap
50
+ };
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@prosekit/solid",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "private": false,
6
+ "author": {
7
+ "name": "ocavue",
8
+ "email": "ocavue@gmail.com"
9
+ },
10
+ "license": "MIT",
11
+ "funding": "https://github.com/sponsors/ocavue",
12
+ "homepage": "https://github.com/ocavue/prosekit#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/ocavue/prosekit.git",
16
+ "directory": "packages/solid"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/ocavue/prosekit/issues"
20
+ },
21
+ "keywords": [
22
+ "ProseMirror"
23
+ ],
24
+ "sideEffects": false,
25
+ "main": "./dist/prosekit-solid.js",
26
+ "module": "./dist/prosekit-solid.js",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/prosekit-solid.d.ts",
30
+ "import": "./dist/prosekit-solid.js",
31
+ "default": "./dist/prosekit-solid.js"
32
+ },
33
+ "./components/autocomplete-empty": {
34
+ "types": "./dist/prosekit-solid-components-autocomplete-empty.d.ts",
35
+ "import": "./dist/prosekit-solid-components-autocomplete-empty.js",
36
+ "default": "./dist/prosekit-solid-components-autocomplete-empty.js"
37
+ },
38
+ "./components/autocomplete-item": {
39
+ "types": "./dist/prosekit-solid-components-autocomplete-item.d.ts",
40
+ "import": "./dist/prosekit-solid-components-autocomplete-item.js",
41
+ "default": "./dist/prosekit-solid-components-autocomplete-item.js"
42
+ },
43
+ "./components/autocomplete-list": {
44
+ "types": "./dist/prosekit-solid-components-autocomplete-list.d.ts",
45
+ "import": "./dist/prosekit-solid-components-autocomplete-list.js",
46
+ "default": "./dist/prosekit-solid-components-autocomplete-list.js"
47
+ },
48
+ "./components/autocomplete-popover": {
49
+ "types": "./dist/prosekit-solid-components-autocomplete-popover.d.ts",
50
+ "import": "./dist/prosekit-solid-components-autocomplete-popover.js",
51
+ "default": "./dist/prosekit-solid-components-autocomplete-popover.js"
52
+ }
53
+ },
54
+ "files": [
55
+ "dist"
56
+ ],
57
+ "dependencies": {
58
+ "@prosekit/core": "^0.0.3",
59
+ "@prosekit/lit": "^0.0.4"
60
+ },
61
+ "peerDependencies": {
62
+ "solid-js": ">= 1.7.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "solid-js": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "devDependencies": {
70
+ "@prosekit/dev": "*",
71
+ "solid-js": "^1.7.8",
72
+ "tsup": "^7.1.0",
73
+ "typescript": "^5.1.6",
74
+ "vitest": "^0.33.0"
75
+ },
76
+ "scripts": {
77
+ "build:tsup": "tsup",
78
+ "build:tsc": "tsc -b tsconfig.json"
79
+ },
80
+ "types": "./dist/prosekit-solid.d.ts",
81
+ "typesVersions": {
82
+ "*": {
83
+ ".": [
84
+ "./dist/prosekit-solid.d.ts"
85
+ ],
86
+ "components/autocomplete-empty": [
87
+ "./dist/prosekit-solid-components-autocomplete-empty.d.ts"
88
+ ],
89
+ "components/autocomplete-item": [
90
+ "./dist/prosekit-solid-components-autocomplete-item.d.ts"
91
+ ],
92
+ "components/autocomplete-list": [
93
+ "./dist/prosekit-solid-components-autocomplete-list.d.ts"
94
+ ],
95
+ "components/autocomplete-popover": [
96
+ "./dist/prosekit-solid-components-autocomplete-popover.d.ts"
97
+ ]
98
+ }
99
+ }
100
+ }
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { ProseKit, type ProseKitProps } from './components/prosekit'
2
+ export { useEditor } from './hooks/use-editor'
3
+ export { useExtension } from './hooks/use-extension'
4
+ export { useKeymap } from './hooks/use-keymap'