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", "name": "magico-pagebuilder",
"version": "0.0.5", "version": "0.0.6",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

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