@myissue/vue-website-page-builder 3.2.96 → 3.3.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/README.md +97 -355
- package/dist/vue-website-page-builder.js +1628 -1612
- package/dist/vue-website-page-builder.umd.cjs +31 -31
- package/package.json +1 -1
- package/src/DemoComponents/HomeSection.vue +2 -5
- package/src/PageBuilder/PageBuilder.vue +2 -5
- package/src/composables/PageBuilderService.ts +54 -15
package/README.md
CHANGED
|
@@ -15,10 +15,10 @@ 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
|
-
## 🚀
|
|
18
|
+
## 🚀 Get Started in Minutes
|
|
19
19
|
|
|
20
20
|
Easy setup and instant productivity.
|
|
21
|
-
|
|
21
|
+
Follow the [Quick Start](#quick-start) guide to begin building with just a few simple steps.
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
@@ -38,13 +38,11 @@ Lightweight & Minimalist Page Builder with an elegant and intuitive design, focu
|
|
|
38
38
|
|
|
39
39
|
Build responsive pages like listings, jobs or blog posts and manage content easily using the free Click & Drop Page Builder.
|
|
40
40
|
|
|
41
|
-
To star the repository, simply click on the **Star** button located at the top-right corner of the GitHub page.
|
|
42
|
-
|
|
43
41
|
<img style="max-width: 100%;" src="./public/home/editor.jpg" alt="Vue Website Page Builder - the editor" />
|
|
44
42
|
|
|
45
43
|
## Demo
|
|
46
44
|
|
|
47
|
-
Introducing
|
|
45
|
+
Introducing **The Lightweight Free Vue Click & Drop Page Builder**
|
|
48
46
|
create and enhance digital experiences with Vue on any backend.
|
|
49
47
|
|
|
50
48
|
[Play around with the Page Builder](https://www.builder-demo.myissue.dk)
|
|
@@ -119,17 +117,16 @@ bun install
|
|
|
119
117
|
|
|
120
118
|
### Quick Start
|
|
121
119
|
|
|
122
|
-
Get up and running quickly
|
|
120
|
+
Grammar: Should be "Get up and running quickly by initializing the builder in your Vue project. The following code example demonstrates the minimal setup required to start building pages.
|
|
123
121
|
|
|
124
122
|
- You must explicitly call initPageBuilder() once in your app entry (e.g. main.ts) before using any Page Builder features.
|
|
125
123
|
|
|
126
124
|
- Then, use `getPageBuilder()` anywhere to access the shared builder instance.
|
|
127
125
|
|
|
128
|
-
- Import the CSS file once, ideally in your `main.js`/`main.ts` or root component for proper styling and automatic icon loading
|
|
126
|
+
- Import the CSS file once, ideally in your `main.js`/`main.ts` or root component for proper styling and automatic icon loading.
|
|
129
127
|
|
|
130
128
|
```typescript
|
|
131
129
|
import { createApp } from 'vue'
|
|
132
|
-
import { createPinia } from 'pinia'
|
|
133
130
|
import App from './App.vue'
|
|
134
131
|
import { initPageBuilder } from '@myissue/vue-website-page-builder'
|
|
135
132
|
import '@myissue/vue-website-page-builder/style.css'
|
|
@@ -139,7 +136,6 @@ import '@myissue/vue-website-page-builder/style.css'
|
|
|
139
136
|
initPageBuilder()
|
|
140
137
|
|
|
141
138
|
const app = createApp(App)
|
|
142
|
-
app.use(createPinia())
|
|
143
139
|
app.mount('#app')
|
|
144
140
|
```
|
|
145
141
|
|
|
@@ -170,7 +166,6 @@ const configPageBuilder = {
|
|
|
170
166
|
|
|
171
167
|
// Retrieve Page Builder service instance
|
|
172
168
|
const pageBuilderService = getPageBuilder()
|
|
173
|
-
|
|
174
169
|
await pageBuilderService.startBuilder(configPageBuilder)
|
|
175
170
|
</script>
|
|
176
171
|
|
|
@@ -240,7 +235,7 @@ import '@myissue/vue-website-page-builder/style.css'
|
|
|
240
235
|
|
|
241
236
|
### Rendering Only the HTML Output from the Page Builder in Other Frameworks (React, Nuxt, etc.)
|
|
242
237
|
|
|
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.
|
|
238
|
+
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 prefix Tailwind and builder-specific styles are applied to the rendered HTML.
|
|
244
239
|
|
|
245
240
|
```vue
|
|
246
241
|
<script setup>
|
|
@@ -272,44 +267,37 @@ Then use `v-html` to render the HTML.
|
|
|
272
267
|
|
|
273
268
|
> **Note:** You do not need to import any Vue components if you only want to render the HTML. Just import the CSS file.
|
|
274
269
|
|
|
275
|
-
###
|
|
270
|
+
### Provide Config to PageBuilder
|
|
276
271
|
|
|
277
272
|
Get up and running quickly by importing the PageBuilder component, setting up your configuration, and initializing the builder in your Vue project. The following example demonstrates the minimal setup required to start building pages with your own config and logo.
|
|
278
273
|
|
|
279
|
-
-
|
|
280
|
-
- (
|
|
281
|
-
- `
|
|
282
|
-
- `resourceData`
|
|
283
|
-
- `
|
|
284
|
-
- `
|
|
285
|
-
-
|
|
286
|
-
- `
|
|
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).
|
|
274
|
+
- Provide a `configPageBuilder` object to customize the builder, such as:
|
|
275
|
+
- `formType` (required): Used to retrieve the correct content from local storage. Specify whether you are creating or updating a resource by setting this to `create` or `update` in the `updateOrCreate` config.
|
|
276
|
+
- `formName` (required): 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.
|
|
277
|
+
- `resourceData` (optional): Prefill the builder with initial resource data (e.g., `"title"`, `"id"`).
|
|
278
|
+
- `userForPageBuilder` (optional): Pass an object with user information (e.g., `name` and `image`) in your config to display the logged-in user's details within the builder interface.
|
|
279
|
+
- `pageBuilderLogo` (optional): Display your company logo in the builder toolbar.
|
|
280
|
+
- `userSettings` (optional): Set user preferences such as theme, language, or autoSave.
|
|
281
|
+
- `brandColor` (optional): Set your brand’s primary color for key UI elements in the builder (inside the `settings` config).
|
|
288
282
|
|
|
289
283
|
```vue
|
|
290
284
|
<script setup>
|
|
291
|
-
import {
|
|
292
|
-
PageBuilder,
|
|
293
|
-
PageBuilderClass,
|
|
294
|
-
sharedPageBuilderStore,
|
|
295
|
-
} from '@myissue/vue-website-page-builder'
|
|
296
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
285
|
+
import { getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
297
286
|
|
|
298
287
|
const configPageBuilder = {
|
|
299
288
|
updateOrCreate: {
|
|
300
|
-
formType: 'create'
|
|
289
|
+
formType: 'create', // Set to 'create' or 'update'
|
|
301
290
|
// Set the resource type for better local storage and multi-resource support
|
|
302
291
|
formName: 'article',
|
|
303
292
|
},
|
|
304
|
-
pageBuilderLogo: {
|
|
305
|
-
src: '/logo/logo.svg',
|
|
306
|
-
},
|
|
307
|
-
userForPageBuilder: { name: 'John Doe', image: '/jane_doe.jpg' },
|
|
308
293
|
resourceData: {
|
|
309
294
|
title: 'Demo Article',
|
|
310
|
-
// ID is optional for better local storage and multi-resource support
|
|
311
295
|
id: 1,
|
|
312
296
|
},
|
|
297
|
+
userForPageBuilder: { name: 'John Doe', image: '/jon_doe.jpg' },
|
|
298
|
+
pageBuilderLogo: {
|
|
299
|
+
src: '/logo/logo.svg',
|
|
300
|
+
},
|
|
313
301
|
userSettings: {
|
|
314
302
|
theme: 'light',
|
|
315
303
|
language: 'en',
|
|
@@ -320,52 +308,8 @@ const configPageBuilder = {
|
|
|
320
308
|
},
|
|
321
309
|
}
|
|
322
310
|
|
|
323
|
-
//
|
|
324
|
-
const
|
|
325
|
-
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
await pageBuilderService.startBuilder(configPageBuilder)
|
|
329
|
-
</script>
|
|
330
|
-
|
|
331
|
-
<template>
|
|
332
|
-
<PageBuilder />
|
|
333
|
-
</template>
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
### Company Logo & Logged-in User
|
|
337
|
-
|
|
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:
|
|
339
|
-
|
|
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.
|
|
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).
|
|
342
|
-
|
|
343
|
-
**Basic Usage:**
|
|
344
|
-
|
|
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.
|
|
346
|
-
|
|
347
|
-
Basic Usage:
|
|
348
|
-
|
|
349
|
-
```vue
|
|
350
|
-
<script setup>
|
|
351
|
-
import {
|
|
352
|
-
PageBuilder,
|
|
353
|
-
PageBuilderClass,
|
|
354
|
-
sharedPageBuilderStore,
|
|
355
|
-
} from '@myissue/vue-website-page-builder'
|
|
356
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
357
|
-
|
|
358
|
-
const configPageBuilder = {
|
|
359
|
-
pageBuilderLogo: {
|
|
360
|
-
src: '/logo/logo.svg',
|
|
361
|
-
},
|
|
362
|
-
userForPageBuilder: { name: 'John Doe', image: '/jane_doe.jpg' },
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Use sharedPageBuilderStore for shared state between PageBuilderClass and PageBuilder component
|
|
366
|
-
const pageBuilderStateStore = sharedPageBuilderStore
|
|
367
|
-
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
368
|
-
|
|
311
|
+
// Retrieve Page Builder service instance
|
|
312
|
+
const pageBuilderService = getPageBuilder()
|
|
369
313
|
await pageBuilderService.startBuilder(configPageBuilder)
|
|
370
314
|
</script>
|
|
371
315
|
|
|
@@ -374,27 +318,22 @@ await pageBuilderService.startBuilder(configPageBuilder)
|
|
|
374
318
|
</template>
|
|
375
319
|
```
|
|
376
320
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
| Prop | Type | Default | Description |
|
|
380
|
-
| ----------------- | -------- | ------- | ----------------------------------- |
|
|
381
|
-
| `PageBuilderLogo` | `String` | `null` | URL path to your company logo image |
|
|
321
|
+
### Local Storage & Auto-Save
|
|
382
322
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
The Page Builder automatically manages all changes using the browser's local storage. Every change you make—such as adding, editing, or deleting components—is saved in local storage. This ensures that your progress is not lost, even if you accidentally close the browser or navigate away.
|
|
323
|
+
The Page Builder automatically manages all changes using the browser's local storage. Every change you make—such as adding, editing, or deleting components—is saved in local storage. This ensures your progress is not lost, even if you accidentally close the browser or navigate away.
|
|
386
324
|
|
|
387
325
|
- **Auto-Save:** The builder periodically auto-saves your changes to local storage, so you don't have to worry about losing your work.
|
|
388
326
|
- **Manual Save:** When the user clicks the Save button, the current state is also saved to local storage.
|
|
389
327
|
|
|
390
|
-
|
|
328
|
+
#### Example: Retrieving the Most Up-to-Date HTML Content for Form Submission
|
|
329
|
+
|
|
330
|
+
The Page Builder uses auto-save, so the data you retrieve from local storage always reflects the latest state of the builder—what the user currently sees in the editor. This means you are getting the most up-to-date content, saved live as the user edits.
|
|
391
331
|
|
|
392
|
-
To use the builder’s saved data in your form submission, you may want both the combined HTML content and the titles of each component. The PageBuilderClass provides a method to access the latest saved state from local storage. The example below demonstrates how to retrieve and parse this data, combining all component HTML into a single string and collecting all titles into an array. This is useful if you want to display or store both the rendered content and the structure or headings of your page.
|
|
332
|
+
To use the builder’s saved data in your form submission, you may want both the combined HTML content and the titles of each component. The `PageBuilderClass` provides a method to access the latest saved state from local storage. The example below demonstrates how to retrieve and parse this data, combining all component HTML into a single string and collecting all titles into an array. This is useful if you want to display or store both the rendered content and the structure or headings of your page.
|
|
393
333
|
|
|
394
|
-
|
|
334
|
+
**Important:**
|
|
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.
|
|
395
336
|
|
|
396
|
-
**Important:**
|
|
397
|
-
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.
|
|
398
337
|
Example:
|
|
399
338
|
|
|
400
339
|
```js
|
|
@@ -406,224 +345,68 @@ const configPageBuilder = {
|
|
|
406
345
|
}
|
|
407
346
|
```
|
|
408
347
|
|
|
409
|
-
|
|
348
|
+
Call this logic when you want to submit or save the builder’s output, for example, when the user clicks a “Save” or “Publish” button. The code safely parses the local storage data, handles errors, and assigns the results to your form fields.
|
|
410
349
|
|
|
411
350
|
```vue
|
|
412
351
|
<script setup>
|
|
413
|
-
import {
|
|
414
|
-
PageBuilder,
|
|
415
|
-
PageBuilderClass,
|
|
416
|
-
sharedPageBuilderStore,
|
|
417
|
-
} from "@myissue/vue-website-page-builder";
|
|
418
|
-
import "@myissue/vue-website-page-builder/style.css";
|
|
419
|
-
|
|
420
|
-
const pageBuilderStateStore = sharedPageBuilderStore;
|
|
421
|
-
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore);
|
|
422
|
-
|
|
352
|
+
import { getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
423
353
|
|
|
424
354
|
const configPageBuilder = {
|
|
425
355
|
updateOrCreate: {
|
|
426
356
|
formType: 'create',
|
|
427
357
|
formName: 'article',
|
|
428
358
|
},
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
await pageBuilderService.startBuilder(configPageBuilder);
|
|
359
|
+
}
|
|
432
360
|
|
|
361
|
+
// Retrieve Page Builder service instance
|
|
362
|
+
const pageBuilderService = getPageBuilder()
|
|
363
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
433
364
|
|
|
434
|
-
let storedComponents = pageBuilderService.loadStoredComponentsFromStorage()
|
|
435
|
-
let contentFromPageBuilder =
|
|
365
|
+
let storedComponents = pageBuilderService.loadStoredComponentsFromStorage()
|
|
366
|
+
let contentFromPageBuilder = ''
|
|
436
367
|
|
|
437
368
|
try {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
369
|
+
storedComponents = JSON.parse(storedComponents)
|
|
370
|
+
contentFromPageBuilder =
|
|
371
|
+
storedComponents && Array.isArray(storedComponents.components)
|
|
372
|
+
? storedComponents.components.map((component) => component.html_code).join('')
|
|
373
|
+
: ''
|
|
443
374
|
} catch (e) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
e
|
|
447
|
-
);
|
|
448
|
-
contentFromPageBuilder = "";
|
|
375
|
+
console.error('Unable to parse storedComponents from localStorage:', e)
|
|
376
|
+
contentFromPageBuilder = ''
|
|
449
377
|
} finally {
|
|
450
|
-
|
|
378
|
+
yourForm.content = contentFromPageBuilder
|
|
451
379
|
}
|
|
452
|
-
<script>
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
#### Resetting the Builder After Successful Resource Creation
|
|
456
|
-
|
|
457
|
-
After you have successfully created a new resource (such as a post, article, or listing) using the Page Builder with formType: 'create', 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 resource.
|
|
458
|
-
|
|
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.
|
|
460
|
-
|
|
461
|
-
```vue
|
|
462
|
-
<script setup>
|
|
463
|
-
import {
|
|
464
|
-
PageBuilder,
|
|
465
|
-
PageBuilderClass,
|
|
466
|
-
sharedPageBuilderStore,
|
|
467
|
-
} from "@myissue/vue-website-page-builder";
|
|
468
|
-
import "@myissue/vue-website-page-builder/style.css";
|
|
469
|
-
|
|
470
|
-
const pageBuilderStateStore = sharedPageBuilderStore;
|
|
471
|
-
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore);
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const configPageBuilder = {
|
|
475
|
-
updateOrCreate: {
|
|
476
|
-
formType: 'create',
|
|
477
|
-
formName: 'article',
|
|
478
|
-
},
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
await pageBuilderService.startBuilder(configPageBuilder);
|
|
482
|
-
|
|
483
|
-
const createResource = async function(){
|
|
484
|
-
pageBuilderService.deleteAllComponents();
|
|
485
|
-
await pageBuilderService.removeItemComponentsLocalStorage();
|
|
486
|
-
};
|
|
487
|
-
<script>
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
#### Resetting the Builder After Successful Resource Update
|
|
491
|
-
|
|
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.
|
|
493
|
-
|
|
494
|
-
```vue
|
|
495
|
-
<script setup>
|
|
496
|
-
import {
|
|
497
|
-
PageBuilder,
|
|
498
|
-
PageBuilderClass,
|
|
499
|
-
sharedPageBuilderStore,
|
|
500
|
-
} from "@myissue/vue-website-page-builder";
|
|
501
|
-
import "@myissue/vue-website-page-builder/style.css";
|
|
502
|
-
|
|
503
|
-
const pageBuilderStateStore = sharedPageBuilderStore;
|
|
504
|
-
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const configPageBuilder = {
|
|
508
|
-
updateOrCreate: {
|
|
509
|
-
formType: 'update',
|
|
510
|
-
formName: 'article',
|
|
511
|
-
},
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
await pageBuilderService.startBuilder(configPageBuilder);
|
|
515
|
-
|
|
516
|
-
const updateResource = async function() {
|
|
517
|
-
pageBuilderService.deleteAllComponents();
|
|
518
|
-
await pageBuilderService.removeItemComponentsLocalStorage();
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
<script>
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
#### Resource-Specific Storage Keys
|
|
525
|
-
|
|
526
|
-
Each save is stored in local storage using a unique key. The key is determined by whether you are creating a new resource or updating an existing one:
|
|
527
|
-
|
|
528
|
-
- **New Resource:** The key will be prefixed with `page-builder-create-resource`.
|
|
529
|
-
- **Updating Resource:** The key will be prefixed with `page-builder-update-resource`.
|
|
530
|
-
|
|
531
|
-
You can further customize and uniquely identify the storage key by providing a `formName` in your `configPageBuilder`:
|
|
532
|
-
|
|
533
|
-
```vue
|
|
534
|
-
<script setup>
|
|
535
|
-
import {
|
|
536
|
-
PageBuilder,
|
|
537
|
-
PageBuilderClass,
|
|
538
|
-
sharedPageBuilderStore,
|
|
539
|
-
} from '@myissue/vue-website-page-builder'
|
|
540
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
541
|
-
|
|
542
|
-
const configPageBuilder = {
|
|
543
|
-
updateOrCreate: {
|
|
544
|
-
// Set the resource type for better local storage and multi-resource support
|
|
545
|
-
formName: 'article',
|
|
546
|
-
},
|
|
547
|
-
// ...other config options
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
const pageBuilderService.= new PageBuilderClass(pageBuilderStateStore)
|
|
551
|
-
|
|
552
|
-
await pageBuilderService.startBuilder(configPageBuilder)
|
|
553
|
-
|
|
554
|
-
// Populating page builder with existing resource content
|
|
555
|
-
pageBuilderService.mountComponentsToDOM(existingResourceFromBackend)
|
|
556
380
|
</script>
|
|
557
|
-
|
|
558
|
-
<template>
|
|
559
|
-
<PageBuilder />
|
|
560
|
-
</template>
|
|
561
381
|
```
|
|
562
382
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
> **Tip:** The local storage key will automatically include the resource type if `formName` is provided, ensuring that drafts for different resource types do not overwrite each other.
|
|
566
|
-
|
|
567
|
-
### Restoring Unfinished Drafts for New Resources
|
|
568
|
-
|
|
569
|
-
If a user started creating a new resource but hasn't finished (e.g., they want to continue the next day), you can restore their draft from local storage:
|
|
570
|
-
|
|
571
|
-
- Set `formType` to `"create"` in your config object.
|
|
572
|
-
- The PageBuilder will automatically look for any saved draft in local storage (based on the resource type) and load it if available.
|
|
573
|
-
|
|
574
|
-
**Example: Set `formType` to "create" for continuing a new resource draft**
|
|
575
|
-
|
|
576
|
-
```vue
|
|
577
|
-
<script setup>
|
|
578
|
-
import {
|
|
579
|
-
PageBuilder,
|
|
580
|
-
PageBuilderClass,
|
|
581
|
-
sharedPageBuilderStore,
|
|
582
|
-
} from '@myissue/vue-website-page-builder'
|
|
583
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
584
|
-
|
|
585
|
-
const pageBuilderStateStore = sharedPageBuilderStore
|
|
586
|
-
|
|
587
|
-
const configPageBuilder = {
|
|
588
|
-
updateOrCreate: {
|
|
589
|
-
formType: 'create',
|
|
590
|
-
formName: 'article',
|
|
591
|
-
},
|
|
592
|
-
}
|
|
383
|
+
#### Resetting the Builder After Successful Resource Creation or Update
|
|
593
384
|
|
|
594
|
-
|
|
385
|
+
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.
|
|
595
386
|
|
|
596
|
-
|
|
597
|
-
</script>
|
|
387
|
+
You can reset the builder state and clear the draft with:
|
|
598
388
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
389
|
+
```js
|
|
390
|
+
// Delete the HTML from the Live DOM
|
|
391
|
+
pageBuilderService.deleteAllComponents()
|
|
392
|
+
// Clear Local Storage for the created or updated resource
|
|
393
|
+
await pageBuilderService.removeItemComponentsLocalStorage()
|
|
602
394
|
```
|
|
603
395
|
|
|
604
|
-
|
|
396
|
+
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.
|
|
605
397
|
|
|
606
398
|
### Loading Published Content from the Backend into the Page Builder
|
|
607
399
|
|
|
608
|
-
|
|
400
|
+
You can easily load existing content—created with this Page Builder—from any backend source.
|
|
609
401
|
|
|
610
|
-
-
|
|
611
|
-
-
|
|
612
|
-
-
|
|
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.
|
|
614
|
-
|
|
615
|
-
**Example: Set `formType` to "update" for editing an existing resource**
|
|
402
|
+
- **Set `formType` (required):** This tells the builder to look for the correct content in local storage. Set `formType` to `update`.
|
|
403
|
+
- **Set `formName` (required):** Specify the resource type (for example, `"article"`, `"jobPost"`, `"store"`, etc.) in the `updateOrCreate` config.
|
|
404
|
+
- Even when loading an existing resource, these values are important if your platform supports multiple resource types. By providing a unique name, the Page Builder can properly manage layouts and local storage for the resource, allowing users to pick up right where they left off.
|
|
616
405
|
|
|
617
406
|
```vue
|
|
618
407
|
<script setup>
|
|
619
|
-
import {
|
|
620
|
-
|
|
621
|
-
PageBuilderClass,
|
|
622
|
-
sharedPageBuilderStore,
|
|
623
|
-
} from '@myissue/vue-website-page-builder'
|
|
624
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
625
|
-
|
|
626
|
-
const pageBuilderStateStore = sharedPageBuilderStore
|
|
408
|
+
import { getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
409
|
+
import html from './html.json'
|
|
627
410
|
|
|
628
411
|
const configPageBuilder = {
|
|
629
412
|
updateOrCreate: {
|
|
@@ -632,26 +415,12 @@ const configPageBuilder = {
|
|
|
632
415
|
},
|
|
633
416
|
}
|
|
634
417
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const existingResourceFromBackend = [
|
|
639
|
-
{
|
|
640
|
-
html_code:
|
|
641
|
-
'<section><div class="relative py-4"><div class="mx-auto max-w-7xl lg:px-4 px-2"><div class="break-words"><h2>Component Example One</h2></div></div></div></section>',
|
|
642
|
-
id: null,
|
|
643
|
-
title: 'Header H2',
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
html_code:
|
|
647
|
-
'<section><div class="relative py-4"><div class="mx-auto max-w-7xl lg:px-4 px-2"><div class="break-words" selected=""><h3>Component Example Two</h3></div></div></div></section>',
|
|
648
|
-
id: null,
|
|
649
|
-
title: 'Header H3',
|
|
650
|
-
},
|
|
651
|
-
]
|
|
418
|
+
// Retrieve Page Builder service instance
|
|
419
|
+
const pageBuilderService = getPageBuilder()
|
|
420
|
+
await pageBuilderService.startBuilder(configPageBuilder)
|
|
652
421
|
|
|
653
|
-
//
|
|
654
|
-
pageBuilderService.mountComponentsToDOM(
|
|
422
|
+
// Load content from your backend or a JSON file into the Page Buildder
|
|
423
|
+
await pageBuilderService.mountComponentsToDOM(JSON.stringify(html))
|
|
655
424
|
</script>
|
|
656
425
|
|
|
657
426
|
<template>
|
|
@@ -659,49 +428,38 @@ pageBuilderService.mountComponentsToDOM(existingResourceFromBackend)
|
|
|
659
428
|
</template>
|
|
660
429
|
```
|
|
661
430
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
The example below shows the structure as it would appear when loaded from local storage after components have been added in the builder.
|
|
665
|
-
|
|
666
|
-
- Example JSON string (from localStorage or backend)
|
|
667
|
-
- For existing resources, id will always be present and set by the page builder.
|
|
668
|
-
|
|
669
|
-
Example `existingResourceFromBackend`:
|
|
431
|
+
**Note:**
|
|
432
|
+
Your `html.json` file should contain an array of component objects, each with a `html_code` and `title` (optional) property, as shown below:
|
|
670
433
|
|
|
671
434
|
```json
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
]
|
|
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
|
+
}
|
|
684
448
|
```
|
|
685
449
|
|
|
686
|
-
|
|
450
|
+
This approach ensures your users can seamlessly load and edit previously published content, providing a smooth and reliable editing experience.
|
|
451
|
+
|
|
452
|
+
### Automatic Draft Recovery
|
|
687
453
|
|
|
688
|
-
|
|
689
|
-
If a draft is found,
|
|
454
|
+
The Page Builder automatically checks for any unsaved drafts in local storage for the current resource.
|
|
455
|
+
If a draft is found, users will be prompted to either continue where they left off or use the version currently loaded from your backend.
|
|
690
456
|
|
|
691
|
-
- `
|
|
692
|
-
|
|
693
|
-
- No extra setup is required—just set `formType: 'update'` and the feature is enabled by default.
|
|
457
|
+
- **`formType` (required):** Used to retrieve the correct content from local storage. Set this to either `create` or `update` in the `updateOrCreate` config, depending on your use case.
|
|
458
|
+
- **`formName` (required):** 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.
|
|
694
459
|
|
|
695
460
|
```vue
|
|
696
461
|
<script setup>
|
|
697
|
-
import {
|
|
698
|
-
PageBuilder,
|
|
699
|
-
PageBuilderClass,
|
|
700
|
-
sharedPageBuilderStore,
|
|
701
|
-
} from '@myissue/vue-website-page-builder'
|
|
702
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
703
|
-
|
|
704
|
-
const pageBuilderStateStore = sharedPageBuilderStore
|
|
462
|
+
import { getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
705
463
|
|
|
706
464
|
const configPageBuilder = {
|
|
707
465
|
updateOrCreate: {
|
|
@@ -710,8 +468,8 @@ const configPageBuilder = {
|
|
|
710
468
|
},
|
|
711
469
|
}
|
|
712
470
|
|
|
713
|
-
|
|
714
|
-
|
|
471
|
+
// Retrieve Page Builder service instance
|
|
472
|
+
const pageBuilderService = getPageBuilder()
|
|
715
473
|
await pageBuilderService.startBuilder(configPageBuilder)
|
|
716
474
|
</script>
|
|
717
475
|
|
|
@@ -720,25 +478,13 @@ await pageBuilderService.startBuilder(configPageBuilder)
|
|
|
720
478
|
</template>
|
|
721
479
|
```
|
|
722
480
|
|
|
723
|
-
### Custom
|
|
724
|
-
|
|
725
|
-
Want to add your own media library or Create custom components that can be injected into the page builder:
|
|
726
|
-
|
|
727
|
-
📚 **[Custom Components Setup Guide](./CUSTOM_COMPONENTS_SETUP.md)** - Learn how to create and integrate your own components
|
|
481
|
+
### Custom Media Library Component or Custom Layout Builder Component
|
|
728
482
|
|
|
729
|
-
|
|
483
|
+
You may extend the Page Builder by adding your own media library or custom layout builder Component.
|
|
484
|
+
Inject your components easily to tailor the builder to your application's needs.
|
|
730
485
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
import { PageBuilder } from '@myissue/vue-website-page-builder'
|
|
734
|
-
import YourMediaLibraryComponent from './ComponentsPageBuilder/YourMediaLibraryComponent.vue'
|
|
735
|
-
import YourCustomBuilderComponents from './ComponentsPageBuilder/YourCustomBuilderComponents.vue'
|
|
736
|
-
</script>
|
|
737
|
-
|
|
738
|
-
<template>
|
|
739
|
-
<PageBuilder :CustomMediaLibraryComponent="YourMediaLibraryComponent" :CustomBuilderComponents="YourCustomBuilderComponents" />
|
|
740
|
-
</template>
|
|
741
|
-
```
|
|
486
|
+
📚 **[Custom Components Setup Guide](./CUSTOM_COMPONENTS_SETUP.md)**
|
|
487
|
+
Learn how to create and integrate your own components step by step.
|
|
742
488
|
|
|
743
489
|
## Troubleshooting
|
|
744
490
|
|
|
@@ -782,7 +528,3 @@ We would greatly appreciate it if you could star the GitHub repository. Starring
|
|
|
782
528
|
## License
|
|
783
529
|
|
|
784
530
|
[MIT License](./LICENSE)
|
|
785
|
-
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
```
|