@rdlabo/ionic-angular-photo-editor 21.6.10 → 21.7.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/README.md CHANGED
@@ -1,13 +1,36 @@
1
1
  # @rdlabo/ionic-angular-photo-editor
2
2
 
3
+ ## Overview
4
+
3
5
  This is a photo editor and viewer for modal page of Ionic Angular project using Capacitor.
4
6
 
5
- **Documentation:** [Read the full documentation](https://docs.rdlabo.dev/projects/ionic-angular-photo-editor)
7
+ ## Features
8
+
9
+ ### Choose by editing goal
10
+
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
+
18
+ ## Quick start
19
+
20
+ After [Installation](#installation), load a photo:
21
+
22
+ ```typescript
23
+ import { PhotoFileService } from '@rdlabo/ionic-angular-photo-editor';
24
+
25
+ const files = await this.photoFileService.loadPhoto(1);
26
+ ```
27
+
28
+ Then present the editor or viewer. Details: [PhotoFileService](./docs/photo-file.md), [Photo Editor](./docs/editor.md), [Photo Viewer](./docs/viewer.md).
6
29
 
7
30
  ## Installation
8
31
 
9
32
  ```bash
10
- npm install @rdlabo/ionic-angular-photo-editor
33
+ npm install @rdlabo/ionic-angular-photo-editor
11
34
  ```
12
35
 
13
36
  If you use capacitor, you need to install plugin:
@@ -26,154 +49,16 @@ If you public your project to the web, you need to add the following input tag t
26
49
  </div>
27
50
  ```
28
51
 
29
- ## Theme
30
-
31
- Default color is set, but user can overwrite it: https://github.com/rdlabo-dev/ionic-angular-library/blob/main/projects/photo-editor/src/lib/pages/core.scss
32
-
33
- ### How to overwrite
34
-
35
- ```scss
36
- :root {
37
- --ion-photo-editor-background: #2a2a2a;
38
- --ion-photo-editor-background-tint: #414141;
39
-
40
- --ion-photo-editor-color: #f0f0f0;
41
- --ion-photo-editor-color-tint: #dbdbdb;
42
-
43
- --ion-photo-editor-primary: #4d8dff;
44
- --ion-photo-editor-danger: #f24c58;
45
- --ion-photo-editor-success: #2dd55b;
46
- }
47
- ```
48
-
49
- ## Usage
50
-
51
- ### PhotoFileService
52
-
53
- ```typescript
54
- import { PhotoFileService } from '@rdlabo/ionic-angular-photo-editor';
55
-
56
- export class AppComponent {
57
- private photoFileService = inject(PhotoFileService);
58
-
59
- constructor() {
60
- this.photoFileService.photoMaxSize = 1000;
61
- this.photoFileService.labels = {
62
- camera: 'Camera',
63
- album: 'Album',
64
- cancel: 'Cancel',
65
- };
66
- }
67
-
68
- async upload() {
69
- const file = await this.photoFileService.loadPhoto();
70
- if (file) {
71
- // upload file
72
- }
73
- }
74
- }
75
- ````
76
-
77
- #### Options
78
- ##### photoMaxSize
79
-
80
- The maximum size of the photo. Default is 1000.
81
-
82
- ##### labels
83
-
84
- If set, the label is overwritten.
85
-
86
-
87
- ### PhotoEditorPage
88
-
89
- ```typescript
90
- import { PhotoEditorPage, IPhotoEditorDismiss } from '@rdlabo/ionic-angular-photo-editor';
91
-
92
- (async () => {
93
- const modal = await this.modalCtrl.create({
94
- component: PhotoEditorPage,
95
- componentProps: {
96
- requireSquare: false,
97
- value: 'https://picsum.photos/200/300',
98
- label: {
99
- save: '送信', // change '保存' to '送信'
100
- },
101
- },
102
- });
103
- await modal.present();
104
- const { data } = await modal.onWillDismiss<IPhotoEditorDismiss>();
105
- if (data?.value) {
106
- console.log(data.value);
107
- }
108
- })();
109
- ```
110
-
111
- ### Options
112
-
113
- #### requireSquare: boolean
114
-
115
- If true, the image must be cropped to a square at first.
116
-
117
- #### value: string
118
-
119
- The image url or base64 string.
120
-
121
- #### labels: IDictionaryForEditor
122
-
123
- If set, the label is overwritten.
124
-
125
- List is [here](https://github.com/rdlabo-dev/ionic-angular-library/blob/main/projects/photo-editor/src/lib/dictionaries.ts).
126
-
127
-
128
- ### PhotoViewerPage
129
-
130
- ```typescript
131
- import { PhotoViewerPage, IPhotoViewerDismiss } from '@rdlabo/ionic-angular-photo-editor';
132
-
133
- (async () => {
134
- const modal = await this.modalCtrl.create({
135
- component: PhotoViewerPage,
136
- componentProps: {
137
- imageUrls: [
138
- 'https://picsum.photos/200/300',
139
- 'https://picsum.photos/200/300',
140
- ],
141
- index: 0,
142
- isCircle: false,
143
- },
144
- });
145
- await modal.present();
146
- const { data } = await modal.onWillDismiss<IPhotoViewerDismiss>();
147
- if (data?.delete) {
148
- // User delete image
149
- }
150
- })();
151
- ```
152
-
153
- ### Options
154
-
155
- #### imageUrls: string[]
156
-
157
- The image url or base64 string[].
158
-
159
- #### index: number
160
-
161
- The index of imageUrls.
162
-
163
- #### isCircle: boolean
164
-
165
- If set, the image is displayed in a circle.
166
-
167
- #### enableDelete: boolean
168
-
169
- If true, the delete button is displayed.
170
-
171
- #### enableFooterSafeArea: boolean
172
52
 
173
- If true, enable footer safe area for iOS.
53
+ ## Documentation
174
54
 
175
- #### labels: IDictionaryForViewer
55
+ Start with [Installation](#installation), then pick a guide.
176
56
 
177
- If set, the label is overwritten.
57
+ - [PhotoFileService](./docs/photo-file.md) — camera and album.
58
+ - [Photo Editor](./docs/editor.md) — crop and edit in a modal.
59
+ - [Photo Viewer](./docs/viewer.md) — browse images in a modal.
60
+ - [Theme](./docs/theme.md) — CSS variables.
178
61
 
179
- List is [here](https://github.com/rdlabo-dev/ionic-angular-library/blob/main/projects/photo-editor/src/lib/dictionaries.ts).
62
+ <!-- rdlabo-docs-omit -->
63
+ **Full documentation:** [https://docs.rdlabo.dev/projects/ionic-angular-photo-editor](https://docs.rdlabo.dev/projects/ionic-angular-photo-editor)
64
+ <!-- /rdlabo-docs-omit -->
package/docs/editor.md ADDED
@@ -0,0 +1,39 @@
1
+ Present `PhotoEditorPage` in an Ionic modal. Call this after [Installation](../README.md#installation).
2
+
3
+ ```typescript
4
+ import { PhotoEditorPage, IPhotoEditorDismiss } from '@rdlabo/ionic-angular-photo-editor';
5
+
6
+ (async () => {
7
+ const modal = await this.modalCtrl.create({
8
+ component: PhotoEditorPage,
9
+ componentProps: {
10
+ requireSquare: false,
11
+ value: 'https://picsum.photos/200/300',
12
+ labels: {
13
+ save: '送信', // change '保存' to '送信'
14
+ },
15
+ },
16
+ });
17
+ await modal.present();
18
+ const { data } = await modal.onWillDismiss<IPhotoEditorDismiss>();
19
+ if (data?.value) {
20
+ console.log(data.value);
21
+ }
22
+ })();
23
+ ```
24
+
25
+ ### Options
26
+
27
+ #### requireSquare: boolean
28
+
29
+ If true, the image must be cropped to a square at first.
30
+
31
+ #### value: string
32
+
33
+ The image url or base64 string.
34
+
35
+ #### labels: IDictionaryForEditor
36
+
37
+ If set, the label is overwritten.
38
+
39
+ List is [here](https://github.com/rdlabo-dev/ionic-angular-library/blob/v21.6.2/projects/photo-editor/src/lib/dictionaries.ts).
@@ -0,0 +1,35 @@
1
+ Load photos from the camera or album. Call this after [Installation](../README.md#installation).
2
+
3
+ ```typescript
4
+ import { PhotoFileService } from '@rdlabo/ionic-angular-photo-editor';
5
+
6
+ export class AppComponent {
7
+ private photoFileService = inject(PhotoFileService);
8
+
9
+ constructor() {
10
+ this.photoFileService.photoMaxSize = 1000;
11
+ this.photoFileService.labels = {
12
+ camera: 'Camera',
13
+ album: 'Album',
14
+ cancel: 'Cancel',
15
+ };
16
+ }
17
+
18
+ async upload() {
19
+ const files = await this.photoFileService.loadPhoto(1);
20
+ if (files.length > 0) {
21
+ // upload files
22
+ }
23
+ }
24
+ }
25
+ ```
26
+
27
+ #### Options
28
+
29
+ ##### photoMaxSize
30
+
31
+ The maximum size of the photo. Default is 1000.
32
+
33
+ ##### labels
34
+
35
+ If set, the label is overwritten.
package/docs/theme.md ADDED
@@ -0,0 +1,19 @@
1
+ Override the editor colors after [Installation](../README.md#installation).
2
+
3
+ Default color is set, but user can overwrite it: https://github.com/rdlabo-dev/ionic-angular-library/blob/v21.6.2/projects/photo-editor/src/lib/pages/core.scss
4
+
5
+ ## How to overwrite
6
+
7
+ ```scss
8
+ :root {
9
+ --ion-photo-editor-background: #2a2a2a;
10
+ --ion-photo-editor-background-tint: #414141;
11
+
12
+ --ion-photo-editor-color: #f0f0f0;
13
+ --ion-photo-editor-color-tint: #dbdbdb;
14
+
15
+ --ion-photo-editor-primary: #4d8dff;
16
+ --ion-photo-editor-danger: #f24c58;
17
+ --ion-photo-editor-success: #2dd55b;
18
+ }
19
+ ```
package/docs/viewer.md ADDED
@@ -0,0 +1,49 @@
1
+ Present `PhotoViewerPage` in an Ionic modal. Call this after [Installation](../README.md#installation).
2
+
3
+ ```typescript
4
+ import { PhotoViewerPage, IPhotoViewerDismiss } from '@rdlabo/ionic-angular-photo-editor';
5
+
6
+ (async () => {
7
+ const modal = await this.modalCtrl.create({
8
+ component: PhotoViewerPage,
9
+ componentProps: {
10
+ imageUrls: ['https://picsum.photos/200/300', 'https://picsum.photos/200/300'],
11
+ index: 0,
12
+ isCircle: false,
13
+ },
14
+ });
15
+ await modal.present();
16
+ const { data } = await modal.onWillDismiss<IPhotoViewerDismiss>();
17
+ if (data?.delete) {
18
+ // User delete image
19
+ }
20
+ })();
21
+ ```
22
+
23
+ ### Options
24
+
25
+ #### imageUrls: string[]
26
+
27
+ The image url or base64 string[].
28
+
29
+ #### index: number
30
+
31
+ The index of imageUrls.
32
+
33
+ #### isCircle: boolean
34
+
35
+ If set, the image is displayed in a circle.
36
+
37
+ #### enableDelete: boolean
38
+
39
+ If true, the delete button is displayed.
40
+
41
+ #### enableFooterSafeArea: boolean
42
+
43
+ If true, enable footer safe area for iOS.
44
+
45
+ #### labels: IDictionaryForViewer
46
+
47
+ If set, the label is overwritten.
48
+
49
+ List is [here](https://github.com/rdlabo-dev/ionic-angular-library/blob/v21.6.2/projects/photo-editor/src/lib/dictionaries.ts).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-photo-editor",
3
- "version": "21.6.10",
3
+ "version": "21.7.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:rdlabo-dev/ionic-angular-library.git"