@prosekit/preact 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 +21 -0
- package/README.md +0 -0
- package/dist/prosekit-preact-components-autocomplete-empty.d.ts +10 -0
- package/dist/prosekit-preact-components-autocomplete-empty.js +9 -0
- package/dist/prosekit-preact-components-autocomplete-item.d.ts +10 -0
- package/dist/prosekit-preact-components-autocomplete-item.js +9 -0
- package/dist/prosekit-preact-components-autocomplete-list.d.ts +10 -0
- package/dist/prosekit-preact-components-autocomplete-list.js +9 -0
- package/dist/prosekit-preact-components-autocomplete-popover.d.ts +11 -0
- package/dist/prosekit-preact-components-autocomplete-popover.js +9 -0
- package/dist/prosekit-preact.d.ts +21 -0
- package/dist/prosekit-preact.js +48 -0
- package/package.json +100 -0
- package/src/index.ts +4 -0
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 { ComponentChildren, ComponentType } from 'preact';
|
3
|
+
|
4
|
+
type AutocompleteEmptyProps = {
|
5
|
+
class?: string;
|
6
|
+
children?: ComponentChildren;
|
7
|
+
} & AutocompleteEmptyProps$1;
|
8
|
+
declare const AutocompleteEmpty: ComponentType<AutocompleteEmptyProps>;
|
9
|
+
|
10
|
+
export { AutocompleteEmpty, AutocompleteEmptyProps };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { AutocompleteItemProps as AutocompleteItemProps$1 } from '@prosekit/lit/components/autocomplete-item';
|
2
|
+
import { ComponentChildren, ComponentType } from 'preact';
|
3
|
+
|
4
|
+
type AutocompleteItemProps = {
|
5
|
+
class?: string;
|
6
|
+
children?: ComponentChildren;
|
7
|
+
} & AutocompleteItemProps$1;
|
8
|
+
declare const AutocompleteItem: ComponentType<AutocompleteItemProps>;
|
9
|
+
|
10
|
+
export { AutocompleteItem, AutocompleteItemProps };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { AutocompleteListProps as AutocompleteListProps$1 } from '@prosekit/lit/components/autocomplete-list';
|
2
|
+
import { ComponentChildren, ComponentType } from 'preact';
|
3
|
+
|
4
|
+
type AutocompleteListProps = {
|
5
|
+
class?: string;
|
6
|
+
children?: ComponentChildren;
|
7
|
+
} & AutocompleteListProps$1;
|
8
|
+
declare const AutocompleteList: ComponentType<AutocompleteListProps>;
|
9
|
+
|
10
|
+
export { AutocompleteList, AutocompleteListProps };
|
@@ -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 { ComponentChildren, ComponentType } from 'preact';
|
4
|
+
|
5
|
+
type AutocompletePopoverProps = {
|
6
|
+
class?: string;
|
7
|
+
children?: ComponentChildren;
|
8
|
+
} & AutocompletePopoverProps$1;
|
9
|
+
declare const AutocompletePopover: ComponentType<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 "preact";
|
4
|
+
var AutocompletePopover = (props) => {
|
5
|
+
return h("prosekit-autocomplete-popover", props);
|
6
|
+
};
|
7
|
+
export {
|
8
|
+
AutocompletePopover
|
9
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Editor, Extension, Keymap } from '@prosekit/core';
|
2
|
+
import { ComponentChildren, ComponentType } from 'preact';
|
3
|
+
|
4
|
+
interface ProseKitProps {
|
5
|
+
editor: Editor;
|
6
|
+
children?: ComponentChildren;
|
7
|
+
}
|
8
|
+
declare const ProseKit: ComponentType<ProseKitProps>;
|
9
|
+
|
10
|
+
declare function useEditor<E extends Extension = any>(): Editor<E>;
|
11
|
+
|
12
|
+
interface UseExtensionProps<T extends Extension = Extension> {
|
13
|
+
extension: T;
|
14
|
+
}
|
15
|
+
declare function useExtension({ extension }: UseExtensionProps): void;
|
16
|
+
|
17
|
+
declare function useKeymap({ keymap }: {
|
18
|
+
keymap: Keymap;
|
19
|
+
}): void;
|
20
|
+
|
21
|
+
export { ProseKit, ProseKitProps, useEditor, useExtension, useKeymap };
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// src/components/prosekit.ts
|
2
|
+
import { h } from "preact";
|
3
|
+
|
4
|
+
// src/contexts/editor-context.ts
|
5
|
+
import { createContext } from "preact";
|
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 "preact/hooks";
|
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 { useEffect } from "preact/hooks";
|
31
|
+
function useExtension({ extension }) {
|
32
|
+
const editor = useEditor();
|
33
|
+
useEffect(() => editor.use(extension), [editor, extension]);
|
34
|
+
}
|
35
|
+
|
36
|
+
// src/hooks/use-keymap.ts
|
37
|
+
import { addKeymap } from "@prosekit/core";
|
38
|
+
import { useMemo } from "preact/hooks";
|
39
|
+
function useKeymap({ keymap }) {
|
40
|
+
const extension = useMemo(() => addKeymap(keymap), [keymap]);
|
41
|
+
useExtension({ extension });
|
42
|
+
}
|
43
|
+
export {
|
44
|
+
ProseKit,
|
45
|
+
useEditor,
|
46
|
+
useExtension,
|
47
|
+
useKeymap
|
48
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
{
|
2
|
+
"name": "@prosekit/preact",
|
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/preact"
|
17
|
+
},
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/ocavue/prosekit/issues"
|
20
|
+
},
|
21
|
+
"keywords": [
|
22
|
+
"ProseMirror"
|
23
|
+
],
|
24
|
+
"sideEffects": false,
|
25
|
+
"main": "./dist/prosekit-preact.js",
|
26
|
+
"module": "./dist/prosekit-preact.js",
|
27
|
+
"exports": {
|
28
|
+
".": {
|
29
|
+
"types": "./dist/prosekit-preact.d.ts",
|
30
|
+
"import": "./dist/prosekit-preact.js",
|
31
|
+
"default": "./dist/prosekit-preact.js"
|
32
|
+
},
|
33
|
+
"./components/autocomplete-empty": {
|
34
|
+
"types": "./dist/prosekit-preact-components-autocomplete-empty.d.ts",
|
35
|
+
"import": "./dist/prosekit-preact-components-autocomplete-empty.js",
|
36
|
+
"default": "./dist/prosekit-preact-components-autocomplete-empty.js"
|
37
|
+
},
|
38
|
+
"./components/autocomplete-item": {
|
39
|
+
"types": "./dist/prosekit-preact-components-autocomplete-item.d.ts",
|
40
|
+
"import": "./dist/prosekit-preact-components-autocomplete-item.js",
|
41
|
+
"default": "./dist/prosekit-preact-components-autocomplete-item.js"
|
42
|
+
},
|
43
|
+
"./components/autocomplete-list": {
|
44
|
+
"types": "./dist/prosekit-preact-components-autocomplete-list.d.ts",
|
45
|
+
"import": "./dist/prosekit-preact-components-autocomplete-list.js",
|
46
|
+
"default": "./dist/prosekit-preact-components-autocomplete-list.js"
|
47
|
+
},
|
48
|
+
"./components/autocomplete-popover": {
|
49
|
+
"types": "./dist/prosekit-preact-components-autocomplete-popover.d.ts",
|
50
|
+
"import": "./dist/prosekit-preact-components-autocomplete-popover.js",
|
51
|
+
"default": "./dist/prosekit-preact-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
|
+
"preact": ">= 9.0.0"
|
63
|
+
},
|
64
|
+
"peerDependenciesMeta": {
|
65
|
+
"preact": {
|
66
|
+
"optional": true
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"devDependencies": {
|
70
|
+
"@prosekit/dev": "*",
|
71
|
+
"preact": "^10.16.0",
|
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-preact.d.ts",
|
81
|
+
"typesVersions": {
|
82
|
+
"*": {
|
83
|
+
".": [
|
84
|
+
"./dist/prosekit-preact.d.ts"
|
85
|
+
],
|
86
|
+
"components/autocomplete-empty": [
|
87
|
+
"./dist/prosekit-preact-components-autocomplete-empty.d.ts"
|
88
|
+
],
|
89
|
+
"components/autocomplete-item": [
|
90
|
+
"./dist/prosekit-preact-components-autocomplete-item.d.ts"
|
91
|
+
],
|
92
|
+
"components/autocomplete-list": [
|
93
|
+
"./dist/prosekit-preact-components-autocomplete-list.d.ts"
|
94
|
+
],
|
95
|
+
"components/autocomplete-popover": [
|
96
|
+
"./dist/prosekit-preact-components-autocomplete-popover.d.ts"
|
97
|
+
]
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
package/src/index.ts
ADDED