app/assets/javascripts/spina/controllers/trix_controller.js in spina-2.15.1 vs app/assets/javascripts/spina/controllers/trix_controller.js in spina-2.16.0

- old
+ new

@@ -17,11 +17,11 @@ } else { this.imageFieldsTarget.classList.add("hidden") } }.bind(this)) } - + insertEmbeddable(html) { let embeddable = new Trix.Attachment({ content: html, contentType: "application/vnd+spina.embed+html"}) @@ -36,11 +36,19 @@ let attachment = new Trix.Attachment({content: `<span class="trix-attachment-spina-image" data-label="Alt text"> <img src="${event.detail.embeddedUrl}" /> </span>`, contentType: "Spina::Image"}) this.editor.insertAttachment(attachment) } - + + fileAccept(event) { + const file = event.file + if(file) { + const startUploadEvent = new CustomEvent("auto-file-upload:start", { detail: { file, trixId: this.trixId }}) + window.dispatchEvent(startUploadEvent) + } + } + setAltText(event) { let alt = event.currentTarget.value let altLabel = alt if (altLabel.trim().length == 0) altLabel = "Alt text" // Fallback let content = this.trixAttachment.getContent() @@ -78,9 +86,13 @@ return fragment.querySelector('img').alt } get trixAttachment() { return this.getTrixAttachment(this.mutableImageAttachment.dataset.trixId) + } + + get trixId() { + return this.element.id } get mutableImageAttachment() { return this.element.querySelector(`figure[data-trix-mutable][data-trix-content-type="Spina::Image"]`) } \ No newline at end of file