Skip to content

Commit 6275239

Browse files
committed
Keep typedefs from overtype repo.
1 parent a107bd5 commit 6275239

File tree

1 file changed

+131
-24
lines changed

1 file changed

+131
-24
lines changed
Lines changed: 131 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,147 @@
1-
interface OverTypeOptions {
1+
// Type definitions for OverType
2+
// Project: https://github.com/panphora/overtype
3+
// Definitions generated from JSDoc comments and implementation
4+
5+
export interface Theme {
6+
name: string;
7+
colors: {
8+
bgPrimary?: string;
9+
bgSecondary?: string;
10+
text?: string;
11+
textSecondary?: string;
12+
h1?: string;
13+
h2?: string;
14+
h3?: string;
15+
strong?: string;
16+
em?: string;
17+
link?: string;
18+
code?: string;
19+
codeBg?: string;
20+
blockquote?: string;
21+
hr?: string;
22+
syntaxMarker?: string;
23+
listMarker?: string;
24+
cursor?: string;
25+
selection?: string;
26+
rawLine?: string;
27+
// Toolbar theme colors
28+
toolbarBg?: string;
29+
toolbarIcon?: string;
30+
toolbarHover?: string;
31+
toolbarActive?: string;
32+
border?: string;
33+
};
34+
}
35+
36+
export interface Stats {
37+
words: number;
38+
chars: number;
39+
lines: number;
40+
line: number;
41+
column: number;
42+
}
43+
44+
export interface MobileOptions {
245
fontSize?: string;
3-
lineHeight?: number;
46+
padding?: string;
47+
lineHeight?: string | number;
48+
}
49+
50+
export interface Options {
51+
// Typography
52+
fontSize?: string;
53+
lineHeight?: string | number;
454
fontFamily?: string;
5-
theme?: string | ThemeObject;
55+
padding?: string;
56+
57+
// Mobile responsive
58+
mobile?: MobileOptions;
59+
60+
// Native textarea attributes (v1.1.2+)
61+
textareaProps?: Record<string, any>;
62+
63+
// Behavior
664
autofocus?: boolean;
65+
autoResize?: boolean; // v1.1.2+ Auto-expand height with content
66+
minHeight?: string; // v1.1.2+ Minimum height for autoResize mode
67+
maxHeight?: string | null; // v1.1.2+ Maximum height for autoResize mode
768
placeholder?: string;
869
value?: string;
9-
autoResize?: boolean;
10-
minHeight?: string;
11-
maxHeight?: string;
12-
padding?: string;
70+
71+
// Features
72+
showActiveLineRaw?: boolean;
73+
showStats?: boolean;
1374
toolbar?: boolean;
14-
onChange?: (value: string) => void;
15-
onKeydown?: (event: KeyboardEvent) => void;
75+
statsFormatter?: (stats: Stats) => string;
76+
77+
// Theme (deprecated in favor of global theme)
78+
theme?: string | Theme;
79+
colors?: Partial<Theme['colors']>;
80+
81+
// Callbacks
82+
onChange?: (value: string, instance: OverTypeInstance) => void;
83+
onKeydown?: (event: KeyboardEvent, instance: OverTypeInstance) => void;
1684
}
1785

18-
interface ThemeObject {
19-
[key: string]: string;
86+
// Interface for constructor that returns array
87+
export interface OverTypeConstructor {
88+
new(target: string | Element | NodeList | Element[], options?: Options): OverTypeInstance[];
89+
// Static members
90+
instances: WeakMap<Element, OverTypeInstance>;
91+
stylesInjected: boolean;
92+
globalListenersInitialized: boolean;
93+
instanceCount: number;
94+
currentTheme: Theme;
95+
themes: {
96+
solar: Theme;
97+
cave: Theme;
98+
};
99+
MarkdownParser: any;
100+
ShortcutsManager: any;
101+
init(target: string | Element | NodeList | Element[], options?: Options): OverTypeInstance[];
102+
getInstance(element: Element): OverTypeInstance | null;
103+
destroyAll(): void;
104+
injectStyles(force?: boolean): void;
105+
setTheme(theme: string | Theme, customColors?: Partial<Theme['colors']>): void;
106+
initGlobalListeners(): void;
107+
getTheme(name: string): Theme;
20108
}
21109

22-
class OverType {
23-
constructor(
24-
target: string | Element | NodeList | Element[],
25-
options?: OverTypeOptions
26-
);
110+
export interface OverTypeInstance {
111+
// Public properties
112+
container: HTMLElement;
113+
wrapper: HTMLElement;
114+
textarea: HTMLTextAreaElement;
115+
preview: HTMLElement;
116+
statsBar?: HTMLElement;
117+
toolbar?: any; // Toolbar instance
118+
shortcuts?: any; // ShortcutsManager instance
119+
linkTooltip?: any; // LinkTooltip instance
120+
options: Options;
121+
initialized: boolean;
122+
instanceId: number;
123+
element: Element;
27124

125+
// Public methods
28126
getValue(): string;
29127
setValue(value: string): void;
30-
getRenderedHTML(processContent?: boolean): string;
31-
getPreviewHTML(): string;
32-
static setTheme(theme: string | ThemeObject): void;
128+
getStats(): Stats;
129+
getContainer(): HTMLElement;
130+
focus(): void;
131+
blur(): void;
132+
destroy(): void;
133+
isInitialized(): boolean;
134+
reinit(options: Options): void;
33135
showStats(show: boolean): void;
34-
showPlainTextarea(show: boolean): void;
35-
showPreviewMode(show: boolean): void;
36-
37-
static init(selector: string, options?: OverTypeOptions): OverType[];
136+
setTheme(theme: string | Theme): void;
137+
updatePreview(): void;
38138
}
39139

40-
export = OverType;
140+
// Declare the constructor as a constant with proper typing
141+
declare const OverType: OverTypeConstructor;
142+
143+
// Export the instance type under a different name for clarity
144+
export type OverType = OverTypeInstance;
145+
146+
// Module exports - default export is the constructor
147+
export default OverType;

0 commit comments

Comments
 (0)