@pixelvault-dev/paste-react
v0.1.1
Published
React binding for @pixelvault-dev/paste — a usePaste hook that adds paste-and-host to a textarea/input ref.
Maintainers
Readme
@pixelvault-dev/paste-react
React binding for @pixelvault-dev/paste. A usePaste hook that adds
paste-and-host (paste/drop an image → hosted CDN URL) to a textarea or input.
import { useRef } from "react";
import { usePaste } from "@pixelvault-dev/paste-react";
function Editor() {
const ref = useRef<HTMLTextAreaElement>(null);
const { openFilePicker } = usePaste(ref, { publishableKey: "pv_pub_xxxxxxxx" });
return (
<>
<textarea ref={ref} />
<button onClick={openFilePicker}>Upload image</button>
</>
);
}usePaste(ref, options) attaches on mount and detaches on unmount. It
re-attaches if any option changes, so memoize callback options (useCallback)
to avoid needless re-attaching. It returns { openFilePicker } — call it (e.g.
from a button) to open the OS file dialog and insert the chosen image(s).
See @pixelvault-dev/paste for the full PasteOptions reference. Get a
publishable key (pv_pub_…) in the PixelVault dashboard.
react >= 17 is a peer dependency.
