Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor Driver Support #266

Merged
merged 2 commits into from Mar 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions js/src/forum/addUploadButton.js
Expand Up @@ -44,14 +44,14 @@ export default function () {
}
});

const dragAndDrop = new DragAndDrop((files) => this.uploader.upload(files), this.$().parents('.Composer')[0]);
this.dragAndDrop = new DragAndDrop((files) => this.uploader.upload(files), this.$().parents('.Composer')[0]);

const unloadHandler = () => {
dragAndDrop.unload();
};
new PasteClipboard((files) => this.uploader.upload(files), this.$('.TextEditor-editor')[0]);
});

this.$('textarea').bind('onunload', unloadHandler);
extend(TextEditor.prototype, 'onremove', function (f_, vnode) {
if (!app.forum.attribute('fof-upload.canUpload')) return;

new PasteClipboard((files) => this.uploader.upload(files), this.$('textarea')[0]);
this.dragAndDrop.unload();
});
}
7 changes: 3 additions & 4 deletions js/src/forum/components/PasteClipboard.js
@@ -1,10 +1,9 @@
export default class PasteClipboard {
constructor(upload, textAreaElement) {
constructor(upload, element) {
this.upload = upload;

// We don't need to remove the events listeners, because they are bound to the textarea when it's created,
// and need to stay as long as the textarea exists in the DOM
textAreaElement.addEventListener('paste', this.paste.bind(this));
// We don't need to remove the events listeners, because they'll get removed when the DOM does.
element.addEventListener('paste', this.paste.bind(this));
}

paste(e) {
Expand Down