@synclineapi/editor 4.0.2 → 4.0.4
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 +217 -4
- package/dist/syncline-editor.es.js +5364 -0
- package/dist/syncline-editor.es.js.map +1 -0
- package/dist/syncline-editor.umd.js +520 -0
- package/dist/syncline-editor.umd.js.map +1 -0
- package/dist/types/index.d.ts +1474 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1474 @@
|
|
|
1
|
+
declare interface BracketMatch {
|
|
2
|
+
open: CursorPosition;
|
|
3
|
+
close: CursorPosition;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export declare const BUILT_IN_THEMES: ThemeDefinition[];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Snapshot of token cache performance counters.
|
|
10
|
+
* Useful for monitoring and diagnosing tokeniser regressions.
|
|
11
|
+
*/
|
|
12
|
+
export declare interface CacheMetrics {
|
|
13
|
+
/** Number of successful cache lookups (cache hits). */
|
|
14
|
+
hits: number;
|
|
15
|
+
/** Number of failed lookups that required re-tokenising a line. */
|
|
16
|
+
misses: number;
|
|
17
|
+
/** Number of entries evicted to stay within `maxSize`. */
|
|
18
|
+
evictions: number;
|
|
19
|
+
/** Current number of entries in the cache. */
|
|
20
|
+
size: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Context passed to a `provideCompletions` callback.
|
|
25
|
+
* Describes the current cursor position and document state at the moment
|
|
26
|
+
* the autocomplete popup is about to open.
|
|
27
|
+
*/
|
|
28
|
+
export declare interface CompletionContext {
|
|
29
|
+
/** The full text of the line the cursor is on. */
|
|
30
|
+
line: string;
|
|
31
|
+
/** Zero-based column index of the cursor within the line. */
|
|
32
|
+
col: number;
|
|
33
|
+
/** The word-prefix immediately before the cursor (characters typed so far). */
|
|
34
|
+
prefix: string;
|
|
35
|
+
/** The active language identifier (e.g. `'typescript'`, `'css'`). */
|
|
36
|
+
language: string;
|
|
37
|
+
/** The full document as an array of lines (read-only view). */
|
|
38
|
+
doc: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A single entry shown in the autocomplete popup.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const item: CompletionItem = {
|
|
47
|
+
* label: 'myFunction',
|
|
48
|
+
* kind: 'fn',
|
|
49
|
+
* detail: '(x: number) => void',
|
|
50
|
+
* };
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare interface CompletionItem {
|
|
54
|
+
/** The text inserted when this item is accepted. Also used for filtering. */
|
|
55
|
+
label: string;
|
|
56
|
+
/** Visual category badge shown in the popup. */
|
|
57
|
+
kind: CompletionKind;
|
|
58
|
+
/**
|
|
59
|
+
* Short hint shown on the right side of the popup row (type signature, source, etc.).
|
|
60
|
+
* Keep this brief — one line or a short type annotation.
|
|
61
|
+
*/
|
|
62
|
+
detail?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Full documentation shown in the VS Code-style description panel on the right side
|
|
65
|
+
* of the popup when this item is selected. Supports plain text; newlines are rendered
|
|
66
|
+
* as paragraph breaks. Falls back to `body` preview for `'snip'` items when omitted.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* { label: 'fetch', kind: 'fn', detail: 'Promise<Response>',
|
|
71
|
+
* description: 'Fetches a resource from the network.\n\nReturns a Promise that resolves to a Response.' }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
description?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Snippet body template. When present, accepting this item expands the
|
|
77
|
+
* full body instead of inserting just the label. Use `$1`, `$2`, … as
|
|
78
|
+
* tab-stop placeholders — the cursor is placed at `$1` after expansion.
|
|
79
|
+
* Use `\n` for newlines; indentation is inherited from the trigger line.
|
|
80
|
+
*
|
|
81
|
+
* Set `kind` to `'snip'` so the badge shows **S** in the popup.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* { label: 'forof', kind: 'snip', detail: 'for…of loop',
|
|
86
|
+
* body: 'for (const $1 of $2) {\n $3\n}' }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
body?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Restrict this item to specific languages. When provided, the item only appears
|
|
92
|
+
* when the editor's active language matches. Omit to show in all languages.
|
|
93
|
+
*
|
|
94
|
+
* @example `language: 'typescript'` or `language: ['typescript', 'javascript']`
|
|
95
|
+
*/
|
|
96
|
+
language?: string | string[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Category of a completion item, controlling the badge icon shown in the popup.
|
|
101
|
+
*
|
|
102
|
+
* - `'kw'` — keyword (badge: **K**)
|
|
103
|
+
* - `'fn'` — function or method (badge: **f**)
|
|
104
|
+
* - `'typ'` — type or interface (badge: **T**)
|
|
105
|
+
* - `'cls'` — class (badge: **C**)
|
|
106
|
+
* - `'var'` — variable, property, or other symbol (badge: **·**)
|
|
107
|
+
* - `'snip'` — snippet template (badge: **S**); accepting expands a multi-line body
|
|
108
|
+
* - `'emmet'` — emmet abbreviation (badge: **E**); accepting expands the abbreviation to HTML
|
|
109
|
+
*/
|
|
110
|
+
export declare type CompletionKind = 'kw' | 'fn' | 'typ' | 'cls' | 'var' | 'snip' | 'emmet';
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Quick factory function for creating an editor instance.
|
|
114
|
+
*
|
|
115
|
+
* @param container The DOM element to mount the editor in.
|
|
116
|
+
* @param config Optional editor configuration.
|
|
117
|
+
* @returns The editor API.
|
|
118
|
+
*/
|
|
119
|
+
export declare function createEditor(container: HTMLElement, config?: EditorConfig): EditorAPI;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A single cursor position in document (line/column) space.
|
|
123
|
+
* Both `row` and `col` are zero-based.
|
|
124
|
+
*/
|
|
125
|
+
export declare interface CursorPosition {
|
|
126
|
+
/** Zero-based line index within the document. */
|
|
127
|
+
row: number;
|
|
128
|
+
/** Zero-based character offset within the line. */
|
|
129
|
+
col: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A single editing operation that can be applied forward (redo) or inverted (undo).
|
|
134
|
+
*
|
|
135
|
+
* - `insert` — `lines` were inserted starting at `row`. Undo removes them; redo re-inserts.
|
|
136
|
+
* - `delete` — `count` lines starting at `row` were removed; `removed` holds their content.
|
|
137
|
+
* Undo re-inserts; redo removes again.
|
|
138
|
+
* - `replace` — lines `[row, row + oldLines.length)` were replaced by `newLines`.
|
|
139
|
+
* Undo swaps `newLines` back to `oldLines`; redo swaps forward again.
|
|
140
|
+
*
|
|
141
|
+
* Only the affected lines are stored — never a full document copy — making this
|
|
142
|
+
* safe for documents with 1 M+ lines.
|
|
143
|
+
*/
|
|
144
|
+
declare type EditOp = {
|
|
145
|
+
kind: 'insert';
|
|
146
|
+
row: number;
|
|
147
|
+
lines: string[];
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'delete';
|
|
150
|
+
row: number;
|
|
151
|
+
count: number;
|
|
152
|
+
removed: string[];
|
|
153
|
+
} | {
|
|
154
|
+
kind: 'replace';
|
|
155
|
+
row: number;
|
|
156
|
+
oldLines: string[];
|
|
157
|
+
newLines: string[];
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Public API surface returned by `SynclineEditor.create()`.
|
|
162
|
+
* All methods are safe to call at any time after construction.
|
|
163
|
+
*/
|
|
164
|
+
export declare interface EditorAPI {
|
|
165
|
+
/**
|
|
166
|
+
* Returns the full document content as a single newline-joined string.
|
|
167
|
+
*/
|
|
168
|
+
getValue(): string;
|
|
169
|
+
/**
|
|
170
|
+
* Replaces the entire document content.
|
|
171
|
+
* Records an undo snapshot before overwriting, so the change can be undone.
|
|
172
|
+
* Fires `onChange`.
|
|
173
|
+
*/
|
|
174
|
+
setValue(value: string): void;
|
|
175
|
+
/**
|
|
176
|
+
* Returns a copy of the current cursor position.
|
|
177
|
+
*/
|
|
178
|
+
getCursor(): CursorPosition;
|
|
179
|
+
/**
|
|
180
|
+
* Moves the cursor to the given position and scrolls it into view.
|
|
181
|
+
*/
|
|
182
|
+
setCursor(position: CursorPosition): void;
|
|
183
|
+
/**
|
|
184
|
+
* Returns a copy of the current selection, or `null` if nothing is selected.
|
|
185
|
+
*/
|
|
186
|
+
getSelection(): Selection_2 | null;
|
|
187
|
+
/**
|
|
188
|
+
* Sets or clears the selection without moving the cursor.
|
|
189
|
+
* Pass `null` to deselect.
|
|
190
|
+
*/
|
|
191
|
+
setSelection(selection: Selection_2 | null): void;
|
|
192
|
+
/**
|
|
193
|
+
* Inserts text at the current cursor position, replacing any active selection.
|
|
194
|
+
* No-op when `readOnly` is `true`.
|
|
195
|
+
*/
|
|
196
|
+
insertText(text: string): void;
|
|
197
|
+
/**
|
|
198
|
+
* Applies a theme by registered ID or by passing a full `ThemeDefinition`.
|
|
199
|
+
* Rebuilds minimap colours and re-renders immediately.
|
|
200
|
+
*/
|
|
201
|
+
setTheme(theme: string | ThemeDefinition): void;
|
|
202
|
+
/**
|
|
203
|
+
* Updates any subset of config options at runtime.
|
|
204
|
+
* Visual options (font, cursor, gutter, etc.) take effect immediately.
|
|
205
|
+
* Structural options (`showMinimap`, `showStatusBar`) add or remove DOM nodes.
|
|
206
|
+
*/
|
|
207
|
+
updateConfig(patch: Partial<EditorConfig>): void;
|
|
208
|
+
/**
|
|
209
|
+
* Focuses the hidden textarea that captures keyboard input.
|
|
210
|
+
*/
|
|
211
|
+
focus(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Returns the IDs of all currently registered themes (built-in + custom).
|
|
214
|
+
*/
|
|
215
|
+
getThemes(): string[];
|
|
216
|
+
/**
|
|
217
|
+
* Registers a custom theme so it can be applied by ID via `setTheme()`.
|
|
218
|
+
* If a theme with the same `id` already exists it is overwritten.
|
|
219
|
+
*/
|
|
220
|
+
registerTheme(theme: ThemeDefinition): void;
|
|
221
|
+
/**
|
|
222
|
+
* Undoes the last edit operation.
|
|
223
|
+
* No-op if the undo stack is empty or `readOnly` is `true`.
|
|
224
|
+
*/
|
|
225
|
+
undo(): void;
|
|
226
|
+
/**
|
|
227
|
+
* Redoes the last undone operation.
|
|
228
|
+
* No-op if the redo stack is empty or `readOnly` is `true`.
|
|
229
|
+
*/
|
|
230
|
+
redo(): void;
|
|
231
|
+
/**
|
|
232
|
+
* Executes a built-in editor command by name.
|
|
233
|
+
* Mutating commands are no-ops when `readOnly` is `true`.
|
|
234
|
+
*
|
|
235
|
+
* Supported command names:
|
|
236
|
+
* `'undo'`, `'redo'`, `'selectAll'`, `'copy'`, `'cut'`,
|
|
237
|
+
* `'toggleComment'`, `'duplicateLine'`, `'deleteLine'`,
|
|
238
|
+
* `'toggleWordWrap'`, `'find'`, `'findReplace'`,
|
|
239
|
+
* `'indentLine'`, `'outdentLine'`
|
|
240
|
+
*/
|
|
241
|
+
executeCommand(command: string): void;
|
|
242
|
+
/**
|
|
243
|
+
* Removes all editor DOM nodes from the host element and cleans up
|
|
244
|
+
* internal state. The instance should not be used after calling this.
|
|
245
|
+
*/
|
|
246
|
+
destroy(): void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare abstract class EditorAutocomplete extends EditorFind {
|
|
250
|
+
protected _acVisible(): boolean;
|
|
251
|
+
protected _acHide(): void;
|
|
252
|
+
protected _acTrigger(): void;
|
|
253
|
+
protected _acTriggerNow(): void;
|
|
254
|
+
protected _renderAcPopup(): void;
|
|
255
|
+
protected _posAcPopup(): void;
|
|
256
|
+
protected _acAccept(): void;
|
|
257
|
+
protected _allCompletions(): CompletionItem[];
|
|
258
|
+
protected _emmetCheck(): void;
|
|
259
|
+
protected _emmetAccept(): boolean;
|
|
260
|
+
protected _snippetCheck(): void;
|
|
261
|
+
protected _snippetAccept(): boolean;
|
|
262
|
+
protected _expandBodyAt(body: string, triggerStart: number): void;
|
|
263
|
+
protected _ctrlD(): void;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
declare abstract class EditorBase {
|
|
267
|
+
protected readonly _host: HTMLElement;
|
|
268
|
+
protected readonly _shadow: ShadowRoot;
|
|
269
|
+
protected readonly _editorEl: HTMLElement;
|
|
270
|
+
protected readonly _spacerEl: HTMLElement;
|
|
271
|
+
protected readonly _vpEl: HTMLElement;
|
|
272
|
+
protected readonly _inputEl: HTMLTextAreaElement;
|
|
273
|
+
protected readonly _minimapWrap: HTMLElement;
|
|
274
|
+
protected readonly _mmCanvas: HTMLCanvasElement;
|
|
275
|
+
protected readonly _mmSlider: HTMLElement;
|
|
276
|
+
protected readonly _statusBar: HTMLElement;
|
|
277
|
+
protected readonly _findBar: HTMLElement;
|
|
278
|
+
protected readonly _findInput: HTMLInputElement;
|
|
279
|
+
protected readonly _replaceInput: HTMLInputElement;
|
|
280
|
+
protected readonly _findCount: HTMLElement;
|
|
281
|
+
protected readonly _replaceRow: HTMLElement;
|
|
282
|
+
protected readonly _acPopup: HTMLElement;
|
|
283
|
+
protected readonly _emmetTip: HTMLElement;
|
|
284
|
+
protected readonly _snippetTip: HTMLElement;
|
|
285
|
+
protected readonly _hoverTip: HTMLElement;
|
|
286
|
+
protected readonly _themeOverlay: HTMLElement;
|
|
287
|
+
protected readonly _themePanel: HTMLElement;
|
|
288
|
+
protected readonly _placeholderEl: HTMLElement;
|
|
289
|
+
protected readonly _goToLineBar: HTMLElement;
|
|
290
|
+
protected readonly _goToLineInput: HTMLInputElement;
|
|
291
|
+
protected readonly _goToLineHint: HTMLElement;
|
|
292
|
+
protected _config: Required<EditorConfig>;
|
|
293
|
+
protected _tab: EditorTab;
|
|
294
|
+
protected _wm: WrapMap;
|
|
295
|
+
protected _foldedLines: Map<number, number>;
|
|
296
|
+
protected _tokenCache: TokenCache;
|
|
297
|
+
protected _themeManager: ThemeManager;
|
|
298
|
+
protected _findMatches: FindMatch[];
|
|
299
|
+
protected _findIdx: number;
|
|
300
|
+
protected _findCaseSensitive: boolean;
|
|
301
|
+
protected _findRegex: boolean;
|
|
302
|
+
protected _wordHighlights: FindMatch[];
|
|
303
|
+
protected _bracketMatch: BracketMatch | null;
|
|
304
|
+
protected _acItems: CompletionItem[];
|
|
305
|
+
protected _acSel: number;
|
|
306
|
+
protected _acPrefix: string;
|
|
307
|
+
protected _acStartCol: number;
|
|
308
|
+
protected _emmetAcStartCol: number;
|
|
309
|
+
protected _mc: MultiCursorState;
|
|
310
|
+
protected _extraCursors: ExtraCursor[];
|
|
311
|
+
protected _isDragging: boolean;
|
|
312
|
+
protected _dragAnchor: CursorPosition | null;
|
|
313
|
+
protected _hoverTimer: ReturnType<typeof setTimeout> | null;
|
|
314
|
+
protected _hoverPinned: boolean;
|
|
315
|
+
protected _mmDragMode: 'none' | 'slider' | 'jump';
|
|
316
|
+
protected _mmDragStartY: number;
|
|
317
|
+
protected _mmDragStartScroll: number;
|
|
318
|
+
protected _mmSliderOffset: number;
|
|
319
|
+
protected _mmColors: MinimapColors;
|
|
320
|
+
protected _lastInputTime: number;
|
|
321
|
+
protected _linewiseCopy: boolean;
|
|
322
|
+
protected _dynamicStyleEl: HTMLStyleElement;
|
|
323
|
+
protected _emmetExpanded: {
|
|
324
|
+
abbr: string;
|
|
325
|
+
result: string;
|
|
326
|
+
start: number;
|
|
327
|
+
} | null;
|
|
328
|
+
protected _snippetExpanded: {
|
|
329
|
+
snippet: CompletionItem;
|
|
330
|
+
start: number;
|
|
331
|
+
} | null;
|
|
332
|
+
protected _snippetSession: {
|
|
333
|
+
stops: Array<{
|
|
334
|
+
row: number;
|
|
335
|
+
col: number;
|
|
336
|
+
}>;
|
|
337
|
+
idx: number;
|
|
338
|
+
} | null;
|
|
339
|
+
protected _acDebounceTimer: ReturnType<typeof setTimeout> | null;
|
|
340
|
+
protected _rafId: number | null;
|
|
341
|
+
/** Number of visual rows currently rendered in the DOM viewport. */
|
|
342
|
+
protected _renderedRowCount: number;
|
|
343
|
+
/** Last scrollTop seen in _render(); used to gate wrap-map rebuilds. */
|
|
344
|
+
protected _lastRenderScroll: number;
|
|
345
|
+
protected _logicalScroll(domScrollTop: number): number;
|
|
346
|
+
protected _domScroll(logicalPx: number): number;
|
|
347
|
+
protected readonly _onWinMouseUp: () => void;
|
|
348
|
+
protected readonly _onWinResize: () => void;
|
|
349
|
+
protected readonly _onEditorScroll: () => void;
|
|
350
|
+
protected readonly _onWinMmMouseMove: (e: MouseEvent) => void;
|
|
351
|
+
protected readonly _onWinMmMouseUp: () => void;
|
|
352
|
+
protected _ro: ResizeObserver | null;
|
|
353
|
+
protected abstract _render(): void;
|
|
354
|
+
protected abstract _scheduleRender(): void;
|
|
355
|
+
protected abstract _scrollIntoView(): void;
|
|
356
|
+
protected abstract _applyDynamicStyles(): void;
|
|
357
|
+
protected abstract _rebuildWrapMap(): void;
|
|
358
|
+
protected abstract _bindEditorEvents(): void;
|
|
359
|
+
protected abstract _bindMinimapEvents(): void;
|
|
360
|
+
protected abstract _bindFindEvents(): void;
|
|
361
|
+
protected abstract _toggleWrap(): void;
|
|
362
|
+
protected abstract _openThemePicker(): void;
|
|
363
|
+
protected abstract _hideHover(): void;
|
|
364
|
+
protected abstract _updateMinimap(): void;
|
|
365
|
+
constructor(container: HTMLElement, config?: EditorConfig);
|
|
366
|
+
private _buildFindBar;
|
|
367
|
+
private _buildGoToLineBar;
|
|
368
|
+
protected _openGoToLine(): void;
|
|
369
|
+
protected _closeGoToLine(): void;
|
|
370
|
+
protected _focusInput(): void;
|
|
371
|
+
private _buildStatusBar;
|
|
372
|
+
protected _destroyBase(): void;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** ─── Editor Configuration ──────────────────────────────── */
|
|
376
|
+
/**
|
|
377
|
+
* Full, deeply-customisable editor configuration.
|
|
378
|
+
* Every field is optional — sensible defaults are applied for any omitted field.
|
|
379
|
+
* Pass this object to `SynclineEditor.create()` to configure the editor on
|
|
380
|
+
* initialisation, or call `updateConfig()` to change options at runtime.
|
|
381
|
+
*/
|
|
382
|
+
export declare interface EditorConfig {
|
|
383
|
+
/**
|
|
384
|
+
* Initial document content.
|
|
385
|
+
* Accepts either a newline-delimited string or a pre-split string array.
|
|
386
|
+
* Default: `''` (empty document).
|
|
387
|
+
*/
|
|
388
|
+
value?: string | string[];
|
|
389
|
+
/**
|
|
390
|
+
* Language used for syntax highlighting and autocomplete.
|
|
391
|
+
* Selects the built-in keyword set, type set, and built-in completion items
|
|
392
|
+
* appropriate for that language.
|
|
393
|
+
* Default: `'typescript'`.
|
|
394
|
+
*/
|
|
395
|
+
language?: Language;
|
|
396
|
+
/**
|
|
397
|
+
* Active theme.
|
|
398
|
+
* Pass a registered theme ID string (e.g. `'vr-dark'`) or a full
|
|
399
|
+
* `ThemeDefinition` object for a custom theme.
|
|
400
|
+
* Default: `''` (built-in VR Dark theme).
|
|
401
|
+
*/
|
|
402
|
+
theme?: string | ThemeDefinition;
|
|
403
|
+
/**
|
|
404
|
+
* Show the line-number gutter on the left side of the editor.
|
|
405
|
+
* When `false` the gutter is hidden and its width is removed from all
|
|
406
|
+
* mouse-position calculations.
|
|
407
|
+
* Default: `true`.
|
|
408
|
+
*/
|
|
409
|
+
showGutter?: boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Show the minimap panel on the right side of the editor.
|
|
412
|
+
* Can be toggled at runtime via `updateConfig({ showMinimap: false })`.
|
|
413
|
+
* Default: `true`.
|
|
414
|
+
*/
|
|
415
|
+
showMinimap?: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Show the status bar at the bottom of the editor.
|
|
418
|
+
* Displays cursor position, language, selection count, and undo depth.
|
|
419
|
+
* Default: `true`.
|
|
420
|
+
*/
|
|
421
|
+
showStatusBar?: boolean;
|
|
422
|
+
/**
|
|
423
|
+
* Wrap long lines at `wrapColumn` characters instead of scrolling horizontally.
|
|
424
|
+
* Wrapped lines produce multiple visual rows for a single document line.
|
|
425
|
+
* Toggle at runtime with `updateConfig({ wordWrap: true })` or `Alt+Z`.
|
|
426
|
+
* Default: `false`.
|
|
427
|
+
*/
|
|
428
|
+
wordWrap?: boolean;
|
|
429
|
+
/**
|
|
430
|
+
* Column at which lines are soft-wrapped when `wordWrap` is `true`.
|
|
431
|
+
* Has no effect when `wordWrap` is `false`.
|
|
432
|
+
* Default: `80`.
|
|
433
|
+
*/
|
|
434
|
+
wrapColumn?: number;
|
|
435
|
+
/**
|
|
436
|
+
* CSS font-family string applied to all code text and the gutter.
|
|
437
|
+
* Example: `"'Fira Code', monospace"`.
|
|
438
|
+
* Default: `"'JetBrains Mono', monospace"`.
|
|
439
|
+
*/
|
|
440
|
+
fontFamily?: string;
|
|
441
|
+
/**
|
|
442
|
+
* Font size in pixels applied to all code text.
|
|
443
|
+
* Default: `13`.
|
|
444
|
+
*/
|
|
445
|
+
fontSize?: number;
|
|
446
|
+
/**
|
|
447
|
+
* Line height in pixels. Controls row height, cursor size, and all
|
|
448
|
+
* scroll/minimap calculations. Must match the rendered font metrics to
|
|
449
|
+
* avoid misaligned click targets.
|
|
450
|
+
* Default: `22`.
|
|
451
|
+
*/
|
|
452
|
+
lineHeight?: number;
|
|
453
|
+
/**
|
|
454
|
+
* Number of spaces inserted when the Tab key is pressed (or used as the
|
|
455
|
+
* indentation unit when `insertSpaces` is `true`).
|
|
456
|
+
* Default: `2`.
|
|
457
|
+
*/
|
|
458
|
+
tabSize?: number;
|
|
459
|
+
/**
|
|
460
|
+
* When `true`, pressing Tab inserts spaces; when `false`, a literal tab
|
|
461
|
+
* character (`\t`) is inserted.
|
|
462
|
+
* Default: `true`.
|
|
463
|
+
*/
|
|
464
|
+
insertSpaces?: boolean;
|
|
465
|
+
/**
|
|
466
|
+
* Maximum number of undo snapshots retained per buffer.
|
|
467
|
+
* Older snapshots are discarded when the stack exceeds this limit.
|
|
468
|
+
* Default: `300`.
|
|
469
|
+
*/
|
|
470
|
+
maxUndoHistory?: number;
|
|
471
|
+
/**
|
|
472
|
+
* Render faint vertical lines at each indentation level to aid visual
|
|
473
|
+
* alignment of nested code blocks.
|
|
474
|
+
* Default: `true`.
|
|
475
|
+
*/
|
|
476
|
+
showIndentGuides?: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Highlight matching bracket pairs when the cursor is adjacent to a
|
|
479
|
+
* bracket character (`(`, `)`, `[`, `]`, `{`, `}`).
|
|
480
|
+
* Default: `true`.
|
|
481
|
+
*/
|
|
482
|
+
bracketMatching?: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* Enable code folding. When `true`, a fold toggle button appears in the
|
|
485
|
+
* gutter for foldable blocks (functions, classes, etc.).
|
|
486
|
+
* Default: `true`.
|
|
487
|
+
*/
|
|
488
|
+
codeFolding?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Enable Emmet abbreviation expansion via the Tab key.
|
|
491
|
+
* A preview tooltip appears when a valid Emmet abbreviation is detected
|
|
492
|
+
* before the cursor.
|
|
493
|
+
* Default: `true`.
|
|
494
|
+
*/
|
|
495
|
+
emmet?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* Enable snippet expansion via the Tab key.
|
|
498
|
+
* When the word immediately before the cursor matches a snippet trigger,
|
|
499
|
+
* pressing Tab replaces it with the snippet body and places the cursor
|
|
500
|
+
* at the first `$1` tab stop.
|
|
501
|
+
* Built-in snippets are provided for TypeScript/JavaScript, CSS, and HTML.
|
|
502
|
+
* A preview tooltip appears when a matching trigger is detected.
|
|
503
|
+
* Default: `true`.
|
|
504
|
+
*/
|
|
505
|
+
snippetExpansion?: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Show an autocomplete popup with suggestions as the user types.
|
|
508
|
+
* Suggestions are derived from symbols already present in the document.
|
|
509
|
+
* Default: `true`.
|
|
510
|
+
*/
|
|
511
|
+
autocomplete?: boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Allow multiple simultaneous cursors.
|
|
514
|
+
* Multi-cursor is activated via `Alt+Click` (add cursor) and `Ctrl+D`
|
|
515
|
+
* (select next occurrence). Setting this to `false` disables both.
|
|
516
|
+
* Default: `true`.
|
|
517
|
+
*/
|
|
518
|
+
multiCursor?: boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Enable the find bar (Ctrl+F / Cmd+F).
|
|
521
|
+
* When `false`, the find bar cannot be opened via keyboard shortcut or
|
|
522
|
+
* `executeCommand('find')`, and the Ctrl+F key combination is released
|
|
523
|
+
* back to the browser.
|
|
524
|
+
* Default: `true`.
|
|
525
|
+
*/
|
|
526
|
+
find?: boolean;
|
|
527
|
+
/**
|
|
528
|
+
* Enable find-and-replace (Ctrl+H / Cmd+H).
|
|
529
|
+
* When `false`, the replace row is inaccessible and Ctrl+H is a no-op.
|
|
530
|
+
* Has no effect when `find` is also `false`.
|
|
531
|
+
* Default: `true`.
|
|
532
|
+
*/
|
|
533
|
+
findReplace?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Enable word selection on double-click.
|
|
536
|
+
* When `true`, double-clicking a word selects it (standard editor behaviour).
|
|
537
|
+
* When `false`, double-clicking places the cursor without creating a selection.
|
|
538
|
+
* Default: `true`.
|
|
539
|
+
*/
|
|
540
|
+
wordSelection?: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Highlight all occurrences of the word currently under the cursor.
|
|
543
|
+
* When `true`, every other occurrence of the same whole-word token in the
|
|
544
|
+
* document gets a subtle background box (`--word-hl-bg` / `--word-hl-border`).
|
|
545
|
+
* Highlights are cleared automatically when a text selection is active.
|
|
546
|
+
* When `false`, no word-occurrence highlighting is applied.
|
|
547
|
+
* Default: `true`.
|
|
548
|
+
*/
|
|
549
|
+
wordHighlight?: boolean;
|
|
550
|
+
/**
|
|
551
|
+
* Highlight the line that currently contains the cursor with a distinct
|
|
552
|
+
* background colour (`--cur-line-bg`) and a matching gutter background.
|
|
553
|
+
* Set to `false` to disable the active-line indicator entirely.
|
|
554
|
+
* Default: `true`.
|
|
555
|
+
*/
|
|
556
|
+
highlightActiveLine?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Minimum number of characters the user must type before the autocomplete
|
|
559
|
+
* popup appears. Increasing this reduces noise on short prefixes; setting it
|
|
560
|
+
* to `1` triggers suggestions after a single character.
|
|
561
|
+
* Default: `2`.
|
|
562
|
+
*/
|
|
563
|
+
autocompletePrefixLength?: number;
|
|
564
|
+
/**
|
|
565
|
+
* Prevent all content mutations.
|
|
566
|
+
* When `true`, typing, paste, cut, undo/redo, and all other edit operations
|
|
567
|
+
* are silently blocked. Navigation, selection, copy, and find still work.
|
|
568
|
+
* Default: `false`.
|
|
569
|
+
*/
|
|
570
|
+
readOnly?: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Additional keywords to include in syntax highlighting beyond the
|
|
573
|
+
* built-in keyword list for the active language.
|
|
574
|
+
* Example: `['myDSLKeyword', 'pipeline']`.
|
|
575
|
+
* Default: `[]`.
|
|
576
|
+
*/
|
|
577
|
+
extraKeywords?: string[];
|
|
578
|
+
/**
|
|
579
|
+
* Additional type names to recognise during syntax highlighting beyond
|
|
580
|
+
* the built-in type list for the active language.
|
|
581
|
+
* Example: `['MyCustomType', 'Result']`.
|
|
582
|
+
* Default: `[]`.
|
|
583
|
+
*/
|
|
584
|
+
extraTypes?: string[];
|
|
585
|
+
/**
|
|
586
|
+
* The **single unified completions array** — the only completion source you need.
|
|
587
|
+
*
|
|
588
|
+
* Every item is a `CompletionItem`. Differentiate by `kind`:
|
|
589
|
+
* - `'kw'`, `'fn'`, `'typ'`, `'cls'`, `'var'` — regular completions merged with built-ins
|
|
590
|
+
* - `'snip'` — snippet: set `body` and the item expands like a snippet on accept
|
|
591
|
+
*
|
|
592
|
+
* All items can carry a `language` filter and a `description` for the docs panel.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```ts
|
|
596
|
+
* completions: [
|
|
597
|
+
* // Regular completion with docs
|
|
598
|
+
* { label: 'myQuery', kind: 'fn', detail: 'GraphQL helper',
|
|
599
|
+
* description: 'Executes a GraphQL query and returns the result.' },
|
|
600
|
+
* // Inline snippet
|
|
601
|
+
* { label: 'mycomp', kind: 'snip', detail: 'My component',
|
|
602
|
+
* body: 'export function $1Component() {\n return <div>$2</div>;\n}',
|
|
603
|
+
* language: ['typescript'] },
|
|
604
|
+
* ]
|
|
605
|
+
* ```
|
|
606
|
+
* Default: `[]`.
|
|
607
|
+
*/
|
|
608
|
+
completions?: CompletionItem[];
|
|
609
|
+
/**
|
|
610
|
+
* When `true`, the items in `completions` **replace** the built-in language
|
|
611
|
+
* keywords/types/functions entirely instead of being merged on top.
|
|
612
|
+
* Only the provided items (plus in-file word suggestions) will appear.
|
|
613
|
+
*
|
|
614
|
+
* Use alongside `completions`.
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* // DSL editor — show only your own keywords
|
|
619
|
+
* replaceBuiltins: true,
|
|
620
|
+
* completions: [
|
|
621
|
+
* { label: 'SELECT', kind: 'kw', detail: 'SQL' },
|
|
622
|
+
* { label: 'FROM', kind: 'kw', detail: 'SQL' },
|
|
623
|
+
* ]
|
|
624
|
+
* ```
|
|
625
|
+
* Default: `false`.
|
|
626
|
+
*/
|
|
627
|
+
replaceBuiltins?: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* Custom syntax tokeniser override.
|
|
630
|
+
*
|
|
631
|
+
* When provided, this function is called **instead of** the built-in
|
|
632
|
+
* regex-free tokeniser for **every line** before it is rendered.
|
|
633
|
+
* Return an array of `TokenSegment` objects that cover the half-open
|
|
634
|
+
* character ranges you want coloured. Ranges you don't cover are
|
|
635
|
+
* rendered as plain text.
|
|
636
|
+
*
|
|
637
|
+
* The result is still cached by the internal LRU token cache (keyed on
|
|
638
|
+
* the raw line text + language), so the function is only called once per
|
|
639
|
+
* unique `(text, language)` pair — not on every frame.
|
|
640
|
+
*
|
|
641
|
+
* Pass `null` or `undefined` to fall through to the built-in tokeniser.
|
|
642
|
+
*
|
|
643
|
+
* **Use this for custom languages, DSLs, or Markdown** where you need
|
|
644
|
+
* full control over which character ranges receive which token class.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```ts
|
|
648
|
+
* // Minimal Markdown tokeniser
|
|
649
|
+
* provideTokens: (line, _lang) => {
|
|
650
|
+
* const segs: TokenSegment[] = [];
|
|
651
|
+
* // ATX headings → keyword colour
|
|
652
|
+
* if (/^#{1,6}\s/.test(line))
|
|
653
|
+
* segs.push({ cls: 'kw', start: 0, end: line.length });
|
|
654
|
+
* // **bold** → string colour
|
|
655
|
+
* for (const m of line.matchAll(/\*\*(.+?)\*\*\/g))
|
|
656
|
+
* segs.push({ cls: 'str', start: m.index!, end: m.index! + m[0].length });
|
|
657
|
+
* return segs;
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* Default: `undefined` (use built-in tokeniser).
|
|
662
|
+
*/
|
|
663
|
+
provideTokens?: (line: string, language: string) => TokenSegment[];
|
|
664
|
+
/**
|
|
665
|
+
* Dynamic completion provider called each time the autocomplete popup is
|
|
666
|
+
* about to open. Receives a `CompletionContext` describing the current
|
|
667
|
+
* cursor position and returns an array of `CompletionItem` to display
|
|
668
|
+
* instead of the built-in language completions.
|
|
669
|
+
*
|
|
670
|
+
* Return `null` or `undefined` to fall through to the built-in defaults.
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```ts
|
|
674
|
+
* provideCompletions: (ctx) => {
|
|
675
|
+
* if (ctx.prefix.startsWith('$')) {
|
|
676
|
+
* return mySymbolTable.map(s => ({ label: s, kind: 'var' }));
|
|
677
|
+
* }
|
|
678
|
+
* return null; // use defaults
|
|
679
|
+
* }
|
|
680
|
+
* ```
|
|
681
|
+
* Default: `undefined` (use built-in language completions).
|
|
682
|
+
*/
|
|
683
|
+
provideCompletions?: (context: CompletionContext) => CompletionItem[] | null | undefined;
|
|
684
|
+
/**
|
|
685
|
+
* Auto-close bracket and quote pairs.
|
|
686
|
+
* When the user types the opening character, the closing character is
|
|
687
|
+
* inserted automatically and the cursor placed between them.
|
|
688
|
+
*
|
|
689
|
+
* Pass an empty object `{ } ` to disable all auto-closing.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```ts
|
|
693
|
+
* // Only auto-close parentheses and curly braces
|
|
694
|
+
* autoClosePairs: { '(': ')', '{': '}' }
|
|
695
|
+
* ```
|
|
696
|
+
* Default: `{ '(': ')', '[': ']', '{': '}', '"': '"', "'": "'", '`': '`' } `.
|
|
697
|
+
*/
|
|
698
|
+
autoClosePairs?: Record<string, string>;
|
|
699
|
+
/**
|
|
700
|
+
* Line comment token used by the "toggle comment" command (Ctrl+/).
|
|
701
|
+
* Set to the prefix string for single-line comments in your language.
|
|
702
|
+
*
|
|
703
|
+
* When empty or omitted, the editor auto-selects based on `language`:
|
|
704
|
+
* - TypeScript / JavaScript / CSS → `'//'`
|
|
705
|
+
* - Python / Ruby / Bash / YAML → `'#'`
|
|
706
|
+
* - Markdown / JSON → no comment token (toggle comment is a no-op)
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```ts
|
|
710
|
+
* lineCommentToken: '#' // Python, Ruby, shell scripts
|
|
711
|
+
* lineCommentToken: '--' // SQL, Lua
|
|
712
|
+
* lineCommentToken: '%' // LaTeX
|
|
713
|
+
* ```
|
|
714
|
+
* Default: `''` (auto-detect from language).
|
|
715
|
+
*/
|
|
716
|
+
lineCommentToken?: string;
|
|
717
|
+
/**
|
|
718
|
+
* A string containing every character that should be treated as a word
|
|
719
|
+
* separator (non-word character) for word-based operations: double-click
|
|
720
|
+
* word selection, Ctrl+Left/Right navigation, and Ctrl+D (select next
|
|
721
|
+
* occurrence).
|
|
722
|
+
*
|
|
723
|
+
* Characters NOT in this string (and not whitespace) are treated as word
|
|
724
|
+
* characters. Leave empty to use the default `\w` + `$` word boundary.
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* ```ts
|
|
728
|
+
* // Treat hyphens as word separators (useful for CSS/Markdown)
|
|
729
|
+
* wordSeparators: '`~!@#%^&*()-=+[{]}\\|;:\'",.<>/?'
|
|
730
|
+
* ```
|
|
731
|
+
* Default: `''` (use built-in `\w$` word character definition).
|
|
732
|
+
*/
|
|
733
|
+
wordSeparators?: string;
|
|
734
|
+
/**
|
|
735
|
+
* Milliseconds window for grouping consecutive keystrokes into a single
|
|
736
|
+
* undo snapshot. Keystrokes within this window are merged and undone
|
|
737
|
+
* together in one step.
|
|
738
|
+
*
|
|
739
|
+
* Set to `0` to record a separate undo snapshot for every keystroke.
|
|
740
|
+
* Default: `700`.
|
|
741
|
+
*/
|
|
742
|
+
undoBatchMs?: number;
|
|
743
|
+
/**
|
|
744
|
+
* Maximum number of items shown in the autocomplete popup.
|
|
745
|
+
* Includes both base completions and in-file word suggestions.
|
|
746
|
+
* Default: `14`.
|
|
747
|
+
*/
|
|
748
|
+
maxCompletions?: number;
|
|
749
|
+
/**
|
|
750
|
+
* Width of the line-number gutter in pixels.
|
|
751
|
+
* Affects mouse-to-cursor mapping and popup positioning.
|
|
752
|
+
* Default: `60`.
|
|
753
|
+
*/
|
|
754
|
+
gutterWidth?: number;
|
|
755
|
+
/**
|
|
756
|
+
* Width of the minimap panel in pixels.
|
|
757
|
+
* Default: `120`.
|
|
758
|
+
*/
|
|
759
|
+
minimapWidth?: number;
|
|
760
|
+
/**
|
|
761
|
+
* Cursor blink period in milliseconds.
|
|
762
|
+
* The cursor completes one full blink cycle (on → off → on) in this time.
|
|
763
|
+
* Set to a very large value (e.g. `999999`) to effectively disable blinking.
|
|
764
|
+
* Default: `1050`.
|
|
765
|
+
*/
|
|
766
|
+
cursorBlinkRate?: number;
|
|
767
|
+
/**
|
|
768
|
+
* Visual style of the text cursor.
|
|
769
|
+
* - `'line'` — thin vertical beam (default, VS Code-style)
|
|
770
|
+
* - `'block'` — filled rectangle covering the character under the cursor
|
|
771
|
+
* - `'underline'` — horizontal bar below the character
|
|
772
|
+
* Default: `'line'`.
|
|
773
|
+
*/
|
|
774
|
+
cursorStyle?: 'line' | 'block' | 'underline';
|
|
775
|
+
/**
|
|
776
|
+
* Controls whether whitespace characters are rendered as visible glyphs.
|
|
777
|
+
* - `'none'` — whitespace is invisible (default)
|
|
778
|
+
* - `'boundary'` — leading and trailing spaces shown as `·`, tabs as `→`
|
|
779
|
+
* - `'all'` — every space shown as `·`, every tab as `→`
|
|
780
|
+
* Default: `'none'`.
|
|
781
|
+
*/
|
|
782
|
+
renderWhitespace?: 'none' | 'boundary' | 'all';
|
|
783
|
+
/**
|
|
784
|
+
* Per-token syntax-highlight colour overrides applied **on top of** the
|
|
785
|
+
* active theme. Any field set here takes precedence over the corresponding
|
|
786
|
+
* `ThemeTokens` colour without replacing the entire theme.
|
|
787
|
+
*
|
|
788
|
+
* Set a field to `''` (empty string) to restore the theme's default for
|
|
789
|
+
* that token. Omit a field entirely to leave it unchanged.
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* ```ts
|
|
793
|
+
* // Dracula-inspired keywords + string colours on any base theme
|
|
794
|
+
* editor.updateConfig({
|
|
795
|
+
* tokenColors: {
|
|
796
|
+
* keyword: '#ff79c6',
|
|
797
|
+
* string: '#f1fa8c',
|
|
798
|
+
* function: '#50fa7b',
|
|
799
|
+
* type: '#8be9fd',
|
|
800
|
+
* comment: '#6272a4',
|
|
801
|
+
* }
|
|
802
|
+
* });
|
|
803
|
+
* ```
|
|
804
|
+
* Default: `{ } ` (no overrides — all colours come from the active theme).
|
|
805
|
+
*/
|
|
806
|
+
tokenColors?: TokenColors;
|
|
807
|
+
/**
|
|
808
|
+
* Called whenever the document content changes (after every keystroke,
|
|
809
|
+
* paste, undo, or programmatic `setValue`).
|
|
810
|
+
* Receives the full document as a newline-joined string.
|
|
811
|
+
*/
|
|
812
|
+
onChange?: (value: string) => void;
|
|
813
|
+
/**
|
|
814
|
+
* Called whenever the cursor moves to a new position.
|
|
815
|
+
* Receives a copy of the new `CursorPosition`.
|
|
816
|
+
*/
|
|
817
|
+
onCursorChange?: (position: CursorPosition) => void;
|
|
818
|
+
/**
|
|
819
|
+
* Called whenever the selection changes or is cleared.
|
|
820
|
+
* Receives a copy of the new `Selection`, or `null` when deselected.
|
|
821
|
+
*/
|
|
822
|
+
onSelectionChange?: (selection: Selection_2 | null) => void;
|
|
823
|
+
/**
|
|
824
|
+
* Called when the editor gains keyboard focus.
|
|
825
|
+
*/
|
|
826
|
+
onFocus?: () => void;
|
|
827
|
+
/**
|
|
828
|
+
* Called when the editor loses keyboard focus.
|
|
829
|
+
*/
|
|
830
|
+
onBlur?: () => void;
|
|
831
|
+
/**
|
|
832
|
+
* Enable hover documentation tooltips.
|
|
833
|
+
* When `true`, resting the pointer over a recognised identifier for ~500 ms
|
|
834
|
+
* shows a floating tooltip with its type signature and description.
|
|
835
|
+
* Covers built-in JS/TS/CSS symbols and any symbols provided via `provideHover`.
|
|
836
|
+
* Default: `true`.
|
|
837
|
+
*/
|
|
838
|
+
hover?: boolean;
|
|
839
|
+
/**
|
|
840
|
+
* Custom hover documentation provider.
|
|
841
|
+
* Called when the user hovers over an identifier and no built-in doc is found.
|
|
842
|
+
* Return a `HoverDoc` object to show a tooltip, or `null`/`undefined` to show nothing.
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* ```ts
|
|
846
|
+
* provideHover: (ctx) => {
|
|
847
|
+
* const entry = mySymbolTable[ctx.word];
|
|
848
|
+
* if (!entry) return null;
|
|
849
|
+
* return {
|
|
850
|
+
* title: entry.name,
|
|
851
|
+
* type: entry.signature,
|
|
852
|
+
* body: entry.description,
|
|
853
|
+
* };
|
|
854
|
+
* }
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
857
|
+
provideHover?: (context: HoverContext) => HoverDoc | null | undefined;
|
|
858
|
+
/**
|
|
859
|
+
* Ghost text shown inside the editor when the document is completely empty.
|
|
860
|
+
* Only rendered when this string is non-empty.
|
|
861
|
+
* @default ''
|
|
862
|
+
*/
|
|
863
|
+
placeholder?: string;
|
|
864
|
+
/**
|
|
865
|
+
* Enable the Go to Line bar (Ctrl+G / Cmd+G).
|
|
866
|
+
* When `false` the shortcut does nothing and the bar is never shown.
|
|
867
|
+
* @default false
|
|
868
|
+
*/
|
|
869
|
+
goToLine?: boolean;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
declare abstract class EditorEditing extends EditorRenderer {
|
|
873
|
+
protected _insertStr(text: string, groupable: boolean): void;
|
|
874
|
+
protected _doBackspace(): void;
|
|
875
|
+
protected _doEnter(): void;
|
|
876
|
+
protected _doDelete(): void;
|
|
877
|
+
protected _selectAll(): void;
|
|
878
|
+
protected _doCopy(): void;
|
|
879
|
+
protected _doCut(): void;
|
|
880
|
+
/**
|
|
881
|
+
* Cmd+Enter: insert a blank (auto-indented) line below the current line and
|
|
882
|
+
* move the cursor there — regardless of where the cursor is on the line.
|
|
883
|
+
* Matches VS Code's "editor.action.insertLineAfter".
|
|
884
|
+
*/
|
|
885
|
+
protected _doInsertLineBelow(): void;
|
|
886
|
+
/**
|
|
887
|
+
* Cmd+Shift+Enter: insert a blank (auto-indented) line above the current line
|
|
888
|
+
* and move the cursor there.
|
|
889
|
+
* Matches VS Code's "editor.action.insertLineBefore".
|
|
890
|
+
*/
|
|
891
|
+
protected _doInsertLineAbove(): void;
|
|
892
|
+
protected _toggleComment(): void;
|
|
893
|
+
protected _duplicateLine(): void;
|
|
894
|
+
protected _deleteLine(): void;
|
|
895
|
+
protected _indentSel(): void;
|
|
896
|
+
protected _unindentSel(): void;
|
|
897
|
+
protected _toggleWrap(): void;
|
|
898
|
+
protected _getSelRows(): number[];
|
|
899
|
+
protected _duplicateLines(down: boolean): void;
|
|
900
|
+
protected _moveLines(up: boolean): void;
|
|
901
|
+
/** Skip forward past one word boundary (Option/Ctrl+Right, Option/Ctrl+Delete). */
|
|
902
|
+
protected _wordSkipRight(line: string, col: number): number;
|
|
903
|
+
/** Skip backward past one word boundary (Option/Ctrl+Left, Option/Ctrl+Backspace). */
|
|
904
|
+
protected _wordSkipLeft(line: string, col: number): number;
|
|
905
|
+
/** Cmd+Backspace: delete from cursor back to column 0 on the same line. */
|
|
906
|
+
protected _deleteToLineStart(): void;
|
|
907
|
+
/** Option/Ctrl+Backspace: delete one word to the left of cursor. */
|
|
908
|
+
protected _deleteWordLeft(): void;
|
|
909
|
+
/** Cmd+Delete: delete from cursor forward to end of line. */
|
|
910
|
+
protected _deleteToLineEnd(): void;
|
|
911
|
+
/** Option/Ctrl+Delete: delete one word to the right of cursor. */
|
|
912
|
+
protected _deleteWordRight(): void;
|
|
913
|
+
protected _doUndo(): void;
|
|
914
|
+
protected _doRedo(): void;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
declare abstract class EditorEvents extends EditorHoverAndTheme {
|
|
918
|
+
protected _posFromMouse(e: MouseEvent): CursorPosition;
|
|
919
|
+
protected _bindEditorEvents(): void;
|
|
920
|
+
protected _onKeyDown(e: KeyboardEvent): void;
|
|
921
|
+
protected _handleArrowKeys(e: KeyboardEvent, _ctrl: boolean, shift: boolean): void;
|
|
922
|
+
protected _isWordChar(ch: string): boolean;
|
|
923
|
+
private _wordStart;
|
|
924
|
+
private _wordEnd;
|
|
925
|
+
protected _onInput(e: InputEvent): void;
|
|
926
|
+
protected _bindMinimapEvents(): void;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
declare abstract class EditorFind extends EditorEditing {
|
|
930
|
+
protected _openFind(withReplace: boolean): void;
|
|
931
|
+
protected _closeFind(): void;
|
|
932
|
+
protected _runFind(q: string): void;
|
|
933
|
+
protected _navFind(dir: 1 | -1): void;
|
|
934
|
+
protected _doReplaceOne(): void;
|
|
935
|
+
protected _doReplaceAll(): void;
|
|
936
|
+
protected _bindFindEvents(): void;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
declare abstract class EditorHoverAndTheme extends EditorAutocomplete {
|
|
940
|
+
protected _scheduleHover(e: MouseEvent): void;
|
|
941
|
+
protected _doHover(clientX: number, clientY: number): void;
|
|
942
|
+
protected _showHoverTip(doc: HoverDoc, clientX: number, clientY: number): void;
|
|
943
|
+
protected _hideHover(): void;
|
|
944
|
+
protected _openThemePicker(): void;
|
|
945
|
+
protected _applyTheme(theme: string | ThemeDefinition): void;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
declare abstract class EditorRenderer extends EditorStyles {
|
|
949
|
+
protected _scheduleRender(): void;
|
|
950
|
+
protected _render(): void;
|
|
951
|
+
protected readonly _onFoldBtnClick: (e: MouseEvent) => void;
|
|
952
|
+
protected _updateStatusBar(): void;
|
|
953
|
+
protected _updateMinimap(): void;
|
|
954
|
+
protected _rebuildWrapMap(): void;
|
|
955
|
+
protected _scrollIntoView(): void;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
declare abstract class EditorStyles extends EditorBase {
|
|
959
|
+
protected _applyDynamicStyles(): void;
|
|
960
|
+
protected _applyTokenOverrides(): void;
|
|
961
|
+
protected _refreshMinimapColors(): void;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* The full state of an open editor buffer (tab).
|
|
966
|
+
* Contains the document text, cursor, selection, scroll offset, and history stacks.
|
|
967
|
+
*/
|
|
968
|
+
export declare interface EditorTab {
|
|
969
|
+
/** Unique numeric identifier for this buffer. */
|
|
970
|
+
fileId: number;
|
|
971
|
+
/** Document content as an array of lines (without newline characters). */
|
|
972
|
+
doc: string[];
|
|
973
|
+
/** Current cursor position. */
|
|
974
|
+
cur: CursorPosition;
|
|
975
|
+
/** Current text selection, or `null` if nothing is selected. */
|
|
976
|
+
sel: Selection_2 | null;
|
|
977
|
+
/** `true` if the buffer has unsaved changes. */
|
|
978
|
+
dirty: boolean;
|
|
979
|
+
/** Stack of snapshots that can be restored via Undo. */
|
|
980
|
+
undoStack: HistorySnapshot[];
|
|
981
|
+
/** Stack of snapshots that can be restored via Redo. */
|
|
982
|
+
redoStack: HistorySnapshot[];
|
|
983
|
+
/** Vertical scroll offset of the editor viewport in pixels. */
|
|
984
|
+
scrollTop: number;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* An additional cursor in a multi-cursor editing session.
|
|
989
|
+
* Each extra cursor tracks its own position and optional selection range.
|
|
990
|
+
*/
|
|
991
|
+
export declare interface ExtraCursor {
|
|
992
|
+
/** Zero-based line index of this cursor. */
|
|
993
|
+
row: number;
|
|
994
|
+
/** Zero-based column of this cursor. */
|
|
995
|
+
col: number;
|
|
996
|
+
/** Selection associated with this cursor, or `null` if none. */
|
|
997
|
+
sel: Selection_2 | null;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* A single result from a find (search) operation.
|
|
1002
|
+
* Identifies a contiguous substring within one document line.
|
|
1003
|
+
*/
|
|
1004
|
+
export declare interface FindMatch {
|
|
1005
|
+
/** Zero-based line index where the match was found. */
|
|
1006
|
+
row: number;
|
|
1007
|
+
/** Zero-based column where the match starts. */
|
|
1008
|
+
col: number;
|
|
1009
|
+
/** Length of the matched text in characters. */
|
|
1010
|
+
len: number;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* A point-in-time snapshot of document state stored in the undo/redo stacks.
|
|
1015
|
+
* Stores a delta `EditOp` rather than a full document copy.
|
|
1016
|
+
*/
|
|
1017
|
+
export declare interface HistorySnapshot {
|
|
1018
|
+
/** The editing operation that was performed to reach the post-edit state. */
|
|
1019
|
+
op: EditOp;
|
|
1020
|
+
/** Cursor position before the operation (restored on undo). */
|
|
1021
|
+
beforeCur: CursorPosition;
|
|
1022
|
+
/** Selection before the operation (restored on undo). */
|
|
1023
|
+
beforeSel: Selection_2 | null;
|
|
1024
|
+
/** Cursor position after the operation (restored on redo). */
|
|
1025
|
+
afterCur: CursorPosition;
|
|
1026
|
+
/** Selection after the operation (restored on redo). */
|
|
1027
|
+
afterSel: Selection_2 | null;
|
|
1028
|
+
/**
|
|
1029
|
+
* Extra cursor positions immediately BEFORE the operation.
|
|
1030
|
+
* Restored when the operation is undone, so multi-cursor state
|
|
1031
|
+
* (including per-cursor selections from Ctrl+D) is preserved
|
|
1032
|
+
* across undo — identical to VS Code behaviour.
|
|
1033
|
+
*/
|
|
1034
|
+
beforeExtra: ExtraCursor[];
|
|
1035
|
+
/**
|
|
1036
|
+
* Extra cursor positions immediately AFTER the operation.
|
|
1037
|
+
* Restored when the operation is redone.
|
|
1038
|
+
*/
|
|
1039
|
+
afterExtra: ExtraCursor[];
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Context passed to a `provideHover` callback.
|
|
1044
|
+
* Describes the word under the pointer and the surrounding document state.
|
|
1045
|
+
*/
|
|
1046
|
+
export declare interface HoverContext {
|
|
1047
|
+
/** The full identifier under the pointer (may include a dot prefix, e.g. `"console.log"`). */
|
|
1048
|
+
word: string;
|
|
1049
|
+
/** Zero-based document line index where the pointer is. */
|
|
1050
|
+
row: number;
|
|
1051
|
+
/** Zero-based character column where the pointer is. */
|
|
1052
|
+
col: number;
|
|
1053
|
+
/** The full text of the hovered line. */
|
|
1054
|
+
line: string;
|
|
1055
|
+
/** The active language identifier (e.g. `'typescript'`). */
|
|
1056
|
+
language: string;
|
|
1057
|
+
/** The full document as a read-only array of lines. */
|
|
1058
|
+
doc: readonly string[];
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* Documentation shown in a hover tooltip when the user rests the pointer
|
|
1063
|
+
* over a recognised identifier in the editor.
|
|
1064
|
+
*/
|
|
1065
|
+
export declare interface HoverDoc {
|
|
1066
|
+
/** Display name of the symbol — shown prominently at the top of the tooltip. */
|
|
1067
|
+
title: string;
|
|
1068
|
+
/**
|
|
1069
|
+
* Type signature or category label (e.g. `"(...data: any[]) => void"`,
|
|
1070
|
+
* `"primitive type"`, `"keyword"`).
|
|
1071
|
+
* Rendered in monospace below the title.
|
|
1072
|
+
*/
|
|
1073
|
+
type?: string;
|
|
1074
|
+
/** Human-readable description of what the symbol does. */
|
|
1075
|
+
body: string;
|
|
1076
|
+
/**
|
|
1077
|
+
* Restrict this doc entry to specific languages.
|
|
1078
|
+
* When provided, the tooltip only appears when the editor's active language matches.
|
|
1079
|
+
* Omit to show in all languages.
|
|
1080
|
+
*/
|
|
1081
|
+
language?: string | string[];
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Supported language identifiers for syntax highlighting and autocomplete.
|
|
1086
|
+
* Pass as the `language` option in `EditorConfig`.
|
|
1087
|
+
*/
|
|
1088
|
+
export declare type Language = 'typescript' | 'javascript' | 'css' | 'json' | 'markdown' | 'text';
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Colour palette used when painting the minimap canvas.
|
|
1092
|
+
* Each value is a CSS colour string resolved from the active theme.
|
|
1093
|
+
* The interface also accepts arbitrary string keys so token class names
|
|
1094
|
+
* (`'kw'`, `'fn'`, etc.) can be used for direct index access.
|
|
1095
|
+
*/
|
|
1096
|
+
export declare interface MinimapColors {
|
|
1097
|
+
/** Colour for keyword tokens. */
|
|
1098
|
+
kw: string;
|
|
1099
|
+
/** Colour for function-name tokens. */
|
|
1100
|
+
fn: string;
|
|
1101
|
+
/** Colour for class-name tokens. */
|
|
1102
|
+
cls: string;
|
|
1103
|
+
/** Colour for type-name tokens. */
|
|
1104
|
+
typ: string;
|
|
1105
|
+
/** Colour for string-literal tokens. */
|
|
1106
|
+
str: string;
|
|
1107
|
+
/** Colour for numeric-literal tokens. */
|
|
1108
|
+
num: string;
|
|
1109
|
+
/** Colour for comment tokens. */
|
|
1110
|
+
cmt: string;
|
|
1111
|
+
/** Colour for decorator tokens. */
|
|
1112
|
+
dec: string;
|
|
1113
|
+
/** Colour for operator tokens. */
|
|
1114
|
+
op: string;
|
|
1115
|
+
/** Colour for plain (un-tokenised) text. */
|
|
1116
|
+
txt: string;
|
|
1117
|
+
/** Index signature — allows token class names to be used as dynamic keys. */
|
|
1118
|
+
[key: string]: string;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
declare interface MultiCursorState {
|
|
1122
|
+
cursors: ExtraCursor[];
|
|
1123
|
+
searchWord: string;
|
|
1124
|
+
lastMatchRow: number;
|
|
1125
|
+
lastMatchCol: number;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* A selection range defined by an anchor (where selection started)
|
|
1130
|
+
* and a focus (where the caret currently sits). Either end can be
|
|
1131
|
+
* before the other — use `normaliseSelection` when you need start ≤ end.
|
|
1132
|
+
*/
|
|
1133
|
+
declare interface Selection_2 {
|
|
1134
|
+
/** Anchor row — the line where the selection was started. */
|
|
1135
|
+
ar: number;
|
|
1136
|
+
/** Anchor column — the character offset where the selection was started. */
|
|
1137
|
+
ac: number;
|
|
1138
|
+
/** Focus row — the line where the caret currently sits. */
|
|
1139
|
+
fr: number;
|
|
1140
|
+
/** Focus column — the character offset where the caret currently sits. */
|
|
1141
|
+
fc: number;
|
|
1142
|
+
}
|
|
1143
|
+
export { Selection_2 as Selection }
|
|
1144
|
+
|
|
1145
|
+
export declare class SynclineEditor extends EditorEvents implements EditorAPI {
|
|
1146
|
+
getValue(): string;
|
|
1147
|
+
setValue(value: string): void;
|
|
1148
|
+
getCursor(): CursorPosition;
|
|
1149
|
+
setCursor(pos: CursorPosition): void;
|
|
1150
|
+
getSelection(): Selection_2 | null;
|
|
1151
|
+
setSelection(sel: Selection_2 | null): void;
|
|
1152
|
+
insertText(text: string): void;
|
|
1153
|
+
setTheme(theme: string | ThemeDefinition): void;
|
|
1154
|
+
updateConfig(patch: Partial<EditorConfig>): void;
|
|
1155
|
+
focus(): void;
|
|
1156
|
+
getThemes(): string[];
|
|
1157
|
+
registerTheme(theme: ThemeDefinition): void;
|
|
1158
|
+
undo(): void;
|
|
1159
|
+
redo(): void;
|
|
1160
|
+
executeCommand(command: string): void;
|
|
1161
|
+
destroy(): void;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
export declare const THEME_DRACULA: ThemeDefinition;
|
|
1165
|
+
|
|
1166
|
+
export declare const THEME_GITHUB_LIGHT: ThemeDefinition;
|
|
1167
|
+
|
|
1168
|
+
export declare const THEME_MDX_DARK: ThemeDefinition;
|
|
1169
|
+
|
|
1170
|
+
export declare const THEME_MDX_LIGHT: ThemeDefinition;
|
|
1171
|
+
|
|
1172
|
+
export declare const THEME_MONOKAI: ThemeDefinition;
|
|
1173
|
+
|
|
1174
|
+
export declare const THEME_SOLARIZED_LIGHT: ThemeDefinition;
|
|
1175
|
+
|
|
1176
|
+
export declare const THEME_VR_DARK: ThemeDefinition;
|
|
1177
|
+
|
|
1178
|
+
export declare const THEME_VSCODE_DARK: ThemeDefinition;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* A named, complete theme definition.
|
|
1182
|
+
* Pass a `ThemeDefinition` to `setTheme()` or `registerTheme()` to apply
|
|
1183
|
+
* a fully custom colour scheme at runtime.
|
|
1184
|
+
*/
|
|
1185
|
+
export declare interface ThemeDefinition {
|
|
1186
|
+
/** Unique identifier used to reference this theme (e.g. `'my-dark'`). */
|
|
1187
|
+
id: string;
|
|
1188
|
+
/** Human-readable display name shown in the theme picker. */
|
|
1189
|
+
name: string;
|
|
1190
|
+
/** Short description of the theme's appearance or origin. */
|
|
1191
|
+
description: string;
|
|
1192
|
+
/** `true` for light themes, `false` for dark themes. */
|
|
1193
|
+
light: boolean;
|
|
1194
|
+
/** Complete set of colour values for every CSS variable the theme controls. */
|
|
1195
|
+
tokens: ThemeTokens;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
declare class ThemeManager {
|
|
1199
|
+
private readonly _registry;
|
|
1200
|
+
private _activeId;
|
|
1201
|
+
private readonly _root;
|
|
1202
|
+
constructor(root: HTMLElement);
|
|
1203
|
+
/** Register a custom or override theme. */
|
|
1204
|
+
register(theme: ThemeDefinition): void;
|
|
1205
|
+
/** Apply a theme by id or by definition. */
|
|
1206
|
+
apply(idOrDef: string | ThemeDefinition): void;
|
|
1207
|
+
get activeId(): string;
|
|
1208
|
+
get activeTheme(): ThemeDefinition | undefined;
|
|
1209
|
+
get allIds(): string[];
|
|
1210
|
+
get all(): ThemeDefinition[];
|
|
1211
|
+
private _applyTokens;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
/** ─── Theme ─────────────────────────────────────────────── */
|
|
1215
|
+
/**
|
|
1216
|
+
* The complete set of CSS custom-property values that define a theme's
|
|
1217
|
+
* visual appearance. Every key maps 1-to-1 with a `--<name>` CSS variable
|
|
1218
|
+
* injected on the editor host element.
|
|
1219
|
+
*/
|
|
1220
|
+
export declare interface ThemeTokens {
|
|
1221
|
+
/** Deepest background — editor chrome and overall host fill. */
|
|
1222
|
+
bg0: string;
|
|
1223
|
+
/** Slightly lighter background — used for panels and sidebars. */
|
|
1224
|
+
bg1: string;
|
|
1225
|
+
/** Editor pane background. */
|
|
1226
|
+
bg2: string;
|
|
1227
|
+
/** Popover / floating-panel background (find bar, theme picker). */
|
|
1228
|
+
bg3: string;
|
|
1229
|
+
/** Input and list-item background inside popovers. */
|
|
1230
|
+
bg4: string;
|
|
1231
|
+
/** Subtle border — low-contrast dividers. */
|
|
1232
|
+
border: string;
|
|
1233
|
+
/** Medium-contrast border. */
|
|
1234
|
+
border2: string;
|
|
1235
|
+
/** High-contrast border — used for focused inputs and active elements. */
|
|
1236
|
+
border3: string;
|
|
1237
|
+
/** Primary text colour for code and labels. */
|
|
1238
|
+
text: string;
|
|
1239
|
+
/** Secondary text colour for metadata and de-emphasised labels. */
|
|
1240
|
+
text2: string;
|
|
1241
|
+
/** Muted text colour for placeholders and disabled states. */
|
|
1242
|
+
text3: string;
|
|
1243
|
+
/** Primary accent — cursor, links, and active highlights. */
|
|
1244
|
+
accent: string;
|
|
1245
|
+
/** Darker accent — status bar background. */
|
|
1246
|
+
accent2: string;
|
|
1247
|
+
/** Semantic green (success, string tokens in some themes). */
|
|
1248
|
+
green: string;
|
|
1249
|
+
/** Semantic orange (warnings, function tokens in some themes). */
|
|
1250
|
+
orange: string;
|
|
1251
|
+
/** Semantic purple (numbers, extra cursors). */
|
|
1252
|
+
purple: string;
|
|
1253
|
+
/** Semantic red (errors, decorator tokens). */
|
|
1254
|
+
red: string;
|
|
1255
|
+
/** Semantic yellow (class names in some themes). */
|
|
1256
|
+
yellow: string;
|
|
1257
|
+
/** Cursor beam / block fill colour. */
|
|
1258
|
+
cur: string;
|
|
1259
|
+
/** Glow halo colour rendered around the cursor. */
|
|
1260
|
+
curGlow: string;
|
|
1261
|
+
/** Background tint applied to the current-line row. */
|
|
1262
|
+
curLineBg: string;
|
|
1263
|
+
/** Gutter cell background on the current-line row. */
|
|
1264
|
+
curLineGutter: string;
|
|
1265
|
+
/** Default gutter background. */
|
|
1266
|
+
gutterBg: string;
|
|
1267
|
+
/** Gutter background on row hover. */
|
|
1268
|
+
gutterHover: string;
|
|
1269
|
+
/** Gutter right-border colour. */
|
|
1270
|
+
gutterBorder: string;
|
|
1271
|
+
/** Line-number text colour (inactive lines). */
|
|
1272
|
+
gutterNum: string;
|
|
1273
|
+
/** Line-number text colour on the active (cursor) line. */
|
|
1274
|
+
gutterNumAct: string;
|
|
1275
|
+
/** Background tint for selected text. */
|
|
1276
|
+
selBg: string;
|
|
1277
|
+
/** Background tint for word-occurrence highlights. */
|
|
1278
|
+
wordHlBg: string;
|
|
1279
|
+
/** Border colour for word-occurrence highlights. */
|
|
1280
|
+
wordHlBorder: string;
|
|
1281
|
+
/** Border colour for bracket-match highlights. */
|
|
1282
|
+
bmBorder: string;
|
|
1283
|
+
/** Background tint applied to folded-line rows. */
|
|
1284
|
+
foldBg: string;
|
|
1285
|
+
/** Bottom-border colour on folded-line rows. */
|
|
1286
|
+
foldBorder: string;
|
|
1287
|
+
/** Background tint for non-current find matches. */
|
|
1288
|
+
findBg: string;
|
|
1289
|
+
/** Border colour for non-current find matches. */
|
|
1290
|
+
findBorder: string;
|
|
1291
|
+
/** Background for the currently active find match. */
|
|
1292
|
+
findCurBg: string;
|
|
1293
|
+
/** Border colour for the currently active find match. */
|
|
1294
|
+
findCurBorder: string;
|
|
1295
|
+
/** Text colour inside the currently active find match. */
|
|
1296
|
+
findCurText: string;
|
|
1297
|
+
/** Background for the active file entry in a sidebar. */
|
|
1298
|
+
fileActiveBg: string;
|
|
1299
|
+
/** Text colour for the active file entry in a sidebar. */
|
|
1300
|
+
fileActiveText: string;
|
|
1301
|
+
/** Minimap panel background. */
|
|
1302
|
+
mmBg: string;
|
|
1303
|
+
/** Minimap viewport-slider fill colour. */
|
|
1304
|
+
mmSlider: string;
|
|
1305
|
+
/** Semi-transparent overlay dimming the out-of-view minimap area. */
|
|
1306
|
+
mmDim: string;
|
|
1307
|
+
/** Edge highlight on the minimap slider. */
|
|
1308
|
+
mmEdge: string;
|
|
1309
|
+
/** Colour of vertical indent-guide lines. */
|
|
1310
|
+
indentGuide: string;
|
|
1311
|
+
/** Colour for keyword tokens (`kw`). */
|
|
1312
|
+
tokKw: string;
|
|
1313
|
+
/** Colour for string-literal tokens (`str`). */
|
|
1314
|
+
tokStr: string;
|
|
1315
|
+
/** Colour for comment tokens (`cmt`). */
|
|
1316
|
+
tokCmt: string;
|
|
1317
|
+
/** Colour for function-name tokens (`fn`). */
|
|
1318
|
+
tokFn: string;
|
|
1319
|
+
/** Colour for numeric-literal tokens (`num`). */
|
|
1320
|
+
tokNum: string;
|
|
1321
|
+
/** Colour for class-name tokens (`cls`). */
|
|
1322
|
+
tokCls: string;
|
|
1323
|
+
/** Colour for operator tokens (`op`). */
|
|
1324
|
+
tokOp: string;
|
|
1325
|
+
/** Colour for type-name tokens (`typ`). */
|
|
1326
|
+
tokTyp: string;
|
|
1327
|
+
/** Colour for decorator tokens (`dec`). */
|
|
1328
|
+
tokDec: string;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/** Simple LRU token cache — keyed by `"docLine:segIdx"`. */
|
|
1332
|
+
declare class TokenCache {
|
|
1333
|
+
private readonly _cache;
|
|
1334
|
+
private readonly _maxSize;
|
|
1335
|
+
private _hits;
|
|
1336
|
+
private _misses;
|
|
1337
|
+
private _evictions;
|
|
1338
|
+
constructor(maxSize?: number);
|
|
1339
|
+
/** Live snapshot of cache performance. Useful for observability. */
|
|
1340
|
+
get metrics(): CacheMetrics;
|
|
1341
|
+
get(key: string, text: string): TokenSegment[] | null;
|
|
1342
|
+
set(key: string, text: string, segs: TokenSegment[]): void;
|
|
1343
|
+
invalidateLine(docLine: number, segCount: number): void;
|
|
1344
|
+
/** Clear all cached entries and reset performance counters. */
|
|
1345
|
+
clear(): void;
|
|
1346
|
+
/** Reset performance counters without clearing cached entries. */
|
|
1347
|
+
resetMetrics(): void;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* Syntax token class identifiers produced by the tokeniser.
|
|
1352
|
+
* Each value maps to a CSS class that controls token colour.
|
|
1353
|
+
*
|
|
1354
|
+
* - `'kw'` — keyword (e.g. `if`, `const`, `return`)
|
|
1355
|
+
* - `'str'` — string literal
|
|
1356
|
+
* - `'cmt'` — comment
|
|
1357
|
+
* - `'fn'` — function name
|
|
1358
|
+
* - `'num'` — numeric literal
|
|
1359
|
+
* - `'cls'` — class name
|
|
1360
|
+
* - `'op'` — operator
|
|
1361
|
+
* - `'typ'` — type name
|
|
1362
|
+
* - `'dec'` — decorator
|
|
1363
|
+
*/
|
|
1364
|
+
export declare type TokenClass = 'kw' | 'str' | 'cmt' | 'fn' | 'num' | 'cls' | 'op' | 'typ' | 'dec';
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Per-token syntax-highlight colour overrides.
|
|
1368
|
+
*
|
|
1369
|
+
* Set any subset of these to override the corresponding CSS variable on top
|
|
1370
|
+
* of the active theme — without needing to register a full `ThemeDefinition`.
|
|
1371
|
+
* Accepts any valid CSS colour string (`'#ff79c6'`, `'hsl(330,100%,74%)'`,
|
|
1372
|
+
* `'rgba(255,121,198,.9)'`, etc.).
|
|
1373
|
+
*
|
|
1374
|
+
* These map 1-to-1 to the `ThemeTokens` syntax fields:
|
|
1375
|
+
* `keyword → tokKw`, `string → tokStr`, `comment → tokCmt`,
|
|
1376
|
+
* `function → tokFn`, `number → tokNum`, `class → tokCls`,
|
|
1377
|
+
* `operator → tokOp`, `type → tokTyp`, `decorator → tokDec`.
|
|
1378
|
+
*
|
|
1379
|
+
* @example
|
|
1380
|
+
* ```ts
|
|
1381
|
+
* editor.updateConfig({
|
|
1382
|
+
* tokenColors: {
|
|
1383
|
+
* keyword: '#ff79c6', // pink keywords
|
|
1384
|
+
* string: '#f1fa8c', // yellow strings
|
|
1385
|
+
* type: '#8be9fd', // cyan types
|
|
1386
|
+
* comment: '#6272a4', // muted comments
|
|
1387
|
+
* }
|
|
1388
|
+
* });
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1391
|
+
export declare interface TokenColors {
|
|
1392
|
+
/** Colour for keyword tokens — `if`, `const`, `class`, `interface`, `return`, etc. */
|
|
1393
|
+
keyword?: string;
|
|
1394
|
+
/** Colour for string-literal tokens — single-quoted, double-quoted, and template literals. */
|
|
1395
|
+
string?: string;
|
|
1396
|
+
/** Colour for comment tokens — line comments (//) and block comments. */
|
|
1397
|
+
comment?: string;
|
|
1398
|
+
/** Colour for function-name tokens — `console`, `fetch`, `myFn` when followed by `(`. */
|
|
1399
|
+
function?: string;
|
|
1400
|
+
/** Colour for numeric-literal tokens — `42`, `3.14`, `0xff`, `1n`. */
|
|
1401
|
+
number?: string;
|
|
1402
|
+
/** Colour for class-name tokens — `MyClass`, `EventEmitter`, constructor calls. */
|
|
1403
|
+
class?: string;
|
|
1404
|
+
/** Colour for operator tokens — `+`, `=>`, `===`, `&&`, `?.`, `|`. */
|
|
1405
|
+
operator?: string;
|
|
1406
|
+
/** Colour for type-name tokens — `string`, `number`, `boolean`, `Promise`, `Record`. */
|
|
1407
|
+
type?: string;
|
|
1408
|
+
/** Colour for decorator tokens — `@Component`, `@Injectable`, `@deprecated`. */
|
|
1409
|
+
decorator?: string;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* A tokenised segment within a single line.
|
|
1414
|
+
* Covers the half-open character range `[start, end)`.
|
|
1415
|
+
*/
|
|
1416
|
+
export declare interface TokenSegment {
|
|
1417
|
+
/** Token class that determines the syntax highlight colour. */
|
|
1418
|
+
cls: TokenClass;
|
|
1419
|
+
/** Start character index (inclusive). */
|
|
1420
|
+
start: number;
|
|
1421
|
+
/** End character index (exclusive). */
|
|
1422
|
+
end: number;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* One visual (rendered) row on screen.
|
|
1427
|
+
* A single document line may produce multiple `VisualRow` entries when
|
|
1428
|
+
* word-wrap is active.
|
|
1429
|
+
*/
|
|
1430
|
+
export declare interface VisualRow {
|
|
1431
|
+
/** Zero-based document line that this visual row belongs to. */
|
|
1432
|
+
docLine: number;
|
|
1433
|
+
/**
|
|
1434
|
+
* Wrap-segment index within the document line.
|
|
1435
|
+
* `0` for the first (or only) visual row of a line; `1`, `2`, … for
|
|
1436
|
+
* subsequent wrapped segments.
|
|
1437
|
+
*/
|
|
1438
|
+
segIdx: number;
|
|
1439
|
+
/** The text content of this visual row segment. */
|
|
1440
|
+
text: string;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
declare interface WrapMap {
|
|
1444
|
+
/** wrapMap[docLine] = array of segment strings (empty array for outside-window lines). */
|
|
1445
|
+
segments: string[][];
|
|
1446
|
+
/**
|
|
1447
|
+
* Compact array of fully-computed visual rows covering only the window
|
|
1448
|
+
* [windowStart, windowEnd]. Index 0 here corresponds to absolute visual
|
|
1449
|
+
* row `windowVisStart`, so callers must offset: `visualRows[v - windowVisStart]`.
|
|
1450
|
+
*
|
|
1451
|
+
* For non-windowed mode `windowVisStart === 0` and the array covers the
|
|
1452
|
+
* whole document — the offset is a no-op (0).
|
|
1453
|
+
*/
|
|
1454
|
+
visualRows: VisualRow[];
|
|
1455
|
+
/**
|
|
1456
|
+
* docToVisArr[docLine] = first visual row index for that doc line.
|
|
1457
|
+
* `null` signals the **identity mapping** (visRow === docLine), used by the
|
|
1458
|
+
* large-file fast path when word-wrap is off and there are no folds.
|
|
1459
|
+
* Callers should use `docToVisualPos()` rather than indexing this directly.
|
|
1460
|
+
*/
|
|
1461
|
+
docToVisArr: number[] | null;
|
|
1462
|
+
/**
|
|
1463
|
+
* Total estimated visual rows in the document.
|
|
1464
|
+
* Use this for spacer-height calculations instead of `visualRows.length`.
|
|
1465
|
+
*/
|
|
1466
|
+
totalVisualRows: number;
|
|
1467
|
+
/**
|
|
1468
|
+
* Absolute visual-row index of `visualRows[0]`.
|
|
1469
|
+
* Always 0 for non-windowed (full) builds.
|
|
1470
|
+
*/
|
|
1471
|
+
windowVisStart: number;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
export { }
|