diff --git a/app/javascript/controllers/remote_auto_save_controller.js b/app/javascript/controllers/remote_auto_save_controller.js index 7ba4a6d5e..429c1b9a4 100644 --- a/app/javascript/controllers/remote_auto_save_controller.js +++ b/app/javascript/controllers/remote_auto_save_controller.js @@ -10,4 +10,26 @@ export default class extends Controller { submit() { this.autoSaveOutlet.submit() } + + pasteFiles(event) { + const files = event.clipboardData?.files + if (!files?.length) return + + const editor = this.element.querySelector('house-md') + if (!editor) return + + for (const file of files) { + const upload = new CustomEvent('house-md:before-upload', { + bubbles: true, + detail: { file } + }) + + if (editor.dispatchEvent(upload)) { + const uploadElement = document.createElement('house-md-upload') + uploadElement.file = file + uploadElement.uploadsURL = editor.dataset.uploadsUrl + editor.appendChild(uploadElement) + } + } + } } diff --git a/app/views/bubbles/show.html.erb b/app/views/bubbles/show.html.erb index 18126f584..74fdd519d 100644 --- a/app/views/bubbles/show.html.erb +++ b/app/views/bubbles/show.html.erb @@ -103,9 +103,9 @@ <% else %>
-
+ <%= tag.house_md @bubble.draft_comment, name: "bubble[draft_comment]", class: "input comment__input", form: "bubble_form", placeholder: new_comment_placeholder(@bubble), - data: { action: "house-md:change->remote-auto-save#change focusout->remote-auto-save#submit" } %> + data: { action: "house-md:change->remote-auto-save#change focusout->remote-auto-save#submit", uploads_url: uploads_url(format: "json") } %>