-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c70bfc8
commit 688cd01
Showing
1 changed file
with
71 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,71 @@ | ||
export default anchor; | ||
declare function anchor(md: any, opts: any): void; | ||
declare namespace anchor { | ||
export { permalink }; | ||
export namespace defaults { | ||
export const level: number; | ||
export { slugify }; | ||
export const uniqueSlugStartIndex: number; | ||
export const tabIndex: string; | ||
export { getTokensText }; | ||
const permalink_1: boolean; | ||
export { permalink_1 as permalink }; | ||
export const renderPermalink: typeof import("./permalink").legacy; | ||
export const permalinkClass: string; | ||
export const permalinkSpace: any; | ||
export const permalinkSymbol: string; | ||
export const permalinkBefore: boolean; | ||
export const permalinkHref: typeof import("./permalink").renderHref; | ||
export const permalinkAttrs: typeof import("./permalink").renderAttrs; | ||
} | ||
export { anchor as default }; | ||
} | ||
import * as permalink from "./permalink"; | ||
declare function slugify(s: any): string; | ||
declare function getTokensText(tokens: any): any; | ||
import MarkdownIt from 'markdown-it'; | ||
import Token from 'markdown-it/lib/token.mjs'; | ||
import State from 'markdown-it/lib/rules_core/state_core.mjs'; | ||
|
||
declare namespace anchor { | ||
export type RenderHref = (slug: string, state: State) => string; | ||
export type RenderAttrs = (slug: string, state: State) => Record<string, string | number>; | ||
|
||
export interface PermalinkOptions { | ||
class?: string, | ||
symbol?: string, | ||
renderHref?: RenderHref, | ||
renderAttrs?: RenderAttrs | ||
} | ||
|
||
export interface HeaderLinkPermalinkOptions extends PermalinkOptions { | ||
safariReaderFix?: boolean; | ||
} | ||
|
||
export interface LinkAfterHeaderPermalinkOptions extends PermalinkOptions { | ||
style?: 'visually-hidden' | 'aria-label' | 'aria-describedby' | 'aria-labelledby', | ||
assistiveText?: (title: string) => string, | ||
visuallyHiddenClass?: string, | ||
space?: boolean | string, | ||
placement?: 'before' | 'after' | ||
wrapper?: [string, string] | null | ||
} | ||
|
||
export interface LinkInsideHeaderPermalinkOptions extends PermalinkOptions { | ||
space?: boolean | string, | ||
placement?: 'before' | 'after', | ||
ariaHidden?: boolean | ||
} | ||
|
||
export interface AriaHiddenPermalinkOptions extends PermalinkOptions { | ||
space?: boolean | string, | ||
placement?: 'before' | 'after' | ||
} | ||
|
||
export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: State, index: number) => void; | ||
|
||
export interface AnchorInfo { | ||
slug: string; | ||
title: string; | ||
} | ||
|
||
export interface AnchorOptions { | ||
level?: number | number[]; | ||
|
||
slugify?(str: string): string; | ||
getTokensText?(tokens: Token[]): string; | ||
|
||
uniqueSlugStartIndex?: number; | ||
permalink?: PermalinkGenerator; | ||
|
||
callback?(token: Token, anchor_info: AnchorInfo): void; | ||
|
||
tabIndex?: number | false; | ||
} | ||
|
||
export const permalink: { | ||
headerLink: (opts?: HeaderLinkPermalinkOptions) => PermalinkGenerator | ||
linkAfterHeader: (opts?: LinkAfterHeaderPermalinkOptions) => PermalinkGenerator | ||
linkInsideHeader: (opts?: LinkInsideHeaderPermalinkOptions) => PermalinkGenerator | ||
ariaHidden: (opts?: AriaHiddenPermalinkOptions) => PermalinkGenerator | ||
}; | ||
} | ||
|
||
declare function anchor(md: MarkdownIt, opts?: anchor.AnchorOptions): void; | ||
|
||
export default anchor; |