@rageshpikalmunde/rp-image-editor-angular 1.1.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/dist/cjs/index.js +17 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/rp-image-editor.component.js +132 -0
- package/dist/cjs/lib/rp-image-editor.component.js.map +1 -0
- package/dist/cjs/lib/rp-image-editor.module.js +36 -0
- package/dist/cjs/lib/rp-image-editor.module.js.map +1 -0
- package/dist/cjs/lib/rp-image-editor.service.js +52 -0
- package/dist/cjs/lib/rp-image-editor.service.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/rp-image-editor.component.js +129 -0
- package/dist/esm/lib/rp-image-editor.component.js.map +1 -0
- package/dist/esm/lib/rp-image-editor.module.js +33 -0
- package/dist/esm/lib/rp-image-editor.module.js.map +1 -0
- package/dist/esm/lib/rp-image-editor.service.js +49 -0
- package/dist/esm/lib/rp-image-editor.service.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/lib/rp-image-editor.component.d.ts +40 -0
- package/dist/types/lib/rp-image-editor.module.d.ts +8 -0
- package/dist/types/lib/rp-image-editor.service.d.ts +30 -0
- package/package.json +47 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @rageshpikalmunde/rp-image-editor-angular
|
|
4
|
+
* Angular wrapper for the rp-image-editor plugin
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RpImageEditorService = exports.RpImageEditorComponent = exports.RpImageEditorModule = void 0;
|
|
8
|
+
// Module
|
|
9
|
+
var rp_image_editor_module_1 = require("./lib/rp-image-editor.module");
|
|
10
|
+
Object.defineProperty(exports, "RpImageEditorModule", { enumerable: true, get: function () { return rp_image_editor_module_1.RpImageEditorModule; } });
|
|
11
|
+
// Component
|
|
12
|
+
var rp_image_editor_component_1 = require("./lib/rp-image-editor.component");
|
|
13
|
+
Object.defineProperty(exports, "RpImageEditorComponent", { enumerable: true, get: function () { return rp_image_editor_component_1.RpImageEditorComponent; } });
|
|
14
|
+
// Service
|
|
15
|
+
var rp_image_editor_service_1 = require("./lib/rp-image-editor.service");
|
|
16
|
+
Object.defineProperty(exports, "RpImageEditorService", { enumerable: true, get: function () { return rp_image_editor_service_1.RpImageEditorService; } });
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,SAAS;AACT,uEAAmE;AAA1D,6HAAA,mBAAmB,OAAA;AAE5B,YAAY;AACZ,6EAAyE;AAAhE,mIAAA,sBAAsB,OAAA;AAE/B,UAAU;AACV,yEAAqE;AAA5D,+HAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RpImageEditorComponent = void 0;
|
|
13
|
+
const core_1 = require("@angular/core");
|
|
14
|
+
const rp_image_editor_1 = require("@rageshpikalmunde/rp-image-editor");
|
|
15
|
+
let RpImageEditorComponent = class RpImageEditorComponent {
|
|
16
|
+
constructor() {
|
|
17
|
+
/** Image source — File, Blob, or URL string */
|
|
18
|
+
this.image = null;
|
|
19
|
+
/** Editor configuration */
|
|
20
|
+
this.config = {};
|
|
21
|
+
/** Emitted when user clicks Apply — contains the edited image result */
|
|
22
|
+
this.imageEdited = new core_1.EventEmitter();
|
|
23
|
+
/** Emitted when user clicks Close/Cancel */
|
|
24
|
+
this.editorClosed = new core_1.EventEmitter();
|
|
25
|
+
/** Emitted when an error occurs */
|
|
26
|
+
this.editorError = new core_1.EventEmitter();
|
|
27
|
+
this.editor = null;
|
|
28
|
+
}
|
|
29
|
+
ngAfterViewInit() {
|
|
30
|
+
if (this.image) {
|
|
31
|
+
this.initEditor();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
ngOnDestroy() {
|
|
35
|
+
this.destroyEditor();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Programmatically load an image (can be called after component init)
|
|
39
|
+
*/
|
|
40
|
+
async loadImage(source) {
|
|
41
|
+
this.image = source;
|
|
42
|
+
await this.initEditor();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the edited result programmatically
|
|
46
|
+
*/
|
|
47
|
+
async getResult() {
|
|
48
|
+
try {
|
|
49
|
+
return await this.editor?.getResult() ?? null;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
this.editorError.emit(err);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Apply and emit result
|
|
58
|
+
*/
|
|
59
|
+
async apply() {
|
|
60
|
+
const result = await this.getResult();
|
|
61
|
+
if (result) {
|
|
62
|
+
this.imageEdited.emit(result);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Close the editor
|
|
67
|
+
*/
|
|
68
|
+
close() {
|
|
69
|
+
this.destroyEditor();
|
|
70
|
+
this.editorClosed.emit();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reset to original image
|
|
74
|
+
*/
|
|
75
|
+
async reset() {
|
|
76
|
+
await this.editor?.reset();
|
|
77
|
+
}
|
|
78
|
+
async initEditor() {
|
|
79
|
+
this.destroyEditor();
|
|
80
|
+
if (!this.image || !this.containerRef?.nativeElement)
|
|
81
|
+
return;
|
|
82
|
+
this.editor = new rp_image_editor_1.RpImageEditor(this.containerRef.nativeElement, this.config);
|
|
83
|
+
this.editor.on('error', (err) => {
|
|
84
|
+
this.editorError.emit(err);
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
await this.editor.loadImage(this.image);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
this.editorError.emit(err);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
destroyEditor() {
|
|
94
|
+
if (this.editor) {
|
|
95
|
+
this.editor.destroy();
|
|
96
|
+
this.editor = null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.RpImageEditorComponent = RpImageEditorComponent;
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, core_1.ViewChild)('editorContainer', { static: true }),
|
|
103
|
+
__metadata("design:type", core_1.ElementRef)
|
|
104
|
+
], RpImageEditorComponent.prototype, "containerRef", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, core_1.Input)(),
|
|
107
|
+
__metadata("design:type", Object)
|
|
108
|
+
], RpImageEditorComponent.prototype, "image", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, core_1.Input)(),
|
|
111
|
+
__metadata("design:type", Object)
|
|
112
|
+
], RpImageEditorComponent.prototype, "config", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, core_1.Output)(),
|
|
115
|
+
__metadata("design:type", Object)
|
|
116
|
+
], RpImageEditorComponent.prototype, "imageEdited", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, core_1.Output)(),
|
|
119
|
+
__metadata("design:type", Object)
|
|
120
|
+
], RpImageEditorComponent.prototype, "editorClosed", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, core_1.Output)(),
|
|
123
|
+
__metadata("design:type", Object)
|
|
124
|
+
], RpImageEditorComponent.prototype, "editorError", void 0);
|
|
125
|
+
exports.RpImageEditorComponent = RpImageEditorComponent = __decorate([
|
|
126
|
+
(0, core_1.Component)({
|
|
127
|
+
selector: 'rp-image-editor',
|
|
128
|
+
template: `<div #editorContainer class="rp-image-editor-host" [style.width]="'100%'" [style.height]="'100%'" [style.display]="'flex'" [style.flexDirection]="'column'"></div>`,
|
|
129
|
+
styles: [`:host { display: block; width: 100%; height: 100%; } .rp-image-editor-host { min-height: 300px; }`]
|
|
130
|
+
})
|
|
131
|
+
], RpImageEditorComponent);
|
|
132
|
+
//# sourceMappingURL=rp-image-editor.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rp-image-editor.component.js","sourceRoot":"","sources":["../../../src/lib/rp-image-editor.component.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAwH;AACxH,uEAAkG;AAO3F,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAA5B;QAGL,+CAA+C;QACtC,UAAK,GAAgC,IAAI,CAAC;QAEnD,2BAA2B;QAClB,WAAM,GAA4B,EAAE,CAAC;QAE9C,wEAAwE;QAC9D,gBAAW,GAAG,IAAI,mBAAY,EAAkB,CAAC;QAE3D,4CAA4C;QAClC,iBAAY,GAAG,IAAI,mBAAY,EAAQ,CAAC;QAElD,mCAAmC;QACzB,gBAAW,GAAG,IAAI,mBAAY,EAAS,CAAC;QAE1C,WAAM,GAAyB,IAAI,CAAC;IAiF9C,CAAC;IA/EC,eAAe;QACb,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,EAA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AE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAY,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAEO,aAAa;QACnB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF,CAAA;AAnGY,wDAAsB;AACe;IAA/C,IAAA,gBAAS,EAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;8BAAgB,iBAAU;4DAAc;AAG9E;IAAR,IAAA,YAAK,GAAE;;qDAA2C;AAG1C;IAAR,IAAA,YAAK,GAAE;;sDAAsC;AAGpC;IAAT,IAAA,aAAM,GAAE;;2DAAkD;AAGjD;IAAT,IAAA,aAAM,GAAE;;4DAAyC;AAGxC;IAAT,IAAA,aAAM,GAAE;;2DAAyC;iCAhBvC,sBAAsB;IALlC,IAAA,gBAAS,EAAC;QACT,QAAQ,EAAE,iBAAiB;QAC3B,QAAQ,EAAE,oKAAoK;QAC9K,MAAM,EAAE,CAAC,mGAAmG,CAAC;KAC9G,CAAC;GACW,sBAAsB,CAmGlC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var RpImageEditorModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.RpImageEditorModule = void 0;
|
|
11
|
+
const core_1 = require("@angular/core");
|
|
12
|
+
const common_1 = require("@angular/common");
|
|
13
|
+
const rp_image_editor_component_1 = require("./rp-image-editor.component");
|
|
14
|
+
const rp_image_editor_service_1 = require("./rp-image-editor.service");
|
|
15
|
+
let RpImageEditorModule = RpImageEditorModule_1 = class RpImageEditorModule {
|
|
16
|
+
/**
|
|
17
|
+
* Use forRoot() if you want to provide the service at root level
|
|
18
|
+
* (optional — service is already providedIn: 'root')
|
|
19
|
+
*/
|
|
20
|
+
static forRoot() {
|
|
21
|
+
return {
|
|
22
|
+
ngModule: RpImageEditorModule_1,
|
|
23
|
+
providers: [rp_image_editor_service_1.RpImageEditorService],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.RpImageEditorModule = RpImageEditorModule;
|
|
28
|
+
exports.RpImageEditorModule = RpImageEditorModule = RpImageEditorModule_1 = __decorate([
|
|
29
|
+
(0, core_1.NgModule)({
|
|
30
|
+
declarations: [rp_image_editor_component_1.RpImageEditorComponent],
|
|
31
|
+
imports: [common_1.CommonModule],
|
|
32
|
+
exports: [rp_image_editor_component_1.RpImageEditorComponent],
|
|
33
|
+
providers: [rp_image_editor_service_1.RpImageEditorService],
|
|
34
|
+
})
|
|
35
|
+
], RpImageEditorModule);
|
|
36
|
+
//# sourceMappingURL=rp-image-editor.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rp-image-editor.module.js","sourceRoot":"","sources":["../../../src/lib/rp-image-editor.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAA8D;AAC9D,4CAA+C;AAC/C,2EAAqE;AACrE,uEAAiE;AAQ1D,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAC9B;;;OAGG;IACH,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,QAAQ,EAAE,qBAAmB;YAC7B,SAAS,EAAE,CAAC,8CAAoB,CAAC;SAClC,CAAC;IACJ,CAAC;CACF,CAAA;AAXY,kDAAmB;8BAAnB,mBAAmB;IAN/B,IAAA,eAAQ,EAAC;QACR,YAAY,EAAE,CAAC,kDAAsB,CAAC;QACtC,OAAO,EAAE,CAAC,qBAAY,CAAC;QACvB,OAAO,EAAE,CAAC,kDAAsB,CAAC;QACjC,SAAS,EAAE,CAAC,8CAAoB,CAAC;KAClC,CAAC;GACW,mBAAmB,CAW/B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RpImageEditorService = void 0;
|
|
10
|
+
const core_1 = require("@angular/core");
|
|
11
|
+
const rp_image_editor_1 = require("@rageshpikalmunde/rp-image-editor");
|
|
12
|
+
/**
|
|
13
|
+
* Service to open the image editor as a modal overlay.
|
|
14
|
+
* Works with or without Ionic — uses the core modal implementation.
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* ```ts
|
|
18
|
+
* constructor(private rpEditor: RpImageEditorService) {}
|
|
19
|
+
*
|
|
20
|
+
* async editImage(file: File) {
|
|
21
|
+
* const result = await this.rpEditor.openEditor(file, {
|
|
22
|
+
* theme: { applyButtonBackground: '#28a745' }
|
|
23
|
+
* });
|
|
24
|
+
* if (result) {
|
|
25
|
+
* // result.file — upload to server
|
|
26
|
+
* // result.base64 — preview
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
let RpImageEditorService = class RpImageEditorService {
|
|
32
|
+
/**
|
|
33
|
+
* Open the image editor in a modal popup.
|
|
34
|
+
*
|
|
35
|
+
* @param image - File, Blob, or URL string to edit
|
|
36
|
+
* @param config - Optional editor configuration (theme, crop ratios, etc.)
|
|
37
|
+
* @returns Promise resolving to RpEditorResult if applied, or null if cancelled
|
|
38
|
+
*/
|
|
39
|
+
async openEditor(image, config) {
|
|
40
|
+
return (0, rp_image_editor_1.openEditorModal)({
|
|
41
|
+
image,
|
|
42
|
+
config,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.RpImageEditorService = RpImageEditorService;
|
|
47
|
+
exports.RpImageEditorService = RpImageEditorService = __decorate([
|
|
48
|
+
(0, core_1.Injectable)({
|
|
49
|
+
providedIn: 'root',
|
|
50
|
+
})
|
|
51
|
+
], RpImageEditorService);
|
|
52
|
+
//# sourceMappingURL=rp-image-editor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rp-image-editor.service.js","sourceRoot":"","sources":["../../../src/lib/rp-image-editor.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,wCAA2C;AAC3C,uEAI2C;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AAII,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CACd,KAA2B,EAC3B,MAAgC;QAEhC,OAAO,IAAA,iCAAe,EAAC;YACrB,KAAK;YACL,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBY,oDAAoB;+BAApB,oBAAoB;IAHhC,IAAA,iBAAU,EAAC;QACV,UAAU,EAAE,MAAM;KACnB,CAAC;GACW,oBAAoB,CAiBhC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rageshpikalmunde/rp-image-editor-angular
|
|
3
|
+
* Angular wrapper for the rp-image-editor plugin
|
|
4
|
+
*/
|
|
5
|
+
// Module
|
|
6
|
+
export { RpImageEditorModule } from './lib/rp-image-editor.module';
|
|
7
|
+
// Component
|
|
8
|
+
export { RpImageEditorComponent } from './lib/rp-image-editor.component';
|
|
9
|
+
// Service
|
|
10
|
+
export { RpImageEditorService } from './lib/rp-image-editor.service';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,SAAS;AACT,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,YAAY;AACZ,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,UAAU;AACV,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
|
11
|
+
import { RpImageEditor } from '@rageshpikalmunde/rp-image-editor';
|
|
12
|
+
let RpImageEditorComponent = class RpImageEditorComponent {
|
|
13
|
+
constructor() {
|
|
14
|
+
/** Image source — File, Blob, or URL string */
|
|
15
|
+
this.image = null;
|
|
16
|
+
/** Editor configuration */
|
|
17
|
+
this.config = {};
|
|
18
|
+
/** Emitted when user clicks Apply — contains the edited image result */
|
|
19
|
+
this.imageEdited = new EventEmitter();
|
|
20
|
+
/** Emitted when user clicks Close/Cancel */
|
|
21
|
+
this.editorClosed = new EventEmitter();
|
|
22
|
+
/** Emitted when an error occurs */
|
|
23
|
+
this.editorError = new EventEmitter();
|
|
24
|
+
this.editor = null;
|
|
25
|
+
}
|
|
26
|
+
ngAfterViewInit() {
|
|
27
|
+
if (this.image) {
|
|
28
|
+
this.initEditor();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
ngOnDestroy() {
|
|
32
|
+
this.destroyEditor();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Programmatically load an image (can be called after component init)
|
|
36
|
+
*/
|
|
37
|
+
async loadImage(source) {
|
|
38
|
+
this.image = source;
|
|
39
|
+
await this.initEditor();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the edited result programmatically
|
|
43
|
+
*/
|
|
44
|
+
async getResult() {
|
|
45
|
+
try {
|
|
46
|
+
return await this.editor?.getResult() ?? null;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
this.editorError.emit(err);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Apply and emit result
|
|
55
|
+
*/
|
|
56
|
+
async apply() {
|
|
57
|
+
const result = await this.getResult();
|
|
58
|
+
if (result) {
|
|
59
|
+
this.imageEdited.emit(result);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Close the editor
|
|
64
|
+
*/
|
|
65
|
+
close() {
|
|
66
|
+
this.destroyEditor();
|
|
67
|
+
this.editorClosed.emit();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Reset to original image
|
|
71
|
+
*/
|
|
72
|
+
async reset() {
|
|
73
|
+
await this.editor?.reset();
|
|
74
|
+
}
|
|
75
|
+
async initEditor() {
|
|
76
|
+
this.destroyEditor();
|
|
77
|
+
if (!this.image || !this.containerRef?.nativeElement)
|
|
78
|
+
return;
|
|
79
|
+
this.editor = new RpImageEditor(this.containerRef.nativeElement, this.config);
|
|
80
|
+
this.editor.on('error', (err) => {
|
|
81
|
+
this.editorError.emit(err);
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
await this.editor.loadImage(this.image);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
this.editorError.emit(err);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
destroyEditor() {
|
|
91
|
+
if (this.editor) {
|
|
92
|
+
this.editor.destroy();
|
|
93
|
+
this.editor = null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
__decorate([
|
|
98
|
+
ViewChild('editorContainer', { static: true }),
|
|
99
|
+
__metadata("design:type", ElementRef)
|
|
100
|
+
], RpImageEditorComponent.prototype, "containerRef", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
Input(),
|
|
103
|
+
__metadata("design:type", Object)
|
|
104
|
+
], RpImageEditorComponent.prototype, "image", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
Input(),
|
|
107
|
+
__metadata("design:type", Object)
|
|
108
|
+
], RpImageEditorComponent.prototype, "config", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
Output(),
|
|
111
|
+
__metadata("design:type", Object)
|
|
112
|
+
], RpImageEditorComponent.prototype, "imageEdited", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
Output(),
|
|
115
|
+
__metadata("design:type", Object)
|
|
116
|
+
], RpImageEditorComponent.prototype, "editorClosed", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
Output(),
|
|
119
|
+
__metadata("design:type", Object)
|
|
120
|
+
], RpImageEditorComponent.prototype, "editorError", void 0);
|
|
121
|
+
RpImageEditorComponent = __decorate([
|
|
122
|
+
Component({
|
|
123
|
+
selector: 'rp-image-editor',
|
|
124
|
+
template: `<div #editorContainer class="rp-image-editor-host" [style.width]="'100%'" [style.height]="'100%'" [style.display]="'flex'" [style.flexDirection]="'column'"></div>`,
|
|
125
|
+
styles: [`:host { display: block; width: 100%; height: 100%; } .rp-image-editor-host { min-height: 300px; }`]
|
|
126
|
+
})
|
|
127
|
+
], RpImageEditorComponent);
|
|
128
|
+
export { RpImageEditorComponent };
|
|
129
|
+
//# sourceMappingURL=rp-image-editor.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rp-image-editor.component.js","sourceRoot":"","sources":["../../../src/lib/rp-image-editor.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAa,MAAM,EAAE,SAAS,EAAiB,MAAM,eAAe,CAAC;AACxH,OAAO,EAAE,aAAa,EAAkC,MAAM,mCAAmC,CAAC;AAO3F,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAA5B;QAGL,+CAA+C;QACtC,UAAK,GAAgC,IAAI,CAAC;QAEnD,2BAA2B;QAClB,WAAM,GAA4B,EAAE,CAAC;QAE9C,wEAAwE;QAC9D,gBAAW,GAAG,IAAI,YAAY,EAAkB,CAAC;QAE3D,4CAA4C;QAClC,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
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var RpImageEditorModule_1;
|
|
8
|
+
import { NgModule } from '@angular/core';
|
|
9
|
+
import { CommonModule } from '@angular/common';
|
|
10
|
+
import { RpImageEditorComponent } from './rp-image-editor.component';
|
|
11
|
+
import { RpImageEditorService } from './rp-image-editor.service';
|
|
12
|
+
let RpImageEditorModule = RpImageEditorModule_1 = class RpImageEditorModule {
|
|
13
|
+
/**
|
|
14
|
+
* Use forRoot() if you want to provide the service at root level
|
|
15
|
+
* (optional — service is already providedIn: 'root')
|
|
16
|
+
*/
|
|
17
|
+
static forRoot() {
|
|
18
|
+
return {
|
|
19
|
+
ngModule: RpImageEditorModule_1,
|
|
20
|
+
providers: [RpImageEditorService],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
RpImageEditorModule = RpImageEditorModule_1 = __decorate([
|
|
25
|
+
NgModule({
|
|
26
|
+
declarations: [RpImageEditorComponent],
|
|
27
|
+
imports: [CommonModule],
|
|
28
|
+
exports: [RpImageEditorComponent],
|
|
29
|
+
providers: [RpImageEditorService],
|
|
30
|
+
})
|
|
31
|
+
], RpImageEditorModule);
|
|
32
|
+
export { RpImageEditorModule };
|
|
33
|
+
//# sourceMappingURL=rp-image-editor.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rp-image-editor.module.js","sourceRoot":"","sources":["../../../src/lib/rp-image-editor.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAQ1D,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAC9B;;;OAGG;IACH,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,QAAQ,EAAE,qBAAmB;YAC7B,SAAS,EAAE,CAAC,oBAAoB,CAAC;SAClC,CAAC;IACJ,CAAC;CACF,CAAA;AAXY,mBAAmB;IAN/B,QAAQ,CAAC;QACR,YAAY,EAAE,CAAC,sBAAsB,CAAC;QACtC,OAAO,EAAE,CAAC,YAAY,CAAC;QACvB,OAAO,EAAE,CAAC,sBAAsB,CAAC;QACjC,SAAS,EAAE,CAAC,oBAAoB,CAAC;KAClC,CAAC;GACW,mBAAmB,CAW/B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@angular/core';
|
|
8
|
+
import { openEditorModal, } from '@rageshpikalmunde/rp-image-editor';
|
|
9
|
+
/**
|
|
10
|
+
* Service to open the image editor as a modal overlay.
|
|
11
|
+
* Works with or without Ionic — uses the core modal implementation.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```ts
|
|
15
|
+
* constructor(private rpEditor: RpImageEditorService) {}
|
|
16
|
+
*
|
|
17
|
+
* async editImage(file: File) {
|
|
18
|
+
* const result = await this.rpEditor.openEditor(file, {
|
|
19
|
+
* theme: { applyButtonBackground: '#28a745' }
|
|
20
|
+
* });
|
|
21
|
+
* if (result) {
|
|
22
|
+
* // result.file — upload to server
|
|
23
|
+
* // result.base64 — preview
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
let RpImageEditorService = class RpImageEditorService {
|
|
29
|
+
/**
|
|
30
|
+
* Open the image editor in a modal popup.
|
|
31
|
+
*
|
|
32
|
+
* @param image - File, Blob, or URL string to edit
|
|
33
|
+
* @param config - Optional editor configuration (theme, crop ratios, etc.)
|
|
34
|
+
* @returns Promise resolving to RpEditorResult if applied, or null if cancelled
|
|
35
|
+
*/
|
|
36
|
+
async openEditor(image, config) {
|
|
37
|
+
return openEditorModal({
|
|
38
|
+
image,
|
|
39
|
+
config,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
RpImageEditorService = __decorate([
|
|
44
|
+
Injectable({
|
|
45
|
+
providedIn: 'root',
|
|
46
|
+
})
|
|
47
|
+
], RpImageEditorService);
|
|
48
|
+
export { RpImageEditorService };
|
|
49
|
+
//# sourceMappingURL=rp-image-editor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rp-image-editor.service.js","sourceRoot":"","sources":["../../../src/lib/rp-image-editor.service.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAGL,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AAII,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CACd,KAA2B,EAC3B,MAAgC;QAEhC,OAAO,eAAe,CAAC;YACrB,KAAK;YACL,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBY,oBAAoB;IAHhC,UAAU,CAAC;QACV,UAAU,EAAE,MAAM;KACnB,CAAC;GACW,oBAAoB,CAiBhC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rageshpikalmunde/rp-image-editor-angular
|
|
3
|
+
* Angular wrapper for the rp-image-editor plugin
|
|
4
|
+
*/
|
|
5
|
+
export { RpImageEditorModule } from './lib/rp-image-editor.module';
|
|
6
|
+
export { RpImageEditorComponent } from './lib/rp-image-editor.component';
|
|
7
|
+
export { RpImageEditorService } from './lib/rp-image-editor.service';
|
|
8
|
+
export type { RpEditorConfig, RpEditorTheme, RpEditorResult, CropAspectRatio, EditorMode, } from '@rageshpikalmunde/rp-image-editor';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ElementRef, EventEmitter, OnDestroy, AfterViewInit } from '@angular/core';
|
|
2
|
+
import { RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-editor';
|
|
3
|
+
export declare class RpImageEditorComponent implements AfterViewInit, OnDestroy {
|
|
4
|
+
containerRef: ElementRef<HTMLElement>;
|
|
5
|
+
/** Image source — File, Blob, or URL string */
|
|
6
|
+
image: File | Blob | string | null;
|
|
7
|
+
/** Editor configuration */
|
|
8
|
+
config: Partial<RpEditorConfig>;
|
|
9
|
+
/** Emitted when user clicks Apply — contains the edited image result */
|
|
10
|
+
imageEdited: EventEmitter<RpEditorResult>;
|
|
11
|
+
/** Emitted when user clicks Close/Cancel */
|
|
12
|
+
editorClosed: EventEmitter<void>;
|
|
13
|
+
/** Emitted when an error occurs */
|
|
14
|
+
editorError: EventEmitter<Error>;
|
|
15
|
+
private editor;
|
|
16
|
+
ngAfterViewInit(): void;
|
|
17
|
+
ngOnDestroy(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Programmatically load an image (can be called after component init)
|
|
20
|
+
*/
|
|
21
|
+
loadImage(source: File | Blob | string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the edited result programmatically
|
|
24
|
+
*/
|
|
25
|
+
getResult(): Promise<RpEditorResult | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Apply and emit result
|
|
28
|
+
*/
|
|
29
|
+
apply(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Close the editor
|
|
32
|
+
*/
|
|
33
|
+
close(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Reset to original image
|
|
36
|
+
*/
|
|
37
|
+
reset(): Promise<void>;
|
|
38
|
+
private initEditor;
|
|
39
|
+
private destroyEditor;
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
export declare class RpImageEditorModule {
|
|
3
|
+
/**
|
|
4
|
+
* Use forRoot() if you want to provide the service at root level
|
|
5
|
+
* (optional — service is already providedIn: 'root')
|
|
6
|
+
*/
|
|
7
|
+
static forRoot(): ModuleWithProviders<RpImageEditorModule>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-editor';
|
|
2
|
+
/**
|
|
3
|
+
* Service to open the image editor as a modal overlay.
|
|
4
|
+
* Works with or without Ionic — uses the core modal implementation.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ```ts
|
|
8
|
+
* constructor(private rpEditor: RpImageEditorService) {}
|
|
9
|
+
*
|
|
10
|
+
* async editImage(file: File) {
|
|
11
|
+
* const result = await this.rpEditor.openEditor(file, {
|
|
12
|
+
* theme: { applyButtonBackground: '#28a745' }
|
|
13
|
+
* });
|
|
14
|
+
* if (result) {
|
|
15
|
+
* // result.file — upload to server
|
|
16
|
+
* // result.base64 — preview
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class RpImageEditorService {
|
|
22
|
+
/**
|
|
23
|
+
* Open the image editor in a modal popup.
|
|
24
|
+
*
|
|
25
|
+
* @param image - File, Blob, or URL string to edit
|
|
26
|
+
* @param config - Optional editor configuration (theme, crop ratios, etc.)
|
|
27
|
+
* @returns Promise resolving to RpEditorResult if applied, or null if cancelled
|
|
28
|
+
*/
|
|
29
|
+
openEditor(image: File | Blob | string, config?: Partial<RpEditorConfig>): Promise<RpEditorResult | null>;
|
|
30
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rageshpikalmunde/rp-image-editor-angular",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Angular wrapper for rp-image-editor — use inside Ionic+Angular apps",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/esm/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
20
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
21
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
22
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
23
|
+
"clean": "rm -rf dist"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"image-editor",
|
|
27
|
+
"angular",
|
|
28
|
+
"ionic",
|
|
29
|
+
"capacitor"
|
|
30
|
+
],
|
|
31
|
+
"author": "Ragesh Pikalmunde",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@rageshpikalmunde/rp-image-editor": "^1.1.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@angular/core": ">=14.0.0",
|
|
41
|
+
"@angular/common": ">=14.0.0",
|
|
42
|
+
"@ionic/angular": ">=6.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"typescript": "~5.3.0"
|
|
46
|
+
}
|
|
47
|
+
}
|