Merge pull request #4349 from advplyr/trix_prevent_attachments

Update rich text editor to prevent pasting in images from the browser
This commit is contained in:
advplyr 2025-05-29 17:37:31 -05:00 committed by GitHub
commit f44c2d9e11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,7 @@
</div>
</div>
</trix-toolbar>
<trix-editor :toolbar="toolbarId" :contenteditable="!disabledEditor" :class="['trix-content']" ref="trix" :input="computedId" :placeholder="placeholder" @trix-change="handleContentChange" @trix-initialize="handleInitialize" @trix-focus="processTrixFocus" @trix-blur="processTrixBlur" />
<trix-editor :toolbar="toolbarId" :contenteditable="!disabledEditor" :class="['trix-content']" ref="trix" :input="computedId" :placeholder="placeholder" @trix-change="handleContentChange" @trix-initialize="handleInitialize" @trix-focus="processTrixFocus" @trix-blur="processTrixBlur" @trix-attachment-add="handleAttachmentAdd" />
<input type="hidden" :name="inputName" :id="computedId" :value="editorContent" />
</div>
</template>
@ -316,6 +316,12 @@ export default {
if (this.$refs.trix && this.$refs.trix.blur) {
this.$refs.trix.blur()
}
},
handleAttachmentAdd(event) {
// Prevent pasting in images from the browser
if (!event.attachment.file) {
event.attachment.remove()
}
}
},
mounted() {