email-match.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { __extends } from "tslib";
  2. import { AbstractMatch } from './abstract-match';
  3. /**
  4. * @class Autolinker.match.Email
  5. * @extends Autolinker.match.AbstractMatch
  6. *
  7. * Represents a Email match found in an input string which should be Autolinked.
  8. *
  9. * See this class's superclass ({@link Autolinker.match.Match}) for more details.
  10. */
  11. var EmailMatch = /** @class */ (function (_super) {
  12. __extends(EmailMatch, _super);
  13. /**
  14. * @method constructor
  15. * @param {Object} cfg The configuration properties for the Match
  16. * instance, specified in an Object (map).
  17. */
  18. function EmailMatch(cfg) {
  19. var _this = _super.call(this, cfg) || this;
  20. /**
  21. * @public
  22. * @property {'email'} type
  23. *
  24. * A string name for the type of match that this class represents. Can be
  25. * used in a TypeScript discriminating union to type-narrow from the
  26. * `Match` type.
  27. */
  28. _this.type = 'email';
  29. /**
  30. * @cfg {String} email (required)
  31. *
  32. * The email address that was matched.
  33. */
  34. _this.email = ''; // default value just to get the above doc comment in the ES5 output and documentation generator
  35. _this.email = cfg.email;
  36. return _this;
  37. }
  38. /**
  39. * Returns a string name for the type of match that this class represents.
  40. * For the case of EmailMatch, returns 'email'.
  41. *
  42. * @return {String}
  43. */
  44. EmailMatch.prototype.getType = function () {
  45. return 'email';
  46. };
  47. /**
  48. * Returns the email address that was matched.
  49. *
  50. * @return {String}
  51. */
  52. EmailMatch.prototype.getEmail = function () {
  53. return this.email;
  54. };
  55. /**
  56. * Returns the anchor href that should be generated for the match.
  57. *
  58. * @return {String}
  59. */
  60. EmailMatch.prototype.getAnchorHref = function () {
  61. return 'mailto:' + this.email;
  62. };
  63. /**
  64. * Returns the anchor text that should be generated for the match.
  65. *
  66. * @return {String}
  67. */
  68. EmailMatch.prototype.getAnchorText = function () {
  69. return this.email;
  70. };
  71. return EmailMatch;
  72. }(AbstractMatch));
  73. export { EmailMatch };
  74. //# sourceMappingURL=email-match.js.map