@paperpic/vue 0.1.0 → 0.3.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.
@@ -9,7 +9,7 @@ Phone photos have 12 megapixels or more, and editing them takes real work. This
9
9
 
10
10
  ## A Web Worker does the work
11
11
 
12
- Clean up and Straighten take more than a second on a 12-megapixel photo on a phone. On the main thread, the page would freeze for that long. PaperPic runs them in a Web Worker instead, so the page keeps responding while Apply runs.
12
+ Clean up and Straighten take about a second and a half on a 12-megapixel photo on a recent phone, as the [measured times](#measurements) show. On the main thread, the page would freeze for that long. PaperPic runs them in a Web Worker instead, so the page keeps responding while Apply runs.
13
13
 
14
14
  The worker ships inside the package and starts with the standard `new Worker(new URL(…, import.meta.url))`, which bundlers such as Vite and webpack 5 pick up on their own, with no configuration. If the worker cannot start, the editing runs on the main thread: it still works, but the page can freeze for a moment with large images.
15
15
 
@@ -19,6 +19,8 @@ With a Content Security Policy, allow:
19
19
 
20
20
  - `worker-src 'self'`, for the worker.
21
21
  - `img-src blob:`, because the viewer shows attached files and the results of Apply through `blob:` URLs.
22
+ - `paperpic` in `trusted-types`, if your policy restricts Trusted Types policies, because the icons of the buttons go through that policy.
23
+ - A `default` Trusted Types policy whose `createScriptURL` accepts the URL of the worker, if your policy requires Trusted Types. Bundlers only pick up a worker created from a plain URL, which Trusted Types block, so without that policy the editing runs on the main thread.
22
24
 
23
25
  ## Large photos
24
26
 
@@ -26,9 +28,21 @@ With a Content Security Policy, allow:
26
28
  - **On Apply**, every edit runs at full resolution. Large photos take a few seconds, so the viewer shows a message and blocks the controls meanwhile.
27
29
  - **To save time and memory**, set [`maxOutputSize`](../reference/options#maxoutputsize). A limit such as 2000 or 3000 pixels keeps documents readable, and makes Apply faster and the files smaller.
28
30
 
29
- ## Images it accepts
31
+ ## Measured times {#measurements}
30
32
 
31
- `src` takes a URL from the same origin as your page, or a `File` or `Blob` attached on the client. PaperPic reads the pixels of the image, and browsers only allow that for images from other origins under CORS, which PaperPic does not request. Serve the images from your own domain, or fetch them yourself and pass the `Blob`.
33
+ Each step of Apply, in the worker, on a Pixel 10 Pro with Chrome 156:
34
+
35
+ | Step | 2 MP | 12 MP | 37.5 MP |
36
+ | --------------------------- | ------ | ------ | ------- |
37
+ | Clean up | 256 ms | 1.5 s | 4.8 s |
38
+ | Straighten | 251 ms | 1.6 s | 5.0 s |
39
+ | Export to PNG | 92 ms | 378 ms | 979 ms |
40
+ | Export to JPEG, quality 0.9 | 33 ms | 142 ms | 525 ms |
41
+
42
+ - A move of the ruler of Clean up takes about 40 ms on the same phone, because it works on the preview of about 2 MP.
43
+ - A desktop computer with 8 cores does each step about six times faster.
44
+ - At 37.5 MP, Clean up needs about 340 MB of memory at its peak.
45
+ - Mid-range Android phones and iPhones are not measured yet.
32
46
 
33
47
  ## Server-side rendering
34
48
 
@@ -129,6 +129,12 @@ const pic = new PaperPic(container, {
129
129
 
130
130
  The preview while editing is always about 2 megapixels, so `maxOutputSize` changes only the result.
131
131
 
132
+ Safari on iOS limits a canvas to about 16 megapixels, and recent iPhones take photos of 24 megapixels or more, so Apply can fail at full resolution. If your users edit photos from an iPhone, set `maxOutputSize`. 3000 pixels keeps documents readable and stays well below the limit. [Apply fails with a large photo](./troubleshooting#too-large) shows the error.
133
+
134
+ ## Metadata {#metadata}
135
+
136
+ The result of Apply carries no metadata. PaperPic draws the image on a canvas, so the EXIF data of the photo, such as the GPS position, the camera and the date, is gone. The download button saves the source as it is until the first Apply, with its metadata.
137
+
132
138
  ## The download button
133
139
 
134
140
  [`download: true`](../reference/options#download) adds a button at the end of the toolbar that saves the image on display: the result of the last Apply, or else the source as it is. It is hidden while editing, because the edits are not applied yet. [`download()`](../reference/methods#download) does the same from code, with or without the button. The browser's context menu does not open over the viewer, so this button is the way to save the image from it.
@@ -55,6 +55,8 @@ Five [CSS tokens](../reference/css-tokens) set the surface, the text, the accent
55
55
  }
56
56
  ```
57
57
 
58
+ <Demo src="/samples/receipt.jpg" alt="A receipt" style="--paperpic-color-accent: #c2410c; --paperpic-radius: 0" />
59
+
58
60
  The tokens are inherited, so a class on the container of one viewer, or on the Vue or React component, changes that viewer only:
59
61
 
60
62
  ```css
@@ -7,6 +7,8 @@ description: How the Adjust tool of PaperPic changes the brightness and the cont
7
7
 
8
8
  Photos taken in poor light come out dark or gray. Adjust changes the brightness and the contrast and keeps the colors, for documents that should not become black and white, such as colored forms or photos.
9
9
 
10
+ <Demo src="/samples/receipt.jpg" alt="A receipt" :tools="['adjust']" />
11
+
10
12
  ## Use it
11
13
 
12
14
  1. Press Edit, then Adjust. Its panel takes the place of the tools: a ruler, and Brightness and Contrast to choose which tone it changes.
@@ -7,6 +7,8 @@ description: How the Crop tool of PaperPic keeps the part of a photo that holds
7
7
 
8
8
  A photo of a document often shows the table, a hand or other papers around it. Crop keeps the rectangle that holds the document and drops the rest.
9
9
 
10
+ <Demo src="/samples/receipt.jpg" alt="A receipt" :tools="['crop']" />
11
+
10
12
  ## Use it
11
13
 
12
14
  1. Press Edit, then Crop. A rectangle appears inside the image, with a handle at each corner.
@@ -7,6 +7,8 @@ description: How to rotate and flip a document image in PaperPic, in the edit mo
7
7
 
8
8
  Phones often save a photo of a document sideways or upside down, and some scans come out mirrored. Rotate left and Flip fix the orientation and leave the rest of the image as it is.
9
9
 
10
+ <Demo src="/samples/receipt.jpg" alt="A receipt" :tools="['rotate', 'flip']" />
11
+
10
12
  ## Rotate
11
13
 
12
14
  In the edit bar, Rotate left turns the image a quarter turn counterclockwise, as in photo galleries. Press it twice for a half turn, or three times for a quarter turn clockwise.
@@ -22,7 +24,7 @@ pic.rotate(-1)
22
24
 
23
25
  ## Flip
24
26
 
25
- Flip mirrors the image left to right, as it is on display, so after a quarter turn it still mirrors left to right on the screen. To turn an image upside down, flip it and rotate it twice.
27
+ Flip mirrors the image left to right, as it is on display, so after a quarter turn it still mirrors left to right on the screen. To mirror an image top to bottom, flip it and rotate it twice.
26
28
 
27
29
  Flips and rotations that cancel out leave nothing to apply. From code, call [`flip()`](../../reference/methods#flip).
28
30
 
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: Troubleshooting
3
+ description: What to do when the PaperPic viewer has no height or no style, Tailwind CSS changes it, an image does not load or cannot be edited, the page freezes on Apply, or a large photo fails.
4
+ ---
5
+
6
+ # Troubleshooting
7
+
8
+ Most problems with PaperPic come from its setup, and not from the image. Find what you see, and the fix below it.
9
+
10
+ ## The viewer is a thin strip, or does not show {#no-height}
11
+
12
+ The viewer fills its container, and a container without a height collapses to the minimum height of the viewer. Give the container a height, such as `height: 480px`, or a place in a flex or grid layout that gives it one. [Styling](./styling) shows both.
13
+
14
+ ## The buttons have no style, and the console warns {#no-stylesheet}
15
+
16
+ The console says `PaperPic: the stylesheet is missing, so the viewer has no layout.` Import the stylesheet once in your app: `@paperpic/core/style.css`, or the `style.css` of `@paperpic/vue` or `@paperpic/react`.
17
+
18
+ ## Tailwind CSS removes the borders and the padding of the viewer {#tailwind}
19
+
20
+ The reset of Tailwind CSS 4 wins over the stylesheet of PaperPic when the cascade layers come in the wrong order. Name the layers before you import both, as [Styling](./styling#tailwind) shows.
21
+
22
+ ## The image shows, but editing it fails {#other-origin}
23
+
24
+ The [`error`](../reference/events#error) says that the image comes from another origin. Browsers do not let PaperPic read the pixels of such an image. Fetch it yourself and pass the `Blob`, as [Loading images](./loading#fetch) shows.
25
+
26
+ ## The image does not load {#load-error}
27
+
28
+ The viewer shows that the image could not be loaded, and `error` carries `phase: 'load'`. Check that the URL exists, and that the browser opens the format: HEIC only opens in Safari, and an SVG needs `width` and `height` attributes. [Loading images](./loading#formats) lists the formats.
29
+
30
+ ## The page freezes while Apply runs {#worker}
31
+
32
+ The worker did not start, so the editing runs on the main thread. It still works, but large photos freeze the page for a moment. The usual causes are:
33
+
34
+ - A Content Security Policy without `worker-src 'self'`, or one that requires Trusted Types without a `default` policy. [Performance and support](./performance) lists what to allow.
35
+ - The package loaded from a CDN, from another origin than the page. Browsers only start a worker from the origin of the page.
36
+
37
+ The network panel of the browser shows whether the page requested the worker file, whose name starts with `worker`.
38
+
39
+ ## Apply fails with a large photo {#too-large}
40
+
41
+ The `error` says `The browser could not read an image of …`. Browsers limit the size of a canvas, and Safari on iOS the most. Set [`maxOutputSize`](../reference/options#maxoutputsize), such as to 3000 pixels, which keeps documents readable.
42
+
43
+ ## The wheel zooms the image instead of scrolling the page {#wheel}
44
+
45
+ Set [`wheelZoom: false`](../reference/options#wheelzoom). The buttons, the keyboard and a pinch still zoom.
@@ -18,7 +18,7 @@ Small print and long receipts are hard to read at a glance on a screen. The view
18
18
  | Switch between the fit and 100% | Double click | Double tap | |
19
19
  | Fit the whole image | | | `0` |
20
20
 
21
- The keyboard works with the focus on the viewer. A pinch zooms around the point between the fingers. On a touch screen, one finger scrolls the page while the image is fitted, and pans the image once it is zoomed in.
21
+ The keyboard works with the focus on the viewer. While there is nothing to move, the arrow keys scroll the page. A pinch zooms around the point between the fingers. On a touch screen, one finger scrolls the page while the image is fitted, and pans the image once it is zoomed in.
22
22
 
23
23
  The zoom goes from the fit of the whole image, or 100% for a small image, up to 800%. An image that fits stays centered, and one that overflows pans up to its edges.
24
24
 
@@ -5,7 +5,7 @@ description: The events of PaperPic and what each one carries, load, error, chan
5
5
 
6
6
  # Events
7
7
 
8
- Events tell your code what happens in the viewer. Listen to them with [`on()`](./methods#on). In Vue they are component events, such as `@apply`, and in React they are props, such as `onApply`.
8
+ Events tell your code what happens in the viewer. Listen to them with [`on()`](./methods#on). In Vue they are component events, such as `@apply`, and in React they are props, such as `onApply`. A listener that throws does not stop the viewer: the page gets the error as any uncaught one, and the other listeners still run.
9
9
 
10
10
  :::tabs key:framework
11
11
  == JavaScript
@@ -30,31 +30,35 @@ pic.on('apply', ({ blob }) => upload(blob))
30
30
 
31
31
  ## `load`
32
32
 
33
- - **Payload:** `{ width: number, height: number }`
33
+ - **Payload:** [`Size`](./types#size)
34
34
 
35
35
  The image is loaded and on display. `width` and `height` are its size in pixels.
36
36
 
37
37
  ## `error`
38
38
 
39
- - **Payload:** `{ error: Error }`
39
+ - **Payload:** `{ error: Error, phase: 'load' | 'preview' | 'apply' }`
40
40
 
41
- The image could not be loaded, or the edits could not be applied. After a failed Apply, the edit stays open.
41
+ Something failed, and `phase` says what:
42
+
43
+ - `'load'`: the image could not be loaded.
44
+ - `'preview'`: an edit could not be shown, as when the image is too large for the browser. The edit stays open.
45
+ - `'apply'`: the changes could not be applied. The edit stays open.
42
46
 
43
47
  ## `change`
44
48
 
45
49
  - **Payload:** [`PaperPicState`](./state)
46
50
 
47
- The user changed the view or the edit, such as by zooming, opening a tool or undoing. It also reports the start of Apply, with `busy: true`. `setOptions()` and the props of the components never emit it.
51
+ The user changed the view or the edit, such as by zooming, opening a tool or undoing. It also reports the start of Apply, with `busy: true`. Panning the image does not emit it, because the state does not hold its position. `setOptions()` and the props of the components never emit it.
48
52
 
49
53
  ## `apply`
50
54
 
51
- - **Payload:** `{ blob: Blob, width: number, height: number, type: string }`
55
+ - **Payload:** [`ExportedImage`](./types#exportedimage)
52
56
 
53
57
  The user applied the edits, and the result is already on display. `blob` holds the image in the format `type`, which [`output`](./options#output) chooses.
54
58
 
55
59
  ## `download`
56
60
 
57
- - **Payload:** `{ source: string | Blob, filename: string, preventDefault: () => void }`
61
+ - **Payload:** [`PaperPicDownload`](./types#paperpicdownload)
58
62
 
59
63
  The image is about to be saved, from the download button or from [`download()`](./methods#download). `source` is the image on display: the result of the last Apply, or else the `src`. `filename` is the name of the file.
60
64
 
@@ -27,7 +27,7 @@ class PaperPic {
27
27
 
28
28
  Creates the viewer inside `container`, which it fills. Give the container a height, or the viewer stays at its minimum height. [Options](./options) lists what `options` takes.
29
29
 
30
- It throws a `TypeError` if `container` is not an element. Create the viewer once the element exists, such as on mount.
30
+ It throws a `TypeError` if `container` is not an element. Create the viewer once the element exists, such as on mount. It throws a `RangeError` if an option is out of its range.
31
31
 
32
32
  ### `destroy()`
33
33
 
@@ -45,7 +45,7 @@ Removes the viewer and releases everything it holds, such as its worker and the
45
45
  function setOptions(options: PaperPicOptions): void
46
46
  ```
47
47
 
48
- Changes the options you pass and keeps the others. `undefined` brings an option back to its default. It never emits `change`, so two-way bindings do not loop.
48
+ Changes the options you pass and keeps the others. `undefined` brings an option back to its default. It never emits `change`, so two-way bindings do not loop. It throws a `RangeError` if an option is out of its range, and then no option changes.
49
49
 
50
50
  ### `getState()`
51
51
 
@@ -58,7 +58,7 @@ Returns what the viewer is showing, such as the zoom, the mode and whether there
58
58
  ### `on()`
59
59
 
60
60
  ```ts
61
- function on(name: keyof PaperPicEvents, listener: (payload) => void): () => void
61
+ function on<Name extends keyof PaperPicEvents>(name: Name, listener: (payload: PaperPicEvents[Name]) => void): () => void
62
62
  ```
63
63
 
64
64
  Listens to an event, and returns a function that stops listening. [Events](./events) describes each event.
@@ -90,20 +90,20 @@ Zooms out one step, around the center of the viewer.
90
90
  ### `zoomTo()`
91
91
 
92
92
  ```ts
93
- function zoomTo(zoom: number, point?: { x: number, y: number }): void
93
+ function zoomTo(zoom: number, point?: ViewPoint): void
94
94
  ```
95
95
 
96
- Sets the zoom, where `1` shows one pixel of the image per screen pixel. `point` stays in place: it is in CSS pixels from the top left corner of the viewer, and its center by default.
96
+ Sets the zoom, where `1` shows one pixel of the image per screen pixel. [`point`](./types#viewpoint) stays in place: it is in CSS pixels from the top left corner of the viewer, and its center by default.
97
97
 
98
98
  The zoom goes from the fit of the whole image, or `1` if that is smaller, up to `8`. A value out of range is clamped.
99
99
 
100
100
  ### `fit()`
101
101
 
102
102
  ```ts
103
- function fit(fit: 'image' | 'width' | 'height'): void
103
+ function fit(fit: Fit): void
104
104
  ```
105
105
 
106
- Fits the whole image, its width or its height to the viewer.
106
+ Fits the whole image, its width or its height to the viewer. `fit` is a [`Fit`](./types#fit): `'image'`, `'width'` or `'height'`.
107
107
 
108
108
  ## Editing
109
109
 
@@ -129,7 +129,7 @@ Turns the image a quarter turn: clockwise with `1`, the default, and countercloc
129
129
  function flip(): void
130
130
  ```
131
131
 
132
- Mirrors the image left to right as it is on display, so after a quarter turn it still mirrors left to right. To turn the image upside down, flip it and rotate it twice. It is an edit, and it does nothing outside the edit mode or while a tool is open.
132
+ Mirrors the image left to right as it is on display, so after a quarter turn it still mirrors left to right. To mirror it top to bottom, flip it and rotate it twice. It is an edit, and it does nothing outside the edit mode or while a tool is open.
133
133
 
134
134
  ### `openTool()`
135
135
 
@@ -13,13 +13,13 @@ const pic = new PaperPic(container, { src: '/receipt.jpg', alt: 'A receipt' })
13
13
  pic.setOptions({ editable: false })
14
14
  ```
15
15
 
16
- `setOptions()` changes only the options you pass, and `undefined` brings an option back to its default. It never emits `change`.
16
+ `setOptions()` changes only the options you pass, and `undefined` brings an option back to its default. It never emits `change`. An option out of its range throws a `RangeError` that names it, such as a `softness` of 2.
17
17
 
18
18
  ## Image
19
19
 
20
20
  ### `src`
21
21
 
22
- - **Type:** `string | Blob`
22
+ - **Type:** [`PaperPicSource`](./types#paperpicsource)
23
23
  - **Default:** none
24
24
 
25
25
  The image to show: a URL from the same origin, or a `File` or `Blob` attached on the client.
@@ -51,10 +51,10 @@ Whether to show the built-in toolbar and edit bar. Without them, build your own
51
51
 
52
52
  ### `tools`
53
53
 
54
- - **Type:** `readonly ToolId[]`
54
+ - **Type:** [`readonly ToolId[]`](./types#toolid)
55
55
  - **Default:** every tool
56
56
 
57
- The tools the edit bar offers. They keep the order of this table, whatever the order of the array.
57
+ The tools the edit bar offers. They keep the order of this table, whatever the order of the array. It only chooses the buttons: the [methods](./methods) work with every tool.
58
58
 
59
59
  | Id | Button |
60
60
  | --------------- | ----------------------------------- |
@@ -81,14 +81,14 @@ Whether the toolbar has a button that saves the image on display: the result of
81
81
 
82
82
  ### `labels`
83
83
 
84
- - **Type:** `Partial<PaperPicLabels>`
84
+ - **Type:** [`Partial<PaperPicLabels>`](./types#paperpiclabels)
85
85
  - **Default:** the English texts
86
86
 
87
87
  Replaces any of the texts that the component shows or announces. [Labels](./labels) lists every key.
88
88
 
89
89
  ### `icons`
90
90
 
91
- - **Type:** `Partial<PaperPicIcons>`
91
+ - **Type:** [`Partial<PaperPicIcons>`](./types#paperpicicons)
92
92
  - **Default:** the built-in icons
93
93
 
94
94
  Replaces any of the icons with your own markup of one element, such as an `<svg>`. The markup goes into the page as HTML, so pass only markup you trust. An empty string leaves the buttons of that icon without one. [Styling](../guide/styling#icons) shows an example.
@@ -122,7 +122,7 @@ Each key names an icon, and some icons appear on two buttons:
122
122
 
123
123
  ### `output`
124
124
 
125
- - **Type:** `{ type?: string, quality?: number }`
125
+ - **Type:** [`PaperPicOutput`](./types#paperpicoutput)
126
126
  - **Default:** the format of the source
127
127
 
128
128
  The format of the edited image. `type` is `'image/jpeg'`, `'image/png'` or `'image/webp'`, and `quality` goes from 0 to 1 for JPEG and WebP, with `0.92` by default.
@@ -36,23 +36,23 @@ Every [option](./options) is a prop with the same name, such as `editable={false
36
36
  | `className` | `string` | Classes on top of `paperpic-host` |
37
37
  | `style` | `CSSProperties` | Inline styles |
38
38
 
39
- Objects and arrays, such as `labels` or `tools`, reach the viewer again whenever they are new. Define them outside the component, or with `useMemo`.
39
+ An object or array with the same contents as before, such as `tools={['crop', 'rotate']}`, changes nothing, so inline values are fine. A function is new on every render, so define the functions of `labels`, such as `zoomLevel`, outside the component, or build those labels with `useMemo`.
40
40
 
41
41
  ## Events
42
42
 
43
- | Prop | Payload |
44
- | ------------ | -------------------------------------- |
45
- | `onApply` | `{ blob, width, height, type }` |
46
- | `onChange` | [`PaperPicState`](./state) |
47
- | `onDownload` | `{ source, filename, preventDefault }` |
48
- | `onError` | `{ error }` |
49
- | `onLoad` | `{ width, height }` |
43
+ | Prop | Payload |
44
+ | ------------ | ---------------------------------------------- |
45
+ | `onApply` | [`ExportedImage`](./types#exportedimage) |
46
+ | `onChange` | [`PaperPicState`](./state) |
47
+ | `onDownload` | [`PaperPicDownload`](./types#paperpicdownload) |
48
+ | `onError` | `{ error, phase }` |
49
+ | `onLoad` | [`Size`](./types#size) |
50
50
 
51
51
  [Events](./events) describes each one. A new function does not recreate the viewer, so inline functions are fine. A change of props never calls `onChange`.
52
52
 
53
53
  ## Methods
54
54
 
55
- `ref` receives the viewer, of type `PaperPicInstance`, with every [method](./methods). It is `null` until the component mounts:
55
+ `ref` receives the viewer, of type [`PaperPicInstance`](./types#paperpicinstance), with every [method](./methods). It is `null` until the component mounts:
56
56
 
57
57
  ```tsx
58
58
  import type { PaperPicInstance } from '@paperpic/react'
@@ -75,9 +75,9 @@ export function Viewer({ src }: { src: string }) {
75
75
 
76
76
  Passing the same `src` again does not reload the image, so it keeps the result of an edit. To bring back the original, call `picRef.current.reload()`.
77
77
 
78
- ## Types
78
+ ## Types {#types}
79
79
 
80
- `@paperpic/react` exports the types you need, so you do not need to install `@paperpic/core`: `PaperPicProps`, `PaperPicInstance`, `PaperPicState`, `PaperPicEvents`, `PaperPicIcons`, `PaperPicLabels`, `PaperPicOutput`, `PaperPicDownload`, `ExportedImage` and `ToolId`.
80
+ `@paperpic/react` exports every type of `@paperpic/core`, so you do not need to install it: [Types](./types) shows each one. It also exports the types of the component: [`PaperPicProps`](./types#paperpicprops), with its props, and [`PaperPicInstance`](./types#paperpicinstance), the viewer that `ref` receives.
81
81
 
82
82
  ## Server-side rendering
83
83
 
@@ -15,16 +15,16 @@ pic.on('change', ({ canApply, busy }) => {
15
15
 
16
16
  | Field | Type | Description |
17
17
  | ------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
18
- | `activeTool` | `ToolId \| null` | The open tool, such as `'crop'` or `'adjust'`, or `null` |
18
+ | `activeTool` | [`ToolId \| null`](./types#toolid) | The open tool, such as `'crop'` or `'adjust'`, or `null` |
19
19
  | `adjustments` | `{ brightness, contrast }` | The brightness and the contrast, each from -1 to 1. Clean up leaves them out. While Adjust is open, the values it shows |
20
20
  | `busy` | `boolean` | Whether Apply is running |
21
21
  | `canApply` | `boolean` | Whether there are changes to apply. Rotations and flips that cancel out are no change |
22
22
  | `canRedo` | `boolean` | Whether there is an edit to bring back |
23
23
  | `canUndo` | `boolean` | Whether there is an edit to undo |
24
- | `fit` | `'image' \| 'width' \| 'height' \| null` | The fit in effect, or `null` once the user has zoomed by hand |
25
- | `image` | `{ width, height } \| null` | The size of the image on display in pixels, with the edits so far, or `null` without an image |
24
+ | `fit` | [`Fit \| null`](./types#fit) | The fit in effect, or `null` once the user has zoomed by hand |
25
+ | `image` | [`Size \| null`](./types#size) | The size of the image on display in pixels, with the edits so far, or `null` without an image |
26
26
  | `mode` | `'view' \| 'edit'` | Whether the user is viewing or editing the image |
27
- | `rotation` | `0 \| 90 \| 180 \| 270` | How far the image on display is turned, in degrees clockwise |
27
+ | `rotation` | [`Rotation`](./types#rotation) | How far the image on display is turned, in degrees clockwise |
28
28
  | `status` | `'empty' \| 'loading' \| 'ready' \| 'error'` | Whether there is an image, and whether it loaded |
29
29
  | `threshold` | `{ enabled, sensitivity }` | Whether Clean up is on, and its sensitivity from 0 to 1. While Clean up is open, what it shows |
30
30
  | `zoom` | `number` | Screen pixels per pixel of the image |