rangy icon indicating copy to clipboard operation
rangy copied to clipboard

Add support for CSS text-transform

Open mfulton26 opened this issue 7 years ago • 0 comments

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;
  }
}

mfulton26 avatar Apr 20 '18 12:04 mfulton26