Fix iterating over check boxes and attachment images in the editor rendering
This commit is contained in:
parent
55b9b68258
commit
c051baf9d1
1 changed files with 18 additions and 18 deletions
|
@ -329,10 +329,10 @@ export default {
|
||||||
return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${this._uid}"/>`
|
return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${this._uid}"/>`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
highlight: function(code, language) {
|
highlight: function (code, language) {
|
||||||
const hljs = require('highlight.js');
|
const hljs = require('highlight.js')
|
||||||
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext';
|
const validLanguage = hljs.getLanguage(language) ? language : 'plaintext'
|
||||||
return hljs.highlight(validLanguage, code).value;
|
return hljs.highlight(validLanguage, code).value
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -347,8 +347,8 @@ export default {
|
||||||
// Some docs at https://stackoverflow.com/q/62865160/10924593
|
// Some docs at https://stackoverflow.com/q/62865160/10924593
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const attachmentImage = document.getElementsByClassName('attachment-image')
|
const attachmentImage = document.getElementsByClassName('attachment-image')
|
||||||
if(attachmentImage) {
|
if (attachmentImage) {
|
||||||
attachmentImage.forEach(img => {
|
for (const img of attachmentImage) {
|
||||||
// The url is something like /tasks/<id>/attachments/<id>
|
// The url is something like /tasks/<id>/attachments/<id>
|
||||||
const parts = img.dataset.src.substr(window.API_URL.length + 1).split('/')
|
const parts = img.dataset.src.substr(window.API_URL.length + 1).split('/')
|
||||||
const taskId = parseInt(parts[1])
|
const taskId = parseInt(parts[1])
|
||||||
|
@ -363,15 +363,15 @@ export default {
|
||||||
.then(url => {
|
.then(url => {
|
||||||
img.src = url
|
img.src = url
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const textCheckbox = document.getElementsByClassName(`text-checkbox-${this._uid}`)
|
const textCheckbox = document.getElementsByClassName(`text-checkbox-${this._uid}`)
|
||||||
if(textCheckbox) {
|
if (textCheckbox) {
|
||||||
textCheckbox.forEach(check => {
|
for (const check of textCheckbox) {
|
||||||
check.removeEventListener('change', this.handleCheckboxClick)
|
check.removeEventListener('change', this.handleCheckboxClick)
|
||||||
check.addEventListener('change', this.handleCheckboxClick)
|
check.addEventListener('change', this.handleCheckboxClick)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -382,10 +382,10 @@ export default {
|
||||||
|
|
||||||
const index = this.findNthIndex(this.text, numMarkdownCheck)
|
const index = this.findNthIndex(this.text, numMarkdownCheck)
|
||||||
if (index < 0 || typeof index === 'undefined') {
|
if (index < 0 || typeof index === 'undefined') {
|
||||||
console.log('no index found')
|
console.debug('no index found')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(index, this.text.substr(index, 9))
|
console.debug(index, this.text.substr(index, 9))
|
||||||
|
|
||||||
if (checked) {
|
if (checked) {
|
||||||
this.text = this.replaceAt(this.text, index, '* [x] ')
|
this.text = this.replaceAt(this.text, index, '* [x] ')
|
||||||
|
@ -397,13 +397,13 @@ export default {
|
||||||
},
|
},
|
||||||
toggleEdit() {
|
toggleEdit() {
|
||||||
if (this.isEditActive) {
|
if (this.isEditActive) {
|
||||||
this.isPreviewActive = true;
|
this.isPreviewActive = true
|
||||||
this.isEditActive = false;
|
this.isEditActive = false
|
||||||
this.renderPreview();
|
this.renderPreview()
|
||||||
this.bubble(0); // save instantly
|
this.bubble(0) // save instantly
|
||||||
} else {
|
} else {
|
||||||
this.isPreviewActive = false;
|
this.isPreviewActive = false
|
||||||
this.isEditActive = true;
|
this.isEditActive = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue