-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix #10786 - Allow QuickView image preview for arbitrary URLs #10788
Conversation
I've updated this with the suggestion made to examine extensions. |
Could you take a look at the data provided by language.json/LanguageManager and see if you can use them? image is particularly interesting for whitelist (please concat "svg" yourself), audio and binary for blacklist (concat the ones you already have, plus maybe also "rss", "php"). |
I've rewritten this to use |
This is ready for review. |
@humphd Can you add some unit tests, if possible? Also run smoke tests with these changes, especially the one relating to editor and Extensions. |
ePos = {line: pos.line, ch: token.end}; | ||
} | ||
|
||
var imgPreview = "<div class='image-preview'>" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put in the imgPath check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already been dealt with in the if-block above from lines 475-483, returning early if we have no value for imgPath
, and therefore not needing to do the check and indent all this code.
LGTM |
The original Quick View implementation had support for arbitrary URLs, but it was removed due to concerns about performance (i.e. downloading external files on mousemove!). The code has been optimized since then so it now does not try to parse code in editor until mouse hasn't moved for 350ms, but people with a slow network or no network connection might see problems. Be sure to test this with no internet connection! You should consider:
|
I've updated this again. New commit adds:
Regarding @redmunds' questions. First, with no network, you end up in the |
@@ -784,10 +812,15 @@ define(function (require, exports, module) { | |||
|
|||
// Setup initial UI state | |||
setEnabled(prefs.get("enabled"), true); | |||
setExtensionlessImagePreview(prefs.get("extensionlessImagePreview")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should never write to prefs on initial load. This is unnecessary and slows down startup. I can see that this is emulating the other pref here, so remove that also if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, call to setEnabled(prefs.get("enabled"), true);
on line above is not writing to prefs, so that should be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the whole doNotSave
dance was done for the initial load case? I'll echo that for this as well and avoid the write.
In general, this looks good. Be sure to turn on JSLint as I am seeing some JSLint errors in QuickView/main.js. Also, there is a merge conflict that needs to be resolved. Just 1 other comment. |
@redmunds thanks for the review. I've rebased and pushed fixes. See if this approach satisfies what you wanted with the pref saving and startup. |
Looks good. |
Great, can someone land this then? |
Fix #10786 - Allow QuickView image preview for arbitrary URLs
Thanks @humphd for this fix |
This leverages the
img
element'sload
anderror
events to try and load arbitrary images. It also expands the list of known image extensions to include.bmp
, which browsers can display.