@myissue/vue-website-page-builder 3.4.32 → 3.4.33
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 +135 -77
- package/dist/style.css +1 -1
- package/dist/vue-website-page-builder.js +10006 -9755
- package/dist/vue-website-page-builder.umd.cjs +349 -110
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,14 +18,18 @@
|
|
|
18
18
|
- [Getting Started](#getting-started)
|
|
19
19
|
- [Installation](#installation)
|
|
20
20
|
- [Quick Start](#quick-start)
|
|
21
|
-
|
|
22
|
-
- [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- [
|
|
21
|
+
- [Nuxt Integration](#nuxt-integration)
|
|
22
|
+
- [1. Install the Package](#1-install-the-package)
|
|
23
|
+
- [2. Create a Nuxt Plugin](#2-create-a-nuxt-plugin)
|
|
24
|
+
- [3. Register the Plugin in `nuxt.config.ts`](#3-register-the-plugin-in-nuxtconfigts)
|
|
25
|
+
- [4. Using the Page Builder Component](#4-using-the-page-builder-component)
|
|
26
|
+
- [5. Why Initialize the Page Builder with `onMounted` in Nuxt?](#5-why-initialize-the-page-builder-with-onmounted-in-nuxt)
|
|
27
|
+
- [Vue Integration](#vue-integration)
|
|
28
|
+
- [1. Install the Package](#1-install-the-package-1)
|
|
29
|
+
- [2. Import and use the Page Builder Plugin](#2-import-and-use-the-page-builder-plugin)
|
|
30
|
+
- [3. Using the Page Builder Component](#3-using-the-page-builder-component)
|
|
31
|
+
- [4. Initialize Page Builder with `onMounted` Troubleshooting](#4-initialize-page-builder-with-onmounted-troubleshooting)
|
|
32
|
+
- [Why Use the Shared Instance?](#why-use-the-shared-instance)
|
|
29
33
|
- [Important: CSS Prefixing (`pbx-`)](#important-css-prefixing-pbx-)
|
|
30
34
|
- [Rendering HTML Output in Other Frameworks (React, Nuxt, etc.)](#rendering-html-output-in-other-frameworks-react-nuxt-etc)
|
|
31
35
|
- [Providing Configuration to the Page Builder](#providing-configuration-to-the-page-builder)
|
|
@@ -47,7 +51,8 @@
|
|
|
47
51
|
- [Integrate Unsplash Library](#integrate-unsplash-library)
|
|
48
52
|
- [Custom Layout Builder Component](#custom-layout-builder-component)
|
|
49
53
|
- [Troubleshooting](#troubleshooting)
|
|
50
|
-
- [Fonts or Icons Not Displaying](#fonts-or-icons-not-displaying)
|
|
54
|
+
- [1. Fonts or Icons Not Displaying](#1-fonts-or-icons-not-displaying)
|
|
55
|
+
- [2. Initialize Page Builder with `onMounted` Troubleshooting](#2-initialize-page-builder-with-onmounted-troubleshooting)
|
|
51
56
|
- [Page Builder Architecture](#page-builder-architecture)
|
|
52
57
|
- [How the Page Builder Works](#how-the-page-builder-works)
|
|
53
58
|
- [Contributing](#contributing)
|
|
@@ -60,7 +65,7 @@
|
|
|
60
65
|
|
|
61
66
|
## Demo
|
|
62
67
|
|
|
63
|
-
A Vue 3
|
|
68
|
+
A Vue 3 Page Builder component with drag-and-drop functionality for creating dynamic web pages.
|
|
64
69
|
|
|
65
70
|
Create and enhance digital experiences with Vue on any backend.
|
|
66
71
|
|
|
@@ -206,7 +211,7 @@ bun install
|
|
|
206
211
|
|
|
207
212
|
## Installation
|
|
208
213
|
|
|
209
|
-
The web builder for stunning pages.
|
|
214
|
+
The web builder for stunning pages. Enables users to design and publish modern pages at any scale.
|
|
210
215
|
|
|
211
216
|
```bash
|
|
212
217
|
npm install @myissue/vue-website-page-builder
|
|
@@ -214,54 +219,27 @@ npm install @myissue/vue-website-page-builder
|
|
|
214
219
|
|
|
215
220
|
## Quick Start
|
|
216
221
|
|
|
217
|
-
Get up and running with the Vue Website Page Builder in just a few minutes.
|
|
222
|
+
Get up and running with the Vue Website Page Builder in just a few minutes.
|
|
218
223
|
This section walks you through the essential steps—from installation to rendering your first page—so you can start building beautiful, dynamic content right away.
|
|
219
224
|
|
|
220
|
-
|
|
225
|
+
## Nuxt Integration
|
|
221
226
|
|
|
222
|
-
To
|
|
227
|
+
To use `@myissue/vue-website-page-builder` in your Nuxt 3 or Nuxt 4 project, follow these steps:
|
|
223
228
|
|
|
224
|
-
|
|
225
|
-
- **Access the shared builder instance** anywhere in your application using the `getPageBuilder()` composable.
|
|
226
|
-
|
|
227
|
-
> **Note:**
|
|
228
|
-
> 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.
|
|
229
|
-
|
|
230
|
-
- **Import the CSS file once** in your `main.js`, `main.ts`, or root component to ensure proper styling and automatic icon loading.
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
233
|
-
import { createApp } from 'vue'
|
|
234
|
-
import App from './App.vue'
|
|
235
|
-
import { pageBuilder } from '@myissue/vue-website-page-builder'
|
|
236
|
-
// Import the Page Builder styles once in your application entry, not in individual components.
|
|
237
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
238
|
-
|
|
239
|
-
// Use the Page Builder plugin
|
|
240
|
-
const app = createApp(App)
|
|
241
|
-
app.use(pageBuilder)
|
|
242
|
-
app.mount('#app')
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
The Page Builder is implemented as a singleton service, meaning all page-building logic and state are managed by a single shared instance across your app — even if you use `<PageBuilder />` in multiple places.
|
|
246
|
-
|
|
247
|
-
### Nuxt Integration
|
|
248
|
-
|
|
249
|
-
> **🎉 Great news:** The Page Builder now works with Nuxt 3 and Nuxt 4.
|
|
229
|
+
> **🎉 Great news:** The Page Builder now works with Nuxt 3 and Nuxt 4.
|
|
250
230
|
> Follow the steps below to get started in your Nuxt project.
|
|
251
231
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
#### 1. Install the Package
|
|
232
|
+
### 1. Install the Package
|
|
255
233
|
|
|
256
234
|
```bash
|
|
257
235
|
npm install @myissue/vue-website-page-builder
|
|
258
236
|
```
|
|
259
237
|
|
|
260
|
-
|
|
238
|
+
### 2. Create a Nuxt Plugin
|
|
261
239
|
|
|
262
|
-
In the root create a file named:
|
|
240
|
+
In the root, create a file named:
|
|
263
241
|
|
|
264
|
-
```
|
|
242
|
+
```plaintext
|
|
265
243
|
plugins/page-builder.client.js
|
|
266
244
|
```
|
|
267
245
|
|
|
@@ -277,12 +255,12 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
277
255
|
})
|
|
278
256
|
```
|
|
279
257
|
|
|
280
|
-
|
|
258
|
+
### 3. Register the Plugin in `nuxt.config.ts`
|
|
281
259
|
|
|
282
|
-
Make sure Nuxt knows about your new
|
|
260
|
+
Make sure Nuxt knows about your new Plugin by adding it to your config:
|
|
283
261
|
|
|
284
|
-
> **Note:** If your
|
|
285
|
-
> Adding it to `nuxt.config.ts` is optional, but
|
|
262
|
+
> **Note:** If your Plugin is inside the `/plugins` folder, Nuxt will auto-register it.
|
|
263
|
+
> Adding it to `nuxt.config.ts` is optional, but improves clarity.
|
|
286
264
|
|
|
287
265
|
```typescript
|
|
288
266
|
export default defineNuxtConfig({
|
|
@@ -291,11 +269,13 @@ export default defineNuxtConfig({
|
|
|
291
269
|
})
|
|
292
270
|
```
|
|
293
271
|
|
|
294
|
-
|
|
272
|
+
### 4. Using the Page Builder Component
|
|
273
|
+
|
|
274
|
+
Now anywhere in your application, use the `getPageBuilder()` composable to interact with the Page Builder’s shared instance.
|
|
295
275
|
|
|
296
|
-
|
|
276
|
+
The Page Builder relies on browser APIs like `localStorage` and dynamic `DOM` manipulation, which are only available on the client side. Wrapping it in `<client-only>` ensures it is rendered exclusively in the browser, preventing SSR errors and guaranteeing a smooth editing experience.
|
|
297
277
|
|
|
298
|
-
|
|
278
|
+
You’re now ready to use the Page Builder in your Nuxt pages or components with the `getPageBuilder()` composable.
|
|
299
279
|
|
|
300
280
|
```vue
|
|
301
281
|
<script setup>
|
|
@@ -309,8 +289,7 @@ const configPageBuilder = {
|
|
|
309
289
|
},
|
|
310
290
|
}
|
|
311
291
|
|
|
312
|
-
// Initialize the
|
|
313
|
-
// The Page Builder depends on the browser (DOM, `window`, `localStorage`, etc.)
|
|
292
|
+
// Initialize the Page Builder with `onMounted`
|
|
314
293
|
onMounted(async () => {
|
|
315
294
|
const pageBuilderService = getPageBuilder()
|
|
316
295
|
const result = await pageBuilderService.startBuilder(configPageBuilder)
|
|
@@ -328,26 +307,48 @@ onMounted(async () => {
|
|
|
328
307
|
```
|
|
329
308
|
|
|
330
309
|
> **Tip:**
|
|
331
|
-
> By initializing the builder inside `onMounted`, you ensure everything is ready and avoid
|
|
310
|
+
> By initializing the builder inside `onMounted`, you ensure everything is ready and avoid hydration errors.
|
|
332
311
|
|
|
333
|
-
|
|
312
|
+
### 5. Why Initialize the Page Builder with `onMounted` in Nuxt?
|
|
334
313
|
|
|
335
|
-
In a Server-Side Rendering (SSR) framework like Nuxt, any code that depends on the browser (DOM
|
|
314
|
+
In a Server-Side Rendering (SSR) framework like Nuxt, any code that depends on the browser (`DOM`, `window`, `localStorage`, etc.) should only run on the client. Using `onMounted` ensures the Page Builder initializes safely after the component is mounted, avoiding SSR errors. Many popular packages follow this pattern.
|
|
336
315
|
|
|
337
|
-
|
|
316
|
+
## Vue Integration
|
|
338
317
|
|
|
339
|
-
|
|
340
|
-
issues, and unpredictable behavior. All components and modules interact with the same centralized
|
|
341
|
-
service, ensuring that updates and state changes are reflected everywhere in your application. ###
|
|
342
|
-
Using the Page Builder Component Ensure the following configuration options are set: - **`formType`
|
|
343
|
-
(required):** Indicates whether you are creating or updating a resource. This is used to retrieve
|
|
344
|
-
the correct content from local storage. - **`formName` (required):** Specifies the resource type
|
|
345
|
-
(for example, `article`, `jobPost`, `store`, etc.). ```vue
|
|
318
|
+
To use `@myissue/vue-website-page-builder` in your Vue project, follow these steps:
|
|
346
319
|
|
|
320
|
+
### 1. Install the Package
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
npm install @myissue/vue-website-page-builder
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### 2. Import and use the Page Builder Plugin
|
|
327
|
+
|
|
328
|
+
Import the `pageBuilder` Plugin and register it in your application entry point (e.g., `main.ts` or `main.js`). This sets up a single, shared Page Builder instance for your entire app.
|
|
329
|
+
|
|
330
|
+
Import the CSS file once in your `main.js`, `main.ts`, or root component. This ensures proper styling and automatic icon loading. You do **not** need to import it in individual components.
|
|
331
|
+
|
|
332
|
+
```javascript
|
|
333
|
+
import { createApp } from 'vue'
|
|
334
|
+
import App from './App.vue'
|
|
335
|
+
import { pageBuilder } from '@myissue/vue-website-page-builder'
|
|
336
|
+
import '@myissue/vue-website-page-builder/style.css'
|
|
337
|
+
|
|
338
|
+
const app = createApp(App)
|
|
339
|
+
app.use(pageBuilder)
|
|
340
|
+
app.mount('#app')
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### 3. Using the Page Builder Component
|
|
344
|
+
|
|
345
|
+
Now anywhere in your application, use the `getPageBuilder()` composable to interact with the Page Builder’s shared instance.
|
|
346
|
+
|
|
347
|
+
You’re now ready to use the Page Builder in your Vue pages or components with the `getPageBuilder()` composable.
|
|
348
|
+
|
|
349
|
+
```vue
|
|
347
350
|
<script setup>
|
|
348
351
|
import { PageBuilder, getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
349
|
-
// Import the Page Builder styles once in your application entry, not in individual components.
|
|
350
|
-
import '@myissue/vue-website-page-builder/style.css'
|
|
351
352
|
|
|
352
353
|
const configPageBuilder = {
|
|
353
354
|
updateOrCreate: {
|
|
@@ -365,7 +366,39 @@ console.info('You may inspect this result for message, status, or error:', resul
|
|
|
365
366
|
<template>
|
|
366
367
|
<PageBuilder />
|
|
367
368
|
</template>
|
|
368
|
-
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### 4. Initialize Page Builder with `onMounted` Troubleshooting
|
|
372
|
+
|
|
373
|
+
If you encounter issues with the component not fully mounting, you can initialize the Page Builder inside Vue's `onMounted` lifecycle hook. This ensures it runs safely after the component is mounted.
|
|
374
|
+
|
|
375
|
+
```vue
|
|
376
|
+
<script setup>
|
|
377
|
+
import { onMounted } from 'vue'
|
|
378
|
+
import { PageBuilder, getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
379
|
+
|
|
380
|
+
const configPageBuilder = {
|
|
381
|
+
updateOrCreate: {
|
|
382
|
+
formType: 'create',
|
|
383
|
+
formName: 'article',
|
|
384
|
+
},
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Initialize the Page Builder with `onMounted`
|
|
388
|
+
onMounted(async () => {
|
|
389
|
+
const pageBuilderService = getPageBuilder()
|
|
390
|
+
const result = await pageBuilderService.startBuilder(configPageBuilder)
|
|
391
|
+
console.info('You may inspect this result for message, status, or error:', result)
|
|
392
|
+
})
|
|
393
|
+
</script>
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Why Use the Shared Instance?
|
|
397
|
+
|
|
398
|
+
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.
|
|
399
|
+
|
|
400
|
+
> **Note:**
|
|
401
|
+
> The Page Builder is implemented as a singleton service. All page-building logic and state are managed by a single shared instance, even if you use `<PageBuilder />` in multiple places.
|
|
369
402
|
|
|
370
403
|
## Important: CSS Prefixing (`pbx-`)
|
|
371
404
|
|
|
@@ -374,9 +407,9 @@ This prevents global styles from leaking into the builder and vice versa, which
|
|
|
374
407
|
|
|
375
408
|
**How does this affect you?**
|
|
376
409
|
|
|
377
|
-
When a user adds a component into the
|
|
410
|
+
When a user adds a component into the Page Builder, all classes from that component are automatically prefixed with `pbx-` (e.g., `pbx-button`, `pbx-container`) to ensure style isolation and avoid conflicts.
|
|
378
411
|
|
|
379
|
-
Tailwind installation is not required. The
|
|
412
|
+
Tailwind installation is not required. The Page Builder ships with prefixed utility classes to ensure there are no naming conflicts. If you wish to use Tailwind in your own application, you may install and configure it as usual without interfering with the Page Builder.
|
|
380
413
|
|
|
381
414
|
> **Note:**
|
|
382
415
|
> Simply import the builder’s CSS file once in your project. All builder styles are namespaced, so there is no risk of style conflicts.
|
|
@@ -413,7 +446,7 @@ import { ref } from 'vue'
|
|
|
413
446
|
// Import the Page Builder styles once in your application entry, not in individual components.
|
|
414
447
|
import '@myissue/vue-website-page-builder/style.css'
|
|
415
448
|
|
|
416
|
-
const rawHtml = ref('<p>This is content from the
|
|
449
|
+
const rawHtml = ref('<p>This is content from the Page Builder.</p>')
|
|
417
450
|
</script>
|
|
418
451
|
|
|
419
452
|
<template>
|
|
@@ -593,9 +626,9 @@ yourForm.content = storedComponents
|
|
|
593
626
|
|
|
594
627
|
### Resetting the Builder After Successful Resource Creation or Update
|
|
595
628
|
|
|
596
|
-
After successfully creating or updating a resource (such as a post, article, or listing) using the Page Builder, it is important to clear the DOM and the builder’s draft state, as well as 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.
|
|
629
|
+
After successfully creating or updating a resource (such as a post, article, or listing) using the Page Builder, it is important to clear the `DOM` and the builder’s draft state, as well as 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.
|
|
597
630
|
|
|
598
|
-
You can reset the Page Builder’s live DOM
|
|
631
|
+
You can reset the Page Builder’s live `DOM`, builder state, and clear the draft with:
|
|
599
632
|
|
|
600
633
|
```typescript
|
|
601
634
|
await pageBuilderService.handleFormSubmission()
|
|
@@ -819,7 +852,7 @@ Learn how to create and integrate your own components step by step.
|
|
|
819
852
|
|
|
820
853
|
## Troubleshooting
|
|
821
854
|
|
|
822
|
-
### Fonts or Icons Not Displaying
|
|
855
|
+
### 1. Fonts or Icons Not Displaying
|
|
823
856
|
|
|
824
857
|
If fonts or Material Icons are not displaying correctly, verify that:
|
|
825
858
|
|
|
@@ -830,9 +863,34 @@ If fonts or Material Icons are not displaying correctly, verify that:
|
|
|
830
863
|
import '@myissue/vue-website-page-builder/style.css'
|
|
831
864
|
```
|
|
832
865
|
|
|
866
|
+
### 2. Initialize Page Builder with `onMounted` Troubleshooting
|
|
867
|
+
|
|
868
|
+
If you encounter issues with the component not fully mounting, you can initialize the Page Builder inside Vue's `onMounted` lifecycle hook. This ensures it runs safely after the component is mounted.
|
|
869
|
+
|
|
870
|
+
```vue
|
|
871
|
+
<script setup>
|
|
872
|
+
import { onMounted } from 'vue'
|
|
873
|
+
import { PageBuilder, getPageBuilder } from '@myissue/vue-website-page-builder'
|
|
874
|
+
|
|
875
|
+
const configPageBuilder = {
|
|
876
|
+
updateOrCreate: {
|
|
877
|
+
formType: 'create',
|
|
878
|
+
formName: 'article',
|
|
879
|
+
},
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// Initialize the Page Builder with `onMounted`
|
|
883
|
+
onMounted(async () => {
|
|
884
|
+
const pageBuilderService = getPageBuilder()
|
|
885
|
+
const result = await pageBuilderService.startBuilder(configPageBuilder)
|
|
886
|
+
console.info('You may inspect this result for message, status, or error:', result)
|
|
887
|
+
})
|
|
888
|
+
</script>
|
|
889
|
+
```
|
|
890
|
+
|
|
833
891
|
## Page Builder Architecture
|
|
834
892
|
|
|
835
|
-
The Page Builder is designed as a modular, state-driven editor for dynamic page content. Its architecture separates configuration, state management, and DOM interaction, ensuring flexibility and maintainability.
|
|
893
|
+
The Page Builder is designed as a modular, state-driven editor for dynamic page content. Its architecture separates configuration, state management, and `DOM` interaction, ensuring flexibility and maintainability.
|
|
836
894
|
|
|
837
895
|
### How the Page Builder Works
|
|
838
896
|
|
|
@@ -840,7 +898,7 @@ The Page Builder is designed to be easy to use and flexible for any web project.
|
|
|
840
898
|
|
|
841
899
|
- **Configuration First:**
|
|
842
900
|
When you start the builder, you pass in your configuration (such as what type of page you’re building, user info, branding, and any existing content).
|
|
843
|
-
The builder saves this configuration immediately—even if the editing interface
|
|
901
|
+
The builder saves this configuration immediately—even if the editing interface `DOM` isn’t loaded yet. This means you can safely set up the builder in advance, and it will be ready as soon as the editor appears on the page.
|
|
844
902
|
|
|
845
903
|
- **Loading Content:**
|
|
846
904
|
If you have existing content (like a published page), the builder loads it so you can continue editing. If not, you start with a blank page.
|