angular-editor
angular-editor copied to clipboard
How to get event when someone remove image?
I just want to know how I can catch image removing event. I want that event with URL so that I can remove from server and database as well. My project has more modules so there will be garbage images if there is no such thing.
Valid feature request! Image deletion tracking would help manage server storage.
Current limitation: No event fires when images are removed from the editor.
Proposed solution:
Add onImageDelete event to configuration:
editorConfig: AngularEditorConfig = {
onImageDelete: (imageUrl: string) => {
// Called when image is removed from editor
this.deleteImageFromServer(imageUrl);
}
};
Implementation approach:
// Monitor content changes and detect removed images
private trackImageDeletions(oldContent: string, newContent: string) {
const oldImages = this.extractImageUrls(oldContent);
const newImages = this.extractImageUrls(newContent);
const deletedImages = oldImages.filter(url => !newImages.includes(url));
deletedImages.forEach(url => {
if (this.config.onImageDelete) {
this.config.onImageDelete(url);
}
});
}
This is a valid enhancement for server-side image cleanup. Labeling as enhancement and help wanted.
Complexity: Medium - Requires content diffing and image URL extraction.
Would welcome a PR!