rangy
rangy copied to clipboard
Add support for CSS text-transform
I see that CSS text-transform is one of the "factors that are not [currently] taken into consideration" in the Text Range Module.
Can support be added for this? e.g. Using something like the following code:
function transformText(string, parentElement) {
var computedStyle = window.getComputedStyle(parentElement);
switch (computedStyle["text-transform"]) {
case "capitalize":
return string.replace(/\b\w/g, function (match) {
return match.toUpperCase();
});
case "uppercase":
return string.replace(/\w/g, function (match) {
return match.toUpperCase();
});
case "lowercase":
return string.replace(/\w/g, function (match) {
return match.toLowerCase();
});
case "none":
default:
return string;
}
}