email-match.js 2.3 KB

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