forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitter-text.d.ts
103 lines (92 loc) · 3.78 KB
/
twitter-text.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Type definitions for twitter-text v1.13.4
// Project: https://github.com/twitter/twitter-text
// Definitions by: rhysd <https://rhysd.github.io>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "twitter-text" {
export interface HashtagWithIndices {
hashtag: string;
indices: [number, number];
}
export interface UrlWithIndices {
url: string;
indices: [number, number];
}
export interface MentionWithIndices {
screenName: string;
indices: [number, number];
}
export interface MentionOrListWithIndices {
screenName: string;
listSlug: string;
indices: [number, number];
}
export interface CashtagWithIndices {
cashtag: string;
indices: [number, number];
}
export type EntityWithIndices =
HashtagWithIndices |
UrlWithIndices |
MentionWithIndices |
MentionOrListWithIndices |
CashtagWithIndices;
interface Indices {
indices: [number, number];
}
export function htmlEscape(text: string): string;
export function splitTags(text: string): string[];
export function extractHashtags(text: string): string[];
export function extractHashtagsWithIndices(text: string): HashtagWithIndices[];
export function extractUrls(text: string): string[];
export function extractUrlsWithIndices(text: string): UrlWithIndices[];
export function extractMentions(text: string): string[];
export function extractMentionsWithIndices(text: string): MentionWithIndices[];
export function extractMentionsOrListsWithIndices(text: string): MentionOrListWithIndices[];
export function extractReplies(text: string): string[];
export function extractCashtags(text: string): string[];
export function extractCashtagsWithIndices(text: string): CashtagWithIndices[];
export function extractEntitiesWithIndices(text: string): EntityWithIndices[];
export function modifyIndicesFromUnicodeToUTF16<I>(i: I): I;
export function modifyIndicesFromUTF16ToUnicode<I>(i: I): I;
export interface UrlEntity {
url: string;
display_url: string;
expanded_url: string;
indices: [number, number];
}
export interface AutoLinkOptions {
hashtagClass?: string;
hashtagUrlBase?: string;
cashtagClass?: string;
cashtagUrlBase?: string;
listClass?: string;
usernameClass?: string;
usernameUrlBase?: string;
listUrlBase?: string;
htmlAttrs?: string;
invisibleTagAttrs?: string;
htmlEscapeNonEntities?: boolean;
urlEntities?: UrlEntity[];
}
export function autoLink(text: string, options?: AutoLinkOptions): string;
export function autoLinkUsernamesOrLists(text: string, options?: AutoLinkOptions): string;
export function autoLinkHashtags(text: string, options?: AutoLinkOptions): string;
export function autoLinkCashtags(text: string, options?: AutoLinkOptions): string;
export function autoLinkUrlsCustom(text: string, options?: AutoLinkOptions): string;
export function autoLinkEntities(text: string, entities: EntityWithIndices[], options?: AutoLinkOptions): string;
interface TweetLengthOptions {
short_url_length: number;
short_url_length_https: number;
}
export function getTweetLength(text: string, options?: TweetLengthOptions): number;
export function isValidUsername(username: string): boolean;
export function isValidList(usernameList: string): boolean;
export function isValidHashtag(hashtag: string): boolean;
// Note: unicodeDomainsa and requireProtocol can be null
export function isValidUrl(url: string, unicodeDomains: boolean, requireProtocol: boolean): boolean;
export function isInvalidTweet(text: string): string;
export function getUnicodeTextLength(text: string): number;
// Note: This function directly modify entities" indices
export function convertUnicodeIndices(text: string, entities: EntityWithIndices[], indicesInUTF16?: boolean): void;
export function hitHighlight(text: string, hits?: number[][], options?: {tag: string}): string;
}