@theia/core 1.38.0-next.0 → 1.38.0-next.27
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.
- package/README.md +6 -6
- package/lib/browser/json-schema-store.d.ts +1 -0
- package/lib/browser/json-schema-store.d.ts.map +1 -1
- package/lib/browser/json-schema-store.js +4 -2
- package/lib/browser/json-schema-store.js.map +1 -1
- package/lib/browser/quick-input/quick-command-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/quick-input/quick-command-frontend-contribution.js +25 -1
- package/lib/browser/quick-input/quick-command-frontend-contribution.js.map +1 -1
- package/lib/browser/quick-input/quick-command-service.d.ts +1 -0
- package/lib/browser/quick-input/quick-command-service.d.ts.map +1 -1
- package/lib/browser/quick-input/quick-command-service.js +4 -1
- package/lib/browser/quick-input/quick-command-service.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts +2 -0
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +23 -8
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
- package/lib/browser/shell/tab-bars.d.ts +33 -24
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +90 -45
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/widgets/select-component.d.ts +4 -2
- package/lib/browser/widgets/select-component.d.ts.map +1 -1
- package/lib/browser/widgets/select-component.js +14 -11
- package/lib/browser/widgets/select-component.js.map +1 -1
- package/lib/common/command.d.ts +1 -0
- package/lib/common/command.d.ts.map +1 -1
- package/lib/common/command.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/objects.d.ts +1 -0
- package/lib/common/objects.d.ts.map +1 -1
- package/lib/common/objects.js +43 -1
- package/lib/common/objects.js.map +1 -1
- package/lib/common/telemetry.d.ts +20 -0
- package/lib/common/telemetry.d.ts.map +1 -0
- package/lib/common/telemetry.js +25 -0
- package/lib/common/telemetry.js.map +1 -0
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +5 -0
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.js +4 -3
- package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
- package/package.json +4 -4
- package/src/browser/json-schema-store.ts +3 -2
- package/src/browser/quick-input/quick-command-frontend-contribution.ts +26 -2
- package/src/browser/quick-input/quick-command-service.ts +4 -0
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +23 -6
- package/src/browser/shell/tab-bars.ts +107 -63
- package/src/browser/style/tabs.css +67 -7
- package/src/browser/widgets/select-component.tsx +21 -13
- package/src/common/command.ts +1 -0
- package/src/common/index.ts +1 -0
- package/src/common/objects.ts +48 -1
- package/src/common/telemetry.ts +45 -0
- package/src/electron-browser/menu/electron-main-menu-factory.ts +10 -3
|
@@ -34,6 +34,9 @@ import { IDragEvent } from '@phosphor/dragdrop';
|
|
|
34
34
|
import { LOCKED_CLASS, PINNED_CLASS } from '../widgets/widget';
|
|
35
35
|
import { CorePreferences } from '../core-preferences';
|
|
36
36
|
import { HoverService } from '../hover-service';
|
|
37
|
+
import { Root, createRoot } from 'react-dom/client';
|
|
38
|
+
import { SelectComponent } from '../widgets/select-component';
|
|
39
|
+
import { createElement } from 'react';
|
|
37
40
|
|
|
38
41
|
/** The class name added to hidden content nodes, which are required to render vertical side bars. */
|
|
39
42
|
const HIDDEN_CONTENT_CLASS = 'theia-TabBar-hidden-content';
|
|
@@ -228,7 +231,7 @@ export class TabBarRenderer extends TabBar.Renderer {
|
|
|
228
231
|
} else {
|
|
229
232
|
width = '';
|
|
230
233
|
}
|
|
231
|
-
return { zIndex, height, width };
|
|
234
|
+
return { zIndex, height, minWidth: width, maxWidth: width };
|
|
232
235
|
}
|
|
233
236
|
|
|
234
237
|
/**
|
|
@@ -575,13 +578,6 @@ export class TabBarRenderer extends TabBar.Renderer {
|
|
|
575
578
|
|
|
576
579
|
}
|
|
577
580
|
|
|
578
|
-
export namespace ScrollableTabBar {
|
|
579
|
-
export interface Options {
|
|
580
|
-
minimumTabSize: number;
|
|
581
|
-
defaultTabSize: number;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
581
|
/**
|
|
586
582
|
* A specialized tab bar for the main and bottom areas.
|
|
587
583
|
*/
|
|
@@ -595,13 +591,18 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
595
591
|
protected needsRecompute = false;
|
|
596
592
|
protected tabSize = 0;
|
|
597
593
|
private _dynamicTabOptions?: ScrollableTabBar.Options;
|
|
594
|
+
protected contentContainer: HTMLElement;
|
|
595
|
+
protected topRow: HTMLElement;
|
|
598
596
|
|
|
599
597
|
protected readonly toDispose = new DisposableCollection();
|
|
598
|
+
protected openTabsContainer: HTMLDivElement;
|
|
599
|
+
protected openTabsRoot: Root;
|
|
600
600
|
|
|
601
601
|
constructor(options?: TabBar.IOptions<Widget> & PerfectScrollbar.Options, dynamicTabOptions?: ScrollableTabBar.Options) {
|
|
602
602
|
super(options);
|
|
603
603
|
this.scrollBarFactory = () => new PerfectScrollbar(this.scrollbarHost, options);
|
|
604
604
|
this._dynamicTabOptions = dynamicTabOptions;
|
|
605
|
+
this.rewireDOM();
|
|
605
606
|
}
|
|
606
607
|
|
|
607
608
|
set dynamicTabOptions(options: ScrollableTabBar.Options | undefined) {
|
|
@@ -621,6 +622,35 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
621
622
|
this.toDispose.dispose();
|
|
622
623
|
}
|
|
623
624
|
|
|
625
|
+
/**
|
|
626
|
+
* Restructures the DOM defined in PhosphorJS.
|
|
627
|
+
*
|
|
628
|
+
* By default the tabs (`li`) are contained in the `this.contentNode` (`ul`) which is wrapped in a `div` (`this.node`).
|
|
629
|
+
* Instead of this structure, we add a container for the `this.contentNode` and for the toolbar.
|
|
630
|
+
* The scrollbar will only work for the `ul` part but it does not affect the toolbar, so it can be on the right hand-side.
|
|
631
|
+
*/
|
|
632
|
+
private rewireDOM(): void {
|
|
633
|
+
const contentNode = this.node.getElementsByClassName(ScrollableTabBar.Styles.TAB_BAR_CONTENT)[0];
|
|
634
|
+
if (!contentNode) {
|
|
635
|
+
throw new Error("'this.node' does not have the content as a direct child with class name 'p-TabBar-content'.");
|
|
636
|
+
}
|
|
637
|
+
this.node.removeChild(contentNode);
|
|
638
|
+
this.contentContainer = document.createElement('div');
|
|
639
|
+
this.contentContainer.classList.add(ScrollableTabBar.Styles.TAB_BAR_CONTENT_CONTAINER);
|
|
640
|
+
this.contentContainer.appendChild(contentNode);
|
|
641
|
+
|
|
642
|
+
this.topRow = document.createElement('div');
|
|
643
|
+
this.topRow.classList.add('theia-tabBar-tab-row');
|
|
644
|
+
this.topRow.appendChild(this.contentContainer);
|
|
645
|
+
|
|
646
|
+
this.openTabsContainer = document.createElement('div');
|
|
647
|
+
this.openTabsContainer.classList.add('theia-tabBar-open-tabs');
|
|
648
|
+
this.openTabsRoot = createRoot(this.openTabsContainer);
|
|
649
|
+
this.topRow.appendChild(this.openTabsContainer);
|
|
650
|
+
|
|
651
|
+
this.node.appendChild(this.topRow);
|
|
652
|
+
}
|
|
653
|
+
|
|
624
654
|
protected override onAfterAttach(msg: Message): void {
|
|
625
655
|
if (!this.scrollBar) {
|
|
626
656
|
this.scrollBar = this.scrollBarFactory();
|
|
@@ -649,18 +679,41 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
649
679
|
}
|
|
650
680
|
|
|
651
681
|
protected updateTabs(): void {
|
|
652
|
-
|
|
653
682
|
const content = [];
|
|
654
683
|
if (this.dynamicTabOptions) {
|
|
684
|
+
|
|
685
|
+
this.openTabsRoot.render(createElement(SelectComponent, {
|
|
686
|
+
options: this.titles,
|
|
687
|
+
onChange: (option, index) => {
|
|
688
|
+
this.currentIndex = index;
|
|
689
|
+
},
|
|
690
|
+
alignment: 'right'
|
|
691
|
+
}));
|
|
692
|
+
|
|
655
693
|
if (this.isMouseOver) {
|
|
656
694
|
this.needsRecompute = true;
|
|
657
695
|
} else {
|
|
658
696
|
this.needsRecompute = false;
|
|
659
697
|
if (this.orientation === 'horizontal') {
|
|
660
|
-
|
|
698
|
+
let availableWidth = this.scrollbarHost.clientWidth;
|
|
699
|
+
let effectiveWidth = availableWidth;
|
|
700
|
+
if (!this.openTabsContainer.classList.contains('p-mod-hidden')) {
|
|
701
|
+
availableWidth += this.openTabsContainer.getBoundingClientRect().width;
|
|
702
|
+
}
|
|
703
|
+
if (this.dynamicTabOptions.minimumTabSize * this.titles.length <= availableWidth) {
|
|
704
|
+
effectiveWidth += this.openTabsContainer.getBoundingClientRect().width;
|
|
705
|
+
this.openTabsContainer.classList.add('p-mod-hidden');
|
|
706
|
+
} else {
|
|
707
|
+
this.openTabsContainer.classList.remove('p-mod-hidden');
|
|
708
|
+
}
|
|
709
|
+
this.tabSize = Math.max(Math.min(effectiveWidth / this.titles.length,
|
|
661
710
|
this.dynamicTabOptions.defaultTabSize), this.dynamicTabOptions.minimumTabSize);
|
|
662
711
|
}
|
|
663
712
|
}
|
|
713
|
+
this.node.classList.add('dynamic-tabs');
|
|
714
|
+
} else {
|
|
715
|
+
this.openTabsContainer.classList.add('p-mod-hidden');
|
|
716
|
+
this.node.classList.remove('dynamic-tabs');
|
|
664
717
|
}
|
|
665
718
|
for (let i = 0, n = this.titles.length; i < n; ++i) {
|
|
666
719
|
const title = this.titles[i];
|
|
@@ -674,7 +727,9 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
674
727
|
}
|
|
675
728
|
VirtualDOM.render(content, this.contentNode);
|
|
676
729
|
if (this.scrollBar) {
|
|
677
|
-
this.
|
|
730
|
+
if (!(this.dynamicTabOptions && this.isMouseOver)) {
|
|
731
|
+
this.scrollBar.update();
|
|
732
|
+
}
|
|
678
733
|
}
|
|
679
734
|
}
|
|
680
735
|
|
|
@@ -739,10 +794,38 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
739
794
|
return result;
|
|
740
795
|
}
|
|
741
796
|
|
|
797
|
+
/**
|
|
798
|
+
* Overrides the `contentNode` property getter in PhosphorJS' TabBar.
|
|
799
|
+
*/
|
|
800
|
+
// @ts-expect-error TS2611 `TabBar<T>.contentNode` is declared as `readonly contentNode` but is implemented as a getter.
|
|
801
|
+
get contentNode(): HTMLUListElement {
|
|
802
|
+
return this.tabBarContainer.getElementsByClassName(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT)[0] as HTMLUListElement;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Overrides the scrollable host from the parent class.
|
|
807
|
+
*/
|
|
742
808
|
protected get scrollbarHost(): HTMLElement {
|
|
743
|
-
return this.
|
|
809
|
+
return this.tabBarContainer;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
protected get tabBarContainer(): HTMLElement {
|
|
813
|
+
return this.node.getElementsByClassName(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT_CONTAINER)[0] as HTMLElement;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
export namespace ScrollableTabBar {
|
|
818
|
+
|
|
819
|
+
export interface Options {
|
|
820
|
+
minimumTabSize: number;
|
|
821
|
+
defaultTabSize: number;
|
|
744
822
|
}
|
|
823
|
+
export namespace Styles {
|
|
745
824
|
|
|
825
|
+
export const TAB_BAR_CONTENT = 'p-TabBar-content';
|
|
826
|
+
export const TAB_BAR_CONTENT_CONTAINER = 'p-TabBar-content-container';
|
|
827
|
+
|
|
828
|
+
}
|
|
746
829
|
}
|
|
747
830
|
|
|
748
831
|
/**
|
|
@@ -761,12 +844,9 @@ export class ScrollableTabBar extends TabBar<Widget> {
|
|
|
761
844
|
*
|
|
762
845
|
*/
|
|
763
846
|
export class ToolbarAwareTabBar extends ScrollableTabBar {
|
|
764
|
-
|
|
765
|
-
protected contentContainer: HTMLElement;
|
|
766
847
|
protected toolbar: TabBarToolbar | undefined;
|
|
767
848
|
protected breadcrumbsContainer: HTMLElement;
|
|
768
849
|
protected readonly breadcrumbsRenderer: BreadcrumbsRenderer;
|
|
769
|
-
protected topRow: HTMLElement;
|
|
770
850
|
|
|
771
851
|
constructor(
|
|
772
852
|
protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry,
|
|
@@ -777,7 +857,8 @@ export class ToolbarAwareTabBar extends ScrollableTabBar {
|
|
|
777
857
|
) {
|
|
778
858
|
super(options, dynamicTabOptions);
|
|
779
859
|
this.breadcrumbsRenderer = this.breadcrumbsRendererFactory();
|
|
780
|
-
this.
|
|
860
|
+
this.addBreadcrumbs();
|
|
861
|
+
this.toolbar = this.tabBarToolbarFactory();
|
|
781
862
|
this.toDispose.push(this.tabBarToolbarRegistry.onDidChange(() => this.update()));
|
|
782
863
|
this.toDispose.push(this.breadcrumbsRenderer);
|
|
783
864
|
this.toDispose.push(this.breadcrumbsRenderer.onDidChangeActiveState(active => {
|
|
@@ -792,25 +873,6 @@ export class ToolbarAwareTabBar extends ScrollableTabBar {
|
|
|
792
873
|
this.toDispose.push(Disposable.create(() => this.currentChanged.disconnect(handler)));
|
|
793
874
|
}
|
|
794
875
|
|
|
795
|
-
/**
|
|
796
|
-
* Overrides the `contentNode` property getter in PhosphorJS' TabBar.
|
|
797
|
-
*/
|
|
798
|
-
// @ts-expect-error TS2611 `TabBar<T>.contentNode` is declared as `readonly contentNode` but is implemented as a getter.
|
|
799
|
-
get contentNode(): HTMLUListElement {
|
|
800
|
-
return this.tabBarContainer.getElementsByClassName(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT)[0] as HTMLUListElement;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
/**
|
|
804
|
-
* Overrides the scrollable host from the parent class.
|
|
805
|
-
*/
|
|
806
|
-
protected override get scrollbarHost(): HTMLElement {
|
|
807
|
-
return this.tabBarContainer;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
protected get tabBarContainer(): HTMLElement {
|
|
811
|
-
return this.node.getElementsByClassName(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT_CONTAINER)[0] as HTMLElement;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
876
|
protected async updateBreadcrumbs(): Promise<void> {
|
|
815
877
|
const current = this.currentTitle?.owner;
|
|
816
878
|
const uri = NavigatableWidget.is(current) ? current.getResourceUri() : undefined;
|
|
@@ -853,13 +915,19 @@ export class ToolbarAwareTabBar extends ScrollableTabBar {
|
|
|
853
915
|
}
|
|
854
916
|
|
|
855
917
|
override handleEvent(event: Event): void {
|
|
856
|
-
if (
|
|
857
|
-
|
|
858
|
-
|
|
918
|
+
if (event instanceof MouseEvent) {
|
|
919
|
+
if (this.toolbar && this.toolbar.shouldHandleMouseEvent(event) || this.isOver(event, this.openTabsContainer)) {
|
|
920
|
+
// if the mouse event is over the toolbar part don't handle it.
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
859
923
|
}
|
|
860
924
|
super.handleEvent(event);
|
|
861
925
|
}
|
|
862
926
|
|
|
927
|
+
private isOver(event: Event, element: Element): boolean {
|
|
928
|
+
return element && event.target instanceof Element && element.contains(event.target);
|
|
929
|
+
}
|
|
930
|
+
|
|
863
931
|
/**
|
|
864
932
|
* Restructures the DOM defined in PhosphorJS.
|
|
865
933
|
*
|
|
@@ -867,20 +935,7 @@ export class ToolbarAwareTabBar extends ScrollableTabBar {
|
|
|
867
935
|
* Instead of this structure, we add a container for the `this.contentNode` and for the toolbar.
|
|
868
936
|
* The scrollbar will only work for the `ul` part but it does not affect the toolbar, so it can be on the right hand-side.
|
|
869
937
|
*/
|
|
870
|
-
|
|
871
|
-
const contentNode = this.node.getElementsByClassName(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT)[0];
|
|
872
|
-
if (!contentNode) {
|
|
873
|
-
throw new Error("'this.node' does not have the content as a direct child with class name 'p-TabBar-content'.");
|
|
874
|
-
}
|
|
875
|
-
this.node.removeChild(contentNode);
|
|
876
|
-
this.topRow = document.createElement('div');
|
|
877
|
-
this.topRow.classList.add('theia-tabBar-tab-row');
|
|
878
|
-
this.contentContainer = document.createElement('div');
|
|
879
|
-
this.contentContainer.classList.add(ToolbarAwareTabBar.Styles.TAB_BAR_CONTENT_CONTAINER);
|
|
880
|
-
this.contentContainer.appendChild(contentNode);
|
|
881
|
-
this.topRow.appendChild(this.contentContainer);
|
|
882
|
-
this.node.appendChild(this.topRow);
|
|
883
|
-
this.toolbar = this.tabBarToolbarFactory();
|
|
938
|
+
private addBreadcrumbs(): void {
|
|
884
939
|
this.breadcrumbsContainer = document.createElement('div');
|
|
885
940
|
this.breadcrumbsContainer.classList.add('theia-tabBar-breadcrumb-row');
|
|
886
941
|
this.breadcrumbsContainer.appendChild(this.breadcrumbsRenderer.host);
|
|
@@ -888,17 +943,6 @@ export class ToolbarAwareTabBar extends ScrollableTabBar {
|
|
|
888
943
|
}
|
|
889
944
|
}
|
|
890
945
|
|
|
891
|
-
export namespace ToolbarAwareTabBar {
|
|
892
|
-
|
|
893
|
-
export namespace Styles {
|
|
894
|
-
|
|
895
|
-
export const TAB_BAR_CONTENT = 'p-TabBar-content';
|
|
896
|
-
export const TAB_BAR_CONTENT_CONTAINER = 'p-TabBar-content-container';
|
|
897
|
-
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
}
|
|
901
|
-
|
|
902
946
|
/**
|
|
903
947
|
* A specialized tab bar for side areas.
|
|
904
948
|
*/
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.p-TabBar[data-orientation='horizontal'] {
|
|
25
|
-
overflow-x: hidden;
|
|
26
|
-
overflow-y: hidden;
|
|
27
25
|
min-height: var(--theia-horizontal-toolbar-height);
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -38,6 +36,7 @@
|
|
|
38
36
|
line-height: var(--theia-private-horizontal-tab-height);
|
|
39
37
|
padding: 0px 8px;
|
|
40
38
|
align-items: center;
|
|
39
|
+
overflow: hidden;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
.p-TabBar[data-orientation='vertical'] .p-TabBar-tab {
|
|
@@ -215,7 +214,19 @@
|
|
|
215
214
|
-ms-user-select: none;
|
|
216
215
|
}
|
|
217
216
|
|
|
218
|
-
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable > .p-TabBar-tabCloseIcon
|
|
217
|
+
.p-TabBar.theia-app-centers.dynamic-tabs .p-TabBar-tab.p-mod-closable > .p-TabBar-tabCloseIcon,
|
|
218
|
+
.p-TabBar.theia-app-centers.dynamic-tabs .p-TabBar-tab.theia-mod-pinned > .p-TabBar-tabCloseIcon {
|
|
219
|
+
/* hide close icon for dynamic tabs strategy*/
|
|
220
|
+
display: none;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-current > .p-TabBar-tabCloseIcon,
|
|
224
|
+
.p-TabBar.theia-app-centers .p-TabBar-tab:hover.p-mod-closable > .p-TabBar-tabCloseIcon,
|
|
225
|
+
.p-TabBar.theia-app-centers .p-TabBar-tab:hover.theia-mod-pinned > .p-TabBar-tabCloseIcon {
|
|
226
|
+
display: inline-block;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.p-TabBar.theia-app-centers .p-TabBar-tab:hover.p-mod-closable > .p-TabBar-tabCloseIcon {
|
|
219
230
|
border-radius: 5px;
|
|
220
231
|
background-color: rgba(50%, 50%, 50%, 0.2);
|
|
221
232
|
}
|
|
@@ -303,6 +314,15 @@
|
|
|
303
314
|
bottom: calc((var(--theia-private-horizontal-tab-scrollbar-rail-height) - var(--theia-private-horizontal-tab-scrollbar-height)) / 2);
|
|
304
315
|
}
|
|
305
316
|
|
|
317
|
+
.p-TabBar[data-orientation='vertical'] .p-TabBar-content-container > .ps__rail-y {
|
|
318
|
+
width: var(--theia-private-horizontal-tab-scrollbar-rail-height);
|
|
319
|
+
z-index: 1000;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.p-TabBar[data-orientation='vertical'] .p-TabBar-content-container > .ps__rail-y > .ps__thumb-y {
|
|
323
|
+
width: var(--theia-private-horizontal-tab-scrollbar-height) !important;
|
|
324
|
+
right: calc((var(--theia-private-horizontal-tab-scrollbar-rail-height) - var(--theia-private-horizontal-tab-scrollbar-height)) / 2);
|
|
325
|
+
}
|
|
306
326
|
|
|
307
327
|
/*-----------------------------------------------------------------------------
|
|
308
328
|
| Dragged tabs
|
|
@@ -405,18 +425,36 @@
|
|
|
405
425
|
flex-direction: column;
|
|
406
426
|
}
|
|
407
427
|
|
|
408
|
-
.theia-tabBar-tab-row {
|
|
428
|
+
.p-TabBar[data-orientation='horizontal'] .theia-tabBar-tab-row {
|
|
409
429
|
display: flex;
|
|
410
430
|
flex-flow: row nowrap;
|
|
411
431
|
min-width: 100%;
|
|
412
432
|
}
|
|
413
433
|
|
|
414
|
-
.p-TabBar-
|
|
434
|
+
.p-TabBar[data-orientation='vertical'] .theia-tabBar-tab-row {
|
|
435
|
+
display: flex;
|
|
436
|
+
flex-flow: column nowrap;
|
|
437
|
+
height: 100%;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.p-TabBar[data-orientation='horizontal'] .p-TabBar-content {
|
|
441
|
+
flex-direction: row;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.p-TabBar[data-orientation='vertical'] .p-TabBar-content {
|
|
445
|
+
flex-direction: column;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.p-TabBar.theia-app-centers[data-orientation='horizontal'].dynamic-tabs .p-TabBar-tabLabel {
|
|
449
|
+
/* fade out text with dynamic tabs strategy */
|
|
450
|
+
mask-image: linear-gradient(to left, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 1) 15px);
|
|
451
|
+
-webkit-mask-image: linear-gradient(to left, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 1) 15px);
|
|
415
452
|
flex: 1;
|
|
416
453
|
}
|
|
417
454
|
|
|
418
|
-
|
|
419
|
-
.p-TabBar[data-orientation='horizontal'] .p-TabBar-tab
|
|
455
|
+
|
|
456
|
+
.p-TabBar[data-orientation='horizontal'] .p-TabBar-tab .theia-tab-icon-label {
|
|
457
|
+
flex: 1;
|
|
420
458
|
overflow: hidden;
|
|
421
459
|
}
|
|
422
460
|
|
|
@@ -435,3 +473,25 @@
|
|
|
435
473
|
margin: 0px 0px;
|
|
436
474
|
margin-top: 4px;
|
|
437
475
|
}
|
|
476
|
+
|
|
477
|
+
/*-----------------------------------------------------------------------------
|
|
478
|
+
| Open tabs dropdown
|
|
479
|
+
|----------------------------------------------------------------------------*/
|
|
480
|
+
.theia-tabBar-open-tabs>.theia-select-component .theia-select-component-label {
|
|
481
|
+
display: none;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.theia-tabBar-open-tabs>.theia-select-component {
|
|
485
|
+
min-width: auto;
|
|
486
|
+
height: 100%;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.theia-tabBar-open-tabs {
|
|
490
|
+
flex: 0 0 auto;
|
|
491
|
+
display: flex;
|
|
492
|
+
align-items: center;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.theia-tabBar-open-tabs.p-mod-hidden {
|
|
496
|
+
display: none
|
|
497
|
+
}
|
|
@@ -34,11 +34,12 @@ export interface SelectOption {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export interface SelectComponentProps {
|
|
37
|
-
options: SelectOption[]
|
|
37
|
+
options: readonly SelectOption[]
|
|
38
38
|
defaultValue?: string | number
|
|
39
39
|
onChange?: (option: SelectOption, index: number) => void,
|
|
40
40
|
onBlur?: () => void,
|
|
41
|
-
onFocus?: () => void
|
|
41
|
+
onFocus?: () => void,
|
|
42
|
+
alignment?: 'left' | 'right';
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export interface SelectComponentState {
|
|
@@ -81,7 +82,7 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
81
82
|
this.dropdownElement = list;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
get options(): SelectOption[] {
|
|
85
|
+
get options(): readonly SelectOption[] {
|
|
85
86
|
return this.props.options;
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -105,6 +106,10 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
protected get alignLeft(): boolean {
|
|
110
|
+
return this.props.alignment !== 'right';
|
|
111
|
+
}
|
|
112
|
+
|
|
108
113
|
protected getOptimalWidth(): number {
|
|
109
114
|
const textWidth = measureTextWidth(this.props.options.map(e => e.label || e.value || '' + (e.detail || '')));
|
|
110
115
|
return Math.ceil(textWidth + 16);
|
|
@@ -168,7 +173,7 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
168
173
|
if (options[selected]?.separator) {
|
|
169
174
|
selected = this.nextNotSeparator('forwards');
|
|
170
175
|
}
|
|
171
|
-
const selectedItemLabel = options[selected]
|
|
176
|
+
const selectedItemLabel = options[selected]?.label ?? options[selected]?.value;
|
|
172
177
|
return <>
|
|
173
178
|
<div
|
|
174
179
|
key="select-component"
|
|
@@ -279,6 +284,9 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
279
284
|
if (!this.state.dimensions) {
|
|
280
285
|
return;
|
|
281
286
|
}
|
|
287
|
+
|
|
288
|
+
const shellArea = document.getElementById('theia-app-shell')!.getBoundingClientRect();
|
|
289
|
+
const maxWidth = this.alignLeft ? shellArea.width - this.state.dimensions.left : this.state.dimensions.right;
|
|
282
290
|
if (this.mountedListeners.size === 0) {
|
|
283
291
|
// Only attach our listeners once we render our dropdown menu
|
|
284
292
|
this.attachListeners();
|
|
@@ -286,11 +294,11 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
286
294
|
this.optimalWidth = this.getOptimalWidth();
|
|
287
295
|
this.optimalHeight = this.getOptimalHeight(Math.max(this.state.dimensions.width, this.optimalWidth));
|
|
288
296
|
}
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
const availableBottom = clientRect.top + clientRect.height - this.state.dimensions.bottom;
|
|
297
|
+
const availableTop = this.state.dimensions.top - shellArea.top;
|
|
298
|
+
const availableBottom = shellArea.top + shellArea.height - this.state.dimensions.bottom;
|
|
292
299
|
// prefer rendering to the bottom unless there is not enough space and more content can be shown to the top
|
|
293
300
|
const invert = availableBottom < this.optimalHeight && (availableBottom - this.optimalHeight) < (availableTop - this.optimalHeight);
|
|
301
|
+
|
|
294
302
|
const { options } = this.props;
|
|
295
303
|
const { hover } = this.state;
|
|
296
304
|
const description = options[hover].description;
|
|
@@ -313,14 +321,14 @@ export class SelectComponent extends React.Component<SelectComponentProps, Selec
|
|
|
313
321
|
items.push(descriptionNode);
|
|
314
322
|
}
|
|
315
323
|
}
|
|
316
|
-
|
|
317
|
-
const maxWidth = clientRect.width - this.state.dimensions.left;
|
|
324
|
+
|
|
318
325
|
return <div key="dropdown" className="theia-select-component-dropdown" style={{
|
|
319
326
|
top: invert ? 'none' : this.state.dimensions.bottom,
|
|
320
|
-
bottom: invert ?
|
|
321
|
-
left: this.state.dimensions.left,
|
|
322
|
-
|
|
323
|
-
|
|
327
|
+
bottom: invert ? shellArea.top + shellArea.height - this.state.dimensions.top : 'none',
|
|
328
|
+
left: this.alignLeft ? this.state.dimensions.left : 'none',
|
|
329
|
+
right: this.alignLeft ? 'none' : shellArea.width - this.state.dimensions.right,
|
|
330
|
+
width: Math.min(Math.max(this.state.dimensions.width, this.optimalWidth), maxWidth),
|
|
331
|
+
maxHeight: shellArea.height - (invert ? shellArea.height - this.state.dimensions.bottom : this.state.dimensions.top) - this.state.dimensions.height,
|
|
324
332
|
position: 'absolute'
|
|
325
333
|
}} ref={this.dropdownRef}>
|
|
326
334
|
{items}
|
package/src/common/command.ts
CHANGED
|
@@ -122,6 +122,7 @@ export interface CommandHandler {
|
|
|
122
122
|
*/
|
|
123
123
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
124
|
isEnabled?(...args: any[]): boolean;
|
|
125
|
+
onDidChangeEnabled?: Event<void>;
|
|
125
126
|
/**
|
|
126
127
|
* Test whether menu items for this handler should be visible.
|
|
127
128
|
*/
|
package/src/common/index.ts
CHANGED
package/src/common/objects.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { isObject } from './types';
|
|
17
|
+
import { isObject, isUndefined } from './types';
|
|
18
18
|
|
|
19
19
|
export function deepClone<T>(obj: T): T {
|
|
20
20
|
if (!isObject(obj)) {
|
|
@@ -70,3 +70,50 @@ export function notEmpty<T>(arg: T | undefined | null): arg is T {
|
|
|
70
70
|
export function isEmpty(arg: Object): boolean {
|
|
71
71
|
return Object.keys(arg).length === 0 && arg.constructor === Object;
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
// copied and modified from https://github.com/microsoft/vscode/blob/1.76.0/src/vs/base/common/objects.ts#L45-L83
|
|
75
|
+
/*---------------------------------------------------------------------------------------------
|
|
76
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
77
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
78
|
+
*--------------------------------------------------------------------------------------------*/
|
|
79
|
+
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
export function cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<any>): any {
|
|
82
|
+
// impossible to clone an undefined or null object
|
|
83
|
+
// eslint-disable-next-line no-null/no-null
|
|
84
|
+
if (isUndefined(obj) || obj === null) {
|
|
85
|
+
return obj;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const changed = changer(obj);
|
|
89
|
+
if (!isUndefined(changed)) {
|
|
90
|
+
return changed;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (Array.isArray(obj)) {
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
const r1: any[] = [];
|
|
96
|
+
for (const e of obj) {
|
|
97
|
+
r1.push(cloneAndChange(e, changer, seen));
|
|
98
|
+
}
|
|
99
|
+
return r1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (isObject(obj)) {
|
|
103
|
+
if (seen.has(obj)) {
|
|
104
|
+
throw new Error('Cannot clone recursive data-structure');
|
|
105
|
+
}
|
|
106
|
+
seen.add(obj);
|
|
107
|
+
const r2 = {};
|
|
108
|
+
for (const i2 in obj) {
|
|
109
|
+
if (_hasOwnProperty.call(obj, i2)) {
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
(r2 as any)[i2] = cloneAndChange(obj[i2], changer, seen);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
seen.delete(obj);
|
|
115
|
+
return r2;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return obj;
|
|
119
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics 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
|
+
export class TelemetryTrustedValue<T> {
|
|
18
|
+
readonly value: T;
|
|
19
|
+
|
|
20
|
+
constructor(value: T) {
|
|
21
|
+
this.value = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TelemetryLogger {
|
|
26
|
+
readonly sender: TelemetrySender;
|
|
27
|
+
readonly options: TelemetryLoggerOptions | undefined;
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
logUsage(eventName: string, data?: Record<string, any | TelemetryTrustedValue<any>>): void;
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
logError(eventNameOrException: string | Error, data?: Record<string, any | TelemetryTrustedValue<any>>): void;
|
|
32
|
+
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface TelemetrySender {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
sendEventData(eventName: string, data?: Record<string, any>): void;
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
sendErrorData(error: Error, data?: Record<string, any>): void;
|
|
41
|
+
flush?(): void | Thenable<void>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface TelemetryLoggerOptions {
|
|
45
|
+
}
|
|
@@ -35,6 +35,12 @@ export interface ElectronMenuOptions {
|
|
|
35
35
|
* Defaults to `true`.
|
|
36
36
|
*/
|
|
37
37
|
readonly showDisabled?: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Controls whether to render disabled items as disabled
|
|
41
|
+
* Defaults to `true`
|
|
42
|
+
*/
|
|
43
|
+
readonly honorDisabled?: boolean;
|
|
38
44
|
/**
|
|
39
45
|
* A DOM context to use when evaluating any `when` clauses
|
|
40
46
|
* of menu items registered for this item.
|
|
@@ -108,7 +114,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
108
114
|
const maxWidget = document.getElementsByClassName(MAXIMIZED_CLASS);
|
|
109
115
|
if (preference === 'visible' || (preference === 'classic' && maxWidget.length === 0)) {
|
|
110
116
|
const menuModel = this.menuProvider.getMenu(MAIN_MENU_BAR);
|
|
111
|
-
this._menu = this.fillMenuTemplate([], menuModel, [], { rootMenuPath: MAIN_MENU_BAR });
|
|
117
|
+
this._menu = this.fillMenuTemplate([], menuModel, [], { honorDisabled: false, rootMenuPath: MAIN_MENU_BAR });
|
|
112
118
|
if (isOSX) {
|
|
113
119
|
this._menu.unshift(this.createOSXMenu());
|
|
114
120
|
}
|
|
@@ -121,7 +127,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
121
127
|
|
|
122
128
|
createElectronContextMenu(menuPath: MenuPath, args?: any[], context?: HTMLElement, contextKeyService?: ContextMatcher): MenuDto[] {
|
|
123
129
|
const menuModel = this.menuProvider.getMenu(menuPath);
|
|
124
|
-
return this.fillMenuTemplate([], menuModel, args, { showDisabled:
|
|
130
|
+
return this.fillMenuTemplate([], menuModel, args, { showDisabled: true, context, rootMenuPath: menuPath, contextKeyService });
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
protected fillMenuTemplate(parentItems: MenuDto[],
|
|
@@ -130,6 +136,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
130
136
|
options: ElectronMenuOptions
|
|
131
137
|
): MenuDto[] {
|
|
132
138
|
const showDisabled = options?.showDisabled !== false;
|
|
139
|
+
const honorDisabled = options?.honorDisabled !== false;
|
|
133
140
|
|
|
134
141
|
if (CompoundMenuNode.is(menu) && menu.children.length && this.undefinedOrMatch(options.contextKeyService ?? this.contextKeyService, menu.when, options.context)) {
|
|
135
142
|
const role = CompoundMenuNode.getRole(menu);
|
|
@@ -181,7 +188,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
|
|
|
181
188
|
label: node.label,
|
|
182
189
|
type: this.commandRegistry.getToggledHandler(commandId, ...args) ? 'checkbox' : 'normal',
|
|
183
190
|
checked: this.commandRegistry.isToggled(commandId, ...args),
|
|
184
|
-
enabled:
|
|
191
|
+
enabled: !honorDisabled || this.commandRegistry.isEnabled(commandId, args), // see https://github.com/eclipse-theia/theia/issues/446
|
|
185
192
|
visible: true,
|
|
186
193
|
accelerator,
|
|
187
194
|
execute: () => this.execute(commandId, args, options.rootMenuPath)
|