@myissue/vue-website-page-builder 3.3.11 → 3.3.13
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/README.md +118 -131
- package/dist/vue-website-page-builder.css +1 -1
- package/dist/vue-website-page-builder.js +5382 -5317
- package/dist/vue-website-page-builder.umd.cjs +38 -38
- package/package.json +1 -1
- package/src/Components/Loaders/GlobalLoader.vue +1 -1
- package/src/Components/Modals/ModalBuilder.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue +4 -4
- package/src/Components/PageBuilder/EditorMenu/Editables/DeleteElement.vue +2 -2
- package/src/Components/PageBuilder/EditorMenu/Editables/ElementEditor.vue +2 -2
- package/src/Components/PageBuilder/ToolbarOption/ToolbarOption.vue +4 -4
- package/src/DemoComponents/HomeSection.vue +7 -3
- package/src/DemoComponents/html.json +46 -48
- package/src/PageBuilder/PageBuilder.vue +30 -27
- package/src/composables/PageBuilderService.ts +470 -337
- package/src/helpers/isEmptyObject.ts +1 -1
- package/src/stores/page-builder-state.ts +1 -1
- package/src/tailwind-safelist.html +1 -1
- package/src/types/index.ts +10 -0
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Powerful Page Builder for any growing merchants, brands, & agencies. Empower use
|
|
|
89
89
|
|
|
90
90
|
## Documentation
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
## Requirements
|
|
93
93
|
|
|
94
94
|
Please note that these instructions assume you have Node.js installed.
|
|
95
95
|
|
|
@@ -97,7 +97,7 @@ Please note that these instructions assume you have Node.js installed.
|
|
|
97
97
|
- Vue.js ≥ 3.0.0
|
|
98
98
|
- Modern browser with ES6+ support
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
## Getting started & installation
|
|
101
101
|
|
|
102
102
|
Make sure to install the dependencies:
|
|
103
103
|
|
|
@@ -115,15 +115,15 @@ yarn install
|
|
|
115
115
|
bun install
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
## Quick Start
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
### Initializing the Page Builder
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
To get started with the Page Builder, follow these steps:
|
|
123
123
|
|
|
124
|
-
-
|
|
125
|
-
|
|
126
|
-
- Import the CSS file once
|
|
124
|
+
- **Call `initPageBuilder()` once** in your application entry point (e.g., `main.ts` or `main.js`). This sets up the shared builder instance for your entire app.
|
|
125
|
+
- **Access the shared builder instance** anywhere in your application using the `getPageBuilder()` composable.
|
|
126
|
+
- **Import the CSS file once** in your `main.js`, `main.ts`, or root component to ensure proper styling and automatic icon loading.
|
|
127
127
|
|
|
128
128
|
```typescript
|
|
129
129
|
import { createApp } from 'vue'
|
|
@@ -131,26 +131,37 @@ import App from './App.vue'
|
|
|
131
131
|
import { initPageBuilder } from '@myissue/vue-website-page-builder'
|
|
132
132
|
import '@myissue/vue-website-page-builder/style.css'
|
|
133
133
|
|
|
134
|
-
// Initialize shared
|
|
135
|
-
//
|
|
134
|
+
// Initialize the shared Page Builder instance
|
|
135
|
+
// This must be called once in your app entry point
|
|
136
136
|
initPageBuilder()
|
|
137
137
|
|
|
138
138
|
const app = createApp(App)
|
|
139
139
|
app.mount('#app')
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
> **Note:**
|
|
143
|
+
> You only need to import the CSS file once. If you have already imported it in your app entry, you do not need to import it again in individual components.
|
|
144
|
+
|
|
145
|
+
### Accessing the Shared Page Builder Service
|
|
146
|
+
|
|
147
|
+
After initializing the Page Builder service in your application (by calling `initPageBuilder()` once in your app entry point), you may access the shared instance from anywhere in your application using the `getPageBuilder()` composable.
|
|
148
|
+
|
|
149
|
+
> **Note**
|
|
150
|
+
> The Page Builder is implemented as a singleton service. This ensures that all page-building logic and state are managed by a single, shared instance throughout your application.
|
|
143
151
|
|
|
144
|
-
|
|
152
|
+
#### Why Use the Shared Instance?
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
The Page Builder is implemented as a singleton service. This means there is only one instance that manages all page-building logic and state across your app. Using this shared instance avoids creating multiple, isolated copies of the builder, which can lead to data inconsistencies, synchronization issues, and unpredictable behavior.
|
|
154
|
+
By always accessing the shared instance, you avoid creating multiple, isolated copies of the builder. This prevents data inconsistencies, synchronization issues, and unpredictable behavior. All components and modules interact with the same centralized service, ensuring that updates and state changes are reflected everywhere in your application.
|
|
148
155
|
|
|
149
|
-
|
|
150
|
-
By accessing the shared instance, your components and modules interact with the same centralized service, allowing smooth and reliable updates and coordination. This guarantees that all builder actions and state changes are reflected everywhere in your app.
|
|
156
|
+
#### Usage
|
|
151
157
|
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
Ensure the following configuration options are set:
|
|
159
|
+
|
|
160
|
+
- **`formType` (required):**
|
|
161
|
+
Indicates whether you are creating or updating a resource. This is used to retrieve the correct content from local storage.
|
|
162
|
+
|
|
163
|
+
- **`formName` (required):**
|
|
164
|
+
Specifies the resource type (for example, `article`, `jobPost`, `store`, etc.). This is essential for platforms supporting multiple resource types, as it enables the builder to manage layouts and local storage for each resource uniquely.
|
|
154
165
|
|
|
155
166
|
```vue
|
|
156
167
|
<script setup>
|
|
@@ -164,9 +175,10 @@ const configPageBuilder = {
|
|
|
164
175
|
},
|
|
165
176
|
}
|
|
166
177
|
|
|
167
|
-
// Retrieve Page Builder service instance
|
|
168
178
|
const pageBuilderService = getPageBuilder()
|
|
169
|
-
await pageBuilderService.startBuilder(configPageBuilder)
|
|
179
|
+
const result = await pageBuilderService.startBuilder(configPageBuilder)
|
|
180
|
+
|
|
181
|
+
console.info('You may inspect this result for message, status, or error:', result)
|
|
170
182
|
</script>
|
|
171
183
|
|
|
172
184
|
<template>
|
|
@@ -174,76 +186,42 @@ await pageBuilderService.startBuilder(configPageBuilder)
|
|
|
174
186
|
</template>
|
|
175
187
|
```
|
|
176
188
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
The Page Builder requires its CSS file to be imported for proper styling and automatic icon loading.
|
|
180
|
-
|
|
181
|
-
**You only need to import the CSS file once, ideally in your `main.js`/`main.ts` or root component.**
|
|
182
|
-
If you have already imported it in your app entry, you do not need to import it again in individual components.
|
|
183
|
-
|
|
184
|
-
```vue
|
|
185
|
-
<script setup>
|
|
186
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
187
|
-
</script>
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
This import automatically includes:
|
|
191
|
-
|
|
192
|
-
- ✅ Page Builder styles
|
|
193
|
-
- ✅ Responsive design utilities
|
|
194
|
-
|
|
195
|
-
### Important: CSS Prefix (`pbx-`) for All Builder Styles
|
|
189
|
+
## Important: CSS Prefixing (`pbx-`)
|
|
196
190
|
|
|
197
|
-
|
|
191
|
+
All CSS classes generated or processed by the Page Builder—including Tailwind utilities and your custom classes—are automatically prefixed with `pbx-`. This ensures the builder’s styles never conflict with your app’s existing CSS or Tailwind setup.
|
|
198
192
|
|
|
199
|
-
**
|
|
193
|
+
**How does this affect you?**
|
|
200
194
|
|
|
201
|
-
-
|
|
202
|
-
-
|
|
203
|
-
- All Tailwind classes are also prefixed, e.g. `bg-red-100` becomes `pbx-bg-red-100`, `md:grid-cols-2` becomes `md:pbx-grid-cols-2`, etc.
|
|
204
|
-
|
|
205
|
-
**Why is this important?**
|
|
206
|
-
|
|
207
|
-
- The prefixing is done automatically by the builder to avoid style conflicts between the builder’s output and your own app’s CSS or Tailwind setup.
|
|
195
|
+
- Any class you use in builder components will be output as `pbx-ClassName`.
|
|
196
|
+
- Tailwind classes are also prefixed, e.g. `bg-red-100` becomes `pbx-bg-red-100`, `md:grid-cols-2` becomes `md:pbx-grid-cols-2`.
|
|
208
197
|
|
|
209
198
|
**Example:**
|
|
210
199
|
|
|
211
200
|
```html
|
|
212
|
-
<!-- Builder output -->
|
|
213
201
|
<div class="pbx-myCustomCSSClass pbx-bg-blue-100 md:pbx-grid-cols-2"></div>
|
|
214
202
|
```
|
|
215
203
|
|
|
216
204
|
```css
|
|
217
|
-
/* To style this element, use the pbx- prefix */
|
|
218
205
|
.pbx-myCustomCSSClass {
|
|
219
206
|
margin-bottom: 2rem;
|
|
220
207
|
}
|
|
221
208
|
```
|
|
222
209
|
|
|
223
|
-
**
|
|
210
|
+
> **Note:**
|
|
211
|
+
> Simply import the builder’s CSS file once in your project. All builder styles are namespaced, so there is no risk of style conflicts
|
|
224
212
|
|
|
225
|
-
|
|
226
|
-
<script setup>
|
|
227
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
228
|
-
</script>
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**What does this mean for you?**
|
|
213
|
+
## Rendering HTML Output in Other Frameworks (React, Nuxt, etc.)
|
|
232
214
|
|
|
233
|
-
|
|
234
|
-
- ✅ **There is no risk of style conflicts between the builder and your app, since all builder-related styles are namespaced.**.
|
|
215
|
+
You can use the Page Builder to generate HTML and render it in any frontend framework, such as React, Nuxt, or even server-side apps.
|
|
235
216
|
|
|
236
|
-
|
|
217
|
+
To ensure your content is styled correctly, simply install the Page Builder package in your target project and import its CSS file. All builder and Tailwind-prefixed styles will be applied automatically.
|
|
237
218
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
```vue
|
|
241
|
-
<script setup>
|
|
219
|
+
```js
|
|
220
|
+
// Import the builder's CSS file once in your project
|
|
242
221
|
import '@myissue/vue-website-page-builder/style.css'
|
|
243
|
-
</script>
|
|
244
222
|
```
|
|
245
223
|
|
|
246
|
-
This will apply all
|
|
224
|
+
This will apply all necessary styles to any HTML output from the builder, even if you render it with `dangerouslySetInnerHTML`, `v-html`, or similar methods.
|
|
247
225
|
|
|
248
226
|
**Example (React):**
|
|
249
227
|
|
|
@@ -265,20 +243,29 @@ import '@myissue/vue-website-page-builder/style.css'
|
|
|
265
243
|
|
|
266
244
|
Then use `v-html` to render the HTML.
|
|
267
245
|
|
|
268
|
-
> **Note:**
|
|
246
|
+
> **Note:**
|
|
247
|
+
> You do not need to import any Vue components if you only want to render the HTML. Just import the CSS file.
|
|
269
248
|
|
|
270
|
-
|
|
249
|
+
## Providing Configuration to the Page Builder
|
|
271
250
|
|
|
272
|
-
|
|
251
|
+
The example below demonstrates the setup to start building pages, with additional options available for customization and branding.
|
|
273
252
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
253
|
+
Your `configPageBuilder` object can include:
|
|
254
|
+
|
|
255
|
+
- **`formType` (required):**
|
|
256
|
+
Used to retrieve the correct content from local storage. Specify whether you are creating or updating a resource.
|
|
257
|
+
- **`formName` (required):**
|
|
258
|
+
The resource type (e.g., `article`, `jobPost`, `store`, etc.). This is especially useful for platforms supporting multiple resource types, allowing the builder to manage layouts and storage for each resource uniquely.
|
|
259
|
+
- **`resourceData` (optional):**
|
|
260
|
+
Prefill the builder with initial resource data (e.g., `title`, `id`).
|
|
261
|
+
- **`userForPageBuilder` (optional):**
|
|
262
|
+
Pass user information (such as `name` and `image`) to display the logged-in user’s details in the builder.
|
|
263
|
+
- **`pageBuilderLogo` (optional):**
|
|
264
|
+
Display your company logo in the builder toolbar.
|
|
265
|
+
- **`userSettings` (optional):**
|
|
266
|
+
Set user preferences such as theme, language, or auto-save.
|
|
267
|
+
- **`brandColor` (optional):**
|
|
268
|
+
Set your brand’s primary color for key UI elements (inside the `settings` config).
|
|
282
269
|
|
|
283
270
|
```vue
|
|
284
271
|
<script setup>
|
|
@@ -310,7 +297,9 @@ const configPageBuilder = {
|
|
|
310
297
|
|
|
311
298
|
// Retrieve Page Builder service instance
|
|
312
299
|
const pageBuilderService = getPageBuilder()
|
|
313
|
-
await pageBuilderService.startBuilder(configPageBuilder)
|
|
300
|
+
const result = await pageBuilderService.startBuilder(configPageBuilder)
|
|
301
|
+
|
|
302
|
+
console.info('You may inspect this result for message, status, or error:', result)
|
|
314
303
|
</script>
|
|
315
304
|
|
|
316
305
|
<template>
|
|
@@ -318,23 +307,20 @@ await pageBuilderService.startBuilder(configPageBuilder)
|
|
|
318
307
|
</template>
|
|
319
308
|
```
|
|
320
309
|
|
|
321
|
-
|
|
310
|
+
## Local Storage & Auto-Save
|
|
322
311
|
|
|
323
|
-
The Page Builder automatically
|
|
312
|
+
The Page Builder automatically saves all changes to the browser’s local storage. Every time you add, edit, or delete a component, your progress is preserved—even if you close the browser or navigate away.
|
|
324
313
|
|
|
325
|
-
- **Auto-Save:**
|
|
326
|
-
- **Manual Save:**
|
|
314
|
+
- **Auto-Save:** Changes are periodically saved as you work.
|
|
315
|
+
- **Manual Save:** Clicking the Save button also stores the current state.
|
|
327
316
|
|
|
328
|
-
|
|
317
|
+
## Retrieving the Latest HTML Content for Form Submission
|
|
329
318
|
|
|
330
|
-
The
|
|
319
|
+
The builder’s auto-save ensures that the data in local storage always reflects the latest state of your page. You can retrieve this data at any time for form submission, publishing, or preview.
|
|
331
320
|
|
|
332
|
-
To
|
|
321
|
+
To get the most up-to-date content, use the same `resourceData` (such as `formType` and `formName`) that was used when saving. If these values do not match, the builder may not find the expected content.
|
|
333
322
|
|
|
334
|
-
**
|
|
335
|
-
To retrieve the correct content from local storage, you must pass the same `resourceData` (such as `formType` and `formName`) to the Page Builder that was used when the content was originally saved. If the resource data does not match, the Page Builder will look for a different local storage key and may not find the expected content.
|
|
336
|
-
|
|
337
|
-
Example:
|
|
323
|
+
**Example:**
|
|
338
324
|
|
|
339
325
|
```js
|
|
340
326
|
const configPageBuilder = {
|
|
@@ -345,7 +331,7 @@ const configPageBuilder = {
|
|
|
345
331
|
}
|
|
346
332
|
```
|
|
347
333
|
|
|
348
|
-
Call this logic when you
|
|
334
|
+
Call this logic when you need to submit or save the builder’s output—for example, when the user clicks “Save” or “Publish.” The code below safely retrieves and parses the latest data from local storage, handling errors and assigning the results to your form fields.
|
|
349
335
|
|
|
350
336
|
```vue
|
|
351
337
|
<script setup>
|
|
@@ -380,7 +366,7 @@ try {
|
|
|
380
366
|
</script>
|
|
381
367
|
```
|
|
382
368
|
|
|
383
|
-
|
|
369
|
+
### Resetting the Builder After Successful Resource Creation or Update
|
|
384
370
|
|
|
385
371
|
After you have successfully created or updated a resource (such as a post, article, or listing) using the Page Builder, it is important to clear the builder’s draft state and remove the corresponding local storage entry. This ensures that old drafts do not appear the next time the builder is opened for a new or existing resource.
|
|
386
372
|
|
|
@@ -388,25 +374,32 @@ You can reset the builder state and clear the draft with:
|
|
|
388
374
|
|
|
389
375
|
```js
|
|
390
376
|
// Delete the HTML from the Live DOM
|
|
391
|
-
pageBuilderService.
|
|
377
|
+
pageBuilderService.deleteAllComponentsFromDOM()
|
|
392
378
|
// Clear Local Storage for the created or updated resource
|
|
393
|
-
await pageBuilderService.
|
|
379
|
+
await pageBuilderService.removeCurrentComponentsFromLocalStorage()
|
|
394
380
|
```
|
|
395
381
|
|
|
396
382
|
Always call these methods after a successful post or resource update to ensure users start with a fresh builder the next time they create or edit a resource.
|
|
397
383
|
|
|
398
|
-
|
|
384
|
+
## Loading existing Content or Components into the Page Builder
|
|
385
|
+
|
|
386
|
+
The Page Builder makes it simple to load previously published content from any backend source, such as your database or API.
|
|
399
387
|
|
|
400
|
-
|
|
388
|
+
The `startBuilder` method accepts two arguments:
|
|
401
389
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
390
|
+
1. **Configuration** (required):
|
|
391
|
+
The builder configuration object.
|
|
392
|
+
2. **Components Data** (optional):
|
|
393
|
+
An array of component objects. Each object must include a `html_code` string and may optionally include a title string. This is especially useful when loading previously published or saved content into the builder.
|
|
394
|
+
|
|
395
|
+
**Important**
|
|
396
|
+
|
|
397
|
+
To load existing content into the Page Builder, ensure that the formType is set to update in your configuration.
|
|
398
|
+
This tells the builder to expect and load your provided components array as the initial content.
|
|
405
399
|
|
|
406
400
|
```vue
|
|
407
401
|
<script setup>
|
|
408
402
|
import { getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
409
|
-
import html from './html.json'
|
|
410
403
|
|
|
411
404
|
const configPageBuilder = {
|
|
412
405
|
updateOrCreate: {
|
|
@@ -415,12 +408,19 @@ const configPageBuilder = {
|
|
|
415
408
|
},
|
|
416
409
|
}
|
|
417
410
|
|
|
418
|
-
// Retrieve Page Builder service instance
|
|
411
|
+
// Retrieve the Page Builder service instance
|
|
419
412
|
const pageBuilderService = getPageBuilder()
|
|
420
|
-
await pageBuilderService.startBuilder(configPageBuilder)
|
|
421
413
|
|
|
422
|
-
// Load
|
|
423
|
-
|
|
414
|
+
// Load existing components into the builder (title is optional)
|
|
415
|
+
const myArticle = [
|
|
416
|
+
{ html_code: '<section>...</section>', title: 'Header H2' },
|
|
417
|
+
{ html_code: '<section>...</section>', title: 'Text' },
|
|
418
|
+
{ html_code: '<section>...</section>', title: 'Image' },
|
|
419
|
+
]
|
|
420
|
+
|
|
421
|
+
const result = await pageBuilderService.startBuilder(configPageBuilder, myArticle)
|
|
422
|
+
|
|
423
|
+
console.info('You may inspect this result for message, status, or error:', result)
|
|
424
424
|
</script>
|
|
425
425
|
|
|
426
426
|
<template>
|
|
@@ -428,34 +428,21 @@ await pageBuilderService.mountComponentsToDOM(JSON.stringify(html))
|
|
|
428
428
|
</template>
|
|
429
429
|
```
|
|
430
430
|
|
|
431
|
-
**Note:**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
```json
|
|
435
|
-
{
|
|
436
|
-
"components": [
|
|
437
|
-
{
|
|
438
|
-
"html_code": "<section><div class=\"relative py-4\"><div class=\"mx-auto max-w-7xl lg:px-4 px-2\"><div class=\"pbx-break-words pbx-text-5xl\"><h2><strong>Demo Content</strong></h2></div></div></div></section>",
|
|
439
|
-
"title": "Header H2"
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
"html_code": "<section>...</section>",
|
|
443
|
-
"title": "Text"
|
|
444
|
-
}
|
|
445
|
-
// ...more components
|
|
446
|
-
]
|
|
447
|
-
}
|
|
448
|
-
```
|
|
431
|
+
> **Note:**
|
|
432
|
+
> Each component’s `html_code` must be wrapped in a `<section>...</section>` tag.
|
|
433
|
+
> This is how the Page Builder defines and separates individual components.
|
|
449
434
|
|
|
450
|
-
This approach ensures your users can seamlessly load and edit previously published content, providing a smooth and reliable editing
|
|
435
|
+
This approach ensures your users can seamlessly load and edit previously published content, providing a smooth and reliable editing.
|
|
451
436
|
|
|
452
|
-
|
|
437
|
+
## Automatic Draft Recovery
|
|
453
438
|
|
|
454
|
-
The Page Builder automatically checks for
|
|
455
|
-
If a draft is found, users
|
|
439
|
+
The Page Builder automatically checks for unsaved drafts in local storage for the current resource.
|
|
440
|
+
If a draft is found, users are prompted to either continue where they left off or use the version loaded from your backend.
|
|
456
441
|
|
|
457
|
-
- **`formType` (required):**
|
|
458
|
-
|
|
442
|
+
- **`formType` (required):**
|
|
443
|
+
Determines which draft to load from local storage. Set this to either `create` or `update` in the `updateOrCreate` config, depending on your use case.
|
|
444
|
+
- **`formName` (required):**
|
|
445
|
+
Specifies the resource type (e.g., `article`, `jobPost`, `store`, etc.) in the `updateOrCreate` config. This is especially important if your platform supports multiple resource types. By providing a unique name, the Page Builder can correctly manage layouts and drafts for each resource, allowing users to pick up where they left
|
|
459
446
|
|
|
460
447
|
```vue
|
|
461
448
|
<script setup>
|
|
@@ -468,9 +455,9 @@ const configPageBuilder = {
|
|
|
468
455
|
},
|
|
469
456
|
}
|
|
470
457
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
458
|
+
const result = await pageBuilderService.startBuilder(configPageBuilder)
|
|
459
|
+
|
|
460
|
+
console.info('You may inspect this result for message, status, or error:', result)
|
|
474
461
|
</script>
|
|
475
462
|
|
|
476
463
|
<template>
|