Make autosave work with lexical

This commit is contained in:
Jorge Manrubia
2025-05-28 23:20:14 +02:00
parent 2594bf90a7
commit 594161b982
6 changed files with 10 additions and 38 deletions
@@ -47,8 +47,8 @@ export default class extends Controller {
}
#triggerChangeEvent(newValue) {
if (this.inputTarget.tagName === "HOUSE-MD") {
this.inputTarget.dispatchEvent(new CustomEvent('house-md:change', {
if (this.inputTarget.tagName === "LEXICAL-EDITOR") {
this.inputTarget.dispatchEvent(new CustomEvent('actiontext:change', {
bubbles: true,
detail: {
previousContent: '',
@@ -1,28 +0,0 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
pasteFiles(event) {
const editor = event.target.closest("house-md")
if (!editor) return
const files = event.clipboardData?.files
if (!files?.length) return
event.preventDefault()
for (const file of files) {
const uploadEvent = new CustomEvent("house-md:before-upload", {
bubbles: true,
detail: { file },
cancelable: true
})
if (editor.dispatchEvent(uploadEvent)) {
const upload = document.createElement("house-md-upload")
upload.file = file
upload.uploadsURL = editor.dataset.uploadsUrl
editor.appendChild(upload)
}
}
}
}