1 | import MarkdownIt from 'markdown-it';
|
2 | import Token from 'markdown-it/lib/token.mjs';
|
3 | import State from 'markdown-it/lib/rules_core/state_core.mjs';
|
4 |
|
5 | declare namespace anchor {
|
6 | export type RenderHref = (slug: string, state: State) => string;
|
7 | export type RenderAttrs = (slug: string, state: State) => Record<string, string | number>;
|
8 |
|
9 | export interface PermalinkOptions {
|
10 | class?: string,
|
11 | symbol?: string,
|
12 | renderHref?: RenderHref,
|
13 | renderAttrs?: RenderAttrs
|
14 | }
|
15 |
|
16 | export interface HeaderLinkPermalinkOptions extends PermalinkOptions {
|
17 | safariReaderFix?: boolean;
|
18 | }
|
19 |
|
20 | export interface LinkAfterHeaderPermalinkOptions extends PermalinkOptions {
|
21 | style?: 'visually-hidden' | 'aria-label' | 'aria-describedby' | 'aria-labelledby',
|
22 | assistiveText?: (title: string) => string,
|
23 | visuallyHiddenClass?: string,
|
24 | space?: boolean | string,
|
25 | placement?: 'before' | 'after'
|
26 | wrapper?: [string, string] | null
|
27 | }
|
28 |
|
29 | export interface LinkInsideHeaderPermalinkOptions extends PermalinkOptions {
|
30 | space?: boolean | string,
|
31 | placement?: 'before' | 'after',
|
32 | ariaHidden?: boolean
|
33 | }
|
34 |
|
35 | export interface AriaHiddenPermalinkOptions extends PermalinkOptions {
|
36 | space?: boolean | string,
|
37 | placement?: 'before' | 'after'
|
38 | }
|
39 |
|
40 | export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: State, index: number) => void;
|
41 |
|
42 | export interface AnchorInfo {
|
43 | slug: string;
|
44 | title: string;
|
45 | }
|
46 |
|
47 | export interface AnchorOptions {
|
48 | level?: number | number[];
|
49 |
|
50 | slugify?(str: string): string;
|
51 | slugifyWithState?(str: string, state: State): string;
|
52 | getTokensText?(tokens: Token[]): string;
|
53 |
|
54 | uniqueSlugStartIndex?: number;
|
55 | permalink?: PermalinkGenerator;
|
56 |
|
57 | callback?(token: Token, anchor_info: AnchorInfo): void;
|
58 |
|
59 | tabIndex?: number | false;
|
60 | }
|
61 |
|
62 | export const permalink: {
|
63 | headerLink: (opts?: HeaderLinkPermalinkOptions) => PermalinkGenerator
|
64 | linkAfterHeader: (opts?: LinkAfterHeaderPermalinkOptions) => PermalinkGenerator
|
65 | linkInsideHeader: (opts?: LinkInsideHeaderPermalinkOptions) => PermalinkGenerator
|
66 | ariaHidden: (opts?: AriaHiddenPermalinkOptions) => PermalinkGenerator
|
67 | };
|
68 | }
|
69 |
|
70 | declare function anchor(md: MarkdownIt, opts?: anchor.AnchorOptions): void;
|
71 |
|
72 | export default anchor;
|