@rdlabo/ionic-angular-photo-editor 21.7.0 → 22.0.0-1
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/README.md +57 -23
- package/css/ios26-header-button-color-scheme.css +114 -0
- package/docs/editor.md +65 -18
- package/docs/photo-file.md +90 -18
- package/docs/theme.md +21 -3
- package/docs/viewer.md +58 -23
- package/fesm2022/rdlabo-ionic-angular-photo-editor-editor-tui.mjs +12 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-editor-tui.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-editor.mjs +301 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-editor.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-file-capacitor.mjs +30 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-file-capacitor.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-file.mjs +193 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-file.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-viewer.mjs +126 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor-viewer.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-photo-editor.mjs +32 -500
- package/fesm2022/rdlabo-ionic-angular-photo-editor.mjs.map +1 -1
- package/package.json +49 -10
- package/types/rdlabo-ionic-angular-photo-editor-editor-tui.d.ts +6 -0
- package/types/rdlabo-ionic-angular-photo-editor-editor.d.ts +52 -0
- package/types/rdlabo-ionic-angular-photo-editor-file-capacitor.d.ts +6 -0
- package/types/rdlabo-ionic-angular-photo-editor-file.d.ts +13 -0
- package/types/rdlabo-ionic-angular-photo-editor-viewer.d.ts +32 -0
- package/types/rdlabo-ionic-angular-photo-editor.d.ts +144 -95
package/README.md
CHANGED
|
@@ -2,30 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Photo editor and viewer modal pages for Ionic Angular applications, with Capacitor camera/album support.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
### Choose by editing goal
|
|
10
10
|
|
|
11
|
-
| Goal
|
|
12
|
-
|
|
|
13
|
-
| Load a photo from camera or album | [PhotoFileService](./docs/photo-file.md)
|
|
14
|
-
| Crop and edit in a modal
|
|
15
|
-
| Browse images in a modal
|
|
16
|
-
| Override editor colors
|
|
11
|
+
| Goal | Guide |
|
|
12
|
+
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| Load a photo from camera or album | [PhotoFileService](./docs/photo-file.md) |
|
|
14
|
+
| Crop and edit in a modal | [Photo Editor](./docs/editor.md) |
|
|
15
|
+
| Browse images in a modal | [Photo Viewer](./docs/viewer.md) |
|
|
16
|
+
| Override editor colors | [Theme](./docs/theme.md) |
|
|
17
|
+
| Upgrade from an earlier release | [Migration guide](https://github.com/rdlabo-dev/ionic-angular-library/blob/main/docs/migration.md#rdlaboionic-angular-photo-editor) |
|
|
17
18
|
|
|
18
19
|
## Quick start
|
|
19
20
|
|
|
20
|
-
After [Installation](#installation), load a photo:
|
|
21
|
+
After [Installation](#installation), register optional defaults and load a photo:
|
|
21
22
|
|
|
22
23
|
```typescript
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
import { providePhotoEditor } from '@rdlabo/ionic-angular-photo-editor';
|
|
25
|
+
import { createTuiImageEditor } from '@rdlabo/ionic-angular-photo-editor/editor/tui';
|
|
26
|
+
import { PhotoFileService } from '@rdlabo/ionic-angular-photo-editor/file';
|
|
27
|
+
import { loadCapacitorPhotoCamera } from '@rdlabo/ionic-angular-photo-editor/file/capacitor';
|
|
28
|
+
|
|
29
|
+
// app.config.ts
|
|
30
|
+
export const appConfig = {
|
|
31
|
+
providers: [
|
|
32
|
+
providePhotoEditor({
|
|
33
|
+
maxSize: 1000,
|
|
34
|
+
createImageEditor: createTuiImageEditor,
|
|
35
|
+
loadCamera: loadCapacitorPhotoCamera,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// component
|
|
41
|
+
const files = await this.photoFileService.loadPhoto({ limit: 1 });
|
|
26
42
|
```
|
|
27
43
|
|
|
28
|
-
|
|
44
|
+
Present the editor or viewer from their secondary entry points. Details: [PhotoFileService](./docs/photo-file.md), [Photo Editor](./docs/editor.md), [Photo Viewer](./docs/viewer.md).
|
|
45
|
+
|
|
46
|
+
## Package entry points
|
|
47
|
+
|
|
48
|
+
| Import path | Exports |
|
|
49
|
+
| --------------------------------------------------- | -------------------------------------------------------------------- |
|
|
50
|
+
| `@rdlabo/ionic-angular-photo-editor` | Types, `providePhotoEditor`, `PHOTO_EDITOR_CONFIG`, `PhotoLoadError` |
|
|
51
|
+
| `@rdlabo/ionic-angular-photo-editor/editor` | `PhotoEditorPage` |
|
|
52
|
+
| `@rdlabo/ionic-angular-photo-editor/editor/tui` | opt-in `createTuiImageEditor` adapter |
|
|
53
|
+
| `@rdlabo/ionic-angular-photo-editor/viewer` | `PhotoViewerPage` |
|
|
54
|
+
| `@rdlabo/ionic-angular-photo-editor/file` | `PhotoFileService` |
|
|
55
|
+
| `@rdlabo/ionic-angular-photo-editor/file/capacitor` | opt-in `loadCapacitorPhotoCamera` adapter |
|
|
56
|
+
|
|
57
|
+
Import components and services only from their entry point. Import shared types and configuration from the root package.
|
|
29
58
|
|
|
30
59
|
## Installation
|
|
31
60
|
|
|
@@ -33,22 +62,24 @@ Then present the editor or viewer. Details: [PhotoFileService](./docs/photo-file
|
|
|
33
62
|
npm install @rdlabo/ionic-angular-photo-editor
|
|
34
63
|
```
|
|
35
64
|
|
|
36
|
-
|
|
65
|
+
Install only the optional feature dependencies used by the application:
|
|
37
66
|
|
|
38
67
|
```bash
|
|
39
|
-
|
|
40
|
-
|
|
68
|
+
# editor, and resizing in PhotoFileService
|
|
69
|
+
npm install tui-image-editor
|
|
41
70
|
|
|
42
|
-
|
|
71
|
+
# viewer
|
|
72
|
+
npm install swiper
|
|
43
73
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```html
|
|
47
|
-
<div style="width: 0; height: 0; overflow: hidden">
|
|
48
|
-
<input id="browserPhotoUploader" type="file" accept="image/*" />
|
|
49
|
-
</div>
|
|
74
|
+
# native camera and album selection
|
|
75
|
+
npm install @capacitor/camera
|
|
50
76
|
```
|
|
51
77
|
|
|
78
|
+
Configure Android/iOS camera permissions as described in the [Capacitor Camera docs](https://capacitorjs.com/docs/apis/camera#android-configuration).
|
|
79
|
+
Native iOS applications must target iOS/iPadOS 16.4 or later.
|
|
80
|
+
|
|
81
|
+
No static `<input type="file">` in `index.html` is required. On web, `PhotoFileService` creates and attaches a hidden file input synchronously when `loadPhoto()` is called.
|
|
82
|
+
The root, `/editor`, and `/file` entry points do not import optional implementations. Opt in through `/editor/tui` and `/file/capacitor`; web-only consumers can omit the Capacitor adapter and dependency.
|
|
52
83
|
|
|
53
84
|
## Documentation
|
|
54
85
|
|
|
@@ -57,8 +88,11 @@ Start with [Installation](#installation), then pick a guide.
|
|
|
57
88
|
- [PhotoFileService](./docs/photo-file.md) — camera and album.
|
|
58
89
|
- [Photo Editor](./docs/editor.md) — crop and edit in a modal.
|
|
59
90
|
- [Photo Viewer](./docs/viewer.md) — browse images in a modal.
|
|
60
|
-
- [Theme](./docs/theme.md) — CSS variables.
|
|
91
|
+
- [Theme](./docs/theme.md) — CSS variables and toolbar color scheme.
|
|
92
|
+
- [Migration guide](https://github.com/rdlabo-dev/ionic-angular-library/blob/main/docs/migration.md#rdlaboionic-angular-photo-editor) — breaking changes and required consumer updates.
|
|
61
93
|
|
|
62
94
|
<!-- rdlabo-docs-omit -->
|
|
95
|
+
|
|
63
96
|
**Full documentation:** [https://docs.rdlabo.dev/projects/ionic-angular-photo-editor](https://docs.rdlabo.dev/projects/ionic-angular-photo-editor)
|
|
97
|
+
|
|
64
98
|
<!-- /rdlabo-docs-omit -->
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
ion-header.photo-editor-header-buttons-light {
|
|
2
|
+
--ion-text-color-rgb: 0, 0, 0;
|
|
3
|
+
--ios26-glass-background-rgb: 255, 255, 255;
|
|
4
|
+
--ios26-glass-box-shadow-color-rgb: 220, 220, 220;
|
|
5
|
+
--ios26-glass-border-color-rgb: 255, 255, 255;
|
|
6
|
+
--ios26-button-color-selected-rgb: 16, 16, 16;
|
|
7
|
+
}
|
|
8
|
+
ion-header.photo-editor-header-buttons-light ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear), ion-menu-button.menu-button-hidden)):has(.ion-activated) {
|
|
9
|
+
background: rgba(var(--ios26-glass-background-rgb), 0.72);
|
|
10
|
+
backdrop-filter: blur(2px) saturate(360%);
|
|
11
|
+
box-shadow: inset 0 0 8px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.2), 0 0 10px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.82);
|
|
12
|
+
border-top: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 1);
|
|
13
|
+
border-right: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 0.8);
|
|
14
|
+
border-bottom: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 1);
|
|
15
|
+
border-left: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 0.6);
|
|
16
|
+
transform: translateZ(0);
|
|
17
|
+
-webkit-transform: translateZ(0);
|
|
18
|
+
-webkit-backface-visibility: hidden;
|
|
19
|
+
backface-visibility: hidden;
|
|
20
|
+
box-shadow: inset 0 0 8px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.2), 0 0 8px -4px rgba(var(--ios26-glass-box-shadow-color-rgb), 0.92);
|
|
21
|
+
}
|
|
22
|
+
ion-header.photo-editor-header-buttons-light ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear), ion-menu-button.menu-button-hidden)) ion-button:not(.ios26-disabled).button-clear.ion-activated {
|
|
23
|
+
color: rgba(var(--ion-text-color-rgb), 0.1);
|
|
24
|
+
--color: rgba(var(--ion-text-color-rgb), 0.1);
|
|
25
|
+
}
|
|
26
|
+
ion-header.photo-editor-header-buttons-light ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear), ion-menu-button.menu-button-hidden)) ion-button:not(.ios26-disabled).button-clear.ion-activated.ion-color {
|
|
27
|
+
color: rgba(var(--ion-color-base-rgb, var(--ion-text-color-rgb)), 0.1);
|
|
28
|
+
--color: rgba(var(--ion-color-base-rgb, var(--ion-text-color-rgb)), 0.1);
|
|
29
|
+
}
|
|
30
|
+
ion-header.photo-editor-header-buttons-light ion-button.ios:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear) {
|
|
31
|
+
--color: rgba(var(--ion-text-color-rgb), 0.1);
|
|
32
|
+
}
|
|
33
|
+
ion-header.photo-editor-header-buttons-light ion-button.ios:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear).ion-color {
|
|
34
|
+
--color: rgba(var(--ion-color-base-rgb, var(--ion-text-color-rgb)), 0.1);
|
|
35
|
+
}
|
|
36
|
+
ion-header.photo-editor-header-buttons-light ion-button.ios:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear)::part(native) {
|
|
37
|
+
background: rgba(var(--ios26-glass-background-rgb), 0.72);
|
|
38
|
+
backdrop-filter: blur(2px) saturate(360%);
|
|
39
|
+
box-shadow: inset 0 0 8px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.2), 0 0 10px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.82);
|
|
40
|
+
border-top: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 1);
|
|
41
|
+
border-right: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 0.8);
|
|
42
|
+
border-bottom: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 1);
|
|
43
|
+
border-left: 0.5px solid rgba(var(--ios26-glass-border-color-rgb), 0.6);
|
|
44
|
+
transform: translateZ(0);
|
|
45
|
+
-webkit-transform: translateZ(0);
|
|
46
|
+
-webkit-backface-visibility: hidden;
|
|
47
|
+
backface-visibility: hidden;
|
|
48
|
+
box-shadow: inset 0 0 8px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.2), 0 0 8px -4px rgba(var(--ios26-glass-box-shadow-color-rgb), 0.92);
|
|
49
|
+
}
|
|
50
|
+
ion-header.photo-editor-header-buttons-light ion-button.ios:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear) ion-icon {
|
|
51
|
+
color: rgba(var(--ion-text-color-rgb), 0.1) !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ion-header.photo-editor-header-buttons-dark {
|
|
55
|
+
--ion-text-color-rgb: 255, 255, 255;
|
|
56
|
+
--ios26-glass-background-rgb: 62, 62, 62;
|
|
57
|
+
--ios26-glass-box-shadow-color-rgb: 0, 0, 0 / 0;
|
|
58
|
+
--ios26-glass-border-color-rgb: 68, 68, 68;
|
|
59
|
+
--ios26-button-color-selected-rgb: 255, 255, 255;
|
|
60
|
+
--ios26-content-box-shadow-rgb: 0, 0, 0;
|
|
61
|
+
}
|
|
62
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))):has(.ion-activated) {
|
|
63
|
+
background: rgba(var(--ios26-button-color-selected-rgb), 0.56);
|
|
64
|
+
backdrop-filter: blur(7px) saturate(180%);
|
|
65
|
+
box-shadow: inset 0 0 16px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.55);
|
|
66
|
+
border-top: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.8);
|
|
67
|
+
border-right: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.4);
|
|
68
|
+
border-bottom: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.8);
|
|
69
|
+
border-left: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.6);
|
|
70
|
+
transform: translateZ(0);
|
|
71
|
+
-webkit-transform: translateZ(0);
|
|
72
|
+
-webkit-backface-visibility: hidden;
|
|
73
|
+
backface-visibility: hidden;
|
|
74
|
+
}
|
|
75
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))) ion-button:not(.ios26-disabled).button-clear.ion-activated {
|
|
76
|
+
color: rgb(var(--ion-text-color-rgb, 0, 0, 0));
|
|
77
|
+
}
|
|
78
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))) ion-button:not(.ios26-disabled).button-clear.ion-activated.ion-color {
|
|
79
|
+
color: rgb(var(--ion-color-base-rgb, var(--ion-text-color-rgb, 0, 0, 0)));
|
|
80
|
+
}
|
|
81
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))) ion-button:not(.ios26-disabled).ion-activated,
|
|
82
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))) ion-back-button:not(.ios26-disabled).ion-activated {
|
|
83
|
+
--color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 1);
|
|
84
|
+
}
|
|
85
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))) ion-button:not(.ios26-disabled).ion-activated.ion-color,
|
|
86
|
+
ion-header.photo-editor-header-buttons-dark ion-buttons.ios:not(.ios26-disabled):not(:has(ion-back-button, ion-button:not(.button-clear))) ion-back-button:not(.ios26-disabled).ion-activated.ion-color {
|
|
87
|
+
--color: rgba(var(--ion-color-base-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 1);
|
|
88
|
+
}
|
|
89
|
+
ion-header.photo-editor-header-buttons-dark ion-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear),
|
|
90
|
+
ion-header.photo-editor-header-buttons-dark ion-back-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear) {
|
|
91
|
+
--color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 1);
|
|
92
|
+
}
|
|
93
|
+
ion-header.photo-editor-header-buttons-dark ion-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear).ion-color,
|
|
94
|
+
ion-header.photo-editor-header-buttons-dark ion-back-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear).ion-color {
|
|
95
|
+
--color: rgba(var(--ion-color-base-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 1);
|
|
96
|
+
}
|
|
97
|
+
ion-header.photo-editor-header-buttons-dark ion-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear)::part(native),
|
|
98
|
+
ion-header.photo-editor-header-buttons-dark ion-back-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear)::part(native) {
|
|
99
|
+
background: rgba(var(--ios26-button-color-selected-rgb), 0.56);
|
|
100
|
+
backdrop-filter: blur(7px) saturate(180%);
|
|
101
|
+
box-shadow: inset 0 0 16px 0 rgba(var(--ios26-glass-box-shadow-color-rgb), 0.55);
|
|
102
|
+
border-top: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.8);
|
|
103
|
+
border-right: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.4);
|
|
104
|
+
border-bottom: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.8);
|
|
105
|
+
border-left: 0.8px solid rgba(var(--ios26-button-color-selected-rgb), 0.6);
|
|
106
|
+
transform: translateZ(0);
|
|
107
|
+
-webkit-transform: translateZ(0);
|
|
108
|
+
-webkit-backface-visibility: hidden;
|
|
109
|
+
backface-visibility: hidden;
|
|
110
|
+
}
|
|
111
|
+
ion-header.photo-editor-header-buttons-dark ion-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear) ion-icon,
|
|
112
|
+
ion-header.photo-editor-header-buttons-dark ion-back-button:not(.ios26-disabled).ion-activated:not(.button-solid):not(.button-outline):not(.button-clear) ion-icon {
|
|
113
|
+
color: rgb(255, 255, 255) !important;
|
|
114
|
+
}
|
package/docs/editor.md
CHANGED
|
@@ -1,39 +1,86 @@
|
|
|
1
1
|
Present `PhotoEditorPage` in an Ionic modal. Call this after [Installation](../README.md#installation).
|
|
2
2
|
|
|
3
3
|
```typescript
|
|
4
|
-
import {
|
|
4
|
+
import { PhotoEditorProps, PhotoEditorResult, providePhotoEditor } from '@rdlabo/ionic-angular-photo-editor';
|
|
5
|
+
import { PhotoEditorPage } from '@rdlabo/ionic-angular-photo-editor/editor';
|
|
6
|
+
import { createTuiImageEditor } from '@rdlabo/ionic-angular-photo-editor/editor/tui';
|
|
7
|
+
|
|
8
|
+
// app.config.ts
|
|
9
|
+
export const appConfig = {
|
|
10
|
+
providers: [providePhotoEditor({ createImageEditor: createTuiImageEditor })],
|
|
11
|
+
};
|
|
5
12
|
|
|
6
13
|
(async () => {
|
|
14
|
+
const componentProps = {
|
|
15
|
+
requireSquare: false,
|
|
16
|
+
value: 'https://picsum.photos/200/300',
|
|
17
|
+
toolbarColorScheme: 'dark',
|
|
18
|
+
labels: {
|
|
19
|
+
save: '送信', // override default '保存'
|
|
20
|
+
},
|
|
21
|
+
} satisfies PhotoEditorProps;
|
|
7
22
|
const modal = await this.modalCtrl.create({
|
|
8
23
|
component: PhotoEditorPage,
|
|
9
|
-
componentProps
|
|
10
|
-
requireSquare: false,
|
|
11
|
-
value: 'https://picsum.photos/200/300',
|
|
12
|
-
labels: {
|
|
13
|
-
save: '送信', // change '保存' to '送信'
|
|
14
|
-
},
|
|
15
|
-
},
|
|
24
|
+
componentProps,
|
|
16
25
|
});
|
|
17
26
|
await modal.present();
|
|
18
|
-
const { data } = await modal.onWillDismiss<
|
|
19
|
-
if (data?.
|
|
27
|
+
const { data } = await modal.onWillDismiss<PhotoEditorResult>();
|
|
28
|
+
if (data?.action === 'save') {
|
|
20
29
|
console.log(data.value);
|
|
21
30
|
}
|
|
22
31
|
})();
|
|
23
32
|
```
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
## Modal result
|
|
35
|
+
|
|
36
|
+
On save, the modal dismisses with:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
interface PhotoEditorResult {
|
|
40
|
+
action: 'save';
|
|
41
|
+
value: string; // data URL of the edited image
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Closing without saving dismisses with no data.
|
|
46
|
+
|
|
47
|
+
## Options
|
|
48
|
+
|
|
49
|
+
### requireSquare: boolean
|
|
50
|
+
|
|
51
|
+
When `true`, the image must be cropped to a square before editing continues.
|
|
26
52
|
|
|
27
|
-
|
|
53
|
+
### value: string
|
|
28
54
|
|
|
29
|
-
|
|
55
|
+
Image URL or data URL to edit.
|
|
30
56
|
|
|
31
|
-
|
|
57
|
+
### toolbarColorScheme: 'light' | 'dark'
|
|
32
58
|
|
|
33
|
-
The
|
|
59
|
+
**Required.** Use `dark` for a dark/black `ion-toolbar` and `light` for a light/white toolbar. The library cannot infer toolbar appearance from CSS, translucency, or runtime theme overrides. See [Theme](./theme.md).
|
|
34
60
|
|
|
35
|
-
|
|
61
|
+
### labels: Partial<PhotoEditorLabels>
|
|
36
62
|
|
|
37
|
-
|
|
63
|
+
Overrides default UI strings. Unspecified keys keep the built-in Japanese defaults:
|
|
38
64
|
|
|
39
|
-
|
|
65
|
+
| Key | Default (ja) |
|
|
66
|
+
| ---------- | -------------- |
|
|
67
|
+
| save | 保存 |
|
|
68
|
+
| close | 閉じる |
|
|
69
|
+
| back | 戻る |
|
|
70
|
+
| apply | 適用 |
|
|
71
|
+
| crop | 切り抜き・回転 |
|
|
72
|
+
| rotate | 回転 |
|
|
73
|
+
| cropCover | 画像に合わせる |
|
|
74
|
+
| crop16x9 | 16対9 |
|
|
75
|
+
| cropSquare | 正方形 |
|
|
76
|
+
| cropFree | 自由 |
|
|
77
|
+
| filter | フィルター |
|
|
78
|
+
| brightness | 明るさ |
|
|
79
|
+
| original | オリジナル |
|
|
80
|
+
| invert | 反転 |
|
|
81
|
+
| sepia | セピア |
|
|
82
|
+
| vintage | ヴィンテージ |
|
|
83
|
+
| blur | ぼかし |
|
|
84
|
+
| grayscale | グレースケール |
|
|
85
|
+
| sharpen | 輪郭 |
|
|
86
|
+
| emboss | エンボス |
|
package/docs/photo-file.md
CHANGED
|
@@ -1,35 +1,107 @@
|
|
|
1
1
|
Load photos from the camera or album. Call this after [Installation](../README.md#installation).
|
|
2
2
|
|
|
3
3
|
```typescript
|
|
4
|
-
import {
|
|
4
|
+
import { providePhotoEditor, PhotoLoadError } from '@rdlabo/ionic-angular-photo-editor';
|
|
5
|
+
import { createTuiImageEditor } from '@rdlabo/ionic-angular-photo-editor/editor/tui';
|
|
6
|
+
import { PhotoFileService } from '@rdlabo/ionic-angular-photo-editor/file';
|
|
7
|
+
import { loadCapacitorPhotoCamera } from '@rdlabo/ionic-angular-photo-editor/file/capacitor';
|
|
5
8
|
|
|
9
|
+
// app.config.ts — optional global defaults
|
|
10
|
+
export const appConfig = {
|
|
11
|
+
providers: [
|
|
12
|
+
providePhotoEditor({
|
|
13
|
+
maxSize: 1000,
|
|
14
|
+
labels: {
|
|
15
|
+
camera: 'Camera',
|
|
16
|
+
album: 'Album',
|
|
17
|
+
cancel: 'Cancel',
|
|
18
|
+
},
|
|
19
|
+
createImageEditor: createTuiImageEditor,
|
|
20
|
+
loadCamera: loadCapacitorPhotoCamera,
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// component
|
|
6
26
|
export class AppComponent {
|
|
7
27
|
private photoFileService = inject(PhotoFileService);
|
|
8
28
|
|
|
9
|
-
constructor() {
|
|
10
|
-
this.photoFileService.photoMaxSize = 1000;
|
|
11
|
-
this.photoFileService.labels = {
|
|
12
|
-
camera: 'Camera',
|
|
13
|
-
album: 'Album',
|
|
14
|
-
cancel: 'Cancel',
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
29
|
async upload() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
try {
|
|
31
|
+
const files = await this.photoFileService.loadPhoto({
|
|
32
|
+
limit: 1,
|
|
33
|
+
maxSize: 1000,
|
|
34
|
+
labels: { camera: 'Camera' }, // merges over configured defaults
|
|
35
|
+
});
|
|
36
|
+
if (files.length > 0) {
|
|
37
|
+
// upload files
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof PhotoLoadError && error.code === 'cancelled') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
22
44
|
}
|
|
23
45
|
}
|
|
24
46
|
}
|
|
25
47
|
```
|
|
26
48
|
|
|
27
|
-
|
|
49
|
+
## loadPhoto(options?)
|
|
50
|
+
|
|
51
|
+
Opens the platform photo picker and returns normalized data URLs.
|
|
52
|
+
|
|
53
|
+
| Option | Default | Description |
|
|
54
|
+
| --------- | ------------------------------ | ---------------------------------------------- |
|
|
55
|
+
| `limit` | `1` | Maximum number of images (album and web only). |
|
|
56
|
+
| `maxSize` | configured `maxSize` or `1000` | Longest edge in pixels after resize. |
|
|
57
|
+
| `labels` | configured `labels` | Action sheet button text (Capacitor only). |
|
|
58
|
+
|
|
59
|
+
### Browser behavior
|
|
60
|
+
|
|
61
|
+
On web, `loadPhoto()` synchronously creates a hidden `<input type="file">`, attaches it to `document.body`, and calls `click()` in the same turn as the caller's gesture. This preserves WebKit transient user activation. The input has no fixed id; it is removed after selection or cancellation.
|
|
62
|
+
|
|
63
|
+
Do not add a static file input to `index.html`.
|
|
64
|
+
|
|
65
|
+
### Capacitor behavior
|
|
28
66
|
|
|
29
|
-
|
|
67
|
+
On native platforms, an action sheet asks the user to choose camera or album. Per-request `labels` merge over values from `providePhotoEditor({ labels })`.
|
|
68
|
+
Register `loadCapacitorPhotoCamera` from `/file/capacitor`; the base `/file` entry point stays usable by browser-only applications without `@capacitor/camera`.
|
|
30
69
|
|
|
31
|
-
|
|
70
|
+
### Errors
|
|
32
71
|
|
|
33
|
-
|
|
72
|
+
Expected failures throw `PhotoLoadError`:
|
|
73
|
+
|
|
74
|
+
| Code | When |
|
|
75
|
+
| -------------- | -------------------------------------------------------- |
|
|
76
|
+
| `cancelled` | User dismissed the picker or action sheet |
|
|
77
|
+
| `invalid-type` | Selected file is not an image (web only) |
|
|
78
|
+
| `unavailable` | Permission, plugin, picker, file-read, or resize failure |
|
|
79
|
+
|
|
80
|
+
## Default labels (ja)
|
|
81
|
+
|
|
82
|
+
When no global or per-request `labels` are supplied:
|
|
83
|
+
|
|
84
|
+
| Key | Default (ja) |
|
|
85
|
+
| ------ | ---------------- |
|
|
86
|
+
| camera | カメラ撮影 |
|
|
87
|
+
| album | アルバムから選択 |
|
|
88
|
+
| cancel | キャンセル |
|
|
89
|
+
|
|
90
|
+
## providePhotoEditor(config?)
|
|
91
|
+
|
|
92
|
+
Register application-wide defaults in `app.config.ts`:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
export const appConfig = {
|
|
96
|
+
providers: [
|
|
97
|
+
providePhotoEditor({
|
|
98
|
+
maxSize: 1200,
|
|
99
|
+
labels: { camera: '…', album: '…', cancel: '…' },
|
|
100
|
+
createImageEditor: createTuiImageEditor,
|
|
101
|
+
loadCamera: loadCapacitorPhotoCamera, // omit in browser-only applications
|
|
102
|
+
}),
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
```
|
|
34
106
|
|
|
35
|
-
|
|
107
|
+
`PhotoFileService` reads these adapters plus the global `maxSize` and `labels` defaults from this configuration. Per-request values with the same names override them for a single call. A resize requires `createImageEditor`; a native picker requires `loadCamera`. Missing adapters throw `PhotoLoadError` with `code: 'unavailable'`.
|
package/docs/theme.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
Override the editor colors after [Installation](../README.md#installation).
|
|
2
2
|
|
|
3
|
-
Default
|
|
4
|
-
|
|
5
|
-
## How to overwrite
|
|
3
|
+
Default colors are defined in the library stylesheet. Override them with CSS variables:
|
|
6
4
|
|
|
7
5
|
```scss
|
|
8
6
|
:root {
|
|
@@ -15,5 +13,25 @@ Default color is set, but user can overwrite it: https://github.com/rdlabo-dev/i
|
|
|
15
13
|
--ion-photo-editor-primary: #4d8dff;
|
|
16
14
|
--ion-photo-editor-danger: #f24c58;
|
|
17
15
|
--ion-photo-editor-success: #2dd55b;
|
|
16
|
+
|
|
17
|
+
--ion-photo-editor-header-button-color-on-light: #222428;
|
|
18
|
+
--ion-photo-editor-header-button-color-on-dark: #f4f5f8;
|
|
18
19
|
}
|
|
19
20
|
```
|
|
21
|
+
|
|
22
|
+
Source reference: [`core.scss`](https://github.com/rdlabo-dev/ionic-angular-library/blob/main/projects/photo-editor/src/lib/pages/core.scss).
|
|
23
|
+
|
|
24
|
+
## Toolbar color scheme
|
|
25
|
+
|
|
26
|
+
`PhotoEditorPage` and `PhotoViewerPage` require `toolbarColorScheme: 'light' | 'dark'` in modal `componentProps`. Select `dark` for a dark/black `ion-toolbar` and `light` for a light/white toolbar. The consumer must choose because the library cannot reliably infer the final toolbar appearance from CSS, translucency, or runtime theme overrides.
|
|
27
|
+
|
|
28
|
+
For `@rdlabo/ionic-theme-ios26` v3, import the optional integration stylesheet after the iOS 26 theme and dark-mode styles:
|
|
29
|
+
|
|
30
|
+
```scss
|
|
31
|
+
@import '@rdlabo/ionic-theme-ios26/dist/css/ionic-theme-ios26.css';
|
|
32
|
+
@import '@ionic/angular/css/palettes/dark.class.css';
|
|
33
|
+
@import '@rdlabo/ionic-theme-ios26/dist/css/ionic-theme-ios26-dark-class.css';
|
|
34
|
+
@import '@rdlabo/ionic-angular-photo-editor/css/ios26-header-button-color-scheme.css';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Use the matching Always or System dark-mode import instead when appropriate. The photo-editor integration stylesheet must remain last so its local header scheme can override the ambient application scheme. Applications that do not use the iOS 26 theme should not import this optional stylesheet; they receive only the regular Ionic button foreground-color switch.
|
package/docs/viewer.md
CHANGED
|
@@ -1,49 +1,84 @@
|
|
|
1
1
|
Present `PhotoViewerPage` in an Ionic modal. Call this after [Installation](../README.md#installation).
|
|
2
2
|
|
|
3
3
|
```typescript
|
|
4
|
-
import {
|
|
4
|
+
import { PhotoViewerProps, PhotoViewerResult } from '@rdlabo/ionic-angular-photo-editor';
|
|
5
|
+
import { PhotoViewerPage } from '@rdlabo/ionic-angular-photo-editor/viewer';
|
|
5
6
|
|
|
6
7
|
(async () => {
|
|
8
|
+
const componentProps = {
|
|
9
|
+
imageUrls: ['https://picsum.photos/200/300', 'https://picsum.photos/200/301'],
|
|
10
|
+
index: 0,
|
|
11
|
+
isCircle: false,
|
|
12
|
+
enableDelete: true,
|
|
13
|
+
toolbarColorScheme: 'dark',
|
|
14
|
+
imageAlt: (url, index) => `Photo ${index + 1}`,
|
|
15
|
+
labels: {
|
|
16
|
+
delete: 'Delete',
|
|
17
|
+
},
|
|
18
|
+
} satisfies PhotoViewerProps;
|
|
7
19
|
const modal = await this.modalCtrl.create({
|
|
8
20
|
component: PhotoViewerPage,
|
|
9
|
-
componentProps
|
|
10
|
-
imageUrls: ['https://picsum.photos/200/300', 'https://picsum.photos/200/300'],
|
|
11
|
-
index: 0,
|
|
12
|
-
isCircle: false,
|
|
13
|
-
},
|
|
21
|
+
componentProps,
|
|
14
22
|
});
|
|
15
23
|
await modal.present();
|
|
16
|
-
const { data } = await modal.onWillDismiss<
|
|
17
|
-
if (data?.delete) {
|
|
18
|
-
|
|
24
|
+
const { data } = await modal.onWillDismiss<PhotoViewerResult>();
|
|
25
|
+
if (data?.action === 'delete') {
|
|
26
|
+
console.log(data.index, data.value);
|
|
19
27
|
}
|
|
20
28
|
})();
|
|
21
29
|
```
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
## Modal result
|
|
32
|
+
|
|
33
|
+
When the user taps delete, the modal dismisses with:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
interface PhotoViewerResult {
|
|
37
|
+
action: 'delete';
|
|
38
|
+
index: number;
|
|
39
|
+
value: string; // URL of the image at index
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Closing or swiping down dismisses with no data.
|
|
44
|
+
|
|
45
|
+
## Options
|
|
46
|
+
|
|
47
|
+
### imageUrls: string[]
|
|
48
|
+
|
|
49
|
+
**Required.** Image URLs or data URLs to display.
|
|
50
|
+
|
|
51
|
+
### index: number
|
|
52
|
+
|
|
53
|
+
Initial slide index. Default `0`.
|
|
54
|
+
|
|
55
|
+
### isCircle: boolean
|
|
24
56
|
|
|
25
|
-
|
|
57
|
+
When `true`, images render in a circle.
|
|
26
58
|
|
|
27
|
-
|
|
59
|
+
### enableDelete: boolean
|
|
28
60
|
|
|
29
|
-
|
|
61
|
+
When `true`, shows the delete button.
|
|
30
62
|
|
|
31
|
-
|
|
63
|
+
### enableFooterSafeArea: boolean
|
|
32
64
|
|
|
33
|
-
|
|
65
|
+
When `true`, adds footer safe-area padding on iOS.
|
|
34
66
|
|
|
35
|
-
|
|
67
|
+
### toolbarColorScheme: 'light' | 'dark'
|
|
36
68
|
|
|
37
|
-
|
|
69
|
+
**Required.** Use `dark` for a dark/black `ion-toolbar` and `light` for a light/white toolbar. See [Theme](./theme.md).
|
|
38
70
|
|
|
39
|
-
|
|
71
|
+
### imageAlt: string | ((url: string, index: number) => string)
|
|
40
72
|
|
|
41
|
-
|
|
73
|
+
Accessible `alt` text for each slide image. Default is an empty string. Pass a function when alt text depends on the URL or index.
|
|
42
74
|
|
|
43
|
-
|
|
75
|
+
### labels: Partial<PhotoViewerLabels>
|
|
44
76
|
|
|
45
|
-
|
|
77
|
+
Overrides default UI strings. Unspecified keys keep the built-in Japanese defaults:
|
|
46
78
|
|
|
47
|
-
|
|
79
|
+
| Key | Default (ja) |
|
|
80
|
+
| ------ | ------------ |
|
|
81
|
+
| close | 閉じる |
|
|
82
|
+
| delete | 削除 |
|
|
48
83
|
|
|
49
|
-
|
|
84
|
+
The close button also uses `aria-label` from the `close` label.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Creates a TUI Image Editor adapter in a bundler-resolvable lazy chunk. */
|
|
2
|
+
const createTuiImageEditor = async (host, options) => {
|
|
3
|
+
const { default: ImageEditor } = await import('tui-image-editor');
|
|
4
|
+
return new ImageEditor(host, options);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generated bundle index. Do not edit.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export { createTuiImageEditor };
|
|
12
|
+
//# sourceMappingURL=rdlabo-ionic-angular-photo-editor-editor-tui.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rdlabo-ionic-angular-photo-editor-editor-tui.mjs","sources":["../../../projects/photo-editor/editor/tui/src/public-api.ts","../../../projects/photo-editor/editor/tui/src/rdlabo-ionic-angular-photo-editor-editor-tui.ts"],"sourcesContent":["import { PhotoImageEditorFactory } from '@rdlabo/ionic-angular-photo-editor';\n\n/** Creates a TUI Image Editor adapter in a bundler-resolvable lazy chunk. */\nexport const createTuiImageEditor: PhotoImageEditorFactory = async (host, options) => {\n const { default: ImageEditor } = await import('tui-image-editor');\n return new ImageEditor(host, options);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEA;AACO,MAAM,oBAAoB,GAA4B,OAAO,IAAI,EAAE,OAAO,KAAI;IACnF,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,OAAO,kBAAkB,CAAC;AACjE,IAAA,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC;AACvC;;ACNA;;AAEG;;;;"}
|