@myissue/vue-website-page-builder 3.1.21 → 3.1.23

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.
Files changed (31) hide show
  1. package/dist/vue-website-page-builder.js +5199 -5181
  2. package/dist/vue-website-page-builder.umd.cjs +34 -34
  3. package/package.json +1 -1
  4. package/src/Components/Homepage/HomeSection.vue +5 -5
  5. package/src/Components/Modals/PageBuilderPreviewModal.vue +4 -14
  6. package/src/Components/PageBuilder/DemoContent/NoneCustomSearchComponent.vue +2 -8
  7. package/src/Components/PageBuilder/DropdownsPlusToggles/OptionsDropdown.vue +4 -3
  8. package/src/Components/PageBuilder/EditorMenu/Editables/BackgroundColorEditor.vue +6 -5
  9. package/src/Components/PageBuilder/EditorMenu/Editables/BorderRadius.vue +14 -13
  10. package/src/Components/PageBuilder/EditorMenu/Editables/Borders.vue +10 -9
  11. package/src/Components/PageBuilder/EditorMenu/Editables/ClassEditor.vue +8 -7
  12. package/src/Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue +4 -4
  13. package/src/Components/PageBuilder/EditorMenu/Editables/DeleteElement.vue +4 -3
  14. package/src/Components/PageBuilder/EditorMenu/Editables/EditGetElement.vue +4 -3
  15. package/src/Components/PageBuilder/EditorMenu/Editables/ElementEditor.vue +4 -3
  16. package/src/Components/PageBuilder/EditorMenu/Editables/ImageEditor.vue +4 -4
  17. package/src/Components/PageBuilder/EditorMenu/Editables/LinkEditor.vue +4 -3
  18. package/src/Components/PageBuilder/EditorMenu/Editables/ManageBackgroundOpacity.vue +6 -5
  19. package/src/Components/PageBuilder/EditorMenu/Editables/ManageOpacity.vue +6 -5
  20. package/src/Components/PageBuilder/EditorMenu/Editables/PaddingPlusMargin.vue +12 -11
  21. package/src/Components/PageBuilder/EditorMenu/Editables/TextColorEditor.vue +6 -5
  22. package/src/Components/PageBuilder/EditorMenu/Editables/Typography.vue +18 -17
  23. package/src/Components/PageBuilder/EditorMenu/RightSidebarEditor.vue +4 -3
  24. package/src/Components/PageBuilder/Settings/AdvancedPageBuilderSettings.vue +4 -3
  25. package/src/Components/PageBuilder/Settings/PageBuilderSettings.vue +16 -14
  26. package/src/Components/TipTap/TipTap.vue +3 -3
  27. package/src/Components/TipTap/TipTapInput.vue +4 -3
  28. package/src/PageBuilder/PageBuilder.vue +33 -26
  29. package/src/composables/PageBuilderClass.ts +22 -14
  30. package/src/index.ts +5 -2
  31. package/src/stores/shared-store.ts +13 -0
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
- import { computed, inject } from 'vue'
2
+ import { computed } from 'vue'
3
+ import { sharedPageBuilderStore } from '../../../stores/shared-store'
3
4
  import ClassEditor from './Editables/ClassEditor.vue'
4
5
  import ImageEditor from './Editables/ImageEditor.vue'
5
6
  import OpacityEditor from './Editables/OpacityEditor.vue'
@@ -14,8 +15,8 @@ import TipTap from '../../TipTap/TipTap.vue'
14
15
  import EditGetElement from './Editables/EditGetElement.vue'
15
16
  import ElementEditor from './Editables/ElementEditor.vue'
16
17
 
17
- // Get stores from parent PageBuilder component
18
- const pageBuilderStateStore = inject('pageBuilderStateStore')
18
+ // Use shared store instance
19
+ const pageBuilderStateStore = sharedPageBuilderStore
19
20
 
20
21
  // emit
21
22
  const emit = defineEmits(['closeEditor'])
@@ -1,8 +1,9 @@
1
1
  <script setup>
2
- import { ref, computed, inject } from 'vue'
2
+ import { ref, computed } from 'vue'
3
+ import { sharedPageBuilderStore } from '../../../stores/shared-store'
3
4
 
4
- // Get stores from parent PageBuilder component
5
- const pageBuilderStateStore = inject('pageBuilderStateStore')
5
+ // Use shared store instance
6
+ const pageBuilderStateStore = sharedPageBuilderStore
6
7
 
7
8
  const getElement = computed(() => {
8
9
  return pageBuilderStateStore.getElement
@@ -1,12 +1,13 @@
1
1
  <script setup>
2
2
  import SlideOverRightParent from '../Slidebars/SlideOverRightParent.vue'
3
3
  import AdvancedPageBuilderSettings from './AdvancedPageBuilderSettings.vue'
4
- import { ref, computed, inject } from 'vue'
4
+ import { ref, computed } from 'vue'
5
+ import { sharedPageBuilderStore } from '../../../stores/shared-store'
5
6
  import fullHTMLContent from '../../../utils/builder/html-doc-declaration-with-components'
6
7
  const version = __APP_VERSION__
7
8
 
8
- // Get stores from parent PageBuilder component
9
- const pageBuilderStateStore = inject('pageBuilderStateStore')
9
+ // Use shared store instance
10
+ const pageBuilderStateStore = sharedPageBuilderStore
10
11
 
11
12
  const showAdvancedSettingsSlideOverRight = ref(false)
12
13
  const titleSettingsSlideOverRight = ref('')
@@ -343,26 +344,27 @@ const handleDownloadHTML = function () {
343
344
  : 'bg-blue-100 text-blue-800'
344
345
  "
345
346
  >
346
- {{
347
- getConfigPageBuilder.updateOrCreate.formType === 'create'
348
- ? 'Creating new Resource'
349
- : 'Updating existing Resource'
350
- }}
347
+ <span v-if="getConfigPageBuilder.updateOrCreate.formType === 'create'">
348
+ {{ getConfigPageBuilder.updateOrCreate.formType }}
349
+ </span>
350
+ <span v-if="getConfigPageBuilder.updateOrCreate.formType === 'update'">
351
+ {{ getConfigPageBuilder.updateOrCreate.formType }}
352
+ </span>
351
353
  </span>
352
354
  </td>
353
355
  </tr>
354
- <tr>
356
+ <tr
357
+ v-if="
358
+ getConfigPageBuilder.updateOrCreate.createNewResourceFormName &&
359
+ getConfigPageBuilder.updateOrCreate.createNewResourceFormName.length > 0
360
+ "
361
+ >
355
362
  <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
356
363
  Form Name
357
364
  </td>
358
365
  <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
359
366
  <span
360
367
  class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium"
361
- :class="
362
- getConfigPageBuilder.updateOrCreate === 'create'
363
- ? 'bg-green-100 text-green-800'
364
- : 'bg-blue-100 text-blue-800'
365
- "
366
368
  >
367
369
  {{ getConfigPageBuilder.updateOrCreate.createNewResourceFormName }}
368
370
  </span>
@@ -1,9 +1,9 @@
1
1
  <script setup>
2
- import { inject } from 'vue'
3
2
  import PageBuilderClass from '../../composables/PageBuilderClass.ts'
3
+ import { sharedPageBuilderStore } from '../../stores/shared-store'
4
4
 
5
- // Get stores from parent PageBuilder component
6
- const pageBuilderStateStore = inject('pageBuilderStateStore')
5
+ // Use shared store instance
6
+ const pageBuilderStateStore = sharedPageBuilderStore
7
7
 
8
8
  const pageBuilderClass = new PageBuilderClass(pageBuilderStateStore)
9
9
  </script>
@@ -1,13 +1,14 @@
1
1
  <script setup>
2
2
  import { useEditor, EditorContent } from '@tiptap/vue-3'
3
3
  import StarterKit from '@tiptap/starter-kit'
4
- import { computed, onBeforeMount, onMounted, ref, watch, inject } from 'vue'
4
+ import { computed, onBeforeMount, onMounted, ref, watch } from 'vue'
5
5
  import PageBuilderClass from '../../composables/PageBuilderClass.ts'
6
6
  import Link from '@tiptap/extension-link'
7
7
  import DynamicModalBuilder from '../Modals/DynamicModalBuilder.vue'
8
+ import { sharedPageBuilderStore } from '../../stores/shared-store'
8
9
 
9
- // Get stores from parent PageBuilder component
10
- const pageBuilderStateStore = inject('pageBuilderStateStore')
10
+ // Use shared store instance
11
+ const pageBuilderStateStore = sharedPageBuilderStore
11
12
 
12
13
  const showModalUrl = ref(false)
13
14
 
@@ -1,6 +1,5 @@
1
1
  <script setup>
2
2
  import { onMounted, computed, ref, watch, provide } from 'vue'
3
- import { createPinia } from 'pinia'
4
3
  import PageBuilderClass from '../composables/PageBuilderClass.ts'
5
4
  import PageBuilderPreviewModal from '../Components/Modals/PageBuilderPreviewModal.vue'
6
5
  import Preview from './Preview.vue'
@@ -9,7 +8,7 @@ import EditGetElement from '../Components/PageBuilder/EditorMenu/Editables/EditG
9
8
  import SearchComponents from '../Components/Search/SearchComponents.vue'
10
9
  import OptionsDropdown from '../Components/PageBuilder/DropdownsPlusToggles/OptionsDropdown.vue'
11
10
  import RightSidebarEditor from '../Components/PageBuilder/EditorMenu/RightSidebarEditor.vue'
12
- import { usePageBuilderStateStore } from '../stores/page-builder-state'
11
+ import { sharedPageBuilderPinia, sharedPageBuilderStore } from '../stores/shared-store'
13
12
 
14
13
  /**
15
14
  * Props for PageBuilder component
@@ -34,24 +33,33 @@ const props = defineProps({
34
33
  },
35
34
  })
36
35
 
37
- // Create internal Pinia instance for PageBuilder package
38
- const internalPinia = createPinia()
39
- const pageBuilderStateStore = usePageBuilderStateStore(internalPinia)
36
+ // Use shared Pinia instance for PageBuilder package (THIS IS THE KEY CHANGE!)
37
+ const internalPinia = sharedPageBuilderPinia
38
+ const pageBuilderStateStore = sharedPageBuilderStore
40
39
 
41
40
  // Set configPageBuilder in store (this will be the single source of truth)
42
41
  if (props.configPageBuilder) {
43
- // Ensure updateOrCreate defaults to 'create' if not provided
42
+ // Ensure updateOrCreate defaults with proper deep merge
43
+ const defaultUpdateOrCreate = {
44
+ formType: 'create',
45
+ createNewResourceFormName: 'post',
46
+ }
47
+
48
+ const defaultUserSettings = {
49
+ theme: 'light',
50
+ language: 'en',
51
+ autoSave: true,
52
+ }
53
+
44
54
  const configWithDefaults = {
45
55
  ...props.configPageBuilder,
46
- updateOrCreate: props.configPageBuilder.updateOrCreate || {
47
- formType: 'create',
48
- createNewResourceFormName: 'post',
56
+ updateOrCreate: {
57
+ ...defaultUpdateOrCreate,
58
+ ...props.configPageBuilder.updateOrCreate,
49
59
  },
50
-
51
- userSettings: props.configPageBuilder.userSettings || {
52
- theme: 'light',
53
- language: 'en',
54
- autoSave: true,
60
+ userSettings: {
61
+ ...defaultUserSettings,
62
+ ...props.configPageBuilder.userSettings,
55
63
  },
56
64
  }
57
65
  pageBuilderStateStore.setConfigPageBuilder(configWithDefaults)
@@ -122,7 +130,8 @@ const handleAddComponent = function () {
122
130
  }
123
131
 
124
132
  const getComponents = computed(() => {
125
- return pageBuilderStateStore.getComponents
133
+ const components = pageBuilderStateStore.getComponents
134
+ return components
126
135
  })
127
136
 
128
137
  const getElement = computed(() => {
@@ -146,7 +155,7 @@ const getElementAttributes = computed(() => {
146
155
  return attributesToWatch
147
156
  })
148
157
 
149
- watch(getElementAttributes, (newAttributes, oldAttributes) => {
158
+ watch(getElementAttributes, async (newAttributes, oldAttributes) => {
150
159
  // Check if any of the specified attributes have changed
151
160
  if (
152
161
  newAttributes?.src !== oldAttributes?.src ||
@@ -156,8 +165,8 @@ watch(getElementAttributes, (newAttributes, oldAttributes) => {
156
165
  newAttributes?.dataImage !== oldAttributes?.dataImage
157
166
  ) {
158
167
  // Trigger your method when any of the specified attributes change
159
- pageBuilderClass.handlePageBuilderMethods()
160
- pageBuilderClass.setEventListenersForElements()
168
+ await pageBuilderClass.handlePageBuilderMethods()
169
+ await pageBuilderClass.setEventListenersForElements()
161
170
  }
162
171
  })
163
172
 
@@ -170,14 +179,12 @@ const draggableZone = ref(null)
170
179
  onMounted(async () => {
171
180
  pageBuilderClass.updateLocalStorageItemName()
172
181
  // Set up event listeners
173
- pageBuilderClass.setEventListenersForElements()
182
+ await pageBuilderClass.setEventListenersForElements()
174
183
 
175
- //
176
- //
177
- //
178
- //
184
+ if (getConfigPageBuilder.value.updateOrCreate.formType === 'create') {
185
+ pageBuilderClass.loadExistingContent()
186
+ }
179
187
 
180
- pageBuilderClass.loadExistingContent()
181
188
  pageBuilderClass.removeHoveredAndSelected()
182
189
  })
183
190
  </script>
@@ -371,8 +378,8 @@ onMounted(async () => {
371
378
  <div ref="draggableZone">
372
379
  <!-- Added Components to DOM # start -->
373
380
  <div
374
- v-for="component in Array.isArray(getComponents) && getComponents"
375
- :key="component"
381
+ v-for="component in getComponents"
382
+ :key="component.id"
376
383
  id="page-builder-editor-editable-area"
377
384
  class="bg-white grow"
378
385
  >
@@ -21,7 +21,7 @@ import tailwindFontStyles from '../utils/builder/tailwind-font-styles'
21
21
  import tailwindPaddingAndMargin from '../utils/builder/tailwind-padding-margin'
22
22
  import tailwindBorderRadius from '../utils/builder/tailwind-border-radius'
23
23
  import tailwindBorderStyleWidthPlusColor from '../utils/builder/tailwind-border-style-width-color'
24
- import { computed, ref, nextTick, inject } from 'vue'
24
+ import { computed, ref, nextTick } from 'vue'
25
25
  import type { ComputedRef } from 'vue'
26
26
  import { v4 as uuidv4 } from 'uuid'
27
27
  import { delay } from './delay'
@@ -72,7 +72,6 @@ class PageBuilderClass {
72
72
 
73
73
  this.timer = null
74
74
 
75
- // Store is now required parameter - no fallback to inject
76
75
  this.pageBuilderStateStore = pageBuilderStateStore
77
76
 
78
77
  this.getTextAreaVueModel = computed(() => this.pageBuilderStateStore.getTextAreaVueModel)
@@ -541,7 +540,7 @@ class PageBuilderClass {
541
540
  this.pageBuilderStateStore.setElement(null)
542
541
  }
543
542
 
544
- handleRestoreElement() {
543
+ async handleRestoreElement() {
545
544
  if (this.showRunningMethodLogs) {
546
545
  console.log('handleRestoreElement')
547
546
  }
@@ -568,7 +567,7 @@ class PageBuilderClass {
568
567
  this.pageBuilderStateStore.setComponent(null)
569
568
  this.pageBuilderStateStore.setElement(null)
570
569
 
571
- this.setEventListenersForElements()
570
+ await this.setEventListenersForElements()
572
571
  }
573
572
 
574
573
  handleFontWeight(userSelectedFontWeight?: string): void {
@@ -1475,35 +1474,47 @@ class PageBuilderClass {
1475
1474
 
1476
1475
  // Wait for the DOM to update before setting event listeners
1477
1476
  await nextTick()
1478
- this.setEventListenersForElements()
1477
+ await this.setEventListenersForElements()
1479
1478
  } catch (error) {
1480
1479
  console.error('Error adding component:', error)
1481
1480
  }
1482
1481
  }
1483
1482
 
1484
- // Public method to parse and set components from JSON or HTML
1483
+ /**
1484
+ * Parse and set components from JSON or HTML data
1485
+ *
1486
+ * Supports:
1487
+ * - JSON: Array of ComponentObject with html_code, id, title
1488
+ * - HTML: String containing <section data-componentid="..."> elements
1489
+ *
1490
+ * Auto-detects format and parses accordingly
1491
+ *
1492
+ * @param data - JSON string (e.g., '[{"html_code":"...","id":"123","title":"..."}]')
1493
+ * OR HTML string (e.g., '<section data-componentid="123">...</section>')
1494
+ */
1485
1495
  setComponentsFromData(data: string): void {
1486
1496
  if (this.showRunningMethodLogs) {
1487
1497
  console.log('setComponentsFromData')
1488
1498
  }
1489
-
1490
1499
  // Auto-detect if input is JSON or HTML
1491
1500
  const trimmedData = data.trim()
1492
1501
 
1493
1502
  if (trimmedData.startsWith('[') || trimmedData.startsWith('{')) {
1503
+ console.log('Using JSON method..............1')
1494
1504
  // Looks like JSON - parse as JSON
1495
1505
  this.#parseJSONComponents(trimmedData)
1496
1506
  } else if (trimmedData.startsWith('<')) {
1507
+ console.log('Using HTML method..............2')
1497
1508
  // Looks like HTML - parse as HTML
1498
1509
  this.#parseHTMLComponents(trimmedData)
1499
1510
  } else {
1511
+ console.log('Using JSON method..............3')
1500
1512
  this.#parseJSONComponents(trimmedData)
1501
1513
  }
1502
1514
  }
1503
1515
 
1504
1516
  // Private method to parse JSON components
1505
1517
  #parseJSONComponents(jsonData: string): void {
1506
- console.log('using HTML method...')
1507
1518
  try {
1508
1519
  const parsedData = JSON.parse(jsonData)
1509
1520
  let savedCurrentDesign: ComponentObject[] = []
@@ -1524,7 +1535,6 @@ class PageBuilderClass {
1524
1535
 
1525
1536
  // Private method to parse HTML components
1526
1537
  #parseHTMLComponents(htmlData: string): void {
1527
- console.log('using JSON method...')
1528
1538
  try {
1529
1539
  // Parse the HTML content using DOMParser
1530
1540
  const parser = new DOMParser()
@@ -1554,7 +1564,7 @@ class PageBuilderClass {
1554
1564
  }
1555
1565
 
1556
1566
  // Load existing content from HTML when in update mode
1557
- loadExistingContent(JSONComponents?: string): void {
1567
+ loadExistingContent(data?: string): void {
1558
1568
  if (this.showRunningMethodLogs) {
1559
1569
  console.log('loadExistingContent')
1560
1570
  }
@@ -1570,10 +1580,8 @@ class PageBuilderClass {
1570
1580
  }
1571
1581
 
1572
1582
  if (this.pageBuilderStateStore.getConfigPageBuilder?.updateOrCreate?.formType === 'update') {
1573
- console.log('should come here, since update...... passed JSONComponents are:', JSONComponents)
1574
- // Update mode: Use passed JSONComponents
1575
- if (JSONComponents) {
1576
- this.setComponentsFromData(JSONComponents)
1583
+ if (data) {
1584
+ this.setComponentsFromData(data)
1577
1585
  }
1578
1586
  }
1579
1587
  }
package/src/index.ts CHANGED
@@ -5,16 +5,19 @@ export { default as Preview } from './PageBuilder/Preview.vue'
5
5
  // Export stores (consolidated into single store)
6
6
  export { usePageBuilderStateStore } from './stores/page-builder-state'
7
7
 
8
- export { default as PageBuilderClass } from './composables/PageBuilderClass'
8
+ export { default as PageBuilderClass } from './composables/PageBuilderClass.ts'
9
9
 
10
10
  // Export composables
11
11
  export { usePageBuilderModal } from './composables/usePageBuilderModal'
12
12
 
13
13
  // Export types
14
- export type { PageBuilderUser, ComponentObject, ImageObject } from './types'
14
+ export type { PageBuilderUser, ComponentObject, ImageObject, PageBuilderConfig } from './types'
15
15
 
16
16
  // Export Pinia for convenience (same version as package uses)
17
17
  export { createPinia } from 'pinia'
18
18
 
19
19
  // Export CSS (users will need to import this separately)
20
20
  import './css/app.css'
21
+
22
+ // Export shared store instances for external access
23
+ export { sharedPageBuilderPinia, sharedPageBuilderStore } from './stores/shared-store'
@@ -0,0 +1,13 @@
1
+ import { createPinia } from 'pinia'
2
+ import { usePageBuilderStateStore } from './page-builder-state'
3
+ import type { PageBuilderStateStore } from '../types'
4
+
5
+ // Create a shared Pinia instance that will be used across the entire package
6
+ export const sharedPageBuilderPinia = createPinia()
7
+
8
+ // Create and export a shared store instance with proper typing
9
+ export const sharedPageBuilderStore: ReturnType<typeof usePageBuilderStateStore> =
10
+ usePageBuilderStateStore(sharedPageBuilderPinia)
11
+
12
+ // Export the store and Pinia instance for external use
13
+ export { usePageBuilderStateStore } from './page-builder-state'