From c051baf9d113f8127a9256e77807675218a902c4 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 14 Jan 2021 22:35:08 +0100 Subject: [PATCH] Fix iterating over check boxes and attachment images in the editor rendering --- src/components/input/editor.vue | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/input/editor.vue b/src/components/input/editor.vue index 6c902aaf5..26b7f4562 100644 --- a/src/components/input/editor.vue +++ b/src/components/input/editor.vue @@ -329,10 +329,10 @@ export default { return `` }, }, - highlight: function(code, language) { - const hljs = require('highlight.js'); - const validLanguage = hljs.getLanguage(language) ? language : 'plaintext'; - return hljs.highlight(validLanguage, code).value; + highlight: function (code, language) { + const hljs = require('highlight.js') + const validLanguage = hljs.getLanguage(language) ? language : 'plaintext' + return hljs.highlight(validLanguage, code).value }, }) @@ -347,8 +347,8 @@ export default { // Some docs at https://stackoverflow.com/q/62865160/10924593 this.$nextTick(() => { const attachmentImage = document.getElementsByClassName('attachment-image') - if(attachmentImage) { - attachmentImage.forEach(img => { + if (attachmentImage) { + for (const img of attachmentImage) { // The url is something like /tasks//attachments/ const parts = img.dataset.src.substr(window.API_URL.length + 1).split('/') const taskId = parseInt(parts[1]) @@ -363,15 +363,15 @@ export default { .then(url => { img.src = url }) - }) + } } const textCheckbox = document.getElementsByClassName(`text-checkbox-${this._uid}`) - if(textCheckbox) { - textCheckbox.forEach(check => { + if (textCheckbox) { + for (const check of textCheckbox) { check.removeEventListener('change', this.handleCheckboxClick) check.addEventListener('change', this.handleCheckboxClick) - }) + } } }) }, @@ -382,10 +382,10 @@ export default { const index = this.findNthIndex(this.text, numMarkdownCheck) if (index < 0 || typeof index === 'undefined') { - console.log('no index found') + console.debug('no index found') return } - console.log(index, this.text.substr(index, 9)) + console.debug(index, this.text.substr(index, 9)) if (checked) { this.text = this.replaceAt(this.text, index, '* [x] ') @@ -397,13 +397,13 @@ export default { }, toggleEdit() { if (this.isEditActive) { - this.isPreviewActive = true; - this.isEditActive = false; - this.renderPreview(); - this.bubble(0); // save instantly + this.isPreviewActive = true + this.isEditActive = false + this.renderPreview() + this.bubble(0) // save instantly } else { - this.isPreviewActive = false; - this.isEditActive = true; + this.isPreviewActive = false + this.isEditActive = true } }, },