@paperpic/vue 0.0.0-stage → 0.2.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 +40 -2
- package/dist/docs/examples/custom-toolbar.md +211 -0
- package/dist/docs/examples/fixed-proportions.md +120 -0
- package/dist/docs/examples/read-only.md +115 -0
- package/dist/docs/examples/upload.md +130 -0
- package/dist/docs/guide/accessibility.md +55 -0
- package/dist/docs/guide/editing.md +140 -0
- package/dist/docs/guide/getting-started.md +144 -0
- package/dist/docs/guide/introduction.md +36 -0
- package/dist/docs/guide/labels.md +120 -0
- package/dist/docs/guide/performance.md +39 -0
- package/dist/docs/guide/saving.md +186 -0
- package/dist/docs/guide/styling.md +266 -0
- package/dist/docs/guide/tools/adjust.md +41 -0
- package/dist/docs/guide/tools/clean-up.md +41 -0
- package/dist/docs/guide/tools/crop.md +39 -0
- package/dist/docs/guide/tools/rotate-and-flip.md +35 -0
- package/dist/docs/guide/tools/straighten.md +78 -0
- package/dist/docs/guide/viewer.md +81 -0
- package/dist/docs/reference/css-tokens.md +113 -0
- package/dist/docs/reference/events.md +68 -0
- package/dist/docs/reference/labels.md +70 -0
- package/dist/docs/reference/methods.md +228 -0
- package/dist/docs/reference/options.md +160 -0
- package/dist/docs/reference/react.md +84 -0
- package/dist/docs/reference/state.md +30 -0
- package/dist/docs/reference/types.md +301 -0
- package/dist/docs/reference/vue.md +78 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +68 -0
- package/dist/style.css +702 -0
- package/package.json +63 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ExportedImage, Fit, PaperPic, PaperPicDownload, PaperPicEvents, PaperPicIcons, PaperPicIcons as PaperPicIcons$1, PaperPicLabels, PaperPicLabels as PaperPicLabels$1, PaperPicOptions, PaperPicOutput, PaperPicOutput as PaperPicOutput$1, PaperPicSource, PaperPicSource as PaperPicSource$1, PaperPicState, Rotation, Size, ToolId, ToolId as ToolId$1, ViewPoint } from "@paperpic/core";
|
|
2
|
+
/** The viewer that the component exposes as `instance`, with the methods of `@paperpic/core`, such as `zoomIn()` or `reload()`. */
|
|
3
|
+
type PaperPicInstance = PaperPic;
|
|
4
|
+
/**
|
|
5
|
+
* The props of `PaperPic`, which fills its parent element. Give the parent a height, and import the stylesheet once,
|
|
6
|
+
* from `@paperpic/vue/style.css`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <script setup lang="ts">
|
|
10
|
+
* import { PaperPic } from '@paperpic/vue'
|
|
11
|
+
* import '@paperpic/vue/style.css'
|
|
12
|
+
* </script>
|
|
13
|
+
*
|
|
14
|
+
* <template>
|
|
15
|
+
* <div style="height: 480px">
|
|
16
|
+
* <PaperPic src="/receipt.jpg" alt="A receipt" @apply="({ blob }) => upload(blob)" />
|
|
17
|
+
* </div>
|
|
18
|
+
* </template>
|
|
19
|
+
*/
|
|
20
|
+
interface PaperPicProps {
|
|
21
|
+
/** Describes the image for screen readers. Without it, they skip the image, as they skip an `<img>` with an empty `alt`. */
|
|
22
|
+
alt?: string;
|
|
23
|
+
/** The real proportions of the document, as width divided by height, such as `210 / 297` for A4. Without it, straightening estimates them. */
|
|
24
|
+
aspectRatio?: number;
|
|
25
|
+
/** Whether the toolbar has a button that saves the image on display, which is the result of the last Apply or else the source. */
|
|
26
|
+
download?: boolean;
|
|
27
|
+
/** Whether the image can be edited. With `false` it is a read-only viewer, whose toolbar can also rotate the image. */
|
|
28
|
+
editable?: boolean;
|
|
29
|
+
/** The name of the saved file. By default, the name of the source. The extension follows the format of the image. */
|
|
30
|
+
filename?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Replaces any of the icons with the markup of one element, such as an `<svg>`. The markup is inserted as HTML, so
|
|
33
|
+
* pass only markup you trust. An empty string leaves the buttons of that icon without one.
|
|
34
|
+
*/
|
|
35
|
+
icons?: Partial<PaperPicIcons$1>;
|
|
36
|
+
/** Replaces any of the texts, which are in English by default. */
|
|
37
|
+
labels?: Partial<PaperPicLabels$1>;
|
|
38
|
+
/** The longest side of the edited image, in pixels. By default, it keeps the full resolution. */
|
|
39
|
+
maxOutputSize?: number;
|
|
40
|
+
/** The format of the edited image. By default, the format of the source. */
|
|
41
|
+
output?: PaperPicOutput$1;
|
|
42
|
+
/**
|
|
43
|
+
* From 0 to 1. How much gray cleaning up a document keeps, which makes letters easier to read. By default, 0.25.
|
|
44
|
+
* Use 0 for strict black and white, which gives smaller files but breaks thin strokes.
|
|
45
|
+
*/
|
|
46
|
+
softness?: number;
|
|
47
|
+
/** The image to show: a URL from the same origin, or a file attached on the client. */
|
|
48
|
+
src?: PaperPicSource$1;
|
|
49
|
+
/** Whether to show the built-in toolbar and edit bar. Without them, build your own with the methods of `instance`. */
|
|
50
|
+
toolbar?: boolean;
|
|
51
|
+
/** Which tools the edit bar offers. By default, all of them. */
|
|
52
|
+
tools?: readonly ToolId$1[];
|
|
53
|
+
/** Whether the wheel zooms. Turn it off when the viewer sits in a long page. */
|
|
54
|
+
wheelZoom?: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare const __VLS_export: import("vue").DefineComponent<PaperPicProps, {
|
|
57
|
+
instance: import("vue").ShallowRef<PaperPic | null, PaperPic | null>;
|
|
58
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
59
|
+
download: (payload: import("@paperpic/core").PaperPicDownload) => any;
|
|
60
|
+
apply: (payload: import("@paperpic/core").ExportedImage) => any;
|
|
61
|
+
change: (payload: import("@paperpic/core").PaperPicState) => any;
|
|
62
|
+
error: (payload: {
|
|
63
|
+
error: Error;
|
|
64
|
+
}) => any;
|
|
65
|
+
load: (payload: import("@paperpic/core").Size) => any;
|
|
66
|
+
}, string, import("vue").PublicProps, Readonly<PaperPicProps> & Readonly<{
|
|
67
|
+
onDownload?: ((payload: import("@paperpic/core").PaperPicDownload) => any) | undefined;
|
|
68
|
+
onApply?: ((payload: import("@paperpic/core").ExportedImage) => any) | undefined;
|
|
69
|
+
onChange?: ((payload: import("@paperpic/core").PaperPicState) => any) | undefined;
|
|
70
|
+
onError?: ((payload: {
|
|
71
|
+
error: Error;
|
|
72
|
+
}) => any) | undefined;
|
|
73
|
+
onLoad?: ((payload: import("@paperpic/core").Size) => any) | undefined;
|
|
74
|
+
}>, {
|
|
75
|
+
editable: boolean;
|
|
76
|
+
toolbar: boolean;
|
|
77
|
+
wheelZoom: boolean;
|
|
78
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
79
|
+
declare const _default: typeof __VLS_export;
|
|
80
|
+
export { type ExportedImage, type Fit, _default as PaperPic, type PaperPicDownload, type PaperPicEvents, type PaperPicIcons, type PaperPicInstance, type PaperPicLabels, type PaperPicOptions, type PaperPicOutput, type PaperPicProps, type PaperPicSource, type PaperPicState, type Rotation, type Size, type ToolId, type ViewPoint };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createElementBlock, defineComponent, onBeforeUnmount, onMounted, openBlock, shallowRef, useTemplateRef, watch } from "vue";
|
|
2
|
+
import { PaperPic } from "@paperpic/core";
|
|
3
|
+
// src/components/PaperPic.vue
|
|
4
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
5
|
+
__name: "PaperPic",
|
|
6
|
+
props: {
|
|
7
|
+
alt: {},
|
|
8
|
+
aspectRatio: {},
|
|
9
|
+
download: { type: Boolean },
|
|
10
|
+
editable: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: true
|
|
13
|
+
},
|
|
14
|
+
filename: {},
|
|
15
|
+
icons: {},
|
|
16
|
+
labels: {},
|
|
17
|
+
maxOutputSize: {},
|
|
18
|
+
output: {},
|
|
19
|
+
softness: {},
|
|
20
|
+
src: {},
|
|
21
|
+
toolbar: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
},
|
|
25
|
+
tools: {},
|
|
26
|
+
wheelZoom: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [
|
|
32
|
+
"apply",
|
|
33
|
+
"change",
|
|
34
|
+
"download",
|
|
35
|
+
"error",
|
|
36
|
+
"load"
|
|
37
|
+
],
|
|
38
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
39
|
+
const props = __props;
|
|
40
|
+
const emit = __emit;
|
|
41
|
+
const host = useTemplateRef("host");
|
|
42
|
+
/** The viewer, for a custom interface. It is `null` until the component mounts. */
|
|
43
|
+
const instance = shallowRef(null);
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
const pic = new PaperPic(host.value, { ...props });
|
|
46
|
+
pic.on("apply", (payload) => emit("apply", payload));
|
|
47
|
+
pic.on("change", (payload) => emit("change", payload));
|
|
48
|
+
pic.on("download", (payload) => emit("download", payload));
|
|
49
|
+
pic.on("error", (payload) => emit("error", payload));
|
|
50
|
+
pic.on("load", (payload) => emit("load", payload));
|
|
51
|
+
instance.value = pic;
|
|
52
|
+
});
|
|
53
|
+
watch(() => ({ ...props }), (options) => instance.value?.setOptions(options));
|
|
54
|
+
onBeforeUnmount(() => {
|
|
55
|
+
instance.value?.destroy();
|
|
56
|
+
instance.value = null;
|
|
57
|
+
});
|
|
58
|
+
__expose({ instance });
|
|
59
|
+
return (_ctx, _cache) => {
|
|
60
|
+
return openBlock(), createElementBlock("div", {
|
|
61
|
+
ref_key: "host",
|
|
62
|
+
ref: host,
|
|
63
|
+
class: "paperpic-host"
|
|
64
|
+
}, null, 512);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export { _sfc_main as PaperPic };
|