Make sure the editor does not break if the text has checkboxes

This commit is contained in:
kolaente 2020-12-08 18:40:13 +01:00
parent 0b620a07ef
commit 188d54ebe6
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -345,27 +345,33 @@ export default {
// not already made available. // not already made available.
// Some docs at https://stackoverflow.com/q/62865160/10924593 // Some docs at https://stackoverflow.com/q/62865160/10924593
this.$nextTick(() => { this.$nextTick(() => {
document.getElementsByClassName('attachment-image').forEach(img => { const attachmentImage = document.getElementsByClassName('attachment-image')
// The url is something like /tasks/<id>/attachments/<id> if(attachmentImage) {
const parts = img.dataset.src.substr(window.API_URL.length + 1).split('/') attachmentImage.forEach(img => {
const taskId = parseInt(parts[1]) // The url is something like /tasks/<id>/attachments/<id>
const attachmentId = parseInt(parts[3]) const parts = img.dataset.src.substr(window.API_URL.length + 1).split('/')
const attachment = new AttachmentModel({taskId: taskId, id: attachmentId}) const taskId = parseInt(parts[1])
const attachmentId = parseInt(parts[3])
const attachment = new AttachmentModel({taskId: taskId, id: attachmentId})
if (this.attachmentService === null) {
this.attachmentService = new AttachmentService()
}
this.attachmentService.getBlobUrl(attachment)
.then(url => {
img.src = url
})
})
}
if (this.attachmentService === null) { const textCheckbox = document.getElementsByClassName(`text-checkbox-${this._uid}`)
this.attachmentService = new AttachmentService() if(textCheckbox) {
} textCheckbox.forEach(check => {
check.removeEventListener('change', this.handleCheckboxClick)
this.attachmentService.getBlobUrl(attachment) check.addEventListener('change', this.handleCheckboxClick)
.then(url => { })
img.src = url }
})
})
document.getElementsByClassName(`text-checkbox-${this._uid}`).forEach(check => {
check.removeEventListener('change', this.handleCheckboxClick)
check.addEventListener('change', this.handleCheckboxClick)
})
}) })
}, },
handleCheckboxClick(e) { handleCheckboxClick(e) {