@rageshpikalmunde/rp-image-editor-angular 1.5.12 → 1.6.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/LICENSE +21 -0
- package/README.md +76 -0
- package/esm2020/index.mjs +11 -0
- package/esm2020/lib/rp-image-editor.component.mjs +113 -0
- package/esm2020/lib/rp-image-editor.module.mjs +30 -0
- package/esm2020/lib/rp-image-editor.service.mjs +57 -0
- package/esm2020/rageshpikalmunde-rp-image-editor-angular.mjs +5 -0
- package/fesm2015/rageshpikalmunde-rp-image-editor-angular.mjs +225 -0
- package/fesm2015/rageshpikalmunde-rp-image-editor-angular.mjs.map +1 -0
- package/fesm2020/rageshpikalmunde-rp-image-editor-angular.mjs +205 -0
- package/fesm2020/rageshpikalmunde-rp-image-editor-angular.mjs.map +1 -0
- package/{dist/types/index.d.ts → index.d.ts} +1 -1
- package/{dist/types/lib → lib}/rp-image-editor.component.d.ts +6 -0
- package/lib/rp-image-editor.module.d.ts +14 -0
- package/{dist/types/lib → lib}/rp-image-editor.service.d.ts +13 -1
- package/package.json +25 -27
- package/dist/cjs/index.js +0 -17
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/lib/rp-image-editor.component.js +0 -132
- package/dist/cjs/lib/rp-image-editor.component.js.map +0 -1
- package/dist/cjs/lib/rp-image-editor.module.js +0 -36
- package/dist/cjs/lib/rp-image-editor.module.js.map +0 -1
- package/dist/cjs/lib/rp-image-editor.service.js +0 -52
- package/dist/cjs/lib/rp-image-editor.service.js.map +0 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/rp-image-editor.component.js +0 -129
- package/dist/esm/lib/rp-image-editor.component.js.map +0 -1
- package/dist/esm/lib/rp-image-editor.module.js +0 -33
- package/dist/esm/lib/rp-image-editor.module.js.map +0 -1
- package/dist/esm/lib/rp-image-editor.service.js +0 -49
- package/dist/esm/lib/rp-image-editor.service.js.map +0 -1
- package/dist/types/lib/rp-image-editor.module.d.ts +0 -8
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, PLATFORM_ID, Component, Inject, ViewChild, Input, Output, Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
4
|
+
import { RpImageEditor, openEditorModal, openMultiEditorModal } from '@rageshpikalmunde/rp-image-editor';
|
|
5
|
+
|
|
6
|
+
class RpImageEditorComponent {
|
|
7
|
+
constructor(platformId) {
|
|
8
|
+
/** Image source — File, Blob, or URL string */
|
|
9
|
+
this.image = null;
|
|
10
|
+
/** Editor configuration */
|
|
11
|
+
this.config = {};
|
|
12
|
+
/** Emitted when user clicks Apply — contains the edited image result */
|
|
13
|
+
this.imageEdited = new EventEmitter();
|
|
14
|
+
/** Emitted when user clicks Close/Cancel */
|
|
15
|
+
this.editorClosed = new EventEmitter();
|
|
16
|
+
/** Emitted when an error occurs */
|
|
17
|
+
this.editorError = new EventEmitter();
|
|
18
|
+
this.editor = null;
|
|
19
|
+
this.isBrowser = isPlatformBrowser(platformId);
|
|
20
|
+
}
|
|
21
|
+
ngAfterViewInit() {
|
|
22
|
+
if (this.image) {
|
|
23
|
+
this.initEditor();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
ngOnDestroy() {
|
|
27
|
+
this.destroyEditor();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Programmatically load an image (can be called after component init)
|
|
31
|
+
*/
|
|
32
|
+
async loadImage(source) {
|
|
33
|
+
this.image = source;
|
|
34
|
+
await this.initEditor();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the edited result programmatically
|
|
38
|
+
*/
|
|
39
|
+
async getResult() {
|
|
40
|
+
try {
|
|
41
|
+
return await this.editor?.getResult() ?? null;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
this.editorError.emit(err);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Apply and emit result
|
|
50
|
+
*/
|
|
51
|
+
async apply() {
|
|
52
|
+
const result = await this.getResult();
|
|
53
|
+
if (result) {
|
|
54
|
+
this.imageEdited.emit(result);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Close the editor
|
|
59
|
+
*/
|
|
60
|
+
close() {
|
|
61
|
+
this.destroyEditor();
|
|
62
|
+
this.editorClosed.emit();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reset to original image
|
|
66
|
+
*/
|
|
67
|
+
async reset() {
|
|
68
|
+
await this.editor?.reset();
|
|
69
|
+
}
|
|
70
|
+
async initEditor() {
|
|
71
|
+
this.destroyEditor();
|
|
72
|
+
if (!this.isBrowser || !this.image || !this.containerRef?.nativeElement)
|
|
73
|
+
return;
|
|
74
|
+
this.editor = new RpImageEditor(this.containerRef.nativeElement, this.config);
|
|
75
|
+
this.editor.on('error', (err) => {
|
|
76
|
+
this.editorError.emit(err);
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
await this.editor.loadImage(this.image);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
this.editorError.emit(err);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
destroyEditor() {
|
|
86
|
+
if (this.editor) {
|
|
87
|
+
this.editor.destroy();
|
|
88
|
+
this.editor = null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
RpImageEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorComponent, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component });
|
|
93
|
+
RpImageEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: RpImageEditorComponent, selector: "rp-image-editor", inputs: { image: "image", config: "config" }, outputs: { imageEdited: "imageEdited", editorClosed: "editorClosed", editorError: "editorError" }, viewQueries: [{ propertyName: "containerRef", first: true, predicate: ["editorContainer"], descendants: true, static: true }], ngImport: i0, template: `<div #editorContainer class="rp-image-editor-host" [style.width]="'100%'" [style.height]="'100%'" [style.display]="'flex'" [style.flexDirection]="'column'"></div>`, isInline: true, styles: [":host{display:block;width:100%;height:100%}.rp-image-editor-host{min-height:300px}\n"] });
|
|
94
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorComponent, decorators: [{
|
|
95
|
+
type: Component,
|
|
96
|
+
args: [{ selector: 'rp-image-editor', template: `<div #editorContainer class="rp-image-editor-host" [style.width]="'100%'" [style.height]="'100%'" [style.display]="'flex'" [style.flexDirection]="'column'"></div>`, styles: [":host{display:block;width:100%;height:100%}.rp-image-editor-host{min-height:300px}\n"] }]
|
|
97
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
98
|
+
type: Inject,
|
|
99
|
+
args: [PLATFORM_ID]
|
|
100
|
+
}] }]; }, propDecorators: { containerRef: [{
|
|
101
|
+
type: ViewChild,
|
|
102
|
+
args: ['editorContainer', { static: true }]
|
|
103
|
+
}], image: [{
|
|
104
|
+
type: Input
|
|
105
|
+
}], config: [{
|
|
106
|
+
type: Input
|
|
107
|
+
}], imageEdited: [{
|
|
108
|
+
type: Output
|
|
109
|
+
}], editorClosed: [{
|
|
110
|
+
type: Output
|
|
111
|
+
}], editorError: [{
|
|
112
|
+
type: Output
|
|
113
|
+
}] } });
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Service to open the image editor as a modal overlay.
|
|
117
|
+
* Works with or without Ionic — uses the core modal implementation.
|
|
118
|
+
*
|
|
119
|
+
* Usage:
|
|
120
|
+
* ```ts
|
|
121
|
+
* constructor(private rpEditor: RpImageEditorService) {}
|
|
122
|
+
*
|
|
123
|
+
* async editImage(file: File) {
|
|
124
|
+
* const result = await this.rpEditor.openEditor(file, {
|
|
125
|
+
* theme: { applyButtonBackground: '#28a745' }
|
|
126
|
+
* });
|
|
127
|
+
* if (result) {
|
|
128
|
+
* // result.file — upload to server
|
|
129
|
+
* // result.base64 — preview
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
class RpImageEditorService {
|
|
135
|
+
/**
|
|
136
|
+
* Open the image editor in a modal popup.
|
|
137
|
+
*
|
|
138
|
+
* @param image - File, Blob, or URL string to edit
|
|
139
|
+
* @param config - Optional editor configuration (theme, crop ratios, etc.)
|
|
140
|
+
* @returns Promise resolving to RpEditorResult if applied, or null if cancelled
|
|
141
|
+
*/
|
|
142
|
+
async openEditor(image, config) {
|
|
143
|
+
return openEditorModal({
|
|
144
|
+
image,
|
|
145
|
+
config,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Edit several images in one modal with a thumbnail strip.
|
|
150
|
+
*
|
|
151
|
+
* @param images - Files, Blobs or URL strings, in strip order
|
|
152
|
+
* @param config - Editor configuration shared by every image
|
|
153
|
+
* @param startIndex - 0-based index of the image to open first
|
|
154
|
+
* @returns One `{ index, edited, result }` per image on Apply, or null if closed
|
|
155
|
+
*/
|
|
156
|
+
async openMultiEditor(images, config, startIndex) {
|
|
157
|
+
return openMultiEditorModal({ images, config, startIndex });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
RpImageEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
161
|
+
RpImageEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorService, providedIn: 'root' });
|
|
162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorService, decorators: [{
|
|
163
|
+
type: Injectable,
|
|
164
|
+
args: [{
|
|
165
|
+
providedIn: 'root',
|
|
166
|
+
}]
|
|
167
|
+
}] });
|
|
168
|
+
|
|
169
|
+
class RpImageEditorModule {
|
|
170
|
+
/**
|
|
171
|
+
* Use forRoot() if you want to provide the service at root level
|
|
172
|
+
* (optional — service is already providedIn: 'root')
|
|
173
|
+
*/
|
|
174
|
+
static forRoot() {
|
|
175
|
+
return {
|
|
176
|
+
ngModule: RpImageEditorModule,
|
|
177
|
+
providers: [RpImageEditorService],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
RpImageEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
182
|
+
RpImageEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorModule, declarations: [RpImageEditorComponent], imports: [CommonModule], exports: [RpImageEditorComponent] });
|
|
183
|
+
RpImageEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorModule, providers: [RpImageEditorService], imports: [CommonModule] });
|
|
184
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RpImageEditorModule, decorators: [{
|
|
185
|
+
type: NgModule,
|
|
186
|
+
args: [{
|
|
187
|
+
declarations: [RpImageEditorComponent],
|
|
188
|
+
imports: [CommonModule],
|
|
189
|
+
exports: [RpImageEditorComponent],
|
|
190
|
+
providers: [RpImageEditorService],
|
|
191
|
+
}]
|
|
192
|
+
}] });
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @rageshpikalmunde/rp-image-editor-angular
|
|
196
|
+
* Angular wrapper for the rp-image-editor plugin
|
|
197
|
+
*/
|
|
198
|
+
// Module
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Generated bundle index. Do not edit.
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
export { RpImageEditorComponent, RpImageEditorModule, RpImageEditorService };
|
|
205
|
+
//# sourceMappingURL=rageshpikalmunde-rp-image-editor-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rageshpikalmunde-rp-image-editor-angular.mjs","sources":["../../src/lib/rp-image-editor.component.ts","../../src/lib/rp-image-editor.service.ts","../../src/lib/rp-image-editor.module.ts","../../src/index.ts","../../src/rageshpikalmunde-rp-image-editor-angular.ts"],"sourcesContent":["import { Component, ElementRef, EventEmitter, Inject, Input, OnDestroy, Output, PLATFORM_ID, ViewChild, AfterViewInit } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { RpImageEditor, RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-editor';\n\n@Component({\n selector: 'rp-image-editor',\n template: `<div #editorContainer class=\"rp-image-editor-host\" [style.width]=\"'100%'\" [style.height]=\"'100%'\" [style.display]=\"'flex'\" [style.flexDirection]=\"'column'\"></div>`,\n styles: [`:host { display: block; width: 100%; height: 100%; } .rp-image-editor-host { min-height: 300px; }`]\n})\nexport class RpImageEditorComponent implements AfterViewInit, OnDestroy {\n @ViewChild('editorContainer', { static: true }) containerRef!: ElementRef<HTMLElement>;\n\n /** Image source — File, Blob, or URL string */\n @Input() image: File | Blob | string | null = null;\n\n /** Editor configuration */\n @Input() config: Partial<RpEditorConfig> = {};\n\n /** Emitted when user clicks Apply — contains the edited image result */\n @Output() imageEdited = new EventEmitter<RpEditorResult>();\n\n /** Emitted when user clicks Close/Cancel */\n @Output() editorClosed = new EventEmitter<void>();\n\n /** Emitted when an error occurs */\n @Output() editorError = new EventEmitter<Error>();\n\n private editor: RpImageEditor | null = null;\n\n /** False during server-side rendering, where there is no DOM/canvas. */\n private readonly isBrowser: boolean;\n\n constructor(@Inject(PLATFORM_ID) platformId: object) {\n this.isBrowser = isPlatformBrowser(platformId);\n }\n\n ngAfterViewInit(): void {\n if (this.image) {\n this.initEditor();\n }\n }\n\n ngOnDestroy(): void {\n this.destroyEditor();\n }\n\n /**\n * Programmatically load an image (can be called after component init)\n */\n async loadImage(source: File | Blob | string): Promise<void> {\n this.image = source;\n await this.initEditor();\n }\n\n /**\n * Get the edited result programmatically\n */\n async getResult(): Promise<RpEditorResult | null> {\n try {\n return await this.editor?.getResult() ?? null;\n } catch (err) {\n this.editorError.emit(err as Error);\n return null;\n }\n }\n\n /**\n * Apply and emit result\n */\n async apply(): Promise<void> {\n const result = await this.getResult();\n if (result) {\n this.imageEdited.emit(result);\n }\n }\n\n /**\n * Close the editor\n */\n close(): void {\n this.destroyEditor();\n this.editorClosed.emit();\n }\n\n /**\n * Reset to original image\n */\n async reset(): Promise<void> {\n await this.editor?.reset();\n }\n\n private async initEditor(): Promise<void> {\n this.destroyEditor();\n\n if (!this.isBrowser || !this.image || !this.containerRef?.nativeElement) return;\n\n this.editor = new RpImageEditor(this.containerRef.nativeElement, this.config);\n\n this.editor.on('error', (err) => {\n this.editorError.emit(err);\n });\n\n try {\n await this.editor.loadImage(this.image);\n } catch (err) {\n this.editorError.emit(err as Error);\n }\n }\n\n private destroyEditor(): void {\n if (this.editor) {\n this.editor.destroy();\n this.editor = null;\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport {\n RpEditorConfig,\n RpEditorResult,\n RpMultiEditorItemResult,\n openEditorModal,\n openMultiEditorModal,\n} from '@rageshpikalmunde/rp-image-editor';\n\n/**\n * Service to open the image editor as a modal overlay.\n * Works with or without Ionic — uses the core modal implementation.\n *\n * Usage:\n * ```ts\n * constructor(private rpEditor: RpImageEditorService) {}\n *\n * async editImage(file: File) {\n * const result = await this.rpEditor.openEditor(file, {\n * theme: { applyButtonBackground: '#28a745' }\n * });\n * if (result) {\n * // result.file — upload to server\n * // result.base64 — preview\n * }\n * }\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class RpImageEditorService {\n /**\n * Open the image editor in a modal popup.\n *\n * @param image - File, Blob, or URL string to edit\n * @param config - Optional editor configuration (theme, crop ratios, etc.)\n * @returns Promise resolving to RpEditorResult if applied, or null if cancelled\n */\n async openEditor(\n image: File | Blob | string,\n config?: Partial<RpEditorConfig>\n ): Promise<RpEditorResult | null> {\n return openEditorModal({\n image,\n config,\n });\n }\n\n /**\n * Edit several images in one modal with a thumbnail strip.\n *\n * @param images - Files, Blobs or URL strings, in strip order\n * @param config - Editor configuration shared by every image\n * @param startIndex - 0-based index of the image to open first\n * @returns One `{ index, edited, result }` per image on Apply, or null if closed\n */\n async openMultiEditor(\n images: Array<File | Blob | string>,\n config?: Partial<RpEditorConfig>,\n startIndex?: number\n ): Promise<RpMultiEditorItemResult[] | null> {\n return openMultiEditorModal({ images, config, startIndex });\n }\n}\n","import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { RpImageEditorComponent } from './rp-image-editor.component';\nimport { RpImageEditorService } from './rp-image-editor.service';\n\n@NgModule({\n declarations: [RpImageEditorComponent],\n imports: [CommonModule],\n exports: [RpImageEditorComponent],\n providers: [RpImageEditorService],\n})\nexport class RpImageEditorModule {\n /**\n * Use forRoot() if you want to provide the service at root level\n * (optional — service is already providedIn: 'root')\n */\n static forRoot(): ModuleWithProviders<RpImageEditorModule> {\n return {\n ngModule: RpImageEditorModule,\n providers: [RpImageEditorService],\n };\n }\n}\n","/**\n * @rageshpikalmunde/rp-image-editor-angular\n * Angular wrapper for the rp-image-editor plugin\n */\n\n// Module\nexport { RpImageEditorModule } from './lib/rp-image-editor.module';\n\n// Component\nexport { RpImageEditorComponent } from './lib/rp-image-editor.component';\n\n// Service\nexport { RpImageEditorService } from './lib/rp-image-editor.service';\n\n// Re-export types from core\nexport type {\n RpEditorConfig,\n RpEditorTheme,\n RpEditorResult,\n RpMultiEditorItemResult,\n CropAspectRatio,\n EditorMode,\n} from '@rageshpikalmun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AAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,EAFnB,SAAA,EAAA,CAAC,oBAAoB,CAAC,YAFvB,YAAY,CAAA,EAAA,CAAA,CAAA;4FAIX,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAN/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,YAAY,EAAE,CAAC,sBAAsB,CAAC;oBACtC,OAAO,EAAE,CAAC,YAAY,CAAC;oBACvB,OAAO,EAAE,CAAC,sBAAsB,CAAC;oBACjC,SAAS,EAAE,CAAC,oBAAoB,CAAC;AAClC,iBAAA,CAAA;;;ACVD;;;AAGG;AAEH;;ACLA;;AAEG;;;;"}
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
export { RpImageEditorModule } from './lib/rp-image-editor.module';
|
|
6
6
|
export { RpImageEditorComponent } from './lib/rp-image-editor.component';
|
|
7
7
|
export { RpImageEditorService } from './lib/rp-image-editor.service';
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import { ElementRef, EventEmitter, OnDestroy, AfterViewInit } from '@angular/core';
|
|
2
2
|
import { RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-editor';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
3
4
|
export declare class RpImageEditorComponent implements AfterViewInit, OnDestroy {
|
|
4
5
|
containerRef: ElementRef<HTMLElement>;
|
|
5
6
|
/** Image source — File, Blob, or URL string */
|
|
@@ -13,6 +14,9 @@ export declare class RpImageEditorComponent implements AfterViewInit, OnDestroy
|
|
|
13
14
|
/** Emitted when an error occurs */
|
|
14
15
|
editorError: EventEmitter<Error>;
|
|
15
16
|
private editor;
|
|
17
|
+
/** False during server-side rendering, where there is no DOM/canvas. */
|
|
18
|
+
private readonly isBrowser;
|
|
19
|
+
constructor(platformId: object);
|
|
16
20
|
ngAfterViewInit(): void;
|
|
17
21
|
ngOnDestroy(): void;
|
|
18
22
|
/**
|
|
@@ -37,4 +41,6 @@ export declare class RpImageEditorComponent implements AfterViewInit, OnDestroy
|
|
|
37
41
|
reset(): Promise<void>;
|
|
38
42
|
private initEditor;
|
|
39
43
|
private destroyEditor;
|
|
44
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RpImageEditorComponent, never>;
|
|
45
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RpImageEditorComponent, "rp-image-editor", never, { "image": "image"; "config": "config"; }, { "imageEdited": "imageEdited"; "editorClosed": "editorClosed"; "editorError": "editorError"; }, never, never, false, never>;
|
|
40
46
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import * as i1 from "./rp-image-editor.component";
|
|
4
|
+
import * as i2 from "@angular/common";
|
|
5
|
+
export declare class RpImageEditorModule {
|
|
6
|
+
/**
|
|
7
|
+
* Use forRoot() if you want to provide the service at root level
|
|
8
|
+
* (optional — service is already providedIn: 'root')
|
|
9
|
+
*/
|
|
10
|
+
static forRoot(): ModuleWithProviders<RpImageEditorModule>;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RpImageEditorModule, never>;
|
|
12
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<RpImageEditorModule, [typeof i1.RpImageEditorComponent], [typeof i2.CommonModule], [typeof i1.RpImageEditorComponent]>;
|
|
13
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<RpImageEditorModule>;
|
|
14
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RpEditorConfig, RpEditorResult } from '@rageshpikalmunde/rp-image-editor';
|
|
1
|
+
import { RpEditorConfig, RpEditorResult, RpMultiEditorItemResult } from '@rageshpikalmunde/rp-image-editor';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
2
3
|
/**
|
|
3
4
|
* Service to open the image editor as a modal overlay.
|
|
4
5
|
* Works with or without Ionic — uses the core modal implementation.
|
|
@@ -27,4 +28,15 @@ export declare class RpImageEditorService {
|
|
|
27
28
|
* @returns Promise resolving to RpEditorResult if applied, or null if cancelled
|
|
28
29
|
*/
|
|
29
30
|
openEditor(image: File | Blob | string, config?: Partial<RpEditorConfig>): Promise<RpEditorResult | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Edit several images in one modal with a thumbnail strip.
|
|
33
|
+
*
|
|
34
|
+
* @param images - Files, Blobs or URL strings, in strip order
|
|
35
|
+
* @param config - Editor configuration shared by every image
|
|
36
|
+
* @param startIndex - 0-based index of the image to open first
|
|
37
|
+
* @returns One `{ index, edited, result }` per image on Apply, or null if closed
|
|
38
|
+
*/
|
|
39
|
+
openMultiEditor(images: Array<File | Blob | string>, config?: Partial<RpEditorConfig>, startIndex?: number): Promise<RpMultiEditorItemResult[] | null>;
|
|
40
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RpImageEditorService, never>;
|
|
41
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<RpImageEditorService>;
|
|
30
42
|
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rageshpikalmunde/rp-image-editor-angular",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Angular wrapper for rp-image-editor with crop, annotation, filters, and native-resolution export support",
|
|
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
5
|
"keywords": [
|
|
26
6
|
"image-editor",
|
|
27
7
|
"angular-image-editor",
|
|
@@ -44,11 +24,12 @@
|
|
|
44
24
|
"access": "public"
|
|
45
25
|
},
|
|
46
26
|
"dependencies": {
|
|
47
|
-
"@rageshpikalmunde/rp-image-editor": "^1.
|
|
27
|
+
"@rageshpikalmunde/rp-image-editor": "^1.6.0",
|
|
28
|
+
"tslib": "^2.3.0"
|
|
48
29
|
},
|
|
49
30
|
"peerDependencies": {
|
|
50
|
-
"@angular/core": ">=
|
|
51
|
-
"@angular/common": ">=
|
|
31
|
+
"@angular/core": ">=15.0.0",
|
|
32
|
+
"@angular/common": ">=15.0.0",
|
|
52
33
|
"@ionic/angular": ">=6.0.0"
|
|
53
34
|
},
|
|
54
35
|
"peerDependenciesMeta": {
|
|
@@ -56,7 +37,24 @@
|
|
|
56
37
|
"optional": true
|
|
57
38
|
}
|
|
58
39
|
},
|
|
59
|
-
"
|
|
60
|
-
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"module": "fesm2015/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
42
|
+
"es2020": "fesm2020/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
43
|
+
"esm2020": "esm2020/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
44
|
+
"fesm2020": "fesm2020/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
45
|
+
"fesm2015": "fesm2015/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
46
|
+
"typings": "index.d.ts",
|
|
47
|
+
"exports": {
|
|
48
|
+
"./package.json": {
|
|
49
|
+
"default": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
".": {
|
|
52
|
+
"types": "./index.d.ts",
|
|
53
|
+
"esm2020": "./esm2020/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
54
|
+
"es2020": "./fesm2020/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
55
|
+
"es2015": "./fesm2015/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
56
|
+
"node": "./fesm2015/rageshpikalmunde-rp-image-editor-angular.mjs",
|
|
57
|
+
"default": "./fesm2020/rageshpikalmunde-rp-image-editor-angular.mjs"
|
|
58
|
+
}
|
|
61
59
|
}
|
|
62
|
-
}
|
|
60
|
+
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,132 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IAED,WAAW;QACT,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,MAA4B;QAC1C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;IAC1B,CAAC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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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/esm/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|