From 597fb6cf2b11ca76d62b1771da1eab8ddbad7144 Mon Sep 17 00:00:00 2001 From: "CORP\\kotov.alexander" Date: Thu, 14 Apr 2022 11:15:33 +0400 Subject: [PATCH] remove unnecessary changes --- modules/uploader.js | 59 ++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/modules/uploader.js b/modules/uploader.js index 0637f5de97..5338db570f 100644 --- a/modules/uploader.js +++ b/modules/uploader.js @@ -29,42 +29,35 @@ class Uploader extends Module { } addDropHandler() { - this.bindedDropHandler = this.dropHandler.bind(this); - this.quill.root.addEventListener('drop', this.bindedDropHandler); - } - - dropHandler(e) { - const noFiles = e.dataTransfer.files.length === 0; - const { onDrop } = this.options; - - if (onDrop && typeof onDrop === 'function') { - onDrop(e); - } - - if (noFiles || this.preventImageUpload) { - return; - } + this.quill.root.addEventListener('drop', e => { + const noFiles = e.dataTransfer.files.length === 0; + const { onDrop } = this.options; - e.preventDefault(); - let native; + if (onDrop && typeof onDrop === 'function') { + onDrop(e); + } - if (document.caretRangeFromPoint) { - native = document.caretRangeFromPoint(e.clientX, e.clientY); - } else if (document.caretPositionFromPoint) { - const position = document.caretPositionFromPoint(e.clientX, e.clientY); - native = document.createRange(); - native.setStart(position.offsetNode, position.offset); - native.setEnd(position.offsetNode, position.offset); - } else { - return; - } - const normalized = this.quill.selection.normalizeNative(native); - const range = this.quill.selection.normalizedToRange(normalized); - this.upload(range, e.dataTransfer.files); - } + if (noFiles || this.preventImageUpload) { + return; + } - removeDropHandler() { - this.quill.root.removeEventListener('drop', this.bindedDropHandler); + e.preventDefault(); + let native; + + if (document.caretRangeFromPoint) { + native = document.caretRangeFromPoint(e.clientX, e.clientY); + } else if (document.caretPositionFromPoint) { + const position = document.caretPositionFromPoint(e.clientX, e.clientY); + native = document.createRange(); + native.setStart(position.offsetNode, position.offset); + native.setEnd(position.offsetNode, position.offset); + } else { + return; + } + const normalized = this.quill.selection.normalizeNative(native); + const range = this.quill.selection.normalizedToRange(normalized); + this.upload(range, e.dataTransfer.files); + }); } preventImageUploading(value) {