@myissue/vue-website-page-builder 3.1.24 → 3.1.26

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
@@ -114,6 +114,8 @@ bun install
114
114
 
115
115
  ### Quick Start
116
116
 
117
+ 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.
118
+
117
119
  ```vue
118
120
  <script setup>
119
121
  import { PageBuilder } from '@myissue/vue-website-page-builder'
@@ -125,6 +127,51 @@ import '@myissue/vue-website-page-builder/style.css'
125
127
  </template>
126
128
  ```
127
129
 
130
+ ### Optional: Provide Config to PageBuilder
131
+
132
+ 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.
133
+
134
+ - Use `sharedPageBuilderStore` to ensure the external PageBuilderClass and internal PageBuilder component share the same state
135
+ - (Optional) Provide a `configPageBuilder` object to customize the builder, such as:
136
+ - `pageBuilderLogo` to display your company logo in the builder toolbar
137
+ - `resourceData` to prefill the builder with initial data
138
+ - `userSettings` to set user preferences such as theme, language, or autoSave
139
+
140
+ ```vue
141
+ <script setup>
142
+ import { onMounted } from 'vue'
143
+ import { PageBuilder } from '@myissue/vue-website-page-builder'
144
+ import '@myissue/vue-website-page-builder/style.css'
145
+
146
+ const configPageBuilder = {
147
+ pageBuilderLogo: {
148
+ src: '/logo/logo.svg',
149
+ },
150
+ userForPageBuilder: { name: 'John Doe' },
151
+ resourceData: {
152
+ title: 'Demo Article',
153
+ id: 1,
154
+ },
155
+ userSettings: {
156
+ theme: 'light',
157
+ language: 'en',
158
+ autoSave: true,
159
+ },
160
+ }
161
+
162
+ const pageBuilderStateStore = sharedPageBuilderStore
163
+ const pageBuilderClass = new PageBuilderClass(pageBuilderStateStore)
164
+
165
+ onMounted(() => {
166
+ pageBuilderClass.setConfigPageBuilder(configPageBuilder)
167
+ })
168
+ </script>
169
+
170
+ <template>
171
+ <PageBuilder />
172
+ </template>
173
+ ```
174
+
128
175
  > **📝 Note**: Google Fonts (Jost, Cormorant) and Material Icons are automatically loaded when you import the CSS file. No additional setup required for fonts or icons!
129
176
 
130
177
  ### Updating Existing Resources
@@ -134,16 +181,12 @@ To load existing content that was created with this PageBuilder:
134
181
  - Use `sharedPageBuilderStore` to ensure the external PageBuilderClass and internal PageBuilder component share the same state
135
182
  - Import `PageBuilderClass` which contains all methods to manipulate and control the page builder state - in this case we need the `loadExistingContent()` method to load existing content into the page builder
136
183
  - 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
137
- - Set formType to "update" to tell the PageBuilder that you're editing an existing resource rather than creating a new one, which affects how the component handles data and interactions
184
+ - Set `formType` to `"update"` in your config object and pass it to the PageBuilder using `pageBuilderClass.setConfigPageBuilder(configPageBuilder)` inside `onMounted`. 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.
138
185
 
139
186
  1. **Set formType to "update"** in template:
140
187
 
141
188
  ```javascript
142
- <PageBuilder
143
- updateOrCreate: {
144
- formType: 'update',
145
- }
146
- />
189
+ <PageBuilder />
147
190
  ```
148
191
 
149
192
  2. **Load existing content on mount**:
@@ -156,10 +199,17 @@ import {
156
199
  sharedPageBuilderStore,
157
200
  } from '@myissue/vue-website-page-builder'
158
201
 
202
+ const configPageBuilder = {
203
+ updateOrCreate: {
204
+ formType: 'update',
205
+ },
206
+ }
207
+
159
208
  const pageBuilderStateStore = sharedPageBuilderStore
160
209
  const pageBuilderClass = new PageBuilderClass(pageBuilderStateStore)
161
210
 
162
211
  onMounted(() => {
212
+ pageBuilderClass.setConfigPageBuilder(configPageBuilder)
163
213
  pageBuilderClass.loadExistingContent(existingResourceFromBackend)
164
214
  })
165
215
  ```
@@ -190,7 +240,9 @@ import SearchComponent from './ComponentsPageBuilder/SearchComponent.vue'
190
240
 
191
241
  ### Company Logo
192
242
 
193
- You can display your company logo in the page builder interface by passing a logo URL to the `PageBuilderLogo` prop. When provided, the logo will appear in the top toolbar of the page builder.
243
+ You can display your company logo in the page builder interface by passing a logo URL:
244
+
245
+ - You can display your company logo in the page builder interface by setting the logo URL in your config object and passing it to the PageBuilder using `pageBuilderClass.setConfigPageBuilder(configPageBuilder)` inside `onMounted`. When provided, the logo will appear in the top toolbar of the page builder.
194
246
 
195
247
  Basic Usage:
196
248
 
@@ -198,10 +250,28 @@ Basic Usage:
198
250
  <script setup>
199
251
  import { PageBuilder } from '@myissue/vue-website-page-builder'
200
252
  import '@myissue/vue-website-page-builder/style.css'
253
+
254
+ const configPageBuilder = {
255
+ pageBuilderLogo: {
256
+ src: '/logo/logo.svg',
257
+ },
258
+ userForPageBuilder: { name: 'John Doe' },
259
+ resourceData: {
260
+ title: 'Demo Article',
261
+ id: 1,
262
+ },
263
+ }
264
+
265
+ const pageBuilderStateStore = sharedPageBuilderStore
266
+ const pageBuilderClass = new PageBuilderClass(pageBuilderStateStore)
267
+
268
+ onMounted(() => {
269
+ pageBuilderClass.setConfigPageBuilder(configPageBuilder)
270
+ })
201
271
  </script>
202
272
 
203
273
  <template>
204
- <PageBuilder PageBuilderLogo="/logo/square-logo.svg" />
274
+ <PageBuilder />
205
275
  </template>
206
276
  ```
207
277