Last active
September 16, 2025 11:39
-
-
Save donnfelker/9e74a93371084955d557d219e5adea7a to your computer and use it in GitHub Desktop.
Images only and Disable Uploads for Lexxy Editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Controller } from "@hotwired/stimulus" | |
| export default class extends Controller { | |
| connect() { | |
| // Disable Lexxy uploads by preventing all file-accept events | |
| document.addEventListener("lexxy:file-accept", function(event) { | |
| console.log("file uploads not allowed") | |
| event.preventDefault(); | |
| }); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%# This will give you the ability to provide UI feedback (via the stimulus controller) to the user of why %> | |
| <%= form.rich_text_area :body, data: { controller: "disable-uploads" } %> | |
| <%# This is the default mechanism to block attachments, but with no UI feedback of why %> | |
| <%= form.rich_text_area :body, attachments: false %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Controller } from "@hotwired/stimulus" | |
| export default class extends Controller { | |
| connect() { | |
| document.addEventListener("lexxy:file-accept", function(event) { | |
| // Only allow jpg/jpeg, png and gif images | |
| const acceptedTypes = ['image/jpeg', 'image/png', 'image/gif'] | |
| if (!acceptedTypes.includes(event.detail.file.type)) { | |
| event.preventDefault() | |
| alert("We only support jpeg, png or gif files") | |
| } | |
| }) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= form.rich_text_area :body, data: { controller: "images-only" } %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment