abstract-image
Advanced tools
Comparing version 2.2.4 to 2.2.5
@@ -96,3 +96,5 @@ "use strict"; | ||
var lines_1 = component.text !== null ? component.text.split("\n") : []; | ||
var tSpans = lines_1.map(function (t) { return (React.createElement("tspan", { key: t, x: component.position.x, y: component.position.y + (lines_1.indexOf(t) + dy_1) * lineHeight_1, height: lineHeight_1.toString() + "px" }, t)); }); | ||
var tSpans = lines_1.map(function (t) { | ||
return renderLine(t, component.position.x, component.position.y + (lines_1.indexOf(t) + dy_1) * lineHeight_1, component.fontSize, lineHeight_1); | ||
}); | ||
var cs = []; | ||
@@ -134,2 +136,18 @@ if (component.strokeThickness > 0 && component.strokeColor) { | ||
} | ||
function renderLine(text, x, y, fontSize, lineHeight) { | ||
var split = R.unnest(text.split("<sub>").map(function (t) { return t.split("</sub>"); })); | ||
var inside = false; | ||
var tags = []; | ||
for (var _i = 0, split_1 = split; _i < split_1.length; _i++) { | ||
var text_1 = split_1[_i]; | ||
if (inside) { | ||
tags.push(React.createElement("tspan", { baselineShift: "sub", style: { fontSize: (fontSize * 0.8).toString() + "px" } }, text_1)); | ||
} | ||
else { | ||
tags.push(React.createElement("tspan", null, text_1)); | ||
} | ||
inside = !inside; | ||
} | ||
return (React.createElement("tspan", { key: text, x: x, y: y, height: lineHeight.toString() + "px" }, tags)); | ||
} | ||
function getBaselineAdjustment(d) { | ||
@@ -136,0 +154,0 @@ if (d === "up") { |
@@ -89,3 +89,8 @@ "use strict"; | ||
height: lineHeight_1.toString() + "px" | ||
}, [t]); | ||
}, [ | ||
t | ||
.replace("<sub>", "<tspan style=\"font-size: " + component.fontSize * | ||
0.8 + "px\" baseline-shift=\"sub\">") | ||
.replace("</sub>", "</tspan>") | ||
]); | ||
}); | ||
@@ -92,0 +97,0 @@ var cs = []; |
@@ -93,3 +93,5 @@ import * as R from "ramda"; | ||
var lines_1 = component.text !== null ? component.text.split("\n") : []; | ||
var tSpans = lines_1.map(function (t) { return (React.createElement("tspan", { key: t, x: component.position.x, y: component.position.y + (lines_1.indexOf(t) + dy_1) * lineHeight_1, height: lineHeight_1.toString() + "px" }, t)); }); | ||
var tSpans = lines_1.map(function (t) { | ||
return renderLine(t, component.position.x, component.position.y + (lines_1.indexOf(t) + dy_1) * lineHeight_1, component.fontSize, lineHeight_1); | ||
}); | ||
var cs = []; | ||
@@ -131,2 +133,18 @@ if (component.strokeThickness > 0 && component.strokeColor) { | ||
} | ||
function renderLine(text, x, y, fontSize, lineHeight) { | ||
var split = R.unnest(text.split("<sub>").map(function (t) { return t.split("</sub>"); })); | ||
var inside = false; | ||
var tags = []; | ||
for (var _i = 0, split_1 = split; _i < split_1.length; _i++) { | ||
var text_1 = split_1[_i]; | ||
if (inside) { | ||
tags.push(React.createElement("tspan", { baselineShift: "sub", style: { fontSize: (fontSize * 0.8).toString() + "px" } }, text_1)); | ||
} | ||
else { | ||
tags.push(React.createElement("tspan", null, text_1)); | ||
} | ||
inside = !inside; | ||
} | ||
return (React.createElement("tspan", { key: text, x: x, y: y, height: lineHeight.toString() + "px" }, tags)); | ||
} | ||
function getBaselineAdjustment(d) { | ||
@@ -133,0 +151,0 @@ if (d === "up") { |
@@ -86,3 +86,8 @@ export function createSVG(image, pixelWidth, pixelHeight) { | ||
height: lineHeight_1.toString() + "px" | ||
}, [t]); | ||
}, [ | ||
t | ||
.replace("<sub>", "<tspan style=\"font-size: " + component.fontSize * | ||
0.8 + "px\" baseline-shift=\"sub\">") | ||
.replace("</sub>", "</tspan>") | ||
]); | ||
}); | ||
@@ -89,0 +94,0 @@ var cs = []; |
{ | ||
"name": "abstract-image", | ||
"version": "2.2.4", | ||
"version": "2.2.5", | ||
"description": "Dynamically create images using code or JSX and render to any format", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169427
2263