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

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myissue/vue-website-page-builder",
3
- "version": "v3.1.26",
3
+ "version": "v3.1.30",
4
4
  "description": "🚧 DEVELOPMENT VERSION - Vue.js page builder component with drag & drop functionality. Not ready for production use.",
5
5
  "type": "module",
6
6
  "main": "./dist/vue-website-page-builder.umd.cjs",
@@ -1135,103 +1135,139 @@ class PageBuilderClass {
1135
1135
  const resourceFormName =
1136
1136
  this.pageBuilderStateStore.getConfigPageBuilder?.updateOrCreate?.createNewResourceFormName
1137
1137
 
1138
- // Logic for create
1139
- if (updateOrCreate === 'create' && resourceFormName && resourceFormName.length > 0) {
1140
- this.pageBuilderStateStore.setLocalStorageItemName(
1141
- `page-builder-create-resource-${this.sanitizeForLocalStorage(resourceFormName)}`,
1142
- )
1143
- return
1144
- }
1145
-
1146
- // Logic for create
1138
+ // Logic for create resource
1147
1139
  if (updateOrCreate === 'create') {
1148
- this.pageBuilderStateStore.setLocalStorageItemName(`page-builder-create-resource`)
1149
- return
1150
- }
1151
-
1152
- // Logic for update
1153
- if (
1154
- (updateOrCreate === 'update' && typeof resourceFormName !== 'string') ||
1155
- (typeof resourceFormName === 'string' && resourceFormName?.length < 1)
1156
- ) {
1157
- // if resource data is null
1158
- if (resourceData === null) {
1159
- this.pageBuilderStateStore.setLocalStorageItemName(`page-builder-update-resource`)
1160
- return
1161
- }
1162
-
1163
- // If resource is present
1164
-
1165
- // Runs when resourceData has id but no title
1166
- if (typeof resourceData === 'object' && 'id' in resourceData && !('title' in resourceData)) {
1167
- const sanitizedId = this.sanitizeForLocalStorage(String(resourceData['id']))
1168
- this.pageBuilderStateStore.setLocalStorageItemName(
1169
- `page-builder-update-resource-${sanitizedId}`,
1170
- )
1171
- return
1172
- }
1173
-
1174
- // Runs when resourceData has title but no id
1175
- if (typeof resourceData === 'object' && 'title' in resourceData && !('id' in resourceData)) {
1176
- const sanitizedTitle = this.sanitizeForLocalStorage(String(resourceData['title']))
1140
+ if (resourceFormName && resourceFormName.length > 0) {
1177
1141
  this.pageBuilderStateStore.setLocalStorageItemName(
1178
- `page-builder-update-resource-${sanitizedTitle}`,
1142
+ `page-builder-create-resource-${this.sanitizeForLocalStorage(resourceFormName)}`,
1179
1143
  )
1180
1144
  return
1181
1145
  }
1182
1146
 
1183
- // Runs when resourceData has both title and id
1184
- if (typeof resourceData === 'object' && 'title' in resourceData && 'id' in resourceData) {
1185
- const sanitizedId = this.sanitizeForLocalStorage(String(resourceData['id']))
1186
- const sanitizedTitle = this.sanitizeForLocalStorage(String(resourceData['title']))
1187
-
1188
- this.pageBuilderStateStore.setLocalStorageItemName(
1189
- `page-builder-update-resource-${sanitizedTitle}-${sanitizedId}`,
1190
- )
1191
- return
1192
- }
1147
+ this.pageBuilderStateStore.setLocalStorageItemName(`page-builder-create-resource`)
1148
+ return
1193
1149
  }
1150
+
1151
+ // Logic for create
1194
1152
  // Logic for update and with resource form name
1195
- if (
1196
- updateOrCreate === 'update' &&
1197
- typeof resourceFormName === 'string' &&
1198
- resourceFormName.length > 0
1199
- ) {
1200
- // if resource data is null
1201
- if (resourceData === null) {
1202
- this.pageBuilderStateStore.setLocalStorageItemName(`page-builder-update-resource`)
1203
- return
1204
- }
1153
+ if (updateOrCreate === 'update') {
1154
+ //
1155
+ //
1156
+ //
1157
+ if (typeof resourceFormName === 'string' && resourceFormName.length > 0) {
1158
+ //
1159
+ //
1160
+ if (resourceData && resourceData != null && !resourceData.title) {
1161
+ // Check if id is missing, null, undefined, or an empty string (after trimming)
1162
+ if (!resourceData.id || typeof resourceData.id === 'string') {
1163
+ this.pageBuilderStateStore.setLocalStorageItemName(`page-builder-update-resource`)
1164
+ return
1165
+ }
1166
+ }
1205
1167
 
1206
- // If resource is present
1168
+ // Runs when resourceData has title but no ID
1169
+ if (resourceData && resourceData != null) {
1170
+ if (
1171
+ resourceData.title &&
1172
+ typeof resourceData.title === 'string' &&
1173
+ resourceData.title.length > 0
1174
+ ) {
1175
+ if (!resourceData.id || typeof resourceData.id === 'string') {
1176
+ this.pageBuilderStateStore.setLocalStorageItemName(
1177
+ `page-builder-update-resource-${this.sanitizeForLocalStorage(resourceFormName)}-${this.sanitizeForLocalStorage(resourceData.title)}`,
1178
+ )
1179
+ return
1180
+ }
1181
+ }
1182
+ }
1207
1183
 
1208
- // Runs when resourceData has id but no title
1209
- if (typeof resourceData === 'object' && 'id' in resourceData && !('title' in resourceData)) {
1210
- const sanitizedId = this.sanitizeForLocalStorage(String(resourceData['id']))
1211
- this.pageBuilderStateStore.setLocalStorageItemName(
1212
- `page-builder-update-resource-${sanitizedId}-${this.sanitizeForLocalStorage(resourceFormName)}`,
1213
- )
1214
- return
1215
- }
1184
+ // Runs when resourceData has ID but no title
1185
+ if (resourceData && resourceData != null) {
1186
+ if (!resourceData.title && typeof resourceData.title !== 'string') {
1187
+ if (resourceData.id || typeof resourceData.id === 'number') {
1188
+ this.pageBuilderStateStore.setLocalStorageItemName(
1189
+ `page-builder-update-resource-${this.sanitizeForLocalStorage(resourceFormName)}-${this.sanitizeForLocalStorage(String(resourceData.id))}`,
1190
+ )
1191
+ return
1192
+ }
1193
+ }
1194
+ }
1216
1195
 
1217
- // Runs when resourceData has title but no id
1218
- if (typeof resourceData === 'object' && 'title' in resourceData && !('id' in resourceData)) {
1219
- const sanitizedTitle = this.sanitizeForLocalStorage(String(resourceData['title']))
1220
- this.pageBuilderStateStore.setLocalStorageItemName(
1221
- `page-builder-update-resource-${sanitizedTitle}-${this.sanitizeForLocalStorage(resourceFormName)}`,
1222
- )
1223
- return
1196
+ // Runs when resourceData has both title and ID
1197
+ if (resourceData && resourceData != null) {
1198
+ if (
1199
+ resourceData.title &&
1200
+ typeof resourceData.title === 'string' &&
1201
+ resourceData.title.length > 0
1202
+ ) {
1203
+ if (resourceData.id || typeof resourceData.id === 'number') {
1204
+ this.pageBuilderStateStore.setLocalStorageItemName(
1205
+ `page-builder-update-resource-${this.sanitizeForLocalStorage(resourceFormName)}-${this.sanitizeForLocalStorage(resourceData.title)}-${this.sanitizeForLocalStorage(String(resourceData.id))}`,
1206
+ )
1207
+ return
1208
+ }
1209
+ }
1210
+ }
1224
1211
  }
1225
1212
 
1226
- // Runs when resourceData has both title and id
1227
- if (typeof resourceData === 'object' && 'title' in resourceData && 'id' in resourceData) {
1228
- const sanitizedId = this.sanitizeForLocalStorage(String(resourceData['id']))
1229
- const sanitizedTitle = this.sanitizeForLocalStorage(String(resourceData['title']))
1213
+ // Logic for update without without resourceFormName
1214
+ if (
1215
+ !resourceFormName ||
1216
+ (typeof resourceFormName === 'string' && resourceFormName.length === 0)
1217
+ ) {
1218
+ //
1219
+ //
1220
+ if (resourceData && resourceData != null && !resourceData.title) {
1221
+ // Check if id is missing, null, undefined, or an empty string (after trimming)
1222
+ if (!resourceData.id || typeof resourceData.id === 'string') {
1223
+ this.pageBuilderStateStore.setLocalStorageItemName(`page-builder-update-resource`)
1224
+ return
1225
+ }
1226
+ }
1230
1227
 
1231
- this.pageBuilderStateStore.setLocalStorageItemName(
1232
- `page-builder-update-resource-${sanitizedTitle}-${this.sanitizeForLocalStorage(resourceFormName)}-${sanitizedId}`,
1233
- )
1234
- return
1228
+ // Runs when resourceData has title but no ID
1229
+ if (resourceData && resourceData != null) {
1230
+ if (
1231
+ resourceData.title &&
1232
+ typeof resourceData.title === 'string' &&
1233
+ resourceData.title.length > 0
1234
+ ) {
1235
+ if (!resourceData.id || typeof resourceData.id === 'string') {
1236
+ this.pageBuilderStateStore.setLocalStorageItemName(
1237
+ `page-builder-update-resource-${this.sanitizeForLocalStorage(resourceData.title)}`,
1238
+ )
1239
+ return
1240
+ }
1241
+ }
1242
+ }
1243
+
1244
+ // Runs when resourceData has ID but no title
1245
+ if (resourceData && resourceData != null) {
1246
+ if (!resourceData.title && typeof resourceData.title !== 'string') {
1247
+ if (resourceData.id || typeof resourceData.id === 'number') {
1248
+ this.pageBuilderStateStore.setLocalStorageItemName(
1249
+ `page-builder-update-resource-${this.sanitizeForLocalStorage(String(resourceData.id))}`,
1250
+ )
1251
+ return
1252
+ }
1253
+ }
1254
+ }
1255
+
1256
+ // Runs when resourceData has both title and ID
1257
+ if (resourceData && resourceData != null) {
1258
+ if (
1259
+ resourceData.title &&
1260
+ typeof resourceData.title === 'string' &&
1261
+ resourceData.title.length > 0
1262
+ ) {
1263
+ if (resourceData.id || typeof resourceData.id === 'number') {
1264
+ this.pageBuilderStateStore.setLocalStorageItemName(
1265
+ `page-builder-update-resource-${this.sanitizeForLocalStorage(resourceData.title)}-${this.sanitizeForLocalStorage(String(resourceData.id))}`,
1266
+ )
1267
+ return
1268
+ }
1269
+ }
1270
+ }
1235
1271
  }
1236
1272
  }
1237
1273
  }
@@ -1575,15 +1611,12 @@ class PageBuilderClass {
1575
1611
  const trimmedData = data.trim()
1576
1612
 
1577
1613
  if (trimmedData.startsWith('[') || trimmedData.startsWith('{')) {
1578
- console.log('Using JSON method..............1:', trimmedData)
1579
1614
  // Looks like JSON - parse as JSON
1580
1615
  this.#parseJSONComponents(trimmedData)
1581
1616
  } else if (trimmedData.startsWith('<')) {
1582
- console.log('Using HTML method..............2:', trimmedData)
1583
1617
  // Looks like HTML - parse as HTML
1584
1618
  this.#parseHTMLComponents(trimmedData)
1585
1619
  } else {
1586
- console.log('Using JSON method..............3:', trimmedData)
1587
1620
  this.#parseJSONComponents(trimmedData)
1588
1621
  }
1589
1622
  }