Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially fixes #538, #539 and #540.
Adds a
fileInput
component, that progressively enhances an<input type="text">
to be populated from the upload from an injected<input type="file">
. After clicking the file selector and choosing a file, a fetch request is initiated that uploads the chosen file and returns the URL from the media endpoint.Possibly a number of ways this could be improved, but I think this is a good first pass at making uploading images inline easier, certainly easier than going to the separate file upload page and copy and pasting an uploaded file URL.
Accessibility
Given restrictions around initiating a file picker programmatically, and without universal support for
window.showOpenFilePicker()
, am using a<label>
styled as a<button>
which is used to trigger the hidden<input type="file">
. The label has been given abutton
role, added to thetabindex
, and given the behaviours of a button so that it can be triggered using a keyboard.Have tested using VoiceOver, but doubtless there are untold issues in other user agents. However, this seems like the most reasonable means of creating a button like control that can initiate the file picker. Open to other ideas on how this can be achieved.