@myissue/vue-website-page-builder 3.1.13 → 3.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-website-page-builder.css +1 -1
- package/dist/vue-website-page-builder.js +5161 -5194
- package/dist/vue-website-page-builder.umd.cjs +38 -38
- package/package.json +1 -1
- package/src/App.vue +2 -2
- package/src/Components/Homepage/HomeSection.vue +18 -7
- package/src/Components/Modals/{DynamicModal.vue → DynamicModalBuilder.vue} +38 -31
- package/src/Components/Modals/MediaLibraryModal.vue +1 -1
- package/src/Components/Modals/{Modal.vue → ModalBuilder.vue} +9 -15
- package/src/Components/Modals/PageBuilderPreviewModal.vue +13 -6
- package/src/Components/PageBuilder/DemoContent/NoneCustomSearchComponent.vue +0 -17
- package/src/Components/PageBuilder/DropdownsPlusToggles/OptionsDropdown.vue +113 -87
- package/src/Components/PageBuilder/EditorMenu/Editables/BackgroundColorEditor.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/BorderRadius.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/Borders.vue +3 -3
- package/src/Components/PageBuilder/EditorMenu/Editables/ClassEditor.vue +1 -1
- package/src/Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue +13 -13
- package/src/Components/PageBuilder/EditorMenu/Editables/DeleteElement.vue +1 -1
- package/src/Components/PageBuilder/EditorMenu/Editables/EditGetElement.vue +25 -25
- package/src/Components/PageBuilder/EditorMenu/Editables/ElementEditor.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/ImageEditor.vue +3 -3
- package/src/Components/PageBuilder/EditorMenu/Editables/LinkEditor.vue +1 -1
- package/src/Components/PageBuilder/EditorMenu/Editables/ManageBackgroundOpacity.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/ManageOpacity.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/OpacityEditor.vue +3 -3
- package/src/Components/PageBuilder/EditorMenu/Editables/PaddingPlusMargin.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/TextColorEditor.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/Typography.vue +3 -3
- package/src/Components/PageBuilder/EditorMenu/RightSidebarEditor.vue +13 -13
- package/src/Components/PageBuilder/Settings/AdvancedPageBuilderSettings.vue +9 -1
- package/src/Components/PageBuilder/Settings/PageBuilderSettings.vue +306 -15
- package/src/Components/Search/SearchComponents.vue +14 -8
- package/src/Components/TipTap/TipTap.vue +1 -1
- package/src/Components/TipTap/TipTapInput.vue +15 -17
- package/src/PageBuilder/PageBuilder.vue +37 -131
- package/src/composables/PageBuilderClass.ts +90 -80
- package/src/stores/page-builder-state.ts +9 -192
- package/src/types/index.ts +13 -10
- package/src/utils/builder/html-doc-declaration-with-components.ts +1 -1
- package/src/utils/html-elements/componentHelpers.ts +3 -3
- package/src/composables/isObject.ts +0 -6
- package/src/composables/usePromise.ts +0 -10
- package/src/composables/vueFetch.ts +0 -278
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { onMounted, computed, ref, watch, provide } from 'vue'
|
|
3
3
|
import { createPinia } from 'pinia'
|
|
4
|
-
import PageBuilderClass from '
|
|
5
|
-
import PageBuilderPreviewModal from '
|
|
6
|
-
import Preview from '
|
|
7
|
-
import ComponentTopMenu from '
|
|
8
|
-
import EditGetElement from '
|
|
9
|
-
import SearchComponents from '
|
|
10
|
-
import OptionsDropdown from '
|
|
11
|
-
import RightSidebarEditor from '
|
|
12
|
-
import { usePageBuilderStateStore } from '
|
|
4
|
+
import PageBuilderClass from '../composables/PageBuilderClass.ts'
|
|
5
|
+
import PageBuilderPreviewModal from '../Components/Modals/PageBuilderPreviewModal.vue'
|
|
6
|
+
import Preview from './Preview.vue'
|
|
7
|
+
import ComponentTopMenu from '../Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue'
|
|
8
|
+
import EditGetElement from '../Components/PageBuilder/EditorMenu/Editables/EditGetElement.vue'
|
|
9
|
+
import SearchComponents from '../Components/Search/SearchComponents.vue'
|
|
10
|
+
import OptionsDropdown from '../Components/PageBuilder/DropdownsPlusToggles/OptionsDropdown.vue'
|
|
11
|
+
import RightSidebarEditor from '../Components/PageBuilder/EditorMenu/RightSidebarEditor.vue'
|
|
12
|
+
import { usePageBuilderStateStore } from '../stores/page-builder-state'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Props for PageBuilder component
|
|
16
16
|
* @typedef {Object} Props
|
|
17
17
|
* @property {Object|null} CustomMediaLibraryComponent - Custom media component
|
|
18
18
|
* @property {Object|null} CustomSearchComponent - Custom search component
|
|
19
|
-
* @property {
|
|
20
|
-
* @property {Object|null} user - User object with name property: { name: string }
|
|
19
|
+
* @property {Object} configPageBuilder - Configuration object containing:
|
|
21
20
|
*/
|
|
22
21
|
const props = defineProps({
|
|
23
|
-
PageBuilderLogo: {
|
|
24
|
-
type: String,
|
|
25
|
-
default: null,
|
|
26
|
-
},
|
|
27
22
|
CustomMediaLibraryComponent: {
|
|
28
23
|
type: Object,
|
|
29
24
|
default: null,
|
|
@@ -32,32 +27,10 @@ const props = defineProps({
|
|
|
32
27
|
type: Object,
|
|
33
28
|
default: null,
|
|
34
29
|
},
|
|
35
|
-
|
|
36
|
-
type: String,
|
|
37
|
-
default: 'create',
|
|
38
|
-
required: false,
|
|
39
|
-
},
|
|
40
|
-
userForPageBuilder: {
|
|
41
|
-
type: Object,
|
|
42
|
-
default: null,
|
|
43
|
-
validator: (value) => {
|
|
44
|
-
// Allow null or object with name property
|
|
45
|
-
return value === null || (typeof value === 'object' && typeof value.name === 'string')
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
resourceData: {
|
|
30
|
+
configPageBuilder: {
|
|
49
31
|
type: Object,
|
|
50
|
-
default:
|
|
32
|
+
default: () => ({ updateOrCreate: 'create' }),
|
|
51
33
|
required: false,
|
|
52
|
-
validator: (value) => {
|
|
53
|
-
// Allow null or object with title (string) and id (number) properties
|
|
54
|
-
return (
|
|
55
|
-
value === null ||
|
|
56
|
-
(typeof value === 'object' &&
|
|
57
|
-
typeof value.title === 'string' &&
|
|
58
|
-
typeof value.id === 'number')
|
|
59
|
-
)
|
|
60
|
-
},
|
|
61
34
|
},
|
|
62
35
|
})
|
|
63
36
|
|
|
@@ -65,27 +38,21 @@ const props = defineProps({
|
|
|
65
38
|
const internalPinia = createPinia()
|
|
66
39
|
const pageBuilderStateStore = usePageBuilderStateStore(internalPinia)
|
|
67
40
|
|
|
68
|
-
// Set
|
|
69
|
-
if (props.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// Set current user if provided
|
|
82
|
-
if (props.userForPageBuilder) {
|
|
83
|
-
pageBuilderStateStore.setCurrentUser(props.userForPageBuilder)
|
|
41
|
+
// Set configPageBuilder in store (this will be the single source of truth)
|
|
42
|
+
if (props.configPageBuilder) {
|
|
43
|
+
// Ensure updateOrCreate defaults to 'create' if not provided
|
|
44
|
+
const configWithDefaults = {
|
|
45
|
+
...props.configPageBuilder,
|
|
46
|
+
updateOrCreate: props.configPageBuilder.updateOrCreate || 'create',
|
|
47
|
+
userSettings: props.configPageBuilder.userSettings || {
|
|
48
|
+
theme: 'light',
|
|
49
|
+
language: 'en',
|
|
50
|
+
autoSave: true,
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
pageBuilderStateStore.setConfigPageBuilder(configWithDefaults)
|
|
84
54
|
}
|
|
85
55
|
|
|
86
|
-
// Set updateOrCreate in store
|
|
87
|
-
pageBuilderStateStore.setUpdateOrCreate(props.updateOrCreate)
|
|
88
|
-
|
|
89
56
|
// Initialize PageBuilder with store
|
|
90
57
|
const pageBuilderClass = new PageBuilderClass(pageBuilderStateStore)
|
|
91
58
|
|
|
@@ -105,6 +72,10 @@ const closeAddComponentModal = () => {
|
|
|
105
72
|
}
|
|
106
73
|
provide('closeAddComponentModal', closeAddComponentModal)
|
|
107
74
|
|
|
75
|
+
const getConfigPageBuilder = computed(() => {
|
|
76
|
+
return pageBuilderStateStore.getConfigPageBuilder
|
|
77
|
+
})
|
|
78
|
+
|
|
108
79
|
const getMenuRight = computed(() => {
|
|
109
80
|
return pageBuilderStateStore.getMenuRight
|
|
110
81
|
})
|
|
@@ -150,17 +121,6 @@ const getComponents = computed(() => {
|
|
|
150
121
|
return pageBuilderStateStore.getComponents
|
|
151
122
|
})
|
|
152
123
|
|
|
153
|
-
const getCurrentUser = computed(() => {
|
|
154
|
-
return pageBuilderStateStore.getCurrentUser
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
const getCurrentResourceData = computed(() => {
|
|
158
|
-
return pageBuilderStateStore.getCurrentResourceData
|
|
159
|
-
})
|
|
160
|
-
const getUpdateOrCreate = computed(() => {
|
|
161
|
-
return pageBuilderStateStore.getUpdateOrCreate
|
|
162
|
-
})
|
|
163
|
-
|
|
164
124
|
const getElement = computed(() => {
|
|
165
125
|
return pageBuilderStateStore.getElement
|
|
166
126
|
})
|
|
@@ -246,9 +206,15 @@ onMounted(async () => {
|
|
|
246
206
|
class="px-4 lg:h-[10vh] h-[16vh] flex items-center justify-between border-b border-gray-200 bg-white"
|
|
247
207
|
>
|
|
248
208
|
<div class="flex items-center justify-start divide-x divide-gray-200">
|
|
249
|
-
<template
|
|
209
|
+
<template
|
|
210
|
+
v-if="
|
|
211
|
+
getConfigPageBuilder &&
|
|
212
|
+
getConfigPageBuilder.pageBuilderLogo &&
|
|
213
|
+
getConfigPageBuilder.pageBuilderLogo.src
|
|
214
|
+
"
|
|
215
|
+
>
|
|
250
216
|
<div class="border-r border-gray-200 pr-6">
|
|
251
|
-
<img class="h-6" :src="
|
|
217
|
+
<img class="h-6" :src="getConfigPageBuilder.pageBuilderLogo.src" alt="Logo" />
|
|
252
218
|
</div>
|
|
253
219
|
</template>
|
|
254
220
|
<button
|
|
@@ -280,66 +246,6 @@ onMounted(async () => {
|
|
|
280
246
|
</div>
|
|
281
247
|
<!-- Save laylout # end -->
|
|
282
248
|
|
|
283
|
-
<div class="py-4 p-4 bg-red-100 text-sm test-data m-4 rounded-lg">
|
|
284
|
-
<h3 class="font-semibold mb-3 text-gray-800">PageBuilder Debug Info</h3>
|
|
285
|
-
<div class="bg-white rounded border overflow-hidden">
|
|
286
|
-
<table class="min-w-full text-xs">
|
|
287
|
-
<thead class="bg-gray-50">
|
|
288
|
-
<tr>
|
|
289
|
-
<th class="px-3 py-2 text-left font-medium text-gray-700 border-b">Property</th>
|
|
290
|
-
<th class="px-3 py-2 text-left font-medium text-gray-700 border-b">Value</th>
|
|
291
|
-
<th class="px-3 py-2 text-left font-medium text-gray-700 border-b">Type</th>
|
|
292
|
-
<th class="px-3 py-2 text-left font-medium text-gray-700 border-b">Present</th>
|
|
293
|
-
</tr>
|
|
294
|
-
</thead>
|
|
295
|
-
<tbody class="divide-y divide-gray-200">
|
|
296
|
-
<tr>
|
|
297
|
-
<td class="px-3 py-2 font-medium text-gray-600">User (store)</td>
|
|
298
|
-
<td class="px-3 py-2">
|
|
299
|
-
{{ getCurrentUser ? JSON.stringify(getCurrentUser) : 'null' }}
|
|
300
|
-
</td>
|
|
301
|
-
<td class="px-3 py-2 text-gray-500">{{ typeof getCurrentUser }}</td>
|
|
302
|
-
<td class="px-3 py-2 text-gray-500">{{ !!getCurrentUser }}</td>
|
|
303
|
-
</tr>
|
|
304
|
-
<tr>
|
|
305
|
-
<td class="px-3 py-2 font-medium text-gray-600">Update or Create (store)</td>
|
|
306
|
-
<td class="px-3 py-2">{{ getUpdateOrCreate }}</td>
|
|
307
|
-
<td class="px-3 py-2 text-gray-500">{{ typeof getUpdateOrCreate }}</td>
|
|
308
|
-
<td class="px-3 py-2 text-gray-500">{{ !!getUpdateOrCreate }}</td>
|
|
309
|
-
</tr>
|
|
310
|
-
<tr>
|
|
311
|
-
<td class="px-3 py-2 font-medium text-gray-600">Resource Data (store)</td>
|
|
312
|
-
<td class="px-3 py-2">
|
|
313
|
-
{{ getCurrentResourceData ? JSON.stringify(getCurrentResourceData) : 'null' }}
|
|
314
|
-
</td>
|
|
315
|
-
<td class="px-3 py-2 text-gray-500">{{ typeof getCurrentResourceData }}</td>
|
|
316
|
-
<td class="px-3 py-2 text-gray-500">{{ !!getCurrentResourceData }}</td>
|
|
317
|
-
</tr>
|
|
318
|
-
<tr>
|
|
319
|
-
<td class="px-3 py-2 font-medium text-gray-600">Custom Media Component</td>
|
|
320
|
-
<td class="px-3 py-2">
|
|
321
|
-
{{ props.CustomMediaLibraryComponent ? 'Provided' : 'Not provided' }}
|
|
322
|
-
</td>
|
|
323
|
-
<td class="px-3 py-2 text-gray-500">
|
|
324
|
-
{{ props.CustomMediaLibraryComponent ? 'true' : 'false' }}
|
|
325
|
-
</td>
|
|
326
|
-
<td class="px-3 py-2 text-gray-500">{{ !!props.CustomMediaLibraryComponent }}</td>
|
|
327
|
-
</tr>
|
|
328
|
-
<tr>
|
|
329
|
-
<td class="px-3 py-2 font-medium text-gray-600">Custom Search Component</td>
|
|
330
|
-
<td class="px-3 py-2">
|
|
331
|
-
{{ props.CustomSearchComponent ? 'Provided' : 'Not provided' }}
|
|
332
|
-
</td>
|
|
333
|
-
<td class="px-3 py-2 text-gray-500">
|
|
334
|
-
{{ props.CustomSearchComponent ? 'true' : 'false' }}
|
|
335
|
-
</td>
|
|
336
|
-
<td class="px-3 py-2 text-gray-500">{{ !!props.CustomSearchComponent }}</td>
|
|
337
|
-
</tr>
|
|
338
|
-
</tbody>
|
|
339
|
-
</table>
|
|
340
|
-
</div>
|
|
341
|
-
</div>
|
|
342
|
-
|
|
343
249
|
<div class="relative h-full flex">
|
|
344
250
|
<div
|
|
345
251
|
@click.self="pageBuilderStateStore.setComponent(null)"
|
|
@@ -11,20 +11,20 @@ import type {
|
|
|
11
11
|
TailwindPaddingAndMargin,
|
|
12
12
|
TailwindBorderRadius,
|
|
13
13
|
TailwindBorderStyleWidthColor,
|
|
14
|
-
} from '
|
|
15
|
-
import type { usePageBuilderStateStore } from '
|
|
16
|
-
|
|
17
|
-
import tailwindColors from '
|
|
18
|
-
import tailwindOpacities from '
|
|
19
|
-
import tailwindFontSizes from '
|
|
20
|
-
import tailwindFontStyles from '
|
|
21
|
-
import tailwindPaddingAndMargin from '
|
|
22
|
-
import tailwindBorderRadius from '
|
|
23
|
-
import tailwindBorderStyleWidthPlusColor from '
|
|
14
|
+
} from '../types'
|
|
15
|
+
import type { usePageBuilderStateStore } from '../stores/page-builder-state'
|
|
16
|
+
|
|
17
|
+
import tailwindColors from '../utils/builder/tailwaind-colors'
|
|
18
|
+
import tailwindOpacities from '../utils/builder/tailwind-opacities'
|
|
19
|
+
import tailwindFontSizes from '../utils/builder/tailwind-font-sizes'
|
|
20
|
+
import tailwindFontStyles from '../utils/builder/tailwind-font-styles'
|
|
21
|
+
import tailwindPaddingAndMargin from '../utils/builder/tailwind-padding-margin'
|
|
22
|
+
import tailwindBorderRadius from '../utils/builder/tailwind-border-radius'
|
|
23
|
+
import tailwindBorderStyleWidthPlusColor from '../utils/builder/tailwind-border-style-width-color'
|
|
24
24
|
import { computed, ref, nextTick, inject } from 'vue'
|
|
25
25
|
import type { ComputedRef } from 'vue'
|
|
26
26
|
import { v4 as uuidv4 } from 'uuid'
|
|
27
|
-
import { delay } from '
|
|
27
|
+
import { delay } from './delay'
|
|
28
28
|
|
|
29
29
|
class PageBuilderClass {
|
|
30
30
|
// Class properties with types
|
|
@@ -280,8 +280,6 @@ class PageBuilderClass {
|
|
|
280
280
|
* attach event listeners to each element within a 'section'
|
|
281
281
|
*/
|
|
282
282
|
setEventListenersForElements = async () => {
|
|
283
|
-
console.log('setEventListenersForElements called')
|
|
284
|
-
|
|
285
283
|
if (this.showRunningMethodLogs) {
|
|
286
284
|
console.log('setEventListenersForElements')
|
|
287
285
|
}
|
|
@@ -1101,9 +1099,10 @@ class PageBuilderClass {
|
|
|
1101
1099
|
}
|
|
1102
1100
|
|
|
1103
1101
|
updateLocalStorageItemName(): void {
|
|
1104
|
-
const updateOrCreate =
|
|
1102
|
+
const updateOrCreate =
|
|
1103
|
+
this.pageBuilderStateStore.getConfigPageBuilder?.updateOrCreate || 'create'
|
|
1105
1104
|
|
|
1106
|
-
const resourceData = this.pageBuilderStateStore.
|
|
1105
|
+
const resourceData = this.pageBuilderStateStore.getConfigPageBuilder?.resourceData
|
|
1107
1106
|
|
|
1108
1107
|
// Logic for update
|
|
1109
1108
|
if (updateOrCreate === 'create') {
|
|
@@ -1213,21 +1212,7 @@ class PageBuilderClass {
|
|
|
1213
1212
|
const savedCurrentDesign = localStorage.getItem(this.getLocalStorageItemName.value)
|
|
1214
1213
|
|
|
1215
1214
|
if (savedCurrentDesign) {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
// Ensure components is always an array
|
|
1219
|
-
components = Array.isArray(components) ? components : []
|
|
1220
|
-
|
|
1221
|
-
// Transform HTML strings to component objects if needed
|
|
1222
|
-
if (components.length > 0 && typeof components[0] === 'string') {
|
|
1223
|
-
components = components.map((htmlString: string) => ({
|
|
1224
|
-
html_code: htmlString,
|
|
1225
|
-
}))
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
this.pageBuilderStateStore.setComponents(components)
|
|
1229
|
-
|
|
1230
|
-
return true
|
|
1215
|
+
return savedCurrentDesign
|
|
1231
1216
|
}
|
|
1232
1217
|
}
|
|
1233
1218
|
|
|
@@ -1465,6 +1450,81 @@ class PageBuilderClass {
|
|
|
1465
1450
|
this.#addHyperlinkToElement(hyperlinkEnable, urlInput || null, openHyperlinkInNewTab || false)
|
|
1466
1451
|
}
|
|
1467
1452
|
|
|
1453
|
+
// Helper method for custom components to easily add components
|
|
1454
|
+
async addComponent(componentObject: ComponentObject): Promise<void> {
|
|
1455
|
+
if (this.showRunningMethodLogs) {
|
|
1456
|
+
console.log('addComponent')
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
try {
|
|
1460
|
+
const clonedComponent = this.cloneCompObjForDOMInsertion({
|
|
1461
|
+
html_code: componentObject.html_code,
|
|
1462
|
+
id: componentObject.id,
|
|
1463
|
+
title: componentObject.title,
|
|
1464
|
+
})
|
|
1465
|
+
|
|
1466
|
+
this.pageBuilderStateStore.setPushComponents({
|
|
1467
|
+
component: clonedComponent,
|
|
1468
|
+
componentArrayAddMethod: this.getComponentArrayAddMethod.value || 'push',
|
|
1469
|
+
})
|
|
1470
|
+
|
|
1471
|
+
// Wait for the DOM to update before setting event listeners
|
|
1472
|
+
await nextTick()
|
|
1473
|
+
this.setEventListenersForElements()
|
|
1474
|
+
} catch (error) {
|
|
1475
|
+
console.error('Error adding component:', error)
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
// Load existing content from HTML when in update mode
|
|
1480
|
+
loadExistingContent(): void {
|
|
1481
|
+
if (this.showRunningMethodLogs) {
|
|
1482
|
+
console.log('loadExistingContent')
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
if (!this.pageBuilderStateStore.getConfigPageBuilder) return
|
|
1486
|
+
|
|
1487
|
+
const storedData = this.areComponentsStoredInLocalStorage()
|
|
1488
|
+
|
|
1489
|
+
if (storedData) {
|
|
1490
|
+
if (this.pageBuilderStateStore.getConfigPageBuilder.updateOrCreate === 'create') {
|
|
1491
|
+
try {
|
|
1492
|
+
// Parse the JSON string from localStorage
|
|
1493
|
+
const parsedData = JSON.parse(storedData)
|
|
1494
|
+
let savedCurrentDesign: ComponentObject[] = []
|
|
1495
|
+
|
|
1496
|
+
// Load ComponentObjects from localStorage
|
|
1497
|
+
if (Array.isArray(parsedData) && parsedData.length > 0) {
|
|
1498
|
+
// Data is always ComponentObjects with html_code, id, and title
|
|
1499
|
+
savedCurrentDesign = parsedData
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
this.pageBuilderStateStore.setComponents(savedCurrentDesign)
|
|
1503
|
+
} catch (error) {
|
|
1504
|
+
console.error('Error loading existing content:', error)
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
if (this.pageBuilderStateStore.getConfigPageBuilder.updateOrCreate === 'update') {
|
|
1509
|
+
try {
|
|
1510
|
+
// Parse the JSON string from localStorage
|
|
1511
|
+
const parsedData = JSON.parse(storedData)
|
|
1512
|
+
let savedCurrentDesign: ComponentObject[] = []
|
|
1513
|
+
|
|
1514
|
+
// Load ComponentObjects from localStorage
|
|
1515
|
+
if (Array.isArray(parsedData) && parsedData.length > 0) {
|
|
1516
|
+
// Data is always ComponentObjects with html_code, id, and title
|
|
1517
|
+
savedCurrentDesign = parsedData
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
this.pageBuilderStateStore.setComponents(savedCurrentDesign)
|
|
1521
|
+
} catch (error) {
|
|
1522
|
+
console.error('Error loading existing content:', error)
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1468
1528
|
async handlePageBuilderMethods(): Promise<void> {
|
|
1469
1529
|
await new Promise((resolve) => requestAnimationFrame(resolve))
|
|
1470
1530
|
|
|
@@ -1518,56 +1578,6 @@ class PageBuilderClass {
|
|
|
1518
1578
|
// handle classes
|
|
1519
1579
|
await this.currentClasses()
|
|
1520
1580
|
}
|
|
1521
|
-
|
|
1522
|
-
// Helper method for custom components to easily add components
|
|
1523
|
-
async addComponent(componentObject: ComponentObject): Promise<void> {
|
|
1524
|
-
if (this.showRunningMethodLogs) {
|
|
1525
|
-
console.log('addComponent')
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
try {
|
|
1529
|
-
const clonedComponent = this.cloneCompObjForDOMInsertion({
|
|
1530
|
-
html_code: componentObject.html_code,
|
|
1531
|
-
id: componentObject.id,
|
|
1532
|
-
title: componentObject.title,
|
|
1533
|
-
})
|
|
1534
|
-
|
|
1535
|
-
this.pageBuilderStateStore.setPushComponents({
|
|
1536
|
-
component: clonedComponent,
|
|
1537
|
-
componentArrayAddMethod: this.getComponentArrayAddMethod.value || 'push',
|
|
1538
|
-
})
|
|
1539
|
-
|
|
1540
|
-
// Wait for the DOM to update before setting event listeners
|
|
1541
|
-
await nextTick()
|
|
1542
|
-
this.setEventListenersForElements()
|
|
1543
|
-
} catch (error) {
|
|
1544
|
-
console.error('Error adding component:', error)
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
// Load existing content from HTML when in update mode
|
|
1549
|
-
loadExistingContent(): void {
|
|
1550
|
-
if (this.showRunningMethodLogs) {
|
|
1551
|
-
console.log('loadExistingContent')
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
if (this.pageBuilderStateStore.getUpdateOrCreate === 'update') {
|
|
1555
|
-
if (this.areComponentsStoredInLocalStorage()) {
|
|
1556
|
-
try {
|
|
1557
|
-
// set components
|
|
1558
|
-
const htmlOutput =
|
|
1559
|
-
Array.isArray(this.getComponents.value) &&
|
|
1560
|
-
this.getComponents.value
|
|
1561
|
-
.map((component) => {
|
|
1562
|
-
return component.html_code
|
|
1563
|
-
})
|
|
1564
|
-
.join('')
|
|
1565
|
-
} catch (error) {
|
|
1566
|
-
console.error('Error loading existing content:', error)
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
1581
|
}
|
|
1572
1582
|
|
|
1573
1583
|
export default PageBuilderClass
|