@theia/editor 1.18.0 → 1.21.0-next.12

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 (39) hide show
  1. package/lib/browser/editor-command.d.ts +2 -0
  2. package/lib/browser/editor-command.d.ts.map +1 -1
  3. package/lib/browser/editor-command.js +80 -65
  4. package/lib/browser/editor-command.js.map +1 -1
  5. package/lib/browser/editor-contribution.d.ts +5 -4
  6. package/lib/browser/editor-contribution.d.ts.map +1 -1
  7. package/lib/browser/editor-contribution.js +42 -14
  8. package/lib/browser/editor-contribution.js.map +1 -1
  9. package/lib/browser/editor-frontend-module.js +1 -1
  10. package/lib/browser/editor-frontend-module.js.map +1 -1
  11. package/lib/browser/editor-manager.d.ts +1 -2
  12. package/lib/browser/editor-manager.d.ts.map +1 -1
  13. package/lib/browser/editor-manager.js.map +1 -1
  14. package/lib/browser/editor-menu.d.ts +13 -1
  15. package/lib/browser/editor-menu.d.ts.map +1 -1
  16. package/lib/browser/editor-menu.js +32 -7
  17. package/lib/browser/editor-menu.js.map +1 -1
  18. package/lib/browser/editor-preferences.d.ts +2 -0
  19. package/lib/browser/editor-preferences.d.ts.map +1 -1
  20. package/lib/browser/editor-preferences.js +303 -291
  21. package/lib/browser/editor-preferences.js.map +1 -1
  22. package/lib/browser/editor-widget-factory.js +1 -1
  23. package/lib/browser/editor-widget-factory.js.map +1 -1
  24. package/lib/browser/editor.d.ts +1 -2
  25. package/lib/browser/editor.d.ts.map +1 -1
  26. package/lib/browser/editor.js.map +1 -1
  27. package/lib/browser/quick-editor-service.d.ts +1 -2
  28. package/lib/browser/quick-editor-service.d.ts.map +1 -1
  29. package/lib/browser/quick-editor-service.js.map +1 -1
  30. package/package.json +5 -5
  31. package/src/browser/editor-command.ts +80 -65
  32. package/src/browser/editor-contribution.ts +46 -18
  33. package/src/browser/editor-frontend-module.ts +1 -1
  34. package/src/browser/editor-manager.ts +1 -2
  35. package/src/browser/editor-menu.ts +35 -7
  36. package/src/browser/editor-preferences.ts +303 -291
  37. package/src/browser/editor-widget-factory.ts +2 -2
  38. package/src/browser/editor.ts +1 -2
  39. package/src/browser/quick-editor-service.ts +1 -2
@@ -18,21 +18,27 @@ import { EditorManager } from './editor-manager';
18
18
  import { TextEditor } from './editor';
19
19
  import { injectable, inject, optional } from '@theia/core/shared/inversify';
20
20
  import { StatusBarAlignment, StatusBar } from '@theia/core/lib/browser/status-bar/status-bar';
21
- import { FrontendApplicationContribution, DiffUris, DockLayout, QuickInputService } from '@theia/core/lib/browser';
21
+ import {
22
+ FrontendApplicationContribution, DiffUris, DockLayout,
23
+ QuickInputService, KeybindingRegistry, KeybindingContribution, SHELL_TABBAR_CONTEXT_SPLIT, ApplicationShell
24
+ } from '@theia/core/lib/browser';
22
25
  import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
23
- import { CommandHandler, DisposableCollection } from '@theia/core';
26
+ import { CommandHandler, DisposableCollection, MenuContribution, MenuModelRegistry } from '@theia/core';
24
27
  import { EditorCommands } from './editor-command';
25
28
  import { CommandRegistry, CommandContribution } from '@theia/core/lib/common';
26
- import { KeybindingRegistry, KeybindingContribution } from '@theia/core/lib/browser';
27
29
  import { LanguageService } from '@theia/core/lib/browser/language-service';
28
30
  import { SUPPORTED_ENCODINGS } from '@theia/core/lib/browser/supported-encodings';
31
+ import { nls } from '@theia/core/lib/common/nls';
32
+ import { CurrentWidgetCommandAdapter } from '@theia/core/lib/browser/shell/current-widget-command-adapter';
33
+ import { EditorWidget } from './editor-widget';
29
34
 
30
35
  @injectable()
31
- export class EditorContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution {
36
+ export class EditorContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
32
37
 
33
38
  @inject(StatusBar) protected readonly statusBar: StatusBar;
34
39
  @inject(EditorManager) protected readonly editorManager: EditorManager;
35
40
  @inject(LanguageService) protected readonly languages: LanguageService;
41
+ @inject(ApplicationShell) protected readonly shell: ApplicationShell;
36
42
 
37
43
  @inject(ContextKeyService)
38
44
  protected readonly contextKeyService: ContextKeyService;
@@ -95,7 +101,7 @@ export class EditorContribution implements FrontendApplicationContribution, Comm
95
101
  alignment: StatusBarAlignment.RIGHT,
96
102
  priority: 1,
97
103
  command: EditorCommands.CHANGE_LANGUAGE.id,
98
- tooltip: 'Select Language Mode'
104
+ tooltip: nls.localizeByDefault('Select Language Mode')
99
105
  });
100
106
  }
101
107
 
@@ -109,7 +115,7 @@ export class EditorContribution implements FrontendApplicationContribution, Comm
109
115
  alignment: StatusBarAlignment.RIGHT,
110
116
  priority: 10,
111
117
  command: EditorCommands.CHANGE_ENCODING.id,
112
- tooltip: 'Select Encoding'
118
+ tooltip: nls.localizeByDefault('Select Encoding')
113
119
  });
114
120
  }
115
121
 
@@ -120,11 +126,11 @@ export class EditorContribution implements FrontendApplicationContribution, Comm
120
126
  }
121
127
  const { cursor } = editor;
122
128
  this.statusBar.setElement('editor-status-cursor-position', {
123
- text: `Ln ${cursor.line + 1}, Col ${editor.getVisibleColumn(cursor)}`,
129
+ text: nls.localizeByDefault('Ln {0}, Col {1}', cursor.line + 1, editor.getVisibleColumn(cursor)),
124
130
  alignment: StatusBarAlignment.RIGHT,
125
131
  priority: 100,
126
- tooltip: 'Go To Line',
127
- command: 'editor.action.gotoLine'
132
+ tooltip: EditorCommands.GOTO_LINE_COLUMN.label,
133
+ command: EditorCommands.GOTO_LINE_COLUMN.id
128
134
  });
129
135
  }
130
136
 
@@ -132,15 +138,14 @@ export class EditorContribution implements FrontendApplicationContribution, Comm
132
138
  commands.registerCommand(EditorCommands.SHOW_ALL_OPENED_EDITORS, {
133
139
  execute: () => this.quickInputService?.open('edt ')
134
140
  });
135
- const splitHandlerFactory = (splitMode: DockLayout.InsertMode): CommandHandler => ({
136
- isEnabled: () => !!this.editorManager.currentEditor,
137
- isVisible: () => !!this.editorManager.currentEditor,
138
- execute: async () => {
139
- const { currentEditor } = this.editorManager;
140
- if (currentEditor) {
141
- const selection = currentEditor.editor.selection;
142
- const newEditor = await this.editorManager.openToSide(currentEditor.editor.uri, { selection, widgetOptions: { mode: splitMode } });
143
- const oldEditorState = currentEditor.editor.storeViewState();
141
+ const splitHandlerFactory = (splitMode: DockLayout.InsertMode): CommandHandler => new CurrentWidgetCommandAdapter(this.shell, {
142
+ isEnabled: title => title?.owner instanceof EditorWidget,
143
+ isVisible: title => title?.owner instanceof EditorWidget,
144
+ execute: async title => {
145
+ if (title?.owner instanceof EditorWidget) {
146
+ const selection = title.owner.editor.selection;
147
+ const newEditor = await this.editorManager.openToSide(title.owner.editor.uri, { selection, widgetOptions: { mode: splitMode, ref: title.owner } });
148
+ const oldEditorState = title.owner.editor.storeViewState();
144
149
  newEditor.editor.restoreViewState(oldEditorState);
145
150
  }
146
151
  }
@@ -167,4 +172,27 @@ export class EditorContribution implements FrontendApplicationContribution, Comm
167
172
  keybinding: 'ctrlcmd+k ctrlcmd+\\',
168
173
  });
169
174
  }
175
+
176
+ registerMenus(registry: MenuModelRegistry): void {
177
+ registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
178
+ commandId: EditorCommands.SPLIT_EDITOR_UP.id,
179
+ label: nls.localizeByDefault('Split Up'),
180
+ order: '1',
181
+ });
182
+ registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
183
+ commandId: EditorCommands.SPLIT_EDITOR_DOWN.id,
184
+ label: nls.localizeByDefault('Split Down'),
185
+ order: '2',
186
+ });
187
+ registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
188
+ commandId: EditorCommands.SPLIT_EDITOR_LEFT.id,
189
+ label: nls.localizeByDefault('Split Left'),
190
+ order: '3',
191
+ });
192
+ registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
193
+ commandId: EditorCommands.SPLIT_EDITOR_RIGHT.id,
194
+ label: nls.localizeByDefault('Split Right'),
195
+ order: '4',
196
+ });
197
+ }
170
198
  }
@@ -69,7 +69,7 @@ export default new ContainerModule(bind => {
69
69
 
70
70
  bind(VariableContribution).to(EditorVariableContribution).inSingletonScope();
71
71
 
72
- [CommandContribution, KeybindingContribution].forEach(serviceIdentifier => {
72
+ [CommandContribution, KeybindingContribution, MenuContribution].forEach(serviceIdentifier => {
73
73
  bind(serviceIdentifier).toService(EditorContribution);
74
74
  });
75
75
  bind(QuickEditorService).toSelf().inSingletonScope();
@@ -19,9 +19,8 @@ import URI from '@theia/core/lib/common/uri';
19
19
  import { RecursivePartial, Emitter, Event, MaybePromise } from '@theia/core/lib/common';
20
20
  import { WidgetOpenerOptions, NavigatableWidgetOpenHandler, NavigatableWidgetOptions, Widget } from '@theia/core/lib/browser';
21
21
  import { EditorWidget } from './editor-widget';
22
- import { Range, Position, Location } from './editor';
22
+ import { Range, Position, Location, TextEditor } from './editor';
23
23
  import { EditorWidgetFactory } from './editor-widget-factory';
24
- import { TextEditor } from './editor';
25
24
 
26
25
  export interface WidgetId {
27
26
  id: number;
@@ -18,6 +18,7 @@ import { injectable } from '@theia/core/shared/inversify';
18
18
  import { MenuContribution, MenuModelRegistry, MenuPath, MAIN_MENU_BAR } from '@theia/core';
19
19
  import { CommonCommands, CommonMenus } from '@theia/core/lib/browser';
20
20
  import { EditorCommands } from './editor-command';
21
+ import { nls } from '@theia/core/lib/common/nls';
21
22
 
22
23
  export const EDITOR_CONTEXT_MENU: MenuPath = ['editor_context_menu'];
23
24
 
@@ -41,10 +42,24 @@ export namespace EditorMainMenu {
41
42
  export const GO = [...MAIN_MENU_BAR, '5_go'];
42
43
 
43
44
  /**
44
- * Navigation menu group in the `Go` menu.
45
+ * Navigation menu group in the `Go` main-menu.
45
46
  */
46
47
  export const NAVIGATION_GROUP = [...GO, '1_navigation_group'];
47
48
 
49
+ /**
50
+ * Workspace menu group in the `Go` main-menu.
51
+ */
52
+ export const WORKSPACE_GROUP = [...GO, '2_workspace_group'];
53
+
54
+ /**
55
+ * Language features menu group in the `Go` main-menu.
56
+ */
57
+ export const LANGUAGE_FEATURES_GROUP = [...GO, '3_language_features_group'];
58
+
59
+ /**
60
+ * Location menu group in the `Go` main-menu.
61
+ */
62
+ export const LOCATION_GROUP = [...GO, '4_locations'];
48
63
  }
49
64
 
50
65
  @injectable()
@@ -72,18 +87,26 @@ export class EditorMenuContribution implements MenuContribution {
72
87
  });
73
88
 
74
89
  // Editor navigation. Go > Back and Go > Forward.
75
- registry.registerSubmenu(EditorMainMenu.GO, 'Go');
90
+ registry.registerSubmenu(EditorMainMenu.GO, nls.localizeByDefault('Go'));
76
91
  registry.registerMenuAction(EditorMainMenu.NAVIGATION_GROUP, {
77
92
  commandId: EditorCommands.GO_BACK.id,
78
- label: 'Back'
93
+ label: EditorCommands.GO_BACK.label,
94
+ order: '1'
79
95
  });
80
96
  registry.registerMenuAction(EditorMainMenu.NAVIGATION_GROUP, {
81
97
  commandId: EditorCommands.GO_FORWARD.id,
82
- label: 'Forward'
98
+ label: EditorCommands.GO_FORWARD.label,
99
+ order: '2'
83
100
  });
84
101
  registry.registerMenuAction(EditorMainMenu.NAVIGATION_GROUP, {
85
102
  commandId: EditorCommands.GO_LAST_EDIT.id,
86
- label: 'Last Edit Location'
103
+ label: nls.localizeByDefault('Last Edit Location'),
104
+ order: '3'
105
+ });
106
+
107
+ registry.registerMenuAction(EditorMainMenu.LOCATION_GROUP, {
108
+ commandId: EditorCommands.GOTO_LINE_COLUMN.id,
109
+ order: '1'
87
110
  });
88
111
 
89
112
  // Toggle Commands.
@@ -94,14 +117,19 @@ export class EditorMenuContribution implements MenuContribution {
94
117
  });
95
118
  registry.registerMenuAction(CommonMenus.VIEW_TOGGLE, {
96
119
  commandId: EditorCommands.TOGGLE_MINIMAP.id,
97
- label: 'Show Minimap',
120
+ label: EditorCommands.TOGGLE_MINIMAP.label,
98
121
  order: '1',
99
122
  });
100
123
  registry.registerMenuAction(CommonMenus.VIEW_TOGGLE, {
101
124
  commandId: EditorCommands.TOGGLE_RENDER_WHITESPACE.id,
102
- label: 'Render Whitespace',
125
+ label: EditorCommands.TOGGLE_RENDER_WHITESPACE.label,
103
126
  order: '2'
104
127
  });
128
+ registry.registerMenuAction(CommonMenus.FILE_CLOSE, {
129
+ commandId: CommonCommands.CLOSE_MAIN_TAB.id,
130
+ label: nls.localizeByDefault('Close Editor'),
131
+ order: '1'
132
+ });
105
133
  }
106
134
 
107
135
  }