@myissue/vue-website-page-builder 3.0.1
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/LICENSE +21 -0
- package/README.md +470 -0
- package/dist/android-chrome-192x192.png +0 -0
- package/dist/android-chrome-512x512.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/browserconfig.xml +9 -0
- package/dist/components.json +36 -0
- package/dist/favicon-16x16.png +0 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/home/features.jpg +0 -0
- package/dist/home/page-builder-example.jpg +0 -0
- package/dist/logo/logo.svg +49 -0
- package/dist/mstile-310x150.png +0 -0
- package/dist/mstile-310x310.png +0 -0
- package/dist/page-builder/2-images-text-top.png +0 -0
- package/dist/page-builder/2-images.png +0 -0
- package/dist/page-builder/3-images.png +0 -0
- package/dist/page-builder/6-images.png +0 -0
- package/dist/page-builder/image.png +0 -0
- package/dist/page-builder/placeholder.jpg +0 -0
- package/dist/page-builder/two-vertical-images.png +0 -0
- package/dist/placeholder_image.jpg +0 -0
- package/dist/robots.txt +2 -0
- package/dist/vue-website-page-builder.css +1 -0
- package/dist/vue-website-page-builder.js +24794 -0
- package/dist/vue-website-page-builder.umd.cjs +195 -0
- package/package.json +99 -0
- package/src/App.vue +122 -0
- package/src/Components/Homepage/Footer.vue +42 -0
- package/src/Components/Homepage/HomeSection.vue +540 -0
- package/src/Components/Homepage/Navbar.vue +30 -0
- package/src/Components/Layouts/FullWidthElement.vue +34 -0
- package/src/Components/Loaders/FullScreenSpinner.vue +13 -0
- package/src/Components/Loaders/SmallUniversalSpinner.vue +26 -0
- package/src/Components/MediaLibrary/SidebarUnsplash.vue +40 -0
- package/src/Components/MediaLibrary/Unsplash.vue +306 -0
- package/src/Components/Modals/DynamicModal.vue +476 -0
- package/src/Components/Modals/MediaLibraryModal.vue +418 -0
- package/src/Components/Modals/Modal.vue +102 -0
- package/src/Components/Modals/PageBuilderModal.vue +233 -0
- package/src/Components/Modals/PageBuilderPreviewModal.vue +123 -0
- package/src/Components/PageBuilder/DropdownsPlusToggles/OptionsDropdown.vue +202 -0
- package/src/Components/PageBuilder/DropdownsPlusToggles/SaveDesign.vue +7 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/BackgroundColorEditor.vue +91 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/BorderRadius.vue +163 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/Borders.vue +164 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/ClassEditor.vue +80 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue +93 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/DeleteElement.vue +42 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/EditGetElement.vue +338 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/ElementEditor.vue +58 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/ImageEditor.vue +82 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/LinkEditor.vue +301 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/ManageBackgroundOpacity.vue +109 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/ManageOpacity.vue +107 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/OpacityEditor.vue +16 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/PaddingPlusMargin.vue +134 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/TextColorEditor.vue +91 -0
- package/src/Components/PageBuilder/EditorMenu/Editables/Typography.vue +199 -0
- package/src/Components/PageBuilder/EditorMenu/EditorAccordion.vue +42 -0
- package/src/Components/PageBuilder/EditorMenu/RightSidebarEditor.vue +113 -0
- package/src/Components/PageBuilder/Settings/AdvancedPageBuilderSettings.vue +229 -0
- package/src/Components/PageBuilder/Settings/PageBuilderSettings.vue +101 -0
- package/src/Components/PageBuilder/Slidebars/SlideOverRight.vue +91 -0
- package/src/Components/PageBuilder/Slidebars/SlideOverRightParent.vue +91 -0
- package/src/Components/Search/SearchComponents.vue +259 -0
- package/src/Components/TipTap/TipTap.vue +32 -0
- package/src/Components/TipTap/TipTapInput.vue +325 -0
- package/src/PageBuilder/PageBuilder.vue +347 -0
- package/src/PageBuilder/Preview.vue +24 -0
- package/src/composables/PageBuilder.ts +1483 -0
- package/src/composables/delay.ts +5 -0
- package/src/composables/extract-text-content-html.ts +34 -0
- package/src/composables/isObject.ts +6 -0
- package/src/composables/usePromise.ts +10 -0
- package/src/composables/vueFetch.ts +278 -0
- package/src/css/app.css +614 -0
- package/src/index.ts +16 -0
- package/src/main.ts +11 -0
- package/src/stores/media-library.ts +34 -0
- package/src/stores/page-builder-state.ts +461 -0
- package/src/stores/unsplash.ts +107 -0
- package/src/stores/user.ts +30 -0
- package/src/types/global.d.ts +49 -0
- package/src/utils/builder/compiledCSS.ts +2205 -0
- package/src/utils/builder/html-doc-declaration-with-components.ts +7 -0
- package/src/utils/builder/html-elements/componentHelpers.ts +101 -0
- package/src/utils/builder/tailwaind-colors.ts +503 -0
- package/src/utils/builder/tailwind-border-radius.ts +67 -0
- package/src/utils/builder/tailwind-border-style-width-color.ts +272 -0
- package/src/utils/builder/tailwind-font-sizes.ts +76 -0
- package/src/utils/builder/tailwind-font-styles.ts +24 -0
- package/src/utils/builder/tailwind-opacities.ts +45 -0
- package/src/utils/builder/tailwind-padding-margin.ts +159 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const extractAllTextContent = (html: string, maxLength: number): string => {
|
|
2
|
+
const parser = new DOMParser()
|
|
3
|
+
const doc = parser.parseFromString(html, 'text/html')
|
|
4
|
+
|
|
5
|
+
// Extract content from all elements and insert space after each dot
|
|
6
|
+
const allElements = doc.body.querySelectorAll('*')
|
|
7
|
+
const contentArray = Array.from(allElements).map(
|
|
8
|
+
(element) => element.textContent?.trim().replace(/\./g, '. ') || '',
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// Join the extracted content into a single string
|
|
12
|
+
let content = contentArray.join(' ')
|
|
13
|
+
content = content.replace(/\s+/g, ' ')
|
|
14
|
+
|
|
15
|
+
// Limit the content to the first maxLength characters
|
|
16
|
+
content = content.slice(0, maxLength)
|
|
17
|
+
|
|
18
|
+
return content
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const extractTextContentHTML = function extractTextContentHTML(
|
|
22
|
+
html: string | null | undefined,
|
|
23
|
+
maxLength: number,
|
|
24
|
+
postType: string = 'Page',
|
|
25
|
+
): string {
|
|
26
|
+
if (html) {
|
|
27
|
+
// Extract all text content
|
|
28
|
+
const extractedContent = extractAllTextContent(html, maxLength)
|
|
29
|
+
|
|
30
|
+
return extractedContent ? extractedContent : `Fashion & Jobs | ${postType}`
|
|
31
|
+
} else {
|
|
32
|
+
return `Fashion & Jobs | ${postType}`
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
import type { Ref } from 'vue'
|
|
3
|
+
import { usePromise } from '@/composables/usePromise'
|
|
4
|
+
import { isObject } from '@/composables/isObject'
|
|
5
|
+
|
|
6
|
+
// Type definitions
|
|
7
|
+
interface CustomFetchOptions {
|
|
8
|
+
abortTimeoutTime?: number
|
|
9
|
+
additionalCallTime?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface VueFetchReturn {
|
|
13
|
+
isSuccess: Ref<boolean>
|
|
14
|
+
isLoading: Ref<boolean>
|
|
15
|
+
isError: Ref<boolean>
|
|
16
|
+
error: Ref<string | null>
|
|
17
|
+
errors: Ref<unknown>
|
|
18
|
+
handleData: (
|
|
19
|
+
url: string,
|
|
20
|
+
fetchOptions?: RequestInit,
|
|
21
|
+
customFetchOptions?: CustomFetchOptions,
|
|
22
|
+
) => Promise<unknown>
|
|
23
|
+
fetchedData: Ref<unknown>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const vueFetch = function vueFetch(): VueFetchReturn {
|
|
27
|
+
// Initializing state management references
|
|
28
|
+
const isSuccess: Ref<boolean> = ref(false)
|
|
29
|
+
const isLoading: Ref<boolean> = ref(false)
|
|
30
|
+
const isError: Ref<boolean> = ref(false)
|
|
31
|
+
const error: Ref<string | null> = ref(null)
|
|
32
|
+
const errors: Ref<unknown> = ref(null)
|
|
33
|
+
const goDirectToError: Ref<boolean> = ref(false)
|
|
34
|
+
const fetchedData: Ref<unknown> = ref(null)
|
|
35
|
+
const streamAlreadyRead: Ref<boolean | null> = ref(null)
|
|
36
|
+
const response: Ref<Response | null> = ref(null)
|
|
37
|
+
|
|
38
|
+
const additionalTime: Ref<number | null> = ref(null)
|
|
39
|
+
const abortTimeout: Ref<number | null> = ref(null)
|
|
40
|
+
|
|
41
|
+
// Function to handle data fetching and state updates
|
|
42
|
+
const handleData = async function (
|
|
43
|
+
url: string,
|
|
44
|
+
fetchOptions: RequestInit = {},
|
|
45
|
+
customFetchOptions: CustomFetchOptions = {},
|
|
46
|
+
): Promise<unknown> {
|
|
47
|
+
isSuccess.value = false
|
|
48
|
+
isLoading.value = false
|
|
49
|
+
isError.value = false
|
|
50
|
+
error.value = null
|
|
51
|
+
errors.value = null
|
|
52
|
+
goDirectToError.value = false
|
|
53
|
+
fetchedData.value = null
|
|
54
|
+
streamAlreadyRead.value = null
|
|
55
|
+
response.value = null
|
|
56
|
+
|
|
57
|
+
// Initialize or set timeout and additional time values
|
|
58
|
+
abortTimeout.value = customFetchOptions.abortTimeoutTime ?? 4000
|
|
59
|
+
additionalTime.value = customFetchOptions.additionalCallTime ?? 0
|
|
60
|
+
|
|
61
|
+
// Initializing fetch operation control parameters
|
|
62
|
+
const controller = new AbortController()
|
|
63
|
+
|
|
64
|
+
// Abort fetch operation after the specified timeout
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
controller.abort()
|
|
67
|
+
}, abortTimeout.value)
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
// Begin fetch operation
|
|
71
|
+
isLoading.value = true
|
|
72
|
+
const promise = usePromise(additionalTime.value)
|
|
73
|
+
await promise
|
|
74
|
+
|
|
75
|
+
// Check for abort signal and handle accordingly
|
|
76
|
+
if (controller.signal.aborted) {
|
|
77
|
+
clearTimeout(timer)
|
|
78
|
+
isLoading.value = false
|
|
79
|
+
isError.value = false
|
|
80
|
+
goDirectToError.value = true
|
|
81
|
+
|
|
82
|
+
throw new Error('Error 500. Loading time exceeded.')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Fetch and handle response
|
|
86
|
+
response.value = await fetch(url, {
|
|
87
|
+
...fetchOptions,
|
|
88
|
+
signal: controller.signal,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Check if the fetch request was successful. If not, throw an error
|
|
92
|
+
if (response.value.status !== 200 && response.value.status !== 201) {
|
|
93
|
+
throw new Error(`${response.value.status}. ${response.value.statusText}`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Parse JSON response when content-type is 'application/json'
|
|
97
|
+
const contentType = response.value.headers.get('content-type') || ''
|
|
98
|
+
|
|
99
|
+
// Content-Type 'application/json'
|
|
100
|
+
if (contentType.includes('application/json')) {
|
|
101
|
+
streamAlreadyRead.value = true
|
|
102
|
+
clearTimeout(timer)
|
|
103
|
+
isSuccess.value = true
|
|
104
|
+
isLoading.value = false
|
|
105
|
+
isError.value = false
|
|
106
|
+
|
|
107
|
+
fetchedData.value = await response.value.json()
|
|
108
|
+
return fetchedData.value
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Content-Type 'text/plain' or 'text/html'
|
|
112
|
+
if (contentType.includes('text/plain') || contentType.includes('text/html')) {
|
|
113
|
+
streamAlreadyRead.value = true
|
|
114
|
+
clearTimeout(timer)
|
|
115
|
+
isSuccess.value = true
|
|
116
|
+
isLoading.value = false
|
|
117
|
+
isError.value = false
|
|
118
|
+
|
|
119
|
+
fetchedData.value = await response.value.text()
|
|
120
|
+
return fetchedData.value
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Handle non-GET requests without 'application/json', 'text/plain' or 'text/html'
|
|
124
|
+
if (
|
|
125
|
+
fetchOptions?.method !== 'GET' &&
|
|
126
|
+
fetchOptions?.method !== 'get' &&
|
|
127
|
+
fetchOptions?.method !== undefined
|
|
128
|
+
) {
|
|
129
|
+
clearTimeout(timer)
|
|
130
|
+
isSuccess.value = true
|
|
131
|
+
isLoading.value = false
|
|
132
|
+
isError.value = false
|
|
133
|
+
fetchedData.value = 'Your request was processed successfully.'
|
|
134
|
+
return 'Your request was processed successfully.'
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Handle GET requests without 'application/json' content-type
|
|
138
|
+
clearTimeout(timer)
|
|
139
|
+
isSuccess.value = true
|
|
140
|
+
isLoading.value = false
|
|
141
|
+
isError.value = false
|
|
142
|
+
goDirectToError.value = true
|
|
143
|
+
throw new Error(
|
|
144
|
+
"Error 500. The request header must contain 'application/json', 'text/plain' or 'text/html'",
|
|
145
|
+
)
|
|
146
|
+
} catch (err: unknown) {
|
|
147
|
+
clearTimeout(timer)
|
|
148
|
+
isSuccess.value = false
|
|
149
|
+
isLoading.value = false
|
|
150
|
+
|
|
151
|
+
// Set default error message
|
|
152
|
+
isError.value = true
|
|
153
|
+
const errorMessage = err instanceof Error ? err.message : String(err)
|
|
154
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}.`
|
|
155
|
+
|
|
156
|
+
if (response.value) {
|
|
157
|
+
// Get content type of the response
|
|
158
|
+
const contentType = response.value.headers.get('content-type') || ''
|
|
159
|
+
|
|
160
|
+
if (contentType.includes('application/json') && !streamAlreadyRead.value) {
|
|
161
|
+
// Handle errors when content type is 'application/json'
|
|
162
|
+
if (goDirectToError.value !== true) {
|
|
163
|
+
try {
|
|
164
|
+
// Parse the response body as JSON
|
|
165
|
+
const collectingErrorsJson = await response.value.json()
|
|
166
|
+
|
|
167
|
+
// Collect backend form validation errors
|
|
168
|
+
errors.value = collectingErrorsJson
|
|
169
|
+
|
|
170
|
+
// Handle different types of error messages
|
|
171
|
+
|
|
172
|
+
// If the error message is a string, handle it accordingly
|
|
173
|
+
if (typeof collectingErrorsJson === 'string') {
|
|
174
|
+
// Set error message when error body is a string
|
|
175
|
+
isError.value = true
|
|
176
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}. ${collectingErrorsJson}`
|
|
177
|
+
}
|
|
178
|
+
// If the error message is an array, handle it accordingly
|
|
179
|
+
else if (Array.isArray(collectingErrorsJson)) {
|
|
180
|
+
// Set error message when error body is an array
|
|
181
|
+
isError.value = true
|
|
182
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}. ${collectingErrorsJson.join(' ')}`
|
|
183
|
+
}
|
|
184
|
+
// If the error message is an object, handle it accordingly
|
|
185
|
+
else if (isObject(collectingErrorsJson)) {
|
|
186
|
+
const errorsKeys = Object.keys(collectingErrorsJson)
|
|
187
|
+
const errorsValues = Object.values(collectingErrorsJson)
|
|
188
|
+
|
|
189
|
+
// If there are no errors, handle it accordingly
|
|
190
|
+
if (errorsKeys.length === 0) {
|
|
191
|
+
// Set error message when error body is an empty object
|
|
192
|
+
isError.value = true
|
|
193
|
+
error.value = `Not able to fetch data. Error status: ${response.value.status}.`
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// If there are errors, handle them accordingly
|
|
197
|
+
if (errorsKeys.length > 0) {
|
|
198
|
+
for (let i = 0; i < errorsKeys.length; i++) {
|
|
199
|
+
if (Array.isArray(errorsValues[i]) || isObject(errorsValues[i])) {
|
|
200
|
+
// Set error message when encountering a nested object or array
|
|
201
|
+
isError.value = true
|
|
202
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}`
|
|
203
|
+
break
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// If the error is neither an array nor an object, handle it accordingly
|
|
207
|
+
if (!Array.isArray(errorsValues[i]) && !isObject(errorsValues[i])) {
|
|
208
|
+
const errorObjToString = Object.values(collectingErrorsJson).join(' ')
|
|
209
|
+
// Set error message when error body is a flat object
|
|
210
|
+
isError.value = true
|
|
211
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}. ${errorObjToString}`
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} catch {
|
|
217
|
+
// Handle JSON parsing error
|
|
218
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}`
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// If the response's Content-Type text/plain, handle it accordingly
|
|
224
|
+
if (contentType.includes('text/plain') && !streamAlreadyRead.value) {
|
|
225
|
+
try {
|
|
226
|
+
const plainText = await response.value.text()
|
|
227
|
+
// Remove HTML tags using a regular expression
|
|
228
|
+
const cleanedText = plainText.replace(/<\/?[^>]+(>|$)/g, '')
|
|
229
|
+
error.value = `Error: ${cleanedText}`
|
|
230
|
+
} catch {
|
|
231
|
+
// Handle text parsing error
|
|
232
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}`
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// If the response's Content-Type text/html, handle it accordingly
|
|
237
|
+
if (contentType.includes('text/html') && !streamAlreadyRead.value) {
|
|
238
|
+
try {
|
|
239
|
+
const htmlContent = await response.value.text()
|
|
240
|
+
// Remove HTML tags using a regular expression
|
|
241
|
+
const cleanedText = htmlContent.replace(/<\/?[^>]+(>|$)/g, '')
|
|
242
|
+
error.value = `Error: ${cleanedText}`
|
|
243
|
+
} catch {
|
|
244
|
+
// Handle HTML parsing error
|
|
245
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}`
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (
|
|
250
|
+
(!contentType.includes('application/json') &&
|
|
251
|
+
!contentType.includes('text/plain') &&
|
|
252
|
+
!contentType.includes('text/html')) ||
|
|
253
|
+
goDirectToError.value
|
|
254
|
+
) {
|
|
255
|
+
isError.value = true
|
|
256
|
+
error.value = `Not able to fetch data. Error status: ${errorMessage}`
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Rethrow the error for further handling
|
|
260
|
+
throw err
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Rethrow the error if no response
|
|
264
|
+
throw err
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Return the state variables and the fetch function
|
|
269
|
+
return {
|
|
270
|
+
isSuccess,
|
|
271
|
+
isLoading,
|
|
272
|
+
isError,
|
|
273
|
+
error,
|
|
274
|
+
errors,
|
|
275
|
+
handleData,
|
|
276
|
+
fetchedData,
|
|
277
|
+
}
|
|
278
|
+
}
|