@elementor/editor-props 4.0.0-552 → 4.0.0-573

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/dist/index.js CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  cssFilterFunctionPropUtil: () => cssFilterFunctionPropUtil,
47
47
  dimensionsPropTypeUtil: () => dimensionsPropTypeUtil,
48
48
  dropShadowFilterPropTypeUtil: () => dropShadowFilterPropTypeUtil,
49
+ emailPropTypeUtil: () => emailPropTypeUtil,
49
50
  evaluateTerm: () => evaluateTerm,
50
51
  extractValue: () => extractValue,
51
52
  filterEmptyValues: () => filterEmptyValues,
@@ -54,6 +55,7 @@ __export(index_exports, {
54
55
  getPropSchemaFromCache: () => getPropSchemaFromCache,
55
56
  gradientColorStopPropTypeUtil: () => gradientColorStopPropTypeUtil,
56
57
  htmlPropTypeUtil: () => htmlPropTypeUtil,
58
+ htmlV2PropTypeUtil: () => htmlV2PropTypeUtil,
57
59
  hueRotateFilterPropTypeUtil: () => hueRotateFilterPropTypeUtil,
58
60
  imageAttachmentIdPropType: () => imageAttachmentIdPropType,
59
61
  imagePropTypeUtil: () => imagePropTypeUtil,
@@ -69,6 +71,7 @@ __export(index_exports, {
69
71
  mergeProps: () => mergeProps,
70
72
  moveTransformPropTypeUtil: () => moveTransformPropTypeUtil,
71
73
  numberPropTypeUtil: () => numberPropTypeUtil,
74
+ parseHtmlChildren: () => parseHtmlChildren,
72
75
  perspectiveOriginPropTypeUtil: () => perspectiveOriginPropTypeUtil,
73
76
  positionPropTypeUtil: () => positionPropTypeUtil,
74
77
  queryPropTypeUtil: () => queryPropTypeUtil,
@@ -295,44 +298,61 @@ var import_schema16 = require("@elementor/schema");
295
298
  var stringPropTypeUtil = createPropUtils("string", import_schema16.z.string().nullable());
296
299
 
297
300
  // src/prop-types/string-array.ts
298
- var import_schema17 = require("@elementor/schema");
299
- var stringArrayPropTypeUtil = createPropUtils("string-array", import_schema17.z.array(import_schema17.z.string()));
301
+ var stringArrayPropTypeUtil = createArrayPropUtils(stringPropTypeUtil.key, stringPropTypeUtil.schema);
300
302
 
301
303
  // src/prop-types/stroke.ts
302
- var import_schema18 = require("@elementor/schema");
304
+ var import_schema17 = require("@elementor/schema");
303
305
  var strokePropTypeUtil = createPropUtils(
304
306
  "stroke",
305
- import_schema18.z.strictObject({
307
+ import_schema17.z.strictObject({
306
308
  color: unknownChildrenSchema,
307
309
  width: unknownChildrenSchema
308
310
  })
309
311
  );
310
312
 
311
313
  // src/prop-types/url.ts
312
- var import_schema19 = require("@elementor/schema");
313
- var urlPropTypeUtil = createPropUtils("url", import_schema19.z.string().nullable());
314
+ var import_schema18 = require("@elementor/schema");
315
+ var urlPropTypeUtil = createPropUtils("url", import_schema18.z.string().nullable());
314
316
 
315
317
  // src/prop-types/layout-direction.ts
316
- var import_schema20 = require("@elementor/schema");
318
+ var import_schema19 = require("@elementor/schema");
317
319
  var layoutDirectionPropTypeUtil = createPropUtils(
318
320
  "layout-direction",
319
- import_schema20.z.object({
320
- row: import_schema20.z.any(),
321
- column: import_schema20.z.any()
321
+ import_schema19.z.object({
322
+ row: import_schema19.z.any(),
323
+ column: import_schema19.z.any()
322
324
  })
323
325
  );
324
326
 
325
327
  // src/prop-types/link.ts
326
- var import_schema21 = require("@elementor/schema");
328
+ var import_schema20 = require("@elementor/schema");
327
329
  var linkPropTypeUtil = createPropUtils(
328
330
  "link",
329
- import_schema21.z.strictObject({
331
+ import_schema20.z.strictObject({
330
332
  destination: unknownChildrenSchema,
331
333
  isTargetBlank: unknownChildrenSchema,
332
334
  tag: unknownChildrenSchema
333
335
  })
334
336
  );
335
337
 
338
+ // src/prop-types/email.ts
339
+ var import_schema21 = require("@elementor/schema");
340
+ var emailPropTypeUtil = createPropUtils(
341
+ "email",
342
+ import_schema21.z.strictObject({
343
+ to: unknownChildrenSchema,
344
+ subject: unknownChildrenSchema,
345
+ message: unknownChildrenSchema,
346
+ from: unknownChildrenSchema,
347
+ "meta-data": unknownChildrenSchema,
348
+ "send-as": unknownChildrenSchema,
349
+ "from-name": unknownChildrenSchema,
350
+ "reply-to": unknownChildrenSchema,
351
+ cc: unknownChildrenSchema,
352
+ bcc: unknownChildrenSchema
353
+ })
354
+ );
355
+
336
356
  // src/prop-types/selection-size.ts
337
357
  var import_schema23 = require("@elementor/schema");
338
358
 
@@ -452,14 +472,30 @@ var queryPropTypeUtil = createPropUtils(
452
472
  var import_schema32 = require("@elementor/schema");
453
473
  var htmlPropTypeUtil = createPropUtils("html", import_schema32.z.string().nullable());
454
474
 
475
+ // src/prop-types/html-v2.ts
476
+ var import_schema33 = require("@elementor/schema");
477
+ var childElementSchema = import_schema33.z.lazy(
478
+ () => import_schema33.z.object({
479
+ id: import_schema33.z.string(),
480
+ type: import_schema33.z.string(),
481
+ content: import_schema33.z.string().optional(),
482
+ children: import_schema33.z.array(childElementSchema).optional()
483
+ })
484
+ );
485
+ var htmlV2ValueSchema = import_schema33.z.object({
486
+ content: import_schema33.z.string().nullable(),
487
+ children: import_schema33.z.array(childElementSchema)
488
+ });
489
+ var htmlV2PropTypeUtil = createPropUtils("html-v2", htmlV2ValueSchema);
490
+
455
491
  // src/prop-types/filter-prop-types/filter.ts
456
- var import_schema38 = require("@elementor/schema");
492
+ var import_schema39 = require("@elementor/schema");
457
493
 
458
494
  // src/prop-types/filter-prop-types/drop-shadow-filter.ts
459
- var import_schema33 = require("@elementor/schema");
495
+ var import_schema34 = require("@elementor/schema");
460
496
  var dropShadowFilterPropTypeUtil = createPropUtils(
461
497
  "drop-shadow",
462
- import_schema33.z.object({
498
+ import_schema34.z.object({
463
499
  xAxis: unknownChildrenSchema,
464
500
  yAxis: unknownChildrenSchema,
465
501
  blur: unknownChildrenSchema,
@@ -468,37 +504,37 @@ var dropShadowFilterPropTypeUtil = createPropUtils(
468
504
  );
469
505
 
470
506
  // src/prop-types/filter-prop-types/filter-functions/blur-filter.ts
471
- var import_schema34 = require("@elementor/schema");
507
+ var import_schema35 = require("@elementor/schema");
472
508
  var blurFilterPropTypeUtil = createPropUtils(
473
509
  "blur",
474
- import_schema34.z.strictObject({
510
+ import_schema35.z.strictObject({
475
511
  size: unknownChildrenSchema
476
512
  })
477
513
  );
478
514
 
479
515
  // src/prop-types/filter-prop-types/filter-functions/color-tone-filter.ts
480
- var import_schema35 = require("@elementor/schema");
516
+ var import_schema36 = require("@elementor/schema");
481
517
  var colorToneFilterPropTypeUtil = createPropUtils(
482
518
  "color-tone",
483
- import_schema35.z.strictObject({
519
+ import_schema36.z.strictObject({
484
520
  size: unknownChildrenSchema
485
521
  })
486
522
  );
487
523
 
488
524
  // src/prop-types/filter-prop-types/filter-functions/hue-rotate-filter.ts
489
- var import_schema36 = require("@elementor/schema");
525
+ var import_schema37 = require("@elementor/schema");
490
526
  var hueRotateFilterPropTypeUtil = createPropUtils(
491
527
  "hue-rotate",
492
- import_schema36.z.strictObject({
528
+ import_schema37.z.strictObject({
493
529
  size: unknownChildrenSchema
494
530
  })
495
531
  );
496
532
 
497
533
  // src/prop-types/filter-prop-types/filter-functions/intensity-filter.ts
498
- var import_schema37 = require("@elementor/schema");
534
+ var import_schema38 = require("@elementor/schema");
499
535
  var intensityFilterPropTypeUtil = createPropUtils(
500
536
  "intensity",
501
- import_schema37.z.strictObject({
537
+ import_schema38.z.strictObject({
502
538
  size: unknownChildrenSchema
503
539
  })
504
540
  );
@@ -506,9 +542,9 @@ var intensityFilterPropTypeUtil = createPropUtils(
506
542
  // src/prop-types/filter-prop-types/filter.ts
507
543
  var cssFilterFunctionPropUtil = createPropUtils(
508
544
  "css-filter-func",
509
- import_schema38.z.object({
545
+ import_schema39.z.object({
510
546
  func: stringPropTypeUtil.schema,
511
- args: import_schema38.z.union([
547
+ args: import_schema39.z.union([
512
548
  blurFilterPropTypeUtil.schema,
513
549
  intensityFilterPropTypeUtil.schema,
514
550
  colorToneFilterPropTypeUtil.schema,
@@ -517,13 +553,13 @@ var cssFilterFunctionPropUtil = createPropUtils(
517
553
  ])
518
554
  })
519
555
  );
520
- var filterPropTypeUtil = createPropUtils("filter", import_schema38.z.array(cssFilterFunctionPropUtil.schema));
556
+ var filterPropTypeUtil = createPropUtils("filter", import_schema39.z.array(cssFilterFunctionPropUtil.schema));
521
557
 
522
558
  // src/prop-types/transform-prop-types/transform.ts
523
- var import_schema39 = require("@elementor/schema");
559
+ var import_schema40 = require("@elementor/schema");
524
560
  var transformPropTypeUtil = createPropUtils(
525
561
  "transform",
526
- import_schema39.z.strictObject({
562
+ import_schema40.z.strictObject({
527
563
  "transform-functions": unknownChildrenSchema,
528
564
  "transform-origin": unknownChildrenSchema,
529
565
  perspective: unknownChildrenSchema,
@@ -532,10 +568,10 @@ var transformPropTypeUtil = createPropUtils(
532
568
  );
533
569
 
534
570
  // src/prop-types/transform-prop-types/transform-functions.ts
535
- var import_schema44 = require("@elementor/schema");
571
+ var import_schema45 = require("@elementor/schema");
536
572
 
537
573
  // src/prop-types/transform-prop-types/transform-functions/move-transform.ts
538
- var import_schema40 = require("@elementor/schema");
574
+ var import_schema41 = require("@elementor/schema");
539
575
 
540
576
  // src/prop-types/transform-prop-types/types.ts
541
577
  var TransformFunctionKeys = {
@@ -548,7 +584,7 @@ var TransformFunctionKeys = {
548
584
  // src/prop-types/transform-prop-types/transform-functions/move-transform.ts
549
585
  var moveTransformPropTypeUtil = createPropUtils(
550
586
  TransformFunctionKeys.move,
551
- import_schema40.z.strictObject({
587
+ import_schema41.z.strictObject({
552
588
  x: unknownChildrenSchema,
553
589
  y: unknownChildrenSchema,
554
590
  z: unknownChildrenSchema
@@ -556,10 +592,10 @@ var moveTransformPropTypeUtil = createPropUtils(
556
592
  );
557
593
 
558
594
  // src/prop-types/transform-prop-types/transform-functions/rotate-transform.ts
559
- var import_schema41 = require("@elementor/schema");
595
+ var import_schema42 = require("@elementor/schema");
560
596
  var rotateTransformPropTypeUtil = createPropUtils(
561
597
  TransformFunctionKeys.rotate,
562
- import_schema41.z.strictObject({
598
+ import_schema42.z.strictObject({
563
599
  x: unknownChildrenSchema,
564
600
  y: unknownChildrenSchema,
565
601
  z: unknownChildrenSchema
@@ -567,10 +603,10 @@ var rotateTransformPropTypeUtil = createPropUtils(
567
603
  );
568
604
 
569
605
  // src/prop-types/transform-prop-types/transform-functions/scale-transform.ts
570
- var import_schema42 = require("@elementor/schema");
606
+ var import_schema43 = require("@elementor/schema");
571
607
  var scaleTransformPropTypeUtil = createPropUtils(
572
608
  TransformFunctionKeys.scale,
573
- import_schema42.z.strictObject({
609
+ import_schema43.z.strictObject({
574
610
  x: numberPropTypeUtil.schema.nullable(),
575
611
  y: numberPropTypeUtil.schema.nullable(),
576
612
  z: numberPropTypeUtil.schema.nullable()
@@ -578,10 +614,10 @@ var scaleTransformPropTypeUtil = createPropUtils(
578
614
  );
579
615
 
580
616
  // src/prop-types/transform-prop-types/transform-functions/skew-transform.ts
581
- var import_schema43 = require("@elementor/schema");
617
+ var import_schema44 = require("@elementor/schema");
582
618
  var skewTransformPropTypeUtil = createPropUtils(
583
619
  TransformFunctionKeys.skew,
584
- import_schema43.z.strictObject({
620
+ import_schema44.z.strictObject({
585
621
  x: unknownChildrenSchema,
586
622
  y: unknownChildrenSchema
587
623
  })
@@ -589,13 +625,13 @@ var skewTransformPropTypeUtil = createPropUtils(
589
625
 
590
626
  // src/prop-types/transform-prop-types/transform-functions.ts
591
627
  var filterTypes = moveTransformPropTypeUtil.schema.or(scaleTransformPropTypeUtil.schema).or(rotateTransformPropTypeUtil.schema).or(skewTransformPropTypeUtil.schema);
592
- var transformFunctionsPropTypeUtil = createPropUtils("transform-functions", import_schema44.z.array(filterTypes));
628
+ var transformFunctionsPropTypeUtil = createPropUtils("transform-functions", import_schema45.z.array(filterTypes));
593
629
 
594
630
  // src/prop-types/transform-prop-types/transform-origin.ts
595
- var import_schema45 = require("@elementor/schema");
631
+ var import_schema46 = require("@elementor/schema");
596
632
  var transformOriginPropTypeUtil = createPropUtils(
597
633
  "transform-origin",
598
- import_schema45.z.strictObject({
634
+ import_schema46.z.strictObject({
599
635
  x: unknownChildrenSchema,
600
636
  y: unknownChildrenSchema,
601
637
  z: unknownChildrenSchema
@@ -603,20 +639,20 @@ var transformOriginPropTypeUtil = createPropUtils(
603
639
  );
604
640
 
605
641
  // src/prop-types/transform-prop-types/perspective-origin.ts
606
- var import_schema46 = require("@elementor/schema");
642
+ var import_schema47 = require("@elementor/schema");
607
643
  var perspectiveOriginPropTypeUtil = createPropUtils(
608
644
  "perspective-origin",
609
- import_schema46.z.strictObject({
645
+ import_schema47.z.strictObject({
610
646
  x: unknownChildrenSchema,
611
647
  y: unknownChildrenSchema
612
648
  })
613
649
  );
614
650
 
615
651
  // src/prop-types/filter-prop-types/backdrop-filter.ts
616
- var import_schema47 = require("@elementor/schema");
652
+ var import_schema48 = require("@elementor/schema");
617
653
  var backdropFilterPropTypeUtil = createPropUtils(
618
654
  "backdrop-filter",
619
- import_schema47.z.array(cssFilterFunctionPropUtil.schema)
655
+ import_schema48.z.array(cssFilterFunctionPropUtil.schema)
620
656
  );
621
657
 
622
658
  // src/utils/adjust-llm-prop-value-schema.ts
@@ -1031,11 +1067,11 @@ var validatePropValue = (schema, value) => {
1031
1067
  };
1032
1068
 
1033
1069
  // src/utils/is-transformable.ts
1034
- var import_schema48 = require("@elementor/schema");
1035
- var transformableSchema = import_schema48.z.object({
1036
- $$type: import_schema48.z.string(),
1037
- value: import_schema48.z.any(),
1038
- disabled: import_schema48.z.boolean().optional()
1070
+ var import_schema49 = require("@elementor/schema");
1071
+ var transformableSchema = import_schema49.z.object({
1072
+ $$type: import_schema49.z.string(),
1073
+ value: import_schema49.z.any(),
1074
+ disabled: import_schema49.z.boolean().optional()
1039
1075
  });
1040
1076
  var isTransformable = (value) => {
1041
1077
  return transformableSchema.safeParse(value).success;
@@ -1131,7 +1167,8 @@ function evaluateTerm(term, actualValue) {
1131
1167
  if (("string" !== typeof actualValue || "string" !== typeof valueToCompare) && !Array.isArray(actualValue)) {
1132
1168
  return false;
1133
1169
  }
1134
- return "contains" === operator === actualValue.includes(valueToCompare);
1170
+ const transformedValue = Array.isArray(actualValue) ? actualValue.map((item) => isTransformable(item) ? item.value : item) : actualValue;
1171
+ return "contains" === operator === transformedValue.includes(valueToCompare);
1135
1172
  case "exists":
1136
1173
  case "not_exist":
1137
1174
  const evaluation = !!actualValue || 0 === actualValue || false === actualValue;
@@ -1174,6 +1211,61 @@ function isDependency(term) {
1174
1211
  return "terms" in term;
1175
1212
  }
1176
1213
 
1214
+ // src/utils/parse-html-children.ts
1215
+ var INLINE_ELEMENTS = /* @__PURE__ */ new Set(["span", "b", "strong", "i", "em", "u", "a", "del", "sup", "sub", "s"]);
1216
+ function generateElementId() {
1217
+ const timestamp = Date.now().toString(36);
1218
+ const randomPart = Math.random().toString(36).substring(2, 9);
1219
+ return `e-${timestamp}-${randomPart}`;
1220
+ }
1221
+ function traverseChildren(node) {
1222
+ const result = [];
1223
+ for (const child of Array.from(node.children)) {
1224
+ const tagName = child.tagName.toLowerCase();
1225
+ if (!INLINE_ELEMENTS.has(tagName)) {
1226
+ result.push(...traverseChildren(child));
1227
+ continue;
1228
+ }
1229
+ let id = child.getAttribute("id");
1230
+ if (!id) {
1231
+ id = generateElementId();
1232
+ child.setAttribute("id", id);
1233
+ }
1234
+ const childElement = {
1235
+ id,
1236
+ type: tagName
1237
+ };
1238
+ const textContent = child.textContent?.trim();
1239
+ if (textContent) {
1240
+ childElement.content = textContent;
1241
+ }
1242
+ const nestedChildren = traverseChildren(child);
1243
+ if (nestedChildren.length > 0) {
1244
+ childElement.children = nestedChildren;
1245
+ }
1246
+ result.push(childElement);
1247
+ }
1248
+ return result;
1249
+ }
1250
+ function parseHtmlChildren(html) {
1251
+ if (!html) {
1252
+ return { content: html, children: [] };
1253
+ }
1254
+ const parser = new DOMParser();
1255
+ const doc = parser.parseFromString(`<body>${html}</body>`, "text/html");
1256
+ const parserError = doc.querySelector("parsererror");
1257
+ if (parserError) {
1258
+ console.warn("HTML parsing error, returning original content:", parserError.textContent);
1259
+ return { content: html, children: [] };
1260
+ }
1261
+ const body = doc.body;
1262
+ const children = traverseChildren(body);
1263
+ return {
1264
+ content: body.innerHTML,
1265
+ children
1266
+ };
1267
+ }
1268
+
1177
1269
  // src/index.ts
1178
1270
  var Schema = {
1179
1271
  jsonSchemaToPropType,
@@ -1214,6 +1306,7 @@ var Schema = {
1214
1306
  cssFilterFunctionPropUtil,
1215
1307
  dimensionsPropTypeUtil,
1216
1308
  dropShadowFilterPropTypeUtil,
1309
+ emailPropTypeUtil,
1217
1310
  evaluateTerm,
1218
1311
  extractValue,
1219
1312
  filterEmptyValues,
@@ -1222,6 +1315,7 @@ var Schema = {
1222
1315
  getPropSchemaFromCache,
1223
1316
  gradientColorStopPropTypeUtil,
1224
1317
  htmlPropTypeUtil,
1318
+ htmlV2PropTypeUtil,
1225
1319
  hueRotateFilterPropTypeUtil,
1226
1320
  imageAttachmentIdPropType,
1227
1321
  imagePropTypeUtil,
@@ -1237,6 +1331,7 @@ var Schema = {
1237
1331
  mergeProps,
1238
1332
  moveTransformPropTypeUtil,
1239
1333
  numberPropTypeUtil,
1334
+ parseHtmlChildren,
1240
1335
  perspectiveOriginPropTypeUtil,
1241
1336
  positionPropTypeUtil,
1242
1337
  queryPropTypeUtil,