mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-23 12:36:33 +00:00
ATL-812: Enhanced the Help
menu.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
e33af0d78a
commit
1742c53015
@ -309,7 +309,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
|
||||
label: 'Optimize for Debugging',
|
||||
order: '1'
|
||||
});
|
||||
registry.registerMenuAction(CommonMenus.HELP, {
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__CONTROL_GROUP, {
|
||||
commandId: ArduinoCommands.TOGGLE_ADVANCED_MODE.id,
|
||||
label: 'Advanced Mode'
|
||||
});
|
||||
|
@ -135,6 +135,7 @@ import { DebugFrontendApplicationContribution } from './theia/debug/debug-fronte
|
||||
import { DebugFrontendApplicationContribution as TheiaDebugFrontendApplicationContribution } from '@theia/debug/lib/browser/debug-frontend-application-contribution';
|
||||
import { BoardSelection } from './contributions/board-selection';
|
||||
import { OpenRecentSketch } from './contributions/open-recent-sketch';
|
||||
import { Help } from './contributions/help';
|
||||
|
||||
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
||||
|
||||
@ -339,6 +340,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||
Contribution.configure(bind, Sketchbook);
|
||||
Contribution.configure(bind, BoardSelection);
|
||||
Contribution.configure(bind, OpenRecentSketch);
|
||||
Contribution.configure(bind, Help);
|
||||
|
||||
bind(OutputServiceImpl).toSelf().inSingletonScope().onActivation(({ container }, outputService) => {
|
||||
WebSocketConnectionProvider.createProxy(container, OutputServicePath, outputService);
|
||||
|
@ -24,10 +24,9 @@ export class About extends Contribution {
|
||||
}
|
||||
|
||||
registerMenus(registry: MenuModelRegistry): void {
|
||||
// On macOS we will get the `Quit ${YOUR_APP_NAME}` menu item natively, no need to duplicate it.
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__ABOUT_GROUP, {
|
||||
commandId: About.Commands.ABOUT_APP.id,
|
||||
label: `About${isOSX ? ` ${this.applicationName}` : ''}`,
|
||||
label: `About ${this.applicationName}`,
|
||||
order: '0'
|
||||
});
|
||||
}
|
||||
|
137
arduino-ide-extension/src/browser/contributions/help.ts
Normal file
137
arduino-ide-extension/src/browser/contributions/help.ts
Normal file
@ -0,0 +1,137 @@
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||
import { CommandHandler } from '@theia/core/lib/common/command';
|
||||
import { QuickInputService } from '@theia/core/lib/browser/quick-open/quick-input-service';
|
||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||
import { Contribution, Command, MenuModelRegistry, CommandRegistry, KeybindingRegistry } from './contribution';
|
||||
|
||||
@injectable()
|
||||
export class Help extends Contribution {
|
||||
|
||||
@inject(EditorManager)
|
||||
protected readonly editorManager: EditorManager;
|
||||
|
||||
@inject(WindowService)
|
||||
protected readonly windowService: WindowService;
|
||||
|
||||
@inject(QuickInputService)
|
||||
protected readonly quickInputService: QuickInputService;
|
||||
|
||||
registerCommands(registry: CommandRegistry): void {
|
||||
const open = (url: string) => this.windowService.openNewWindow(url, { external: true });
|
||||
const createOpenHandler = (url: string) => <CommandHandler>{
|
||||
execute: () => open(url)
|
||||
};
|
||||
registry.registerCommand(Help.Commands.GETTING_STARTED, createOpenHandler('https://www.arduino.cc/en/Guide'));
|
||||
registry.registerCommand(Help.Commands.ENVIRONMENT, createOpenHandler('https://www.arduino.cc/en/Guide/Environment'));
|
||||
registry.registerCommand(Help.Commands.TROUBLESHOOTING, createOpenHandler('https://support.arduino.cc/hc/en-us'));
|
||||
registry.registerCommand(Help.Commands.REFERENCE, createOpenHandler('https://www.arduino.cc/reference/en/'));
|
||||
registry.registerCommand(Help.Commands.FIND_IN_REFERENCE, {
|
||||
execute: async () => {
|
||||
let searchFor: string | undefined = undefined;
|
||||
const { currentEditor } = this.editorManager;
|
||||
if (currentEditor && currentEditor.editor instanceof MonacoEditor) {
|
||||
const codeEditor = currentEditor.editor.getControl();
|
||||
const selection = codeEditor.getSelection();
|
||||
const model = codeEditor.getModel();
|
||||
if (model && selection && !monaco.Range.isEmpty(selection)) {
|
||||
searchFor = model.getValueInRange(selection);
|
||||
}
|
||||
}
|
||||
if (!searchFor) {
|
||||
searchFor = await this.quickInputService.open({
|
||||
prompt: 'Search on Arduino.cc',
|
||||
placeHolder: 'Type a keyword'
|
||||
});
|
||||
}
|
||||
if (searchFor) {
|
||||
return open(`https://www.arduino.cc/search?q=${encodeURIComponent(searchFor)}&tab=reference`);
|
||||
}
|
||||
}
|
||||
});
|
||||
registry.registerCommand(Help.Commands.FAQ, createOpenHandler('https://support.arduino.cc/hc/en-us'));
|
||||
registry.registerCommand(Help.Commands.VISIT_ARDUINO, createOpenHandler('https://www.arduino.cc/'));
|
||||
}
|
||||
|
||||
registerMenus(registry: MenuModelRegistry): void {
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, {
|
||||
commandId: Help.Commands.GETTING_STARTED.id,
|
||||
order: '0'
|
||||
});
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, {
|
||||
commandId: Help.Commands.ENVIRONMENT.id,
|
||||
order: '1'
|
||||
});
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, {
|
||||
commandId: Help.Commands.TROUBLESHOOTING.id,
|
||||
order: '2'
|
||||
});
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__MAIN_GROUP, {
|
||||
commandId: Help.Commands.REFERENCE.id,
|
||||
order: '3'
|
||||
});
|
||||
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
|
||||
commandId: Help.Commands.FIND_IN_REFERENCE.id,
|
||||
order: '4'
|
||||
});
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
|
||||
commandId: Help.Commands.FAQ.id,
|
||||
order: '5'
|
||||
});
|
||||
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
|
||||
commandId: Help.Commands.VISIT_ARDUINO.id,
|
||||
order: '6'
|
||||
});
|
||||
}
|
||||
|
||||
registerKeybindings(registry: KeybindingRegistry): void {
|
||||
registry.registerKeybinding({
|
||||
command: Help.Commands.FIND_IN_REFERENCE.id,
|
||||
keybinding: 'CtrlCmd+Shift+F'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace Help {
|
||||
export namespace Commands {
|
||||
export const GETTING_STARTED: Command = {
|
||||
id: 'arduino-getting-started',
|
||||
label: 'Getting Started',
|
||||
category: 'Arduino'
|
||||
};
|
||||
export const ENVIRONMENT: Command = {
|
||||
id: 'arduino-environment',
|
||||
label: 'Environment',
|
||||
category: 'Arduino'
|
||||
};
|
||||
export const TROUBLESHOOTING: Command = {
|
||||
id: 'arduino-troubleshooting',
|
||||
label: 'Troubleshooting',
|
||||
category: 'Arduino'
|
||||
};
|
||||
export const REFERENCE: Command = {
|
||||
id: 'arduino-reference',
|
||||
label: 'Reference',
|
||||
category: 'Arduino'
|
||||
};
|
||||
export const FIND_IN_REFERENCE: Command = {
|
||||
id: 'arduino-find-in-reference',
|
||||
label: 'Find in Reference',
|
||||
category: 'Arduino'
|
||||
};
|
||||
export const FAQ: Command = {
|
||||
id: 'arduino-faq',
|
||||
label: 'Frequently Asked Questions',
|
||||
category: 'Arduino'
|
||||
};
|
||||
export const VISIT_ARDUINO: Command = {
|
||||
id: 'arduino-visit-arduino',
|
||||
label: 'Visit Arduino.cc',
|
||||
category: 'Arduino'
|
||||
};
|
||||
}
|
||||
}
|
@ -49,6 +49,13 @@ export namespace ArduinoMenus {
|
||||
export const TOOLS__BOARD_SETTINGS_GROUP = [...TOOLS, '3_board_settings'];
|
||||
|
||||
// -- Help
|
||||
// `Getting Started`, `Environment`, `Troubleshooting`, etc.
|
||||
export const HELP__MAIN_GROUP = [...CommonMenus.HELP, '0_main'];
|
||||
// `Find in reference`, `FAQ`, etc.
|
||||
export const HELP__FIND_GROUP = [...CommonMenus.HELP, '1_find'];
|
||||
// `Advanced Mode`.
|
||||
// XXX: this will be removed.
|
||||
export const HELP__CONTROL_GROUP = [...CommonMenus.HELP, '2_control'];
|
||||
// `About` group
|
||||
// XXX: on macOS, the about group is not under `Help`
|
||||
export const HELP__ABOUT_GROUP = [...(isOSX ? MAIN_MENU_BAR : CommonMenus.HELP), '999_about'];
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { inject, injectable } from 'inversify';
|
||||
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
|
||||
import { KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
|
||||
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||
import { SearchInWorkspaceFrontendContribution as TheiaSearchInWorkspaceFrontendContribution, SearchInWorkspaceCommands } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
|
||||
import { EditorMode } from '../../editor-mode';
|
||||
import { MenuModelRegistry } from '@theia/core';
|
||||
|
||||
@injectable()
|
||||
export class SearchInWorkspaceFrontendContribution extends TheiaSearchInWorkspaceFrontendContribution {
|
||||
@ -21,4 +22,9 @@ export class SearchInWorkspaceFrontendContribution extends TheiaSearchInWorkspac
|
||||
registry.unregisterMenuAction(SearchInWorkspaceCommands.OPEN_SIW_WIDGET);
|
||||
}
|
||||
|
||||
registerKeybindings(keybindings: KeybindingRegistry): void {
|
||||
super.registerKeybindings(keybindings);
|
||||
keybindings.unregisterKeybinding(SearchInWorkspaceCommands.OPEN_SIW_WIDGET);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user