@adecore/editor 0.0.1 → 0.17.0-beta.1

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 (107) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +82 -0
  3. package/dist/attribution.d.ts +28 -0
  4. package/dist/attribution.js +55 -0
  5. package/dist/code-block.d.ts +2 -0
  6. package/dist/code-block.js +89 -0
  7. package/dist/column-selection.d.ts +9 -0
  8. package/dist/column-selection.js +52 -0
  9. package/dist/controller.d.ts +64 -0
  10. package/dist/controller.js +772 -0
  11. package/dist/editor.css +813 -0
  12. package/dist/engine.d.ts +2 -0
  13. package/dist/engine.js +604 -0
  14. package/dist/fake.d.ts +190 -0
  15. package/dist/fake.js +658 -0
  16. package/dist/find.d.ts +30 -0
  17. package/dist/find.js +108 -0
  18. package/dist/index.d.ts +5 -0
  19. package/dist/index.js +4 -0
  20. package/dist/input.d.ts +9 -0
  21. package/dist/input.js +57 -0
  22. package/dist/keymap-table.d.ts +102 -0
  23. package/dist/keymap-table.js +130 -0
  24. package/dist/keymap.d.ts +36 -0
  25. package/dist/keymap.js +163 -0
  26. package/dist/layout.d.ts +167 -0
  27. package/dist/layout.js +583 -0
  28. package/dist/lens.d.ts +3 -0
  29. package/dist/lens.js +29 -0
  30. package/dist/listeners.d.ts +3 -0
  31. package/dist/listeners.js +12 -0
  32. package/dist/metrics.d.ts +8 -0
  33. package/dist/metrics.js +54 -0
  34. package/dist/modifier-gesture.d.ts +24 -0
  35. package/dist/modifier-gesture.js +98 -0
  36. package/dist/native-input.d.ts +26 -0
  37. package/dist/native-input.js +147 -0
  38. package/dist/offsets.d.ts +2 -0
  39. package/dist/offsets.js +14 -0
  40. package/dist/outline.d.ts +55 -0
  41. package/dist/outline.js +181 -0
  42. package/dist/overview.d.ts +17 -0
  43. package/dist/overview.js +55 -0
  44. package/dist/paint.d.ts +86 -0
  45. package/dist/paint.js +481 -0
  46. package/dist/php-html.d.ts +9 -0
  47. package/dist/php-html.js +36 -0
  48. package/dist/pointer.d.ts +49 -0
  49. package/dist/pointer.js +243 -0
  50. package/dist/scroll-animation.d.ts +3 -0
  51. package/dist/scroll-animation.js +45 -0
  52. package/dist/scroll.d.ts +28 -0
  53. package/dist/scroll.js +76 -0
  54. package/dist/semantic.d.ts +8 -0
  55. package/dist/semantic.js +47 -0
  56. package/dist/shiki.d.ts +7 -0
  57. package/dist/shiki.js +106 -0
  58. package/dist/smart-keys.d.ts +3 -0
  59. package/dist/smart-keys.js +14 -0
  60. package/dist/testing.d.ts +34 -0
  61. package/dist/testing.js +117 -0
  62. package/dist/theme-scopes.d.ts +9 -0
  63. package/dist/theme-scopes.js +61 -0
  64. package/dist/tokens.d.ts +28 -0
  65. package/dist/tokens.js +152 -0
  66. package/dist/tracked-range.d.ts +5 -0
  67. package/dist/tracked-range.js +20 -0
  68. package/dist/types.d.ts +342 -0
  69. package/dist/types.js +1 -0
  70. package/dist/view.d.ts +382 -0
  71. package/dist/view.js +2134 -0
  72. package/package.json +63 -3
  73. package/src/attribution.ts +85 -0
  74. package/src/code-block.ts +100 -0
  75. package/src/column-selection.ts +63 -0
  76. package/src/controller.ts +838 -0
  77. package/src/editor.css +813 -0
  78. package/src/engine.ts +757 -0
  79. package/src/fake.ts +831 -0
  80. package/src/find.ts +128 -0
  81. package/src/index.ts +69 -0
  82. package/src/input.ts +63 -0
  83. package/src/keymap-table.ts +163 -0
  84. package/src/keymap.ts +204 -0
  85. package/src/layout.ts +754 -0
  86. package/src/lens.ts +32 -0
  87. package/src/listeners.ts +15 -0
  88. package/src/metrics.ts +65 -0
  89. package/src/modifier-gesture.ts +115 -0
  90. package/src/native-input.ts +179 -0
  91. package/src/offsets.ts +16 -0
  92. package/src/outline.ts +248 -0
  93. package/src/overview.ts +80 -0
  94. package/src/paint.ts +608 -0
  95. package/src/php-html.ts +43 -0
  96. package/src/pointer.ts +326 -0
  97. package/src/scroll-animation.ts +48 -0
  98. package/src/scroll.ts +102 -0
  99. package/src/semantic.ts +54 -0
  100. package/src/shiki.ts +118 -0
  101. package/src/smart-keys.ts +17 -0
  102. package/src/testing.ts +157 -0
  103. package/src/theme-scopes.ts +75 -0
  104. package/src/tokens.ts +175 -0
  105. package/src/tracked-range.ts +22 -0
  106. package/src/types.ts +656 -0
  107. package/src/view.ts +2436 -0
@@ -0,0 +1,342 @@
1
+ import type { Keymap } from './keymap-table.ts';
2
+ import type { EditorCommand, FoldRole } from '@adecore/editor-core';
3
+ export type { EditorCommand, FoldRole };
4
+ export type EditorFoldOutline = 'off' | 'hover' | 'always';
5
+ export type EditorViewCommand = 'collapseRegion' | 'expandRegion' | 'collapseAllRegions' | 'expandAllRegions' | 'collapseRegionRecursively' | 'expandRegionRecursively' | 'foldSelection' | 'collapseDocComments' | 'expandDocComments' | 'expandAllToLevel1' | 'expandAllToLevel2' | 'expandAllToLevel3' | 'expandAllToLevel4' | 'expandAllToLevel5' | 'toggleColumnMode';
6
+ export type EditorRunCommand = EditorCommand | EditorViewCommand;
7
+ export interface EditorFoldRange {
8
+ readonly startLine: number;
9
+ readonly endLine: number;
10
+ }
11
+ export interface EditorFolds {
12
+ readonly collapsed: readonly EditorFoldRange[];
13
+ readonly custom: readonly EditorFoldRange[];
14
+ }
15
+ export type EditorTheme = string;
16
+ export interface EditorOptions {
17
+ readonly text: string;
18
+ readonly language?: string;
19
+ readonly path?: string;
20
+ readonly theme: EditorTheme;
21
+ readonly readOnly?: boolean;
22
+ readonly readOnlyReason?: string;
23
+ readonly wrap?: boolean;
24
+ readonly indentation?: EditorIndentation;
25
+ readonly smartKeys?: Partial<EditorSmartKeys>;
26
+ readonly guides?: boolean;
27
+ readonly whitespace?: boolean;
28
+ readonly rightMargin?: number | null;
29
+ readonly foldOutline?: EditorFoldOutline;
30
+ readonly messages?: Partial<EditorMessages>;
31
+ readonly folds?: EditorFolds;
32
+ readonly foldDefaults?: readonly FoldRole[];
33
+ readonly line?: number;
34
+ readonly column?: number;
35
+ readonly scrollTop?: number;
36
+ }
37
+ export interface EditorMessages {
38
+ readonly noMoreOccurrences: string;
39
+ }
40
+ export interface EditorSmartKeys {
41
+ readonly autoPairBrackets: boolean;
42
+ readonly autoPairQuotes: boolean;
43
+ readonly surroundSelection: boolean;
44
+ readonly tabOutOfClosers: boolean;
45
+ readonly smartIndentOnEnter: boolean;
46
+ readonly indentOnPaste: boolean;
47
+ readonly smartSemicolon: boolean;
48
+ readonly camelHumps: boolean;
49
+ }
50
+ export interface EditorFoldSymbol {
51
+ readonly range: EditorRange;
52
+ readonly body: 'function' | 'method' | 'class' | 'value';
53
+ }
54
+ export interface EditorFoldHints {
55
+ readonly symbols?: readonly EditorFoldSymbol[];
56
+ readonly ranges?: readonly (EditorFoldRange & {
57
+ readonly kind?: string;
58
+ })[];
59
+ }
60
+ export interface EditorBlock {
61
+ readonly startLine: number;
62
+ readonly endLine: number;
63
+ readonly name?: string;
64
+ readonly kind?: string;
65
+ }
66
+ export type EditorChangeKind = 'added' | 'modified' | 'deleted';
67
+ export interface EditorChangeMark {
68
+ readonly kind: EditorChangeKind;
69
+ readonly startLine: number;
70
+ readonly endLine: number;
71
+ }
72
+ export type EditorMarkColor = string;
73
+ export interface EditorAttributionMark {
74
+ readonly id: string;
75
+ readonly startLine: number;
76
+ readonly endLine: number;
77
+ readonly color: EditorMarkColor;
78
+ }
79
+ export interface EditorRemoteCursor {
80
+ readonly id: string;
81
+ readonly position: EditorPosition;
82
+ readonly name: string;
83
+ readonly color: EditorMarkColor;
84
+ }
85
+ export interface EditorLineHighlight {
86
+ readonly startLine: number;
87
+ readonly endLine: number;
88
+ readonly color: EditorMarkColor;
89
+ readonly fill?: EditorMarkColor;
90
+ readonly sign?: string;
91
+ }
92
+ export interface EditorCodeBlockOptions {
93
+ readonly firstLine?: number;
94
+ readonly sign?: string;
95
+ readonly color?: EditorMarkColor;
96
+ readonly emphasis?: ReadonlyArray<ReadonlyArray<readonly [number, number]>>;
97
+ readonly faded?: boolean;
98
+ }
99
+ export interface EditorAttributionHover {
100
+ readonly id: string;
101
+ readonly rect: EditorRect;
102
+ }
103
+ export interface EditorPosition {
104
+ readonly line: number;
105
+ readonly character: number;
106
+ }
107
+ export interface EditorRange {
108
+ readonly start: EditorPosition;
109
+ readonly end: EditorPosition;
110
+ }
111
+ export interface EditorContentChange {
112
+ readonly range: EditorRange;
113
+ readonly text: string;
114
+ }
115
+ export interface EditorTextChange {
116
+ readonly changes: readonly EditorContentChange[];
117
+ readonly source: 'input' | 'command' | 'external';
118
+ }
119
+ export type EditorMarkerSeverity = 'error' | 'warning' | 'info' | 'hint';
120
+ export interface EditorMarker {
121
+ readonly range: EditorRange;
122
+ readonly severity: EditorMarkerSeverity;
123
+ readonly unnecessary?: boolean;
124
+ readonly deprecated?: boolean;
125
+ readonly message?: string;
126
+ }
127
+ export type EditorHighlightKind = 'text' | 'read' | 'write';
128
+ export interface EditorHighlight {
129
+ readonly range: EditorRange;
130
+ readonly kind: EditorHighlightKind;
131
+ }
132
+ export interface EditorRect {
133
+ readonly left: number;
134
+ readonly top: number;
135
+ readonly right: number;
136
+ readonly bottom: number;
137
+ }
138
+ export interface EditorHover {
139
+ readonly position: EditorPosition;
140
+ readonly rect: EditorRect;
141
+ }
142
+ export interface EditorClick {
143
+ readonly position: EditorPosition;
144
+ readonly mod: boolean;
145
+ readonly alt: boolean;
146
+ readonly shift: boolean;
147
+ }
148
+ export type EditorClickHandler = (click: EditorClick) => boolean;
149
+ export interface EditorContextMenu {
150
+ readonly position: EditorPosition;
151
+ readonly inSelection: boolean;
152
+ readonly x: number;
153
+ readonly y: number;
154
+ }
155
+ export interface EditorWidget {
156
+ readonly id: string;
157
+ readonly line: number;
158
+ readonly placement?: 'above' | 'below';
159
+ readonly height?: number;
160
+ render(container: HTMLElement): void;
161
+ }
162
+ export interface EditorLineAction {
163
+ readonly id: string;
164
+ readonly line: number;
165
+ render(container: HTMLElement): void;
166
+ }
167
+ export interface EditorCodeVisionEntry {
168
+ readonly id: string;
169
+ readonly text: string;
170
+ readonly icon?: 'user' | 'users';
171
+ activate(anchor: EditorRect): void;
172
+ }
173
+ export interface EditorCodeVision {
174
+ readonly id: string;
175
+ readonly line: number;
176
+ readonly entries: readonly EditorCodeVisionEntry[];
177
+ }
178
+ export type EditorKeyHandler = (event: KeyboardEvent) => boolean;
179
+ export type EditorSelectionRanges = (positions: readonly EditorPosition[]) => Promise<readonly (readonly EditorRange[])[] | null>;
180
+ export interface EditorSemanticToken {
181
+ readonly line: number;
182
+ readonly character: number;
183
+ readonly length: number;
184
+ readonly scopes: readonly string[];
185
+ }
186
+ export interface ScopeStyle {
187
+ readonly color: string;
188
+ readonly fontStyle: number;
189
+ }
190
+ export type ScopeColors = (scopes: readonly string[]) => ScopeStyle | undefined;
191
+ export type ScopeColorSource = (theme: EditorTheme) => Promise<ScopeColors | null>;
192
+ export interface EditorInlayHint {
193
+ readonly position: EditorPosition;
194
+ readonly label: string;
195
+ }
196
+ export interface EditorGhostText {
197
+ readonly position: EditorPosition;
198
+ readonly text: string;
199
+ readonly accessory?: (container: HTMLElement) => void;
200
+ }
201
+ export interface EditorGutterAction {
202
+ readonly line: number;
203
+ readonly label: string;
204
+ }
205
+ export interface EditorGutterMarker {
206
+ readonly id: string;
207
+ readonly line: number;
208
+ readonly label: string;
209
+ }
210
+ export type EditorReveal = 'relative' | 'center' | 'centerDown' | 'centerUp';
211
+ export interface EditorIndentation {
212
+ readonly tabSize: number;
213
+ readonly insertSpaces: boolean;
214
+ }
215
+ export interface EditorFindQuery {
216
+ readonly text: string;
217
+ readonly caseSensitive: boolean;
218
+ readonly wholeWord: boolean;
219
+ readonly regex: boolean;
220
+ readonly inSelection?: boolean;
221
+ }
222
+ export interface EditorFindState {
223
+ readonly count: number;
224
+ readonly current: number | null;
225
+ readonly noSelection?: boolean;
226
+ }
227
+ export interface EditorReplaceOptions {
228
+ readonly preserveCase?: boolean;
229
+ }
230
+ export interface EditorTrackedRange {
231
+ get(): EditorRange | null;
232
+ dispose(): void;
233
+ }
234
+ export interface Editor {
235
+ getText(): string;
236
+ setText(text: string): void;
237
+ onChange(listener: () => void): () => void;
238
+ onTextChange(listener: (change: EditorTextChange) => void): () => void;
239
+ positionAt(offset: number): EditorPosition;
240
+ offsetAt(position: EditorPosition): number;
241
+ textInRange(range: EditorRange): string;
242
+ onSave(listener: () => void): () => void;
243
+ onBlur(listener: () => void): () => void;
244
+ revealLine(line: number, reveal?: EditorReveal): void;
245
+ find(query: EditorFindQuery | null): void;
246
+ findStep(direction: 1 | -1): void;
247
+ replace(replacement: string, options?: EditorReplaceOptions): boolean;
248
+ replaceAll(replacement: string, options?: EditorReplaceOptions): number;
249
+ setReplacePreview(replacement: string | null, options?: EditorReplaceOptions): void;
250
+ selectFindMatches(): number;
251
+ findFromCursor(query: EditorFindQuery, direction: 1 | -1): boolean;
252
+ onFind(listener: (state: EditorFindState) => void): () => void;
253
+ endFind(): void;
254
+ setWrap(wrap: boolean): void;
255
+ setIndentation(indentation: EditorIndentation): void;
256
+ setSmartKeys(keys: Partial<EditorSmartKeys>): void;
257
+ setGuides(guides: boolean): void;
258
+ setWhitespace(whitespace: boolean): void;
259
+ setRightMargin(column: number | null): void;
260
+ setFoldOutline(outline: EditorFoldOutline): void;
261
+ setFoldHints(hints: EditorFoldHints | null): void;
262
+ setChangeMarks(marks: readonly EditorChangeMark[]): void;
263
+ setBlocks(blocks: readonly EditorBlock[] | null): void;
264
+ onScope(listener: (scope: readonly EditorBlock[]) => void): () => void;
265
+ setAttributionMarks(marks: readonly EditorAttributionMark[]): void;
266
+ setRemoteCursors(cursors: readonly EditorRemoteCursor[]): void;
267
+ setLineHighlights(highlights: readonly EditorLineHighlight[]): void;
268
+ renderCode(container: HTMLElement, text: string, options?: EditorCodeBlockOptions): void;
269
+ onAttributionHover(listener: (hover: EditorAttributionHover | null) => void): () => void;
270
+ setMarkers(markers: readonly EditorMarker[]): void;
271
+ setHighlights(highlights: readonly EditorHighlight[]): void;
272
+ setLink(range: EditorRange | null): void;
273
+ setSemanticTokens(tokens: readonly EditorSemanticToken[] | null): void;
274
+ setInlayHints(hints: readonly EditorInlayHint[]): void;
275
+ setGhostText(ghost: EditorGhostText | null): void;
276
+ setGutterAction(action: EditorGutterAction | null): void;
277
+ onGutterAction(listener: (line: number) => void): () => void;
278
+ setGutterMarkers(markers: readonly EditorGutterMarker[], owner?: string): void;
279
+ onGutterMarker(listener: (id: string) => void): () => void;
280
+ getCaret(): EditorPosition;
281
+ getScrollTop(): number;
282
+ getFolds(): EditorFolds;
283
+ getSelection(): EditorRange;
284
+ getSelections(): EditorRange[];
285
+ getIndentation(): EditorIndentation;
286
+ setCaret(position: EditorPosition, reveal?: EditorReveal): void;
287
+ setSelection(range: EditorRange, reveal?: EditorReveal): void;
288
+ setSelections(ranges: readonly EditorRange[], reveal?: EditorReveal): void;
289
+ onCaret(listener: (position: EditorPosition) => void): () => void;
290
+ onHover(listener: (hover: EditorHover | null) => void): () => void;
291
+ rectAt(position: EditorPosition): EditorRect | null;
292
+ getVisibleRange(): EditorRange;
293
+ onViewChange(listener: () => void): () => void;
294
+ setWidgets(widgets: readonly EditorWidget[], owner?: string): void;
295
+ setLineActions(actions: readonly EditorLineAction[], owner?: string): void;
296
+ setCodeVision(rows: readonly EditorCodeVision[]): void;
297
+ onClick(handler: EditorClickHandler): () => void;
298
+ onContextMenu(listener: (menu: EditorContextMenu) => void): () => void;
299
+ onKeyDown(handler: EditorKeyHandler): () => void;
300
+ setSelectionRanges(provider: EditorSelectionRanges | null): void;
301
+ trackRange(range: EditorRange): EditorTrackedRange;
302
+ applyEdits(edits: readonly EditorContentChange[]): boolean;
303
+ setTheme(theme: EditorTheme): void;
304
+ refreshFont(): void;
305
+ setReadOnly(readOnly: boolean, reason?: string): void;
306
+ runCommand(command: EditorRunCommand): boolean;
307
+ focus(): void;
308
+ dispose(): void;
309
+ }
310
+ export interface EditorEngine {
311
+ mount(element: HTMLElement, options: EditorOptions): Editor;
312
+ }
313
+ export interface KeyChord {
314
+ readonly mod: boolean;
315
+ readonly ctrl: boolean;
316
+ readonly meta: boolean;
317
+ readonly alt: boolean;
318
+ readonly shift: boolean;
319
+ readonly key: string;
320
+ }
321
+ export interface LineToken {
322
+ readonly length: number;
323
+ readonly color: string;
324
+ readonly fontStyle: number;
325
+ }
326
+ export interface TokenizedLine {
327
+ readonly tokens: readonly LineToken[];
328
+ readonly state: unknown;
329
+ }
330
+ export interface LineTokenizer {
331
+ tokenizeLine(text: string, state: unknown): TokenizedLine;
332
+ sameState(a: unknown, b: unknown): boolean;
333
+ stale?(): boolean;
334
+ }
335
+ export type TokenizerSource = (language: string | undefined, theme: EditorTheme, text?: string) => Promise<LineTokenizer | null>;
336
+ export interface SmartEditorEngineOptions {
337
+ readonly keymap?: Keymap;
338
+ readonly tokenizer: TokenizerSource;
339
+ readonly scopeColors?: ScopeColorSource;
340
+ readonly handBack?: readonly KeyChord[];
341
+ readonly apple?: boolean;
342
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};