@myissue/vue-website-page-builder 3.3.54 → 3.3.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myissue/vue-website-page-builder",
3
- "version": "3.3.54",
3
+ "version": "3.3.55",
4
4
  "description": "Vue 3 page builder component with drag & drop functionality.",
5
5
  "type": "module",
6
6
  "main": "./dist/vue-website-page-builder.umd.cjs",
@@ -6,13 +6,10 @@ import { getPageBuilder } from '../../../../composables/builderInstance'
6
6
 
7
7
  const pageBuilderService = getPageBuilder()
8
8
 
9
- // Use shared store instance
10
9
  const pageBuilderStateStore = sharedPageBuilderStore
11
10
 
12
11
  const currentClasses = ref(null)
13
- const getCurrentClasses = computed(() => {
14
- return pageBuilderStateStore.getCurrentClasses
15
- })
12
+ const getCurrentClasses = computed(() => pageBuilderStateStore.getCurrentClasses)
16
13
 
17
14
  watch(
18
15
  getCurrentClasses,
@@ -23,9 +20,28 @@ watch(
23
20
  )
24
21
 
25
22
  const inputClass = ref('')
23
+ const errorMessage = ref('') // <-- error message reactive ref
26
24
 
27
- const handleAddClasses = async function () {
28
- pageBuilderService.handleAddClasses(inputClass.value)
25
+ const handleAddClasses = async () => {
26
+ const classToAdd = inputClass.value.trim()
27
+
28
+ if (!classToAdd) {
29
+ errorMessage.value = 'Please enter a class name.'
30
+ return
31
+ }
32
+
33
+ // Add prefix if missing
34
+ const prefixedClass = classToAdd.startsWith('pbx-') ? classToAdd : 'pbx-' + classToAdd
35
+
36
+ // Check if class already exists
37
+ if (currentClasses.value?.includes(prefixedClass)) {
38
+ errorMessage.value = `Class "${prefixedClass}" is already added.`
39
+ return
40
+ }
41
+
42
+ errorMessage.value = '' // Clear error
43
+
44
+ pageBuilderService.handleAddClasses(classToAdd)
29
45
  await pageBuilderService.initializeElementStyles()
30
46
 
31
47
  inputClass.value = ''
@@ -36,6 +52,13 @@ const handleAddClasses = async function () {
36
52
  <EditorAccordion>
37
53
  <template #title>Generated CSS</template>
38
54
  <template #content>
55
+ <p class="pbx-myPrimaryParagraph pbx-font-medium pbx-py-0 pbx-my-4">CSS applied</p>
56
+
57
+ <label class="pbx-myPrimaryInputLabel">
58
+ This is the CSS applied by the builder. Add your own CSS and press Enter to apply it to the
59
+ selected element.
60
+ </label>
61
+
39
62
  <div class="pbx-flex pbx-flex-row pbx-flex-wrap pbx-gap-2 pbx-mt-2 pbx-mb-4">
40
63
  <div
41
64
  v-for="className in currentClasses"
@@ -56,28 +79,26 @@ const handleAddClasses = async function () {
56
79
  </div>
57
80
  </div>
58
81
 
59
- <div class="pbx-flex pbx-gap-2 pbx-item-center pbx-flex-col">
82
+ <div>
83
+ <label class="pbx-myPrimaryInputLabel">
84
+ Add your CSS.
85
+ <br />
86
+ The pbx- prefix is added automatically.
87
+ </label>
60
88
  <div class="pbx-flex pbx-gap-2 pbx-item-center">
61
- <div
62
- class="pbx-mt-1 pbx-relative pbx-flex pbx-items-center pbx-w-full pbx-border-solid pbx-border pbx-myPrimaryInput pbx-py-0 pbx-p-0"
63
- >
64
- <input
65
- v-model="inputClass"
66
- type="text"
67
- placeholder="Type class"
68
- @keydown.enter="handleAddClasses()"
69
- autocomplete="off"
70
- class="pbx-myPrimaryInput pbx-border-none pbx-rounded-r-none pbx-ml-0 pbx-w-full"
71
- />
72
- <div
73
- class="pbx-border-none pbx-rounded pbx-flex pbx-items-center pbx-justify-center pbx-h-full pbx-w-8"
74
- >
75
- <kbd class="pbx-myPrimaryParagraph pbx-text-gray-400 pbx-border-none"> ⏎ </kbd>
76
- </div>
77
- </div>
89
+ <input
90
+ v-model="inputClass"
91
+ type="text"
92
+ placeholder="Type class"
93
+ @keydown.enter="handleAddClasses()"
94
+ autocomplete="off"
95
+ class="pbx-myPrimaryInput"
96
+ />
97
+
98
+ <button @click="handleAddClasses" type="button" class="pbx-myPrimaryButton">Add</button>
78
99
  </div>
79
- <p class="pbx-myPrimaryInputError"></p>
80
100
  </div>
101
+ <p v-if="errorMessage" class="pbx-myPrimaryInputError">{{ errorMessage }}</p>
81
102
  </template>
82
103
  </EditorAccordion>
83
104
  </template>
@@ -15,6 +15,7 @@ import TipTap from '../../TipTap/TipTap.vue'
15
15
  import EditGetElement from './Editables/EditGetElement.vue'
16
16
  import ElementEditor from './Editables/ElementEditor.vue'
17
17
  import { getPageBuilder } from '../../../composables/builderInstance'
18
+ import EditorAccordion from '../EditorMenu/EditorAccordion.vue'
18
19
  const pageBuilderService = getPageBuilder()
19
20
  // Use shared store instance
20
21
  const pageBuilderStateStore = sharedPageBuilderStore
@@ -62,6 +63,15 @@ function onScroll() {
62
63
  lastScrollTop = scrollContainer.value.scrollTop
63
64
  }
64
65
  }
66
+
67
+ // handle download HTML
68
+ const handleDownloadHTML = function () {
69
+ downloadedComponents.value = getComponents.value.map((component) => {
70
+ return component.html_code
71
+ })
72
+
73
+ generateHTML('downloaded_html.html', downloadedComponents.value.join(''))
74
+ }
65
75
  </script>
66
76
 
67
77
  <template>
@@ -119,11 +129,25 @@ function onScroll() {
119
129
  </article>
120
130
  </div>
121
131
 
122
- <div>
123
- <article class="pbx-my-1 pbx-bg-white">
124
- <ElementEditor></ElementEditor>
125
- </article>
126
- </div>
132
+ <article class="pbx-my-1 pbx-bg-white">
133
+ <EditorAccordion>
134
+ <template #title>Download HTML</template>
135
+ <template #content>
136
+ <p class="pbx-myPrimaryParagraph pbx-font-medium pbx-py-0 pbx-my-4">
137
+ Download Page as HTML
138
+ </p>
139
+
140
+ <div class="pbx-mt-4">
141
+ <button @click="handleDownloadHTML" type="button" class="pbx-myPrimaryButton">
142
+ Download HTML file
143
+ </button>
144
+ </div>
145
+ </template>
146
+
147
+ <!-- Download Layout HTML - end -->
148
+ </EditorAccordion>
149
+ </article>
150
+
127
151
  <article class="pbx-mt-1 pbx-bg-white"></article>
128
152
  </div>
129
153
  </div>
@@ -34,15 +34,6 @@ const generateHTML = function (filename, HTML) {
34
34
 
35
35
  document.body.removeChild(element)
36
36
  }
37
-
38
- // handle download HTML
39
- const handleDownloadHTML = function () {
40
- downloadedComponents.value = getComponents.value.map((component) => {
41
- return component.html_code
42
- })
43
-
44
- generateHTML('downloaded_html.html', downloadedComponents.value.join(''))
45
- }
46
37
  </script>
47
38
 
48
39
  <template>
@@ -577,21 +568,6 @@ const handleDownloadHTML = function () {
577
568
  </div>
578
569
  </div>
579
570
  <!-- Advanced Settings - end -->
580
- <!-- Download Layout HTML - start -->
581
- <div
582
- class="pbx-mt-4 pbx-mb-4 pbx-py-8 pbx-px-2 pbx-border pbx-border-solid pbx-border-gray-600 pbx-rounded-xl"
583
- >
584
- <div class="pbx-flex pbx-items-left pbx-flex-col pbx-gap-1">
585
- <h3 class="pbx-myQuaternaryHeader">Download Page as HTML</h3>
586
- <p class="pbx-myPrimaryParagraph pbx-text-xs">Download current page layout.</p>
587
- </div>
588
- <div class="pbx-mt-4">
589
- <button @click="handleDownloadHTML" type="button" class="pbx-myPrimaryButton">
590
- Download HTML file
591
- </button>
592
- </div>
593
- </div>
594
- <!-- Download Layout HTML - end -->
595
571
 
596
572
  <!-- Congig - start -->
597
573
  <div
@@ -74,7 +74,7 @@ const configPageBuilder = {
74
74
  userSettings: {
75
75
  theme: 'light',
76
76
  language: 'en',
77
- autoSave: false,
77
+ autoSave: true,
78
78
  },
79
79
  settings: {
80
80
  brandColor: '#DB93B0',
@@ -850,22 +850,24 @@ export class PageBuilderService {
850
850
  handleAddClasses(userSelectedClass: string): void {
851
851
  if (
852
852
  typeof userSelectedClass === 'string' &&
853
- userSelectedClass !== '' &&
853
+ userSelectedClass.trim() !== '' &&
854
854
  !userSelectedClass.includes(' ') &&
855
- // Check if class already exists
856
- !this.getElement.value?.classList.contains(userSelectedClass)
855
+ // Check if class (with prefix) already exists
856
+ !this.getElement.value?.classList.contains('pbx-' + userSelectedClass.trim())
857
857
  ) {
858
- // Remove any leading/trailing spaces
859
858
  const cleanedClass = userSelectedClass.trim()
860
859
 
861
- this.getElement.value?.classList.add(cleanedClass)
860
+ // Add prefix if missing
861
+ const prefixedClass = cleanedClass.startsWith('pbx-') ? cleanedClass : 'pbx-' + cleanedClass
862
862
 
863
- this.pageBuilderStateStore.setElement(this.getElement.value)
863
+ console.log('Adding class:', prefixedClass)
864
+
865
+ this.getElement.value?.classList.add(prefixedClass)
864
866
 
865
- this.pageBuilderStateStore.setClass(userSelectedClass)
867
+ this.pageBuilderStateStore.setElement(this.getElement.value)
868
+ this.pageBuilderStateStore.setClass(prefixedClass)
866
869
  }
867
870
  }
868
-
869
871
  handleFontFamily(userSelectedFontFamily?: string): void {
870
872
  this.#applyElementClassChanges(
871
873
  userSelectedFontFamily,