Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit c417262

Browse files
committed
1 parent 97cad12 commit c417262

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+7008
-37
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@react-navigation/native": "^5.8.6",
1818
"@react-navigation/stack": "^5.12.3",
1919
"@reduxjs/toolkit": "^1.4.0",
20-
"autolinker": "^3.14.2",
20+
"autolinker": "./src/modules/autolinker",
2121
"expo": "~39.0.4",
2222
"expo-app-auth": "~9.2.0",
2323
"expo-av": "~8.6.0",
@@ -59,4 +59,4 @@
5959
"typescript": "~3.9.2"
6060
},
6161
"private": true
62-
}
62+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import { Match } from "./match/match";
2+
import { HtmlTag } from "./html-tag";
3+
import { TruncateConfigObj } from "./autolinker";
4+
/**
5+
* @protected
6+
* @class Autolinker.AnchorTagBuilder
7+
* @extends Object
8+
*
9+
* Builds anchor (<a>) tags for the Autolinker utility when a match is
10+
* found.
11+
*
12+
* Normally this class is instantiated, configured, and used internally by an
13+
* {@link Autolinker} instance, but may actually be used indirectly in a
14+
* {@link Autolinker#replaceFn replaceFn} to create {@link Autolinker.HtmlTag HtmlTag}
15+
* instances which may be modified before returning from the
16+
* {@link Autolinker#replaceFn replaceFn}. For example:
17+
*
18+
* var html = Autolinker.link( "Test google.com", {
19+
* replaceFn : function( match ) {
20+
* var tag = match.buildTag(); // returns an {@link Autolinker.HtmlTag} instance
21+
* tag.setAttr( 'rel', 'nofollow' );
22+
*
23+
* return tag;
24+
* }
25+
* } );
26+
*
27+
* // generated html:
28+
* // Test <a href="http://google.com" target="_blank" rel="nofollow">google.com</a>
29+
*/
30+
export declare class AnchorTagBuilder {
31+
/**
32+
* @cfg {Boolean} newWindow
33+
* @inheritdoc Autolinker#newWindow
34+
*/
35+
private readonly newWindow;
36+
/**
37+
* @cfg {Object} truncate
38+
* @inheritdoc Autolinker#truncate
39+
*/
40+
private readonly truncate;
41+
/**
42+
* @cfg {String} className
43+
* @inheritdoc Autolinker#className
44+
*/
45+
private readonly className;
46+
/**
47+
* @method constructor
48+
* @param {Object} [cfg] The configuration options for the AnchorTagBuilder instance, specified in an Object (map).
49+
*/
50+
constructor(cfg?: AnchorTagBuilderCfg);
51+
/**
52+
* Generates the actual anchor (&lt;a&gt;) tag to use in place of the
53+
* matched text, via its `match` object.
54+
*
55+
* @param {Autolinker.match.Match} match The Match instance to generate an
56+
* anchor tag from.
57+
* @return {Autolinker.HtmlTag} The HtmlTag instance for the anchor tag.
58+
*/
59+
build(match: Match): HtmlTag;
60+
/**
61+
* Creates the Object (map) of the HTML attributes for the anchor (&lt;a&gt;)
62+
* tag being generated.
63+
*
64+
* @protected
65+
* @param {Autolinker.match.Match} match The Match instance to generate an
66+
* anchor tag from.
67+
* @return {Object} A key/value Object (map) of the anchor tag's attributes.
68+
*/
69+
protected createAttrs(match: Match): {
70+
[attrName: string]: string;
71+
};
72+
/**
73+
* Creates the CSS class that will be used for a given anchor tag, based on
74+
* the `matchType` and the {@link #className} config.
75+
*
76+
* Example returns:
77+
*
78+
* - "" // no {@link #className}
79+
* - "myLink myLink-url" // url match
80+
* - "myLink myLink-email" // email match
81+
* - "myLink myLink-phone" // phone match
82+
* - "myLink myLink-hashtag" // hashtag match
83+
* - "myLink myLink-mention myLink-twitter" // mention match with Twitter service
84+
*
85+
* @protected
86+
* @param {Autolinker.match.Match} match The Match instance to generate an
87+
* anchor tag from.
88+
* @return {String} The CSS class string for the link. Example return:
89+
* "myLink myLink-url". If no {@link #className} was configured, returns
90+
* an empty string.
91+
*/
92+
protected createCssClass(match: Match): string;
93+
/**
94+
* Processes the `anchorText` by truncating the text according to the
95+
* {@link #truncate} config.
96+
*
97+
* @private
98+
* @param {String} anchorText The anchor tag's text (i.e. what will be
99+
* displayed).
100+
* @return {String} The processed `anchorText`.
101+
*/
102+
private processAnchorText;
103+
/**
104+
* Performs the truncation of the `anchorText` based on the {@link #truncate}
105+
* option. If the `anchorText` is longer than the length specified by the
106+
* {@link #truncate} option, the truncation is performed based on the
107+
* `location` property. See {@link #truncate} for details.
108+
*
109+
* @private
110+
* @param {String} anchorText The anchor tag's text (i.e. what will be
111+
* displayed).
112+
* @return {String} The truncated anchor text.
113+
*/
114+
private doTruncate;
115+
}
116+
export interface AnchorTagBuilderCfg {
117+
newWindow?: boolean;
118+
truncate?: TruncateConfigObj;
119+
className?: string;
120+
}

src/modules/autolinker/anchor-tag-builder.js

Lines changed: 176 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)