@difizen/libro-code-editor 0.0.0-snapshot-20241017072317

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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/code-editor-info-manager.d.ts +8 -0
  4. package/es/code-editor-info-manager.d.ts.map +1 -0
  5. package/es/code-editor-info-manager.js +32 -0
  6. package/es/code-editor-manager.d.ts +60 -0
  7. package/es/code-editor-manager.d.ts.map +1 -0
  8. package/es/code-editor-manager.js +126 -0
  9. package/es/code-editor-model.d.ts +80 -0
  10. package/es/code-editor-model.d.ts.map +1 -0
  11. package/es/code-editor-model.js +108 -0
  12. package/es/code-editor-protocol.d.ts +475 -0
  13. package/es/code-editor-protocol.d.ts.map +1 -0
  14. package/es/code-editor-protocol.js +113 -0
  15. package/es/code-editor-settings.d.ts +34 -0
  16. package/es/code-editor-settings.d.ts.map +1 -0
  17. package/es/code-editor-settings.js +225 -0
  18. package/es/code-editor-state-manager.d.ts +14 -0
  19. package/es/code-editor-state-manager.d.ts.map +1 -0
  20. package/es/code-editor-state-manager.js +82 -0
  21. package/es/code-editor-view.d.ts +123 -0
  22. package/es/code-editor-view.d.ts.map +1 -0
  23. package/es/code-editor-view.js +420 -0
  24. package/es/index.d.ts +9 -0
  25. package/es/index.d.ts.map +1 -0
  26. package/es/index.js +8 -0
  27. package/es/language-specs.d.ts +38 -0
  28. package/es/language-specs.d.ts.map +1 -0
  29. package/es/language-specs.js +58 -0
  30. package/es/mimetype.d.ts +33 -0
  31. package/es/mimetype.d.ts.map +1 -0
  32. package/es/mimetype.js +11 -0
  33. package/es/module.d.ts +3 -0
  34. package/es/module.d.ts.map +1 -0
  35. package/es/module.js +10 -0
  36. package/package.json +60 -0
  37. package/src/code-editor-info-manager.ts +25 -0
  38. package/src/code-editor-manager.ts +71 -0
  39. package/src/code-editor-model.ts +120 -0
  40. package/src/code-editor-protocol.ts +681 -0
  41. package/src/code-editor-settings.ts +214 -0
  42. package/src/code-editor-state-manager.ts +54 -0
  43. package/src/code-editor-view.tsx +434 -0
  44. package/src/index.spec.ts +10 -0
  45. package/src/index.ts +8 -0
  46. package/src/language-specs.ts +69 -0
  47. package/src/mimetype.ts +37 -0
  48. package/src/module.ts +22 -0
@@ -0,0 +1,475 @@
1
+ import type { JSONObject, JSONValue } from '@difizen/libro-common';
2
+ import type { Disposable, Event, ThemeType } from '@difizen/mana-app';
3
+ import { Syringe } from '@difizen/mana-app';
4
+ import type { IModel } from './code-editor-model.js';
5
+ /**
6
+ * A one-based position in the editor.
7
+ */
8
+ export interface IPosition extends JSONObject {
9
+ /**
10
+ * The cursor line number. one-based.
11
+ */
12
+ readonly line: number;
13
+ /**
14
+ * The cursor column number. one-based.
15
+ */
16
+ readonly column: number;
17
+ }
18
+ /**
19
+ * An interface describing editor state coordinates.
20
+ */
21
+ export type ICoordinate = DOMRectReadOnly;
22
+ /**
23
+ * A range.
24
+ */
25
+ export interface IRange {
26
+ /**
27
+ * The position of the first character in the current range.
28
+ *
29
+ * #### Notes
30
+ * If this position is greater than [end] then the range is considered
31
+ * to be backward.
32
+ */
33
+ readonly start: IPosition;
34
+ /**
35
+ * The position of the last character in the current range.
36
+ *
37
+ * #### Notes
38
+ * If this position is less than [start] then the range is considered
39
+ * to be backward.
40
+ */
41
+ readonly end: IPosition;
42
+ }
43
+ /**
44
+ * A selection style.
45
+ */
46
+ export interface IEditorSelectionStyle {
47
+ /**
48
+ * A class name added to a selection.
49
+ */
50
+ className: string;
51
+ /**
52
+ * A display name added to a selection.
53
+ */
54
+ displayName: string;
55
+ /**
56
+ * A color for UI elements.
57
+ */
58
+ color: string;
59
+ }
60
+ /**
61
+ * The default selection style.
62
+ */
63
+ export declare const defaultSelectionStyle: IEditorSelectionStyle;
64
+ /**
65
+ * A text selection.
66
+ */
67
+ export interface ITextSelection extends IRange {
68
+ /**
69
+ * The uuid of the text selection owner.
70
+ */
71
+ readonly uuid: string;
72
+ /**
73
+ * The style of this selection.
74
+ */
75
+ readonly style: IEditorSelectionStyle;
76
+ }
77
+ /**
78
+ * An interface for a text token, such as a word, keyword, or variable.
79
+ */
80
+ export interface IToken {
81
+ /**
82
+ * The value of the token.
83
+ */
84
+ value: string;
85
+ /**
86
+ * The offset of the token in the code editor.
87
+ */
88
+ offset: number;
89
+ /**
90
+ * An optional type for the token.
91
+ */
92
+ type?: string;
93
+ }
94
+ /**
95
+ * A selection owner.
96
+ */
97
+ export interface ISelectionOwner {
98
+ /**
99
+ * The uuid of this selection owner.
100
+ */
101
+ uuid: string;
102
+ /**
103
+ * Return selection value, if no range, return primary position value
104
+ */
105
+ getSelectionValue: (range?: IRange) => string | undefined;
106
+ /**
107
+ * Returns the primary position of the cursor, never `null`.
108
+ */
109
+ getCursorPosition: () => IPosition;
110
+ /**
111
+ * Set the primary position of the cursor.
112
+ *
113
+ * @param position - The new primary position.
114
+ *
115
+ * #### Notes
116
+ * This will remove any secondary cursors.
117
+ */
118
+ setCursorPosition: (position: IPosition) => void;
119
+ /**
120
+ * Returns the primary selection, never `null`.
121
+ */
122
+ getSelection: () => IRange;
123
+ /**
124
+ * Set the primary selection.
125
+ *
126
+ * @param selection - The desired selection range.
127
+ *
128
+ * #### Notes
129
+ * This will remove any secondary cursors.
130
+ */
131
+ setSelection: (selection: IRange) => void;
132
+ /**
133
+ * Gets the selections for all the cursors, never `null` or empty.
134
+ */
135
+ getSelections: () => IRange[];
136
+ /**
137
+ * Sets the selections for all the cursors.
138
+ *
139
+ * @param selections - The new selections.
140
+ *
141
+ * #### Notes
142
+ * Cursors will be removed or added, as necessary.
143
+ * Passing an empty array resets a cursor position to the start of a
144
+ * document.
145
+ */
146
+ setSelections: (selections: IRange[]) => void;
147
+ /**
148
+ * Replaces selection with the given text.
149
+ */
150
+ replaceSelection: (text: string, range: IRange) => void;
151
+ /**
152
+ * Replaces selection with the given text.
153
+ */
154
+ replaceSelections: (edits: {
155
+ text: string;
156
+ range: IRange;
157
+ }[]) => void;
158
+ /**
159
+ * highlight search matches
160
+ * @param matches
161
+ * @param currentIndex
162
+ */
163
+ highlightMatches: (matches: SearchMatch[], currentIndex: number | undefined) => void;
164
+ }
165
+ /**
166
+ * A keydown handler type.
167
+ *
168
+ * #### Notes
169
+ * Return `true` to prevent the default handling of the event by the
170
+ * editor.
171
+ */
172
+ export type KeydownHandler = (instance: IEditor, event: KeyboardEvent) => boolean;
173
+ /**
174
+ * The location of requested edges.
175
+ */
176
+ export type EdgeLocation = 'top' | 'topLine' | 'bottom';
177
+ /**
178
+ * A widget that provides a code editor.
179
+ */
180
+ export interface IEditor<S = any> extends ISelectionOwner, Disposable {
181
+ editorReady: Promise<void>;
182
+ /**
183
+ * A signal emitted when either the top or bottom edge is requested.
184
+ */
185
+ /**
186
+ * The DOM node that hosts the editor.
187
+ */
188
+ readonly host: HTMLElement;
189
+ /**
190
+ * The model used by the editor.
191
+ */
192
+ readonly model: IModel;
193
+ /**
194
+ * Get the number of lines in the editor.
195
+ */
196
+ readonly lineCount: number;
197
+ /**
198
+ * Get a config option for the editor.
199
+ */
200
+ getOption: <K extends keyof IEditorConfig>(option: K) => IEditorConfig[K];
201
+ /**
202
+ * Set a config option for the editor.
203
+ */
204
+ setOption: <K extends keyof IEditorConfig>(option: K, value: IEditorConfig[K]) => void;
205
+ /**
206
+ * Returns the content for the given line number.
207
+ *
208
+ * @param line - The line of interest.
209
+ *
210
+ * @returns The value of the line.
211
+ *
212
+ * #### Notes
213
+ * Lines are 1-based, and accessing a line out of range returns
214
+ * `undefined`.
215
+ */
216
+ getLine: (line: number) => string | undefined;
217
+ /**
218
+ * Find an zero-based offset for the given position.
219
+ *
220
+ * @param position - The position of interest.
221
+ *
222
+ * @returns The offset at the position, clamped to the extent of the
223
+ * editor contents.
224
+ */
225
+ getOffsetAt: (position: IPosition) => number;
226
+ /**
227
+ * Find a position for the given offset.
228
+ *
229
+ * @param offset - The offset of interest.
230
+ *
231
+ * @returns The position at the offset, clamped to the extent of the
232
+ * editor contents.
233
+ */
234
+ getPositionAt: (offset: number) => IPosition | undefined;
235
+ /**
236
+ * Undo one edit (if any undo events are stored).
237
+ */
238
+ undo: () => void;
239
+ /**
240
+ * Redo one undone edit.
241
+ */
242
+ redo: () => void;
243
+ /**
244
+ * Brings browser focus to this editor text.
245
+ */
246
+ focus: () => void;
247
+ /**
248
+ * Test whether the editor has keyboard focus.
249
+ */
250
+ hasFocus: () => boolean;
251
+ /**
252
+ * Explicitly blur the editor.
253
+ */
254
+ blur: () => void;
255
+ /**
256
+ * Resize the editor to fit its host node.
257
+ */
258
+ resizeToFit: () => void;
259
+ /**
260
+ * Reveals the given selection in the editor.
261
+ *
262
+ * @param position - The desired selection to reveal.
263
+ */
264
+ revealSelection: (selection: IRange) => void;
265
+ /**
266
+ * Get the cursor position given window coordinates.
267
+ *
268
+ * @param coordinate - The desired coordinate.
269
+ *
270
+ * @returns The position of the coordinates, or null if not
271
+ * contained in the editor.
272
+ */
273
+ getPositionForCoordinate: (coordinate: ICoordinate) => IPosition | null;
274
+ onModalChange: Event<boolean>;
275
+ dispose: () => void;
276
+ getState: () => EditorState<S>;
277
+ format: () => void;
278
+ onModelContentChanged?: Event<IModelContentChange[]>;
279
+ }
280
+ export type EditorTheme = Record<ThemeType, string>;
281
+ /**
282
+ * The configuration options for an editor.
283
+ */
284
+ export interface IEditorConfig {
285
+ theme: EditorTheme;
286
+ /**
287
+ * Half-period in milliseconds used for cursor blinking.
288
+ * By setting this to zero, blinking can be disabled.
289
+ * A negative value hides the cursor entirely.
290
+ */
291
+ cursorBlinkRate: number;
292
+ /**
293
+ * User preferred font family for text editors.
294
+ */
295
+ fontFamily: string | null;
296
+ /**
297
+ * User preferred size in pixel of the font used in text editors.
298
+ */
299
+ fontSize: number | null;
300
+ /**
301
+ * User preferred text line height, as a multiplier of font size.
302
+ */
303
+ lineHeight: number | null;
304
+ /**
305
+ * Whether line numbers should be displayed.
306
+ */
307
+ lineNumbers: boolean;
308
+ /**
309
+ * Control the line wrapping of the editor. Possible values are:
310
+ * - "off", lines will never wrap.
311
+ * - "on", lines will wrap at the viewport border.
312
+ * - "wordWrapColumn", lines will wrap at `wordWrapColumn`.
313
+ * - "bounded", lines will wrap at minimum between viewport width and wordWrapColumn.
314
+ */
315
+ lineWrap: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
316
+ /**
317
+ * Whether the editor content is read-only.
318
+ */
319
+ readOnly: boolean;
320
+ /**
321
+ * whther the editor view is editable.
322
+ */
323
+ editable: boolean;
324
+ /**
325
+ * The number of spaces a tab is equal to.
326
+ */
327
+ tabSize: number;
328
+ /**
329
+ * Whether to insert spaces when pressing Tab.
330
+ */
331
+ insertSpaces: boolean;
332
+ /**
333
+ * Whether to highlight matching brackets when one of them is selected.
334
+ */
335
+ matchBrackets: boolean;
336
+ /**
337
+ * Whether to automatically close brackets after opening them.
338
+ */
339
+ autoClosingBrackets: boolean;
340
+ /**
341
+ * Whether the editor should handle paste events.
342
+ */
343
+ handlePaste?: boolean;
344
+ /**
345
+ * The column where to break text line.
346
+ */
347
+ wordWrapColumn: number;
348
+ /**
349
+ * Column index at which rulers should be added.
350
+ */
351
+ rulers: number[];
352
+ /**
353
+ * Whether to allow code folding
354
+ */
355
+ codeFolding: boolean;
356
+ /**
357
+ * Whether to highlight trailing whitespace
358
+ */
359
+ showTrailingSpace: boolean;
360
+ foldGutter?: boolean;
361
+ styleActiveLine?: boolean;
362
+ highlightActiveLineGutter?: boolean;
363
+ placeholder?: HTMLElement | string;
364
+ lspEnabled: boolean;
365
+ paddingTop: number;
366
+ paddingBottom: number;
367
+ scrollBarHeight: number;
368
+ }
369
+ /**
370
+ * The default configuration options for an editor.
371
+ */
372
+ export declare const defaultConfig: Required<IEditorConfig>;
373
+ export type TooltipProviderOption = {
374
+ cursorPosition: number;
375
+ };
376
+ export type TooltipProvider = (option: TooltipProviderOption) => Promise<string | null>;
377
+ export type CompletionProviderOption = {
378
+ cursorPosition: number;
379
+ };
380
+ export type CompletionReply = {
381
+ matches: string[];
382
+ cursor_start: number;
383
+ cursor_end: number;
384
+ metadata: JSONObject;
385
+ };
386
+ export type CompletionProvider = (option: CompletionProviderOption) => Promise<CompletionReply>;
387
+ /**
388
+ * The options used to initialize an editor state.
389
+ */
390
+ export interface IEditorStateOptions {
391
+ /**
392
+ * The model used by the editor.
393
+ */
394
+ model: IModel;
395
+ /**
396
+ * The desired uuid for the editor.
397
+ */
398
+ uuid: string;
399
+ }
400
+ /**
401
+ * The options used to initialize an editor.
402
+ */
403
+ export interface IEditorOptions extends IEditorStateOptions {
404
+ /**
405
+ * The host widget used by the editor.
406
+ */
407
+ host: HTMLElement;
408
+ /**
409
+ * The default selection style for the editor.
410
+ */
411
+ selectionStyle?: Partial<IEditorSelectionStyle>;
412
+ /**
413
+ * The configuration options for the editor.
414
+ */
415
+ config?: Partial<IEditorConfig>;
416
+ tooltipProvider?: TooltipProvider;
417
+ completionProvider?: CompletionProvider;
418
+ }
419
+ /**
420
+ * Base search match interface
421
+ */
422
+ export interface SearchMatch {
423
+ /**
424
+ * Text of the exact match itself
425
+ */
426
+ readonly text: string;
427
+ /**
428
+ * Start location of the match (in a text, this is the column)
429
+ */
430
+ position: number;
431
+ }
432
+ export interface EditorState<T = any> {
433
+ state: T;
434
+ cursorPosition?: IPosition;
435
+ selections?: IRange[];
436
+ toJSON: () => JSONValue;
437
+ dispose: (state: T) => void;
438
+ }
439
+ export type EditorStateFactory<T = any> = (options: IEditorStateOptions) => EditorState<T>;
440
+ /**
441
+ * A factory used to create a code editor.
442
+ */
443
+ export type CodeEditorFactory<T = EditorState> = (options: IEditorOptions, state?: T) => IEditor<T>;
444
+ export declare const CodeEditorContribution: Syringe.DefinedToken;
445
+ export interface CodeEditorContribution<T = any> {
446
+ canHandle(mime: string): number;
447
+ /**
448
+ * editor factory
449
+ */
450
+ factory: CodeEditorFactory<T>;
451
+ /**
452
+ * editor state factory
453
+ */
454
+ stateFactory?: EditorStateFactory<T>;
455
+ defaultConfig: IEditorConfig;
456
+ }
457
+ export interface IModelContentChange {
458
+ /**
459
+ * The range that got replaced.
460
+ */
461
+ readonly range: IRange;
462
+ /**
463
+ * The offset of the range that got replaced.
464
+ */
465
+ readonly rangeOffset: number;
466
+ /**
467
+ * The length of the range that got replaced.
468
+ */
469
+ readonly rangeLength: number;
470
+ /**
471
+ * The new text for the range.
472
+ */
473
+ readonly text: string;
474
+ }
475
+ //# sourceMappingURL=code-editor-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-editor-protocol.d.ts","sourceRoot":"","sources":["../src/code-editor-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AACD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;AAC1C;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAE1B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,E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AC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC;;OAEG;IACH,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACrC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,113 @@
1
+ import { Syringe } from '@difizen/mana-app';
2
+
3
+ /**
4
+ * A one-based position in the editor.
5
+ */
6
+
7
+ /**
8
+ * An interface describing editor state coordinates.
9
+ */
10
+
11
+ /**
12
+ * A range.
13
+ */
14
+
15
+ /**
16
+ * A selection style.
17
+ */
18
+
19
+ /**
20
+ * The default selection style.
21
+ */
22
+ export var defaultSelectionStyle = {
23
+ className: '',
24
+ displayName: '',
25
+ color: 'black'
26
+ };
27
+
28
+ /**
29
+ * A text selection.
30
+ */
31
+
32
+ /**
33
+ * An interface for a text token, such as a word, keyword, or variable.
34
+ */
35
+
36
+ /**
37
+ * A selection owner.
38
+ */
39
+
40
+ /**
41
+ * A keydown handler type.
42
+ *
43
+ * #### Notes
44
+ * Return `true` to prevent the default handling of the event by the
45
+ * editor.
46
+ */
47
+
48
+ /**
49
+ * The location of requested edges.
50
+ */
51
+
52
+ /**
53
+ * A widget that provides a code editor.
54
+ */
55
+
56
+ /**
57
+ * The configuration options for an editor.
58
+ */
59
+
60
+ /**
61
+ * The default configuration options for an editor.
62
+ */
63
+ export var defaultConfig = {
64
+ theme: {
65
+ light: 'light',
66
+ dark: 'dark',
67
+ hc: 'hc-mana'
68
+ },
69
+ // Order matters as gutters will be sorted by the configuration order
70
+ autoClosingBrackets: true,
71
+ cursorBlinkRate: 530,
72
+ fontFamily: null,
73
+ fontSize: 13,
74
+ handlePaste: true,
75
+ insertSpaces: true,
76
+ lineHeight: null,
77
+ lineNumbers: true,
78
+ lineWrap: 'off',
79
+ matchBrackets: true,
80
+ readOnly: false,
81
+ editable: true,
82
+ tabSize: 4,
83
+ rulers: [],
84
+ showTrailingSpace: false,
85
+ wordWrapColumn: 80,
86
+ codeFolding: true,
87
+ foldGutter: true,
88
+ styleActiveLine: false,
89
+ highlightActiveLineGutter: false,
90
+ lspEnabled: true,
91
+ paddingTop: 12,
92
+ paddingBottom: 18,
93
+ scrollBarHeight: 0,
94
+ placeholder: ''
95
+ };
96
+
97
+ /**
98
+ * The options used to initialize an editor state.
99
+ */
100
+
101
+ /**
102
+ * The options used to initialize an editor.
103
+ */
104
+
105
+ /**
106
+ * Base search match interface
107
+ */
108
+
109
+ /**
110
+ * A factory used to create a code editor.
111
+ */
112
+
113
+ export var CodeEditorContribution = Syringe.defineToken('CodeEditorContribution');
@@ -0,0 +1,34 @@
1
+ import { ApplicationContribution, DisposableCollection, Emitter, ConfigurationContribution, ConfigurationService } from '@difizen/mana-app';
2
+ import type { Disposable, ConfigurationNode } from '@difizen/mana-app';
3
+ import type { IEditorConfig } from './code-editor-protocol.js';
4
+ declare global {
5
+ interface ObjectConstructor {
6
+ typedKeys<T>(obj: T): (keyof T)[];
7
+ }
8
+ }
9
+ export declare const CodeEditorSetting: {
10
+ [key in keyof IEditorConfig]?: ConfigurationNode<any>;
11
+ };
12
+ export declare class CodeEditorSettings implements ConfigurationContribution, ApplicationContribution, Disposable {
13
+ protected readonly configurationService: ConfigurationService;
14
+ protected codeEditorSettingsChangeEmitter: Emitter<{
15
+ key: keyof IEditorConfig;
16
+ value: any;
17
+ }>;
18
+ onCodeEditorSettingsChange: import("@difizen/mana-app").Event<{
19
+ key: keyof IEditorConfig;
20
+ value: any;
21
+ }>;
22
+ protected toDispose: DisposableCollection;
23
+ protected useSettings: Partial<IEditorConfig> | undefined;
24
+ constructor(configurationService: ConfigurationService);
25
+ registerConfigurations(): (ConfigurationNode<number> | ConfigurationNode<boolean> | ConfigurationNode<"wordWrapColumn" | "off" | "on" | "bounded">)[];
26
+ onStart(): Promise<void>;
27
+ getUserEditorSettings(): Partial<IEditorConfig> | undefined;
28
+ protected fetchUserEditorSettings(): Promise<Partial<IEditorConfig>>;
29
+ protected handleEditorSettingsChange(): void;
30
+ protected isDisposed: boolean;
31
+ get disposed(): boolean;
32
+ dispose(): void;
33
+ }
34
+ //# sourceMappingURL=code-editor-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-editor-settings.d.ts","sourceRoot":"","sources":["../src/code-editor-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EACvB,oBAAoB,EACpB,OAAO,EACP,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,iBAAiB;QACzB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;KACnC;CACF;AAmGD,eAAO,MAAM,iBAAiB,EAAE;KAC7B,GAAG,IAAI,MAAM,aAAa,CAAC,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC;CAStD,CAAC;AAEF,qBACa,kBACX,YAAW,yBAAyB,EAAE,uBAAuB,EAAE,UAAU;IAEzE,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAE9D,SAAS,CAAC,+BAA+B;aAClC,MAAM,aAAa;eACjB,GAAG;OACP;IAEL,0BAA0B;aAJnB,MAAM,aAAa;eACjB,GAAG;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