embroidery-qc-image 1.0.35 → 1.0.36
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/components/EmbroideryQCImage.d.ts.map +1 -1
- package/dist/index.esm.js +51 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1584,13 +1584,13 @@ const renderSide = (ctx, side, startY, width, height, scaleFactor, imageRefs, mo
|
|
|
1584
1584
|
return currentY - startY;
|
|
1585
1585
|
}
|
|
1586
1586
|
// Compute uniform properties
|
|
1587
|
-
|
|
1588
|
-
|
|
1587
|
+
// Lấy màu từ tất cả ICON positions (sử dụng getIconColors để ưu tiên layer_colors)
|
|
1588
|
+
const iconColorPositions = side.positions.filter((p) => p.type === "ICON");
|
|
1589
1589
|
const iconColorValues = iconColorPositions
|
|
1590
1590
|
.map((p) => {
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
return
|
|
1591
|
+
const iconColors = getIconColors(p);
|
|
1592
|
+
// Join các màu bằng dấu phẩy giống TEXT để so sánh uniform
|
|
1593
|
+
return iconColors?.length ? iconColors.join(",") : null;
|
|
1594
1594
|
})
|
|
1595
1595
|
.filter((color) => Boolean(color));
|
|
1596
1596
|
const uniformProps = computeUniformProperties(textPositions, {
|
|
@@ -1645,38 +1645,62 @@ const renderSide = (ctx, side, startY, width, height, scaleFactor, imageRefs, mo
|
|
|
1645
1645
|
currentY += LAYOUT.LINE_GAP * scaleFactor;
|
|
1646
1646
|
side.positions.forEach((position) => {
|
|
1647
1647
|
if (position.type === "ICON") {
|
|
1648
|
-
const
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
: position.color ?? null;
|
|
1648
|
+
const iconColors = getIconColors(position);
|
|
1649
|
+
const iconColorValue = iconColors?.length ? iconColors.join(",") : null;
|
|
1650
|
+
// Icon có thể hide color nếu uniform với TEXT, bất kể số lượng màu
|
|
1651
|
+
// (vì TEXT với layer_colors nhiều màu cũng có thể uniform)
|
|
1653
1652
|
const hideColor = shouldShowUniformLabels &&
|
|
1654
1653
|
uniformProps.isUniform.color &&
|
|
1655
1654
|
iconColorValue !== null &&
|
|
1656
|
-
uniformProps.values.color === iconColorValue
|
|
1657
|
-
iconUsesSingleColor;
|
|
1655
|
+
uniformProps.values.color === iconColorValue;
|
|
1658
1656
|
currentY += renderIconPosition(ctx, position, padding, currentY, sideWidth, scaleFactor, imageRefs, { hideColor }, mockupBounds);
|
|
1659
1657
|
currentY += (LAYOUT.LINE_GAP / 3) * scaleFactor;
|
|
1660
1658
|
}
|
|
1661
1659
|
});
|
|
1662
1660
|
return currentY - startY;
|
|
1663
1661
|
};
|
|
1662
|
+
// Helper function để lấy màu từ TEXT position (ưu tiên layer_colors, fallback về character_colors hoặc color)
|
|
1663
|
+
const getTextColors = (position) => {
|
|
1664
|
+
if (position.layer_colors?.length) {
|
|
1665
|
+
return position.layer_colors;
|
|
1666
|
+
}
|
|
1667
|
+
if (position.character_colors?.length) {
|
|
1668
|
+
return position.character_colors;
|
|
1669
|
+
}
|
|
1670
|
+
if (position.color) {
|
|
1671
|
+
return [position.color];
|
|
1672
|
+
}
|
|
1673
|
+
return null;
|
|
1674
|
+
};
|
|
1675
|
+
// Helper function để lấy màu từ ICON position (ưu tiên layer_colors, fallback về color)
|
|
1676
|
+
const getIconColors = (position) => {
|
|
1677
|
+
if (position.layer_colors?.length) {
|
|
1678
|
+
return position.layer_colors;
|
|
1679
|
+
}
|
|
1680
|
+
if (position.color) {
|
|
1681
|
+
return [position.color];
|
|
1682
|
+
}
|
|
1683
|
+
return null;
|
|
1684
|
+
};
|
|
1664
1685
|
const groupTextPositions = (textPositions) => {
|
|
1665
1686
|
const groups = [];
|
|
1666
1687
|
let currentGroup = null;
|
|
1667
1688
|
let currentProps = null;
|
|
1668
1689
|
textPositions.forEach((position) => {
|
|
1690
|
+
const textColors = getTextColors(position);
|
|
1669
1691
|
const posProps = {
|
|
1670
1692
|
font: position.font,
|
|
1671
1693
|
text_shape: position.text_shape,
|
|
1672
1694
|
color: position.color,
|
|
1673
1695
|
character_colors: position.character_colors?.join(","),
|
|
1696
|
+
layer_colors: textColors?.join(","),
|
|
1674
1697
|
};
|
|
1675
1698
|
if (!currentGroup ||
|
|
1676
1699
|
currentProps.font !== posProps.font ||
|
|
1677
1700
|
currentProps.text_shape !== posProps.text_shape ||
|
|
1678
1701
|
currentProps.color !== posProps.color ||
|
|
1679
|
-
currentProps.character_colors !== posProps.character_colors
|
|
1702
|
+
currentProps.character_colors !== posProps.character_colors ||
|
|
1703
|
+
currentProps.layer_colors !== posProps.layer_colors) {
|
|
1680
1704
|
if (currentGroup) {
|
|
1681
1705
|
groups.push(currentGroup);
|
|
1682
1706
|
}
|
|
@@ -1701,9 +1725,12 @@ const computeUniformProperties = (textPositions, options) => {
|
|
|
1701
1725
|
const shapes = new Set(textPositions.map((p) => p.text_shape));
|
|
1702
1726
|
const florals = new Set(textPositions.map((p) => p.floral_pattern ?? "None"));
|
|
1703
1727
|
const colorSources = [
|
|
1704
|
-
...textPositions.map((p) =>
|
|
1705
|
-
|
|
1706
|
-
|
|
1728
|
+
...textPositions.map((p) => {
|
|
1729
|
+
const textColors = getTextColors(p);
|
|
1730
|
+
return textColors?.length
|
|
1731
|
+
? textColors.join(",")
|
|
1732
|
+
: p.color ?? "None";
|
|
1733
|
+
}),
|
|
1707
1734
|
...(options?.additionalColorValues?.map((color) => color ?? "None") ?? []),
|
|
1708
1735
|
];
|
|
1709
1736
|
if (textPositions.length === 0 &&
|
|
@@ -2085,9 +2112,11 @@ displayIndex, showLabels, scaleFactor, imageRefs, mockupBounds = null) => {
|
|
|
2085
2112
|
}
|
|
2086
2113
|
}
|
|
2087
2114
|
if (showLabels.color) {
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2115
|
+
// Ưu tiên layer_colors, fallback về character_colors hoặc color (giống ICON)
|
|
2116
|
+
const textColors = getTextColors(position);
|
|
2117
|
+
if (textColors && textColors.length > 0) {
|
|
2118
|
+
const colorValue = textColors.join(", ");
|
|
2119
|
+
const colors = textColors;
|
|
2091
2120
|
const swatchH = Math.floor(otherFontSize * LAYOUT.SWATCH_HEIGHT_RATIO);
|
|
2092
2121
|
const totalSwatchWidth = calculateSwatchesWidth(colors, swatchH, scaleFactor, imageRefs);
|
|
2093
2122
|
// Tính effectiveMaxWidth cho dòng này để tránh mockup
|
|
@@ -2363,16 +2392,9 @@ const renderIconPosition = (ctx, position, x, y, maxWidth, scaleFactor, imageRef
|
|
|
2363
2392
|
cursorY += iconResult.height;
|
|
2364
2393
|
// Draw color swatches (prefer layer_colors, fallback to single color)
|
|
2365
2394
|
// Nếu icon đã bị xóa thì không cần hiển thị màu chỉ nữa
|
|
2366
|
-
const iconColors = position.is_delete_icon
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
? position.layer_colors
|
|
2370
|
-
: position.color
|
|
2371
|
-
? [position.color]
|
|
2372
|
-
: null;
|
|
2373
|
-
const layerCount = position.layer_colors?.length ?? 0;
|
|
2374
|
-
const hasMultiLayerColors = layerCount > 1;
|
|
2375
|
-
const shouldSkipColorSection = options?.hideColor && !hasMultiLayerColors;
|
|
2395
|
+
const iconColors = position.is_delete_icon ? null : getIconColors(position);
|
|
2396
|
+
// Nếu hideColor = true, ẩn màu của ICON (giống TEXT) bất kể số lượng màu
|
|
2397
|
+
const shouldSkipColorSection = options?.hideColor === true;
|
|
2376
2398
|
if (iconColors?.length && !shouldSkipColorSection) {
|
|
2377
2399
|
// Dòng "Màu chỉ:" của icon dùng OTHER_FONT_SIZE, không dùng iconFontSize
|
|
2378
2400
|
const otherFontSize = LAYOUT.OTHER_FONT_SIZE * scaleFactor;
|