Skip to content

Commit

Permalink
feat(imageRemoved): new emitter for deleted images
Browse files Browse the repository at this point in the history
  • Loading branch information
davidroyer committed Aug 5, 2019
1 parent b648602 commit eecc696
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/VueEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,27 @@ export default {
else if (range && !oldRange) this.$emit("focus", this.quill);
},
handleTextChange() {
handleTextChange(delta, oldContents) {
let editorContent =
this.quill.getHTML() === "<p><br></p>" ? "" : this.quill.getHTML();
this.$emit("input", editorContent);
if (this.useCustomImageHandler)
this.handleImageRemoved(delta, oldContents);
},
handleImageRemoved(delta, oldContents) {
const currrentContents = this.quill.getContents();
const deletedContents = currrentContents.diff(oldContents);
const operations = deletedContents.ops;
operations.map(operation => {
if (operation.insert && operation.insert.hasOwnProperty("image")) {
const { image } = operation.insert;
this.$emit("imageRemoved", image);
}
});
},
checkForCustomImageHandler() {
this.useCustomImageHandler === true ? this.setupCustomImageHandler() : "";
},
Expand Down

0 comments on commit eecc696

Please sign in to comment.