Skip to content

Commit

Permalink
Restore types file
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriangalliat committed Aug 24, 2024
1 parent c70bfc8 commit 688cd01
Showing 1 changed file with 71 additions and 25 deletions.
96 changes: 71 additions & 25 deletions types/index.d.ts
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;

0 comments on commit 688cd01

Please sign in to comment.