Extract into a single-purpose controller

This commit is contained in:
Jason Zimdars
2025-02-13 17:40:18 -06:00
parent ddfaf8bf33
commit 3e5b531d12
6 changed files with 32 additions and 51 deletions
@@ -10,26 +10,4 @@ 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)
}
}
}
}