@synclineapi/editor 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.
- package/README.md +1858 -0
- package/dist/syncline-editor.es.js +4466 -0
- package/dist/syncline-editor.es.js.map +1 -0
- package/dist/syncline-editor.umd.js +487 -0
- package/dist/syncline-editor.umd.js.map +1 -0
- package/dist/types/index.d.ts +1183 -0
- package/package.json +79 -0
|
@@ -0,0 +1,1183 @@
|
|
|
1
|
+
export declare const BUILT_IN_THEMES: ThemeDefinition[];
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Snapshot of token cache performance counters.
|
|
5
|
+
* Useful for monitoring and diagnosing tokeniser regressions.
|
|
6
|
+
*/
|
|
7
|
+
export declare interface CacheMetrics {
|
|
8
|
+
/** Number of successful cache lookups (cache hits). */
|
|
9
|
+
hits: number;
|
|
10
|
+
/** Number of failed lookups that required re-tokenising a line. */
|
|
11
|
+
misses: number;
|
|
12
|
+
/** Number of entries evicted to stay within `maxSize`. */
|
|
13
|
+
evictions: number;
|
|
14
|
+
/** Current number of entries in the cache. */
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Context passed to a `provideCompletions` callback.
|
|
20
|
+
* Describes the current cursor position and document state at the moment
|
|
21
|
+
* the autocomplete popup is about to open.
|
|
22
|
+
*/
|
|
23
|
+
export declare interface CompletionContext {
|
|
24
|
+
/** The full text of the line the cursor is on. */
|
|
25
|
+
line: string;
|
|
26
|
+
/** Zero-based column index of the cursor within the line. */
|
|
27
|
+
col: number;
|
|
28
|
+
/** The word-prefix immediately before the cursor (characters typed so far). */
|
|
29
|
+
prefix: string;
|
|
30
|
+
/** The active language identifier (e.g. `'typescript'`, `'css'`). */
|
|
31
|
+
language: string;
|
|
32
|
+
/** The full document as an array of lines (read-only view). */
|
|
33
|
+
doc: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A single entry shown in the autocomplete popup.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const item: CompletionItem = {
|
|
42
|
+
* label: 'myFunction',
|
|
43
|
+
* kind: 'fn',
|
|
44
|
+
* detail: '(x: number) => void',
|
|
45
|
+
* };
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare interface CompletionItem {
|
|
49
|
+
/** The text inserted when this item is accepted. Also used for filtering. */
|
|
50
|
+
label: string;
|
|
51
|
+
/** Visual category badge shown in the popup. */
|
|
52
|
+
kind: CompletionKind;
|
|
53
|
+
/**
|
|
54
|
+
* Short hint shown on the right side of the popup row (type signature, source, etc.).
|
|
55
|
+
* Keep this brief — one line or a short type annotation.
|
|
56
|
+
*/
|
|
57
|
+
detail?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Full documentation shown in the VS Code-style description panel on the right side
|
|
60
|
+
* of the popup when this item is selected. Supports plain text; newlines are rendered
|
|
61
|
+
* as paragraph breaks. Falls back to `body` preview for `'snip'` items when omitted.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* { label: 'fetch', kind: 'fn', detail: 'Promise<Response>',
|
|
66
|
+
* description: 'Fetches a resource from the network.\n\nReturns a Promise that resolves to a Response.' }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
description?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Snippet body template. When present, accepting this item expands the
|
|
72
|
+
* full body instead of inserting just the label. Use `$1`, `$2`, … as
|
|
73
|
+
* tab-stop placeholders — the cursor is placed at `$1` after expansion.
|
|
74
|
+
* Use `\n` for newlines; indentation is inherited from the trigger line.
|
|
75
|
+
*
|
|
76
|
+
* Set `kind` to `'snip'` so the badge shows **S** in the popup.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* { label: 'forof', kind: 'snip', detail: 'for…of loop',
|
|
81
|
+
* body: 'for (const $1 of $2) {\n $3\n}' }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
body?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Restrict this item to specific languages. When provided, the item only appears
|
|
87
|
+
* when the editor's active language matches. Omit to show in all languages.
|
|
88
|
+
*
|
|
89
|
+
* @example `language: 'typescript'` or `language: ['typescript', 'javascript']`
|
|
90
|
+
*/
|
|
91
|
+
language?: string | string[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Category of a completion item, controlling the badge icon shown in the popup.
|
|
96
|
+
*
|
|
97
|
+
* - `'kw'` — keyword (badge: **K**)
|
|
98
|
+
* - `'fn'` — function or method (badge: **f**)
|
|
99
|
+
* - `'typ'` — type or interface (badge: **T**)
|
|
100
|
+
* - `'cls'` — class (badge: **C**)
|
|
101
|
+
* - `'var'` — variable, property, or other symbol (badge: **·**)
|
|
102
|
+
* - `'snip'` — snippet template (badge: **S**); accepting expands a multi-line body
|
|
103
|
+
* - `'emmet'` — emmet abbreviation (badge: **E**); accepting expands the abbreviation to HTML
|
|
104
|
+
*/
|
|
105
|
+
export declare type CompletionKind = 'kw' | 'fn' | 'typ' | 'cls' | 'var' | 'snip' | 'emmet';
|
|
106
|
+
|
|
107
|
+
/** Convenience type alias for the `createEditor` function signature. */
|
|
108
|
+
export declare type CreateEditor = typeof createEditor;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Create and mount a `SynclineEditor` inside `container`.
|
|
112
|
+
*
|
|
113
|
+
* This is the recommended entry point — it returns the narrower `EditorAPI`
|
|
114
|
+
* type, which hides the internal class members and exposes only the public
|
|
115
|
+
* interface. Use `new SynclineEditor(...)` directly if you need access to the
|
|
116
|
+
* concrete class type (e.g., for `instanceof` checks).
|
|
117
|
+
*
|
|
118
|
+
* Config values are validated and clamped to sensible bounds automatically —
|
|
119
|
+
* you never need to guard against negative font sizes or extreme tab widths.
|
|
120
|
+
*
|
|
121
|
+
* @param container - The `HTMLElement` that will host the editor.
|
|
122
|
+
* @param config - Initial configuration. All properties are optional.
|
|
123
|
+
* @returns An `EditorAPI` instance ready to use.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { createEditor } from 'syncline-editor';
|
|
128
|
+
*
|
|
129
|
+
* const editor = createEditor(document.getElementById('app')!, {
|
|
130
|
+
* value: 'console.log("Hello, world!")',
|
|
131
|
+
* language: 'typescript',
|
|
132
|
+
* theme: 'dracula',
|
|
133
|
+
* onChange: (value) => console.log('changed:', value.length, 'chars'),
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* // Later — update config without remounting
|
|
137
|
+
* editor.updateConfig({ theme: 'github-light', fontSize: 15 });
|
|
138
|
+
*
|
|
139
|
+
* // Clean up when done
|
|
140
|
+
* editor.destroy();
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare function createEditor(container: HTMLElement, config?: EditorConfig): EditorAPI;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A single cursor position in document (line/column) space.
|
|
147
|
+
* Both `row` and `col` are zero-based.
|
|
148
|
+
*/
|
|
149
|
+
export declare interface CursorPosition {
|
|
150
|
+
/** Zero-based line index within the document. */
|
|
151
|
+
row: number;
|
|
152
|
+
/** Zero-based character offset within the line. */
|
|
153
|
+
col: number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Public API surface returned by `SynclineEditor.create()`.
|
|
158
|
+
* All methods are safe to call at any time after construction.
|
|
159
|
+
*/
|
|
160
|
+
export declare interface EditorAPI {
|
|
161
|
+
/**
|
|
162
|
+
* Returns the full document content as a single newline-joined string.
|
|
163
|
+
*/
|
|
164
|
+
getValue(): string;
|
|
165
|
+
/**
|
|
166
|
+
* Replaces the entire document content.
|
|
167
|
+
* Records an undo snapshot before overwriting, so the change can be undone.
|
|
168
|
+
* Fires `onChange`.
|
|
169
|
+
*/
|
|
170
|
+
setValue(value: string): void;
|
|
171
|
+
/**
|
|
172
|
+
* Returns a copy of the current cursor position.
|
|
173
|
+
*/
|
|
174
|
+
getCursor(): CursorPosition;
|
|
175
|
+
/**
|
|
176
|
+
* Moves the cursor to the given position and scrolls it into view.
|
|
177
|
+
*/
|
|
178
|
+
setCursor(position: CursorPosition): void;
|
|
179
|
+
/**
|
|
180
|
+
* Returns a copy of the current selection, or `null` if nothing is selected.
|
|
181
|
+
*/
|
|
182
|
+
getSelection(): Selection_2 | null;
|
|
183
|
+
/**
|
|
184
|
+
* Sets or clears the selection without moving the cursor.
|
|
185
|
+
* Pass `null` to deselect.
|
|
186
|
+
*/
|
|
187
|
+
setSelection(selection: Selection_2 | null): void;
|
|
188
|
+
/**
|
|
189
|
+
* Inserts text at the current cursor position, replacing any active selection.
|
|
190
|
+
* No-op when `readOnly` is `true`.
|
|
191
|
+
*/
|
|
192
|
+
insertText(text: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Applies a theme by registered ID or by passing a full `ThemeDefinition`.
|
|
195
|
+
* Rebuilds minimap colours and re-renders immediately.
|
|
196
|
+
*/
|
|
197
|
+
setTheme(theme: string | ThemeDefinition): void;
|
|
198
|
+
/**
|
|
199
|
+
* Updates any subset of config options at runtime.
|
|
200
|
+
* Visual options (font, cursor, gutter, etc.) take effect immediately.
|
|
201
|
+
* Structural options (`showMinimap`, `showStatusBar`) add or remove DOM nodes.
|
|
202
|
+
*/
|
|
203
|
+
updateConfig(patch: Partial<EditorConfig>): void;
|
|
204
|
+
/**
|
|
205
|
+
* Focuses the hidden textarea that captures keyboard input.
|
|
206
|
+
*/
|
|
207
|
+
focus(): void;
|
|
208
|
+
/**
|
|
209
|
+
* Returns the IDs of all currently registered themes (built-in + custom).
|
|
210
|
+
*/
|
|
211
|
+
getThemes(): string[];
|
|
212
|
+
/**
|
|
213
|
+
* Registers a custom theme so it can be applied by ID via `setTheme()`.
|
|
214
|
+
* If a theme with the same `id` already exists it is overwritten.
|
|
215
|
+
*/
|
|
216
|
+
registerTheme(theme: ThemeDefinition): void;
|
|
217
|
+
/**
|
|
218
|
+
* Undoes the last edit operation.
|
|
219
|
+
* No-op if the undo stack is empty or `readOnly` is `true`.
|
|
220
|
+
*/
|
|
221
|
+
undo(): void;
|
|
222
|
+
/**
|
|
223
|
+
* Redoes the last undone operation.
|
|
224
|
+
* No-op if the redo stack is empty or `readOnly` is `true`.
|
|
225
|
+
*/
|
|
226
|
+
redo(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Executes a built-in editor command by name.
|
|
229
|
+
* Mutating commands are no-ops when `readOnly` is `true`.
|
|
230
|
+
*
|
|
231
|
+
* Supported command names:
|
|
232
|
+
* `'undo'`, `'redo'`, `'selectAll'`, `'copy'`, `'cut'`,
|
|
233
|
+
* `'toggleComment'`, `'duplicateLine'`, `'deleteLine'`,
|
|
234
|
+
* `'toggleWordWrap'`, `'find'`, `'findReplace'`,
|
|
235
|
+
* `'indentLine'`, `'outdentLine'`
|
|
236
|
+
*/
|
|
237
|
+
executeCommand(command: string): void;
|
|
238
|
+
/**
|
|
239
|
+
* Removes all editor DOM nodes from the host element and cleans up
|
|
240
|
+
* internal state. The instance should not be used after calling this.
|
|
241
|
+
*/
|
|
242
|
+
destroy(): void;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** ─── Editor Configuration ──────────────────────────────── */
|
|
246
|
+
/**
|
|
247
|
+
* Full, deeply-customisable editor configuration.
|
|
248
|
+
* Every field is optional — sensible defaults are applied for any omitted field.
|
|
249
|
+
* Pass this object to `SynclineEditor.create()` to configure the editor on
|
|
250
|
+
* initialisation, or call `updateConfig()` to change options at runtime.
|
|
251
|
+
*/
|
|
252
|
+
export declare interface EditorConfig {
|
|
253
|
+
/**
|
|
254
|
+
* Initial document content.
|
|
255
|
+
* Accepts either a newline-delimited string or a pre-split string array.
|
|
256
|
+
* Default: `''` (empty document).
|
|
257
|
+
*/
|
|
258
|
+
value?: string | string[];
|
|
259
|
+
/**
|
|
260
|
+
* Language used for syntax highlighting and autocomplete.
|
|
261
|
+
* Selects the built-in keyword set, type set, and built-in completion items
|
|
262
|
+
* appropriate for that language.
|
|
263
|
+
* Default: `'typescript'`.
|
|
264
|
+
*/
|
|
265
|
+
language?: Language;
|
|
266
|
+
/**
|
|
267
|
+
* Active theme.
|
|
268
|
+
* Pass a registered theme ID string (e.g. `'vr-dark'`) or a full
|
|
269
|
+
* `ThemeDefinition` object for a custom theme.
|
|
270
|
+
* Default: `''` (built-in VR Dark theme).
|
|
271
|
+
*/
|
|
272
|
+
theme?: string | ThemeDefinition;
|
|
273
|
+
/**
|
|
274
|
+
* Show the line-number gutter on the left side of the editor.
|
|
275
|
+
* When `false` the gutter is hidden and its width is removed from all
|
|
276
|
+
* mouse-position calculations.
|
|
277
|
+
* Default: `true`.
|
|
278
|
+
*/
|
|
279
|
+
showGutter?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Show the minimap panel on the right side of the editor.
|
|
282
|
+
* Can be toggled at runtime via `updateConfig({ showMinimap: false })`.
|
|
283
|
+
* Default: `true`.
|
|
284
|
+
*/
|
|
285
|
+
showMinimap?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Show the status bar at the bottom of the editor.
|
|
288
|
+
* Displays cursor position, language, selection count, and undo depth.
|
|
289
|
+
* Default: `true`.
|
|
290
|
+
*/
|
|
291
|
+
showStatusBar?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Wrap long lines at `wrapColumn` characters instead of scrolling horizontally.
|
|
294
|
+
* Wrapped lines produce multiple visual rows for a single document line.
|
|
295
|
+
* Toggle at runtime with `updateConfig({ wordWrap: true })` or `Alt+Z`.
|
|
296
|
+
* Default: `false`.
|
|
297
|
+
*/
|
|
298
|
+
wordWrap?: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Column at which lines are soft-wrapped when `wordWrap` is `true`.
|
|
301
|
+
* Has no effect when `wordWrap` is `false`.
|
|
302
|
+
* Default: `80`.
|
|
303
|
+
*/
|
|
304
|
+
wrapColumn?: number;
|
|
305
|
+
/**
|
|
306
|
+
* CSS font-family string applied to all code text and the gutter.
|
|
307
|
+
* Example: `"'Fira Code', monospace"`.
|
|
308
|
+
* Default: `"'JetBrains Mono', monospace"`.
|
|
309
|
+
*/
|
|
310
|
+
fontFamily?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Font size in pixels applied to all code text.
|
|
313
|
+
* Default: `13`.
|
|
314
|
+
*/
|
|
315
|
+
fontSize?: number;
|
|
316
|
+
/**
|
|
317
|
+
* Line height in pixels. Controls row height, cursor size, and all
|
|
318
|
+
* scroll/minimap calculations. Must match the rendered font metrics to
|
|
319
|
+
* avoid misaligned click targets.
|
|
320
|
+
* Default: `22`.
|
|
321
|
+
*/
|
|
322
|
+
lineHeight?: number;
|
|
323
|
+
/**
|
|
324
|
+
* Number of spaces inserted when the Tab key is pressed (or used as the
|
|
325
|
+
* indentation unit when `insertSpaces` is `true`).
|
|
326
|
+
* Default: `2`.
|
|
327
|
+
*/
|
|
328
|
+
tabSize?: number;
|
|
329
|
+
/**
|
|
330
|
+
* When `true`, pressing Tab inserts spaces; when `false`, a literal tab
|
|
331
|
+
* character (`\t`) is inserted.
|
|
332
|
+
* Default: `true`.
|
|
333
|
+
*/
|
|
334
|
+
insertSpaces?: boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Maximum number of undo snapshots retained per buffer.
|
|
337
|
+
* Older snapshots are discarded when the stack exceeds this limit.
|
|
338
|
+
* Default: `300`.
|
|
339
|
+
*/
|
|
340
|
+
maxUndoHistory?: number;
|
|
341
|
+
/**
|
|
342
|
+
* Render faint vertical lines at each indentation level to aid visual
|
|
343
|
+
* alignment of nested code blocks.
|
|
344
|
+
* Default: `true`.
|
|
345
|
+
*/
|
|
346
|
+
showIndentGuides?: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Highlight matching bracket pairs when the cursor is adjacent to a
|
|
349
|
+
* bracket character (`(`, `)`, `[`, `]`, `{`, `}`).
|
|
350
|
+
* Default: `true`.
|
|
351
|
+
*/
|
|
352
|
+
bracketMatching?: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Enable code folding. When `true`, a fold toggle button appears in the
|
|
355
|
+
* gutter for foldable blocks (functions, classes, etc.).
|
|
356
|
+
* Default: `true`.
|
|
357
|
+
*/
|
|
358
|
+
codeFolding?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Enable Emmet abbreviation expansion via the Tab key.
|
|
361
|
+
* A preview tooltip appears when a valid Emmet abbreviation is detected
|
|
362
|
+
* before the cursor.
|
|
363
|
+
* Default: `true`.
|
|
364
|
+
*/
|
|
365
|
+
emmet?: boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Enable snippet expansion via the Tab key.
|
|
368
|
+
* When the word immediately before the cursor matches a snippet trigger,
|
|
369
|
+
* pressing Tab replaces it with the snippet body and places the cursor
|
|
370
|
+
* at the first `$1` tab stop.
|
|
371
|
+
* Built-in snippets are provided for TypeScript/JavaScript, CSS, and HTML.
|
|
372
|
+
* A preview tooltip appears when a matching trigger is detected.
|
|
373
|
+
* Default: `true`.
|
|
374
|
+
*/
|
|
375
|
+
snippetExpansion?: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Show an autocomplete popup with suggestions as the user types.
|
|
378
|
+
* Suggestions are derived from symbols already present in the document.
|
|
379
|
+
* Default: `true`.
|
|
380
|
+
*/
|
|
381
|
+
autocomplete?: boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Allow multiple simultaneous cursors.
|
|
384
|
+
* Multi-cursor is activated via `Alt+Click` (add cursor) and `Ctrl+D`
|
|
385
|
+
* (select next occurrence). Setting this to `false` disables both.
|
|
386
|
+
* Default: `true`.
|
|
387
|
+
*/
|
|
388
|
+
multiCursor?: boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Enable the find bar (Ctrl+F / Cmd+F).
|
|
391
|
+
* When `false`, the find bar cannot be opened via keyboard shortcut or
|
|
392
|
+
* `executeCommand('find')`, and the Ctrl+F key combination is released
|
|
393
|
+
* back to the browser.
|
|
394
|
+
* Default: `true`.
|
|
395
|
+
*/
|
|
396
|
+
find?: boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Enable find-and-replace (Ctrl+H / Cmd+H).
|
|
399
|
+
* When `false`, the replace row is inaccessible and Ctrl+H is a no-op.
|
|
400
|
+
* Has no effect when `find` is also `false`.
|
|
401
|
+
* Default: `true`.
|
|
402
|
+
*/
|
|
403
|
+
findReplace?: boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Enable word selection on double-click.
|
|
406
|
+
* When `true`, double-clicking a word selects it (standard editor behaviour).
|
|
407
|
+
* When `false`, double-clicking places the cursor without creating a selection.
|
|
408
|
+
* Default: `true`.
|
|
409
|
+
*/
|
|
410
|
+
wordSelection?: boolean;
|
|
411
|
+
/**
|
|
412
|
+
* Highlight all occurrences of the word currently under the cursor.
|
|
413
|
+
* When `true`, every other occurrence of the same whole-word token in the
|
|
414
|
+
* document gets a subtle background box (`--word-hl-bg` / `--word-hl-border`).
|
|
415
|
+
* Highlights are cleared automatically when a text selection is active.
|
|
416
|
+
* When `false`, no word-occurrence highlighting is applied.
|
|
417
|
+
* Default: `true`.
|
|
418
|
+
*/
|
|
419
|
+
wordHighlight?: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Highlight the line that currently contains the cursor with a distinct
|
|
422
|
+
* background colour (`--cur-line-bg`) and a matching gutter background.
|
|
423
|
+
* Set to `false` to disable the active-line indicator entirely.
|
|
424
|
+
* Default: `true`.
|
|
425
|
+
*/
|
|
426
|
+
highlightActiveLine?: boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Minimum number of characters the user must type before the autocomplete
|
|
429
|
+
* popup appears. Increasing this reduces noise on short prefixes; setting it
|
|
430
|
+
* to `1` triggers suggestions after a single character.
|
|
431
|
+
* Default: `2`.
|
|
432
|
+
*/
|
|
433
|
+
autocompletePrefixLength?: number;
|
|
434
|
+
/**
|
|
435
|
+
* Prevent all content mutations.
|
|
436
|
+
* When `true`, typing, paste, cut, undo/redo, and all other edit operations
|
|
437
|
+
* are silently blocked. Navigation, selection, copy, and find still work.
|
|
438
|
+
* Default: `false`.
|
|
439
|
+
*/
|
|
440
|
+
readOnly?: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Additional keywords to include in syntax highlighting beyond the
|
|
443
|
+
* built-in keyword list for the active language.
|
|
444
|
+
* Example: `['myDSLKeyword', 'pipeline']`.
|
|
445
|
+
* Default: `[]`.
|
|
446
|
+
*/
|
|
447
|
+
extraKeywords?: string[];
|
|
448
|
+
/**
|
|
449
|
+
* Additional type names to recognise during syntax highlighting beyond
|
|
450
|
+
* the built-in type list for the active language.
|
|
451
|
+
* Example: `['MyCustomType', 'Result']`.
|
|
452
|
+
* Default: `[]`.
|
|
453
|
+
*/
|
|
454
|
+
extraTypes?: string[];
|
|
455
|
+
/**
|
|
456
|
+
* The **single unified completions array** — the only completion source you need.
|
|
457
|
+
*
|
|
458
|
+
* Every item is a `CompletionItem`. Differentiate by `kind`:
|
|
459
|
+
* - `'kw'`, `'fn'`, `'typ'`, `'cls'`, `'var'` — regular completions merged with built-ins
|
|
460
|
+
* - `'snip'` — snippet: set `body` and the item expands like a snippet on accept
|
|
461
|
+
*
|
|
462
|
+
* All items can carry a `language` filter and a `description` for the docs panel.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```ts
|
|
466
|
+
* completions: [
|
|
467
|
+
* // Regular completion with docs
|
|
468
|
+
* { label: 'myQuery', kind: 'fn', detail: 'GraphQL helper',
|
|
469
|
+
* description: 'Executes a GraphQL query and returns the result.' },
|
|
470
|
+
* // Inline snippet
|
|
471
|
+
* { label: 'mycomp', kind: 'snip', detail: 'My component',
|
|
472
|
+
* body: 'export function $1Component() {\n return <div>$2</div>;\n}',
|
|
473
|
+
* language: ['typescript'] },
|
|
474
|
+
* ]
|
|
475
|
+
* ```
|
|
476
|
+
* Default: `[]`.
|
|
477
|
+
*/
|
|
478
|
+
completions?: CompletionItem[];
|
|
479
|
+
/**
|
|
480
|
+
* When `true`, the items in `completions` **replace** the built-in language
|
|
481
|
+
* keywords/types/functions entirely instead of being merged on top.
|
|
482
|
+
* Only the provided items (plus in-file word suggestions) will appear.
|
|
483
|
+
*
|
|
484
|
+
* Use alongside `completions`.
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```ts
|
|
488
|
+
* // DSL editor — show only your own keywords
|
|
489
|
+
* replaceBuiltins: true,
|
|
490
|
+
* completions: [
|
|
491
|
+
* { label: 'SELECT', kind: 'kw', detail: 'SQL' },
|
|
492
|
+
* { label: 'FROM', kind: 'kw', detail: 'SQL' },
|
|
493
|
+
* ]
|
|
494
|
+
* ```
|
|
495
|
+
* Default: `false`.
|
|
496
|
+
*/
|
|
497
|
+
replaceBuiltins?: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Dynamic completion provider called each time the autocomplete popup is
|
|
500
|
+
* about to open. Receives a `CompletionContext` describing the current
|
|
501
|
+
* cursor position and returns an array of `CompletionItem` to display
|
|
502
|
+
* instead of the built-in language completions.
|
|
503
|
+
*
|
|
504
|
+
* Return `null` or `undefined` to fall through to the built-in defaults.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* provideCompletions: (ctx) => {
|
|
509
|
+
* if (ctx.prefix.startsWith('$')) {
|
|
510
|
+
* return mySymbolTable.map(s => ({ label: s, kind: 'var' }));
|
|
511
|
+
* }
|
|
512
|
+
* return null; // use defaults
|
|
513
|
+
* }
|
|
514
|
+
* ```
|
|
515
|
+
* Default: `undefined` (use built-in language completions).
|
|
516
|
+
*/
|
|
517
|
+
provideCompletions?: (context: CompletionContext) => CompletionItem[] | null | undefined;
|
|
518
|
+
/**
|
|
519
|
+
* Auto-close bracket and quote pairs.
|
|
520
|
+
* When the user types the opening character, the closing character is
|
|
521
|
+
* inserted automatically and the cursor placed between them.
|
|
522
|
+
*
|
|
523
|
+
* Pass an empty object `{}` to disable all auto-closing.
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```ts
|
|
527
|
+
* // Only auto-close parentheses and curly braces
|
|
528
|
+
* autoClosePairs: { '(': ')', '{': '}' }
|
|
529
|
+
* ```
|
|
530
|
+
* Default: `{ '(': ')', '[': ']', '{': '}', '"': '"', "'": "'", '`': '`' }`.
|
|
531
|
+
*/
|
|
532
|
+
autoClosePairs?: Record<string, string>;
|
|
533
|
+
/**
|
|
534
|
+
* Line comment token used by the "toggle comment" command (Ctrl+/).
|
|
535
|
+
* Set to the prefix string for single-line comments in your language.
|
|
536
|
+
*
|
|
537
|
+
* When empty or omitted, the editor auto-selects based on `language`:
|
|
538
|
+
* - TypeScript / JavaScript / CSS → `'//'`
|
|
539
|
+
* - Python / Ruby / Bash / YAML → `'#'`
|
|
540
|
+
* - Markdown / JSON → no comment token (toggle comment is a no-op)
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```ts
|
|
544
|
+
* lineCommentToken: '#' // Python, Ruby, shell scripts
|
|
545
|
+
* lineCommentToken: '--' // SQL, Lua
|
|
546
|
+
* lineCommentToken: '%' // LaTeX
|
|
547
|
+
* ```
|
|
548
|
+
* Default: `''` (auto-detect from language).
|
|
549
|
+
*/
|
|
550
|
+
lineCommentToken?: string;
|
|
551
|
+
/**
|
|
552
|
+
* A string containing every character that should be treated as a word
|
|
553
|
+
* separator (non-word character) for word-based operations: double-click
|
|
554
|
+
* word selection, Ctrl+Left/Right navigation, and Ctrl+D (select next
|
|
555
|
+
* occurrence).
|
|
556
|
+
*
|
|
557
|
+
* Characters NOT in this string (and not whitespace) are treated as word
|
|
558
|
+
* characters. Leave empty to use the default `\w` + `$` word boundary.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```ts
|
|
562
|
+
* // Treat hyphens as word separators (useful for CSS/Markdown)
|
|
563
|
+
* wordSeparators: '`~!@#%^&*()-=+[{]}\\|;:\'",.<>/?'
|
|
564
|
+
* ```
|
|
565
|
+
* Default: `''` (use built-in `\w$` word character definition).
|
|
566
|
+
*/
|
|
567
|
+
wordSeparators?: string;
|
|
568
|
+
/**
|
|
569
|
+
* Milliseconds window for grouping consecutive keystrokes into a single
|
|
570
|
+
* undo snapshot. Keystrokes within this window are merged and undone
|
|
571
|
+
* together in one step.
|
|
572
|
+
*
|
|
573
|
+
* Set to `0` to record a separate undo snapshot for every keystroke.
|
|
574
|
+
* Default: `700`.
|
|
575
|
+
*/
|
|
576
|
+
undoBatchMs?: number;
|
|
577
|
+
/**
|
|
578
|
+
* Maximum number of items shown in the autocomplete popup.
|
|
579
|
+
* Includes both base completions and in-file word suggestions.
|
|
580
|
+
* Default: `14`.
|
|
581
|
+
*/
|
|
582
|
+
maxCompletions?: number;
|
|
583
|
+
/**
|
|
584
|
+
* Width of the line-number gutter in pixels.
|
|
585
|
+
* Affects mouse-to-cursor mapping and popup positioning.
|
|
586
|
+
* Default: `60`.
|
|
587
|
+
*/
|
|
588
|
+
gutterWidth?: number;
|
|
589
|
+
/**
|
|
590
|
+
* Width of the minimap panel in pixels.
|
|
591
|
+
* Default: `120`.
|
|
592
|
+
*/
|
|
593
|
+
minimapWidth?: number;
|
|
594
|
+
/**
|
|
595
|
+
* Cursor blink period in milliseconds.
|
|
596
|
+
* The cursor completes one full blink cycle (on → off → on) in this time.
|
|
597
|
+
* Set to a very large value (e.g. `999999`) to effectively disable blinking.
|
|
598
|
+
* Default: `1050`.
|
|
599
|
+
*/
|
|
600
|
+
cursorBlinkRate?: number;
|
|
601
|
+
/**
|
|
602
|
+
* Visual style of the text cursor.
|
|
603
|
+
* - `'line'` — thin vertical beam (default, VS Code-style)
|
|
604
|
+
* - `'block'` — filled rectangle covering the character under the cursor
|
|
605
|
+
* - `'underline'` — horizontal bar below the character
|
|
606
|
+
* Default: `'line'`.
|
|
607
|
+
*/
|
|
608
|
+
cursorStyle?: 'line' | 'block' | 'underline';
|
|
609
|
+
/**
|
|
610
|
+
* Controls whether whitespace characters are rendered as visible glyphs.
|
|
611
|
+
* - `'none'` — whitespace is invisible (default)
|
|
612
|
+
* - `'boundary'` — leading and trailing spaces shown as `·`, tabs as `→`
|
|
613
|
+
* - `'all'` — every space shown as `·`, every tab as `→`
|
|
614
|
+
* Default: `'none'`.
|
|
615
|
+
*/
|
|
616
|
+
renderWhitespace?: 'none' | 'boundary' | 'all';
|
|
617
|
+
/**
|
|
618
|
+
* Per-token syntax-highlight colour overrides applied **on top of** the
|
|
619
|
+
* active theme. Any field set here takes precedence over the corresponding
|
|
620
|
+
* `ThemeTokens` colour without replacing the entire theme.
|
|
621
|
+
*
|
|
622
|
+
* Set a field to `''` (empty string) to restore the theme's default for
|
|
623
|
+
* that token. Omit a field entirely to leave it unchanged.
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```ts
|
|
627
|
+
* // Dracula-inspired keywords + string colours on any base theme
|
|
628
|
+
* editor.updateConfig({
|
|
629
|
+
* tokenColors: {
|
|
630
|
+
* keyword: '#ff79c6',
|
|
631
|
+
* string: '#f1fa8c',
|
|
632
|
+
* function: '#50fa7b',
|
|
633
|
+
* type: '#8be9fd',
|
|
634
|
+
* comment: '#6272a4',
|
|
635
|
+
* }
|
|
636
|
+
* });
|
|
637
|
+
* ```
|
|
638
|
+
* Default: `{}` (no overrides — all colours come from the active theme).
|
|
639
|
+
*/
|
|
640
|
+
tokenColors?: TokenColors;
|
|
641
|
+
/**
|
|
642
|
+
* Called whenever the document content changes (after every keystroke,
|
|
643
|
+
* paste, undo, or programmatic `setValue`).
|
|
644
|
+
* Receives the full document as a newline-joined string.
|
|
645
|
+
*/
|
|
646
|
+
onChange?: (value: string) => void;
|
|
647
|
+
/**
|
|
648
|
+
* Called whenever the cursor moves to a new position.
|
|
649
|
+
* Receives a copy of the new `CursorPosition`.
|
|
650
|
+
*/
|
|
651
|
+
onCursorChange?: (position: CursorPosition) => void;
|
|
652
|
+
/**
|
|
653
|
+
* Called whenever the selection changes or is cleared.
|
|
654
|
+
* Receives a copy of the new `Selection`, or `null` when deselected.
|
|
655
|
+
*/
|
|
656
|
+
onSelectionChange?: (selection: Selection_2 | null) => void;
|
|
657
|
+
/**
|
|
658
|
+
* Called when the editor gains keyboard focus.
|
|
659
|
+
*/
|
|
660
|
+
onFocus?: () => void;
|
|
661
|
+
/**
|
|
662
|
+
* Called when the editor loses keyboard focus.
|
|
663
|
+
*/
|
|
664
|
+
onBlur?: () => void;
|
|
665
|
+
/**
|
|
666
|
+
* Enable hover documentation tooltips.
|
|
667
|
+
* When `true`, resting the pointer over a recognised identifier for ~500 ms
|
|
668
|
+
* shows a floating tooltip with its type signature and description.
|
|
669
|
+
* Covers built-in JS/TS/CSS symbols and any symbols provided via `provideHover`.
|
|
670
|
+
* Default: `true`.
|
|
671
|
+
*/
|
|
672
|
+
hover?: boolean;
|
|
673
|
+
/**
|
|
674
|
+
* Custom hover documentation provider.
|
|
675
|
+
* Called when the user hovers over an identifier and no built-in doc is found.
|
|
676
|
+
* Return a `HoverDoc` object to show a tooltip, or `null`/`undefined` to show nothing.
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* provideHover: (ctx) => {
|
|
681
|
+
* const entry = mySymbolTable[ctx.word];
|
|
682
|
+
* if (!entry) return null;
|
|
683
|
+
* return {
|
|
684
|
+
* title: entry.name,
|
|
685
|
+
* type: entry.signature,
|
|
686
|
+
* body: entry.description,
|
|
687
|
+
* };
|
|
688
|
+
* }
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
provideHover?: (context: HoverContext) => HoverDoc | null | undefined;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* An additional cursor in a multi-cursor editing session.
|
|
696
|
+
* Each extra cursor tracks its own position and optional selection range.
|
|
697
|
+
*/
|
|
698
|
+
export declare interface ExtraCursor {
|
|
699
|
+
/** Zero-based line index of this cursor. */
|
|
700
|
+
row: number;
|
|
701
|
+
/** Zero-based column of this cursor. */
|
|
702
|
+
col: number;
|
|
703
|
+
/** Selection associated with this cursor, or `null` if none. */
|
|
704
|
+
sel: Selection_2 | null;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* A single result from a find (search) operation.
|
|
709
|
+
* Identifies a contiguous substring within one document line.
|
|
710
|
+
*/
|
|
711
|
+
export declare interface FindMatch {
|
|
712
|
+
/** Zero-based line index where the match was found. */
|
|
713
|
+
row: number;
|
|
714
|
+
/** Zero-based column where the match starts. */
|
|
715
|
+
col: number;
|
|
716
|
+
/** Length of the matched text in characters. */
|
|
717
|
+
len: number;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Context passed to a `provideHover` callback.
|
|
722
|
+
* Describes the word under the pointer and the surrounding document state.
|
|
723
|
+
*/
|
|
724
|
+
declare interface HoverContext {
|
|
725
|
+
/** The full identifier under the pointer (may include a dot prefix, e.g. `"console.log"`). */
|
|
726
|
+
word: string;
|
|
727
|
+
/** Zero-based document line index where the pointer is. */
|
|
728
|
+
row: number;
|
|
729
|
+
/** Zero-based character column where the pointer is. */
|
|
730
|
+
col: number;
|
|
731
|
+
/** The full text of the hovered line. */
|
|
732
|
+
line: string;
|
|
733
|
+
/** The active language identifier (e.g. `'typescript'`). */
|
|
734
|
+
language: string;
|
|
735
|
+
/** The full document as a read-only array of lines. */
|
|
736
|
+
doc: readonly string[];
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Documentation shown in a hover tooltip when the user rests the pointer
|
|
741
|
+
* over a recognised identifier in the editor.
|
|
742
|
+
*/
|
|
743
|
+
declare interface HoverDoc {
|
|
744
|
+
/** Display name of the symbol — shown prominently at the top of the tooltip. */
|
|
745
|
+
title: string;
|
|
746
|
+
/**
|
|
747
|
+
* Type signature or category label (e.g. `"(...data: any[]) => void"`,
|
|
748
|
+
* `"primitive type"`, `"keyword"`).
|
|
749
|
+
* Rendered in monospace below the title.
|
|
750
|
+
*/
|
|
751
|
+
type?: string;
|
|
752
|
+
/** Human-readable description of what the symbol does. */
|
|
753
|
+
body: string;
|
|
754
|
+
/**
|
|
755
|
+
* Restrict this doc entry to specific languages.
|
|
756
|
+
* When provided, the tooltip only appears when the editor's active language matches.
|
|
757
|
+
* Omit to show in all languages.
|
|
758
|
+
*/
|
|
759
|
+
language?: string | string[];
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Supported language identifiers for syntax highlighting and autocomplete.
|
|
764
|
+
* Pass as the `language` option in `EditorConfig`.
|
|
765
|
+
*/
|
|
766
|
+
export declare type Language = 'typescript' | 'javascript' | 'css' | 'json' | 'markdown' | 'text';
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Colour palette used when painting the minimap canvas.
|
|
770
|
+
* Each value is a CSS colour string resolved from the active theme.
|
|
771
|
+
* The interface also accepts arbitrary string keys so token class names
|
|
772
|
+
* (`'kw'`, `'fn'`, etc.) can be used for direct index access.
|
|
773
|
+
*/
|
|
774
|
+
export declare interface MinimapColors {
|
|
775
|
+
/** Colour for keyword tokens. */
|
|
776
|
+
kw: string;
|
|
777
|
+
/** Colour for function-name tokens. */
|
|
778
|
+
fn: string;
|
|
779
|
+
/** Colour for class-name tokens. */
|
|
780
|
+
cls: string;
|
|
781
|
+
/** Colour for type-name tokens. */
|
|
782
|
+
typ: string;
|
|
783
|
+
/** Colour for string-literal tokens. */
|
|
784
|
+
str: string;
|
|
785
|
+
/** Colour for numeric-literal tokens. */
|
|
786
|
+
num: string;
|
|
787
|
+
/** Colour for comment tokens. */
|
|
788
|
+
cmt: string;
|
|
789
|
+
/** Colour for decorator tokens. */
|
|
790
|
+
dec: string;
|
|
791
|
+
/** Colour for operator tokens. */
|
|
792
|
+
op: string;
|
|
793
|
+
/** Colour for plain (un-tokenised) text. */
|
|
794
|
+
txt: string;
|
|
795
|
+
/** Index signature — allows token class names to be used as dynamic keys. */
|
|
796
|
+
[key: string]: string;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* A selection range defined by an anchor (where selection started)
|
|
801
|
+
* and a focus (where the caret currently sits). Either end can be
|
|
802
|
+
* before the other — use `normaliseSelection` when you need start ≤ end.
|
|
803
|
+
*/
|
|
804
|
+
declare interface Selection_2 {
|
|
805
|
+
/** Anchor row — the line where the selection was started. */
|
|
806
|
+
ar: number;
|
|
807
|
+
/** Anchor column — the character offset where the selection was started. */
|
|
808
|
+
ac: number;
|
|
809
|
+
/** Focus row — the line where the caret currently sits. */
|
|
810
|
+
fr: number;
|
|
811
|
+
/** Focus column — the character offset where the caret currently sits. */
|
|
812
|
+
fc: number;
|
|
813
|
+
}
|
|
814
|
+
export { Selection_2 as Selection }
|
|
815
|
+
|
|
816
|
+
export declare class SynclineEditor implements EditorAPI {
|
|
817
|
+
private readonly _host;
|
|
818
|
+
private readonly _shadow;
|
|
819
|
+
private readonly _editorEl;
|
|
820
|
+
private readonly _spacerEl;
|
|
821
|
+
private readonly _vpEl;
|
|
822
|
+
private readonly _inputEl;
|
|
823
|
+
private readonly _minimapWrap;
|
|
824
|
+
private readonly _mmCanvas;
|
|
825
|
+
private readonly _mmSlider;
|
|
826
|
+
private readonly _statusBar;
|
|
827
|
+
private readonly _findBar;
|
|
828
|
+
private readonly _findInput;
|
|
829
|
+
private readonly _replaceInput;
|
|
830
|
+
private readonly _findCount;
|
|
831
|
+
private readonly _replaceRow;
|
|
832
|
+
private readonly _acPopup;
|
|
833
|
+
private readonly _emmetTip;
|
|
834
|
+
private readonly _snippetTip;
|
|
835
|
+
private readonly _hoverTip;
|
|
836
|
+
private readonly _themeOverlay;
|
|
837
|
+
private readonly _themePanel;
|
|
838
|
+
private _config;
|
|
839
|
+
private _tab;
|
|
840
|
+
private _wm;
|
|
841
|
+
private _foldedLines;
|
|
842
|
+
private _tokenCache;
|
|
843
|
+
private _themeManager;
|
|
844
|
+
private _findMatches;
|
|
845
|
+
private _findIdx;
|
|
846
|
+
private _findCaseSensitive;
|
|
847
|
+
private _findRegex;
|
|
848
|
+
private _wordHighlights;
|
|
849
|
+
private _bracketMatch;
|
|
850
|
+
private _acItems;
|
|
851
|
+
private _acSel;
|
|
852
|
+
private _acPrefix;
|
|
853
|
+
private _acStartCol;
|
|
854
|
+
private _emmetAcStartCol;
|
|
855
|
+
private _mc;
|
|
856
|
+
private _extraCursors;
|
|
857
|
+
private _isDragging;
|
|
858
|
+
private _dragAnchor;
|
|
859
|
+
private _hoverTimer;
|
|
860
|
+
private _hoverPinned;
|
|
861
|
+
private _mmDragMode;
|
|
862
|
+
private _mmDragStartY;
|
|
863
|
+
private _mmDragStartScroll;
|
|
864
|
+
private _mmSliderOffset;
|
|
865
|
+
private _mmColors;
|
|
866
|
+
private _lastInputTime;
|
|
867
|
+
private _dynamicStyleEl;
|
|
868
|
+
private _emmetExpanded;
|
|
869
|
+
private _snippetExpanded;
|
|
870
|
+
/** Pending debounce timer ID for autocomplete re-computation. */
|
|
871
|
+
private _acDebounceTimer;
|
|
872
|
+
/** Pending requestAnimationFrame ID for coalesced renders. */
|
|
873
|
+
private _rafId;
|
|
874
|
+
private readonly _onWinMouseUp;
|
|
875
|
+
private readonly _onWinResize;
|
|
876
|
+
private readonly _onEditorScroll;
|
|
877
|
+
private readonly _onWinMmMouseMove;
|
|
878
|
+
private readonly _onWinMmMouseUp;
|
|
879
|
+
private _ro;
|
|
880
|
+
constructor(container: HTMLElement, config?: EditorConfig);
|
|
881
|
+
getValue(): string;
|
|
882
|
+
setValue(value: string): void;
|
|
883
|
+
getCursor(): CursorPosition;
|
|
884
|
+
setCursor(pos: CursorPosition): void;
|
|
885
|
+
getSelection(): Selection_2 | null;
|
|
886
|
+
setSelection(sel: Selection_2 | null): void;
|
|
887
|
+
insertText(text: string): void;
|
|
888
|
+
setTheme(theme: string | ThemeDefinition): void;
|
|
889
|
+
updateConfig(patch: Partial<EditorConfig>): void;
|
|
890
|
+
focus(): void;
|
|
891
|
+
getThemes(): string[];
|
|
892
|
+
registerTheme(theme: ThemeDefinition): void;
|
|
893
|
+
undo(): void;
|
|
894
|
+
redo(): void;
|
|
895
|
+
executeCommand(command: string): void;
|
|
896
|
+
destroy(): void;
|
|
897
|
+
private _buildFindBar;
|
|
898
|
+
private _buildStatusBar;
|
|
899
|
+
private _applyDynamicStyles;
|
|
900
|
+
/**
|
|
901
|
+
* Apply tokenColors overrides as inline styles on the host element.
|
|
902
|
+
* Must be called AFTER the theme has applied its own inline styles so
|
|
903
|
+
* our values win (last writer wins for element.style.setProperty).
|
|
904
|
+
* When a token field is empty/absent, restore the active theme's value.
|
|
905
|
+
*/
|
|
906
|
+
private _applyTokenOverrides;
|
|
907
|
+
/**
|
|
908
|
+
* Schedule a render on the next animation frame.
|
|
909
|
+
* Multiple calls within a single frame are coalesced into one render —
|
|
910
|
+
* ideal for scroll and resize handlers which can fire at 60+ Hz.
|
|
911
|
+
*/
|
|
912
|
+
private _scheduleRender;
|
|
913
|
+
private _render;
|
|
914
|
+
private readonly _onFoldBtnClick;
|
|
915
|
+
private _updateStatusBar;
|
|
916
|
+
private _updateMinimap;
|
|
917
|
+
private _rebuildWrapMap;
|
|
918
|
+
private _scrollIntoView;
|
|
919
|
+
private _focusInput;
|
|
920
|
+
private _insertStr;
|
|
921
|
+
private _doBackspace;
|
|
922
|
+
private _doEnter;
|
|
923
|
+
private _doDelete;
|
|
924
|
+
private _selectAll;
|
|
925
|
+
private _doCopy;
|
|
926
|
+
private _doCut;
|
|
927
|
+
private _toggleComment;
|
|
928
|
+
private _duplicateLine;
|
|
929
|
+
private _deleteLine;
|
|
930
|
+
private _indentSel;
|
|
931
|
+
private _unindentSel;
|
|
932
|
+
private _toggleWrap;
|
|
933
|
+
private _getSelRows;
|
|
934
|
+
private _posFromMouse;
|
|
935
|
+
private _openFind;
|
|
936
|
+
private _closeFind;
|
|
937
|
+
private _runFind;
|
|
938
|
+
private _navFind;
|
|
939
|
+
private _acVisible;
|
|
940
|
+
private _acHide;
|
|
941
|
+
/**
|
|
942
|
+
* Schedule an autocomplete refresh after a brief debounce pause.
|
|
943
|
+
* Prevents the suggestion engine running on every single keystroke —
|
|
944
|
+
* only fires when the user pauses for `AC_DEBOUNCE_MS` milliseconds.
|
|
945
|
+
* Call `_acTriggerNow()` directly when an immediate refresh is required
|
|
946
|
+
* (e.g., on explicit Ctrl+Space or arrow-key navigation).
|
|
947
|
+
*/
|
|
948
|
+
private _acTrigger;
|
|
949
|
+
/** Run an autocomplete refresh immediately (no debounce). */
|
|
950
|
+
private _acTriggerNow;
|
|
951
|
+
private _renderAcPopup;
|
|
952
|
+
private _posAcPopup;
|
|
953
|
+
private _acAccept;
|
|
954
|
+
private _emmetCheck;
|
|
955
|
+
private _emmetAccept;
|
|
956
|
+
/** Returns built-in snippets for the current language merged with user completions.
|
|
957
|
+
* When `replaceBuiltins` is true the language built-ins are suppressed so only
|
|
958
|
+
* the caller-supplied completions (e.g. MDX_SNIPPETS) are active. */
|
|
959
|
+
private _allCompletions;
|
|
960
|
+
private _snippetCheck;
|
|
961
|
+
private _snippetAccept;
|
|
962
|
+
/**
|
|
963
|
+
* Expand a snippet/emmet body template at the current cursor position.
|
|
964
|
+
* `triggerStart` is the column where the trigger word begins.
|
|
965
|
+
* `cur.col` must be at the end of the trigger (emmet) or at `triggerStart`
|
|
966
|
+
* when the prefix was already stripped (snippet accepted from popup).
|
|
967
|
+
* Everything between `triggerStart` and `cur.col` is replaced by `body`.
|
|
968
|
+
*/
|
|
969
|
+
private _expandBodyAt;
|
|
970
|
+
private _openThemePicker;
|
|
971
|
+
private _bindEditorEvents;
|
|
972
|
+
private _onKeyDown;
|
|
973
|
+
private _handleArrowKeys;
|
|
974
|
+
private _isWordChar;
|
|
975
|
+
private _wordSkipRight;
|
|
976
|
+
private _wordSkipLeft;
|
|
977
|
+
private _moveLines;
|
|
978
|
+
private _scheduleHover;
|
|
979
|
+
private _doHover;
|
|
980
|
+
private _showHoverTip;
|
|
981
|
+
private _hideHover;
|
|
982
|
+
private _onInput;
|
|
983
|
+
private _ctrlD;
|
|
984
|
+
private _bindFindEvents;
|
|
985
|
+
private _doReplaceOne;
|
|
986
|
+
private _doReplaceAll;
|
|
987
|
+
private _bindMinimapEvents;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
export declare const THEME_DRACULA: ThemeDefinition;
|
|
991
|
+
|
|
992
|
+
export declare const THEME_GITHUB_LIGHT: ThemeDefinition;
|
|
993
|
+
|
|
994
|
+
export declare const THEME_MONOKAI: ThemeDefinition;
|
|
995
|
+
|
|
996
|
+
export declare const THEME_SOLARIZED_LIGHT: ThemeDefinition;
|
|
997
|
+
|
|
998
|
+
export declare const THEME_VR_DARK: ThemeDefinition;
|
|
999
|
+
|
|
1000
|
+
export declare const THEME_VSCODE_DARK: ThemeDefinition;
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* A named, complete theme definition.
|
|
1004
|
+
* Pass a `ThemeDefinition` to `setTheme()` or `registerTheme()` to apply
|
|
1005
|
+
* a fully custom colour scheme at runtime.
|
|
1006
|
+
*/
|
|
1007
|
+
export declare interface ThemeDefinition {
|
|
1008
|
+
/** Unique identifier used to reference this theme (e.g. `'my-dark'`). */
|
|
1009
|
+
id: string;
|
|
1010
|
+
/** Human-readable display name shown in the theme picker. */
|
|
1011
|
+
name: string;
|
|
1012
|
+
/** Short description of the theme's appearance or origin. */
|
|
1013
|
+
description: string;
|
|
1014
|
+
/** `true` for light themes, `false` for dark themes. */
|
|
1015
|
+
light: boolean;
|
|
1016
|
+
/** Complete set of colour values for every CSS variable the theme controls. */
|
|
1017
|
+
tokens: ThemeTokens;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/** ─── Theme ─────────────────────────────────────────────── */
|
|
1021
|
+
/**
|
|
1022
|
+
* The complete set of CSS custom-property values that define a theme's
|
|
1023
|
+
* visual appearance. Every key maps 1-to-1 with a `--<name>` CSS variable
|
|
1024
|
+
* injected on the editor host element.
|
|
1025
|
+
*/
|
|
1026
|
+
export declare interface ThemeTokens {
|
|
1027
|
+
/** Deepest background — editor chrome and overall host fill. */
|
|
1028
|
+
bg0: string;
|
|
1029
|
+
/** Slightly lighter background — used for panels and sidebars. */
|
|
1030
|
+
bg1: string;
|
|
1031
|
+
/** Editor pane background. */
|
|
1032
|
+
bg2: string;
|
|
1033
|
+
/** Popover / floating-panel background (find bar, theme picker). */
|
|
1034
|
+
bg3: string;
|
|
1035
|
+
/** Input and list-item background inside popovers. */
|
|
1036
|
+
bg4: string;
|
|
1037
|
+
/** Subtle border — low-contrast dividers. */
|
|
1038
|
+
border: string;
|
|
1039
|
+
/** Medium-contrast border. */
|
|
1040
|
+
border2: string;
|
|
1041
|
+
/** High-contrast border — used for focused inputs and active elements. */
|
|
1042
|
+
border3: string;
|
|
1043
|
+
/** Primary text colour for code and labels. */
|
|
1044
|
+
text: string;
|
|
1045
|
+
/** Secondary text colour for metadata and de-emphasised labels. */
|
|
1046
|
+
text2: string;
|
|
1047
|
+
/** Muted text colour for placeholders and disabled states. */
|
|
1048
|
+
text3: string;
|
|
1049
|
+
/** Primary accent — cursor, links, and active highlights. */
|
|
1050
|
+
accent: string;
|
|
1051
|
+
/** Darker accent — status bar background. */
|
|
1052
|
+
accent2: string;
|
|
1053
|
+
/** Semantic green (success, string tokens in some themes). */
|
|
1054
|
+
green: string;
|
|
1055
|
+
/** Semantic orange (warnings, function tokens in some themes). */
|
|
1056
|
+
orange: string;
|
|
1057
|
+
/** Semantic purple (numbers, extra cursors). */
|
|
1058
|
+
purple: string;
|
|
1059
|
+
/** Semantic red (errors, decorator tokens). */
|
|
1060
|
+
red: string;
|
|
1061
|
+
/** Semantic yellow (class names in some themes). */
|
|
1062
|
+
yellow: string;
|
|
1063
|
+
/** Cursor beam / block fill colour. */
|
|
1064
|
+
cur: string;
|
|
1065
|
+
/** Glow halo colour rendered around the cursor. */
|
|
1066
|
+
curGlow: string;
|
|
1067
|
+
/** Background tint applied to the current-line row. */
|
|
1068
|
+
curLineBg: string;
|
|
1069
|
+
/** Gutter cell background on the current-line row. */
|
|
1070
|
+
curLineGutter: string;
|
|
1071
|
+
/** Default gutter background. */
|
|
1072
|
+
gutterBg: string;
|
|
1073
|
+
/** Gutter background on row hover. */
|
|
1074
|
+
gutterHover: string;
|
|
1075
|
+
/** Gutter right-border colour. */
|
|
1076
|
+
gutterBorder: string;
|
|
1077
|
+
/** Line-number text colour (inactive lines). */
|
|
1078
|
+
gutterNum: string;
|
|
1079
|
+
/** Line-number text colour on the active (cursor) line. */
|
|
1080
|
+
gutterNumAct: string;
|
|
1081
|
+
/** Background tint for selected text. */
|
|
1082
|
+
selBg: string;
|
|
1083
|
+
/** Background tint for word-occurrence highlights. */
|
|
1084
|
+
wordHlBg: string;
|
|
1085
|
+
/** Border colour for word-occurrence highlights. */
|
|
1086
|
+
wordHlBorder: string;
|
|
1087
|
+
/** Border colour for bracket-match highlights. */
|
|
1088
|
+
bmBorder: string;
|
|
1089
|
+
/** Background tint applied to folded-line rows. */
|
|
1090
|
+
foldBg: string;
|
|
1091
|
+
/** Bottom-border colour on folded-line rows. */
|
|
1092
|
+
foldBorder: string;
|
|
1093
|
+
/** Background tint for non-current find matches. */
|
|
1094
|
+
findBg: string;
|
|
1095
|
+
/** Border colour for non-current find matches. */
|
|
1096
|
+
findBorder: string;
|
|
1097
|
+
/** Background for the currently active find match. */
|
|
1098
|
+
findCurBg: string;
|
|
1099
|
+
/** Border colour for the currently active find match. */
|
|
1100
|
+
findCurBorder: string;
|
|
1101
|
+
/** Text colour inside the currently active find match. */
|
|
1102
|
+
findCurText: string;
|
|
1103
|
+
/** Background for the active file entry in a sidebar. */
|
|
1104
|
+
fileActiveBg: string;
|
|
1105
|
+
/** Text colour for the active file entry in a sidebar. */
|
|
1106
|
+
fileActiveText: string;
|
|
1107
|
+
/** Minimap panel background. */
|
|
1108
|
+
mmBg: string;
|
|
1109
|
+
/** Minimap viewport-slider fill colour. */
|
|
1110
|
+
mmSlider: string;
|
|
1111
|
+
/** Semi-transparent overlay dimming the out-of-view minimap area. */
|
|
1112
|
+
mmDim: string;
|
|
1113
|
+
/** Edge highlight on the minimap slider. */
|
|
1114
|
+
mmEdge: string;
|
|
1115
|
+
/** Colour of vertical indent-guide lines. */
|
|
1116
|
+
indentGuide: string;
|
|
1117
|
+
/** Colour for keyword tokens (`kw`). */
|
|
1118
|
+
tokKw: string;
|
|
1119
|
+
/** Colour for string-literal tokens (`str`). */
|
|
1120
|
+
tokStr: string;
|
|
1121
|
+
/** Colour for comment tokens (`cmt`). */
|
|
1122
|
+
tokCmt: string;
|
|
1123
|
+
/** Colour for function-name tokens (`fn`). */
|
|
1124
|
+
tokFn: string;
|
|
1125
|
+
/** Colour for numeric-literal tokens (`num`). */
|
|
1126
|
+
tokNum: string;
|
|
1127
|
+
/** Colour for class-name tokens (`cls`). */
|
|
1128
|
+
tokCls: string;
|
|
1129
|
+
/** Colour for operator tokens (`op`). */
|
|
1130
|
+
tokOp: string;
|
|
1131
|
+
/** Colour for type-name tokens (`typ`). */
|
|
1132
|
+
tokTyp: string;
|
|
1133
|
+
/** Colour for decorator tokens (`dec`). */
|
|
1134
|
+
tokDec: string;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Per-token syntax-highlight colour overrides.
|
|
1139
|
+
*
|
|
1140
|
+
* Set any subset of these to override the corresponding CSS variable on top
|
|
1141
|
+
* of the active theme — without needing to register a full `ThemeDefinition`.
|
|
1142
|
+
* Accepts any valid CSS colour string (`'#ff79c6'`, `'hsl(330,100%,74%)'`,
|
|
1143
|
+
* `'rgba(255,121,198,.9)'`, etc.).
|
|
1144
|
+
*
|
|
1145
|
+
* These map 1-to-1 to the `ThemeTokens` syntax fields:
|
|
1146
|
+
* `keyword → tokKw`, `string → tokStr`, `comment → tokCmt`,
|
|
1147
|
+
* `function → tokFn`, `number → tokNum`, `class → tokCls`,
|
|
1148
|
+
* `operator → tokOp`, `type → tokTyp`, `decorator → tokDec`.
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* ```ts
|
|
1152
|
+
* editor.updateConfig({
|
|
1153
|
+
* tokenColors: {
|
|
1154
|
+
* keyword: '#ff79c6', // pink keywords
|
|
1155
|
+
* string: '#f1fa8c', // yellow strings
|
|
1156
|
+
* type: '#8be9fd', // cyan types
|
|
1157
|
+
* comment: '#6272a4', // muted comments
|
|
1158
|
+
* }
|
|
1159
|
+
* });
|
|
1160
|
+
* ```
|
|
1161
|
+
*/
|
|
1162
|
+
export declare interface TokenColors {
|
|
1163
|
+
/** Colour for keyword tokens — `if`, `const`, `class`, `interface`, `return`, etc. */
|
|
1164
|
+
keyword?: string;
|
|
1165
|
+
/** Colour for string-literal tokens — single-quoted, double-quoted, and template literals. */
|
|
1166
|
+
string?: string;
|
|
1167
|
+
/** Colour for comment tokens — line comments (//) and block comments. */
|
|
1168
|
+
comment?: string;
|
|
1169
|
+
/** Colour for function-name tokens — `console`, `fetch`, `myFn` when followed by `(`. */
|
|
1170
|
+
function?: string;
|
|
1171
|
+
/** Colour for numeric-literal tokens — `42`, `3.14`, `0xff`, `1n`. */
|
|
1172
|
+
number?: string;
|
|
1173
|
+
/** Colour for class-name tokens — `MyClass`, `EventEmitter`, constructor calls. */
|
|
1174
|
+
class?: string;
|
|
1175
|
+
/** Colour for operator tokens — `+`, `=>`, `===`, `&&`, `?.`, `|`. */
|
|
1176
|
+
operator?: string;
|
|
1177
|
+
/** Colour for type-name tokens — `string`, `number`, `boolean`, `Promise`, `Record`. */
|
|
1178
|
+
type?: string;
|
|
1179
|
+
/** Colour for decorator tokens — `@Component`, `@Injectable`, `@deprecated`. */
|
|
1180
|
+
decorator?: string;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
export { }
|