Hack for supporting pasting images into the composer in Firefox #2083

Merged
merged 1 commit into from Mar 9, 2014

4 participants

@discoursebot

You've signed the CLA, vikhyat. Thank you! This pull request is ready for review.

@vikhyat vikhyat commented on the diff Mar 8, 2014
...javascripts/discourse/views/composer/composer_view.js
@@ -321,6 +321,92 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
Discourse.Utilities.displayErrorForUpload(data);
});
+ // contenteditable div hack for getting image paste to upload working in
+ // Firefox. This is pretty dangerous because it can potentially break
+ // Ctrl+v to paste so we should be conservative about what browsers this runs
+ // in.
+ var uaMatch = navigator.userAgent.match(/Firefox\/(\d+)\.\d/);
+ if (uaMatch && parseInt(uaMatch[1]) >= 26) {
@vikhyat
vikhyat added a note Mar 8, 2014

This is because I've only tested it on FF 26+, I suspect it actually works for 23+ at least but I don't have a way to check right now so I figured it would be better to be conservative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@vikhyat

Not sure why the build is failing, I don't get any errors locally and the failed test on Travis looks unrelated.

@coding-horror
Discourse member
@vikhyat

Turns out this one was actually because of the recent change to have "new" text instead of the asterisk, this test wasn't updated when that was changed. (Fixed in this PR.)

@SamSaffron
Discourse member

Going to take this in, but is there no way you can do feature detection instead of user agent detection?

@SamSaffron SamSaffron merged commit 68630af into discourse:master Mar 9, 2014

1 check failed

Details default The Travis CI build failed
@SamSaffron
Discourse member

thanks, people have been bugging us about this for a while

@vikhyat

I can't think of any way of getting feature detection working here unfortunately, don't have any way to simulate a paste event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment