@theia/core 1.52.0 → 1.53.0-next.5

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.
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DomInputUndoRedoHandler = exports.UndoRedoHandlerService = exports.UndoRedoHandler = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const inversify_1 = require("inversify");
21
+ const common_1 = require("../common");
22
+ exports.UndoRedoHandler = Symbol('UndoRedoHandler');
23
+ let UndoRedoHandlerService = class UndoRedoHandlerService {
24
+ init() {
25
+ this.handlers = this.provider.getContributions().sort((a, b) => b.priority - a.priority);
26
+ }
27
+ undo() {
28
+ for (const handler of this.handlers) {
29
+ const selection = handler.select();
30
+ if (selection) {
31
+ handler.undo(selection);
32
+ return;
33
+ }
34
+ }
35
+ }
36
+ redo() {
37
+ for (const handler of this.handlers) {
38
+ const selection = handler.select();
39
+ if (selection) {
40
+ handler.redo(selection);
41
+ return;
42
+ }
43
+ }
44
+ }
45
+ };
46
+ exports.UndoRedoHandlerService = UndoRedoHandlerService;
47
+ tslib_1.__decorate([
48
+ (0, inversify_1.inject)(common_1.ContributionProvider),
49
+ (0, inversify_1.named)(exports.UndoRedoHandler),
50
+ tslib_1.__metadata("design:type", Object)
51
+ ], UndoRedoHandlerService.prototype, "provider", void 0);
52
+ tslib_1.__decorate([
53
+ (0, inversify_1.postConstruct)(),
54
+ tslib_1.__metadata("design:type", Function),
55
+ tslib_1.__metadata("design:paramtypes", []),
56
+ tslib_1.__metadata("design:returntype", void 0)
57
+ ], UndoRedoHandlerService.prototype, "init", null);
58
+ exports.UndoRedoHandlerService = UndoRedoHandlerService = tslib_1.__decorate([
59
+ (0, inversify_1.injectable)()
60
+ ], UndoRedoHandlerService);
61
+ let DomInputUndoRedoHandler = class DomInputUndoRedoHandler {
62
+ constructor() {
63
+ this.priority = 1000;
64
+ }
65
+ select() {
66
+ const element = document.activeElement;
67
+ if (element && ['input', 'textarea'].includes(element.tagName.toLowerCase())) {
68
+ return element;
69
+ }
70
+ return undefined;
71
+ }
72
+ undo(item) {
73
+ document.execCommand('undo');
74
+ }
75
+ redo(item) {
76
+ document.execCommand('redo');
77
+ }
78
+ };
79
+ exports.DomInputUndoRedoHandler = DomInputUndoRedoHandler;
80
+ exports.DomInputUndoRedoHandler = DomInputUndoRedoHandler = tslib_1.__decorate([
81
+ (0, inversify_1.injectable)()
82
+ ], DomInputUndoRedoHandler);
83
+ //# sourceMappingURL=undo-redo-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undo-redo-handler.js","sourceRoot":"","sources":["../../src/browser/undo-redo-handler.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,yCAAqE;AACrE,sCAAiD;AAEpC,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAUlD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAQrB,IAAI;QACV,IAAI,CAAC,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QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,IAAa;QACd,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,IAAa;QACd,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CAEJ,CAAA;AApBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAoBnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/core",
3
- "version": "1.52.0",
3
+ "version": "1.53.0-next.5+1e5fb536d",
4
4
  "description": "Theia is a cloud & desktop IDE framework implemented in TypeScript.",
5
5
  "main": "lib/common/index.js",
6
6
  "typings": "lib/common/index.d.ts",
@@ -16,8 +16,8 @@
16
16
  "@phosphor/signaling": "1",
17
17
  "@phosphor/virtualdom": "1",
18
18
  "@phosphor/widgets": "1",
19
- "@theia/application-package": "1.52.0",
20
- "@theia/request": "1.52.0",
19
+ "@theia/application-package": "1.53.0-next.5+1e5fb536d",
20
+ "@theia/request": "1.53.0-next.5+1e5fb536d",
21
21
  "@types/body-parser": "^1.16.4",
22
22
  "@types/cookie": "^0.3.3",
23
23
  "@types/dompurify": "^2.2.2",
@@ -216,5 +216,5 @@
216
216
  "nyc": {
217
217
  "extends": "../../configs/nyc.json"
218
218
  },
219
- "gitHead": "40ceebcd4ee75f13ec16b9dc7314e9384493c1ac"
219
+ "gitHead": "1e5fb536d65550ad8fa0fefcec731645b2afc74a"
220
220
  }
@@ -18,7 +18,7 @@
18
18
  * Licensed under the MIT License. See License.txt in the project root for license information.
19
19
  *--------------------------------------------------------------------------------------------*/
20
20
 
21
- import { environment } from '../common';
21
+ import { Disposable, environment } from '../common';
22
22
 
23
23
  const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : '';
24
24
 
@@ -228,3 +228,12 @@ function getMeasurementElement(style?: PartialCSSStyle): HTMLElement {
228
228
  }
229
229
  return measureElement;
230
230
  }
231
+
232
+ export function onDomEvent<K extends keyof HTMLElementEventMap>(
233
+ element: Node,
234
+ type: K,
235
+ listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown,
236
+ options?: boolean | AddEventListenerOptions): Disposable {
237
+ element.addEventListener(type, listener, options);
238
+ return { dispose: () => element.removeEventListener(type, listener, options) };
239
+ }
@@ -67,6 +67,7 @@ import { UserWorkingDirectoryProvider } from './user-working-directory-provider'
67
67
  import { UNTITLED_SCHEME, UntitledResourceResolver } from '../common';
68
68
  import { LanguageQuickPickService } from './i18n/language-quick-pick-service';
69
69
  import { SidebarMenu } from './shell/sidebar-menu-widget';
70
+ import { UndoRedoHandlerService } from './undo-redo-handler';
70
71
 
71
72
  export namespace CommonMenus {
72
73
 
@@ -443,7 +444,11 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
443
444
  @inject(UntitledResourceResolver)
444
445
  protected readonly untitledResourceResolver: UntitledResourceResolver;
445
446
 
447
+ @inject(UndoRedoHandlerService)
448
+ protected readonly undoRedoHandlerService: UndoRedoHandlerService;
449
+
446
450
  protected pinnedKey: ContextKey<boolean>;
451
+ protected inputFocus: ContextKey<boolean>;
447
452
 
448
453
  async configure(app: FrontendApplication): Promise<void> {
449
454
  // FIXME: This request blocks valuable startup time (~200ms).
@@ -458,6 +463,9 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
458
463
  this.contextKeyService.createKey<boolean>('isMac', OS.type() === OS.Type.OSX);
459
464
  this.contextKeyService.createKey<boolean>('isWindows', OS.type() === OS.Type.Windows);
460
465
  this.contextKeyService.createKey<boolean>('isWeb', !this.isElectron());
466
+ this.inputFocus = this.contextKeyService.createKey<boolean>('inputFocus', false);
467
+ this.updateInputFocus();
468
+ browser.onDomEvent(document, 'focusin', () => this.updateInputFocus());
461
469
 
462
470
  this.pinnedKey = this.contextKeyService.createKey<boolean>('activeEditorIsPinned', false);
463
471
  this.updatePinnedKey();
@@ -513,6 +521,15 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
513
521
  }
514
522
  }
515
523
 
524
+ protected updateInputFocus(): void {
525
+ const activeElement = document.activeElement;
526
+ if (activeElement) {
527
+ const isInput = activeElement.tagName?.toLowerCase() === 'input'
528
+ || activeElement.tagName?.toLowerCase() === 'textarea';
529
+ this.inputFocus.set(isInput);
530
+ }
531
+ }
532
+
516
533
  protected updatePinnedKey(): void {
517
534
  const activeTab = this.shell.findTabBar();
518
535
  const pinningTarget = activeTab && this.shell.findTitle(activeTab);
@@ -801,10 +818,14 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
801
818
  }));
802
819
 
803
820
  commandRegistry.registerCommand(CommonCommands.UNDO, {
804
- execute: () => document.execCommand('undo')
821
+ execute: () => {
822
+ this.undoRedoHandlerService.undo();
823
+ }
805
824
  });
806
825
  commandRegistry.registerCommand(CommonCommands.REDO, {
807
- execute: () => document.execCommand('redo')
826
+ execute: () => {
827
+ this.undoRedoHandlerService.redo();
828
+ }
808
829
  });
809
830
  commandRegistry.registerCommand(CommonCommands.SELECT_ALL, {
810
831
  execute: () => document.execCommand('selectAll')
@@ -1067,7 +1088,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
1067
1088
  },
1068
1089
  {
1069
1090
  command: CommonCommands.REDO.id,
1070
- keybinding: 'ctrlcmd+shift+z'
1091
+ keybinding: isOSX ? 'ctrlcmd+shift+z' : 'ctrlcmd+y'
1071
1092
  },
1072
1093
  {
1073
1094
  command: CommonCommands.SELECT_ALL.id,
@@ -1899,6 +1920,94 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
1899
1920
  }, description: 'Status bar warning items foreground color. Warning items stand out from other status bar entries to indicate warning conditions. The status bar is shown in the bottom of the window.'
1900
1921
  },
1901
1922
 
1923
+ // editor find
1924
+
1925
+ {
1926
+ id: 'editor.findMatchBackground',
1927
+ defaults: {
1928
+ light: '#A8AC94',
1929
+ dark: '#515C6A',
1930
+ hcDark: undefined,
1931
+ hcLight: undefined
1932
+ },
1933
+ description: 'Color of the current search match.'
1934
+ },
1935
+
1936
+ {
1937
+ id: 'editor.findMatchForeground',
1938
+ defaults: {
1939
+ light: undefined,
1940
+ dark: undefined,
1941
+ hcDark: undefined,
1942
+ hcLight: undefined
1943
+ },
1944
+ description: 'Text color of the current search match.'
1945
+ },
1946
+ {
1947
+ id: 'editor.findMatchHighlightBackground',
1948
+ defaults: {
1949
+ light: '#EA5C0055',
1950
+ dark: '#EA5C0055',
1951
+ hcDark: undefined,
1952
+ hcLight: undefined
1953
+ },
1954
+ description: 'Color of the other search matches. The color must not be opaque so as not to hide underlying decorations.'
1955
+ },
1956
+
1957
+ {
1958
+ id: 'editor.findMatchHighlightForeground',
1959
+ defaults: {
1960
+ light: undefined,
1961
+ dark: undefined,
1962
+ hcDark: undefined,
1963
+ hcLight: undefined
1964
+ },
1965
+ description: 'Foreground color of the other search matches.'
1966
+ },
1967
+
1968
+ {
1969
+ id: 'editor.findRangeHighlightBackground',
1970
+ defaults: {
1971
+ dark: '#3a3d4166',
1972
+ light: '#b4b4b44d',
1973
+ hcDark: undefined,
1974
+ hcLight: undefined
1975
+ },
1976
+ description: 'Color of the range limiting the search. The color must not be opaque so as not to hide underlying decorations.'
1977
+ },
1978
+
1979
+ {
1980
+ id: 'editor.findMatchBorder',
1981
+ defaults: {
1982
+ light: undefined,
1983
+ dark: undefined,
1984
+ hcDark: 'activeContrastBorder',
1985
+ hcLight: 'activeContrastBorder'
1986
+ },
1987
+ description: 'Border color of the current search match.'
1988
+ },
1989
+ {
1990
+ id: 'editor.findMatchHighlightBorder',
1991
+ defaults: {
1992
+ light: undefined,
1993
+ dark: undefined,
1994
+ hcDark: 'activeContrastBorder',
1995
+ hcLight: 'activeContrastBorder'
1996
+ },
1997
+ description: 'Border color of the other search matches.'
1998
+ },
1999
+
2000
+ {
2001
+ id: 'editor.findRangeHighlightBorder',
2002
+ defaults: {
2003
+ dark: undefined,
2004
+ light: undefined,
2005
+ hcDark: Color.transparent('activeContrastBorder', 0.4),
2006
+ hcLight: Color.transparent('activeContrastBorder', 0.4)
2007
+ },
2008
+ description: 'Border color of the range limiting the search. The color must not be opaque so as not to hide underlying decorations.'
2009
+ },
2010
+
1902
2011
  // Quickinput colors should be aligned with https://code.visualstudio.com/api/references/theme-color#quick-picker
1903
2012
  // if not yet contributed by Monaco, check runtime css variables to learn.
1904
2013
  {
@@ -143,6 +143,7 @@ import { LanguageIconLabelProvider } from './language-icon-provider';
143
143
  import { bindTreePreferences } from './tree';
144
144
  import { OpenWithService } from './open-with-service';
145
145
  import { ViewColumnService } from './shell/view-column-service';
146
+ import { DomInputUndoRedoHandler, UndoRedoHandler, UndoRedoHandlerService } from './undo-redo-handler';
146
147
 
147
148
  export { bindResourceProvider, bindMessageService, bindPreferenceService };
148
149
 
@@ -466,4 +467,9 @@ export const frontendApplicationModule = new ContainerModule((bind, _unbind, _is
466
467
  bind(SecondaryWindowHandler).toSelf().inSingletonScope();
467
468
 
468
469
  bind(ViewColumnService).toSelf().inSingletonScope();
470
+
471
+ bind(UndoRedoHandlerService).toSelf().inSingletonScope();
472
+ bindContributionProvider(bind, UndoRedoHandler);
473
+ bind(DomInputUndoRedoHandler).toSelf().inSingletonScope();
474
+ bind(UndoRedoHandler).toService(DomInputUndoRedoHandler);
469
475
  });
@@ -47,3 +47,4 @@ export * from './decoration-style';
47
47
  export * from './styling-service';
48
48
  export * from './hover-service';
49
49
  export * from './saveable-service';
50
+ export * from './undo-redo-handler';
@@ -239,7 +239,8 @@ blockquote {
239
239
  -o-user-select: none;
240
240
  }
241
241
 
242
- :focus {
242
+ /* Since an iframe has its own focus tracking, we don't show focus on iframes */
243
+ :focus:not(iframe) {
243
244
  outline-width: 1px;
244
245
  outline-style: solid;
245
246
  outline-offset: -1px;
@@ -0,0 +1,85 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 TypeFox 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, named, postConstruct } from 'inversify';
18
+ import { ContributionProvider } from '../common';
19
+
20
+ export const UndoRedoHandler = Symbol('UndoRedoHandler');
21
+
22
+ export interface UndoRedoHandler<T> {
23
+ priority: number;
24
+ select(): T | undefined;
25
+ undo(item: T): void;
26
+ redo(item: T): void;
27
+ }
28
+
29
+ @injectable()
30
+ export class UndoRedoHandlerService {
31
+
32
+ @inject(ContributionProvider) @named(UndoRedoHandler)
33
+ protected readonly provider: ContributionProvider<UndoRedoHandler<unknown>>;
34
+
35
+ protected handlers: UndoRedoHandler<unknown>[];
36
+
37
+ @postConstruct()
38
+ protected init(): void {
39
+ this.handlers = this.provider.getContributions().sort((a, b) => b.priority - a.priority);
40
+ }
41
+
42
+ undo(): void {
43
+ for (const handler of this.handlers) {
44
+ const selection = handler.select();
45
+ if (selection) {
46
+ handler.undo(selection);
47
+ return;
48
+ }
49
+ }
50
+ }
51
+
52
+ redo(): void {
53
+ for (const handler of this.handlers) {
54
+ const selection = handler.select();
55
+ if (selection) {
56
+ handler.redo(selection);
57
+ return;
58
+ }
59
+ }
60
+ }
61
+
62
+ }
63
+
64
+ @injectable()
65
+ export class DomInputUndoRedoHandler implements UndoRedoHandler<Element> {
66
+
67
+ priority = 1000;
68
+
69
+ select(): Element | undefined {
70
+ const element = document.activeElement;
71
+ if (element && ['input', 'textarea'].includes(element.tagName.toLowerCase())) {
72
+ return element;
73
+ }
74
+ return undefined;
75
+ }
76
+
77
+ undo(item: Element): void {
78
+ document.execCommand('undo');
79
+ }
80
+
81
+ redo(item: Element): void {
82
+ document.execCommand('redo');
83
+ }
84
+
85
+ }