UNPKG

2.34 kBTypeScriptView Raw
1import { BidiDirection } from './UnicodeBidiDirection';
2
3/**
4 * Basic (stateless) API for text direction detection
5 *
6 * Part of our implementation of Unicode Bidirectional Algorithm (UBA)
7 * Unicode Standard Annex #9 (UAX9)
8 * http://www.unicode.org/reports/tr9/
9 */
10declare namespace UnicodeBidi {
11 /**
12 * Returns the first strong character (has Bidi_Class value of L, R, or AL).
13 */
14 function firstStrongChar(str: string): string | null | undefined;
15 /**
16 * Returns the direction of a block of text, based on the direction of its
17 * first strong character (has Bidi_Class value of L, R, or AL).
18 */
19 function firstStrongCharDir(str: string): BidiDirection;
20 /**
21 * Returns the direction of a block of text, based on the direction of its
22 * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
23 * direction, if no strong character is found.
24 *
25 * This function is supposed to be used in respect to Higher-Level Protocol
26 * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
27 */
28 function resolveBlockDir(str: string, fallback: BidiDirection | null | undefined): BidiDirection;
29 /**
30 * Returns the direction of a block of text, based on the direction of its
31 * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
32 * direction, if no strong character is found.
33 *
34 * NOTE: This function is similar to resolveBlockDir(), but uses the global
35 * direction as the fallback, so it *always* returns a Strong direction,
36 * making it useful for integration in places that you need to make the final
37 * decision, like setting some CSS class.
38 *
39 * This function is supposed to be used in respect to Higher-Level Protocol
40 * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
41 */
42
43 function getDirection(str: string, strongFallback: BidiDirection | null): BidiDirection;
44 /**
45 * Returns true if getDirection(arguments...) returns LTR.
46 */
47 function isDirectionLTR(str: string, strongFallback: BidiDirection | null): boolean;
48 /**
49 * Returns true if getDirection(arguments...) returns RTL.
50 */
51 function isDirectionRTL(str: string, strongFallback: BidiDirection | null): boolean;
52}
53
54// tslint:disable-next-line export-just-namespace
55export = UnicodeBidi;