custom-electron-titlebar 3.2.6 → 3.2.10
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/.github/FUNDING.yml +1 -0
- package/README.md +15 -24
- package/_config.yml +1 -0
- package/{lib → build}/browser/browser.d.ts +0 -0
- package/{lib → build}/browser/browser.js +0 -0
- package/{lib → build}/browser/browser.js.map +0 -0
- package/{lib → build}/browser/event.d.ts +0 -0
- package/{lib → build}/browser/event.js +2 -1
- package/{lib → build}/browser/event.js.map +1 -1
- package/{lib → build}/browser/iframe.d.ts +0 -0
- package/{lib → build}/browser/iframe.js +0 -0
- package/{lib → build}/browser/iframe.js.map +0 -0
- package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
- package/{lib → build}/browser/keyboardEvent.js +0 -0
- package/{lib → build}/browser/keyboardEvent.js.map +0 -0
- package/{lib → build}/browser/mouseEvent.d.ts +0 -0
- package/{lib → build}/browser/mouseEvent.js +0 -0
- package/{lib → build}/browser/mouseEvent.js.map +0 -0
- package/{lib → build}/common/arrays.d.ts +0 -0
- package/{lib → build}/common/arrays.js +0 -0
- package/{lib → build}/common/arrays.js.map +0 -0
- package/{lib → build}/common/async.d.ts +0 -0
- package/{lib → build}/common/async.js +0 -0
- package/{lib → build}/common/async.js.map +0 -0
- package/{lib → build}/common/charCode.d.ts +0 -0
- package/{lib → build}/common/charCode.js +0 -0
- package/{lib → build}/common/charCode.js.map +0 -0
- package/{lib → build}/common/color.d.ts +0 -0
- package/{lib → build}/common/color.js +0 -0
- package/{lib → build}/common/color.js.map +0 -0
- package/{lib → build}/common/dom.d.ts +0 -0
- package/{lib → build}/common/dom.js +16 -14
- package/build/common/dom.js.map +1 -0
- package/{lib → build}/common/event.d.ts +0 -0
- package/{lib → build}/common/event.js +1 -1
- package/build/common/event.js.map +1 -0
- package/{lib → build}/common/iterator.d.ts +0 -0
- package/{lib → build}/common/iterator.js +0 -0
- package/{lib → build}/common/iterator.js.map +0 -0
- package/{lib → build}/common/keyCodes.d.ts +0 -0
- package/{lib → build}/common/keyCodes.js +0 -0
- package/{lib → build}/common/keyCodes.js.map +0 -0
- package/{lib → build}/common/lifecycle.d.ts +0 -0
- package/{lib → build}/common/lifecycle.js +0 -0
- package/{lib → build}/common/lifecycle.js.map +0 -0
- package/{lib → build}/common/linkedList.d.ts +0 -0
- package/{lib → build}/common/linkedList.js +0 -0
- package/{lib → build}/common/linkedList.js.map +0 -0
- package/{lib → build}/common/platform.d.ts +0 -0
- package/{lib → build}/common/platform.js +0 -0
- package/{lib → build}/common/platform.js.map +0 -0
- package/{lib → build}/index.d.ts +0 -0
- package/{lib → build}/index.js +0 -0
- package/{lib → build}/index.js.map +0 -0
- package/{lib → build}/menu/menu.d.ts +0 -0
- package/{lib → build}/menu/menu.js +38 -38
- package/build/menu/menu.js.map +1 -0
- package/{lib → build}/menu/menuitem.d.ts +10 -2
- package/{lib → build}/menu/menuitem.js +70 -34
- package/build/menu/menuitem.js.map +1 -0
- package/{lib → build}/menubar.d.ts +0 -0
- package/{lib → build}/menubar.js +29 -30
- package/build/menubar.js.map +1 -0
- package/{lib → build}/themebar.d.ts +0 -0
- package/{lib → build}/themebar.js +2 -2
- package/build/themebar.js.map +1 -0
- package/{lib → build}/titlebar.d.ts +0 -0
- package/{lib → build}/titlebar.js +61 -58
- package/build/titlebar.js.map +1 -0
- package/package.json +13 -7
- package/lib/common/dom.js.map +0 -1
- package/lib/common/enableNativeMenuCommands.d.ts +0 -1
- package/lib/common/enableNativeMenuCommands.js +0 -32
- package/lib/common/enableNativeMenuCommands.js.map +0 -1
- package/lib/common/event.js.map +0 -1
- package/lib/main.d.ts +0 -1
- package/lib/main.js +0 -14
- package/lib/main.js.map +0 -1
- package/lib/menu/menu.js.map +0 -1
- package/lib/menu/menuitem.js.map +0 -1
- package/lib/menubar.js.map +0 -1
- package/lib/themebar.js.map +0 -1
- package/lib/titlebar.js.map +0 -1
- package/lib/vs/base/browser/browser.js +0 -150
- package/lib/vs/base/browser/canIUse.js +0 -58
- package/lib/vs/base/browser/codicons.js +0 -37
- package/lib/vs/base/browser/contextmenu.js +0 -9
- package/lib/vs/base/browser/dnd.js +0 -113
- package/lib/vs/base/browser/dom.js +0 -1417
- package/lib/vs/base/browser/event.js +0 -36
- package/lib/vs/base/browser/fastDomNode.js +0 -265
- package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
- package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
- package/lib/vs/base/browser/history.js +0 -9
- package/lib/vs/base/browser/iframe.js +0 -126
- package/lib/vs/base/browser/keyboardEvent.js +0 -599
- package/lib/vs/base/browser/mouseEvent.js +0 -155
- package/lib/vs/base/browser/touch.js +0 -315
- package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
- package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
- package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
- package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
- package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
- package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
- package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
- package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
- package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
- package/lib/vs/base/browser/ui/list/list.js +0 -54
- package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
- package/lib/vs/base/browser/ui/list/listView.js +0 -1388
- package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
- package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
- package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
- package/lib/vs/base/browser/ui/list/splice.js +0 -23
- package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
- package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
- package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
- package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
- package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
- package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
- package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
- package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
- package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
- package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
- package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
- package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
- package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
- package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
- package/lib/vs/base/browser/ui/widget.js +0 -69
- package/lib/vs/base/common/actions.js +0 -224
- package/lib/vs/base/common/amd.js +0 -31
- package/lib/vs/base/common/arrays.js +0 -641
- package/lib/vs/base/common/assert.js +0 -21
- package/lib/vs/base/common/async.js +0 -966
- package/lib/vs/base/common/buffer.js +0 -250
- package/lib/vs/base/common/cache.js +0 -40
- package/lib/vs/base/common/cancellation.js +0 -146
- package/lib/vs/base/common/charCode.js +0 -9
- package/lib/vs/base/common/codicon.js +0 -136
- package/lib/vs/base/common/codicons.js +0 -1378
- package/lib/vs/base/common/collections.js +0 -133
- package/lib/vs/base/common/color.js +0 -716
- package/lib/vs/base/common/comparers.js +0 -280
- package/lib/vs/base/common/console.js +0 -142
- package/lib/vs/base/common/date.js +0 -113
- package/lib/vs/base/common/decorators.js +0 -169
- package/lib/vs/base/common/errorMessage.js +0 -93
- package/lib/vs/base/common/errors.js +0 -213
- package/lib/vs/base/common/errorsWithActions.js +0 -28
- package/lib/vs/base/common/event.js +0 -873
- package/lib/vs/base/common/extpath.js +0 -401
- package/lib/vs/base/common/filters.js +0 -948
- package/lib/vs/base/common/functional.js +0 -28
- package/lib/vs/base/common/fuzzyScorer.js +0 -811
- package/lib/vs/base/common/glob.js +0 -696
- package/lib/vs/base/common/hash.js +0 -359
- package/lib/vs/base/common/history.js +0 -116
- package/lib/vs/base/common/htmlContent.js +0 -162
- package/lib/vs/base/common/idGenerator.js +0 -25
- package/lib/vs/base/common/iterator.js +0 -118
- package/lib/vs/base/common/json.js +0 -1624
- package/lib/vs/base/common/jsonEdit.js +0 -272
- package/lib/vs/base/common/jsonErrorMessages.js +0 -69
- package/lib/vs/base/common/jsonFormatter.js +0 -316
- package/lib/vs/base/common/jsonSchema.js +0 -9
- package/lib/vs/base/common/keyCodes.js +0 -591
- package/lib/vs/base/common/keybindingLabels.js +0 -231
- package/lib/vs/base/common/keybindingParser.js +0 -142
- package/lib/vs/base/common/labels.js +0 -430
- package/lib/vs/base/common/lazy.js +0 -71
- package/lib/vs/base/common/lifecycle.js +0 -308
- package/lib/vs/base/common/linkedList.js +0 -152
- package/lib/vs/base/common/linkedText.js +0 -73
- package/lib/vs/base/common/map.js +0 -1108
- package/lib/vs/base/common/marshalling.js +0 -80
- package/lib/vs/base/common/mime.js +0 -321
- package/lib/vs/base/common/navigator.js +0 -50
- package/lib/vs/base/common/network.js +0 -160
- package/lib/vs/base/common/normalization.js +0 -78
- package/lib/vs/base/common/numbers.js +0 -55
- package/lib/vs/base/common/objects.js +0 -268
- package/lib/vs/base/common/paging.js +0 -190
- package/lib/vs/base/common/parsers.js +0 -78
- package/lib/vs/base/common/path.js +0 -1550
- package/lib/vs/base/common/platform.js +0 -245
- package/lib/vs/base/common/process.js +0 -52
- package/lib/vs/base/common/processes.js +0 -32
- package/lib/vs/base/common/range.js +0 -79
- package/lib/vs/base/common/resourceTree.js +0 -185
- package/lib/vs/base/common/resources.js +0 -421
- package/lib/vs/base/common/scanCode.js +0 -1472
- package/lib/vs/base/common/scrollable.js +0 -397
- package/lib/vs/base/common/search.js +0 -55
- package/lib/vs/base/common/sequence.js +0 -64
- package/lib/vs/base/common/severity.js +0 -55
- package/lib/vs/base/common/skipList.js +0 -234
- package/lib/vs/base/common/stopwatch.js +0 -45
- package/lib/vs/base/common/stream.js +0 -418
- package/lib/vs/base/common/strings.js +0 -1283
- package/lib/vs/base/common/styler.js +0 -9
- package/lib/vs/base/common/types.js +0 -296
- package/lib/vs/base/common/uint.js +0 -46
- package/lib/vs/base/common/uri.js +0 -756
- package/lib/vs/base/common/uriIpc.js +0 -154
- package/lib/vs/base/common/uuid.js +0 -70
- package/lib/vs/nls.mock.js +0 -31
- package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
- package/lib/vs/platform/actions/common/actions.js +0 -456
- package/lib/vs/platform/actions/common/menuService.js +0 -194
- package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
- package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
- package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
- package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
- package/lib/vs/platform/contextview/browser/contextView.js +0 -15
- package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
- package/lib/vs/platform/environment/common/argv.js +0 -9
- package/lib/vs/platform/environment/common/environment.js +0 -15
- package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
- package/lib/vs/platform/instantiation/common/extensions.js +0 -26
- package/lib/vs/platform/instantiation/common/graph.js +0 -93
- package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
- package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
- package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
- package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
- package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
- package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
- package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
- package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
- package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
- package/lib/vs/platform/layout/browser/layoutService.js +0 -14
- package/lib/vs/platform/menubar/common/menubar.js +0 -34
- package/lib/vs/platform/registry/common/platform.js +0 -38
- package/lib/vs/platform/theme/browser/checkbox.js +0 -32
- package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
- package/lib/vs/platform/theme/common/styler.js +0 -290
- package/lib/vs/platform/theme/common/theme.js +0 -21
- package/lib/vs/platform/theme/common/themeService.js +0 -176
- package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
- package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.prepareActions = exports.ActionBar = void 0;
|
|
11
|
-
|
|
12
|
-
require("../../../../css!./actionbar");
|
|
13
|
-
|
|
14
|
-
const lifecycle_1 = require("../../../common/lifecycle");
|
|
15
|
-
|
|
16
|
-
const actions_1 = require("../../../common/actions");
|
|
17
|
-
|
|
18
|
-
const DOM = require("../../dom");
|
|
19
|
-
|
|
20
|
-
const types = require("../../../common/types");
|
|
21
|
-
|
|
22
|
-
const keyboardEvent_1 = require("../../keyboardEvent");
|
|
23
|
-
|
|
24
|
-
const event_1 = require("../../../common/event");
|
|
25
|
-
|
|
26
|
-
const actionViewItems_1 = require("./actionViewItems");
|
|
27
|
-
|
|
28
|
-
class ActionBar extends lifecycle_1.Disposable {
|
|
29
|
-
constructor(container, options = {}) {
|
|
30
|
-
var _a, _b, _c;
|
|
31
|
-
|
|
32
|
-
super();
|
|
33
|
-
this._onDidBlur = this._register(new event_1.Emitter());
|
|
34
|
-
this.onDidBlur = this._onDidBlur.event;
|
|
35
|
-
this._onDidCancel = this._register(new event_1.Emitter({
|
|
36
|
-
onFirstListenerAdd: () => this.cancelHasListener = true
|
|
37
|
-
}));
|
|
38
|
-
this.onDidCancel = this._onDidCancel.event;
|
|
39
|
-
this.cancelHasListener = false;
|
|
40
|
-
this._onDidRun = this._register(new event_1.Emitter());
|
|
41
|
-
this.onDidRun = this._onDidRun.event;
|
|
42
|
-
this._onDidBeforeRun = this._register(new event_1.Emitter());
|
|
43
|
-
this.onDidBeforeRun = this._onDidBeforeRun.event;
|
|
44
|
-
this.options = options;
|
|
45
|
-
this._context = (_a = options.context) !== null && _a !== void 0 ? _a : null;
|
|
46
|
-
this._orientation = (_b = this.options.orientation) !== null && _b !== void 0 ? _b : 0
|
|
47
|
-
/* HORIZONTAL */
|
|
48
|
-
;
|
|
49
|
-
this._triggerKeys = (_c = this.options.triggerKeys) !== null && _c !== void 0 ? _c : {
|
|
50
|
-
keys: [3
|
|
51
|
-
/* Enter */
|
|
52
|
-
, 10
|
|
53
|
-
/* Space */
|
|
54
|
-
],
|
|
55
|
-
keyDown: false
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
if (this.options.actionRunner) {
|
|
59
|
-
this._actionRunner = this.options.actionRunner;
|
|
60
|
-
} else {
|
|
61
|
-
this._actionRunner = new actions_1.ActionRunner();
|
|
62
|
-
|
|
63
|
-
this._register(this._actionRunner);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this._register(this._actionRunner.onDidRun(e => this._onDidRun.fire(e)));
|
|
67
|
-
|
|
68
|
-
this._register(this._actionRunner.onDidBeforeRun(e => this._onDidBeforeRun.fire(e)));
|
|
69
|
-
|
|
70
|
-
this._actionIds = [];
|
|
71
|
-
this.viewItems = [];
|
|
72
|
-
this.focusedItem = undefined;
|
|
73
|
-
this.domNode = document.createElement('div');
|
|
74
|
-
this.domNode.className = 'monaco-action-bar';
|
|
75
|
-
|
|
76
|
-
if (options.animated !== false) {
|
|
77
|
-
this.domNode.classList.add('animated');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let previousKeys;
|
|
81
|
-
let nextKeys;
|
|
82
|
-
|
|
83
|
-
switch (this._orientation) {
|
|
84
|
-
case 0
|
|
85
|
-
/* HORIZONTAL */
|
|
86
|
-
:
|
|
87
|
-
previousKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [15
|
|
88
|
-
/* LeftArrow */
|
|
89
|
-
, 16
|
|
90
|
-
/* UpArrow */
|
|
91
|
-
] : [15
|
|
92
|
-
/* LeftArrow */
|
|
93
|
-
];
|
|
94
|
-
nextKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [17
|
|
95
|
-
/* RightArrow */
|
|
96
|
-
, 18
|
|
97
|
-
/* DownArrow */
|
|
98
|
-
] : [17
|
|
99
|
-
/* RightArrow */
|
|
100
|
-
];
|
|
101
|
-
break;
|
|
102
|
-
|
|
103
|
-
case 1
|
|
104
|
-
/* HORIZONTAL_REVERSE */
|
|
105
|
-
:
|
|
106
|
-
previousKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [17
|
|
107
|
-
/* RightArrow */
|
|
108
|
-
, 18
|
|
109
|
-
/* DownArrow */
|
|
110
|
-
] : [17
|
|
111
|
-
/* RightArrow */
|
|
112
|
-
];
|
|
113
|
-
nextKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [15
|
|
114
|
-
/* LeftArrow */
|
|
115
|
-
, 16
|
|
116
|
-
/* UpArrow */
|
|
117
|
-
] : [15
|
|
118
|
-
/* LeftArrow */
|
|
119
|
-
];
|
|
120
|
-
this.domNode.className += ' reverse';
|
|
121
|
-
break;
|
|
122
|
-
|
|
123
|
-
case 2
|
|
124
|
-
/* VERTICAL */
|
|
125
|
-
:
|
|
126
|
-
previousKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [15
|
|
127
|
-
/* LeftArrow */
|
|
128
|
-
, 16
|
|
129
|
-
/* UpArrow */
|
|
130
|
-
] : [16
|
|
131
|
-
/* UpArrow */
|
|
132
|
-
];
|
|
133
|
-
nextKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [17
|
|
134
|
-
/* RightArrow */
|
|
135
|
-
, 18
|
|
136
|
-
/* DownArrow */
|
|
137
|
-
] : [18
|
|
138
|
-
/* DownArrow */
|
|
139
|
-
];
|
|
140
|
-
this.domNode.className += ' vertical';
|
|
141
|
-
break;
|
|
142
|
-
|
|
143
|
-
case 3
|
|
144
|
-
/* VERTICAL_REVERSE */
|
|
145
|
-
:
|
|
146
|
-
previousKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [17
|
|
147
|
-
/* RightArrow */
|
|
148
|
-
, 18
|
|
149
|
-
/* DownArrow */
|
|
150
|
-
] : [18
|
|
151
|
-
/* DownArrow */
|
|
152
|
-
];
|
|
153
|
-
nextKeys = this.options.ignoreOrientationForPreviousAndNextKey ? [15
|
|
154
|
-
/* LeftArrow */
|
|
155
|
-
, 16
|
|
156
|
-
/* UpArrow */
|
|
157
|
-
] : [16
|
|
158
|
-
/* UpArrow */
|
|
159
|
-
];
|
|
160
|
-
this.domNode.className += ' vertical reverse';
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
this._register(DOM.addDisposableListener(this.domNode, DOM.EventType.KEY_DOWN, e => {
|
|
165
|
-
const event = new keyboardEvent_1.StandardKeyboardEvent(e);
|
|
166
|
-
let eventHandled = true;
|
|
167
|
-
|
|
168
|
-
if (previousKeys && (event.equals(previousKeys[0]) || event.equals(previousKeys[1]))) {
|
|
169
|
-
eventHandled = this.focusPrevious();
|
|
170
|
-
} else if (nextKeys && (event.equals(nextKeys[0]) || event.equals(nextKeys[1]))) {
|
|
171
|
-
eventHandled = this.focusNext();
|
|
172
|
-
} else if (event.equals(9
|
|
173
|
-
/* Escape */
|
|
174
|
-
) && this.cancelHasListener) {
|
|
175
|
-
this._onDidCancel.fire();
|
|
176
|
-
} else if (this.isTriggerKeyEvent(event)) {
|
|
177
|
-
// Staying out of the else branch even if not triggered
|
|
178
|
-
if (this._triggerKeys.keyDown) {
|
|
179
|
-
this.doTrigger(event);
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
eventHandled = false;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (eventHandled) {
|
|
186
|
-
event.preventDefault();
|
|
187
|
-
event.stopPropagation();
|
|
188
|
-
}
|
|
189
|
-
}));
|
|
190
|
-
|
|
191
|
-
this._register(DOM.addDisposableListener(this.domNode, DOM.EventType.KEY_UP, e => {
|
|
192
|
-
const event = new keyboardEvent_1.StandardKeyboardEvent(e); // Run action on Enter/Space
|
|
193
|
-
|
|
194
|
-
if (this.isTriggerKeyEvent(event)) {
|
|
195
|
-
if (!this._triggerKeys.keyDown) {
|
|
196
|
-
this.doTrigger(event);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
event.preventDefault();
|
|
200
|
-
event.stopPropagation();
|
|
201
|
-
} // Recompute focused item
|
|
202
|
-
else if (event.equals(2
|
|
203
|
-
/* Tab */
|
|
204
|
-
) || event.equals(1024
|
|
205
|
-
/* Shift */
|
|
206
|
-
| 2
|
|
207
|
-
/* Tab */
|
|
208
|
-
)) {
|
|
209
|
-
this.updateFocusedItem();
|
|
210
|
-
}
|
|
211
|
-
}));
|
|
212
|
-
|
|
213
|
-
this.focusTracker = this._register(DOM.trackFocus(this.domNode));
|
|
214
|
-
|
|
215
|
-
this._register(this.focusTracker.onDidBlur(() => {
|
|
216
|
-
if (DOM.getActiveElement() === this.domNode || !DOM.isAncestor(DOM.getActiveElement(), this.domNode)) {
|
|
217
|
-
this._onDidBlur.fire();
|
|
218
|
-
|
|
219
|
-
this.focusedItem = undefined;
|
|
220
|
-
}
|
|
221
|
-
}));
|
|
222
|
-
|
|
223
|
-
this._register(this.focusTracker.onDidFocus(() => this.updateFocusedItem()));
|
|
224
|
-
|
|
225
|
-
this.actionsList = document.createElement('ul');
|
|
226
|
-
this.actionsList.className = 'actions-container';
|
|
227
|
-
this.actionsList.setAttribute('role', 'toolbar');
|
|
228
|
-
|
|
229
|
-
if (this.options.ariaLabel) {
|
|
230
|
-
this.actionsList.setAttribute('aria-label', this.options.ariaLabel);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
this.domNode.appendChild(this.actionsList);
|
|
234
|
-
container.appendChild(this.domNode);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
setAriaLabel(label) {
|
|
238
|
-
if (label) {
|
|
239
|
-
this.actionsList.setAttribute('aria-label', label);
|
|
240
|
-
} else {
|
|
241
|
-
this.actionsList.removeAttribute('aria-label');
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
isTriggerKeyEvent(event) {
|
|
246
|
-
let ret = false;
|
|
247
|
-
|
|
248
|
-
this._triggerKeys.keys.forEach(keyCode => {
|
|
249
|
-
ret = ret || event.equals(keyCode);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
return ret;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
updateFocusedItem() {
|
|
256
|
-
for (let i = 0; i < this.actionsList.children.length; i++) {
|
|
257
|
-
const elem = this.actionsList.children[i];
|
|
258
|
-
|
|
259
|
-
if (DOM.isAncestor(DOM.getActiveElement(), elem)) {
|
|
260
|
-
this.focusedItem = i;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
get context() {
|
|
267
|
-
return this._context;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
set context(context) {
|
|
271
|
-
this._context = context;
|
|
272
|
-
this.viewItems.forEach(i => i.setActionContext(context));
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
get actionRunner() {
|
|
276
|
-
return this._actionRunner;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
set actionRunner(actionRunner) {
|
|
280
|
-
if (actionRunner) {
|
|
281
|
-
this._actionRunner = actionRunner;
|
|
282
|
-
this.viewItems.forEach(item => item.actionRunner = actionRunner);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
getContainer() {
|
|
287
|
-
return this.domNode;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
hasAction(action) {
|
|
291
|
-
return this._actionIds.includes(action.id);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
push(arg, options = {}) {
|
|
295
|
-
const actions = Array.isArray(arg) ? arg : [arg];
|
|
296
|
-
let index = types.isNumber(options.index) ? options.index : null;
|
|
297
|
-
actions.forEach(action => {
|
|
298
|
-
const actionViewItemElement = document.createElement('li');
|
|
299
|
-
actionViewItemElement.className = 'action-item';
|
|
300
|
-
actionViewItemElement.setAttribute('role', 'presentation'); // Prevent native context menu on actions
|
|
301
|
-
|
|
302
|
-
if (!this.options.allowContextMenu) {
|
|
303
|
-
this._register(DOM.addDisposableListener(actionViewItemElement, DOM.EventType.CONTEXT_MENU, e => {
|
|
304
|
-
DOM.EventHelper.stop(e, true);
|
|
305
|
-
}));
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
let item;
|
|
309
|
-
|
|
310
|
-
if (this.options.actionViewItemProvider) {
|
|
311
|
-
item = this.options.actionViewItemProvider(action);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (!item) {
|
|
315
|
-
item = new actionViewItems_1.ActionViewItem(this.context, action, options);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
item.actionRunner = this._actionRunner;
|
|
319
|
-
item.setActionContext(this.context);
|
|
320
|
-
item.render(actionViewItemElement);
|
|
321
|
-
|
|
322
|
-
if (index === null || index < 0 || index >= this.actionsList.children.length) {
|
|
323
|
-
this.actionsList.appendChild(actionViewItemElement);
|
|
324
|
-
this.viewItems.push(item);
|
|
325
|
-
|
|
326
|
-
this._actionIds.push(action.id);
|
|
327
|
-
} else {
|
|
328
|
-
this.actionsList.insertBefore(actionViewItemElement, this.actionsList.children[index]);
|
|
329
|
-
this.viewItems.splice(index, 0, item);
|
|
330
|
-
|
|
331
|
-
this._actionIds.splice(index, 0, action.id);
|
|
332
|
-
|
|
333
|
-
index++;
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
if (this.focusedItem) {
|
|
338
|
-
// After a clear actions might be re-added to simply toggle some actions. We should preserve focus #97128
|
|
339
|
-
this.focus(this.focusedItem);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
getWidth(index) {
|
|
344
|
-
if (index >= 0 && index < this.actionsList.children.length) {
|
|
345
|
-
const item = this.actionsList.children.item(index);
|
|
346
|
-
|
|
347
|
-
if (item) {
|
|
348
|
-
return item.clientWidth;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return 0;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
getHeight(index) {
|
|
356
|
-
if (index >= 0 && index < this.actionsList.children.length) {
|
|
357
|
-
const item = this.actionsList.children.item(index);
|
|
358
|
-
|
|
359
|
-
if (item) {
|
|
360
|
-
return item.clientHeight;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return 0;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
pull(index) {
|
|
368
|
-
if (index >= 0 && index < this.viewItems.length) {
|
|
369
|
-
this.actionsList.removeChild(this.actionsList.childNodes[index]);
|
|
370
|
-
lifecycle_1.dispose(this.viewItems.splice(index, 1));
|
|
371
|
-
|
|
372
|
-
this._actionIds.splice(index, 1);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
clear() {
|
|
377
|
-
lifecycle_1.dispose(this.viewItems);
|
|
378
|
-
this.viewItems = [];
|
|
379
|
-
this._actionIds = [];
|
|
380
|
-
DOM.clearNode(this.actionsList);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
length() {
|
|
384
|
-
return this.viewItems.length;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
isEmpty() {
|
|
388
|
-
return this.viewItems.length === 0;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
focus(arg) {
|
|
392
|
-
let selectFirst = false;
|
|
393
|
-
let index = undefined;
|
|
394
|
-
|
|
395
|
-
if (arg === undefined) {
|
|
396
|
-
selectFirst = true;
|
|
397
|
-
} else if (typeof arg === 'number') {
|
|
398
|
-
index = arg;
|
|
399
|
-
} else if (typeof arg === 'boolean') {
|
|
400
|
-
selectFirst = arg;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (selectFirst && typeof this.focusedItem === 'undefined') {
|
|
404
|
-
// Focus the first enabled item
|
|
405
|
-
this.focusedItem = -1;
|
|
406
|
-
this.focusNext();
|
|
407
|
-
} else {
|
|
408
|
-
if (index !== undefined) {
|
|
409
|
-
this.focusedItem = index;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
this.updateFocus();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
focusNext() {
|
|
417
|
-
if (typeof this.focusedItem === 'undefined') {
|
|
418
|
-
this.focusedItem = this.viewItems.length - 1;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
const startIndex = this.focusedItem;
|
|
422
|
-
let item;
|
|
423
|
-
|
|
424
|
-
do {
|
|
425
|
-
if (this.options.preventLoopNavigation && this.focusedItem + 1 >= this.viewItems.length) {
|
|
426
|
-
this.focusedItem = startIndex;
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
this.focusedItem = (this.focusedItem + 1) % this.viewItems.length;
|
|
431
|
-
item = this.viewItems[this.focusedItem];
|
|
432
|
-
} while (this.focusedItem !== startIndex && !item.isEnabled());
|
|
433
|
-
|
|
434
|
-
if (this.focusedItem === startIndex && !item.isEnabled()) {
|
|
435
|
-
this.focusedItem = undefined;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
this.updateFocus();
|
|
439
|
-
return true;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
focusPrevious() {
|
|
443
|
-
if (typeof this.focusedItem === 'undefined') {
|
|
444
|
-
this.focusedItem = 0;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
const startIndex = this.focusedItem;
|
|
448
|
-
let item;
|
|
449
|
-
|
|
450
|
-
do {
|
|
451
|
-
this.focusedItem = this.focusedItem - 1;
|
|
452
|
-
|
|
453
|
-
if (this.focusedItem < 0) {
|
|
454
|
-
if (this.options.preventLoopNavigation) {
|
|
455
|
-
this.focusedItem = startIndex;
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
this.focusedItem = this.viewItems.length - 1;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
item = this.viewItems[this.focusedItem];
|
|
463
|
-
} while (this.focusedItem !== startIndex && !item.isEnabled());
|
|
464
|
-
|
|
465
|
-
if (this.focusedItem === startIndex && !item.isEnabled()) {
|
|
466
|
-
this.focusedItem = undefined;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
this.updateFocus(true);
|
|
470
|
-
return true;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
updateFocus(fromRight, preventScroll) {
|
|
474
|
-
if (typeof this.focusedItem === 'undefined') {
|
|
475
|
-
this.actionsList.focus({
|
|
476
|
-
preventScroll
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
for (let i = 0; i < this.viewItems.length; i++) {
|
|
481
|
-
const item = this.viewItems[i];
|
|
482
|
-
const actionViewItem = item;
|
|
483
|
-
|
|
484
|
-
if (i === this.focusedItem) {
|
|
485
|
-
if (types.isFunction(actionViewItem.isEnabled)) {
|
|
486
|
-
if (actionViewItem.isEnabled() && types.isFunction(actionViewItem.focus)) {
|
|
487
|
-
actionViewItem.focus(fromRight);
|
|
488
|
-
} else {
|
|
489
|
-
this.actionsList.focus({
|
|
490
|
-
preventScroll
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
} else {
|
|
495
|
-
if (types.isFunction(actionViewItem.blur)) {
|
|
496
|
-
actionViewItem.blur();
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
doTrigger(event) {
|
|
503
|
-
if (typeof this.focusedItem === 'undefined') {
|
|
504
|
-
return; //nothing to focus
|
|
505
|
-
} // trigger action
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
const actionViewItem = this.viewItems[this.focusedItem];
|
|
509
|
-
|
|
510
|
-
if (actionViewItem instanceof actionViewItems_1.BaseActionViewItem) {
|
|
511
|
-
const context = actionViewItem._context === null || actionViewItem._context === undefined ? event : actionViewItem._context;
|
|
512
|
-
this.run(actionViewItem._action, context);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
run(action, context) {
|
|
517
|
-
return this._actionRunner.run(action, context);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
dispose() {
|
|
521
|
-
lifecycle_1.dispose(this.viewItems);
|
|
522
|
-
this.viewItems = [];
|
|
523
|
-
this._actionIds = [];
|
|
524
|
-
this.getContainer().remove();
|
|
525
|
-
super.dispose();
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
exports.ActionBar = ActionBar;
|
|
531
|
-
|
|
532
|
-
function prepareActions(actions) {
|
|
533
|
-
if (!actions.length) {
|
|
534
|
-
return actions;
|
|
535
|
-
} // Clean up leading separators
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
let firstIndexOfAction = -1;
|
|
539
|
-
|
|
540
|
-
for (let i = 0; i < actions.length; i++) {
|
|
541
|
-
if (actions[i].id === actions_1.Separator.ID) {
|
|
542
|
-
continue;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
firstIndexOfAction = i;
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
if (firstIndexOfAction === -1) {
|
|
550
|
-
return [];
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
actions = actions.slice(firstIndexOfAction); // Clean up trailing separators
|
|
554
|
-
|
|
555
|
-
for (let h = actions.length - 1; h >= 0; h--) {
|
|
556
|
-
const isSeparator = actions[h].id === actions_1.Separator.ID;
|
|
557
|
-
|
|
558
|
-
if (isSeparator) {
|
|
559
|
-
actions.splice(h, 1);
|
|
560
|
-
} else {
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
} // Clean up separator duplicates
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
let foundAction = false;
|
|
567
|
-
|
|
568
|
-
for (let k = actions.length - 1; k >= 0; k--) {
|
|
569
|
-
const isSeparator = actions[k].id === actions_1.Separator.ID;
|
|
570
|
-
|
|
571
|
-
if (isSeparator && !foundAction) {
|
|
572
|
-
actions.splice(k, 1);
|
|
573
|
-
} else if (!isSeparator) {
|
|
574
|
-
foundAction = true;
|
|
575
|
-
} else if (isSeparator) {
|
|
576
|
-
foundAction = false;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
return actions;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
exports.prepareActions = prepareActions;
|