Skip to content

Commit eecc696

Browse files
committed
feat(imageRemoved): new emitter for deleted images
1 parent b648602 commit eecc696

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/components/VueEditor.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,27 @@ export default {
167167
else if (range && !oldRange) this.$emit("focus", this.quill);
168168
},
169169
170-
handleTextChange() {
170+
handleTextChange(delta, oldContents) {
171171
let editorContent =
172172
this.quill.getHTML() === "<p><br></p>" ? "" : this.quill.getHTML();
173173
this.$emit("input", editorContent);
174+
175+
if (this.useCustomImageHandler)
176+
this.handleImageRemoved(delta, oldContents);
174177
},
175178
179+
handleImageRemoved(delta, oldContents) {
180+
const currrentContents = this.quill.getContents();
181+
const deletedContents = currrentContents.diff(oldContents);
182+
const operations = deletedContents.ops;
183+
184+
operations.map(operation => {
185+
if (operation.insert && operation.insert.hasOwnProperty("image")) {
186+
const { image } = operation.insert;
187+
this.$emit("imageRemoved", image);
188+
}
189+
});
190+
},
176191
checkForCustomImageHandler() {
177192
this.useCustomImageHandler === true ? this.setupCustomImageHandler() : "";
178193
},

0 commit comments

Comments
 (0)