@weasel-js/svg 1.4.1 → 1.4.3
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.ts +4 -1
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -166,8 +166,11 @@ interface SvgTextNode {
|
|
|
166
166
|
* in `data.fill` / `data.stroke`. Not `SvgPaint`, which is the path
|
|
167
167
|
* nodes' shape — a text paint reaches the renderer through the runs, and
|
|
168
168
|
* `StyledRun.fill` / `.stroke` override these per range.
|
|
169
|
+
*
|
|
170
|
+
* `null` is SVG's `fill="none"`: outline-only text, painted by its stroke
|
|
171
|
+
* alone. Absent takes the default black.
|
|
169
172
|
*/
|
|
170
|
-
fill?: FillStyle;
|
|
173
|
+
fill?: FillStyle | null;
|
|
171
174
|
stroke?: Stroke;
|
|
172
175
|
/** Element-level opacity (`opacity="..."`), 0..1. */
|
|
173
176
|
opacity?: number;
|
package/dist/index.js
CHANGED
|
@@ -1297,7 +1297,7 @@ function parseTextElement(el, ctm, style, gradients, onWarn) {
|
|
|
1297
1297
|
);
|
|
1298
1298
|
if (hasStyling) node.runs = runs;
|
|
1299
1299
|
if (Object.keys(textStyle).length > 0) node.style = textStyle;
|
|
1300
|
-
if (textPaint.fill
|
|
1300
|
+
if (textPaint.fill !== void 0) node.fill = textPaint.fill;
|
|
1301
1301
|
if (textPaint.stroke != null) node.stroke = textPaint.stroke;
|
|
1302
1302
|
if (opacity != null) node.opacity = opacity;
|
|
1303
1303
|
if (!isIdentity(localTransform)) {
|
|
@@ -1404,6 +1404,8 @@ function readTextPaint(style, gradients, onWarn) {
|
|
|
1404
1404
|
} else if (parsed?.kind === "ref") {
|
|
1405
1405
|
const paint = gradients.get(parsed.id);
|
|
1406
1406
|
if (paint) out.fill = paint;
|
|
1407
|
+
} else if (parsed?.kind === "none") {
|
|
1408
|
+
out.fill = null;
|
|
1407
1409
|
}
|
|
1408
1410
|
}
|
|
1409
1411
|
const stroke = coreStroke(readStroke(style, gradients, onWarn));
|
|
@@ -1607,17 +1609,18 @@ function paintAttrs(paint, name, registry, includeOpacity = true) {
|
|
|
1607
1609
|
return [`${name}="url(#${id})"`];
|
|
1608
1610
|
}
|
|
1609
1611
|
function coreStrokeAttrs(stroke, registry) {
|
|
1610
|
-
|
|
1612
|
+
const paint = stroke?.paint;
|
|
1613
|
+
if (!stroke || !paint) return [];
|
|
1611
1614
|
const width = resolveStrokeWidth(stroke.width ?? 1, 1);
|
|
1612
1615
|
if (!(width > 0)) return [];
|
|
1613
1616
|
const attrs = [];
|
|
1614
|
-
if ("color" in
|
|
1615
|
-
attrs.push(`stroke="${
|
|
1616
|
-
if (
|
|
1617
|
-
attrs.push(`stroke-opacity="${trimNumber(
|
|
1617
|
+
if ("color" in paint) {
|
|
1618
|
+
attrs.push(`stroke="${paint.color}"`);
|
|
1619
|
+
if (paint.opacity != null && paint.opacity !== 1) {
|
|
1620
|
+
attrs.push(`stroke-opacity="${trimNumber(paint.opacity)}"`);
|
|
1618
1621
|
}
|
|
1619
1622
|
} else {
|
|
1620
|
-
attrs.push(`stroke="url(#${registry.register(
|
|
1623
|
+
attrs.push(`stroke="url(#${registry.register(paint)})"`);
|
|
1621
1624
|
}
|
|
1622
1625
|
attrs.push(`stroke-width="${trimNumber(width)}"`);
|
|
1623
1626
|
if (stroke.cap) attrs.push(`stroke-linecap="${stroke.cap}"`);
|
|
@@ -1735,7 +1738,9 @@ function textXml(node, registry, namespaces) {
|
|
|
1735
1738
|
}
|
|
1736
1739
|
const decoration = textDecorationValue(style?.underline, style?.strikethrough, style?.overline);
|
|
1737
1740
|
if (decoration) attrs.push(`text-decoration="${decoration}"`);
|
|
1738
|
-
if (node.fill) {
|
|
1741
|
+
if (node.fill === null) {
|
|
1742
|
+
attrs.push('fill="none"');
|
|
1743
|
+
} else if (node.fill) {
|
|
1739
1744
|
if ("color" in node.fill) {
|
|
1740
1745
|
attrs.push(`fill="${node.fill.color}"`);
|
|
1741
1746
|
if (node.fill.opacity != null && node.fill.opacity !== 1) {
|