@polotno/schema 0.6.2 → 0.8.0
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/lib/asset-urls.d.ts +3 -0
- package/lib/asset-urls.js +28 -0
- package/lib/defaults.d.ts +2 -0
- package/lib/defaults.js +20 -0
- package/lib/design.schema.json +256 -10
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/schema.d.ts +148 -2
- package/lib/schema.js +62 -37
- package/lib/types.d.ts +9 -0
- package/package.json +6 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Asset fields belong to the design format. Keep this walk zod-free so Node
|
|
2
|
+
// renderers and fixture loaders can share it without importing validation.
|
|
3
|
+
// `custom` is arbitrary caller data; its strings must never be rewritten.
|
|
4
|
+
export const URL_FIELDS = ['src', 'clipSrc', 'maskSrc', 'background', 'url'];
|
|
5
|
+
const URL_FIELD_SET = new Set(URL_FIELDS);
|
|
6
|
+
/** Visit each asset string in place, including nested groups and font styles. */
|
|
7
|
+
export function forEveryUrlField(node, visit) {
|
|
8
|
+
if (!node || typeof node !== 'object')
|
|
9
|
+
return;
|
|
10
|
+
if (Array.isArray(node)) {
|
|
11
|
+
for (const item of node)
|
|
12
|
+
forEveryUrlField(item, visit);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const record = node;
|
|
16
|
+
for (const key of Object.keys(record)) {
|
|
17
|
+
if (key === 'custom')
|
|
18
|
+
continue;
|
|
19
|
+
const value = record[key];
|
|
20
|
+
if (typeof value === 'string') {
|
|
21
|
+
if (URL_FIELD_SET.has(key))
|
|
22
|
+
visit(record, key, value);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
forEveryUrlField(value, visit);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/lib/defaults.d.ts
CHANGED
|
@@ -79,3 +79,5 @@ export declare const MIN_FONT_SIZE = 1;
|
|
|
79
79
|
* the table", which is not a size to clamp.
|
|
80
80
|
*/
|
|
81
81
|
export declare const clampFontSize: <T extends number | undefined>(size: T) => T;
|
|
82
|
+
export declare const BLEND_MODES: readonly ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
|
|
83
|
+
export declare const GROUP_BLEND_MODES: readonly ["pass-through", "normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
|
package/lib/defaults.js
CHANGED
|
@@ -127,3 +127,23 @@ export const MIN_FONT_SIZE = 1;
|
|
|
127
127
|
* the table", which is not a size to clamp.
|
|
128
128
|
*/
|
|
129
129
|
export const clampFontSize = (size) => (size != null && size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size);
|
|
130
|
+
export const BLEND_MODES = [
|
|
131
|
+
'normal',
|
|
132
|
+
'multiply',
|
|
133
|
+
'screen',
|
|
134
|
+
'overlay',
|
|
135
|
+
'darken',
|
|
136
|
+
'lighten',
|
|
137
|
+
'color-dodge',
|
|
138
|
+
'color-burn',
|
|
139
|
+
'hard-light',
|
|
140
|
+
'soft-light',
|
|
141
|
+
'difference',
|
|
142
|
+
'exclusion',
|
|
143
|
+
'hue',
|
|
144
|
+
'saturation',
|
|
145
|
+
'color',
|
|
146
|
+
'luminosity',
|
|
147
|
+
];
|
|
148
|
+
// A group's default: its children blend through it. Any other mode isolates it.
|
|
149
|
+
export const GROUP_BLEND_MODES = ['pass-through', ...BLEND_MODES];
|
package/lib/design.schema.json
CHANGED
|
@@ -235,7 +235,8 @@
|
|
|
235
235
|
},
|
|
236
236
|
"type": {
|
|
237
237
|
"type": "string",
|
|
238
|
-
"const": "text"
|
|
238
|
+
"const": "text",
|
|
239
|
+
"description": "Element type identifier."
|
|
239
240
|
},
|
|
240
241
|
"name": {
|
|
241
242
|
"default": "",
|
|
@@ -275,6 +276,28 @@
|
|
|
275
276
|
"description": "Opacity level (0-1).",
|
|
276
277
|
"type": "number"
|
|
277
278
|
},
|
|
279
|
+
"blendMode": {
|
|
280
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
281
|
+
"type": "string",
|
|
282
|
+
"enum": [
|
|
283
|
+
"normal",
|
|
284
|
+
"multiply",
|
|
285
|
+
"screen",
|
|
286
|
+
"overlay",
|
|
287
|
+
"darken",
|
|
288
|
+
"lighten",
|
|
289
|
+
"color-dodge",
|
|
290
|
+
"color-burn",
|
|
291
|
+
"hard-light",
|
|
292
|
+
"soft-light",
|
|
293
|
+
"difference",
|
|
294
|
+
"exclusion",
|
|
295
|
+
"hue",
|
|
296
|
+
"saturation",
|
|
297
|
+
"color",
|
|
298
|
+
"luminosity"
|
|
299
|
+
]
|
|
300
|
+
},
|
|
278
301
|
"animations": {
|
|
279
302
|
"default": [],
|
|
280
303
|
"description": "Animation configurations.",
|
|
@@ -552,6 +575,16 @@
|
|
|
552
575
|
"description": "Text background padding.",
|
|
553
576
|
"type": "number"
|
|
554
577
|
},
|
|
578
|
+
"borderColor": {
|
|
579
|
+
"default": "black",
|
|
580
|
+
"description": "Text box border color.",
|
|
581
|
+
"type": "string"
|
|
582
|
+
},
|
|
583
|
+
"borderSize": {
|
|
584
|
+
"default": 0,
|
|
585
|
+
"description": "Text box border width in pixels.",
|
|
586
|
+
"type": "number"
|
|
587
|
+
},
|
|
555
588
|
"curveEnabled": {
|
|
556
589
|
"default": false,
|
|
557
590
|
"description": "Whether the text curve effect is enabled.",
|
|
@@ -581,7 +614,8 @@
|
|
|
581
614
|
},
|
|
582
615
|
"type": {
|
|
583
616
|
"type": "string",
|
|
584
|
-
"const": "image"
|
|
617
|
+
"const": "image",
|
|
618
|
+
"description": "Element type identifier."
|
|
585
619
|
},
|
|
586
620
|
"name": {
|
|
587
621
|
"default": "",
|
|
@@ -621,6 +655,28 @@
|
|
|
621
655
|
"description": "Opacity level (0-1).",
|
|
622
656
|
"type": "number"
|
|
623
657
|
},
|
|
658
|
+
"blendMode": {
|
|
659
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
660
|
+
"type": "string",
|
|
661
|
+
"enum": [
|
|
662
|
+
"normal",
|
|
663
|
+
"multiply",
|
|
664
|
+
"screen",
|
|
665
|
+
"overlay",
|
|
666
|
+
"darken",
|
|
667
|
+
"lighten",
|
|
668
|
+
"color-dodge",
|
|
669
|
+
"color-burn",
|
|
670
|
+
"hard-light",
|
|
671
|
+
"soft-light",
|
|
672
|
+
"difference",
|
|
673
|
+
"exclusion",
|
|
674
|
+
"hue",
|
|
675
|
+
"saturation",
|
|
676
|
+
"color",
|
|
677
|
+
"luminosity"
|
|
678
|
+
]
|
|
679
|
+
},
|
|
624
680
|
"animations": {
|
|
625
681
|
"default": [],
|
|
626
682
|
"description": "Animation configurations.",
|
|
@@ -870,7 +926,8 @@
|
|
|
870
926
|
},
|
|
871
927
|
"type": {
|
|
872
928
|
"type": "string",
|
|
873
|
-
"const": "svg"
|
|
929
|
+
"const": "svg",
|
|
930
|
+
"description": "Element type identifier."
|
|
874
931
|
},
|
|
875
932
|
"name": {
|
|
876
933
|
"default": "",
|
|
@@ -892,10 +949,12 @@
|
|
|
892
949
|
},
|
|
893
950
|
"width": {
|
|
894
951
|
"default": 100,
|
|
952
|
+
"description": "Width in pixels.",
|
|
895
953
|
"type": "number"
|
|
896
954
|
},
|
|
897
955
|
"height": {
|
|
898
956
|
"default": 100,
|
|
957
|
+
"description": "Height in pixels.",
|
|
899
958
|
"type": "number"
|
|
900
959
|
},
|
|
901
960
|
"rotation": {
|
|
@@ -908,6 +967,28 @@
|
|
|
908
967
|
"description": "Opacity level (0-1).",
|
|
909
968
|
"type": "number"
|
|
910
969
|
},
|
|
970
|
+
"blendMode": {
|
|
971
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
972
|
+
"type": "string",
|
|
973
|
+
"enum": [
|
|
974
|
+
"normal",
|
|
975
|
+
"multiply",
|
|
976
|
+
"screen",
|
|
977
|
+
"overlay",
|
|
978
|
+
"darken",
|
|
979
|
+
"lighten",
|
|
980
|
+
"color-dodge",
|
|
981
|
+
"color-burn",
|
|
982
|
+
"hard-light",
|
|
983
|
+
"soft-light",
|
|
984
|
+
"difference",
|
|
985
|
+
"exclusion",
|
|
986
|
+
"hue",
|
|
987
|
+
"saturation",
|
|
988
|
+
"color",
|
|
989
|
+
"luminosity"
|
|
990
|
+
]
|
|
991
|
+
},
|
|
911
992
|
"animations": {
|
|
912
993
|
"default": [],
|
|
913
994
|
"description": "Animation configurations.",
|
|
@@ -1089,18 +1170,22 @@
|
|
|
1089
1170
|
},
|
|
1090
1171
|
"cropX": {
|
|
1091
1172
|
"default": 0,
|
|
1173
|
+
"description": "Crop X offset as a fraction (0-1).",
|
|
1092
1174
|
"type": "number"
|
|
1093
1175
|
},
|
|
1094
1176
|
"cropY": {
|
|
1095
1177
|
"default": 0,
|
|
1178
|
+
"description": "Crop Y offset as a fraction (0-1).",
|
|
1096
1179
|
"type": "number"
|
|
1097
1180
|
},
|
|
1098
1181
|
"cropWidth": {
|
|
1099
1182
|
"default": 1,
|
|
1183
|
+
"description": "Crop width as a fraction (0-1).",
|
|
1100
1184
|
"type": "number"
|
|
1101
1185
|
},
|
|
1102
1186
|
"cropHeight": {
|
|
1103
1187
|
"default": 1,
|
|
1188
|
+
"description": "Crop height as a fraction (0-1).",
|
|
1104
1189
|
"type": "number"
|
|
1105
1190
|
},
|
|
1106
1191
|
"keepRatio": {
|
|
@@ -1110,26 +1195,32 @@
|
|
|
1110
1195
|
},
|
|
1111
1196
|
"stretchEnabled": {
|
|
1112
1197
|
"default": true,
|
|
1198
|
+
"description": "Whether stretch mode is enabled.",
|
|
1113
1199
|
"type": "boolean"
|
|
1114
1200
|
},
|
|
1115
1201
|
"flipX": {
|
|
1116
1202
|
"default": false,
|
|
1203
|
+
"description": "Whether the image is flipped horizontally.",
|
|
1117
1204
|
"type": "boolean"
|
|
1118
1205
|
},
|
|
1119
1206
|
"flipY": {
|
|
1120
1207
|
"default": false,
|
|
1208
|
+
"description": "Whether the image is flipped vertically.",
|
|
1121
1209
|
"type": "boolean"
|
|
1122
1210
|
},
|
|
1123
1211
|
"borderColor": {
|
|
1124
1212
|
"default": "black",
|
|
1213
|
+
"description": "Border color.",
|
|
1125
1214
|
"type": "string"
|
|
1126
1215
|
},
|
|
1127
1216
|
"borderSize": {
|
|
1128
1217
|
"default": 0,
|
|
1218
|
+
"description": "Border width in pixels.",
|
|
1129
1219
|
"type": "number"
|
|
1130
1220
|
},
|
|
1131
1221
|
"cornerRadius": {
|
|
1132
1222
|
"default": 0,
|
|
1223
|
+
"description": "Corner radius in pixels.",
|
|
1133
1224
|
"type": "number"
|
|
1134
1225
|
},
|
|
1135
1226
|
"colorsReplace": {
|
|
@@ -1158,7 +1249,8 @@
|
|
|
1158
1249
|
},
|
|
1159
1250
|
"type": {
|
|
1160
1251
|
"type": "string",
|
|
1161
|
-
"const": "line"
|
|
1252
|
+
"const": "line",
|
|
1253
|
+
"description": "Element type identifier."
|
|
1162
1254
|
},
|
|
1163
1255
|
"name": {
|
|
1164
1256
|
"default": "",
|
|
@@ -1180,10 +1272,12 @@
|
|
|
1180
1272
|
},
|
|
1181
1273
|
"width": {
|
|
1182
1274
|
"default": 400,
|
|
1275
|
+
"description": "Width in pixels.",
|
|
1183
1276
|
"type": "number"
|
|
1184
1277
|
},
|
|
1185
1278
|
"height": {
|
|
1186
1279
|
"default": 10,
|
|
1280
|
+
"description": "Height in pixels.",
|
|
1187
1281
|
"type": "number"
|
|
1188
1282
|
},
|
|
1189
1283
|
"rotation": {
|
|
@@ -1196,6 +1290,28 @@
|
|
|
1196
1290
|
"description": "Opacity level (0-1).",
|
|
1197
1291
|
"type": "number"
|
|
1198
1292
|
},
|
|
1293
|
+
"blendMode": {
|
|
1294
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
1295
|
+
"type": "string",
|
|
1296
|
+
"enum": [
|
|
1297
|
+
"normal",
|
|
1298
|
+
"multiply",
|
|
1299
|
+
"screen",
|
|
1300
|
+
"overlay",
|
|
1301
|
+
"darken",
|
|
1302
|
+
"lighten",
|
|
1303
|
+
"color-dodge",
|
|
1304
|
+
"color-burn",
|
|
1305
|
+
"hard-light",
|
|
1306
|
+
"soft-light",
|
|
1307
|
+
"difference",
|
|
1308
|
+
"exclusion",
|
|
1309
|
+
"hue",
|
|
1310
|
+
"saturation",
|
|
1311
|
+
"color",
|
|
1312
|
+
"luminosity"
|
|
1313
|
+
]
|
|
1314
|
+
},
|
|
1199
1315
|
"animations": {
|
|
1200
1316
|
"default": [],
|
|
1201
1317
|
"description": "Animation configurations.",
|
|
@@ -1403,7 +1519,8 @@
|
|
|
1403
1519
|
},
|
|
1404
1520
|
"type": {
|
|
1405
1521
|
"type": "string",
|
|
1406
|
-
"const": "figure"
|
|
1522
|
+
"const": "figure",
|
|
1523
|
+
"description": "Element type identifier."
|
|
1407
1524
|
},
|
|
1408
1525
|
"name": {
|
|
1409
1526
|
"default": "",
|
|
@@ -1443,6 +1560,28 @@
|
|
|
1443
1560
|
"description": "Opacity level (0-1).",
|
|
1444
1561
|
"type": "number"
|
|
1445
1562
|
},
|
|
1563
|
+
"blendMode": {
|
|
1564
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
1565
|
+
"type": "string",
|
|
1566
|
+
"enum": [
|
|
1567
|
+
"normal",
|
|
1568
|
+
"multiply",
|
|
1569
|
+
"screen",
|
|
1570
|
+
"overlay",
|
|
1571
|
+
"darken",
|
|
1572
|
+
"lighten",
|
|
1573
|
+
"color-dodge",
|
|
1574
|
+
"color-burn",
|
|
1575
|
+
"hard-light",
|
|
1576
|
+
"soft-light",
|
|
1577
|
+
"difference",
|
|
1578
|
+
"exclusion",
|
|
1579
|
+
"hue",
|
|
1580
|
+
"saturation",
|
|
1581
|
+
"color",
|
|
1582
|
+
"luminosity"
|
|
1583
|
+
]
|
|
1584
|
+
},
|
|
1446
1585
|
"animations": {
|
|
1447
1586
|
"default": [],
|
|
1448
1587
|
"description": "Animation configurations.",
|
|
@@ -1632,14 +1771,17 @@
|
|
|
1632
1771
|
},
|
|
1633
1772
|
"strokeWidth": {
|
|
1634
1773
|
"default": 0,
|
|
1774
|
+
"description": "Stroke width in pixels.",
|
|
1635
1775
|
"type": "number"
|
|
1636
1776
|
},
|
|
1637
1777
|
"stroke": {
|
|
1638
1778
|
"default": "rgba(98, 197, 255, 1)",
|
|
1779
|
+
"description": "Stroke color.",
|
|
1639
1780
|
"type": "string"
|
|
1640
1781
|
},
|
|
1641
1782
|
"cornerRadius": {
|
|
1642
1783
|
"default": 0,
|
|
1784
|
+
"description": "Corner radius in pixels.",
|
|
1643
1785
|
"type": "number"
|
|
1644
1786
|
}
|
|
1645
1787
|
},
|
|
@@ -1657,7 +1799,8 @@
|
|
|
1657
1799
|
},
|
|
1658
1800
|
"type": {
|
|
1659
1801
|
"type": "string",
|
|
1660
|
-
"const": "gif"
|
|
1802
|
+
"const": "gif",
|
|
1803
|
+
"description": "Element type identifier."
|
|
1661
1804
|
},
|
|
1662
1805
|
"name": {
|
|
1663
1806
|
"default": "",
|
|
@@ -1697,6 +1840,28 @@
|
|
|
1697
1840
|
"description": "Opacity level (0-1).",
|
|
1698
1841
|
"type": "number"
|
|
1699
1842
|
},
|
|
1843
|
+
"blendMode": {
|
|
1844
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
1845
|
+
"type": "string",
|
|
1846
|
+
"enum": [
|
|
1847
|
+
"normal",
|
|
1848
|
+
"multiply",
|
|
1849
|
+
"screen",
|
|
1850
|
+
"overlay",
|
|
1851
|
+
"darken",
|
|
1852
|
+
"lighten",
|
|
1853
|
+
"color-dodge",
|
|
1854
|
+
"color-burn",
|
|
1855
|
+
"hard-light",
|
|
1856
|
+
"soft-light",
|
|
1857
|
+
"difference",
|
|
1858
|
+
"exclusion",
|
|
1859
|
+
"hue",
|
|
1860
|
+
"saturation",
|
|
1861
|
+
"color",
|
|
1862
|
+
"luminosity"
|
|
1863
|
+
]
|
|
1864
|
+
},
|
|
1700
1865
|
"animations": {
|
|
1701
1866
|
"default": [],
|
|
1702
1867
|
"description": "Animation configurations.",
|
|
@@ -1923,6 +2088,7 @@
|
|
|
1923
2088
|
},
|
|
1924
2089
|
"keepRatio": {
|
|
1925
2090
|
"default": true,
|
|
2091
|
+
"description": "Whether to maintain aspect ratio when resizing.",
|
|
1926
2092
|
"type": "boolean"
|
|
1927
2093
|
},
|
|
1928
2094
|
"stretchEnabled": {
|
|
@@ -1950,7 +2116,8 @@
|
|
|
1950
2116
|
},
|
|
1951
2117
|
"type": {
|
|
1952
2118
|
"type": "string",
|
|
1953
|
-
"const": "video"
|
|
2119
|
+
"const": "video",
|
|
2120
|
+
"description": "Element type identifier."
|
|
1954
2121
|
},
|
|
1955
2122
|
"name": {
|
|
1956
2123
|
"default": "",
|
|
@@ -1990,6 +2157,28 @@
|
|
|
1990
2157
|
"description": "Opacity level (0-1).",
|
|
1991
2158
|
"type": "number"
|
|
1992
2159
|
},
|
|
2160
|
+
"blendMode": {
|
|
2161
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
2162
|
+
"type": "string",
|
|
2163
|
+
"enum": [
|
|
2164
|
+
"normal",
|
|
2165
|
+
"multiply",
|
|
2166
|
+
"screen",
|
|
2167
|
+
"overlay",
|
|
2168
|
+
"darken",
|
|
2169
|
+
"lighten",
|
|
2170
|
+
"color-dodge",
|
|
2171
|
+
"color-burn",
|
|
2172
|
+
"hard-light",
|
|
2173
|
+
"soft-light",
|
|
2174
|
+
"difference",
|
|
2175
|
+
"exclusion",
|
|
2176
|
+
"hue",
|
|
2177
|
+
"saturation",
|
|
2178
|
+
"color",
|
|
2179
|
+
"luminosity"
|
|
2180
|
+
]
|
|
2181
|
+
},
|
|
1993
2182
|
"animations": {
|
|
1994
2183
|
"default": [],
|
|
1995
2184
|
"description": "Animation configurations.",
|
|
@@ -2305,6 +2494,28 @@
|
|
|
2305
2494
|
"description": "Opacity level (0-1).",
|
|
2306
2495
|
"type": "number"
|
|
2307
2496
|
},
|
|
2497
|
+
"blendMode": {
|
|
2498
|
+
"description": "How the element composites with the content beneath it. Omitted means normal.",
|
|
2499
|
+
"type": "string",
|
|
2500
|
+
"enum": [
|
|
2501
|
+
"normal",
|
|
2502
|
+
"multiply",
|
|
2503
|
+
"screen",
|
|
2504
|
+
"overlay",
|
|
2505
|
+
"darken",
|
|
2506
|
+
"lighten",
|
|
2507
|
+
"color-dodge",
|
|
2508
|
+
"color-burn",
|
|
2509
|
+
"hard-light",
|
|
2510
|
+
"soft-light",
|
|
2511
|
+
"difference",
|
|
2512
|
+
"exclusion",
|
|
2513
|
+
"hue",
|
|
2514
|
+
"saturation",
|
|
2515
|
+
"color",
|
|
2516
|
+
"luminosity"
|
|
2517
|
+
]
|
|
2518
|
+
},
|
|
2308
2519
|
"animations": {
|
|
2309
2520
|
"default": [],
|
|
2310
2521
|
"description": "Animation configurations.",
|
|
@@ -2747,43 +2958,78 @@
|
|
|
2747
2958
|
"type": "object",
|
|
2748
2959
|
"properties": {
|
|
2749
2960
|
"id": {
|
|
2750
|
-
"type": "string"
|
|
2961
|
+
"type": "string",
|
|
2962
|
+
"description": "Unique identifier for the element."
|
|
2751
2963
|
},
|
|
2752
2964
|
"type": {
|
|
2753
2965
|
"type": "string",
|
|
2754
|
-
"const": "group"
|
|
2966
|
+
"const": "group",
|
|
2967
|
+
"description": "Element type identifier."
|
|
2755
2968
|
},
|
|
2756
2969
|
"name": {
|
|
2757
2970
|
"default": "",
|
|
2971
|
+
"description": "Display name for the element.",
|
|
2758
2972
|
"type": "string"
|
|
2759
2973
|
},
|
|
2760
|
-
"custom": {
|
|
2974
|
+
"custom": {
|
|
2975
|
+
"description": "Custom data attached to the element."
|
|
2976
|
+
},
|
|
2761
2977
|
"opacity": {
|
|
2762
2978
|
"default": 1,
|
|
2979
|
+
"description": "Opacity level (0-1).",
|
|
2763
2980
|
"type": "number"
|
|
2764
2981
|
},
|
|
2982
|
+
"blendMode": {
|
|
2983
|
+
"description": "How the group composites with the content beneath it. Omitted means pass-through: children blend with that content directly. Any other mode composites the children together first.",
|
|
2984
|
+
"type": "string",
|
|
2985
|
+
"enum": [
|
|
2986
|
+
"pass-through",
|
|
2987
|
+
"normal",
|
|
2988
|
+
"multiply",
|
|
2989
|
+
"screen",
|
|
2990
|
+
"overlay",
|
|
2991
|
+
"darken",
|
|
2992
|
+
"lighten",
|
|
2993
|
+
"color-dodge",
|
|
2994
|
+
"color-burn",
|
|
2995
|
+
"hard-light",
|
|
2996
|
+
"soft-light",
|
|
2997
|
+
"difference",
|
|
2998
|
+
"exclusion",
|
|
2999
|
+
"hue",
|
|
3000
|
+
"saturation",
|
|
3001
|
+
"color",
|
|
3002
|
+
"luminosity"
|
|
3003
|
+
]
|
|
3004
|
+
},
|
|
2765
3005
|
"visible": {
|
|
2766
3006
|
"default": true,
|
|
3007
|
+
"description": "Whether the element is visible.",
|
|
2767
3008
|
"type": "boolean"
|
|
2768
3009
|
},
|
|
2769
3010
|
"selectable": {
|
|
2770
3011
|
"default": true,
|
|
3012
|
+
"description": "Whether the element can be selected.",
|
|
2771
3013
|
"type": "boolean"
|
|
2772
3014
|
},
|
|
2773
3015
|
"removable": {
|
|
2774
3016
|
"default": true,
|
|
3017
|
+
"description": "Whether the element can be removed.",
|
|
2775
3018
|
"type": "boolean"
|
|
2776
3019
|
},
|
|
2777
3020
|
"alwaysOnTop": {
|
|
2778
3021
|
"default": false,
|
|
3022
|
+
"description": "Whether the element stays on top of others.",
|
|
2779
3023
|
"type": "boolean"
|
|
2780
3024
|
},
|
|
2781
3025
|
"showInExport": {
|
|
2782
3026
|
"default": true,
|
|
3027
|
+
"description": "Whether the element appears in exports.",
|
|
2783
3028
|
"type": "boolean"
|
|
2784
3029
|
},
|
|
2785
3030
|
"animations": {
|
|
2786
3031
|
"default": [],
|
|
3032
|
+
"description": "Animation configurations.",
|
|
2787
3033
|
"type": "array",
|
|
2788
3034
|
"items": {
|
|
2789
3035
|
"type": "object",
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export type { PolotnoError, PolotnoErrorCode } from './errors.js';
|
|
2
|
+
export { URL_FIELDS, forEveryUrlField } from './asset-urls.js';
|
|
2
3
|
export { normalizeDesign, parseDesign } from './normalize.js';
|
|
3
4
|
export type { ParseOptions } from './normalize.js';
|
|
4
5
|
export { migrateDesign } from './migrate.js';
|
|
5
6
|
export type { MigrateOptions } from './migrate.js';
|
|
6
7
|
export { resolveBleed, ZERO_BLEED } from './bleed.js';
|
|
7
8
|
export type { ResolvedBleed } from './bleed.js';
|
|
8
|
-
export { TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
9
|
+
export { BLEND_MODES, GROUP_BLEND_MODES, TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
9
10
|
export { validateDesign, assertValidDesign, designSchemaLenient, designSchemaCanonical, CURRENT_SCHEMA_VERSION, } from './schema.js';
|
|
10
11
|
export type { DesignInput, ValidationError, ValidationResult, ValidateOptions, } from './schema.js';
|
|
11
12
|
export type * from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Single source: the zod schema (`./schema`) provides validation, defaults, and
|
|
3
3
|
// the generated JSON Schema; `./types` are the hand-written public TypeScript
|
|
4
4
|
// types. zod is a regular dependency (normalize parses with it).
|
|
5
|
+
export { URL_FIELDS, forEveryUrlField } from './asset-urls.js';
|
|
5
6
|
export { normalizeDesign, parseDesign } from './normalize.js';
|
|
6
7
|
export { migrateDesign } from './migrate.js';
|
|
7
8
|
export { resolveBleed, ZERO_BLEED } from './bleed.js';
|
|
8
9
|
// Also available zod-free via the `@polotno/schema/defaults` subpath.
|
|
9
|
-
export { TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
10
|
+
export { BLEND_MODES, GROUP_BLEND_MODES, TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, tableCellBorderInsets, } from './defaults.js';
|
|
10
11
|
export { validateDesign, assertValidDesign, designSchemaLenient, designSchemaCanonical, CURRENT_SCHEMA_VERSION, } from './schema.js';
|
package/lib/schema.d.ts
CHANGED
|
@@ -142,6 +142,8 @@ export declare const leafSchemas: {
|
|
|
142
142
|
backgroundOpacity: z.ZodDefault<z.ZodNumber>;
|
|
143
143
|
backgroundCornerRadius: z.ZodDefault<z.ZodNumber>;
|
|
144
144
|
backgroundPadding: z.ZodDefault<z.ZodNumber>;
|
|
145
|
+
borderColor: z.ZodDefault<z.ZodString>;
|
|
146
|
+
borderSize: z.ZodDefault<z.ZodNumber>;
|
|
145
147
|
curveEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
146
148
|
curvePower: z.ZodDefault<z.ZodNumber>;
|
|
147
149
|
legacyBackground: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -152,6 +154,24 @@ export declare const leafSchemas: {
|
|
|
152
154
|
y: z.ZodDefault<z.ZodNumber>;
|
|
153
155
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
154
156
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
157
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
158
|
+
normal: "normal";
|
|
159
|
+
multiply: "multiply";
|
|
160
|
+
screen: "screen";
|
|
161
|
+
overlay: "overlay";
|
|
162
|
+
darken: "darken";
|
|
163
|
+
lighten: "lighten";
|
|
164
|
+
"color-dodge": "color-dodge";
|
|
165
|
+
"color-burn": "color-burn";
|
|
166
|
+
"hard-light": "hard-light";
|
|
167
|
+
"soft-light": "soft-light";
|
|
168
|
+
difference: "difference";
|
|
169
|
+
exclusion: "exclusion";
|
|
170
|
+
hue: "hue";
|
|
171
|
+
saturation: "saturation";
|
|
172
|
+
color: "color";
|
|
173
|
+
luminosity: "luminosity";
|
|
174
|
+
}>>;
|
|
155
175
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
156
176
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
157
177
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -213,6 +233,24 @@ export declare const leafSchemas: {
|
|
|
213
233
|
height: z.ZodDefault<z.ZodNumber>;
|
|
214
234
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
215
235
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
236
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
237
|
+
normal: "normal";
|
|
238
|
+
multiply: "multiply";
|
|
239
|
+
screen: "screen";
|
|
240
|
+
overlay: "overlay";
|
|
241
|
+
darken: "darken";
|
|
242
|
+
lighten: "lighten";
|
|
243
|
+
"color-dodge": "color-dodge";
|
|
244
|
+
"color-burn": "color-burn";
|
|
245
|
+
"hard-light": "hard-light";
|
|
246
|
+
"soft-light": "soft-light";
|
|
247
|
+
difference: "difference";
|
|
248
|
+
exclusion: "exclusion";
|
|
249
|
+
hue: "hue";
|
|
250
|
+
saturation: "saturation";
|
|
251
|
+
color: "color";
|
|
252
|
+
luminosity: "luminosity";
|
|
253
|
+
}>>;
|
|
216
254
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
217
255
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
218
256
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -262,8 +300,6 @@ export declare const leafSchemas: {
|
|
|
262
300
|
stretchEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
263
301
|
flipX: z.ZodDefault<z.ZodBoolean>;
|
|
264
302
|
flipY: z.ZodDefault<z.ZodBoolean>;
|
|
265
|
-
width: z.ZodDefault<z.ZodNumber>;
|
|
266
|
-
height: z.ZodDefault<z.ZodNumber>;
|
|
267
303
|
borderColor: z.ZodDefault<z.ZodString>;
|
|
268
304
|
borderSize: z.ZodDefault<z.ZodNumber>;
|
|
269
305
|
cornerRadius: z.ZodDefault<z.ZodNumber>;
|
|
@@ -273,8 +309,28 @@ export declare const leafSchemas: {
|
|
|
273
309
|
custom: z.ZodOptional<z.ZodUnknown>;
|
|
274
310
|
x: z.ZodDefault<z.ZodNumber>;
|
|
275
311
|
y: z.ZodDefault<z.ZodNumber>;
|
|
312
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
313
|
+
height: z.ZodDefault<z.ZodNumber>;
|
|
276
314
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
277
315
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
316
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
317
|
+
normal: "normal";
|
|
318
|
+
multiply: "multiply";
|
|
319
|
+
screen: "screen";
|
|
320
|
+
overlay: "overlay";
|
|
321
|
+
darken: "darken";
|
|
322
|
+
lighten: "lighten";
|
|
323
|
+
"color-dodge": "color-dodge";
|
|
324
|
+
"color-burn": "color-burn";
|
|
325
|
+
"hard-light": "hard-light";
|
|
326
|
+
"soft-light": "soft-light";
|
|
327
|
+
difference: "difference";
|
|
328
|
+
exclusion: "exclusion";
|
|
329
|
+
hue: "hue";
|
|
330
|
+
saturation: "saturation";
|
|
331
|
+
color: "color";
|
|
332
|
+
luminosity: "luminosity";
|
|
333
|
+
}>>;
|
|
278
334
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
279
335
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
280
336
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -327,6 +383,24 @@ export declare const leafSchemas: {
|
|
|
327
383
|
y: z.ZodDefault<z.ZodNumber>;
|
|
328
384
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
329
385
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
386
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
387
|
+
normal: "normal";
|
|
388
|
+
multiply: "multiply";
|
|
389
|
+
screen: "screen";
|
|
390
|
+
overlay: "overlay";
|
|
391
|
+
darken: "darken";
|
|
392
|
+
lighten: "lighten";
|
|
393
|
+
"color-dodge": "color-dodge";
|
|
394
|
+
"color-burn": "color-burn";
|
|
395
|
+
"hard-light": "hard-light";
|
|
396
|
+
"soft-light": "soft-light";
|
|
397
|
+
difference: "difference";
|
|
398
|
+
exclusion: "exclusion";
|
|
399
|
+
hue: "hue";
|
|
400
|
+
saturation: "saturation";
|
|
401
|
+
color: "color";
|
|
402
|
+
luminosity: "luminosity";
|
|
403
|
+
}>>;
|
|
330
404
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
331
405
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
332
406
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -381,6 +455,24 @@ export declare const leafSchemas: {
|
|
|
381
455
|
height: z.ZodDefault<z.ZodNumber>;
|
|
382
456
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
383
457
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
458
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
459
|
+
normal: "normal";
|
|
460
|
+
multiply: "multiply";
|
|
461
|
+
screen: "screen";
|
|
462
|
+
overlay: "overlay";
|
|
463
|
+
darken: "darken";
|
|
464
|
+
lighten: "lighten";
|
|
465
|
+
"color-dodge": "color-dodge";
|
|
466
|
+
"color-burn": "color-burn";
|
|
467
|
+
"hard-light": "hard-light";
|
|
468
|
+
"soft-light": "soft-light";
|
|
469
|
+
difference: "difference";
|
|
470
|
+
exclusion: "exclusion";
|
|
471
|
+
hue: "hue";
|
|
472
|
+
saturation: "saturation";
|
|
473
|
+
color: "color";
|
|
474
|
+
luminosity: "luminosity";
|
|
475
|
+
}>>;
|
|
384
476
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
385
477
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
386
478
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -443,6 +535,24 @@ export declare const leafSchemas: {
|
|
|
443
535
|
height: z.ZodDefault<z.ZodNumber>;
|
|
444
536
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
445
537
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
538
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
539
|
+
normal: "normal";
|
|
540
|
+
multiply: "multiply";
|
|
541
|
+
screen: "screen";
|
|
542
|
+
overlay: "overlay";
|
|
543
|
+
darken: "darken";
|
|
544
|
+
lighten: "lighten";
|
|
545
|
+
"color-dodge": "color-dodge";
|
|
546
|
+
"color-burn": "color-burn";
|
|
547
|
+
"hard-light": "hard-light";
|
|
548
|
+
"soft-light": "soft-light";
|
|
549
|
+
difference: "difference";
|
|
550
|
+
exclusion: "exclusion";
|
|
551
|
+
hue: "hue";
|
|
552
|
+
saturation: "saturation";
|
|
553
|
+
color: "color";
|
|
554
|
+
luminosity: "luminosity";
|
|
555
|
+
}>>;
|
|
446
556
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
447
557
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
448
558
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -509,6 +619,24 @@ export declare const leafSchemas: {
|
|
|
509
619
|
height: z.ZodDefault<z.ZodNumber>;
|
|
510
620
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
511
621
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
622
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
623
|
+
normal: "normal";
|
|
624
|
+
multiply: "multiply";
|
|
625
|
+
screen: "screen";
|
|
626
|
+
overlay: "overlay";
|
|
627
|
+
darken: "darken";
|
|
628
|
+
lighten: "lighten";
|
|
629
|
+
"color-dodge": "color-dodge";
|
|
630
|
+
"color-burn": "color-burn";
|
|
631
|
+
"hard-light": "hard-light";
|
|
632
|
+
"soft-light": "soft-light";
|
|
633
|
+
difference: "difference";
|
|
634
|
+
exclusion: "exclusion";
|
|
635
|
+
hue: "hue";
|
|
636
|
+
saturation: "saturation";
|
|
637
|
+
color: "color";
|
|
638
|
+
luminosity: "luminosity";
|
|
639
|
+
}>>;
|
|
512
640
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
513
641
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
514
642
|
duration: z.ZodDefault<z.ZodNumber>;
|
|
@@ -652,6 +780,24 @@ export declare const leafSchemas: {
|
|
|
652
780
|
y: z.ZodDefault<z.ZodNumber>;
|
|
653
781
|
rotation: z.ZodDefault<z.ZodNumber>;
|
|
654
782
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
783
|
+
blendMode: z.ZodOptional<z.ZodEnum<{
|
|
784
|
+
normal: "normal";
|
|
785
|
+
multiply: "multiply";
|
|
786
|
+
screen: "screen";
|
|
787
|
+
overlay: "overlay";
|
|
788
|
+
darken: "darken";
|
|
789
|
+
lighten: "lighten";
|
|
790
|
+
"color-dodge": "color-dodge";
|
|
791
|
+
"color-burn": "color-burn";
|
|
792
|
+
"hard-light": "hard-light";
|
|
793
|
+
"soft-light": "soft-light";
|
|
794
|
+
difference: "difference";
|
|
795
|
+
exclusion: "exclusion";
|
|
796
|
+
hue: "hue";
|
|
797
|
+
saturation: "saturation";
|
|
798
|
+
color: "color";
|
|
799
|
+
luminosity: "luminosity";
|
|
800
|
+
}>>;
|
|
655
801
|
animations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
656
802
|
delay: z.ZodDefault<z.ZodNumber>;
|
|
657
803
|
duration: z.ZodDefault<z.ZodNumber>;
|
package/lib/schema.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// MIN_FONT_SIZE in ./defaults for what they each decided.
|
|
26
26
|
import { z } from 'zod';
|
|
27
27
|
import { polotnoError } from './errors.js';
|
|
28
|
-
import { MIN_FONT_SIZE, clampFontSize, TEXT_DEFAULTS } from './defaults.js';
|
|
28
|
+
import { BLEND_MODES, GROUP_BLEND_MODES, MIN_FONT_SIZE, clampFontSize, TEXT_DEFAULTS, } from './defaults.js';
|
|
29
29
|
export const CURRENT_SCHEMA_VERSION = 4;
|
|
30
30
|
// Every element type the design format knows. Kept in sync with the
|
|
31
31
|
// element discriminatedUnion in build() below.
|
|
@@ -70,6 +70,10 @@ function build(o) {
|
|
|
70
70
|
.describe('Filter intensity (-1 to 1).'),
|
|
71
71
|
}))
|
|
72
72
|
.describe('Applied image filters keyed by filter name.');
|
|
73
|
+
const blendMode = z
|
|
74
|
+
.enum(BLEND_MODES)
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('How the element composites with the content beneath it. Omitted means normal.');
|
|
73
77
|
// Fields shared by every Shape-derived element. Defaults inline.
|
|
74
78
|
const shapeBase = {
|
|
75
79
|
id: z.string().describe('Unique identifier for the element.'),
|
|
@@ -85,6 +89,7 @@ function build(o) {
|
|
|
85
89
|
height: z.number().default(100).describe('Height in pixels.'),
|
|
86
90
|
rotation: z.number().default(0).describe('Rotation angle in degrees.'),
|
|
87
91
|
opacity: z.number().default(1).describe('Opacity level (0-1).'),
|
|
92
|
+
blendMode,
|
|
88
93
|
animations: z
|
|
89
94
|
.array(animation)
|
|
90
95
|
.default([])
|
|
@@ -198,7 +203,7 @@ function build(o) {
|
|
|
198
203
|
};
|
|
199
204
|
const textShape = {
|
|
200
205
|
...shapeBase,
|
|
201
|
-
type: z.literal('text'),
|
|
206
|
+
type: z.literal('text').describe('Element type identifier.'),
|
|
202
207
|
text: z.string().default('').describe('Visible text shown on canvas.'),
|
|
203
208
|
placeholder: z
|
|
204
209
|
.string()
|
|
@@ -288,6 +293,11 @@ function build(o) {
|
|
|
288
293
|
.number()
|
|
289
294
|
.default(0.5)
|
|
290
295
|
.describe('Text background padding.'),
|
|
296
|
+
borderColor: z.string().default('black').describe('Text box border color.'),
|
|
297
|
+
borderSize: z
|
|
298
|
+
.number()
|
|
299
|
+
.default(0)
|
|
300
|
+
.describe('Text box border width in pixels.'),
|
|
291
301
|
curveEnabled: z
|
|
292
302
|
.boolean()
|
|
293
303
|
.default(TEXT_DEFAULTS.curveEnabled)
|
|
@@ -301,31 +311,36 @@ function build(o) {
|
|
|
301
311
|
.optional()
|
|
302
312
|
.describe('Internal compatibility flag stamped by the v2→v3 migration.'),
|
|
303
313
|
};
|
|
304
|
-
const imageShape = {
|
|
314
|
+
const imageShape = {
|
|
315
|
+
...shapeBase,
|
|
316
|
+
...imageProps,
|
|
317
|
+
type: z.literal('image').describe('Element type identifier.'),
|
|
318
|
+
};
|
|
305
319
|
const svgShape = {
|
|
306
320
|
...shapeBase,
|
|
307
|
-
type: z.literal('svg'),
|
|
321
|
+
type: z.literal('svg').describe('Element type identifier.'),
|
|
308
322
|
src: z.string().default('').describe('URL or data URI of the SVG.'),
|
|
309
323
|
maskSrc: z
|
|
310
324
|
.string()
|
|
311
325
|
.default('')
|
|
312
326
|
.describe('URL or data URI for an SVG mask.'),
|
|
313
|
-
cropX:
|
|
314
|
-
cropY:
|
|
315
|
-
cropWidth:
|
|
316
|
-
cropHeight:
|
|
327
|
+
cropX: imageProps.cropX,
|
|
328
|
+
cropY: imageProps.cropY,
|
|
329
|
+
cropWidth: imageProps.cropWidth,
|
|
330
|
+
cropHeight: imageProps.cropHeight,
|
|
317
331
|
keepRatio: z
|
|
318
332
|
.boolean()
|
|
319
333
|
.default(true)
|
|
320
334
|
.describe('Whether to maintain aspect ratio when resizing.'),
|
|
321
|
-
stretchEnabled: z
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
335
|
+
stretchEnabled: z
|
|
336
|
+
.boolean()
|
|
337
|
+
.default(true)
|
|
338
|
+
.describe('Whether stretch mode is enabled.'),
|
|
339
|
+
flipX: imageProps.flipX,
|
|
340
|
+
flipY: imageProps.flipY,
|
|
341
|
+
borderColor: imageProps.borderColor,
|
|
342
|
+
borderSize: imageProps.borderSize,
|
|
343
|
+
cornerRadius: imageProps.cornerRadius,
|
|
329
344
|
colorsReplace: z
|
|
330
345
|
.record(z.string(), z.string())
|
|
331
346
|
.default({})
|
|
@@ -333,9 +348,9 @@ function build(o) {
|
|
|
333
348
|
};
|
|
334
349
|
const lineShape = {
|
|
335
350
|
...shapeBase,
|
|
336
|
-
type: z.literal('line'),
|
|
337
|
-
width: z.number().default(400),
|
|
338
|
-
height: z.number().default(10),
|
|
351
|
+
type: z.literal('line').describe('Element type identifier.'),
|
|
352
|
+
width: z.number().default(400).describe('Width in pixels.'),
|
|
353
|
+
height: z.number().default(10).describe('Height in pixels.'),
|
|
339
354
|
color: z.string().default('black').describe('Line color.'),
|
|
340
355
|
dash: z.array(z.number()).default([]).describe('Dash pattern array.'),
|
|
341
356
|
startHead: z
|
|
@@ -349,28 +364,34 @@ function build(o) {
|
|
|
349
364
|
};
|
|
350
365
|
const figureShape = {
|
|
351
366
|
...shapeBase,
|
|
352
|
-
type: z.literal('figure'),
|
|
367
|
+
type: z.literal('figure').describe('Element type identifier.'),
|
|
353
368
|
subType: z
|
|
354
369
|
.string()
|
|
355
370
|
.default('rect')
|
|
356
371
|
.describe('Figure subtype: rect, ellipse, triangle, etc.'),
|
|
357
372
|
fill: z.string().default('rgb(0, 161, 255)').describe('Fill color.'),
|
|
358
373
|
dash: z.array(z.number()).default([]).describe('Dash pattern array.'),
|
|
359
|
-
strokeWidth: z.number().default(0),
|
|
360
|
-
stroke: z
|
|
361
|
-
|
|
374
|
+
strokeWidth: z.number().default(0).describe('Stroke width in pixels.'),
|
|
375
|
+
stroke: z
|
|
376
|
+
.string()
|
|
377
|
+
.default('rgba(98, 197, 255, 1)')
|
|
378
|
+
.describe('Stroke color.'),
|
|
379
|
+
cornerRadius: imageProps.cornerRadius,
|
|
362
380
|
};
|
|
363
381
|
const gifShape = {
|
|
364
382
|
...shapeBase,
|
|
365
383
|
...imageProps,
|
|
366
|
-
type: z.literal('gif'),
|
|
384
|
+
type: z.literal('gif').describe('Element type identifier.'),
|
|
367
385
|
duration: z.number().default(0).describe('GIF duration in milliseconds.'),
|
|
368
|
-
keepRatio: z
|
|
386
|
+
keepRatio: z
|
|
387
|
+
.boolean()
|
|
388
|
+
.default(true)
|
|
389
|
+
.describe('Whether to maintain aspect ratio when resizing.'),
|
|
369
390
|
};
|
|
370
391
|
const videoShape = {
|
|
371
392
|
...shapeBase,
|
|
372
393
|
...imageProps,
|
|
373
|
-
type: z.literal('video'),
|
|
394
|
+
type: z.literal('video').describe('Element type identifier.'),
|
|
374
395
|
duration: z.number().default(0).describe('Video duration in milliseconds.'),
|
|
375
396
|
startTime: z.number().default(0).describe('Start offset (0-1).'),
|
|
376
397
|
endTime: z.number().default(1).describe('End offset (0-1).'),
|
|
@@ -581,17 +602,21 @@ function build(o) {
|
|
|
581
602
|
.describe('Default cell padding in pixels.'),
|
|
582
603
|
};
|
|
583
604
|
const groupShape = (element) => ({
|
|
584
|
-
id:
|
|
585
|
-
type: z.literal('group'),
|
|
586
|
-
name:
|
|
587
|
-
custom:
|
|
588
|
-
opacity:
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
605
|
+
id: shapeBase.id,
|
|
606
|
+
type: z.literal('group').describe('Element type identifier.'),
|
|
607
|
+
name: shapeBase.name,
|
|
608
|
+
custom: shapeBase.custom,
|
|
609
|
+
opacity: shapeBase.opacity,
|
|
610
|
+
blendMode: z
|
|
611
|
+
.enum(GROUP_BLEND_MODES)
|
|
612
|
+
.optional()
|
|
613
|
+
.describe('How the group composites with the content beneath it. Omitted means pass-through: children blend with that content directly. Any other mode composites the children together first.'),
|
|
614
|
+
visible: shapeBase.visible,
|
|
615
|
+
selectable: shapeBase.selectable,
|
|
616
|
+
removable: shapeBase.removable,
|
|
617
|
+
alwaysOnTop: shapeBase.alwaysOnTop,
|
|
618
|
+
showInExport: shapeBase.showInExport,
|
|
619
|
+
animations: shapeBase.animations,
|
|
595
620
|
children: z
|
|
596
621
|
.array(element)
|
|
597
622
|
.default([])
|
package/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { BLEND_MODES, GROUP_BLEND_MODES } from './defaults.js';
|
|
2
|
+
export type BlendMode = (typeof BLEND_MODES)[number];
|
|
3
|
+
export type GroupBlendMode = (typeof GROUP_BLEND_MODES)[number];
|
|
1
4
|
export interface Design {
|
|
2
5
|
/** Schema version for compatibility / migration. */
|
|
3
6
|
schemaVersion: number;
|
|
@@ -120,6 +123,8 @@ export interface ShapeAttributes {
|
|
|
120
123
|
rotation: number;
|
|
121
124
|
/** Opacity (0-1). */
|
|
122
125
|
opacity: number;
|
|
126
|
+
/** How the element composites with the content beneath it. Omitted means normal. */
|
|
127
|
+
blendMode?: BlendMode;
|
|
123
128
|
/** Animation configurations. */
|
|
124
129
|
animations: Animation[];
|
|
125
130
|
blurEnabled: boolean;
|
|
@@ -155,6 +160,8 @@ export interface GroupElement {
|
|
|
155
160
|
name: string;
|
|
156
161
|
custom?: unknown;
|
|
157
162
|
opacity: number;
|
|
163
|
+
/** How the group composites with the content beneath it. Omitted means pass-through; any other mode composites the children together first. */
|
|
164
|
+
blendMode?: GroupBlendMode;
|
|
158
165
|
visible: boolean;
|
|
159
166
|
selectable: boolean;
|
|
160
167
|
removable: boolean;
|
|
@@ -196,6 +203,8 @@ export interface TextElement extends ShapeAttributes {
|
|
|
196
203
|
backgroundOpacity: number;
|
|
197
204
|
backgroundCornerRadius: number;
|
|
198
205
|
backgroundPadding: number;
|
|
206
|
+
borderColor: string;
|
|
207
|
+
borderSize: number;
|
|
199
208
|
curveEnabled: boolean;
|
|
200
209
|
curvePower: number;
|
|
201
210
|
/** Internal compatibility flag stamped by the v2→v3 migration. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polotno/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Canonical Polotno design format: types, normalize, validate, JSON Schema. Authored in zod, DOM-free.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"import": "./lib/defaults.js",
|
|
17
17
|
"types": "./lib/defaults.d.ts"
|
|
18
18
|
},
|
|
19
|
+
"./asset-urls": {
|
|
20
|
+
"import": "./lib/asset-urls.js",
|
|
21
|
+
"types": "./lib/asset-urls.d.ts"
|
|
22
|
+
},
|
|
19
23
|
"./json": {
|
|
20
24
|
"import": "./lib/design.schema.json"
|
|
21
25
|
},
|
|
@@ -46,7 +50,7 @@
|
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"typescript": "~6.0.3",
|
|
49
|
-
"vitest": "^5.0.
|
|
53
|
+
"vitest": "^5.0.2"
|
|
50
54
|
},
|
|
51
55
|
"scripts": {
|
|
52
56
|
"build": "rm -rf lib && tsc && node scripts/generate-schema.mjs && node ../../scripts/check-pack.mjs",
|