This commit is contained in:
2024-07-01 12:38:36 +02:00
parent de80d14c64
commit e750930057
2 changed files with 40 additions and 33 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "magico-pagebuilder",
"version": "0.0.5",
"version": "0.0.6",
"private": true,
"scripts": {
"dev": "vite",

View File

@@ -27,7 +27,7 @@
<li>
<a
@click.prevent="
modalLoad = !modalLoad
modalLoad = !modalLoad;
pageType = { name: null }
"
class="dropdown-item"
@@ -38,7 +38,7 @@
<li>
<a
@click.prevent="
modalSave = !modalSave
modalSave = !modalSave;
pageType = { name: null }
"
class="dropdown-item"
@@ -47,7 +47,13 @@
>
</li>
<li v-if="descriptionAllegro">
<a @click.prevent="pasteAllegro" class="dropdown-item" href="#"
<a
@click.prevent="
pasteAllegro
"
class="dropdown-item"
href="#"
>Wklej opis <i>Allegro</i></a
>
</li>
@@ -65,7 +71,7 @@
@start="drag = true"
item-key="d"
@end="
drag = false
drag = false;
onChange()
"
>
@@ -141,7 +147,7 @@
<!-- <textarea style="display:none" :name="namex">{{ comps }}</textarea> --><button
class="btn btn-block btn-primary mt-4"
@click.prevent="
modalAddSection = !modalAddSection
modalAddSection = !modalAddSection;
optionx = false
"
>
@@ -259,41 +265,42 @@ export default {
this.changeBody()
},
pasteAllegro: function(){
let sections = this.descriptionAllegro
let sections = this.descriptionAllegro;
try {
sections = JSON.parse(sections)
sections = JSON.parse(sections);
} catch (e) {
if (e instanceof SyntaxError) {
sections = [{ name: 'Tekst', cols: [{ type: 'text', value: sections, size: 12 }] }]
sections = [{ name: 'Tekst', cols: [{ type: 'text', value: sections, size: 12 }] }];
}
}
const pagebuilder = sections.map((item) => {
const columns = []
const pagebuilder = sections.map(item => {
const columns = [];
if (item.cols && Array.isArray(item.cols)) {
item.cols.forEach((col) => {
item.cols.forEach(col => {
const column = {
type: 'container',
type:"container",
items: [
{
name: col.type === 'img' ? 'core_section_image' : 'core_section_textarea',
text: col.value
name: (col.type === 'img' ? 'core_section_image' : 'core_section_textarea'),
text: col.value,
}
]
}
};
if (col.type === 'img' && col.figcaption) {
column.items[0]['figcaption'] = col.figcaption
column.items[0]['figcaption'] = col.figcaption;
}
columns.push(column)
})
columns.push(column);
});
}
return { columns, label: '', name: '' }
})
return { columns,label:'',name:'' };
});
this.comps = pagebuilder
this.onChange()
this.comps = pagebuilder;
this.onChange();
},
changeBody() {
var t = this