Refactor code language and ts types (#9300)

* 🎨 Code block language list adds custom languages

* Update index.d.ts

* 🎨 Improve global variable type definition

* 🎨 Improve global variable type definition

* 🎨 Add constant `EXTRA_CODE_LANGUAGES`
This commit is contained in:
Yingyi / 颖逸 2023-09-28 22:38:49 +08:00 committed by GitHub
parent 17d2a16a94
commit b2a27bb54c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 86 additions and 72 deletions

View file

@ -81,6 +81,15 @@ type TAVFilterOperator =
declare module "blueimp-md5"
interface Window {
ABCJS?: IABCJS
Viewer?: Function
Viz?: IViz
echarts?: IECharts
hljs?: IHLJS
katex?: IKaTeX
mermaid?: IMermaid
plantumlEncoder?: IPlantumlEncoder
pdfjsLib: any
dataLayer: any[]
siyuan: ISiyuan

View file

@ -1,15 +1,13 @@
declare const echarts: {
init(element: HTMLElement, theme?: string, options?: { width: number }): IEChart;
dispose(element: Element): void;
getInstanceById(id: string): { resize: () => void };
};
interface IABCJS {
renderAbc(element: Element, text: string, options: { responsive: string }): void;
}
declare const hljs: {
highlight(text: string, options: { language?: string, ignoreIllegals: boolean }): { value: string };
getLanguage(text: string): { name: string };
};
interface IViz {
new(worker: { worker: Worker }): IViz;
renderSVGElement: (code: string) => Promise<any>;
}
interface IEChart {
interface IEChartsInstance {
setOption(option: any): void;
getZr(): any;
@ -21,6 +19,37 @@ interface IEChart {
resize(): void;
}
interface IECharts {
init(element: HTMLElement, theme?: string, options?: { width: number }): IEChartsInstance;
dispose(element: Element): void;
getInstanceById(id: string): { resize: () => void };
}
interface IHLJS {
highlight(text: string, options: { language?: string, ignoreIllegals: boolean }): { value: string };
getLanguage(text: string): { name: string };
listLanguages(): string[];
}
interface IKaTeX {
renderToString(math: string, option: {
displayMode: boolean;
output: string;
macros: IObject;
trust: boolean;
strict: (errorCode: string) => "ignore" | "warn";
}): string;
}
interface IMermaid {
initialize(options: any): void;
init(options: any, element: Element): void;
}
interface IPlantumlEncoder {
encode(options: string): string;
}
interface ILuteNode {
TokensStr: () => string;
__internal_object__: {