@routevn/creator-model 1.10.0 → 1.10.1
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 +1 -1
- package/src/model.js +142 -1
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -3066,6 +3066,60 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
|
|
|
3066
3066
|
}
|
|
3067
3067
|
};
|
|
3068
3068
|
|
|
3069
|
+
const validateTextStyleShadow = ({ shadow, path, errorFactory }) => {
|
|
3070
|
+
if (!isPlainObject(shadow)) {
|
|
3071
|
+
return invalidFromErrorFactory(errorFactory, `${path} must be an object`);
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
{
|
|
3075
|
+
const result = validateAllowedKeys({
|
|
3076
|
+
value: shadow,
|
|
3077
|
+
allowedKeys: ["colorId", "alpha", "blur", "offsetX", "offsetY"],
|
|
3078
|
+
path,
|
|
3079
|
+
errorFactory,
|
|
3080
|
+
});
|
|
3081
|
+
if (result?.valid === false) {
|
|
3082
|
+
return result;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
if (!isNonEmptyString(shadow.colorId)) {
|
|
3087
|
+
return invalidFromErrorFactory(
|
|
3088
|
+
errorFactory,
|
|
3089
|
+
`${path}.colorId must be a non-empty string`,
|
|
3090
|
+
);
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
if (
|
|
3094
|
+
shadow.alpha !== undefined &&
|
|
3095
|
+
(!isFiniteNumber(shadow.alpha) || shadow.alpha < 0 || shadow.alpha > 1)
|
|
3096
|
+
) {
|
|
3097
|
+
return invalidFromErrorFactory(
|
|
3098
|
+
errorFactory,
|
|
3099
|
+
`${path}.alpha must be a finite number between 0 and 1 when provided`,
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
if (
|
|
3104
|
+
shadow.blur !== undefined &&
|
|
3105
|
+
(!isFiniteNumber(shadow.blur) || shadow.blur < 0)
|
|
3106
|
+
) {
|
|
3107
|
+
return invalidFromErrorFactory(
|
|
3108
|
+
errorFactory,
|
|
3109
|
+
`${path}.blur must be a non-negative finite number when provided`,
|
|
3110
|
+
);
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
for (const key of ["offsetX", "offsetY"]) {
|
|
3114
|
+
if (shadow[key] !== undefined && !isFiniteNumber(shadow[key])) {
|
|
3115
|
+
return invalidFromErrorFactory(
|
|
3116
|
+
errorFactory,
|
|
3117
|
+
`${path}.${key} must be a finite number when provided`,
|
|
3118
|
+
);
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
};
|
|
3122
|
+
|
|
3069
3123
|
const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
3070
3124
|
for (const [itemId, item] of Object.entries(items)) {
|
|
3071
3125
|
const itemPath = `${path}.${itemId}`;
|
|
@@ -3103,6 +3157,7 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
|
3103
3157
|
"strokeColorId",
|
|
3104
3158
|
"strokeAlpha",
|
|
3105
3159
|
"strokeWidth",
|
|
3160
|
+
"shadow",
|
|
3106
3161
|
],
|
|
3107
3162
|
path: itemPath,
|
|
3108
3163
|
errorFactory,
|
|
@@ -3262,6 +3317,17 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
|
3262
3317
|
`${itemPath}.strokeWidth must be a finite number when provided`,
|
|
3263
3318
|
);
|
|
3264
3319
|
}
|
|
3320
|
+
|
|
3321
|
+
if (item.shadow !== undefined) {
|
|
3322
|
+
const result = validateTextStyleShadow({
|
|
3323
|
+
shadow: item.shadow,
|
|
3324
|
+
path: `${itemPath}.shadow`,
|
|
3325
|
+
errorFactory,
|
|
3326
|
+
});
|
|
3327
|
+
if (result?.valid === false) {
|
|
3328
|
+
return result;
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3265
3331
|
}
|
|
3266
3332
|
}
|
|
3267
3333
|
};
|
|
@@ -5207,6 +5273,22 @@ const applyTagIdsUpdate = ({ currentItem, data }) => {
|
|
|
5207
5273
|
return nextItem;
|
|
5208
5274
|
};
|
|
5209
5275
|
|
|
5276
|
+
const applyTextStyleUpdate = ({ currentItem, data }) => {
|
|
5277
|
+
const nextData = structuredClone(data);
|
|
5278
|
+
delete nextData.clearShadow;
|
|
5279
|
+
|
|
5280
|
+
const nextItem = applyTagIdsUpdate({
|
|
5281
|
+
currentItem,
|
|
5282
|
+
data: nextData,
|
|
5283
|
+
});
|
|
5284
|
+
|
|
5285
|
+
if (data.clearShadow === true) {
|
|
5286
|
+
delete nextItem.shadow;
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5289
|
+
return nextItem;
|
|
5290
|
+
};
|
|
5291
|
+
|
|
5210
5292
|
const applyCharacterUpdate = ({ currentItem, data }) => {
|
|
5211
5293
|
const nextItem = applyTagIdsUpdate({
|
|
5212
5294
|
currentItem,
|
|
@@ -7098,6 +7180,19 @@ export const assertInvariants = ({ state }) => {
|
|
|
7098
7180
|
);
|
|
7099
7181
|
}
|
|
7100
7182
|
}
|
|
7183
|
+
|
|
7184
|
+
if (textStyle.shadow !== undefined) {
|
|
7185
|
+
const shadowColor = state.colors.items[textStyle.shadow.colorId];
|
|
7186
|
+
if (!isPlainObject(shadowColor) || shadowColor.type === "folder") {
|
|
7187
|
+
return invalidInvariant(
|
|
7188
|
+
"textStyle.shadow.colorId must reference an existing non-folder color",
|
|
7189
|
+
{
|
|
7190
|
+
textStyleId,
|
|
7191
|
+
colorId: textStyle.shadow.colorId,
|
|
7192
|
+
},
|
|
7193
|
+
);
|
|
7194
|
+
}
|
|
7195
|
+
}
|
|
7101
7196
|
}
|
|
7102
7197
|
|
|
7103
7198
|
for (const [imageId, image] of Object.entries(state.images.items)) {
|
|
@@ -11023,6 +11118,7 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
11023
11118
|
"strokeColorId",
|
|
11024
11119
|
"strokeAlpha",
|
|
11025
11120
|
"strokeWidth",
|
|
11121
|
+
"shadow",
|
|
11026
11122
|
],
|
|
11027
11123
|
path: "payload.data",
|
|
11028
11124
|
errorFactory,
|
|
@@ -11098,6 +11194,8 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
11098
11194
|
"strokeColorId",
|
|
11099
11195
|
"strokeAlpha",
|
|
11100
11196
|
"strokeWidth",
|
|
11197
|
+
"shadow",
|
|
11198
|
+
"clearShadow",
|
|
11101
11199
|
],
|
|
11102
11200
|
path: "payload.data",
|
|
11103
11201
|
errorFactory,
|
|
@@ -11166,6 +11264,31 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
11166
11264
|
}
|
|
11167
11265
|
}
|
|
11168
11266
|
|
|
11267
|
+
if (data.shadow !== undefined) {
|
|
11268
|
+
const result = validateTextStyleShadow({
|
|
11269
|
+
shadow: data.shadow,
|
|
11270
|
+
path: "payload.data.shadow",
|
|
11271
|
+
errorFactory,
|
|
11272
|
+
});
|
|
11273
|
+
if (result?.valid === false) {
|
|
11274
|
+
return result;
|
|
11275
|
+
}
|
|
11276
|
+
}
|
|
11277
|
+
|
|
11278
|
+
if (data.clearShadow !== undefined && data.clearShadow !== true) {
|
|
11279
|
+
return invalidFromErrorFactory(
|
|
11280
|
+
errorFactory,
|
|
11281
|
+
"payload.data.clearShadow must be true when provided",
|
|
11282
|
+
);
|
|
11283
|
+
}
|
|
11284
|
+
|
|
11285
|
+
if (data.shadow !== undefined && data.clearShadow === true) {
|
|
11286
|
+
return invalidFromErrorFactory(
|
|
11287
|
+
errorFactory,
|
|
11288
|
+
"payload.data.shadow and payload.data.clearShadow cannot both be provided",
|
|
11289
|
+
);
|
|
11290
|
+
}
|
|
11291
|
+
|
|
11169
11292
|
if (data.breakWords !== undefined && typeof data.breakWords !== "boolean") {
|
|
11170
11293
|
return invalidFromErrorFactory(
|
|
11171
11294
|
errorFactory,
|
|
@@ -18322,7 +18445,7 @@ const COMMAND_DEFINITIONS = [
|
|
|
18322
18445
|
};
|
|
18323
18446
|
},
|
|
18324
18447
|
updateItem: ({ currentItem, payload }) =>
|
|
18325
|
-
|
|
18448
|
+
applyTextStyleUpdate({
|
|
18326
18449
|
currentItem,
|
|
18327
18450
|
data: payload.data,
|
|
18328
18451
|
}),
|
|
@@ -18360,6 +18483,15 @@ const COMMAND_DEFINITIONS = [
|
|
|
18360
18483
|
);
|
|
18361
18484
|
}
|
|
18362
18485
|
}
|
|
18486
|
+
|
|
18487
|
+
if (data.shadow !== undefined) {
|
|
18488
|
+
const shadowColor = state.colors.items[data.shadow.colorId];
|
|
18489
|
+
if (!isPlainObject(shadowColor) || shadowColor.type === "folder") {
|
|
18490
|
+
return invalidPrecondition(
|
|
18491
|
+
"payload.data.shadow.colorId must reference an existing non-folder color",
|
|
18492
|
+
);
|
|
18493
|
+
}
|
|
18494
|
+
}
|
|
18363
18495
|
},
|
|
18364
18496
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
18365
18497
|
if (
|
|
@@ -18403,6 +18535,15 @@ const COMMAND_DEFINITIONS = [
|
|
|
18403
18535
|
);
|
|
18404
18536
|
}
|
|
18405
18537
|
}
|
|
18538
|
+
|
|
18539
|
+
if (payload.data.shadow !== undefined) {
|
|
18540
|
+
const shadowColor = state.colors.items[payload.data.shadow.colorId];
|
|
18541
|
+
if (!isPlainObject(shadowColor) || shadowColor.type === "folder") {
|
|
18542
|
+
return invalidPrecondition(
|
|
18543
|
+
"payload.data.shadow.colorId must reference an existing non-folder color",
|
|
18544
|
+
);
|
|
18545
|
+
}
|
|
18546
|
+
}
|
|
18406
18547
|
},
|
|
18407
18548
|
}),
|
|
18408
18549
|
...createFolderedCollectionCommandDefinitions({
|