@elementor/editor-props 4.0.0-552 → 4.0.0-564
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.d.mts +155 -24
- package/dist/index.d.ts +155 -24
- package/dist/index.js +108 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/prop-types/html-v2.ts +30 -0
- package/src/prop-types/index.ts +1 -0
- package/src/prop-types/string-array.ts +4 -3
- package/src/utils/parse-html-children.ts +82 -0
package/dist/index.mjs
CHANGED
|
@@ -205,38 +205,37 @@ import { z as z16 } from "@elementor/schema";
|
|
|
205
205
|
var stringPropTypeUtil = createPropUtils("string", z16.string().nullable());
|
|
206
206
|
|
|
207
207
|
// src/prop-types/string-array.ts
|
|
208
|
-
|
|
209
|
-
var stringArrayPropTypeUtil = createPropUtils("string-array", z17.array(z17.string()));
|
|
208
|
+
var stringArrayPropTypeUtil = createArrayPropUtils(stringPropTypeUtil.key, stringPropTypeUtil.schema);
|
|
210
209
|
|
|
211
210
|
// src/prop-types/stroke.ts
|
|
212
|
-
import { z as
|
|
211
|
+
import { z as z17 } from "@elementor/schema";
|
|
213
212
|
var strokePropTypeUtil = createPropUtils(
|
|
214
213
|
"stroke",
|
|
215
|
-
|
|
214
|
+
z17.strictObject({
|
|
216
215
|
color: unknownChildrenSchema,
|
|
217
216
|
width: unknownChildrenSchema
|
|
218
217
|
})
|
|
219
218
|
);
|
|
220
219
|
|
|
221
220
|
// src/prop-types/url.ts
|
|
222
|
-
import { z as
|
|
223
|
-
var urlPropTypeUtil = createPropUtils("url",
|
|
221
|
+
import { z as z18 } from "@elementor/schema";
|
|
222
|
+
var urlPropTypeUtil = createPropUtils("url", z18.string().nullable());
|
|
224
223
|
|
|
225
224
|
// src/prop-types/layout-direction.ts
|
|
226
|
-
import { z as
|
|
225
|
+
import { z as z19 } from "@elementor/schema";
|
|
227
226
|
var layoutDirectionPropTypeUtil = createPropUtils(
|
|
228
227
|
"layout-direction",
|
|
229
|
-
|
|
230
|
-
row:
|
|
231
|
-
column:
|
|
228
|
+
z19.object({
|
|
229
|
+
row: z19.any(),
|
|
230
|
+
column: z19.any()
|
|
232
231
|
})
|
|
233
232
|
);
|
|
234
233
|
|
|
235
234
|
// src/prop-types/link.ts
|
|
236
|
-
import { z as
|
|
235
|
+
import { z as z20 } from "@elementor/schema";
|
|
237
236
|
var linkPropTypeUtil = createPropUtils(
|
|
238
237
|
"link",
|
|
239
|
-
|
|
238
|
+
z20.strictObject({
|
|
240
239
|
destination: unknownChildrenSchema,
|
|
241
240
|
isTargetBlank: unknownChildrenSchema,
|
|
242
241
|
tag: unknownChildrenSchema
|
|
@@ -244,13 +243,13 @@ var linkPropTypeUtil = createPropUtils(
|
|
|
244
243
|
);
|
|
245
244
|
|
|
246
245
|
// src/prop-types/selection-size.ts
|
|
247
|
-
import { z as
|
|
246
|
+
import { z as z22 } from "@elementor/schema";
|
|
248
247
|
|
|
249
248
|
// src/prop-types/key-value.ts
|
|
250
|
-
import { z as
|
|
249
|
+
import { z as z21 } from "@elementor/schema";
|
|
251
250
|
var keyValuePropTypeUtil = createPropUtils(
|
|
252
251
|
"key-value",
|
|
253
|
-
|
|
252
|
+
z21.strictObject({
|
|
254
253
|
key: unknownChildrenSchema,
|
|
255
254
|
value: unknownChildrenSchema
|
|
256
255
|
})
|
|
@@ -259,17 +258,17 @@ var keyValuePropTypeUtil = createPropUtils(
|
|
|
259
258
|
// src/prop-types/selection-size.ts
|
|
260
259
|
var selectionSizePropTypeUtil = createPropUtils(
|
|
261
260
|
"selection-size",
|
|
262
|
-
|
|
263
|
-
selection:
|
|
261
|
+
z22.strictObject({
|
|
262
|
+
selection: z22.union([keyValuePropTypeUtil.schema, stringPropTypeUtil.schema]),
|
|
264
263
|
size: unknownChildrenSchema
|
|
265
264
|
})
|
|
266
265
|
);
|
|
267
266
|
|
|
268
267
|
// src/prop-types/background-prop-types/background.ts
|
|
269
|
-
import { z as
|
|
268
|
+
import { z as z23 } from "@elementor/schema";
|
|
270
269
|
var backgroundPropTypeUtil = createPropUtils(
|
|
271
270
|
"background",
|
|
272
|
-
|
|
271
|
+
z23.strictObject({
|
|
273
272
|
color: unknownChildrenSchema,
|
|
274
273
|
clip: unknownChildrenSchema,
|
|
275
274
|
"background-overlay": unknownChildrenSchema
|
|
@@ -277,7 +276,7 @@ var backgroundPropTypeUtil = createPropUtils(
|
|
|
277
276
|
);
|
|
278
277
|
|
|
279
278
|
// src/prop-types/background-prop-types/background-overlay.ts
|
|
280
|
-
import { z as
|
|
279
|
+
import { z as z24 } from "@elementor/schema";
|
|
281
280
|
|
|
282
281
|
// src/prop-types/background-prop-types/background-color-overlay.ts
|
|
283
282
|
var backgroundColorOverlayPropTypeUtil = createPropUtils("background-color-overlay", unknownChildrenSchema);
|
|
@@ -293,7 +292,7 @@ var backgroundImageOverlayPropTypeUtil = createPropUtils("background-image-overl
|
|
|
293
292
|
|
|
294
293
|
// src/prop-types/background-prop-types/background-overlay.ts
|
|
295
294
|
var backgroundOverlayItem = backgroundColorOverlayPropTypeUtil.schema.or(backgroundGradientOverlayPropTypeUtil.schema).or(backgroundImageOverlayPropTypeUtil.schema);
|
|
296
|
-
var backgroundOverlayPropTypeUtil = createPropUtils("background-overlay",
|
|
295
|
+
var backgroundOverlayPropTypeUtil = createPropUtils("background-overlay", z24.array(backgroundOverlayItem));
|
|
297
296
|
|
|
298
297
|
// src/prop-types/background-prop-types/background-image-position-offset.ts
|
|
299
298
|
var backgroundImagePositionOffsetPropTypeUtil = createPropUtils(
|
|
@@ -308,59 +307,75 @@ var backgroundImageSizeScalePropTypeUtil = createPropUtils(
|
|
|
308
307
|
);
|
|
309
308
|
|
|
310
309
|
// src/prop-types/boolean.ts
|
|
311
|
-
import { z as
|
|
312
|
-
var booleanPropTypeUtil = createPropUtils("boolean",
|
|
310
|
+
import { z as z25 } from "@elementor/schema";
|
|
311
|
+
var booleanPropTypeUtil = createPropUtils("boolean", z25.boolean().nullable());
|
|
313
312
|
|
|
314
313
|
// src/prop-types/color-stop.ts
|
|
315
|
-
import { z as
|
|
314
|
+
import { z as z26 } from "@elementor/schema";
|
|
316
315
|
var colorStopPropTypeUtil = createPropUtils(
|
|
317
316
|
"color-stop",
|
|
318
|
-
|
|
317
|
+
z26.strictObject({
|
|
319
318
|
color: unknownChildrenSchema,
|
|
320
319
|
offset: unknownChildrenSchema
|
|
321
320
|
})
|
|
322
321
|
);
|
|
323
322
|
|
|
324
323
|
// src/prop-types/gradient-color-stop.ts
|
|
325
|
-
import { z as
|
|
324
|
+
import { z as z27 } from "@elementor/schema";
|
|
326
325
|
var gradientColorStopPropTypeUtil = createPropUtils(
|
|
327
326
|
"gradient-color-stop",
|
|
328
|
-
|
|
327
|
+
z27.array(colorStopPropTypeUtil.schema)
|
|
329
328
|
);
|
|
330
329
|
|
|
331
330
|
// src/prop-types/date-time.ts
|
|
332
|
-
import { z as
|
|
331
|
+
import { z as z28 } from "@elementor/schema";
|
|
333
332
|
var DateTimePropTypeUtil = createPropUtils(
|
|
334
333
|
"date-time",
|
|
335
|
-
|
|
334
|
+
z28.strictObject({
|
|
336
335
|
date: unknownChildrenSchema,
|
|
337
336
|
time: unknownChildrenSchema
|
|
338
337
|
})
|
|
339
338
|
);
|
|
340
339
|
|
|
341
340
|
// src/prop-types/position.ts
|
|
342
|
-
import { z as
|
|
341
|
+
import { z as z29 } from "@elementor/schema";
|
|
343
342
|
var positionPropTypeUtil = createPropUtils(
|
|
344
343
|
"object-position",
|
|
345
|
-
|
|
344
|
+
z29.strictObject({
|
|
346
345
|
x: unknownChildrenSchema,
|
|
347
346
|
y: unknownChildrenSchema
|
|
348
347
|
})
|
|
349
348
|
);
|
|
350
349
|
|
|
351
350
|
// src/prop-types/query.ts
|
|
352
|
-
import { z as
|
|
351
|
+
import { z as z30 } from "@elementor/schema";
|
|
353
352
|
var queryPropTypeUtil = createPropUtils(
|
|
354
353
|
"query",
|
|
355
|
-
|
|
354
|
+
z30.strictObject({
|
|
356
355
|
id: unknownChildrenSchema,
|
|
357
356
|
label: unknownChildrenSchema
|
|
358
357
|
})
|
|
359
358
|
);
|
|
360
359
|
|
|
361
360
|
// src/prop-types/html.ts
|
|
361
|
+
import { z as z31 } from "@elementor/schema";
|
|
362
|
+
var htmlPropTypeUtil = createPropUtils("html", z31.string().nullable());
|
|
363
|
+
|
|
364
|
+
// src/prop-types/html-v2.ts
|
|
362
365
|
import { z as z32 } from "@elementor/schema";
|
|
363
|
-
var
|
|
366
|
+
var childElementSchema = z32.lazy(
|
|
367
|
+
() => z32.object({
|
|
368
|
+
id: z32.string(),
|
|
369
|
+
type: z32.string(),
|
|
370
|
+
content: z32.string().optional(),
|
|
371
|
+
children: z32.array(childElementSchema).optional()
|
|
372
|
+
})
|
|
373
|
+
);
|
|
374
|
+
var htmlV2ValueSchema = z32.object({
|
|
375
|
+
content: z32.string().nullable(),
|
|
376
|
+
children: z32.array(childElementSchema)
|
|
377
|
+
});
|
|
378
|
+
var htmlV2PropTypeUtil = createPropUtils("html-v2", htmlV2ValueSchema);
|
|
364
379
|
|
|
365
380
|
// src/prop-types/filter-prop-types/filter.ts
|
|
366
381
|
import { z as z38 } from "@elementor/schema";
|
|
@@ -1084,6 +1099,61 @@ function isDependency(term) {
|
|
|
1084
1099
|
return "terms" in term;
|
|
1085
1100
|
}
|
|
1086
1101
|
|
|
1102
|
+
// src/utils/parse-html-children.ts
|
|
1103
|
+
var INLINE_ELEMENTS = /* @__PURE__ */ new Set(["span", "b", "strong", "i", "em", "u", "a", "del", "sup", "sub", "s"]);
|
|
1104
|
+
function generateElementId() {
|
|
1105
|
+
const timestamp = Date.now().toString(36);
|
|
1106
|
+
const randomPart = Math.random().toString(36).substring(2, 9);
|
|
1107
|
+
return `e-${timestamp}-${randomPart}`;
|
|
1108
|
+
}
|
|
1109
|
+
function traverseChildren(node) {
|
|
1110
|
+
const result = [];
|
|
1111
|
+
for (const child of Array.from(node.children)) {
|
|
1112
|
+
const tagName = child.tagName.toLowerCase();
|
|
1113
|
+
if (!INLINE_ELEMENTS.has(tagName)) {
|
|
1114
|
+
result.push(...traverseChildren(child));
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
let id = child.getAttribute("id");
|
|
1118
|
+
if (!id) {
|
|
1119
|
+
id = generateElementId();
|
|
1120
|
+
child.setAttribute("id", id);
|
|
1121
|
+
}
|
|
1122
|
+
const childElement = {
|
|
1123
|
+
id,
|
|
1124
|
+
type: tagName
|
|
1125
|
+
};
|
|
1126
|
+
const textContent = child.textContent?.trim();
|
|
1127
|
+
if (textContent) {
|
|
1128
|
+
childElement.content = textContent;
|
|
1129
|
+
}
|
|
1130
|
+
const nestedChildren = traverseChildren(child);
|
|
1131
|
+
if (nestedChildren.length > 0) {
|
|
1132
|
+
childElement.children = nestedChildren;
|
|
1133
|
+
}
|
|
1134
|
+
result.push(childElement);
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1137
|
+
}
|
|
1138
|
+
function parseHtmlChildren(html) {
|
|
1139
|
+
if (!html) {
|
|
1140
|
+
return { content: html, children: [] };
|
|
1141
|
+
}
|
|
1142
|
+
const parser = new DOMParser();
|
|
1143
|
+
const doc = parser.parseFromString(`<body>${html}</body>`, "text/html");
|
|
1144
|
+
const parserError = doc.querySelector("parsererror");
|
|
1145
|
+
if (parserError) {
|
|
1146
|
+
console.warn("HTML parsing error, returning original content:", parserError.textContent);
|
|
1147
|
+
return { content: html, children: [] };
|
|
1148
|
+
}
|
|
1149
|
+
const body = doc.body;
|
|
1150
|
+
const children = traverseChildren(body);
|
|
1151
|
+
return {
|
|
1152
|
+
content: body.innerHTML,
|
|
1153
|
+
children
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1087
1157
|
// src/index.ts
|
|
1088
1158
|
var Schema = {
|
|
1089
1159
|
jsonSchemaToPropType,
|
|
@@ -1131,6 +1201,7 @@ export {
|
|
|
1131
1201
|
getPropSchemaFromCache,
|
|
1132
1202
|
gradientColorStopPropTypeUtil,
|
|
1133
1203
|
htmlPropTypeUtil,
|
|
1204
|
+
htmlV2PropTypeUtil,
|
|
1134
1205
|
hueRotateFilterPropTypeUtil,
|
|
1135
1206
|
imageAttachmentIdPropType,
|
|
1136
1207
|
imagePropTypeUtil,
|
|
@@ -1146,6 +1217,7 @@ export {
|
|
|
1146
1217
|
mergeProps,
|
|
1147
1218
|
moveTransformPropTypeUtil,
|
|
1148
1219
|
numberPropTypeUtil,
|
|
1220
|
+
parseHtmlChildren,
|
|
1149
1221
|
perspectiveOriginPropTypeUtil,
|
|
1150
1222
|
positionPropTypeUtil,
|
|
1151
1223
|
queryPropTypeUtil,
|