@myissue/vue-website-page-builder 3.4.27 β†’ 3.4.28

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 CHANGED
@@ -19,8 +19,12 @@
19
19
  - [Installation](#installation)
20
20
  - [Quick Start](#quick-start)
21
21
  - [Initializing the Page Builder](#initializing-the-page-builder)
22
- - [Nuxt 3 Integration](#nuxt-3-integration)
23
- - [Create a Nuxt Plugin](#create-a-nuxt-plugin)
22
+ - [Nuxt Integration](#nuxt-integration)
23
+ - [1. Install the Package](#1-install-the-package)
24
+ - [2. Create a Nuxt Plugin](#2-create-a-nuxt-plugin)
25
+ - [3. Register the Plugin in `nuxt.config.ts`](#3-register-the-plugin-in-nuxtconfigts)
26
+ - [4. Using the Page Builder Component](#4-using-the-page-builder-component)
27
+ - [Why initialize the page builder with `onMounted`](#why-initialize-the-page-builder-with-onmounted)
24
28
  - [Why Use the Shared Instance? By always accessing the shared instance, you avoid creating](#why-use-the-shared-instance-by-always-accessing-the-shared-instance-you-avoid-creating)
25
29
  - [Important: CSS Prefixing (`pbx-`)](#important-css-prefixing-pbx-)
26
30
  - [Rendering HTML Output in Other Frameworks (React, Nuxt, etc.)](#rendering-html-output-in-other-frameworks-react-nuxt-etc)
@@ -219,12 +223,17 @@ To get started with the Page Builder, follow these steps:
219
223
 
220
224
  - **Use the Page Builder plugin** in your application entry point (e.g., `main.ts` or `main.js`). This sets up the shared builder instance for your entire app.
221
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
+
222
230
  - **Import the CSS file once** in your `main.js`, `main.ts`, or root component to ensure proper styling and automatic icon loading.
223
231
 
224
232
  ```typescript
225
233
  import { createApp } from 'vue'
226
234
  import App from './App.vue'
227
235
  import { pageBuilder } from '@myissue/vue-website-page-builder'
236
+ // Import the Page Builder styles once in your application entry, not in individual components.
228
237
  import '@myissue/vue-website-page-builder/style.css'
229
238
 
230
239
  // Use the Page Builder plugin
@@ -233,32 +242,34 @@ app.use(pageBuilder)
233
242
  app.mount('#app')
234
243
  ```
235
244
 
236
- > **Note:**
237
- > 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.
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.
238
246
 
239
- > **Note:**
240
- > 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.
247
+ ### Nuxt Integration
241
248
 
242
- ### Nuxt 3 Integration
249
+ > **πŸŽ‰ Great news:** The Page Builder now works with Nuxt 3 and Nuxt 4.
250
+ > Follow the steps below to get started in your Nuxt project.
243
251
 
244
- To use `@myissue/vue-website-page-builder` in a Nuxt 3 project, follow these steps:
252
+ To use `@myissue/vue-website-page-builder` in your Nuxt 3 project, follow these steps
253
+
254
+ #### 1. Install the Package
245
255
 
246
256
  ```bash
247
257
  npm install @myissue/vue-website-page-builder
248
258
  ```
249
259
 
250
- #### Create a Nuxt Plugin
260
+ #### 2. Create a Nuxt Plugin
251
261
 
252
- Create a file:
262
+ In the root create a file named:
253
263
 
254
264
  ```
255
265
  plugins/page-builder.client.js
256
266
  ```
257
267
 
258
- Add:
268
+ Add the following code:
259
269
 
260
270
  ```javascript
261
271
  import { pageBuilder } from '@myissue/vue-website-page-builder'
272
+ // Import the Page Builder styles once in your application entry, not in individual components.
262
273
  import '@myissue/vue-website-page-builder/style.css'
263
274
 
264
275
  export default defineNuxtPlugin((nuxtApp) => {
@@ -266,16 +277,63 @@ export default defineNuxtPlugin((nuxtApp) => {
266
277
  })
267
278
  ```
268
279
 
269
- Uusing the component:
280
+ #### 3. Register the Plugin in `nuxt.config.ts`
281
+
282
+ Make sure Nuxt knows about your new plugin by adding it to your config:
283
+
284
+ > **Note:** If your plugin is inside the `/plugins` folder, Nuxt will auto-register it.
285
+ > Adding it to `nuxt.config.ts` is optional, but can be useful for clarity.
286
+
287
+ ```typescript
288
+ export default defineNuxtConfig({
289
+ devtools: { enabled: true },
290
+ plugins: ['./plugins/page-builder.client.js'],
291
+ })
292
+ ```
293
+
294
+ #### 4. Using the Page Builder Component
295
+
296
+ Now you’re ready to use the builder in your pages or components.
297
+
298
+ 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.
270
299
 
271
300
  ```vue
301
+ <script setup>
302
+ import { onMounted } from 'vue'
303
+ import { PageBuilder, getPageBuilder } from '@myissue/vue-website-page-builder'
304
+
305
+ const configPageBuilder = {
306
+ updateOrCreate: {
307
+ formType: 'create',
308
+ formName: 'article',
309
+ },
310
+ }
311
+
312
+ // Initialize the page builder with `onMounted`
313
+ // The Page Builder depends on the browser (DOM, `window`, `localStorage`, etc.)
314
+ onMounted(async () => {
315
+ const pageBuilderService = getPageBuilder()
316
+ const result = await pageBuilderService.startBuilder(configPageBuilder)
317
+ console.info('You may inspect this result for message, status, or error:', result)
318
+ })
319
+ </script>
320
+
272
321
  <template>
273
- <client-only>
274
- <PageBuilder />
275
- </client-only>
322
+ <div>
323
+ <client-only>
324
+ <PageBuilder />
325
+ </client-only>
326
+ </div>
276
327
  </template>
277
328
  ```
278
329
 
330
+ > **Tip:**
331
+ > By initializing the builder inside `onMounted`, you ensure everything is ready and avoid those pesky hydration errors.
332
+
333
+ #### Why initialize the page builder with `onMounted`
334
+
335
+ 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 same pattern.
336
+
279
337
  ### Why Use the Shared Instance? By always accessing the shared instance, you avoid creating
280
338
 
281
339
  multiple, isolated copies of the builder. This prevents data inconsistencies, synchronization
@@ -288,6 +346,7 @@ the correct content from local storage. - **`formName` (required):** Specifies t
288
346
 
289
347
  <script setup>
290
348
  import { PageBuilder, getPageBuilder } from '@myissue/vue-website-page-builder'
349
+ // Import the Page Builder styles once in your application entry, not in individual components.
291
350
  import '@myissue/vue-website-page-builder/style.css'
292
351
 
293
352
  const configPageBuilder = {
@@ -329,6 +388,7 @@ You can use the Page Builder to generate HTML and render it in any frontend fram
329
388
  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.
330
389
 
331
390
  ```typescript
391
+ // Import the Page Builder styles once in your application entry, not in individual components.
332
392
  import '@myissue/vue-website-page-builder/style.css'
333
393
  ```
334
394
 
@@ -337,6 +397,7 @@ This will apply all necessary styles to any HTML output from the builder, even i
337
397
  **Example (React):**
338
398
 
339
399
  ```jsx
400
+ // Import the Page Builder styles once in your application entry, not in individual components.
340
401
  import '@myissue/vue-website-page-builder/style.css'
341
402
 
342
403
  function MyPage({ html }) {
@@ -349,6 +410,7 @@ function MyPage({ html }) {
349
410
  ```vue
350
411
  <script setup>
351
412
  import { ref } from 'vue'
413
+ // Import the Page Builder styles once in your application entry, not in individual components.
352
414
  import '@myissue/vue-website-page-builder/style.css'
353
415
 
354
416
  const rawHtml = ref('<p>This is content from the page builder.</p>')
@@ -764,6 +826,7 @@ If fonts or Material Icons are not displaying correctly, verify that:
764
826
  **CSS Import**: You are importing the CSS file:
765
827
 
766
828
  ```typescript
829
+ // Import the Page Builder styles once in your application entry, not in individual components.
767
830
  import '@myissue/vue-website-page-builder/style.css'
768
831
  ```
769
832