@pfmcodes/caret 0.1.1 → 0.1.3

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.
@@ -0,0 +1,347 @@
1
+ /**
2
+ * Caret Editor - Comprehensive Type Definitions
3
+ * Extended types for internal structures and utilities
4
+ */
5
+
6
+ /**
7
+ * Internal DOM element IDs used by the Caret editor
8
+ */
9
+ export const enum CaretElementIds {
10
+ TEXTAREA = "Caret-textarea",
11
+ HIGHLIGHTED = "Caret-highlighted",
12
+ CARET = "Caret-caret",
13
+ LINE_COUNTER = "Caret-lineCounter",
14
+ THEME = "Caret-theme"
15
+ }
16
+
17
+ /**
18
+ * CSS class names used by the Caret editor
19
+ */
20
+ export const enum CaretClassNames {
21
+ LINE_NUMBER = "Caret-lineCounter-number"
22
+ }
23
+
24
+ /**
25
+ * Default editor dimensions
26
+ */
27
+ export interface EditorDimensions {
28
+ width: string;
29
+ height: string;
30
+ }
31
+
32
+ /**
33
+ * Editor style configuration
34
+ */
35
+ export interface EditorStyle {
36
+ position: string;
37
+ width: string;
38
+ height: string;
39
+ overflow: string;
40
+ fontSize: string;
41
+ }
42
+
43
+ /**
44
+ * Theme configuration
45
+ */
46
+ export interface ThemeConfig {
47
+ /**
48
+ * Whether the theme is a dark theme
49
+ */
50
+ isDark: boolean;
51
+
52
+ /**
53
+ * Color for the caret
54
+ */
55
+ caretColor: string;
56
+
57
+ /**
58
+ * Color for line numbers
59
+ */
60
+ lineColor: string;
61
+
62
+ /**
63
+ * Path to the theme CSS file
64
+ */
65
+ themePath: string;
66
+ }
67
+
68
+ /**
69
+ * Caret position information
70
+ */
71
+ export interface CaretPosition {
72
+ /**
73
+ * Horizontal position in pixels
74
+ */
75
+ left: number;
76
+
77
+ /**
78
+ * Vertical position in pixels
79
+ */
80
+ top: number;
81
+
82
+ /**
83
+ * Height of the caret in pixels
84
+ */
85
+ height: number;
86
+ }
87
+
88
+ /**
89
+ * Text selection information
90
+ */
91
+ export interface TextSelection {
92
+ /**
93
+ * Start position of the selection
94
+ */
95
+ start: number;
96
+
97
+ /**
98
+ * End position of the selection
99
+ */
100
+ end: number;
101
+
102
+ /**
103
+ * Selected text content
104
+ */
105
+ text: string;
106
+ }
107
+
108
+ /**
109
+ * Line information for the editor
110
+ */
111
+ export interface LineInfo {
112
+ /**
113
+ * Line number (1-indexed)
114
+ */
115
+ lineNumber: number;
116
+
117
+ /**
118
+ * Line content
119
+ */
120
+ content: string;
121
+
122
+ /**
123
+ * Starting character index in the full text
124
+ */
125
+ startIndex: number;
126
+
127
+ /**
128
+ * Ending character index in the full text
129
+ */
130
+ endIndex: number;
131
+ }
132
+
133
+ /**
134
+ * Indentation configuration
135
+ */
136
+ export interface IndentConfig {
137
+ /**
138
+ * Indentation string (spaces or tab)
139
+ * @default " " (4 spaces)
140
+ */
141
+ indent: string;
142
+
143
+ /**
144
+ * Whether to use tabs instead of spaces
145
+ * @default false
146
+ */
147
+ useTabs?: boolean;
148
+
149
+ /**
150
+ * Number of spaces per indent level
151
+ * @default 4
152
+ */
153
+ tabSize?: number;
154
+ }
155
+
156
+ /**
157
+ * Event handlers for editor events
158
+ */
159
+ export interface CaretEditorEventHandlers {
160
+ /**
161
+ * Called when the editor content changes
162
+ */
163
+ onInput?: (value: string) => void;
164
+
165
+ /**
166
+ * Called when the editor gains focus
167
+ */
168
+ onFocus?: () => void;
169
+
170
+ /**
171
+ * Called when the editor loses focus
172
+ */
173
+ onBlur?: () => void;
174
+
175
+ /**
176
+ * Called when the editor is scrolled
177
+ */
178
+ onScroll?: (scrollLeft: number, scrollTop: number) => void;
179
+
180
+ /**
181
+ * Called when a key is pressed
182
+ */
183
+ onKeyDown?: (event: KeyboardEvent) => void;
184
+
185
+ /**
186
+ * Called when a key is released
187
+ */
188
+ onKeyUp?: (event: KeyboardEvent) => void;
189
+
190
+ /**
191
+ * Called when the caret position changes
192
+ */
193
+ onCaretMove?: (position: CaretPosition) => void;
194
+
195
+ /**
196
+ * Called when the text selection changes
197
+ */
198
+ onSelectionChange?: (selection: TextSelection) => void;
199
+ }
200
+
201
+ /**
202
+ * Extended configuration with event handlers and additional options
203
+ */
204
+ export interface ExtendedCaretEditorConfig extends CaretEditorConfig {
205
+ /**
206
+ * Event handlers
207
+ */
208
+ events?: CaretEditorEventHandlers;
209
+
210
+ /**
211
+ * Custom indentation settings
212
+ */
213
+ indentation?: IndentConfig;
214
+
215
+ /**
216
+ * Custom editor dimensions
217
+ */
218
+ dimensions?: EditorDimensions;
219
+
220
+ /**
221
+ * Whether to enable spell checking
222
+ * @default false
223
+ */
224
+ spellcheck?: boolean;
225
+
226
+ /**
227
+ * Whether to disable autocapitalization
228
+ * @default true
229
+ */
230
+ disableAutocapitalize?: boolean;
231
+
232
+ /**
233
+ * Whether to show line numbers
234
+ * @default true
235
+ */
236
+ showLineNumbers?: boolean;
237
+ }
238
+
239
+ /**
240
+ * Keyboard event information for Tab handling
241
+ */
242
+ export interface TabKeyEvent {
243
+ /**
244
+ * Whether Shift key was pressed
245
+ */
246
+ shiftKey: boolean;
247
+
248
+ /**
249
+ * Current cursor/selection start
250
+ */
251
+ selectionStart: number;
252
+
253
+ /**
254
+ * Current cursor/selection end
255
+ */
256
+ selectionEnd: number;
257
+
258
+ /**
259
+ * Current editor value
260
+ */
261
+ value: string;
262
+ }
263
+
264
+ /**
265
+ * Result of tab key processing
266
+ */
267
+ export interface TabKeyResult {
268
+ /**
269
+ * New value after indentation/unindentation
270
+ */
271
+ newValue: string;
272
+
273
+ /**
274
+ * New selection start position
275
+ */
276
+ newSelectionStart: number;
277
+
278
+ /**
279
+ * New selection end position
280
+ */
281
+ newSelectionEnd: number;
282
+ }
283
+
284
+ /**
285
+ * Utility type for Highlight.js language names
286
+ * Common languages - extend as needed
287
+ */
288
+ export type HighlightLanguage =
289
+ | "javascript"
290
+ | "typescript"
291
+ | "python"
292
+ | "java"
293
+ | "csharp"
294
+ | "cpp"
295
+ | "c"
296
+ | "go"
297
+ | "rust"
298
+ | "php"
299
+ | "ruby"
300
+ | "swift"
301
+ | "kotlin"
302
+ | "scala"
303
+ | "html"
304
+ | "css"
305
+ | "scss"
306
+ | "less"
307
+ | "json"
308
+ | "xml"
309
+ | "yaml"
310
+ | "markdown"
311
+ | "sql"
312
+ | "bash"
313
+ | "shell"
314
+ | "powershell"
315
+ | "dockerfile"
316
+ | string; // Allow any string for custom languages
317
+
318
+ /**
319
+ * Utility type for Highlight.js theme names
320
+ * Common themes - extend as needed
321
+ */
322
+ export type HighlightTheme =
323
+ | "hybrid"
324
+ | "monokai"
325
+ | "github"
326
+ | "atom-one-dark"
327
+ | "atom-one-light"
328
+ | "vs"
329
+ | "vs2015"
330
+ | "dracula"
331
+ | "nord"
332
+ | "solarized-dark"
333
+ | "solarized-light"
334
+ | "tomorrow"
335
+ | "tomorrow-night"
336
+ | string; // Allow any string for custom themes
337
+
338
+ /**
339
+ * Re-export main types for convenience
340
+ */
341
+ export type {
342
+ CaretEditorConfig,
343
+ CaretEditorInstance,
344
+ CaretEditor,
345
+ FontMetrics,
346
+ LanguageManager
347
+ } from "./index";