@myissue/vue-website-page-builder 3.2.91 → 3.2.92
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 +122 -84
- package/dist/vue-website-page-builder.css +1 -1
- package/dist/vue-website-page-builder.js +5191 -5273
- package/dist/vue-website-page-builder.umd.cjs +52 -52
- package/package.json +1 -1
- package/src/Components/Loaders/GlobalLoader.vue +11 -0
- package/src/Components/Modals/DynamicModalBuilder.vue +41 -245
- package/src/Components/Modals/ModalBuilder.vue +29 -4
- package/src/Components/PageBuilder/DefaultComponents/DefaultBuilderComponents.vue +3 -8
- package/src/Components/PageBuilder/EditorMenu/Editables/BackgroundColorEditor.vue +5 -4
- package/src/Components/PageBuilder/EditorMenu/Editables/BorderRadius.vue +12 -13
- package/src/Components/PageBuilder/EditorMenu/Editables/Borders.vue +8 -8
- package/src/Components/PageBuilder/EditorMenu/Editables/ClassEditor.vue +7 -6
- package/src/Components/PageBuilder/EditorMenu/Editables/ComponentTopMenu.vue +6 -10
- package/src/Components/PageBuilder/EditorMenu/Editables/DeleteElement.vue +4 -4
- package/src/Components/PageBuilder/EditorMenu/Editables/EditGetElement.vue +10 -11
- package/src/Components/PageBuilder/EditorMenu/Editables/ElementEditor.vue +4 -5
- package/src/Components/PageBuilder/EditorMenu/Editables/ImageEditor.vue +0 -9
- package/src/Components/PageBuilder/EditorMenu/Editables/LinkEditor.vue +5 -5
- package/src/Components/PageBuilder/EditorMenu/Editables/ManageBackgroundOpacity.vue +4 -4
- package/src/Components/PageBuilder/EditorMenu/Editables/ManageOpacity.vue +4 -4
- package/src/Components/PageBuilder/EditorMenu/Editables/Margin.vue +8 -8
- package/src/Components/PageBuilder/EditorMenu/Editables/Padding.vue +8 -8
- package/src/Components/PageBuilder/EditorMenu/Editables/TextColorEditor.vue +4 -4
- package/src/Components/PageBuilder/EditorMenu/Editables/Typography.vue +16 -16
- package/src/Components/PageBuilder/EditorMenu/RightSidebarEditor.vue +3 -7
- package/src/Components/PageBuilder/Settings/PageBuilderSettings.vue +55 -58
- package/src/Components/PageBuilder/ToolbarOption/ToolbarOption.vue +33 -40
- package/src/Components/TipTap/TipTap.vue +4 -9
- package/src/Components/TipTap/TipTapInput.vue +8 -8
- package/src/DemoComponents/DemoUnsplash.vue +4 -5
- package/src/DemoComponents/HomeSection.vue +9 -30
- package/src/PageBuilder/PageBuilder.vue +194 -96
- package/src/composables/{PageBuilderClass.ts → PageBuilderService.ts} +258 -97
- package/src/composables/builderInstance.ts +25 -0
- package/src/css/app.css +15 -0
- package/src/css/dev-global.css +7 -0
- package/src/index.ts +4 -2
- package/src/main.ts +3 -0
- package/src/stores/page-builder-state.ts +32 -2
- package/src/types/index.ts +99 -9
- package/src/helpers/passedPageBuilderConfig.ts +0 -71
package/README.md
CHANGED
|
@@ -15,6 +15,13 @@ Integration is easy, and content is safely auto stored in the browser's local st
|
|
|
15
15
|
|
|
16
16
|
Want to include your company logo in the editor toolbar or reflect your brand's color scheme throughout the builder interface? Done. With robust configuration options, branding the builder to match your product or client identity is quick and effortless.
|
|
17
17
|
|
|
18
|
+
## 🚀 Start Within Minutes
|
|
19
|
+
|
|
20
|
+
Easy setup and instant productivity.
|
|
21
|
+
**Get up and running in just a few steps—see [Quick Start](#quick-start) below!**
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
18
25
|
## Installation
|
|
19
26
|
|
|
20
27
|
The web builder for stunning pages. Enable users to design and publish modern pages at any scale.
|
|
@@ -70,6 +77,7 @@ The Page Builder is packed with features:
|
|
|
70
77
|
- **Undo & Redo**: Experiment confidently with the ability to revert changes.
|
|
71
78
|
- **Global Styles**: Global Styles for fonts, designs, & colors.
|
|
72
79
|
- **YouTube Videos**: Integrate video content smoothly.
|
|
80
|
+
- **Tailwind Support**: Fully compatible with Tailwind CSS (with automatic class prefixing to avoid conflicts).
|
|
73
81
|
- **Styles Prefixed**: No risk of style conflicts between the builder and your app.
|
|
74
82
|
|
|
75
83
|
Powerful Page Builder for any growing merchants, brands, & agencies. Empower users to create the perfect content with the Page Builder.
|
|
@@ -111,14 +119,59 @@ bun install
|
|
|
111
119
|
|
|
112
120
|
### Quick Start
|
|
113
121
|
|
|
114
|
-
Get up and running quickly and initializing the builder in your Vue project. The following example demonstrates the minimal setup required to start building pages.
|
|
122
|
+
Get up and running quickly and initializing the builder in your Vue project. The following below code example demonstrates the minimal setup required to start building pages.
|
|
123
|
+
|
|
124
|
+
- You must explicitly call initPageBuilder() once in your app entry (e.g. main.ts) before using any Page Builder features.
|
|
125
|
+
|
|
126
|
+
- Then, use `getPageBuilder()` anywhere to access the shared builder instance.
|
|
115
127
|
|
|
116
|
-
-
|
|
128
|
+
- Import the CSS file once, ideally in your `main.js`/`main.ts` or root component for proper styling and automatic icon loading..
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { createApp } from 'vue'
|
|
132
|
+
import { createPinia } from 'pinia'
|
|
133
|
+
import App from './App.vue'
|
|
134
|
+
import { initPageBuilder } from '@myissue/vue-website-page-builder'
|
|
135
|
+
import '@myissue/vue-website-page-builder/style.css'
|
|
136
|
+
|
|
137
|
+
// Initialize shared builder instance
|
|
138
|
+
// MUST be called once
|
|
139
|
+
initPageBuilder()
|
|
140
|
+
|
|
141
|
+
const app = createApp(App)
|
|
142
|
+
app.use(createPinia())
|
|
143
|
+
app.mount('#app')
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Accessing the Shared Page Builder Service
|
|
147
|
+
|
|
148
|
+
Once you have initialized the Page Builder service in your application (by calling `initPageBuilder()` once in your app entry), you can access the shared instance anywhere by using the `getPageBuilder()` composable. This ensures you are always working with the same underlying builder service and state, keeping your application consistent and synchronized.
|
|
149
|
+
|
|
150
|
+
**Why Access the Shared Instance?**
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
**There’s only one source of truth:**
|
|
154
|
+
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.
|
|
155
|
+
|
|
156
|
+
**How to Use the Shared Instance**
|
|
157
|
+
Whenever you need to interact with the Page Builder service, import and call the `getPageBuilder()` function. This will return the existing instance you initialized earlier — no need to create a new one.
|
|
117
158
|
|
|
118
159
|
```vue
|
|
119
160
|
<script setup>
|
|
120
|
-
import { PageBuilder } from '@myissue/vue-website-page-builder'
|
|
161
|
+
import { PageBuilder, getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
121
162
|
import '@myissue/vue-website-page-builder/style.css'
|
|
163
|
+
|
|
164
|
+
const configPageBuilder = {
|
|
165
|
+
updateOrCreate: {
|
|
166
|
+
formType: 'create',
|
|
167
|
+
formName: 'article',
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Retrieve Page Builder service instance
|
|
172
|
+
const pageBuilderService = getPageBuilder()
|
|
173
|
+
|
|
174
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
122
175
|
</script>
|
|
123
176
|
|
|
124
177
|
<template>
|
|
@@ -128,17 +181,20 @@ import '@myissue/vue-website-page-builder/style.css'
|
|
|
128
181
|
|
|
129
182
|
### Important: CSS Import Required
|
|
130
183
|
|
|
131
|
-
The Page Builder requires its CSS file to be imported for proper styling and automatic icon loading
|
|
184
|
+
The Page Builder requires its CSS file to be imported for proper styling and automatic icon loading.
|
|
132
185
|
|
|
133
|
-
|
|
186
|
+
**You only need to import the CSS file once, ideally in your `main.js`/`main.ts` or root component.**
|
|
187
|
+
If you have already imported it in your app entry, you do not need to import it again in individual components.
|
|
188
|
+
|
|
189
|
+
```vue
|
|
190
|
+
<script setup>
|
|
134
191
|
import '@myissue/vue-website-page-builder/style.css'
|
|
192
|
+
</script>
|
|
135
193
|
```
|
|
136
194
|
|
|
137
195
|
This import automatically includes:
|
|
138
196
|
|
|
139
197
|
- ✅ Page Builder styles
|
|
140
|
-
- ✅ Google Fonts (Jost, Cormorant - no additional setup needed)
|
|
141
|
-
- ✅ Google Material Icons (no additional setup needed)
|
|
142
198
|
- ✅ Responsive design utilities
|
|
143
199
|
|
|
144
200
|
### Important: CSS Prefix (`pbx-`) for All Builder Styles
|
|
@@ -171,24 +227,25 @@ The Page Builder automatically adds a `pbx-` prefix to **all CSS classes** it ge
|
|
|
171
227
|
|
|
172
228
|
**When** you import the builder’s CSS file:
|
|
173
229
|
|
|
174
|
-
```
|
|
230
|
+
```vue
|
|
231
|
+
<script setup>
|
|
175
232
|
import '@myissue/vue-website-page-builder/style.css'
|
|
233
|
+
</script>
|
|
176
234
|
```
|
|
177
235
|
|
|
178
|
-
- ✅ **All styles included in this file are already prefixed with `pbx-`**.
|
|
179
|
-
- ✅ **All Tailwind and custom classes generated by the builder are automatically prefixed with `pbx-`**.
|
|
180
|
-
- ✅ **Any custom components you create for the builder will also have their classes prefixed automatically**.
|
|
181
|
-
|
|
182
236
|
**What does this mean for you?**
|
|
183
237
|
|
|
184
|
-
-
|
|
238
|
+
- ✅ **All Tailwind and custom CSS classes in this file prefixed with `pbx-` to prevent style conflicts.**.
|
|
239
|
+
- ✅ **There is no risk of style conflicts between the builder and your app, since all builder-related styles are namespaced.**.
|
|
185
240
|
|
|
186
241
|
### Rendering Only the HTML Output from the Page Builder in Other Frameworks (React, Nuxt, etc.)
|
|
187
242
|
|
|
188
243
|
If you use the Page Builder to generate HTML pages and want to render them in another application (such as React, Nuxt, or any server-side app), simply install the Page Builder package in your target project and import its CSS file. This ensures that all Tailwind and builder-specific styles are applied to the rendered HTML.
|
|
189
244
|
|
|
190
|
-
```
|
|
245
|
+
```vue
|
|
246
|
+
<script setup>
|
|
191
247
|
import '@myissue/vue-website-page-builder/style.css'
|
|
248
|
+
</script>
|
|
192
249
|
```
|
|
193
250
|
|
|
194
251
|
This will apply all the necessary styles to any HTML output from the builder, even if you render it with `dangerouslySetInnerHTML`, `v-html`, or similar methods.
|
|
@@ -205,8 +262,10 @@ function MyPage({ html }) {
|
|
|
205
262
|
|
|
206
263
|
**Example (Nuxt/Vue):**
|
|
207
264
|
|
|
208
|
-
```
|
|
265
|
+
```vue
|
|
266
|
+
<script setup>
|
|
209
267
|
import '@myissue/vue-website-page-builder/style.css'
|
|
268
|
+
</script>
|
|
210
269
|
```
|
|
211
270
|
|
|
212
271
|
Then use `v-html` to render the HTML.
|
|
@@ -223,6 +282,7 @@ Get up and running quickly by importing the PageBuilder component, setting up yo
|
|
|
223
282
|
- `resourceData` to prefill the builder with initial data
|
|
224
283
|
- `userSettings` to set user preferences such as theme, language, or autoSave
|
|
225
284
|
- `brandColor` set brand’s primary color, which will be used for key UI elements in the builder in the `settings` config
|
|
285
|
+
- 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.
|
|
226
286
|
- `formName` (recommended): Specify the resource type (e.g., `"article"`, `"jobPost"`, `"store"`, etc.) in the `updateOrCreate` config. This is especially useful if your platform supports multiple resource types. By providing a unique name, the Page Builder can correctly manage layouts and local storage for each resource type, allowing users to continue where they left off for different resources.
|
|
227
287
|
- Pass a `userForPageBuilder` object in your config to display or use the logged-in user's information within the builder (e.g., name and user image).
|
|
228
288
|
|
|
@@ -237,6 +297,7 @@ import '@myissue/vue-website-page-builder/style.css'
|
|
|
237
297
|
|
|
238
298
|
const configPageBuilder = {
|
|
239
299
|
updateOrCreate: {
|
|
300
|
+
formType: 'create'
|
|
240
301
|
// Set the resource type for better local storage and multi-resource support
|
|
241
302
|
formName: 'article',
|
|
242
303
|
},
|
|
@@ -246,6 +307,7 @@ const configPageBuilder = {
|
|
|
246
307
|
userForPageBuilder: { name: 'John Doe', image: '/jane_doe.jpg' },
|
|
247
308
|
resourceData: {
|
|
248
309
|
title: 'Demo Article',
|
|
310
|
+
// ID is optional for better local storage and multi-resource support
|
|
249
311
|
id: 1,
|
|
250
312
|
},
|
|
251
313
|
userSettings: {
|
|
@@ -260,10 +322,10 @@ const configPageBuilder = {
|
|
|
260
322
|
|
|
261
323
|
// Use sharedPageBuilderStore for shared state between PageBuilderClass and PageBuilder component
|
|
262
324
|
const pageBuilderStateStore = sharedPageBuilderStore
|
|
263
|
-
const
|
|
325
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
326
|
+
|
|
264
327
|
|
|
265
|
-
|
|
266
|
-
pageBuilderClass.applyPageBuilderConfig(configPageBuilder)
|
|
328
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
267
329
|
</script>
|
|
268
330
|
|
|
269
331
|
<template>
|
|
@@ -275,12 +337,12 @@ pageBuilderClass.applyPageBuilderConfig(configPageBuilder)
|
|
|
275
337
|
|
|
276
338
|
You can display your company logo in the Page Builder interface and set the currently logged-in user by passing both a logo URL and user information in your config object:
|
|
277
339
|
|
|
278
|
-
- **Company Logo:** Set the logo URL in your config object and pass it to the PageBuilder using `
|
|
340
|
+
- **Company Logo:** Set the logo URL in your config object and pass it to the PageBuilder using `pageBuilderService.startBuilder(configPageBuilder)`. When provided, the logo will appear at the top of the Page Builder with proper spacing in the toolbar.
|
|
279
341
|
- **Logged-in User:** Pass a `userForPageBuilder` object in your config to display or use the logged-in user's information within the builder (e.g., name and user image).
|
|
280
342
|
|
|
281
343
|
**Basic Usage:**
|
|
282
344
|
|
|
283
|
-
- You can display your company logo in the page builder interface by setting the `src` in your config object and passing it to the PageBuilder using `
|
|
345
|
+
- You can display your company logo in the page builder interface by setting the `src` in your config object and passing it to the PageBuilder using `pageBuilderService.startBuilder(configPageBuilder)`. When provided, the logo will appear in the top of the page builder.
|
|
284
346
|
|
|
285
347
|
Basic Usage:
|
|
286
348
|
|
|
@@ -302,10 +364,9 @@ const configPageBuilder = {
|
|
|
302
364
|
|
|
303
365
|
// Use sharedPageBuilderStore for shared state between PageBuilderClass and PageBuilder component
|
|
304
366
|
const pageBuilderStateStore = sharedPageBuilderStore
|
|
305
|
-
const
|
|
367
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
306
368
|
|
|
307
|
-
|
|
308
|
-
pageBuilderClass.applyPageBuilderConfig(configPageBuilder)
|
|
369
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
309
370
|
</script>
|
|
310
371
|
|
|
311
372
|
<template>
|
|
@@ -347,7 +408,7 @@ const configPageBuilder = {
|
|
|
347
408
|
|
|
348
409
|
Example Getting HTML Content from Local Storage for Form Submission
|
|
349
410
|
|
|
350
|
-
```
|
|
411
|
+
```vue
|
|
351
412
|
<script setup>
|
|
352
413
|
import {
|
|
353
414
|
PageBuilder,
|
|
@@ -356,9 +417,8 @@ import {
|
|
|
356
417
|
} from "@myissue/vue-website-page-builder";
|
|
357
418
|
import "@myissue/vue-website-page-builder/style.css";
|
|
358
419
|
|
|
359
|
-
// Make sure to initialize these before using
|
|
360
420
|
const pageBuilderStateStore = sharedPageBuilderStore;
|
|
361
|
-
const
|
|
421
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore);
|
|
362
422
|
|
|
363
423
|
|
|
364
424
|
const configPageBuilder = {
|
|
@@ -368,10 +428,10 @@ const configPageBuilder = {
|
|
|
368
428
|
},
|
|
369
429
|
};
|
|
370
430
|
|
|
371
|
-
|
|
431
|
+
await pageBuilderService.startBuilder(configPageBuilder);
|
|
372
432
|
|
|
373
433
|
|
|
374
|
-
let storedComponents =
|
|
434
|
+
let storedComponents = pageBuilderService.loadStoredComponentsFromStorage();
|
|
375
435
|
let contentFromPageBuilder = "";
|
|
376
436
|
|
|
377
437
|
try {
|
|
@@ -398,7 +458,7 @@ After you have successfully created a new resource (such as a post, article, or
|
|
|
398
458
|
|
|
399
459
|
Always call these methods after a successful post or resource creation to ensure users start with a fresh builder the next time they create a new resource.
|
|
400
460
|
|
|
401
|
-
```
|
|
461
|
+
```vue
|
|
402
462
|
<script setup>
|
|
403
463
|
import {
|
|
404
464
|
PageBuilder,
|
|
@@ -407,9 +467,8 @@ import {
|
|
|
407
467
|
} from "@myissue/vue-website-page-builder";
|
|
408
468
|
import "@myissue/vue-website-page-builder/style.css";
|
|
409
469
|
|
|
410
|
-
// Make sure to initialize these before using
|
|
411
470
|
const pageBuilderStateStore = sharedPageBuilderStore;
|
|
412
|
-
const
|
|
471
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore);
|
|
413
472
|
|
|
414
473
|
|
|
415
474
|
const configPageBuilder = {
|
|
@@ -419,11 +478,11 @@ const configPageBuilder = {
|
|
|
419
478
|
},
|
|
420
479
|
};
|
|
421
480
|
|
|
422
|
-
|
|
481
|
+
await pageBuilderService.startBuilder(configPageBuilder);
|
|
423
482
|
|
|
424
483
|
const createResource = async function(){
|
|
425
|
-
|
|
426
|
-
await
|
|
484
|
+
pageBuilderService.deleteAllComponents();
|
|
485
|
+
await pageBuilderService.removeItemComponentsLocalStorage();
|
|
427
486
|
};
|
|
428
487
|
<script>
|
|
429
488
|
```
|
|
@@ -432,7 +491,7 @@ await pageBuilderClass.removeItemComponentsLocalStorage();
|
|
|
432
491
|
|
|
433
492
|
After you have successfully updated an existing resource (such as a post, article, or listing) using the Page Builder with formType: 'update', you should clear the builder’s state and remove the corresponding local storage entry. This prevents outdated drafts from being loaded the next time you edit the same resource.
|
|
434
493
|
|
|
435
|
-
```
|
|
494
|
+
```vue
|
|
436
495
|
<script setup>
|
|
437
496
|
import {
|
|
438
497
|
PageBuilder,
|
|
@@ -441,9 +500,8 @@ import {
|
|
|
441
500
|
} from "@myissue/vue-website-page-builder";
|
|
442
501
|
import "@myissue/vue-website-page-builder/style.css";
|
|
443
502
|
|
|
444
|
-
// Make sure to initialize these before using
|
|
445
503
|
const pageBuilderStateStore = sharedPageBuilderStore;
|
|
446
|
-
const
|
|
504
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore);
|
|
447
505
|
|
|
448
506
|
|
|
449
507
|
const configPageBuilder = {
|
|
@@ -453,11 +511,11 @@ const configPageBuilder = {
|
|
|
453
511
|
},
|
|
454
512
|
};
|
|
455
513
|
|
|
456
|
-
|
|
514
|
+
await pageBuilderService.startBuilder(configPageBuilder);
|
|
457
515
|
|
|
458
516
|
const updateResource = async function() {
|
|
459
|
-
|
|
460
|
-
await
|
|
517
|
+
pageBuilderService.deleteAllComponents();
|
|
518
|
+
await pageBuilderService.removeItemComponentsLocalStorage();
|
|
461
519
|
};
|
|
462
520
|
|
|
463
521
|
<script>
|
|
@@ -472,7 +530,7 @@ Each save is stored in local storage using a unique key. The key is determined b
|
|
|
472
530
|
|
|
473
531
|
You can further customize and uniquely identify the storage key by providing a `formName` in your `configPageBuilder`:
|
|
474
532
|
|
|
475
|
-
```
|
|
533
|
+
```vue
|
|
476
534
|
<script setup>
|
|
477
535
|
import {
|
|
478
536
|
PageBuilder,
|
|
@@ -481,7 +539,6 @@ import {
|
|
|
481
539
|
} from '@myissue/vue-website-page-builder'
|
|
482
540
|
import '@myissue/vue-website-page-builder/style.css'
|
|
483
541
|
|
|
484
|
-
|
|
485
542
|
const configPageBuilder = {
|
|
486
543
|
updateOrCreate: {
|
|
487
544
|
// Set the resource type for better local storage and multi-resource support
|
|
@@ -490,17 +547,14 @@ const configPageBuilder = {
|
|
|
490
547
|
// ...other config options
|
|
491
548
|
}
|
|
492
549
|
|
|
493
|
-
const
|
|
550
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
494
551
|
|
|
495
|
-
|
|
496
|
-
pageBuilderClass.applyPageBuilderConfig(configPageBuilder)
|
|
552
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
497
553
|
|
|
498
554
|
// Populating page builder with existing resource content
|
|
499
|
-
|
|
555
|
+
pageBuilderService.mountComponentsToDOM(existingResourceFromBackend)
|
|
500
556
|
</script>
|
|
501
557
|
|
|
502
|
-
|
|
503
|
-
|
|
504
558
|
<template>
|
|
505
559
|
<PageBuilder />
|
|
506
560
|
</template>
|
|
@@ -519,7 +573,7 @@ If a user started creating a new resource but hasn't finished (e.g., they want t
|
|
|
519
573
|
|
|
520
574
|
**Example: Set `formType` to "create" for continuing a new resource draft**
|
|
521
575
|
|
|
522
|
-
```
|
|
576
|
+
```vue
|
|
523
577
|
<script setup>
|
|
524
578
|
import {
|
|
525
579
|
PageBuilder,
|
|
@@ -537,10 +591,9 @@ const configPageBuilder = {
|
|
|
537
591
|
},
|
|
538
592
|
}
|
|
539
593
|
|
|
540
|
-
const
|
|
594
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
541
595
|
|
|
542
|
-
|
|
543
|
-
pageBuilderClass.applyPageBuilderConfig(configPageBuilder)
|
|
596
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
544
597
|
</script>
|
|
545
598
|
|
|
546
599
|
<template>
|
|
@@ -557,11 +610,11 @@ To load existing content that was created with this PageBuilder from any backend
|
|
|
557
610
|
- Use `sharedPageBuilderStore` to ensure the external `PageBuilderClass` and internal `PageBuilder` component share the same state.
|
|
558
611
|
- Import `PageBuilderClass` which contains all methods to manipulate and control the page builder state. Use the `mountComponentsToDOM()` method to load existing content into the page builder.
|
|
559
612
|
- The `PageBuilderClass` uses the shared store to maintain state consistency between external operations and the internal `PageBuilder` component, ensuring that when you load content externally it appears correctly in the PageBuilder interface.
|
|
560
|
-
- Set `formType` to `"update"` in your config object and pass it to the PageBuilder using `
|
|
613
|
+
- Set `formType` to `"update"` in your config object and pass it to the PageBuilder using `pageBuilderService.startBuilder(configPageBuilder)`. This tells the PageBuilder that you're editing an existing resource rather than creating a new one, which affects how the component handles data and interactions.
|
|
561
614
|
|
|
562
615
|
**Example: Set `formType` to "update" for editing an existing resource**
|
|
563
616
|
|
|
564
|
-
```
|
|
617
|
+
```vue
|
|
565
618
|
<script setup>
|
|
566
619
|
import {
|
|
567
620
|
PageBuilder,
|
|
@@ -579,7 +632,7 @@ const configPageBuilder = {
|
|
|
579
632
|
},
|
|
580
633
|
}
|
|
581
634
|
|
|
582
|
-
const
|
|
635
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
583
636
|
|
|
584
637
|
// Saved content in DB from already created content using the Page Builder
|
|
585
638
|
const existingResourceFromBackend = [
|
|
@@ -597,9 +650,8 @@ const existingResourceFromBackend = [
|
|
|
597
650
|
},
|
|
598
651
|
]
|
|
599
652
|
|
|
600
|
-
|
|
601
653
|
// Populating page builder with existing resource content from backend
|
|
602
|
-
|
|
654
|
+
pageBuilderService.mountComponentsToDOM(existingResourceFromBackend)
|
|
603
655
|
</script>
|
|
604
656
|
|
|
605
657
|
<template>
|
|
@@ -633,14 +685,14 @@ Example `existingResourceFromBackend`:
|
|
|
633
685
|
|
|
634
686
|
### Automatic Draft Recovery for Updates
|
|
635
687
|
|
|
636
|
-
When you set `formType: 'update'` in your config, the Page Builder will automatically check for any unsaved draft in local storage for that resource.
|
|
688
|
+
When you set `formType: 'update'` in your config, the Page Builder will automatically check for any unsaved draft in local storage for that resource.
|
|
637
689
|
If a draft is found, the user will be prompted to either continue where they left off or use the version currently loaded from your backend.
|
|
638
690
|
|
|
639
691
|
- `formName` (recommended): Specify the resource type (e.g., `"article"`, `"jobPost"`, `"store"`, etc.) in the `updateOrCreate` config. This is especially useful if your platform supports multiple resource types. By providing a unique name, the Page Builder can correctly manage layouts and local storage for each resource type, allowing users to continue where they left off for different resources.
|
|
640
692
|
- Pass a `userForPageBuilder` object in your config to display or use the logged-in user's information within the builder (e.g., name and user image).
|
|
641
693
|
- No extra setup is required—just set `formType: 'update'` and the feature is enabled by default.
|
|
642
694
|
|
|
643
|
-
```
|
|
695
|
+
```vue
|
|
644
696
|
<script setup>
|
|
645
697
|
import {
|
|
646
698
|
PageBuilder,
|
|
@@ -658,10 +710,9 @@ const configPageBuilder = {
|
|
|
658
710
|
},
|
|
659
711
|
}
|
|
660
712
|
|
|
661
|
-
const
|
|
713
|
+
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
662
714
|
|
|
663
|
-
|
|
664
|
-
pageBuilderClass.applyPageBuilderConfig(configPageBuilder)
|
|
715
|
+
pageBuilderService.startBuilder(configPageBuilder)
|
|
665
716
|
</script>
|
|
666
717
|
|
|
667
718
|
<template>
|
|
@@ -693,30 +744,13 @@ import YourCustomBuilderComponents from './ComponentsPageBuilder/YourCustomBuild
|
|
|
693
744
|
|
|
694
745
|
### Fonts or Icons Not Displaying
|
|
695
746
|
|
|
696
|
-
If fonts
|
|
697
|
-
|
|
698
|
-
1. **CSS Import**: Ensure you're importing the CSS file:
|
|
699
|
-
|
|
700
|
-
```js
|
|
701
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
702
|
-
```
|
|
747
|
+
If fonts or Material Icons are not displaying correctly, verify that:
|
|
703
748
|
|
|
704
|
-
|
|
749
|
+
**CSS Import**: Ensure you're importing the CSS file:
|
|
705
750
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined
|
|
710
|
-
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
3. **Content Security Policy**: If using CSP, allow Google Fonts:
|
|
714
|
-
```html
|
|
715
|
-
<meta
|
|
716
|
-
http-equiv="Content-Security-Policy"
|
|
717
|
-
content="font-src 'self' https://fonts.googleapis.com;"
|
|
718
|
-
/>
|
|
719
|
-
```
|
|
751
|
+
```js
|
|
752
|
+
import '@myissue/vue-website-page-builder/style.css'
|
|
753
|
+
```
|
|
720
754
|
|
|
721
755
|
## Contributing
|
|
722
756
|
|
|
@@ -748,3 +782,7 @@ We would greatly appreciate it if you could star the GitHub repository. Starring
|
|
|
748
782
|
## License
|
|
749
783
|
|
|
750
784
|
[MIT License](./LICENSE)
|
|
785
|
+
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
```
|