@pixelvault-dev/paste-react 0.1.0

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) 2026 PixelVault
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
@@ -0,0 +1,24 @@
1
+ # @pixelvault-dev/paste-react
2
+
3
+ React binding for [`@pixelvault-dev/paste`](../paste). A `usePaste` hook that adds
4
+ paste-and-host (paste/drop an image → hosted CDN URL) to a textarea or input.
5
+
6
+ ```tsx
7
+ import { useRef } from "react";
8
+ import { usePaste } from "@pixelvault-dev/paste-react";
9
+
10
+ function Editor() {
11
+ const ref = useRef<HTMLTextAreaElement>(null);
12
+ usePaste(ref, { publishableKey: "pv_pub_xxxxxxxx" });
13
+ return <textarea ref={ref} />;
14
+ }
15
+ ```
16
+
17
+ `usePaste(ref, options)` attaches on mount and detaches on unmount. It
18
+ re-attaches if any option changes, so memoize callback options (`useCallback`)
19
+ to avoid needless re-attaching.
20
+
21
+ See [`@pixelvault-dev/paste`](../paste) for the full `PasteOptions` reference. Get a
22
+ publishable key (`pv_pub_…`) in the PixelVault dashboard.
23
+
24
+ `react >= 17` is a peer dependency.
@@ -0,0 +1,18 @@
1
+ import type { RefObject } from "react";
2
+ import { type PasteOptions, type PasteTarget } from "@pixelvault-dev/paste";
3
+ /**
4
+ * Add paste-and-host behavior to a textarea/input for the lifetime of the
5
+ * component. Pass a ref to the field and your publishable-key options.
6
+ *
7
+ * ```tsx
8
+ * const ref = useRef<HTMLTextAreaElement>(null);
9
+ * usePaste(ref, { publishableKey: "pv_pub_…" });
10
+ * return <textarea ref={ref} />;
11
+ * ```
12
+ *
13
+ * The listeners are re-attached if any option changes, so memoize callback
14
+ * options (useCallback) to avoid needless re-attaching.
15
+ */
16
+ export declare function usePaste(ref: RefObject<PasteTarget | null>, options: PasteOptions): void;
17
+ export { PixelVaultPasteError } from "@pixelvault-dev/paste";
18
+ export type { PasteOptions, PasteTarget, UploadResult } from "@pixelvault-dev/paste";
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { useEffect } from "react";
2
+ import { attachPaste } from "@pixelvault-dev/paste";
3
+ /**
4
+ * Add paste-and-host behavior to a textarea/input for the lifetime of the
5
+ * component. Pass a ref to the field and your publishable-key options.
6
+ *
7
+ * ```tsx
8
+ * const ref = useRef<HTMLTextAreaElement>(null);
9
+ * usePaste(ref, { publishableKey: "pv_pub_…" });
10
+ * return <textarea ref={ref} />;
11
+ * ```
12
+ *
13
+ * The listeners are re-attached if any option changes, so memoize callback
14
+ * options (useCallback) to avoid needless re-attaching.
15
+ */
16
+ export function usePaste(ref, options) {
17
+ const { publishableKey, endpoint, folder, render, onUploadStart, onUploadComplete, onError, } = options;
18
+ useEffect(() => {
19
+ const el = ref.current;
20
+ if (!el)
21
+ return;
22
+ return attachPaste(el, {
23
+ publishableKey,
24
+ endpoint,
25
+ folder,
26
+ render,
27
+ onUploadStart,
28
+ onUploadComplete,
29
+ onError,
30
+ });
31
+ }, [ref, publishableKey, endpoint, folder, render, onUploadStart, onUploadComplete, onError]);
32
+ }
33
+ export { PixelVaultPasteError } from "@pixelvault-dev/paste";
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@pixelvault-dev/paste-react",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "React binding for @pixelvault-dev/paste — a usePaste hook that adds paste-and-host to a textarea/input ref.",
7
+ "keywords": [
8
+ "image",
9
+ "upload",
10
+ "paste",
11
+ "react",
12
+ "hook",
13
+ "cdn",
14
+ "pixelvault"
15
+ ],
16
+ "homepage": "https://pixelvault.dev/docs#paste",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/pixelvault-dev/pixelvault.git",
20
+ "directory": "packages/paste-react"
21
+ },
22
+ "sideEffects": false,
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "scripts": {
41
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
42
+ "build": "npm run clean && tsc",
43
+ "typecheck": "tsc --noEmit",
44
+ "prepack": "npm run build"
45
+ },
46
+ "dependencies": {
47
+ "@pixelvault-dev/paste": "^0.1.0"
48
+ },
49
+ "peerDependencies": {
50
+ "react": ">=17"
51
+ },
52
+ "devDependencies": {
53
+ "@types/react": "^18.3.12",
54
+ "react": "^18.3.1",
55
+ "typescript": "^5.7.3"
56
+ }
57
+ }