text-container.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.TextContainer = void 0;
  4. var text_1 = require("../css/layout/text");
  5. var TextContainer = /** @class */ (function () {
  6. function TextContainer(context, node, styles) {
  7. this.text = transform(node.data, styles.textTransform);
  8. this.textBounds = text_1.parseTextBounds(context, this.text, styles, node);
  9. }
  10. return TextContainer;
  11. }());
  12. exports.TextContainer = TextContainer;
  13. var transform = function (text, transform) {
  14. switch (transform) {
  15. case 1 /* LOWERCASE */:
  16. return text.toLowerCase();
  17. case 3 /* CAPITALIZE */:
  18. return text.replace(CAPITALIZE, capitalize);
  19. case 2 /* UPPERCASE */:
  20. return text.toUpperCase();
  21. default:
  22. return text;
  23. }
  24. };
  25. var CAPITALIZE = /(^|\s|:|-|\(|\))([a-z])/g;
  26. var capitalize = function (m, p1, p2) {
  27. if (m.length > 0) {
  28. return p1 + p2.toUpperCase();
  29. }
  30. return m;
  31. };
  32. //# sourceMappingURL=text-container.js.map