Created
November 8, 2015 16:45
-
-
Save javan/20e574f1cae443ba6c59 to your computer and use it in GitHub Desktop.
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
buttonHTML = """<button type="button" class="attach" data-action="x-attach">Attach Files</button>""" | |
fileInputHTML = """<input type="file" multiple>""" | |
$(Trix.config.toolbar.content).find(".button_group.block_tools").append(buttonHTML) | |
$(document).on "trix-action-invoke", ($event) -> | |
if $event.originalEvent.actionName is "x-attach" | |
editorElement = $event.target | |
editorElement.focus() | |
$fileInput = $(fileInputHTML) | |
$fileInput.on "change", -> | |
for file in @files | |
editorElement.editor.insertFile(file) | |
$fileInput.click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment