@myissue/vue-website-page-builder 3.4.7 → 3.4.9
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/style.css +1 -1
- package/dist/vue-website-page-builder.js +1575 -1568
- package/dist/vue-website-page-builder.umd.cjs +5 -5
- package/package.json +1 -1
- package/src/PageBuilder/PageBuilder.vue +1 -1
- package/src/css/style.css +22 -3
- package/src/services/PageBuilderService.ts +77 -48
- package/src/tests/TestComponents/DemoUnsplash.vue +7 -7
package/package.json
CHANGED
|
@@ -864,7 +864,7 @@ onMounted(async () => {
|
|
|
864
864
|
<main
|
|
865
865
|
ref="pbxBuilderWrapper"
|
|
866
866
|
id="page-builder-wrapper"
|
|
867
|
-
class="pbx-transition-all pbx-duration-300 pbx-font-sans pbx-p-1 pbx-flex pbx-flex-col pbx-grow pbx-rounded-tr-2xl pbx-rounded-tl-2xl pbx-border-solid pbx-border pbx-border-gray-200 pbx-items-stretch pbx-text-black pbx-h-[100vh] pbx-overflow-y-scroll pbx-relative pbx-pt-
|
|
867
|
+
class="pbx-transition-all pbx-duration-300 pbx-font-sans pbx-p-1 pbx-flex pbx-flex-col pbx-grow pbx-rounded-tr-2xl pbx-rounded-tl-2xl pbx-border-solid pbx-border pbx-border-gray-200 pbx-items-stretch pbx-text-black pbx-h-[100vh] pbx-overflow-y-scroll pbx-relative pbx-pt-16"
|
|
868
868
|
:class="[getMenuRight ? 'pbx-w-full' : 'pbx-w-full']"
|
|
869
869
|
>
|
|
870
870
|
<div
|
package/src/css/style.css
CHANGED
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
min-width: 4rem;
|
|
368
368
|
padding-right: 1rem;
|
|
369
369
|
padding-left: 1rem;
|
|
370
|
-
height:
|
|
370
|
+
height: 2rem;
|
|
371
371
|
box-shadow: 0 0 0 10px oklch(86.9% 0.005 56.366);
|
|
372
372
|
background: oklch(86.9% 0.005 56.366);
|
|
373
373
|
}
|
|
@@ -376,6 +376,7 @@
|
|
|
376
376
|
#pagebuilder {
|
|
377
377
|
position: relative;
|
|
378
378
|
max-height: 100%;
|
|
379
|
+
min-height: fit-content;
|
|
379
380
|
}
|
|
380
381
|
#pagebuilder a {
|
|
381
382
|
pointer-events: none;
|
|
@@ -537,7 +538,7 @@
|
|
|
537
538
|
padding: 0;
|
|
538
539
|
}
|
|
539
540
|
|
|
540
|
-
/* Page Builder Start*/
|
|
541
|
+
/* Page Builder Reset Default Browser Styles Start*/
|
|
541
542
|
#pagebuilder input,
|
|
542
543
|
#pagebuilder button,
|
|
543
544
|
#pagebuilder textarea,
|
|
@@ -580,4 +581,22 @@
|
|
|
580
581
|
padding: 0;
|
|
581
582
|
margin: 0;
|
|
582
583
|
}
|
|
583
|
-
|
|
584
|
+
|
|
585
|
+
#pagebuilder img {
|
|
586
|
+
max-width: 100%;
|
|
587
|
+
height: auto;
|
|
588
|
+
display: block;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
#pagebuilder a {
|
|
592
|
+
color: inherit;
|
|
593
|
+
text-decoration: none;
|
|
594
|
+
}
|
|
595
|
+
#pagebuilder code,
|
|
596
|
+
#pagebuilder pre,
|
|
597
|
+
#pagebuilder strong,
|
|
598
|
+
#pagebuilder em {
|
|
599
|
+
font: inherit;
|
|
600
|
+
font-weight: inherit;
|
|
601
|
+
}
|
|
602
|
+
/* Page Builder Reset Default Browser Styles End*/
|
|
@@ -570,11 +570,11 @@ export class PageBuilderService {
|
|
|
570
570
|
/**
|
|
571
571
|
* Completes the mounting process by loading components into the DOM and setting up listeners.
|
|
572
572
|
* @param {string} html - The HTML string of components to mount.
|
|
573
|
-
* @param {boolean} [
|
|
573
|
+
* @param {boolean} [useConfigPageSettings] - Whether to use page settings from the passed data.
|
|
574
574
|
* @private
|
|
575
575
|
*/
|
|
576
|
-
private async completeMountProcess(html: string,
|
|
577
|
-
await this.mountComponentsToDOM(html,
|
|
576
|
+
private async completeMountProcess(html: string, useConfigPageSettings?: boolean) {
|
|
577
|
+
await this.mountComponentsToDOM(html, useConfigPageSettings)
|
|
578
578
|
|
|
579
579
|
// Clean up any old localStorage items related to previous builder sessions
|
|
580
580
|
this.deleteOldPageBuilderLocalStorage()
|
|
@@ -1452,7 +1452,7 @@ export class PageBuilderService {
|
|
|
1452
1452
|
.forEach((section) => section.remove())
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
|
-
|
|
1455
|
+
|
|
1456
1456
|
public async undo() {
|
|
1457
1457
|
this.pageBuilderStateStore.setIsLoadingGlobal(true)
|
|
1458
1458
|
await delay(300)
|
|
@@ -1464,7 +1464,7 @@ export class PageBuilderService {
|
|
|
1464
1464
|
this.pageBuilderStateStore.setHistoryIndex(this.pageBuilderStateStore.getHistoryIndex - 1)
|
|
1465
1465
|
const data = history[this.pageBuilderStateStore.getHistoryIndex]
|
|
1466
1466
|
const htmlString = this.renderComponentsToHtml(data.components)
|
|
1467
|
-
await this.mountComponentsToDOM(htmlString)
|
|
1467
|
+
await this.mountComponentsToDOM(htmlString, false, data.pageSettings)
|
|
1468
1468
|
}
|
|
1469
1469
|
this.pageBuilderStateStore.setIsLoadingGlobal(false)
|
|
1470
1470
|
}
|
|
@@ -1480,7 +1480,7 @@ export class PageBuilderService {
|
|
|
1480
1480
|
this.pageBuilderStateStore.setHistoryIndex(this.pageBuilderStateStore.getHistoryIndex + 1)
|
|
1481
1481
|
const data = history[this.pageBuilderStateStore.getHistoryIndex]
|
|
1482
1482
|
const htmlString = this.renderComponentsToHtml(data.components)
|
|
1483
|
-
await this.mountComponentsToDOM(htmlString)
|
|
1483
|
+
await this.mountComponentsToDOM(htmlString, false, data.pageSettings)
|
|
1484
1484
|
}
|
|
1485
1485
|
this.pageBuilderStateStore.setIsLoadingGlobal(false)
|
|
1486
1486
|
}
|
|
@@ -1667,9 +1667,7 @@ export class PageBuilderService {
|
|
|
1667
1667
|
await nextTick()
|
|
1668
1668
|
|
|
1669
1669
|
// Scroll to the moved component
|
|
1670
|
-
const pageBuilderWrapper = document.querySelector(
|
|
1671
|
-
'#page-builder-wrapper',
|
|
1672
|
-
) as HTMLElement | null
|
|
1670
|
+
const pageBuilderWrapper = document.querySelector('#page-builder-wrapper') as HTMLElement | null
|
|
1673
1671
|
const movedComponentElement = pageBuilderWrapper?.querySelector(
|
|
1674
1672
|
`section[data-componentid="${componentToMove.id}"]`,
|
|
1675
1673
|
) as HTMLElement
|
|
@@ -1951,6 +1949,10 @@ export class PageBuilderService {
|
|
|
1951
1949
|
|
|
1952
1950
|
if (baseKey) {
|
|
1953
1951
|
const currentDataRaw = localStorage.getItem(baseKey)
|
|
1952
|
+
|
|
1953
|
+
if (!currentDataRaw) {
|
|
1954
|
+
localStorage.setItem(baseKey, JSON.stringify(dataToSave))
|
|
1955
|
+
}
|
|
1954
1956
|
if (currentDataRaw) {
|
|
1955
1957
|
const currentData = JSON.parse(currentDataRaw)
|
|
1956
1958
|
|
|
@@ -1961,40 +1963,49 @@ export class PageBuilderService {
|
|
|
1961
1963
|
const hasChanges = newComponents.some((newComponent, index) => {
|
|
1962
1964
|
const currentComponent = currentComponents[index]
|
|
1963
1965
|
return (
|
|
1964
|
-
|
|
1965
|
-
currentComponent
|
|
1966
|
+
// New component added
|
|
1967
|
+
!currentComponent ||
|
|
1968
|
+
// Component HTML changed
|
|
1969
|
+
currentComponent.html_code !== newComponent.html_code
|
|
1966
1970
|
)
|
|
1967
1971
|
})
|
|
1968
1972
|
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
+
// Compare pageSettings
|
|
1974
|
+
const hasPageSettingsChanges =
|
|
1975
|
+
(currentData.pageSettings &&
|
|
1976
|
+
currentData.pageSettings.classes !== dataToSave.pageSettings.classes) ||
|
|
1977
|
+
(currentData.pageSettings &&
|
|
1978
|
+
currentData.pageSettings.style !== dataToSave.pageSettings.style)
|
|
1979
|
+
|
|
1980
|
+
// Only save to local storage if there's a difference between the existing saved data and the current DOM data
|
|
1981
|
+
if (hasChanges || hasPageSettingsChanges) {
|
|
1982
|
+
localStorage.setItem(baseKey, JSON.stringify(dataToSave))
|
|
1983
|
+
let history = LocalStorageManager.getHistory(baseKey)
|
|
1984
|
+
|
|
1985
|
+
const lastState = history[history.length - 1]
|
|
1986
|
+
if (lastState) {
|
|
1987
|
+
const lastComponents = JSON.stringify(lastState.components)
|
|
1988
|
+
const newComponents = JSON.stringify(dataToSave.components)
|
|
1989
|
+
const lastSettings = JSON.stringify(lastState.pageSettings)
|
|
1990
|
+
const newSettings = JSON.stringify(dataToSave.pageSettings)
|
|
1991
|
+
if (lastComponents === newComponents && lastSettings === newSettings) {
|
|
1992
|
+
return // Do not save duplicate state
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1973
1995
|
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
return
|
|
1996
|
+
if (this.pageBuilderStateStore.getHistoryIndex < history.length - 1) {
|
|
1997
|
+
history = history.slice(0, this.pageBuilderStateStore.getHistoryIndex + 1)
|
|
1998
|
+
}
|
|
1999
|
+
history.push(dataToSave)
|
|
2000
|
+
if (history.length > 10) {
|
|
2001
|
+
history = history.slice(history.length - 10)
|
|
2002
|
+
}
|
|
2003
|
+
localStorage.setItem(baseKey + '-history', JSON.stringify(history))
|
|
2004
|
+
this.pageBuilderStateStore.setHistoryIndex(history.length - 1)
|
|
2005
|
+
this.pageBuilderStateStore.setHistoryLength(history.length)
|
|
2006
|
+
return
|
|
1985
2007
|
}
|
|
1986
2008
|
}
|
|
1987
|
-
|
|
1988
|
-
if (this.pageBuilderStateStore.getHistoryIndex < history.length - 1) {
|
|
1989
|
-
history = history.slice(0, this.pageBuilderStateStore.getHistoryIndex + 1)
|
|
1990
|
-
}
|
|
1991
|
-
history.push(dataToSave)
|
|
1992
|
-
if (history.length > 10) {
|
|
1993
|
-
history = history.slice(history.length - 10)
|
|
1994
|
-
}
|
|
1995
|
-
localStorage.setItem(baseKey + '-history', JSON.stringify(history))
|
|
1996
|
-
this.pageBuilderStateStore.setHistoryIndex(history.length - 1)
|
|
1997
|
-
this.pageBuilderStateStore.setHistoryLength(history.length)
|
|
1998
2009
|
}
|
|
1999
2010
|
}
|
|
2000
2011
|
/**
|
|
@@ -2762,9 +2773,11 @@ export class PageBuilderService {
|
|
|
2762
2773
|
*
|
|
2763
2774
|
* Typical use cases include restoring a published state, importing templates, or previewing published content.
|
|
2764
2775
|
*/
|
|
2776
|
+
|
|
2765
2777
|
private async mountComponentsToDOM(
|
|
2766
2778
|
htmlString: string,
|
|
2767
2779
|
usePassedPageSettings?: boolean,
|
|
2780
|
+
pageSettingsFromHistory?: PageSettings,
|
|
2768
2781
|
): Promise<void> {
|
|
2769
2782
|
// Trim HTML string
|
|
2770
2783
|
const trimmedData = htmlString.trim()
|
|
@@ -2780,36 +2793,53 @@ export class PageBuilderService {
|
|
|
2780
2793
|
const importedPageBuilder = doc.querySelector('#pagebuilder') as HTMLElement | null
|
|
2781
2794
|
const livePageBuilder = document.querySelector('#pagebuilder') as HTMLElement | null
|
|
2782
2795
|
|
|
2783
|
-
// Initialize
|
|
2784
|
-
let
|
|
2796
|
+
// Initialize configPageSettings to null
|
|
2797
|
+
let configPageSettings = null
|
|
2785
2798
|
|
|
2786
2799
|
// Use stored page settings if the flag is true
|
|
2787
2800
|
if (usePassedPageSettings) {
|
|
2788
|
-
|
|
2801
|
+
configPageSettings = this.pageBuilderStateStore.getPageBuilderConfig?.pageSettings || null
|
|
2789
2802
|
}
|
|
2790
2803
|
|
|
2791
2804
|
// Use imported page builder settings if available and pageSettings is still null
|
|
2792
|
-
if (!
|
|
2793
|
-
|
|
2805
|
+
if (!pageSettingsFromHistory && !configPageSettings && importedPageBuilder) {
|
|
2806
|
+
configPageSettings = {
|
|
2794
2807
|
classes: importedPageBuilder.className || '',
|
|
2795
2808
|
style: importedPageBuilder.getAttribute('style') || '',
|
|
2796
2809
|
}
|
|
2797
2810
|
}
|
|
2798
2811
|
|
|
2799
2812
|
// Fallback to stored page settings if pageSettings is still null
|
|
2800
|
-
if (!
|
|
2801
|
-
|
|
2813
|
+
if (!configPageSettings) {
|
|
2814
|
+
configPageSettings = this.pageBuilderStateStore.getPageBuilderConfig?.pageSettings || null
|
|
2802
2815
|
}
|
|
2803
2816
|
|
|
2804
2817
|
// Apply the page settings to the live page builder
|
|
2805
|
-
if (
|
|
2818
|
+
if (!pageSettingsFromHistory && configPageSettings && livePageBuilder) {
|
|
2806
2819
|
// Remove existing class and style attributes
|
|
2807
2820
|
livePageBuilder.removeAttribute('class')
|
|
2808
2821
|
livePageBuilder.removeAttribute('style')
|
|
2809
2822
|
|
|
2810
2823
|
// Apply new classes and styles
|
|
2811
|
-
livePageBuilder.className =
|
|
2812
|
-
livePageBuilder.setAttribute(
|
|
2824
|
+
livePageBuilder.className = configPageSettings.classes || ''
|
|
2825
|
+
livePageBuilder.setAttribute(
|
|
2826
|
+
'style',
|
|
2827
|
+
this.convertStyleObjectToString(configPageSettings.style),
|
|
2828
|
+
)
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
// Apply the page settings to the live page builder
|
|
2832
|
+
if (pageSettingsFromHistory && livePageBuilder) {
|
|
2833
|
+
// Remove existing class and style attributes
|
|
2834
|
+
livePageBuilder.removeAttribute('class')
|
|
2835
|
+
livePageBuilder.removeAttribute('style')
|
|
2836
|
+
|
|
2837
|
+
// Apply new classes and styles
|
|
2838
|
+
livePageBuilder.className = pageSettingsFromHistory.classes || ''
|
|
2839
|
+
livePageBuilder.setAttribute(
|
|
2840
|
+
'style',
|
|
2841
|
+
this.convertStyleObjectToString(pageSettingsFromHistory.style),
|
|
2842
|
+
)
|
|
2813
2843
|
}
|
|
2814
2844
|
|
|
2815
2845
|
// Select all <section> elements
|
|
@@ -2860,7 +2890,6 @@ export class PageBuilderService {
|
|
|
2860
2890
|
await this.addListenersToEditableElements()
|
|
2861
2891
|
}
|
|
2862
2892
|
}
|
|
2863
|
-
|
|
2864
2893
|
private updateLocalStorageItemName(): void {
|
|
2865
2894
|
const formtype =
|
|
2866
2895
|
this.pageBuilderStateStore.getPageBuilderConfig &&
|
|
@@ -144,20 +144,20 @@ onMounted(async () => {
|
|
|
144
144
|
"
|
|
145
145
|
>
|
|
146
146
|
<div class="pbx-mysearchBarWithOptions">
|
|
147
|
-
<div class="pbx-relative pbx-w-full">
|
|
148
|
-
<div
|
|
149
|
-
class="pbx-flex pbx-absolute pbx-inset-y-0 pbx-left-0 pbx-items-center pbx-pl-3 pbx-pointer-events-none"
|
|
150
|
-
>
|
|
151
|
-
<span class="material-symbols-outlined"> search </span>
|
|
152
|
-
</div>
|
|
147
|
+
<div class="pbx-relative pbx-w-full pbx-flex pbx-gap-2">
|
|
153
148
|
<input
|
|
154
149
|
type="search"
|
|
155
150
|
id="search_query"
|
|
156
151
|
v-model="getSearchTerm"
|
|
157
|
-
class="pbx-myPrimarySearchInput pbx-w-full"
|
|
152
|
+
class="pbx-myPrimarySearchInput pbx-w-full pbx-pl-10 pbx-border-0"
|
|
158
153
|
autocomplete="off"
|
|
159
154
|
:placeholder="translate('Search...')"
|
|
160
155
|
/>
|
|
156
|
+
<div
|
|
157
|
+
class="pbx-flex pbx-absolute pbx-inset-y-0 pbx-left-0 pbx-items-center pbx-pl-3 pbx-pointer-events-none"
|
|
158
|
+
>
|
|
159
|
+
<span class="material-symbols-outlined"> search </span>
|
|
160
|
+
</div>
|
|
161
161
|
</div>
|
|
162
162
|
|
|
163
163
|
<button
|