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

Restore Missing fileInputId Property and Add acceptedFileTypes Property #1089

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this file, please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. I've also updated .gitignore to help avoid this. I hope this is OK. I see it's included there in Kamal.

Binary file not shown.
4 changes: 3 additions & 1 deletion src/trix/config/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

const input = {
level2Enabled: true,
fileInputId: `trix-file-input-${Date.now().toString(16)}`,
acceptedFileTypes: '*',

Check failure on line 7 in src/trix/config/input.js

View workflow job for this annotation

GitHub Actions / Browser tests

Strings must use doublequote
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer double quotes for strings. The linter should flag this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


getLevel() {
if (this.level2Enabled && browser.supportsInputEvents) {
Expand All @@ -12,7 +14,7 @@
}
},
pickFiles(callback) {
const input = makeElement("input", { type: "file", multiple: true, hidden: true, id: this.fileInputId })
const input = makeElement("input", { type: "file", multiple: true, hidden: true, id: this.fileInputId, accept: this.acceptedFileTypes })

input.addEventListener("change", () => {
callback(input.files)
Expand Down
Loading