Repository navigation
Expand file tree
/
Copy pathreact-live.d.ts
More file actions
73 lines (59 loc) · 1.74 KB
/
Copy pathreact-live.d.ts
File metadata and controls
73 lines (59 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { ComponentClass, HTMLProps, ComponentType, Context } from "react";
import type { Options } from "sucrase";
import { PrismTheme, Language } from "prism-react-renderer";
// Helper types
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
// React Element Props
type DivProps = HTMLProps<HTMLDivElement>;
type PreProps = HTMLProps<HTMLPreElement>;
// LiveProvider
export type LiveProviderProps = Omit<DivProps, "scope"> & {
Context?: Context<ContextProps>;
transformOptions?: Options;
scope?: { [key: string]: any };
code?: string;
noInline?: boolean;
transformCode?: (code: string) => string | Promise<string>;
language?: Language;
disabled?: boolean;
theme?: PrismTheme;
};
export const theme: PrismTheme;
export const LiveProvider: ComponentClass<LiveProviderProps>;
// Editor
export type EditorProps = Omit<PreProps, "onChange"> & {
Context?: Context<ContextProps>;
code?: string;
disabled?: boolean;
language?: Language;
onChange?: (code: string) => void;
theme?: PrismTheme;
prism?: unknown;
};
export const Editor: ComponentClass<EditorProps>;
// Context
export interface ContextProps {
code?: string;
language?: Language;
theme: PrismTheme;
disabled?: boolean;
error?: string;
}
export const LiveContext: Context<ContextProps>;
// LiveEditor
export type LiveEditorProps = EditorProps;
export const LiveEditor: ComponentClass<
LiveEditorProps & { Context?: Context<ContextProps> }
>;
// LiveError
export const LiveError: ComponentClass<
DivProps & { Context?: Context<ContextProps> }
>;
// LivePreview
export const LivePreview: ComponentClass<
DivProps & { Context?: Context<ContextProps> }
>;
// withLive HOC
export function withLive<P>(
wrappedComponent: ComponentType<P>
): ComponentClass<P>;