@rageshpikalmunde/rp-image-editor-react 1.5.13 → 1.6.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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/cjs/useRpImageEditor.js +6 -2
- package/dist/cjs/useRpImageEditor.js.map +1 -1
- package/dist/esm/useRpImageEditor.js +7 -3
- package/dist/esm/useRpImageEditor.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/useRpImageEditor.d.ts +4 -2
- package/package.json +22 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rpragesh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @rageshpikalmunde/rp-image-editor-react
|
|
2
|
+
|
|
3
|
+
React image editor and annotation component for [`@rageshpikalmunde/rp-image-editor`](https://www.npmjs.com/package/@rageshpikalmunde/rp-image-editor): crop, rotate, draw, text, arrows, shapes, callouts, filters and multi-image editing. Accessible (WCAG 2.2 AA), mobile-ready, TypeScript.
|
|
4
|
+
|
|
5
|
+
[Live demo](https://rpragesh.github.io/image-editor/) · [React guide](https://rpragesh.github.io/image-editor/react-image-editor/) · [React example on StackBlitz](https://stackblitz.com/github/rpragesh/image-editor/tree/main/examples/react) · [API reference](https://rpragesh.github.io/image-editor/api/) · [Full docs](https://github.com/rpragesh/image-editor#readme)
|
|
6
|
+
|
|
7
|
+
[](https://rpragesh.github.io/image-editor/)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @rageshpikalmunde/rp-image-editor @rageshpikalmunde/rp-image-editor-react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Works with React 17 and newer (Vite, CRA, Next.js, Ionic React).
|
|
16
|
+
|
|
17
|
+
## Open the editor as a modal
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { useRpImageEditor } from '@rageshpikalmunde/rp-image-editor-react';
|
|
21
|
+
|
|
22
|
+
export function PhotoUpload() {
|
|
23
|
+
const { openEditor } = useRpImageEditor();
|
|
24
|
+
|
|
25
|
+
async function onFile(e: React.ChangeEvent<HTMLInputElement>) {
|
|
26
|
+
const file = e.target.files?.[0];
|
|
27
|
+
if (!file) return;
|
|
28
|
+
const result = await openEditor(file, { exportFormat: 'jpeg' });
|
|
29
|
+
if (result) upload(result.file); // also result.blob and result.base64
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <input type="file" accept="image/*" onChange={onFile} />;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`openEditor` resolves with the edited image when the user clicks Apply, or `null` if they close the editor.
|
|
37
|
+
|
|
38
|
+
## Edit several images at once
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
const { openMultiEditor } = useRpImageEditor();
|
|
42
|
+
|
|
43
|
+
const results = await openMultiEditor(files, { exportFormat: 'jpeg' });
|
|
44
|
+
// [{ index, edited, result }] for every image, or null if closed
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
A thumbnail strip switches between images, each keeps its own undo history, and Close asks before discarding edits.
|
|
48
|
+
|
|
49
|
+
## Inline editor
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { RpImageEditorComponent } from '@rageshpikalmunde/rp-image-editor-react';
|
|
53
|
+
|
|
54
|
+
<RpImageEditorComponent
|
|
55
|
+
image={file}
|
|
56
|
+
config={{ language: 'de' }}
|
|
57
|
+
onImageEdited={(result) => upload(result.file)}
|
|
58
|
+
style={{ height: 600 }}
|
|
59
|
+
/>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Passing `onImageEdited` shows the editor's Apply button.
|
|
63
|
+
|
|
64
|
+
## Next.js
|
|
65
|
+
|
|
66
|
+
The editor needs the browser (DOM and canvas). Call `openEditor` from an event handler, or load `RpImageEditorComponent` with `next/dynamic` and `ssr: false`.
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
Every option of the core package works here: themes, 15 languages, which tools to show, crop ratios, filter presets, export format and quality. See the [configuration docs](https://github.com/rpragesh/image-editor/blob/main/packages/core/README.md#configuration).
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT © Ragesh Pikalmunde
|
|
@@ -4,7 +4,8 @@ exports.useRpImageEditor = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const rp_image_editor_1 = require("@rageshpikalmunde/rp-image-editor");
|
|
6
6
|
/**
|
|
7
|
-
* React hook to open the image editor as a modal overlay
|
|
7
|
+
* React hook to open the image editor as a modal overlay
|
|
8
|
+
* (`openEditor` for one image, `openMultiEditor` for several).
|
|
8
9
|
*
|
|
9
10
|
* Usage:
|
|
10
11
|
* ```tsx
|
|
@@ -26,7 +27,10 @@ function useRpImageEditor() {
|
|
|
26
27
|
const openEditor = (0, react_1.useCallback)(async (image, config) => {
|
|
27
28
|
return (0, rp_image_editor_1.openEditorModal)({ image, config });
|
|
28
29
|
}, []);
|
|
29
|
-
|
|
30
|
+
const openMultiEditor = (0, react_1.useCallback)(async (images, config, startIndex) => {
|
|
31
|
+
return (0, rp_image_editor_1.openMultiEditorModal)({ images, config, startIndex });
|
|
32
|
+
}, []);
|
|
33
|
+
return { openEditor, openMultiEditor };
|
|
30
34
|
}
|
|
31
35
|
exports.useRpImageEditor = useRpImageEditor;
|
|
32
36
|
//# sourceMappingURL=useRpImageEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRpImageEditor.js","sourceRoot":"","sources":["../../src/useRpImageEditor.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"useRpImageEditor.js","sourceRoot":"","sources":["../../src/useRpImageEditor.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,uEAM2C;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,UAAU,GAAG,IAAA,mBAAW,EAC5B,KAAK,EACH,KAA2B,EAC3B,MAAgC,EACA,EAAE;QAClC,OAAO,IAAA,iCAAe,EAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,KAAK,EACH,MAAmC,EACnC,MAAgC,EAChC,UAAmB,EACwB,EAAE;QAC7C,OAAO,IAAA,sCAAoB,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACzC,CAAC;AAvBD,4CAuBC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { openEditorModal, } from '@rageshpikalmunde/rp-image-editor';
|
|
2
|
+
import { openEditorModal, openMultiEditorModal, } from '@rageshpikalmunde/rp-image-editor';
|
|
3
3
|
/**
|
|
4
|
-
* React hook to open the image editor as a modal overlay
|
|
4
|
+
* React hook to open the image editor as a modal overlay
|
|
5
|
+
* (`openEditor` for one image, `openMultiEditor` for several).
|
|
5
6
|
*
|
|
6
7
|
* Usage:
|
|
7
8
|
* ```tsx
|
|
@@ -23,6 +24,9 @@ export function useRpImageEditor() {
|
|
|
23
24
|
const openEditor = useCallback(async (image, config) => {
|
|
24
25
|
return openEditorModal({ image, config });
|
|
25
26
|
}, []);
|
|
26
|
-
|
|
27
|
+
const openMultiEditor = useCallback(async (images, config, startIndex) => {
|
|
28
|
+
return openMultiEditorModal({ images, config, startIndex });
|
|
29
|
+
}, []);
|
|
30
|
+
return { openEditor, openMultiEditor };
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=useRpImageEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRpImageEditor.js","sourceRoot":"","sources":["../../src/useRpImageEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"useRpImageEditor.js","sourceRoot":"","sources":["../../src/useRpImageEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAIL,eAAe,EACf,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,UAAU,GAAG,WAAW,CAC5B,KAAK,EACH,KAA2B,EAC3B,MAAgC,EACA,EAAE;QAClC,OAAO,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,eAAe,GAAG,WAAW,CACjC,KAAK,EACH,MAAmC,EACnC,MAAgC,EAChC,UAAmB,EACwB,EAAE;QAC7C,OAAO,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC,EACD,EAAE,CACH,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AACzC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
export { RpImageEditorComponent } from './RpImageEditor';
|
|
6
6
|
export type { RpImageEditorProps } from './RpImageEditor';
|
|
7
7
|
export { useRpImageEditor } from './useRpImageEditor';
|
|
8
|
-
export type { RpEditorConfig, RpEditorTheme, RpEditorResult, CropAspectRatio, EditorMode, } from '@rageshpikalmunde/rp-image-editor';
|
|
8
|
+
export type { RpEditorConfig, RpEditorTheme, RpEditorResult, RpMultiEditorItemResult, CropAspectRatio, EditorMode, } from '@rageshpikalmunde/rp-image-editor';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-editor';
|
|
1
|
+
import { RpEditorConfig, RpEditorResult, RpMultiEditorItemResult } from '@rageshpikalmunde/rp-image-editor';
|
|
2
2
|
/**
|
|
3
|
-
* React hook to open the image editor as a modal overlay
|
|
3
|
+
* React hook to open the image editor as a modal overlay
|
|
4
|
+
* (`openEditor` for one image, `openMultiEditor` for several).
|
|
4
5
|
*
|
|
5
6
|
* Usage:
|
|
6
7
|
* ```tsx
|
|
@@ -20,4 +21,5 @@ import { RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-edito
|
|
|
20
21
|
*/
|
|
21
22
|
export declare function useRpImageEditor(): {
|
|
22
23
|
openEditor: (image: File | Blob | string, config?: Partial<RpEditorConfig>) => Promise<RpEditorResult | null>;
|
|
24
|
+
openMultiEditor: (images: Array<File | Blob | string>, config?: Partial<RpEditorConfig>, startIndex?: number) => Promise<RpMultiEditorItemResult[] | null>;
|
|
23
25
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rageshpikalmunde/rp-image-editor-react",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "React
|
|
3
|
+
"version": "1.6.1",
|
|
4
|
+
"description": "React image editor and annotation component (rp-image-editor): crop, rotate, draw, text, shapes, callouts, filters and multi-image editing. Accessible and mobile-ready.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -23,20 +23,24 @@
|
|
|
23
23
|
"clean": "rm -rf dist"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
|
-
"image-editor",
|
|
27
26
|
"react-image-editor",
|
|
28
27
|
"react-photo-editor",
|
|
28
|
+
"react-image-crop",
|
|
29
|
+
"react-image-annotation",
|
|
30
|
+
"image-editor",
|
|
31
|
+
"photo-editor",
|
|
29
32
|
"image-annotation",
|
|
33
|
+
"image-cropper",
|
|
30
34
|
"screenshot-annotation",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"callout",
|
|
35
|
+
"multi-image",
|
|
36
|
+
"image-filters",
|
|
37
|
+
"accessible",
|
|
35
38
|
"fabricjs",
|
|
36
39
|
"react",
|
|
37
40
|
"ionic",
|
|
38
41
|
"ionic-react",
|
|
39
|
-
"capacitor"
|
|
42
|
+
"capacitor",
|
|
43
|
+
"typescript"
|
|
40
44
|
],
|
|
41
45
|
"author": "Ragesh Pikalmunde",
|
|
42
46
|
"license": "MIT",
|
|
@@ -44,7 +48,7 @@
|
|
|
44
48
|
"access": "public"
|
|
45
49
|
},
|
|
46
50
|
"dependencies": {
|
|
47
|
-
"@rageshpikalmunde/rp-image-editor": "^1.
|
|
51
|
+
"@rageshpikalmunde/rp-image-editor": "^1.6.1"
|
|
48
52
|
},
|
|
49
53
|
"peerDependencies": {
|
|
50
54
|
"react": ">=17.0.0",
|
|
@@ -55,5 +59,14 @@
|
|
|
55
59
|
"react-dom": "^18.2.0",
|
|
56
60
|
"@types/react": "^18.2.0",
|
|
57
61
|
"typescript": "~5.3.0"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://rpragesh.github.io/image-editor/react-image-editor/",
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "https://github.com/rpragesh/image-editor.git",
|
|
67
|
+
"directory": "packages/react"
|
|
68
|
+
},
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/rpragesh/image-editor/issues"
|
|
58
71
|
}
|
|
59
72
|
}
|