overtype 1.2.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,28 @@ export interface Stats {
41
41
  column: number;
42
42
  }
43
43
 
44
+ /**
45
+ * Toolbar button definition
46
+ */
47
+ export interface ToolbarButton {
48
+ /** Unique button identifier */
49
+ name: string;
50
+
51
+ /** SVG icon markup (optional for separator) */
52
+ icon?: string;
53
+
54
+ /** Button tooltip text (optional for separator) */
55
+ title?: string;
56
+
57
+ /** Button action callback (optional for separator) */
58
+ action?: (context: {
59
+ editor: OverType;
60
+ getValue: () => string;
61
+ setValue: (value: string) => void;
62
+ event: MouseEvent;
63
+ }) => void | Promise<void>;
64
+ }
65
+
44
66
  export interface MobileOptions {
45
67
  fontSize?: string;
46
68
  padding?: string;
@@ -71,17 +93,11 @@ export interface Options {
71
93
  // Features
72
94
  showActiveLineRaw?: boolean;
73
95
  showStats?: boolean;
74
- toolbar?: boolean | {
75
- buttons?: Array<{
76
- name?: string;
77
- icon?: string;
78
- title?: string;
79
- action?: string;
80
- separator?: boolean;
81
- }>;
82
- };
96
+ toolbar?: boolean;
97
+ toolbarButtons?: ToolbarButton[]; // Custom toolbar button configuration
83
98
  smartLists?: boolean; // v1.2.3+ Smart list continuation
84
99
  statsFormatter?: (stats: Stats) => string;
100
+ codeHighlighter?: ((code: string, language: string) => string) | null; // Per-instance code highlighter
85
101
 
86
102
  // Theme (deprecated in favor of global theme)
87
103
  theme?: string | Theme;
@@ -96,7 +112,7 @@ export interface Options {
96
112
  export interface OverTypeConstructor {
97
113
  new(target: string | Element | NodeList | Element[], options?: Options): OverTypeInstance[];
98
114
  // Static members
99
- instances: WeakMap<Element, OverTypeInstance>;
115
+ instances: any;
100
116
  stylesInjected: boolean;
101
117
  globalListenersInitialized: boolean;
102
118
  instanceCount: number;
@@ -112,6 +128,7 @@ export interface OverTypeConstructor {
112
128
  destroyAll(): void;
113
129
  injectStyles(force?: boolean): void;
114
130
  setTheme(theme: string | Theme, customColors?: Partial<Theme['colors']>): void;
131
+ setCodeHighlighter(highlighter: ((code: string, language: string) => string) | null): void;
115
132
  initGlobalListeners(): void;
116
133
  getTheme(name: string): Theme;
117
134
  }
@@ -146,7 +163,8 @@ export interface OverTypeInstance {
146
163
  isInitialized(): boolean;
147
164
  reinit(options: Options): void;
148
165
  showStats(show: boolean): void;
149
- setTheme(theme: string | Theme): void;
166
+ setTheme(theme: string | Theme): this;
167
+ setCodeHighlighter(highlighter: ((code: string, language: string) => string) | null): void;
150
168
  updatePreview(): void;
151
169
 
152
170
  // HTML output methods
@@ -155,8 +173,9 @@ export interface OverTypeInstance {
155
173
  getPreviewHTML(): string;
156
174
 
157
175
  // View mode methods
158
- showPlainTextarea(show: boolean): void;
159
- showPreviewMode(show: boolean): void;
176
+ showNormalEditMode(): this;
177
+ showPlainTextarea(): this;
178
+ showPreviewMode(): this;
160
179
  }
161
180
 
162
181
  // Declare the constructor as a constant with proper typing
@@ -166,4 +185,28 @@ declare const OverType: OverTypeConstructor;
166
185
  export type OverType = OverTypeInstance;
167
186
 
168
187
  // Module exports - default export is the constructor
169
- export default OverType;
188
+ export default OverType;
189
+
190
+ /**
191
+ * Pre-defined toolbar buttons
192
+ */
193
+ export const toolbarButtons: {
194
+ bold: ToolbarButton;
195
+ italic: ToolbarButton;
196
+ code: ToolbarButton;
197
+ separator: ToolbarButton;
198
+ link: ToolbarButton;
199
+ h1: ToolbarButton;
200
+ h2: ToolbarButton;
201
+ h3: ToolbarButton;
202
+ bulletList: ToolbarButton;
203
+ orderedList: ToolbarButton;
204
+ taskList: ToolbarButton;
205
+ quote: ToolbarButton;
206
+ viewMode: ToolbarButton;
207
+ };
208
+
209
+ /**
210
+ * Default toolbar button layout with separators
211
+ */
212
+ export const defaultToolbarButtons: ToolbarButton[];