@myissue/vue-website-page-builder 3.0.33 → 3.1.0

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": "v3.0.33",
3
+ "version": "v3.1.0",
4
4
  "description": "🚧 DEVELOPMENT VERSION - Vue.js page builder component with drag & drop functionality. Not ready for production use.",
5
5
  "type": "module",
6
6
  "main": "./dist/vue-website-page-builder.umd.cjs",
@@ -7,7 +7,7 @@ import {
7
7
  TransitionRoot,
8
8
  } from '@headlessui/vue'
9
9
  import { provide } from 'vue'
10
- import NoneCustomMediaLibraryComponent from '@/Components/PageBuilder/NoneCustomMediaLibraryComponent.vue'
10
+ import NoneCustomMediaLibraryComponent from '@/Components/PageBuilder/DemoContent/NoneCustomMediaLibraryComponent.vue'
11
11
 
12
12
  const props = defineProps({
13
13
  title: {
@@ -1,11 +1,11 @@
1
1
  <script setup lang="ts">
2
- import componentHelpers from '../../utils/html-elements/componentHelpers'
3
- import components from '../../utils/html-elements/component'
4
- import PageBuilderClass from '../../composables/PageBuilderClass'
5
- import { usePageBuilderModal } from '../../composables/usePageBuilderModal'
6
- import { generateComponentPreview } from '../../utils/componentPreviews'
7
- import type { ComponentObject } from '../../types'
8
- import { usePageBuilderStateStore } from '../../stores/page-builder-state'
2
+ import componentHelpers from '../../../utils/html-elements/componentHelpers'
3
+ import components from '../../../utils/html-elements/component'
4
+ import PageBuilderClass from '../../../composables/PageBuilderClass'
5
+ import { usePageBuilderModal } from '../../../composables/usePageBuilderModal'
6
+ import { generateComponentPreview } from '../../../utils/componentPreviews'
7
+ import type { ComponentObject } from '../../../types'
8
+ import { usePageBuilderStateStore } from '../../../stores/page-builder-state'
9
9
  import type { Pinia } from 'pinia'
10
10
 
11
11
  import { inject } from 'vue'
@@ -75,8 +75,8 @@ const getSvgPreview = (title: string) => {
75
75
  @click="handleDropComponent(helper)"
76
76
  >
77
77
  <div class="max-h-72 cursor-pointer object-contain bg-white mx-auto">
78
- <div class="mr-2" v-html="helper.icon"></div>
79
- <h4 class="myPrimaryParagraph text-sm font-normal">{{ helper.title }}</h4>
78
+ <div v-if="false" class="mr-2" v-html="helper.icon"></div>
79
+ <h4 class="myPrimaryParagraph text-base font-medium">{{ helper.title }}</h4>
80
80
  </div>
81
81
  <div class="myPrimaryParagraph text-xs font-normal pt-2">
82
82
  Click to add {{ helper.title.toLowerCase() }} component
@@ -79,14 +79,14 @@ const deleteAllComponents = function () {
79
79
 
80
80
  // handle slideover window
81
81
  const handleSettingsSlideOver = function () {
82
- pageBuilderStateStore.setComponent(null)
82
+ // pageBuilderStateStore.setComponent(null)
83
83
 
84
84
  titleSettingsSlideOverRight.value = 'Settings'
85
85
  showSettingsSlideOverRight.value = true
86
86
  }
87
87
  // handle slideover window
88
88
  const settingsSlideOverButton = function () {
89
- pageBuilderStateStore.setComponent(null)
89
+ // pageBuilderStateStore.setComponent(null)
90
90
 
91
91
  showSettingsSlideOverRight.value = false
92
92
  }
@@ -99,6 +99,12 @@ const updateCurrentTab = function (tab) {
99
99
  </div>
100
100
  <div class="px-4 pb-8 pt-4 text-white text-xs break-all">
101
101
  <div v-if="current === 'element'">
102
+ <p>eeeer: {{ getElement }}</p>
103
+ <div v-if="!getComponent">
104
+ <p class="pb-2">
105
+ {{ getComponent === null ? 'NULL' : typeof getComponent }}
106
+ </p>
107
+ </div>
102
108
  <div v-if="getElement">
103
109
  <div class="flex flex-col gap-4 border-b border-white mb-4 pb-4">
104
110
  <p>Selected element outerHTML:</p>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import Modal from '@/Components/Modals/Modal.vue'
3
- import NoneCustomSearchComponent from '@/Components/PageBuilder/NoneCustomSearchComponent.vue'
3
+ import NoneCustomSearchComponent from '@/Components/PageBuilder/DemoContent/NoneCustomSearchComponent.vue'
4
4
 
5
5
  const props = defineProps({
6
6
  firstButtonText: {
@@ -215,6 +215,7 @@ onMounted(async () => {
215
215
  //
216
216
 
217
217
  pageBuilderClass.loadExistingContent()
218
+ pageBuilderClass.removeHoveredAndSelected()
218
219
  })
219
220
  </script>
220
221
 
@@ -438,12 +439,12 @@ onMounted(async () => {
438
439
  @click="pageBuilderStateStore.setMenuRight(true)"
439
440
  >
440
441
  <div class="flex items-center justify-center gap-2">
441
- <span class="lg:block hidden"> Design </span>
442
+ <span class="lg:block hidden"> Styling </span>
442
443
 
443
444
  <span
444
445
  class="h-10 w-10 cursor-pointer rounded-full flex items-center border-none justify-center bg-gray-50 aspect-square hover:bg-myPrimaryLinkColor hover:text-white focus-visible:ring-0"
445
446
  >
446
- <span class="myMediumIcon material-symbols-outlined"> palette </span>
447
+ <span class="myMediumIcon material-symbols-outlined"> tune </span>
447
448
  </span>
448
449
  </div>
449
450
  </button>
@@ -128,36 +128,53 @@ class PageBuilderClass {
128
128
  }
129
129
 
130
130
  #applyElementClassChanges(
131
- selectedCSS: string,
131
+ selectedCSS: string | undefined,
132
132
  CSSArray: string[],
133
133
  mutationName: string,
134
134
  ): string | undefined {
135
+ //
136
+ //
135
137
  if (this.showRunningMethodLogs) {
136
138
  console.log('#applyElementClassChanges')
137
139
  }
138
140
 
141
+ const currentHTMLElement = this.getElement.value
142
+ if (!currentHTMLElement) return
143
+
144
+ // currentCSS array example: ["none","py-0", "py-2", ...] or ['none', 'rounded-sm', 'rounded', 'rounded-md', ...]
139
145
  const currentCSS = CSSArray.find((CSS) => {
140
- return this.getElement.value?.classList.contains(CSS)
146
+ return currentHTMLElement.classList.contains(CSS)
141
147
  })
142
148
 
143
149
  // set to 'none' if undefined
144
- let elementClass =
145
- currentCSS || 'none'(this.pageBuilderStateStore as any)[mutationName](elementClass)
150
+ let elementClass = currentCSS || 'none'
151
+
152
+ // If selectedCSS is undefined, just set the current state and return
153
+ if (selectedCSS === undefined) {
154
+ if (typeof mutationName === 'string' && mutationName.length > 2) {
155
+ ;(this.pageBuilderStateStore as any)[mutationName](elementClass)
156
+ }
157
+ return currentCSS
158
+ }
146
159
 
160
+ // selectedCSS examples: bg-zinc-200, px-10, rounded-full etc.
147
161
  if (typeof selectedCSS === 'string' && selectedCSS !== 'none') {
148
- if (elementClass && this.getElement.value?.classList.contains(elementClass)) {
149
- this.getElement.value?.classList.remove(elementClass)
162
+ if (elementClass && currentHTMLElement.classList.contains(elementClass)) {
163
+ currentHTMLElement.classList.remove(elementClass)
150
164
  }
151
165
 
152
- this.getElement.value?.classList.add(selectedCSS)
166
+ currentHTMLElement.classList.add(selectedCSS)
153
167
  elementClass = selectedCSS
154
168
  } else if (typeof selectedCSS === 'string' && selectedCSS === 'none' && elementClass) {
155
- this.getElement.value?.classList.remove(elementClass)
169
+ currentHTMLElement.classList.remove(elementClass)
156
170
  elementClass = selectedCSS
157
171
  }
158
172
 
159
- this.pageBuilderStateStore[mutationName as keyof PageBuilderStateStore](elementClass)
160
- this.pageBuilderStateStore.setElement(this.getElement.value)
173
+ // Only call store mutations after all DOM manipulation is complete
174
+ if (typeof mutationName === 'string' && mutationName.length > 2) {
175
+ ;(this.pageBuilderStateStore as any)[mutationName](elementClass)
176
+ this.pageBuilderStateStore.setElement(currentHTMLElement)
177
+ }
161
178
 
162
179
  return currentCSS
163
180
  }
@@ -413,27 +430,36 @@ class PageBuilderClass {
413
430
  return clonedComponent
414
431
  }
415
432
 
416
- removeHoveredAndSelected() {
433
+ async removeHoveredAndSelected() {
417
434
  if (this.showRunningMethodLogs) {
418
435
  console.log('removeHoveredAndSelected')
419
436
  }
420
437
 
421
- const hoveredElement = document.querySelector('[hovered]')
438
+ await new Promise((resolve) => requestAnimationFrame(resolve))
439
+
440
+ const pagebuilder = document.querySelector('#pagebuilder')
441
+
442
+ if (!pagebuilder) return
443
+
444
+ const hoveredElement = pagebuilder.querySelector('[hovered]')
422
445
  if (hoveredElement) {
423
446
  hoveredElement.removeAttribute('hovered')
424
447
  }
425
448
 
426
- const selectedElement = document.querySelector('[selected]')
449
+ const selectedElement = pagebuilder.querySelector('[selected]')
450
+
427
451
  if (selectedElement) {
428
452
  selectedElement.removeAttribute('selected')
429
453
  }
430
454
  }
431
455
 
432
- currentClasses() {
456
+ async currentClasses() {
433
457
  if (this.showRunningMethodLogs) {
434
458
  console.log('handleAddClasses')
435
459
  }
436
460
 
461
+ await new Promise((resolve) => requestAnimationFrame(resolve))
462
+
437
463
  // convert classList to array
438
464
  const classListArray = Array.from(this.getElement.value?.classList || [])
439
465
 
@@ -497,13 +523,13 @@ class PageBuilderClass {
497
523
  // Store the parent of the deleted element
498
524
  // if parent element tag is section remove the hole component
499
525
  if (element.parentElement?.tagName !== 'SECTION') {
500
- this.pageBuilderStateStore.setParentElement(element.parentNode)
526
+ this.pageBuilderStateStore.setParentElement(element.parentNode as HTMLElement)
501
527
 
502
528
  // Store the outerHTML of the deleted element
503
529
  this.pageBuilderStateStore.setRestoredElement(element.outerHTML)
504
530
 
505
531
  // Store the next sibling of the deleted element
506
- this.pageBuilderStateStore.setNextSibling(element.nextSibling)
532
+ this.pageBuilderStateStore.setNextSibling(element.nextSibling as HTMLElement | null)
507
533
  }
508
534
 
509
535
  // if parent element tag is section remove the hole component
@@ -551,7 +577,6 @@ class PageBuilderClass {
551
577
  if (this.showRunningMethodLogs) {
552
578
  console.log('handleFontWeight')
553
579
  }
554
- if (!userSelectedFontWeight) return
555
580
 
556
581
  this.#applyElementClassChanges(
557
582
  userSelectedFontWeight,
@@ -563,7 +588,6 @@ class PageBuilderClass {
563
588
  if (this.showRunningMethodLogs) {
564
589
  console.log('handleFontFamily')
565
590
  }
566
- if (!userSelectedFontFamily) return
567
591
 
568
592
  this.#applyElementClassChanges(
569
593
  userSelectedFontFamily,
@@ -575,7 +599,6 @@ class PageBuilderClass {
575
599
  if (this.showRunningMethodLogs) {
576
600
  console.log('handleFontStyle')
577
601
  }
578
- if (!userSelectedFontStyle) return
579
602
 
580
603
  this.#applyElementClassChanges(
581
604
  userSelectedFontStyle,
@@ -587,7 +610,6 @@ class PageBuilderClass {
587
610
  if (this.showRunningMethodLogs) {
588
611
  console.log('handleVerticalPadding')
589
612
  }
590
- if (!userSelectedVerticalPadding) return
591
613
 
592
614
  this.#applyElementClassChanges(
593
615
  userSelectedVerticalPadding,
@@ -599,7 +621,6 @@ class PageBuilderClass {
599
621
  if (this.showRunningMethodLogs) {
600
622
  console.log('handleHorizontalPadding')
601
623
  }
602
- if (!userSelectedHorizontalPadding) return
603
624
 
604
625
  this.#applyElementClassChanges(
605
626
  userSelectedHorizontalPadding,
@@ -612,7 +633,6 @@ class PageBuilderClass {
612
633
  if (this.showRunningMethodLogs) {
613
634
  console.log('handleVerticalMargin')
614
635
  }
615
- if (!userSelectedVerticalMargin) return
616
636
 
617
637
  this.#applyElementClassChanges(
618
638
  userSelectedVerticalMargin,
@@ -624,7 +644,6 @@ class PageBuilderClass {
624
644
  if (this.showRunningMethodLogs) {
625
645
  console.log('handleHorizontalMargin')
626
646
  }
627
- if (!userSelectedHorizontalMargin) return
628
647
 
629
648
  this.#applyElementClassChanges(
630
649
  userSelectedHorizontalMargin,
@@ -638,7 +657,6 @@ class PageBuilderClass {
638
657
  if (this.showRunningMethodLogs) {
639
658
  console.log('handleBorderStyle')
640
659
  }
641
- if (!borderStyle) return
642
660
 
643
661
  this.#applyElementClassChanges(
644
662
  borderStyle,
@@ -650,7 +668,6 @@ class PageBuilderClass {
650
668
  if (this.showRunningMethodLogs) {
651
669
  console.log('handleBorderWidth')
652
670
  }
653
- if (!borderWidth) return
654
671
 
655
672
  this.#applyElementClassChanges(
656
673
  borderWidth,
@@ -662,7 +679,6 @@ class PageBuilderClass {
662
679
  if (this.showRunningMethodLogs) {
663
680
  console.log('handleBorderColor')
664
681
  }
665
- if (!borderColor) return
666
682
 
667
683
  this.#applyElementClassChanges(
668
684
  borderColor,
@@ -673,7 +689,6 @@ class PageBuilderClass {
673
689
  // border color, style & width / end
674
690
 
675
691
  handleBackgroundColor(color?: string): void {
676
- if (!color) return
677
692
  this.#applyElementClassChanges(
678
693
  color,
679
694
  tailwindColors.backgroundColorVariables,
@@ -682,7 +697,6 @@ class PageBuilderClass {
682
697
  }
683
698
 
684
699
  handleTextColor(color?: string): void {
685
- if (!color) return
686
700
  this.#applyElementClassChanges(color, tailwindColors.textColorVariables, 'setTextColor')
687
701
  }
688
702
 
@@ -691,7 +705,6 @@ class PageBuilderClass {
691
705
  if (this.showRunningMethodLogs) {
692
706
  console.log('handleBorderRadiusGlobal')
693
707
  }
694
- if (!borderRadiusGlobal) return
695
708
 
696
709
  this.#applyElementClassChanges(
697
710
  borderRadiusGlobal,
@@ -703,7 +716,6 @@ class PageBuilderClass {
703
716
  if (this.showRunningMethodLogs) {
704
717
  console.log('handleBorderRadiusTopLeft')
705
718
  }
706
- if (!borderRadiusTopLeft) return
707
719
 
708
720
  this.#applyElementClassChanges(
709
721
  borderRadiusTopLeft,
@@ -715,7 +727,6 @@ class PageBuilderClass {
715
727
  if (this.showRunningMethodLogs) {
716
728
  console.log('handleBorderRadiusTopRight')
717
729
  }
718
- if (!borderRadiusTopRight) return
719
730
 
720
731
  this.#applyElementClassChanges(
721
732
  borderRadiusTopRight,
@@ -727,7 +738,6 @@ class PageBuilderClass {
727
738
  if (this.showRunningMethodLogs) {
728
739
  console.log('handleBorderRadiusBottomleft')
729
740
  }
730
- if (!borderRadiusBottomleft) return
731
741
 
732
742
  this.#applyElementClassChanges(
733
743
  borderRadiusBottomleft,
@@ -739,7 +749,6 @@ class PageBuilderClass {
739
749
  if (this.showRunningMethodLogs) {
740
750
  console.log('handleBorderRadiusBottomRight')
741
751
  }
742
- if (!borderRadiusBottomRight) return
743
752
 
744
753
  this.#applyElementClassChanges(
745
754
  borderRadiusBottomRight,
@@ -857,7 +866,6 @@ class PageBuilderClass {
857
866
  if (this.showRunningMethodLogs) {
858
867
  console.log('handleBackgroundOpacity')
859
868
  }
860
- if (!opacity) return
861
869
 
862
870
  this.#applyElementClassChanges(
863
871
  opacity,
@@ -869,7 +877,6 @@ class PageBuilderClass {
869
877
  if (this.showRunningMethodLogs) {
870
878
  console.log('handleOpacity')
871
879
  }
872
- if (!opacity) return
873
880
 
874
881
  this.#applyElementClassChanges(opacity, tailwindOpacities.opacities, 'setOpacity')
875
882
  }
@@ -1454,7 +1461,9 @@ class PageBuilderClass {
1454
1461
  this.#addHyperlinkToElement(hyperlinkEnable, urlInput || null, openHyperlinkInNewTab || false)
1455
1462
  }
1456
1463
 
1457
- handlePageBuilderMethods(): void {
1464
+ async handlePageBuilderMethods(): Promise<void> {
1465
+ await new Promise((resolve) => requestAnimationFrame(resolve))
1466
+
1458
1467
  this.pageBuilderStateStore.setParentElement(null)
1459
1468
  this.pageBuilderStateStore.setRestoredElement(null)
1460
1469
 
@@ -1503,7 +1512,7 @@ class PageBuilderClass {
1503
1512
  // handle text color
1504
1513
  this.handleTextColor(undefined)
1505
1514
  // handle classes
1506
- this.currentClasses()
1515
+ await this.currentClasses()
1507
1516
  }
1508
1517
 
1509
1518
  // Helper method for custom components to easily add components
@@ -1,30 +0,0 @@
1
- <script setup>
2
- const emit = defineEmits(['handleButton']);
3
-
4
- // first button function
5
- const handleButton = function () {
6
- emit('handleButton');
7
- };
8
- </script>
9
-
10
- <template>
11
- <nav
12
- class="px-6 py-6 mx-auto flex items-center justify-between bg-gray-50 px-4 lg:h-[10vh] h-[16vh]"
13
- aria-label="Global"
14
- >
15
- <img
16
- class="h-6"
17
- src="/logo/logo.svg"
18
- alt="Logo"
19
- />
20
-
21
- <div class="flex lg:gap-x-12 myPrimaryGap">
22
- <p
23
- @click="handleButton"
24
- class="text-lg font-medium text-myPrimaryDarkGrayColor flex gap-2 items-center cursor-pointer"
25
- >
26
- Start Builder
27
- </p>
28
- </div>
29
- </nav>
30
- </template>
@@ -1,33 +0,0 @@
1
- <script setup>
2
- import { computed } from 'vue'
3
- import { usePageBuilderStateStore } from '@/stores/page-builder-state'
4
-
5
- const pageBuilderStateStore = usePageBuilderStateStore(internalPinia)
6
-
7
- const getCurrentImage = computed(() => {
8
- return pageBuilderStateStore.getCurrentImage
9
- })
10
- </script>
11
-
12
- <template>
13
- <!-- Loading # end -->
14
- <div v-if="getCurrentImage && getCurrentImage.src" class="pb-6 space-y-6">
15
- <img
16
- class="mx-auto block w-full object-cover object-center cursor-pointer"
17
- :src="`${getCurrentImage.src}`"
18
- alt="file"
19
- />
20
-
21
- <div class="md:px-3 px-2">
22
- <div>
23
- <h3 class="font-normal text-gray-900">Information</h3>
24
- <dl class="mt-2 border-t border-b border-gray-200 divide-y divide-gray-200">
25
- <div class="py-3 flex justify-between text-sm font-normal items-center">
26
- <dt class="text-gray-500">From</dt>
27
- <dd class="text-gray-900">Unsplash</dd>
28
- </div>
29
- </dl>
30
- </div>
31
- </div>
32
- </div>
33
- </template>