From 9c933905c86e4cfb7381e6979f5a5a12eada6cb3 Mon Sep 17 00:00:00 2001 From: trendschau Date: Sat, 4 May 2024 17:15:36 +0200 Subject: [PATCH] v.2.4.3 fix shortcode component --- .../typemill/author/js/vue-blox-components.js | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/system/typemill/author/js/vue-blox-components.js b/system/typemill/author/js/vue-blox-components.js index b110a89..8fd8c91 100644 --- a/system/typemill/author/js/vue-blox-components.js +++ b/system/typemill/author/js/vue-blox-components.js @@ -2451,18 +2451,23 @@ bloxeditor.component('shortcode-component', {
-
+
+
+ + + +
@@ -2540,24 +2545,37 @@ bloxeditor.component('shortcode-component', { createmarkdown(shortcodename) { var attributes = ''; - for (var attribute in this.shortcodedata[shortcodename]) + for (var key in this.shortcodedata[shortcodename]) { - if(this.shortcodedata[shortcodename].hasOwnProperty(attribute)) + if(this.shortcodedata[shortcodename].hasOwnProperty(key)) { - attributes += ' ' + attribute + '="' + this.shortcodedata[shortcodename][attribute] + '"'; - } + let value = false; + + if (typeof this.shortcodedata[shortcodename][key] == 'string') + { + value = this.shortcodedata[shortcodename][key]; + } + else if (Array.isArray(this.shortcodedata[shortcodename][key].content)) + { + let item = this.shortcodedata[shortcodename][key]; + if (item.content.includes(item.value)) + { + // Check if value exists in content array + value = item.value; + } + } + + if (value) + { + attributes += ' ' + key + '="' + value + '"'; + } + } } this.compmarkdown = '[:' + shortcodename + attributes + ' :]'; this.$emit('updateMarkdownEvent', this.compmarkdown); }, - selectsearch(item,attribute) - { - /* check if still reactive */ - this.shortcodedata[this.shortcodename][attribute].value = item; - this.createmarkdown(this.shortcodename,attribute); - }, updatemarkdown(event) { this.$emit('updateMarkdownEvent', event.target.value);