@myissue/vue-website-page-builder 3.1.23 → 3.1.25

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,8 +127,93 @@ 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
 
177
+ ### Updating Existing Resources
178
+
179
+ To load existing content that was created with this PageBuilder:
180
+
181
+ - Use `sharedPageBuilderStore` to ensure the external PageBuilderClass and internal PageBuilder component share the same state
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
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
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.
185
+
186
+ 1. **Set formType to "update"** in template:
187
+
188
+ ```javascript
189
+ <PageBuilder />
190
+ ```
191
+
192
+ 2. **Load existing content on mount**:
193
+
194
+ ```javascript
195
+ import { onMounted } from 'vue'
196
+ import {
197
+ PageBuilder,
198
+ PageBuilderClass,
199
+ sharedPageBuilderStore,
200
+ } from '@myissue/vue-website-page-builder'
201
+
202
+ const configPageBuilder = {
203
+ updateOrCreate: {
204
+ formType: 'update',
205
+ },
206
+ }
207
+
208
+ const pageBuilderStateStore = sharedPageBuilderStore
209
+ const pageBuilderClass = new PageBuilderClass(pageBuilderStateStore)
210
+
211
+ onMounted(() => {
212
+ pageBuilderClass.setConfigPageBuilder(configPageBuilder)
213
+ pageBuilderClass.loadExistingContent(existingResourceFromBackend)
214
+ })
215
+ ```
216
+
130
217
  ### Customization
131
218
 
132
219
  Customizing the page builder is made simple since all the logic resides in the PageBuilder Class.
@@ -153,7 +240,9 @@ import SearchComponent from './ComponentsPageBuilder/SearchComponent.vue'
153
240
 
154
241
  ### Company Logo
155
242
 
156
- 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.
157
246
 
158
247
  Basic Usage:
159
248
 
@@ -161,10 +250,28 @@ Basic Usage:
161
250
  <script setup>
162
251
  import { PageBuilder } from '@myissue/vue-website-page-builder'
163
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
+ })
164
271
  </script>
165
272
 
166
273
  <template>
167
- <PageBuilder PageBuilderLogo="/logo/square-logo.svg" />
274
+ <PageBuilder />
168
275
  </template>
169
276
  ```
170
277