| 1 |
import { Matcher, MatcherConfig } from './matcher'; |
| 2 |
import { MentionServices } from '../autolinker'; |
| 3 |
import { Match } from '../match/match'; |
| 4 |
/** |
| 5 |
* @class Autolinker.matcher.Mention |
| 6 |
* @extends Autolinker.matcher.Matcher |
| 7 |
* |
| 8 |
* Matcher to find/replace username matches in an input string. |
| 9 |
*/ |
| 10 |
export declare class MentionMatcher extends Matcher { |
| 11 |
/** |
| 12 |
* @cfg {'twitter'/'instagram'/'soundcloud'} protected |
| 13 |
* |
| 14 |
* The name of service to link @mentions to. |
| 15 |
* |
| 16 |
* Valid values are: 'twitter', 'instagram', 'soundcloud', or 'tiktok' |
| 17 |
*/ |
| 18 |
protected serviceName: MentionServices; |
| 19 |
/** |
| 20 |
* Hash of regular expression to match username handles. Example match: |
| 21 |
* |
| 22 |
* @asdf |
| 23 |
* |
| 24 |
* @private |
| 25 |
* @property {Object} matcherRegexes |
| 26 |
*/ |
| 27 |
protected readonly matcherRegexes: { |
| 28 |
[key: string]: RegExp; |
| 29 |
}; |
| 30 |
/** |
| 31 |
* The regular expression to use to check the character before a username match to |
| 32 |
* make sure we didn't accidentally match an email address. |
| 33 |
* |
| 34 |
* For example, the string "[email protected]" should not match "@asdf" as a username. |
| 35 |
* |
| 36 |
* @private |
| 37 |
* @property {RegExp} nonWordCharRegex |
| 38 |
*/ |
| 39 |
protected readonly nonWordCharRegex: RegExp; |
| 40 |
/** |
| 41 |
* @method constructor |
| 42 |
* @param {Object} cfg The configuration properties for the Match instance, |
| 43 |
* specified in an Object (map). |
| 44 |
*/ |
| 45 |
constructor(cfg: MentionMatcherConfig); |
| 46 |
/** |
| 47 |
* @inheritdoc |
| 48 |
*/ |
| 49 |
parseMatches(text: string): Match[]; |
| 50 |
} |
| 51 |
export interface MentionMatcherConfig extends MatcherConfig { |
| 52 |
serviceName: MentionServices; |
| 53 |
} |