mention-match.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { MentionService } from '../parser/mention-utils';
  2. import { AbstractMatch, AbstractMatchConfig } from './abstract-match';
  3. /**
  4. * @class Autolinker.match.Mention
  5. * @extends Autolinker.match.AbstractMatch
  6. *
  7. * Represents a Mention 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. export declare class MentionMatch extends AbstractMatch {
  12. /**
  13. * @public
  14. * @property {'mention'} type
  15. *
  16. * A string name for the type of match that this class represents. Can be
  17. * used in a TypeScript discriminating union to type-narrow from the
  18. * `Match` type.
  19. */
  20. readonly type: 'mention';
  21. /**
  22. * @cfg {String} serviceName
  23. *
  24. * The service to point mention matches to. See {@link Autolinker#mention}
  25. * for available values.
  26. */
  27. private readonly serviceName;
  28. /**
  29. * @cfg {String} mention (required)
  30. *
  31. * The Mention that was matched, without the '@' character.
  32. */
  33. private readonly mention;
  34. /**
  35. * @method constructor
  36. * @param {Object} cfg The configuration properties for the Match
  37. * instance, specified in an Object (map).
  38. */
  39. constructor(cfg: MentionMatchConfig);
  40. /**
  41. * Returns a string name for the type of match that this class represents.
  42. * For the case of MentionMatch, returns 'mention'.
  43. *
  44. * @return {String}
  45. */
  46. getType(): 'mention';
  47. /**
  48. * Returns the mention, without the '@' character.
  49. *
  50. * @return {String}
  51. */
  52. getMention(): string;
  53. /**
  54. * Returns the configured {@link #serviceName} to point the mention to.
  55. * Ex: 'instagram', 'twitter', 'soundcloud'.
  56. *
  57. * @return {String}
  58. */
  59. getServiceName(): MentionService;
  60. /**
  61. * Returns the anchor href that should be generated for the match.
  62. *
  63. * @return {String}
  64. */
  65. getAnchorHref(): string;
  66. /**
  67. * Returns the anchor text that should be generated for the match.
  68. *
  69. * @return {String}
  70. */
  71. getAnchorText(): string;
  72. /**
  73. * Returns the CSS class suffixes that should be used on a tag built with
  74. * the match. See {@link Autolinker.match.Match#getCssClassSuffixes} for
  75. * details.
  76. *
  77. * @return {String[]}
  78. */
  79. getCssClassSuffixes(): string[];
  80. }
  81. export interface MentionMatchConfig extends AbstractMatchConfig {
  82. serviceName: MentionService;
  83. mention: string;
  84. }