@eclipse-glsp/client 1.1.0-next.0e4a7fc.263 → 1.1.0-next.14c7209.265

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 (46) hide show
  1. package/css/key-shortcut.css +107 -0
  2. package/lib/features/accessibility/accessibility-module.d.ts.map +1 -1
  3. package/lib/features/accessibility/accessibility-module.js +2 -0
  4. package/lib/features/accessibility/accessibility-module.js.map +1 -1
  5. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts +31 -0
  6. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts.map +1 -0
  7. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js +72 -0
  8. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js.map +1 -0
  9. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts +53 -0
  10. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts.map +1 -0
  11. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js +149 -0
  12. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js.map +1 -0
  13. package/lib/features/accessibility/key-shortcut/di.config.d.ts +24 -0
  14. package/lib/features/accessibility/key-shortcut/di.config.d.ts.map +1 -0
  15. package/lib/features/accessibility/key-shortcut/di.config.js +37 -0
  16. package/lib/features/accessibility/key-shortcut/di.config.js.map +1 -0
  17. package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts +6 -1
  18. package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts.map +1 -1
  19. package/lib/features/accessibility/resize-key-tool/resize-key-tool.js +26 -3
  20. package/lib/features/accessibility/resize-key-tool/resize-key-tool.js.map +1 -1
  21. package/lib/features/accessibility/search/search-tool.d.ts +8 -1
  22. package/lib/features/accessibility/search/search-tool.d.ts.map +1 -1
  23. package/lib/features/accessibility/search/search-tool.js +23 -1
  24. package/lib/features/accessibility/search/search-tool.js.map +1 -1
  25. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +7 -2
  26. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
  27. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +19 -1
  28. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
  29. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts +4 -0
  30. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts.map +1 -1
  31. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js +23 -0
  32. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js.map +1 -1
  33. package/lib/index.d.ts +1 -0
  34. package/lib/index.d.ts.map +1 -1
  35. package/lib/index.js +1 -0
  36. package/lib/index.js.map +1 -1
  37. package/package.json +3 -3
  38. package/src/features/accessibility/accessibility-module.ts +2 -0
  39. package/src/features/accessibility/key-shortcut/accessible-key-shortcut-tool.ts +55 -0
  40. package/src/features/accessibility/key-shortcut/accessible-key-shortcut.ts +182 -0
  41. package/src/features/accessibility/key-shortcut/di.config.ts +35 -0
  42. package/src/features/accessibility/resize-key-tool/resize-key-tool.ts +22 -1
  43. package/src/features/accessibility/search/search-tool.ts +24 -5
  44. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +19 -3
  45. package/src/features/accessibility/view-key-tools/zoom-key-tool.ts +22 -1
  46. package/src/index.ts +1 -0
@@ -0,0 +1,182 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { injectable } from 'inversify';
18
+ import { groupBy } from 'lodash';
19
+ import { AbstractUIExtension, Action, IActionHandler, ICommand, matchesKeystroke, SModelRoot } from '~glsp-sprotty';
20
+
21
+ export interface AccessibleKeyShortcutProvider {
22
+ registerShortcutKey(): void;
23
+ }
24
+
25
+ export interface AccessibleKeyShortcut {
26
+ shortcuts: string[];
27
+ description: string;
28
+ group: string;
29
+ position: number;
30
+ }
31
+
32
+ export interface SetAccessibleKeyShortcutAction extends Action {
33
+ kind: typeof SetAccessibleKeyShortcutAction.KIND;
34
+ token: string;
35
+ keys: AccessibleKeyShortcut[];
36
+ }
37
+
38
+ export namespace SetAccessibleKeyShortcutAction {
39
+ export const KIND = 'setAccessibleKeyShortcut';
40
+
41
+ export function is(object: any): object is SetAccessibleKeyShortcutAction {
42
+ return Action.hasKind(object, KIND);
43
+ }
44
+
45
+ export function create(options: { token: string; keys: AccessibleKeyShortcut[] }): SetAccessibleKeyShortcutAction {
46
+ return { kind: KIND, token: options.token, keys: options.keys };
47
+ }
48
+ }
49
+
50
+ @injectable()
51
+ export class KeyShortcutUIExtension extends AbstractUIExtension implements IActionHandler {
52
+ static readonly ID = 'key-shortcut';
53
+ protected container: HTMLDivElement;
54
+ protected shortcutsContainer: HTMLDivElement;
55
+ protected registrations: Record<string, AccessibleKeyShortcut[]> = {};
56
+
57
+ handle(action: Action): ICommand | Action | void {
58
+ if (SetAccessibleKeyShortcutAction.is(action)) {
59
+ this.registrations[action.token] = action.keys;
60
+ if (this.containerElement) {
61
+ this.refreshUI();
62
+ }
63
+ }
64
+ }
65
+ id(): string {
66
+ return KeyShortcutUIExtension.ID;
67
+ }
68
+
69
+ containerClass(): string {
70
+ return KeyShortcutUIExtension.ID;
71
+ }
72
+
73
+ override show(root: Readonly<SModelRoot>, ...contextElementIds: string[]): void {
74
+ super.show(root, ...contextElementIds);
75
+ this.shortcutsContainer.focus();
76
+ }
77
+
78
+ protected refreshUI(): void {
79
+ this.shortcutsContainer.innerHTML = '';
80
+
81
+ const registrations = Object.values(this.registrations).flatMap(r => r);
82
+ registrations.sort((a, b) => {
83
+ if (a.group < b.group) {
84
+ return -1;
85
+ }
86
+ if (a.group > b.group) {
87
+ return 1;
88
+ }
89
+
90
+ return a.position - b.position;
91
+ });
92
+
93
+ const grouped = groupBy(registrations, k => k.group);
94
+
95
+ const groupTable = document.createElement('table');
96
+ const tableHead = document.createElement('thead');
97
+ const tableBody = document.createElement('tbody');
98
+
99
+ const headerRow = document.createElement('tr');
100
+ const commandCell = document.createElement('th');
101
+ const keybindingCell = document.createElement('th');
102
+
103
+ commandCell.classList.add('columnTitle');
104
+ commandCell.classList.add('columnTitle');
105
+
106
+ commandCell.innerText = 'Command';
107
+ keybindingCell.innerText = 'Keybinding';
108
+
109
+ headerRow.appendChild(commandCell);
110
+ headerRow.appendChild(keybindingCell);
111
+ tableHead.appendChild(headerRow);
112
+
113
+ for (const [, shortcuts] of Object.entries(grouped)) {
114
+ shortcuts.forEach(s => {
115
+ tableBody.appendChild(this.createEntry(s));
116
+ });
117
+ }
118
+
119
+ groupTable.appendChild(tableHead);
120
+ groupTable.appendChild(tableBody);
121
+
122
+ this.shortcutsContainer.append(groupTable);
123
+ }
124
+
125
+ protected getShortcutHTML(shortcuts: string[]): HTMLElement {
126
+ const shortcutKeys = document.createElement('span');
127
+ shortcutKeys.innerHTML = shortcuts.map(key => `<kbd>${key}</kbd>`).join(' + ');
128
+
129
+ return shortcutKeys;
130
+ }
131
+
132
+ protected createEntry(registration: AccessibleKeyShortcut): HTMLDivElement {
133
+ const entryRow = document.createElement('tr');
134
+ const shortcutElement = document.createElement('td');
135
+ const descElement = document.createElement('td');
136
+
137
+ const shortcut = this.getShortcutHTML(registration.shortcuts);
138
+ descElement.innerText = registration.description;
139
+
140
+ shortcutElement.appendChild(shortcut);
141
+ entryRow.appendChild(descElement);
142
+ entryRow.appendChild(shortcutElement);
143
+
144
+ return entryRow;
145
+ }
146
+
147
+ protected initializeContents(containerElement: HTMLElement): void {
148
+ this.container = document.createElement('div');
149
+ this.container.classList.add('keyboard-shortcuts-menu');
150
+
151
+ // create title
152
+ const menuTitle = document.createElement('h3');
153
+ menuTitle.classList.add('menu-header');
154
+ menuTitle.innerText = 'Keyboard Shortcuts';
155
+ this.container.appendChild(menuTitle);
156
+
157
+ const closeBtn = document.createElement('button');
158
+ closeBtn.id = 'key-shortcut-close-btn';
159
+ closeBtn.textContent = 'x';
160
+ closeBtn.addEventListener('click', () => {
161
+ this.hide();
162
+ });
163
+
164
+ this.container.appendChild(closeBtn);
165
+
166
+ // create shortcuts container
167
+ this.shortcutsContainer = document.createElement('div');
168
+ this.shortcutsContainer.classList.add('keyboard-shortcuts-container');
169
+ this.shortcutsContainer.tabIndex = 30;
170
+ this.shortcutsContainer.addEventListener('keydown', (event: KeyboardEvent) => {
171
+ if (event.key === 'Escape' || matchesKeystroke(event, 'KeyH', 'alt')) {
172
+ this.hide();
173
+ }
174
+ });
175
+
176
+ this.container.appendChild(this.shortcutsContainer);
177
+ containerElement.appendChild(this.container);
178
+ containerElement.ariaLabel = 'Shortcut-Menu';
179
+
180
+ this.refreshUI();
181
+ }
182
+ }
@@ -0,0 +1,35 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 Business Informatics Group (TU Wien) and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { ContainerModule } from 'inversify';
18
+ import { bindAsService, BindingContext, configureActionHandler, TYPES } from '~glsp-sprotty';
19
+ import '../../../../css/key-shortcut.css';
20
+ import { KeyShortcutUIExtension, SetAccessibleKeyShortcutAction } from './accessible-key-shortcut';
21
+ import { AccessibleKeyShortcutTool } from './accessible-key-shortcut-tool';
22
+
23
+ /**
24
+ * Handles actions for displaying help/information about keyboard shortcuts.
25
+ */
26
+ export const glspShortcutHelpModule = new ContainerModule((bind, unbind, isBound, rebind) => {
27
+ const context = { bind, unbind, isBound, rebind };
28
+ configureShortcutHelpTool(context);
29
+ });
30
+
31
+ export function configureShortcutHelpTool(context: BindingContext): void {
32
+ bindAsService(context, TYPES.IDefaultTool, AccessibleKeyShortcutTool);
33
+ bindAsService(context, TYPES.IUIExtension, KeyShortcutUIExtension);
34
+ configureActionHandler(context, SetAccessibleKeyShortcutAction.KIND, KeyShortcutUIExtension);
35
+ }
@@ -17,9 +17,11 @@
17
17
  import { inject, injectable, optional } from 'inversify';
18
18
  import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
19
19
  import { Action, EnableDefaultToolsAction, EnableToolsAction, ISnapper, KeyListener, KeyTool, SModelElement, TYPES } from '~glsp-sprotty';
20
+ import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
20
21
  import { SelectionService } from '../../../base/selection-service';
21
22
  import { GLSPTool } from '../../../base/tool-manager/glsp-tool-manager';
22
23
  import { IMovementRestrictor } from '../../change-bounds/movement-restrictor';
24
+ import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
23
25
  import { ResizeElementAction, ResizeType } from './resize-key-handler';
24
26
 
25
27
  @injectable()
@@ -31,6 +33,7 @@ export class ResizeKeyTool implements GLSPTool {
31
33
  @inject(KeyTool) protected readonly keytool: KeyTool;
32
34
  @inject(TYPES.IMovementRestrictor) @optional() readonly movementRestrictor?: IMovementRestrictor;
33
35
  @inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
36
+ @inject(TYPES.IActionDispatcher) readonly actionDispatcher: GLSPActionDispatcher;
34
37
  @inject(SelectionService) readonly selectionService: SelectionService;
35
38
 
36
39
  protected resizeKeyListener: ResizeKeyListener = new ResizeKeyListener(this);
@@ -41,6 +44,7 @@ export class ResizeKeyTool implements GLSPTool {
41
44
 
42
45
  enable(): void {
43
46
  this.keytool.register(this.resizeKeyListener);
47
+ this.resizeKeyListener.registerShortcutKey();
44
48
  }
45
49
 
46
50
  disable(): void {
@@ -48,13 +52,30 @@ export class ResizeKeyTool implements GLSPTool {
48
52
  }
49
53
  }
50
54
  @injectable()
51
- export class ResizeKeyListener extends KeyListener {
55
+ export class ResizeKeyListener extends KeyListener implements AccessibleKeyShortcutProvider {
52
56
  protected isEditMode = false;
57
+ protected readonly token = ResizeKeyListener.name;
53
58
 
54
59
  constructor(protected readonly tool: ResizeKeyTool) {
55
60
  super();
56
61
  }
57
62
 
63
+ registerShortcutKey(): void {
64
+ this.tool.actionDispatcher.onceModelInitialized().then(() => {
65
+ this.tool.actionDispatcher.dispatchAll([
66
+ SetAccessibleKeyShortcutAction.create({
67
+ token: this.token,
68
+ keys: [
69
+ { shortcuts: ['ALT', 'A'], description: 'Activate resize mode for selected element', group: 'Resize', position: 0 },
70
+ { shortcuts: ['+'], description: 'Increase size of element', group: 'Resize', position: 1 },
71
+ { shortcuts: ['-'], description: 'Increase size of element', group: 'Resize', position: 2 },
72
+ { shortcuts: ['CTRL', '0'], description: 'Set element size to default', group: 'Resize', position: 3 }
73
+ ]
74
+ })
75
+ ]);
76
+ });
77
+ }
78
+
58
79
  override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
59
80
  const actions = [];
60
81
  const selectedElementsIds = this.tool.selectionService.getSelectedElementIDs();
@@ -16,15 +16,16 @@
16
16
 
17
17
  import { inject, injectable } from 'inversify';
18
18
  import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
19
- import { Action, KeyListener, KeyTool, SModelElement, SetUIExtensionVisibilityAction, Tool } from '~glsp-sprotty';
19
+ import { Action, KeyListener, KeyTool, SetUIExtensionVisibilityAction, SModelElement, Tool, TYPES } from '~glsp-sprotty';
20
+ import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
21
+ import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
20
22
  import { SearchAutocompletePalette } from './search-palette';
21
-
22
23
  @injectable()
23
24
  export class SearchAutocompletePaletteTool implements Tool {
24
25
  static readonly ID = 'glsp.search-autocomplete-palette-tool';
25
26
 
26
- protected readonly keyListener = new SearchAutocompletePaletteKeyListener();
27
-
27
+ protected readonly keyListener = new SearchAutocompletePaletteKeyListener(this);
28
+ @inject(TYPES.IActionDispatcher) readonly actionDispatcher: GLSPActionDispatcher;
28
29
  @inject(KeyTool) protected keyTool: KeyTool;
29
30
 
30
31
  get id(): string {
@@ -33,6 +34,7 @@ export class SearchAutocompletePaletteTool implements Tool {
33
34
 
34
35
  enable(): void {
35
36
  this.keyTool.register(this.keyListener);
37
+ this.keyListener.registerShortcutKey();
36
38
  }
37
39
 
38
40
  disable(): void {
@@ -40,7 +42,24 @@ export class SearchAutocompletePaletteTool implements Tool {
40
42
  }
41
43
  }
42
44
 
43
- export class SearchAutocompletePaletteKeyListener extends KeyListener {
45
+ export class SearchAutocompletePaletteKeyListener extends KeyListener implements AccessibleKeyShortcutProvider {
46
+ protected readonly token = SearchAutocompletePalette.name;
47
+
48
+ constructor(protected tool: SearchAutocompletePaletteTool) {
49
+ super();
50
+ }
51
+
52
+ registerShortcutKey(): void {
53
+ this.tool.actionDispatcher.onceModelInitialized().then(() => {
54
+ this.tool.actionDispatcher.dispatchAll([
55
+ SetAccessibleKeyShortcutAction.create({
56
+ token: this.token,
57
+ keys: [{ shortcuts: ['CTRL', 'F'], description: 'Activate search for elements', group: 'Search', position: 0 }]
58
+ })
59
+ ]);
60
+ });
61
+ }
62
+
44
63
  override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
45
64
  if (this.matchesSearchActivateKeystroke(event)) {
46
65
  return [
@@ -17,10 +17,11 @@
17
17
  import { inject, injectable, optional } from 'inversify';
18
18
  import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
19
19
  import { Action, ISnapper, KeyListener, KeyTool, SModelElement, TYPES } from '~glsp-sprotty';
20
+ import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
21
+ import { SelectionService } from '../../../base/selection-service';
20
22
  import { GLSPTool } from '../../../base/tool-manager/glsp-tool-manager';
21
23
  import { GridSnapper } from '../../change-bounds/snap';
22
-
23
- import { SelectionService } from '../../../base/selection-service';
24
+ import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
24
25
  import { MoveElementAction, MoveViewportAction } from '../move-zoom/move-handler';
25
26
 
26
27
  /**
@@ -37,6 +38,7 @@ export class MovementKeyTool implements GLSPTool {
37
38
  @inject(KeyTool) protected readonly keytool: KeyTool;
38
39
  @inject(SelectionService) selectionService: SelectionService;
39
40
  @inject(TYPES.ISnapper) @optional() readonly snapper?: ISnapper;
41
+ @inject(TYPES.IActionDispatcher) readonly actionDispatcher: GLSPActionDispatcher;
40
42
 
41
43
  get id(): string {
42
44
  return MovementKeyTool.ID;
@@ -44,6 +46,7 @@ export class MovementKeyTool implements GLSPTool {
44
46
 
45
47
  enable(): void {
46
48
  this.keytool.register(this.movementKeyListener);
49
+ this.movementKeyListener.registerShortcutKey();
47
50
  }
48
51
 
49
52
  disable(): void {
@@ -51,13 +54,15 @@ export class MovementKeyTool implements GLSPTool {
51
54
  }
52
55
  }
53
56
 
54
- export class MoveKeyListener extends KeyListener {
57
+ export class MoveKeyListener extends KeyListener implements AccessibleKeyShortcutProvider {
55
58
  // Default x distance used if GridSnapper is not provided
56
59
  static readonly defaultMoveX = 20;
57
60
 
58
61
  // Default y distance used if GridSnapper is not provided
59
62
  static readonly defaultMoveY = 20;
60
63
 
64
+ protected readonly token = MoveKeyListener.name;
65
+
61
66
  protected grid = { x: MoveKeyListener.defaultMoveX, y: MoveKeyListener.defaultMoveY };
62
67
 
63
68
  constructor(protected readonly tool: MovementKeyTool) {
@@ -68,6 +73,17 @@ export class MoveKeyListener extends KeyListener {
68
73
  }
69
74
  }
70
75
 
76
+ registerShortcutKey(): void {
77
+ this.tool.actionDispatcher.onceModelInitialized().then(() => {
78
+ this.tool.actionDispatcher.dispatchAll([
79
+ SetAccessibleKeyShortcutAction.create({
80
+ token: this.token,
81
+ keys: [{ shortcuts: ['⬅ ⬆ ➡ ⬇'], description: 'Move element or viewport', group: 'Move', position: 0 }]
82
+ })
83
+ ]);
84
+ });
85
+ }
86
+
71
87
  override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
72
88
  const selectedElementIds = this.tool.selectionService.getSelectedElementIDs();
73
89
 
@@ -16,9 +16,11 @@
16
16
 
17
17
  import { inject, injectable } from 'inversify';
18
18
  import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
19
- import { Action, CenterAction, KeyListener, KeyTool, SModelElement } from '~glsp-sprotty';
19
+ import { Action, CenterAction, KeyListener, KeyTool, SModelElement, TYPES } from '~glsp-sprotty';
20
+ import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
20
21
  import { SelectionService } from '../../../base/selection-service';
21
22
  import { GLSPTool } from '../../../base/tool-manager/glsp-tool-manager';
23
+ import { SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
22
24
  import { ZoomElementAction, ZoomViewportAction } from '../move-zoom/zoom-handler';
23
25
 
24
26
  /**
@@ -33,6 +35,7 @@ export class ZoomKeyTool implements GLSPTool {
33
35
  protected readonly zoomKeyListener = new ZoomKeyListener(this);
34
36
 
35
37
  @inject(KeyTool) protected readonly keytool: KeyTool;
38
+ @inject(TYPES.IActionDispatcher) readonly actionDispatcher: GLSPActionDispatcher;
36
39
  @inject(SelectionService) selectionService: SelectionService;
37
40
 
38
41
  get id(): string {
@@ -41,6 +44,7 @@ export class ZoomKeyTool implements GLSPTool {
41
44
 
42
45
  enable(): void {
43
46
  this.keytool.register(this.zoomKeyListener);
47
+ this.zoomKeyListener.registerShortcutKey();
44
48
  }
45
49
 
46
50
  disable(): void {
@@ -51,11 +55,28 @@ export class ZoomKeyTool implements GLSPTool {
51
55
  export class ZoomKeyListener extends KeyListener {
52
56
  static readonly defaultZoomInFactor = 1.1;
53
57
  static readonly defaultZoomOutFactor = 0.9;
58
+ protected readonly token = ZoomKeyListener.name;
54
59
 
55
60
  constructor(protected tool: ZoomKeyTool) {
56
61
  super();
57
62
  }
58
63
 
64
+ registerShortcutKey(): void {
65
+ this.tool.actionDispatcher.onceModelInitialized().then(() => {
66
+ this.tool.actionDispatcher.dispatchAll([
67
+ SetAccessibleKeyShortcutAction.create({
68
+ token: this.token,
69
+ keys: [
70
+ { shortcuts: ['+'], description: 'Zoom in to element or viewport', group: 'Zoom', position: 0 },
71
+ { shortcuts: ['-'], description: 'Zoom out to element or viewport', group: 'Zoom', position: 1 },
72
+ { shortcuts: ['CTRL', '0'], description: 'Reset zoom to default', group: 'Zoom', position: 2 },
73
+ { shortcuts: ['CTRL', '+'], description: 'Zoom in via Grid', group: 'Zoom', position: 3 }
74
+ ]
75
+ })
76
+ ]);
77
+ });
78
+ }
79
+
59
80
  override keyDown(element: SModelElement, event: KeyboardEvent): Action[] {
60
81
  const selectedElementIds = this.tool.selectionService.getSelectedElementIDs();
61
82
 
package/src/index.ts CHANGED
@@ -46,6 +46,7 @@ export * from './features/accessibility/resize-key-tool/resize-key-tool';
46
46
  export * from './features/accessibility/view-key-tools/deselect-key-tool';
47
47
  export * from './features/accessibility/view-key-tools/movement-key-tool';
48
48
  export * from './features/accessibility/view-key-tools/zoom-key-tool';
49
+ export * from './features/accessibility/key-shortcut/accessible-key-shortcut-tool';
49
50
  export * from './features/bounds/freeform-layout';
50
51
  export * from './features/bounds/glsp-hidden-bounds-updater';
51
52
  export * from './features/bounds/hbox-layout';