@phucprime/react-native-image-editor 1.0.3 → 1.0.4
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 +51 -31
- package/android/build.gradle +5 -1
- package/android/src/main/java/ui/photoeditor/RNPhotoEditorModule.java +155 -60
- package/android/src/main/java/ui/photoeditor/RNPhotoEditorPackage.java +50 -12
- package/android/src/newarch/java/ui/photoeditor/RNPhotoEditorSpec.java +10 -2
- package/android/src/oldarch/java/ui/photoeditor/RNPhotoEditorSpec.java +22 -4
- package/ios/RNImageEditor.podspec +39 -8
- package/ios/RNPhotoEditor.mm +32 -6
- package/ios/RNPhotoEditor.swift +178 -95
- package/lib/commonjs/NativeRNPhotoEditor.js +41 -0
- package/lib/commonjs/NativeRNPhotoEditor.js.map +1 -0
- package/lib/commonjs/index.js +142 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeRNPhotoEditor.js +40 -0
- package/lib/module/NativeRNPhotoEditor.js.map +1 -0
- package/lib/module/index.js +140 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/NativeRNPhotoEditor.d.ts +46 -0
- package/lib/typescript/NativeRNPhotoEditor.d.ts.map +1 -0
- package/lib/{index.d.ts → typescript/index.d.ts} +44 -34
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +49 -18
- package/src/NativeRNPhotoEditor.ts +38 -8
- package/src/index.ts +85 -80
- package/android/libs/photo-editor-android-original.jar +0 -0
- package/lib/NativeRNPhotoEditor.d.ts +0 -14
- package/lib/NativeRNPhotoEditor.d.ts.map +0 -1
- package/lib/NativeRNPhotoEditor.js +0 -5
- package/lib/NativeRNPhotoEditor.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -120
- package/lib/index.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import NativeRNPhotoEditor from './NativeRNPhotoEditor';
|
|
2
2
|
|
|
3
|
-
// TurboModuleRegistry.getEnforcing handles both architectures:
|
|
4
|
-
// - New Architecture: Uses TurboModule system directly
|
|
5
|
-
// - Old Architecture: Falls back to NativeModules bridge (RN 0.73+)
|
|
6
|
-
const RNPhotoEditor = NativeRNPhotoEditor;
|
|
7
|
-
|
|
8
3
|
/**
|
|
9
4
|
* Localization strings for the image editor UI.
|
|
5
|
+
* All fields are optional — unset keys fall back to the English defaults.
|
|
10
6
|
*/
|
|
11
7
|
export interface ImageEditorLanguage {
|
|
12
8
|
/** Title for the "Done" button */
|
|
@@ -39,7 +35,9 @@ export interface ImageEditorLanguage {
|
|
|
39
35
|
eraserTitle?: string;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Editor control identifiers that can be hidden via `hiddenControls`.
|
|
40
|
+
*/
|
|
43
41
|
export type EditorControl =
|
|
44
42
|
| 'text'
|
|
45
43
|
| 'clear'
|
|
@@ -53,49 +51,55 @@ export type EditorControl =
|
|
|
53
51
|
* Configuration options for the image editor.
|
|
54
52
|
*/
|
|
55
53
|
export interface ImageEditorConfig {
|
|
56
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Local file path (or file:// URI) of the image to edit.
|
|
56
|
+
* The editor overwrites this file when the user taps Done.
|
|
57
|
+
*/
|
|
57
58
|
path: string;
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
61
|
+
* Hex color strings for the drawing and text colour picker.
|
|
62
|
+
* Accepts #RGB, #RRGGBB, and #AARRGGBB formats.
|
|
63
|
+
* @default DEFAULT_COLORS (13-colour palette)
|
|
62
64
|
*/
|
|
63
65
|
colors?: string[];
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* - iOS: Add to Resources folder
|
|
69
|
-
* - Android: Add to drawable folder
|
|
68
|
+
* Sticker image names from native resources.
|
|
69
|
+
* iOS: main bundle image names. Android: res/drawable/ file names (no extension).
|
|
70
70
|
* @default []
|
|
71
71
|
*/
|
|
72
72
|
stickers?: string[];
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Controls to remove from the editor toolbar.
|
|
76
76
|
* @default []
|
|
77
77
|
*/
|
|
78
78
|
hiddenControls?: EditorControl[];
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Localization
|
|
81
|
+
* Localization overrides for editor UI strings.
|
|
82
|
+
* Unset keys fall back to English defaults.
|
|
82
83
|
*/
|
|
83
84
|
languages?: ImageEditorLanguage;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
87
|
+
* Called when the user saves the edited image.
|
|
88
|
+
* `imagePath` is the local path to the overwritten file.
|
|
89
|
+
* Only used by `ImageEditor.open()` — ignored by `ImageEditor.edit()`.
|
|
88
90
|
*/
|
|
89
91
|
onDone?: (imagePath: string) => void;
|
|
90
92
|
|
|
91
93
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
+
* Called when the user dismisses without saving.
|
|
95
|
+
* Only used by `ImageEditor.open()` — ignored by `ImageEditor.edit()`.
|
|
94
96
|
*/
|
|
95
|
-
onCancel?: (
|
|
97
|
+
onCancel?: () => void;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
// ─── Defaults ────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
/** Built-in 13-colour drawing palette. */
|
|
99
103
|
const DEFAULT_COLORS: string[] = [
|
|
100
104
|
'#000000',
|
|
101
105
|
'#808080',
|
|
@@ -112,7 +116,7 @@ const DEFAULT_COLORS: string[] = [
|
|
|
112
116
|
'#ff00ff',
|
|
113
117
|
];
|
|
114
118
|
|
|
115
|
-
/**
|
|
119
|
+
/** Built-in English UI strings. */
|
|
116
120
|
const DEFAULT_LANGUAGES: Required<ImageEditorLanguage> = {
|
|
117
121
|
doneTitle: 'Done',
|
|
118
122
|
saveTitle: 'Save',
|
|
@@ -131,103 +135,104 @@ const DEFAULT_LANGUAGES: Required<ImageEditorLanguage> = {
|
|
|
131
135
|
eraserTitle: 'Eraser',
|
|
132
136
|
};
|
|
133
137
|
|
|
138
|
+
// ─── Core native call ─────────────────────────────────────────────────────────
|
|
139
|
+
|
|
134
140
|
/**
|
|
135
|
-
*
|
|
141
|
+
* Build the props object and call the native TurboModule.
|
|
142
|
+
*
|
|
143
|
+
* The native module exposes a single `edit(props): Promise<string>` method.
|
|
144
|
+
* This is the only point in the codebase that touches the native boundary,
|
|
145
|
+
* keeping the public API (open / edit) as thin wrappers.
|
|
146
|
+
*/
|
|
147
|
+
function callNative(config: ImageEditorConfig): Promise<string> {
|
|
148
|
+
const {
|
|
149
|
+
path,
|
|
150
|
+
stickers = [],
|
|
151
|
+
hiddenControls = [],
|
|
152
|
+
colors = DEFAULT_COLORS,
|
|
153
|
+
languages,
|
|
154
|
+
} = config;
|
|
155
|
+
|
|
156
|
+
const mergedLanguages: Required<ImageEditorLanguage> = languages
|
|
157
|
+
? { ...DEFAULT_LANGUAGES, ...languages }
|
|
158
|
+
: DEFAULT_LANGUAGES;
|
|
159
|
+
|
|
160
|
+
return NativeRNPhotoEditor.edit({
|
|
161
|
+
path,
|
|
162
|
+
colors,
|
|
163
|
+
hiddenControls,
|
|
164
|
+
stickers,
|
|
165
|
+
languages: mergedLanguages,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* React Native Image Editor — native photo editing for iOS and Android.
|
|
173
|
+
*
|
|
174
|
+
* Supports the New Architecture (Fabric + TurboModules) and the classic bridge.
|
|
136
175
|
*
|
|
137
176
|
* @example
|
|
138
177
|
* ```ts
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* path: '/path/to/image.jpg',
|
|
144
|
-
* onDone: (editedPath) => console.log('Edited:', editedPath),
|
|
145
|
-
* onCancel: () => console.log('Cancelled'),
|
|
178
|
+
* // Promise / async-await (recommended)
|
|
179
|
+
* const saved = await ImageEditor.edit('/path/to/photo.jpg', {
|
|
180
|
+
* colors: ['#ff0000', '#00ff00', '#0000ff'],
|
|
181
|
+
* stickers: ['heart', 'star'],
|
|
146
182
|
* });
|
|
147
183
|
*
|
|
148
|
-
* //
|
|
149
|
-
*
|
|
150
|
-
*
|
|
184
|
+
* // Callback
|
|
185
|
+
* ImageEditor.open({
|
|
186
|
+
* path: '/path/to/photo.jpg',
|
|
187
|
+
* onDone: (path) => console.log('saved:', path),
|
|
188
|
+
* onCancel: () => console.log('cancelled'),
|
|
151
189
|
* });
|
|
152
190
|
* ```
|
|
153
191
|
*/
|
|
154
192
|
class ImageEditor {
|
|
155
193
|
/**
|
|
156
|
-
*
|
|
194
|
+
* Edit an image and receive the result via callbacks.
|
|
157
195
|
*
|
|
158
|
-
* @param config - Editor configuration
|
|
196
|
+
* @param config - Editor configuration including `onDone` / `onCancel`.
|
|
159
197
|
*/
|
|
160
198
|
static open(config: ImageEditorConfig): void {
|
|
161
|
-
|
|
162
|
-
stickers = [],
|
|
163
|
-
hiddenControls = [],
|
|
164
|
-
colors = DEFAULT_COLORS,
|
|
165
|
-
languages,
|
|
166
|
-
onDone,
|
|
167
|
-
onCancel,
|
|
168
|
-
...rest
|
|
169
|
-
} = config;
|
|
170
|
-
|
|
171
|
-
const mergedLanguages = languages
|
|
172
|
-
? { ...DEFAULT_LANGUAGES, ...languages }
|
|
173
|
-
: DEFAULT_LANGUAGES;
|
|
174
|
-
|
|
175
|
-
RNPhotoEditor.Edit(
|
|
176
|
-
{
|
|
177
|
-
colors,
|
|
178
|
-
hiddenControls,
|
|
179
|
-
stickers,
|
|
180
|
-
languages: mergedLanguages,
|
|
181
|
-
...rest,
|
|
182
|
-
},
|
|
183
|
-
(imagePath: string) => {
|
|
184
|
-
onDone?.(imagePath);
|
|
185
|
-
},
|
|
186
|
-
(resultCode: number) => {
|
|
187
|
-
onCancel?.(resultCode);
|
|
188
|
-
},
|
|
189
|
-
);
|
|
199
|
+
callNative(config).then(config.onDone).catch(() => config.onCancel?.());
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
/**
|
|
193
|
-
* Edit an image and return a
|
|
203
|
+
* Edit an image and return a Promise.
|
|
194
204
|
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
205
|
+
* Resolves with the saved image path.
|
|
206
|
+
* Rejects with `{ code: 'CANCELLED' }` when the user dismisses.
|
|
207
|
+
*
|
|
208
|
+
* @param path - Local file path of the image to edit.
|
|
209
|
+
* @param options - Optional editor configuration (excludes path, onDone, onCancel).
|
|
198
210
|
*/
|
|
199
211
|
static edit(
|
|
200
212
|
path: string,
|
|
201
213
|
options?: Omit<ImageEditorConfig, 'path' | 'onDone' | 'onCancel'>,
|
|
202
214
|
): Promise<string> {
|
|
203
|
-
return
|
|
204
|
-
ImageEditor.open({
|
|
205
|
-
...options,
|
|
206
|
-
path,
|
|
207
|
-
onDone: resolve,
|
|
208
|
-
onCancel: (resultCode) =>
|
|
209
|
-
reject(new Error(`Editor cancelled with code: ${resultCode}`)),
|
|
210
|
-
});
|
|
211
|
-
});
|
|
215
|
+
return callNative({ ...options, path });
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
/**
|
|
215
|
-
* @deprecated Use `ImageEditor.open()` instead.
|
|
219
|
+
* @deprecated Use `ImageEditor.open()` instead.
|
|
216
220
|
*/
|
|
217
221
|
static Edit(config: ImageEditorConfig): void {
|
|
218
222
|
ImageEditor.open(config);
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
225
|
|
|
226
|
+
// ─── Exports ──────────────────────────────────────────────────────────────────
|
|
227
|
+
|
|
222
228
|
/**
|
|
223
|
-
* @deprecated Use `ImageEditor` instead.
|
|
229
|
+
* @deprecated Use `ImageEditor` instead.
|
|
224
230
|
*/
|
|
225
231
|
const PhotoEditor = ImageEditor;
|
|
226
232
|
|
|
227
233
|
export { ImageEditor, PhotoEditor };
|
|
228
234
|
export default ImageEditor;
|
|
229
235
|
|
|
230
|
-
// Re-export legacy types for backward compatibility
|
|
231
236
|
/** @deprecated Use `ImageEditorConfig` instead. */
|
|
232
237
|
export type PhotoEditorProps = ImageEditorConfig;
|
|
233
238
|
/** @deprecated Use `ImageEditorLanguage` instead. */
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native';
|
|
2
|
-
/**
|
|
3
|
-
* TurboModule codegen spec for RNPhotoEditor.
|
|
4
|
-
*
|
|
5
|
-
* This spec enables proper New Architecture (Fabric + TurboModules) support
|
|
6
|
-
* with compile-time type validation. On Old Architecture, TurboModuleRegistry
|
|
7
|
-
* falls back to the NativeModules bridge automatically.
|
|
8
|
-
*/
|
|
9
|
-
export interface Spec extends TurboModule {
|
|
10
|
-
Edit(props: Object, onDone: (result: string) => void, onCancel: (result: number) => void): void;
|
|
11
|
-
}
|
|
12
|
-
declare const _default: Spec;
|
|
13
|
-
export default _default;
|
|
14
|
-
//# sourceMappingURL=NativeRNPhotoEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeRNPhotoEditor.d.ts","sourceRoot":"","sources":["../src/NativeRNPhotoEditor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD;;;;;;GAMG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,IAAI,CACF,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,EAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACjC,IAAI,CAAC;CACT;;AAED,wBAAuE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeRNPhotoEditor.js","sourceRoot":"","sources":["../src/NativeRNPhotoEditor.ts"],"names":[],"mappings":";;AACA,+CAAmD;AAiBnD,kBAAe,kCAAmB,CAAC,YAAY,CAAO,eAAe,CAAC,CAAC"}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kDAAkD;IAClD,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wDAAwD;AACxD,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IAEjC;;OAEG;IACH,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAEhC;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAsCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAM,WAAW;IACf;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAgC5C;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CACT,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC,GAChE,OAAO,CAAC,MAAM,CAAC;IAYlB;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;CAG7C;AAED;;GAEG;AACH,QAAA,MAAM,WAAW,oBAAc,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACpC,eAAe,WAAW,CAAC;AAG3B,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AACjD,qDAAqD;AACrD,MAAM,MAAM,QAAQ,GAAG,mBAAmB,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.PhotoEditor = exports.ImageEditor = void 0;
|
|
18
|
-
const NativeRNPhotoEditor_1 = __importDefault(require("./NativeRNPhotoEditor"));
|
|
19
|
-
// TurboModuleRegistry.getEnforcing handles both architectures:
|
|
20
|
-
// - New Architecture: Uses TurboModule system directly
|
|
21
|
-
// - Old Architecture: Falls back to NativeModules bridge (RN 0.73+)
|
|
22
|
-
const RNPhotoEditor = NativeRNPhotoEditor_1.default;
|
|
23
|
-
/** Default color palette for the editor. */
|
|
24
|
-
const DEFAULT_COLORS = [
|
|
25
|
-
'#000000',
|
|
26
|
-
'#808080',
|
|
27
|
-
'#a9a9a9',
|
|
28
|
-
'#FFFFFE',
|
|
29
|
-
'#0000ff',
|
|
30
|
-
'#00ff00',
|
|
31
|
-
'#ff0000',
|
|
32
|
-
'#ffff00',
|
|
33
|
-
'#ffa500',
|
|
34
|
-
'#800080',
|
|
35
|
-
'#00ffff',
|
|
36
|
-
'#a52a2a',
|
|
37
|
-
'#ff00ff',
|
|
38
|
-
];
|
|
39
|
-
/** Default localization strings. */
|
|
40
|
-
const DEFAULT_LANGUAGES = {
|
|
41
|
-
doneTitle: 'Done',
|
|
42
|
-
saveTitle: 'Save',
|
|
43
|
-
clearAllTitle: 'Clear all',
|
|
44
|
-
cameraTitle: 'Camera',
|
|
45
|
-
galleryTitle: 'Gallery',
|
|
46
|
-
uploadDialogTitle: 'Upload Image',
|
|
47
|
-
uploadPickerTitle: 'Select Picture',
|
|
48
|
-
directoryCreateFail: 'Failed to create directory',
|
|
49
|
-
accessMediaPermissionsMsg: 'To attach photos, we need to access media on your device',
|
|
50
|
-
continueTxt: 'Continue',
|
|
51
|
-
notNow: 'NOT NOW',
|
|
52
|
-
mediaAccessDeniedMsg: 'You denied storage access, no photos will be added.',
|
|
53
|
-
saveImageSucceed: 'Image saved',
|
|
54
|
-
eraserTitle: 'Eraser',
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* React Native Image Editor - Native photo editing bridge for iOS and Android.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* import { ImageEditor } from '@phucprime/react-native-image-editor';
|
|
62
|
-
*
|
|
63
|
-
* // Callback-based usage
|
|
64
|
-
* ImageEditor.open({
|
|
65
|
-
* path: '/path/to/image.jpg',
|
|
66
|
-
* onDone: (editedPath) => console.log('Edited:', editedPath),
|
|
67
|
-
* onCancel: () => console.log('Cancelled'),
|
|
68
|
-
* });
|
|
69
|
-
*
|
|
70
|
-
* // Promise-based usage
|
|
71
|
-
* const editedPath = await ImageEditor.edit('/path/to/image.jpg', {
|
|
72
|
-
* colors: ['#ff0000', '#00ff00', '#0000ff'],
|
|
73
|
-
* });
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
class ImageEditor {
|
|
77
|
-
/**
|
|
78
|
-
* Open the image editor with callback-based API.
|
|
79
|
-
*
|
|
80
|
-
* @param config - Editor configuration options.
|
|
81
|
-
*/
|
|
82
|
-
static open(config) {
|
|
83
|
-
const { stickers = [], hiddenControls = [], colors = DEFAULT_COLORS, languages, onDone, onCancel } = config, rest = __rest(config, ["stickers", "hiddenControls", "colors", "languages", "onDone", "onCancel"]);
|
|
84
|
-
const mergedLanguages = languages
|
|
85
|
-
? Object.assign(Object.assign({}, DEFAULT_LANGUAGES), languages) : DEFAULT_LANGUAGES;
|
|
86
|
-
RNPhotoEditor.Edit(Object.assign({ colors,
|
|
87
|
-
hiddenControls,
|
|
88
|
-
stickers, languages: mergedLanguages }, rest), (imagePath) => {
|
|
89
|
-
onDone === null || onDone === void 0 ? void 0 : onDone(imagePath);
|
|
90
|
-
}, (resultCode) => {
|
|
91
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel(resultCode);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Edit an image and return a promise with the edited image path.
|
|
96
|
-
*
|
|
97
|
-
* @param path - Path to the image file to edit.
|
|
98
|
-
* @param options - Optional editor configuration (excluding path, onDone, onCancel).
|
|
99
|
-
* @returns Promise that resolves with the edited image path, or rejects if cancelled.
|
|
100
|
-
*/
|
|
101
|
-
static edit(path, options) {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
ImageEditor.open(Object.assign(Object.assign({}, options), { path, onDone: resolve, onCancel: (resultCode) => reject(new Error(`Editor cancelled with code: ${resultCode}`)) }));
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @deprecated Use `ImageEditor.open()` instead. This method is kept for backward compatibility.
|
|
108
|
-
*/
|
|
109
|
-
static Edit(config) {
|
|
110
|
-
ImageEditor.open(config);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.ImageEditor = ImageEditor;
|
|
114
|
-
/**
|
|
115
|
-
* @deprecated Use `ImageEditor` instead. `PhotoEditor` is an alias kept for backward compatibility.
|
|
116
|
-
*/
|
|
117
|
-
const PhotoEditor = ImageEditor;
|
|
118
|
-
exports.PhotoEditor = PhotoEditor;
|
|
119
|
-
exports.default = ImageEditor;
|
|
120
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,g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