tooot/src/modules/autolinker/match/match.js.map

1 line
7.2 KiB
Plaintext

{"version":3,"sources":["../src/match/match.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;IA4BC;;;;;OAKG;IACH,eAAa,GAAgB;QAhC7B;;;;;WAKG;QACK,yBAAoB,GAAG,IAAI,CAAC,CAAE,kGAAkG;QAKxI;;;;WAIG;QACgB,gBAAW,GAAW,EAAE,CAAC,CAAE,gGAAgG;QAE9I;;;;WAIG;QACK,WAAM,GAAW,CAAC,CAAC,CAAE,gGAAgG;QAU5H,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC1B,CAAC;IAYD;;;;OAIG;IACH,8BAAc,GAAd;QACC,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAGD;;;;;;;;;;;OAWG;IACH,yBAAS,GAAT,UAAW,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAGD;;;;;OAKG;IACH,yBAAS,GAAT;QACC,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAqBD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,mCAAmB,GAAnB;QACC,OAAO,CAAE,IAAI,CAAC,OAAO,EAAE,CAAE,CAAC;IAC3B,CAAC;IAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,wBAAQ,GAAR;QACC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAE,IAAI,CAAE,CAAC;IACtC,CAAC;IAEF,YAAC;AAAD,CArKA,AAqKC,IAAA","file":"match.js","sourcesContent":["import { AnchorTagBuilder } from \"../anchor-tag-builder\";\n\n/**\n * @abstract\n * @class Autolinker.match.Match\n *\n * Represents a match found in an input string which should be Autolinked. A Match object is what is provided in a\n * {@link Autolinker#replaceFn replaceFn}, and may be used to query for details about the match.\n *\n * For example:\n *\n * var input = \"...\"; // string with URLs, Email Addresses, and Mentions (Twitter, Instagram, Soundcloud)\n *\n * var linkedText = Autolinker.link( input, {\n * replaceFn : function( match ) {\n * console.log( \"href = \", match.getAnchorHref() );\n * console.log( \"text = \", match.getAnchorText() );\n *\n * switch( match.getType() ) {\n * case 'url' :\n * console.log( \"url: \", match.getUrl() );\n *\n * case 'email' :\n * console.log( \"email: \", match.getEmail() );\n *\n * case 'mention' :\n * console.log( \"mention: \", match.getMention() );\n * }\n * }\n * } );\n *\n * See the {@link Autolinker} class for more details on using the {@link Autolinker#replaceFn replaceFn}.\n */\nexport abstract class Match {\n\n\t/**\n\t * @cfg {Autolinker.AnchorTagBuilder} tagBuilder (required)\n\t *\n\t * Reference to the AnchorTagBuilder instance to use to generate an anchor\n\t * tag for the Match.\n\t */\n\tprivate __jsduckDummyDocProp = null; // property used just to get the above doc comment into the ES5 output and documentation generator\n\n\t// Actual property for the above jsdoc comment\n\tprivate readonly tagBuilder: AnchorTagBuilder;\n\n\t/**\n\t * @cfg {String} matchedText (required)\n\t *\n\t * The original text that was matched by the {@link Autolinker.matcher.Matcher}.\n\t */\n\tprotected readonly matchedText: string = ''; // default value just to get the above doc comment in the ES5 output and documentation generator\n\n\t/**\n\t * @cfg {Number} offset (required)\n\t *\n\t * The offset of where the match was made in the input string.\n\t */\n\tprivate offset: number = 0; // default value just to get the above doc comment in the ES5 output and documentation generator\n\n\n\t/**\n\t * @member Autolinker.match.Match\n\t * @method constructor\n\t * @param {Object} cfg The configuration properties for the Match\n\t * instance, specified in an Object (map).\n\t */\n\tconstructor( cfg: MatchConfig ) {\n\t\tthis.tagBuilder = cfg.tagBuilder;\n\t\tthis.matchedText = cfg.matchedText;\n\t\tthis.offset = cfg.offset;\n\t}\n\n\n\t/**\n\t * Returns a string name for the type of match that this class represents.\n\t *\n\t * @abstract\n\t * @return {String}\n\t */\n\tabstract getType(): string;\n\n\n\t/**\n\t * Returns the original text that was matched.\n\t *\n\t * @return {String}\n\t */\n\tgetMatchedText() {\n\t\treturn this.matchedText;\n\t}\n\n\n\t/**\n\t * Sets the {@link #offset} of where the match was made in the input string.\n\t *\n\t * A {@link Autolinker.matcher.Matcher} will be fed only HTML text nodes,\n\t * and will therefore set an original offset that is relative to the HTML\n\t * text node itself. However, we want this offset to be relative to the full\n\t * HTML input string, and thus if using {@link Autolinker#parse} (rather\n\t * than calling a {@link Autolinker.matcher.Matcher} directly), then this\n\t * offset is corrected after the Matcher itself has done its job.\n\t *\n\t * @param {Number} offset\n\t */\n\tsetOffset( offset: number ) {\n\t\tthis.offset = offset;\n\t}\n\n\n\t/**\n\t * Returns the offset of where the match was made in the input string. This\n\t * is the 0-based index of the match.\n\t *\n\t * @return {Number}\n\t */\n\tgetOffset() {\n\t\treturn this.offset;\n\t}\n\n\n\t/**\n\t * Returns the anchor href that should be generated for the match.\n\t *\n\t * @abstract\n\t * @return {String}\n\t */\n\tabstract getAnchorHref(): string;\n\n\n\t/**\n\t * Returns the anchor text that should be generated for the match.\n\t *\n\t * @abstract\n\t * @return {String}\n\t */\n\tabstract getAnchorText(): string;\n\n\n\t/**\n\t * Returns the CSS class suffix(es) for this match.\n\t *\n\t * A CSS class suffix is appended to the {@link Autolinker#className} in\n\t * the {@link Autolinker.AnchorTagBuilder} when a match is translated into\n\t * an anchor tag.\n\t *\n\t * For example, if {@link Autolinker#className} was configured as 'myLink',\n\t * and this method returns `[ 'url' ]`, the final class name of the element\n\t * will become: 'myLink myLink-url'.\n\t *\n\t * The match may provide multiple CSS class suffixes to be appended to the\n\t * {@link Autolinker#className} in order to facilitate better styling\n\t * options for different match criteria. See {@link Autolinker.match.Mention}\n\t * for an example.\n\t *\n\t * By default, this method returns a single array with the match's\n\t * {@link #getType type} name, but may be overridden by subclasses.\n\t *\n\t * @return {String[]}\n\t */\n\tgetCssClassSuffixes() {\n\t\treturn [ this.getType() ];\n\t}\n\n\n\t/**\n\t * Builds and returns an {@link Autolinker.HtmlTag} instance based on the\n\t * Match.\n\t *\n\t * This can be used to easily generate anchor tags from matches, and either\n\t * return their HTML string, or modify them before doing so.\n\t *\n\t * Example Usage:\n\t *\n\t * var tag = match.buildTag();\n\t * tag.addClass( 'cordova-link' );\n\t * tag.setAttr( 'target', '_system' );\n\t *\n\t * tag.toAnchorString(); // <a href=\"http://google.com\" class=\"cordova-link\" target=\"_system\">Google</a>\n\t * \n\t * Example Usage in {@link Autolinker#replaceFn}:\n\t *\n\t * var html = Autolinker.link( \"Test google.com\", {\n\t * replaceFn : function( match ) {\n\t * var tag = match.buildTag(); // returns an {@link Autolinker.HtmlTag} instance\n\t * tag.setAttr( 'rel', 'nofollow' );\n\t *\n\t * return tag;\n\t * }\n\t * } );\n\t *\n\t * // generated html:\n\t * // Test <a href=\"http://google.com\" target=\"_blank\" rel=\"nofollow\">google.com</a>\n\t */\n\tbuildTag() {\n\t\treturn this.tagBuilder.build( this );\n\t}\n\n}\n\nexport interface MatchConfig {\n\ttagBuilder: AnchorTagBuilder;\n\tmatchedText: string;\n\toffset: number;\n}\n"]}