Skip to content

Commit

Permalink
fix: enable image uploading for mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
artemkin committed Oct 15, 2023
1 parent 2534881 commit f2c610c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontend/static/js/components/CommentMarkdownEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import { createMarkdownEditor, handleFormSubmissionShortcuts, imageUploadOptions
export default {
mounted() {
const $markdownElementDiv = this.$el.children[0];
if (isMobile()) {
inlineAttachment.editors.input.attachToInput($markdownElementDiv, imageUploadOptions);
return;
}
const $markdownElementDiv = this.$el.children[0];
this.editor = createMarkdownEditor($markdownElementDiv, {
toolbar: false,
});
Expand Down
48 changes: 48 additions & 0 deletions frontend/static/js/input.inline-attachment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*jslint newcap: true */
/*global inlineAttachment: false */
(function() {
"use strict";

inlineAttachment.editors.input = {
Editor: function(instance) {

var input = instance;

return {
getValue: function() {
return input.value;
},
insertValue: function(val) {
inlineAttachment.util.insertTextAtCursor(input, val);
},
setValue: function(val) {
input.value = val;
}
};
},
attachToInput: function(input, options) {
options = options || {};

var editor = new inlineAttachment.editors.input.Editor(input),
inlineattach = new inlineAttachment(options, editor);

input.addEventListener("paste", function(e) {
inlineattach.onPaste(e);
}, false);
input.addEventListener("drop", function(e) {
e.stopPropagation();
e.preventDefault();
inlineattach.onDrop(e);
}, false);
input.addEventListener("dragenter", function(e) {
e.stopPropagation();
e.preventDefault();
}, false);
input.addEventListener("dragover", function(e) {
e.stopPropagation();
e.preventDefault();
}, false);
}
};

})();
1 change: 1 addition & 0 deletions frontend/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "../css/index.css";

import "./inline-attachment";
import "./codemirror-4.inline-attachment";
import "./input.inline-attachment";

import App from "./App.js";
import ClubApi from "./common/api.service.js";
Expand Down

0 comments on commit f2c610c

Please sign in to comment.