@pixelvault-dev/paste-vue 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 +21 -0
- package/README.md +39 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +60 -0
- package/package.json +57 -0
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,39 @@
|
|
|
1
|
+
# @pixelvault-dev/paste-vue
|
|
2
|
+
|
|
3
|
+
Vue 3 binding for [`@pixelvault-dev/paste`](../paste). Adds paste-and-host
|
|
4
|
+
(paste/drop an image → hosted CDN URL) to a textarea or input, as either a
|
|
5
|
+
composable or a directive.
|
|
6
|
+
|
|
7
|
+
## Composable
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { ref } from "vue";
|
|
12
|
+
import { usePaste } from "@pixelvault-dev/paste-vue";
|
|
13
|
+
|
|
14
|
+
const field = ref<HTMLTextAreaElement | null>(null);
|
|
15
|
+
usePaste(field, { publishableKey: "pv_pub_xxxxxxxx" });
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<textarea ref="field" />
|
|
20
|
+
</template>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Directive
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { vPaste } from "@pixelvault-dev/paste-vue";
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<textarea v-paste="{ publishableKey: 'pv_pub_xxxxxxxx' }" />
|
|
32
|
+
</template>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Both attach on mount, re-attach if the element/options change, and detach on
|
|
36
|
+
unmount. See [`@pixelvault-dev/paste`](../paste) for the full `PasteOptions`
|
|
37
|
+
reference. Get a publishable key (`pv_pub_…`) in the PixelVault dashboard.
|
|
38
|
+
|
|
39
|
+
`vue >= 3` is a peer dependency.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Ref, type Directive } from "vue";
|
|
2
|
+
import { type PasteOptions, type PasteTarget } from "@pixelvault-dev/paste";
|
|
3
|
+
/**
|
|
4
|
+
* Add paste-and-host behavior to a textarea/input referenced by a template ref,
|
|
5
|
+
* for the lifetime of the component. Re-attaches if the element changes.
|
|
6
|
+
*
|
|
7
|
+
* ```vue
|
|
8
|
+
* <script setup lang="ts">
|
|
9
|
+
* import { ref } from "vue";
|
|
10
|
+
* import { usePaste } from "@pixelvault-dev/paste-vue";
|
|
11
|
+
* const field = ref<HTMLTextAreaElement | null>(null);
|
|
12
|
+
* usePaste(field, { publishableKey: "pv_pub_…" });
|
|
13
|
+
* </script>
|
|
14
|
+
* <template><textarea ref="field" /></template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function usePaste(target: Ref<PasteTarget | null | undefined>, options: PasteOptions): void;
|
|
18
|
+
/**
|
|
19
|
+
* Directive form: `<textarea v-paste="{ publishableKey: 'pv_pub_…' }" />`.
|
|
20
|
+
* Re-attaches when the bound options change.
|
|
21
|
+
*/
|
|
22
|
+
export declare const vPaste: Directive<HTMLElement, PasteOptions>;
|
|
23
|
+
export { PixelVaultPasteError } from "@pixelvault-dev/paste";
|
|
24
|
+
export type { PasteOptions, PasteTarget, UploadResult } from "@pixelvault-dev/paste";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { onMounted, onBeforeUnmount, watch } from "vue";
|
|
2
|
+
import { attachPaste } from "@pixelvault-dev/paste";
|
|
3
|
+
/**
|
|
4
|
+
* Add paste-and-host behavior to a textarea/input referenced by a template ref,
|
|
5
|
+
* for the lifetime of the component. Re-attaches if the element changes.
|
|
6
|
+
*
|
|
7
|
+
* ```vue
|
|
8
|
+
* <script setup lang="ts">
|
|
9
|
+
* import { ref } from "vue";
|
|
10
|
+
* import { usePaste } from "@pixelvault-dev/paste-vue";
|
|
11
|
+
* const field = ref<HTMLTextAreaElement | null>(null);
|
|
12
|
+
* usePaste(field, { publishableKey: "pv_pub_…" });
|
|
13
|
+
* </script>
|
|
14
|
+
* <template><textarea ref="field" /></template>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function usePaste(target, options) {
|
|
18
|
+
let detach = null;
|
|
19
|
+
const stop = () => {
|
|
20
|
+
detach?.();
|
|
21
|
+
detach = null;
|
|
22
|
+
};
|
|
23
|
+
const start = () => {
|
|
24
|
+
stop();
|
|
25
|
+
const el = target.value;
|
|
26
|
+
if (el)
|
|
27
|
+
detach = attachPaste(el, options);
|
|
28
|
+
};
|
|
29
|
+
onMounted(start);
|
|
30
|
+
watch(target, start);
|
|
31
|
+
onBeforeUnmount(stop);
|
|
32
|
+
}
|
|
33
|
+
// Track each directive-bound element's detach fn without polluting the DOM node.
|
|
34
|
+
const detachers = new WeakMap();
|
|
35
|
+
function bind(el, options) {
|
|
36
|
+
if (el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement) {
|
|
37
|
+
detachers.set(el, attachPaste(el, options));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function unbind(el) {
|
|
41
|
+
detachers.get(el)?.();
|
|
42
|
+
detachers.delete(el);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Directive form: `<textarea v-paste="{ publishableKey: 'pv_pub_…' }" />`.
|
|
46
|
+
* Re-attaches when the bound options change.
|
|
47
|
+
*/
|
|
48
|
+
export const vPaste = {
|
|
49
|
+
mounted(el, binding) {
|
|
50
|
+
bind(el, binding.value);
|
|
51
|
+
},
|
|
52
|
+
updated(el, binding) {
|
|
53
|
+
unbind(el);
|
|
54
|
+
bind(el, binding.value);
|
|
55
|
+
},
|
|
56
|
+
unmounted(el) {
|
|
57
|
+
unbind(el);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export { PixelVaultPasteError } from "@pixelvault-dev/paste";
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pixelvault-dev/paste-vue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Vue 3 binding for @pixelvault-dev/paste — a usePaste composable and vPaste directive for paste-and-host.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"image",
|
|
9
|
+
"upload",
|
|
10
|
+
"paste",
|
|
11
|
+
"vue",
|
|
12
|
+
"composable",
|
|
13
|
+
"directive",
|
|
14
|
+
"cdn",
|
|
15
|
+
"pixelvault"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://pixelvault.dev/docs#paste",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/pixelvault-dev/pixelvault.git",
|
|
21
|
+
"directory": "packages/paste-vue"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
43
|
+
"build": "npm run clean && tsc",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"prepack": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@pixelvault-dev/paste": "^0.1.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"vue": ">=3"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"typescript": "^5.7.3",
|
|
55
|
+
"vue": "^3.5.13"
|
|
56
|
+
}
|
|
57
|
+
}
|