tabby-quick-buttons 0.1.0 → 1.0.1
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 +5 -3
- package/dist/index.js +24 -3
- package/dist/quickButtons.component.js +272 -28
- package/dist/quickButtons.view.js +153 -72
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Tabby Quick Buttons
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Source code and issue tracker are available on [GitHub](https://github.com/vzpd/tabby-quick-buttons).
|
|
4
|
+
|
|
5
|
+
Hover over the floating button in a Tabby terminal to open the command panel. The button starts in the lower-right corner. Drag it anywhere in the window to save a new position. Click the **Quick Buttons** icon in the Tabby toolbar to keep the panel open.
|
|
4
6
|
|
|
5
7
|
- **Shared** groups are available in every terminal. Add commands directly or organize them in nested groups.
|
|
6
8
|
- **Current profile** groups are available only in the matching Tabby profile. Renaming the profile keeps the association. Temporary connections without a profile ID can use shared groups.
|
|
7
|
-
- Select **Manage** to add, edit, or delete commands and groups
|
|
9
|
+
- Select **Manage** to add, edit, or delete commands and groups. Drag a command between other commands to reorder it, or onto a group heading to move it. Dropping onto **Shared** or **Current profile** moves it to the root of that scope and changes where it is available. Select **Done** to return to hover mode.
|
|
8
10
|
- Each command has a display alias and a single line of terminal text. **Press Enter after inserting** is enabled by default. Turn it off to insert the command for review or editing.
|
|
9
11
|
|
|
10
12
|
Use shortcuts at an empty shell prompt. The plugin stores commands in Tabby's configuration. Keep passwords and tokens out of command text.
|
|
@@ -21,7 +23,7 @@ npm pack
|
|
|
21
23
|
In Tabby, go to **Settings → Plugins** and open the plugin directory. Install the package from that directory using the path to the generated archive:
|
|
22
24
|
|
|
23
25
|
```sh
|
|
24
|
-
npm install /absolute/path/to/tabby-quick-buttons-0.1.
|
|
26
|
+
npm install /absolute/path/to/tabby-quick-buttons-1.0.1.tgz
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
Quit and reopen Tabby, then open a terminal. The plugin uses the Angular and terminal APIs bundled with Tabby.
|
package/dist/index.js
CHANGED
|
@@ -9,13 +9,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
const common_1 = require("@angular/common");
|
|
10
10
|
const core_1 = require("@angular/core");
|
|
11
11
|
const tabby_core_1 = require("tabby-core");
|
|
12
|
+
const rxjs_1 = require("rxjs");
|
|
12
13
|
const quickButtons_component_1 = require("./quickButtons.component");
|
|
13
14
|
class QuickButtonsConfigProvider extends tabby_core_1.ConfigProvider {
|
|
14
15
|
defaults = {
|
|
15
16
|
quickButtons: { scopes: [] },
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
let QuickButtonsToolbar = class QuickButtonsToolbar extends tabby_core_1.ToolbarButtonProvider {
|
|
20
|
+
opened = new rxjs_1.Subject();
|
|
21
|
+
provide() {
|
|
22
|
+
return [{
|
|
23
|
+
title: 'Quick Buttons',
|
|
24
|
+
icon: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m4 7 5 5-5 5m8 0h7"/></svg>',
|
|
25
|
+
click: () => this.opened.next(),
|
|
26
|
+
}];
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
QuickButtonsToolbar = __decorate([
|
|
30
|
+
(0, core_1.Injectable)()
|
|
31
|
+
], QuickButtonsToolbar);
|
|
32
|
+
function mountQuickButtons(app, injector, document, toolbar) {
|
|
19
33
|
let component;
|
|
20
34
|
return () => {
|
|
21
35
|
if (component) {
|
|
@@ -25,7 +39,12 @@ function mountQuickButtons(app, injector, document) {
|
|
|
25
39
|
document.body.append(host);
|
|
26
40
|
component = (0, core_1.createComponent)(quickButtons_component_1.QuickButtonsComponent, { environmentInjector: injector, hostElement: host });
|
|
27
41
|
app.attachView(component.hostView);
|
|
28
|
-
|
|
42
|
+
const instance = component.instance;
|
|
43
|
+
const launch = toolbar.opened.subscribe(() => instance.togglePinned());
|
|
44
|
+
component.onDestroy(() => {
|
|
45
|
+
launch.unsubscribe();
|
|
46
|
+
host.remove();
|
|
47
|
+
});
|
|
29
48
|
};
|
|
30
49
|
}
|
|
31
50
|
let QuickButtonsPlugin = class QuickButtonsPlugin {
|
|
@@ -36,10 +55,12 @@ QuickButtonsPlugin = __decorate([
|
|
|
36
55
|
declarations: [quickButtons_component_1.QuickButtonsComponent],
|
|
37
56
|
providers: [
|
|
38
57
|
{ provide: tabby_core_1.ConfigProvider, useClass: QuickButtonsConfigProvider, multi: true },
|
|
58
|
+
QuickButtonsToolbar,
|
|
59
|
+
{ provide: tabby_core_1.ToolbarButtonProvider, useExisting: QuickButtonsToolbar, multi: true },
|
|
39
60
|
{
|
|
40
61
|
provide: core_1.APP_BOOTSTRAP_LISTENER,
|
|
41
62
|
useFactory: mountQuickButtons,
|
|
42
|
-
deps: [core_1.ApplicationRef, core_1.EnvironmentInjector, common_1.DOCUMENT],
|
|
63
|
+
deps: [core_1.ApplicationRef, core_1.EnvironmentInjector, common_1.DOCUMENT, QuickButtonsToolbar],
|
|
43
64
|
multi: true,
|
|
44
65
|
},
|
|
45
66
|
],
|
|
@@ -15,19 +15,35 @@ const tabby_core_1 = require("tabby-core");
|
|
|
15
15
|
const tabby_terminal_1 = require("tabby-terminal");
|
|
16
16
|
const quickButtons_view_1 = require("./quickButtons.view");
|
|
17
17
|
const invalidCommandCharacters = /[\x00-\x1f\x7f-\x9f]/;
|
|
18
|
+
const ballSize = 52;
|
|
19
|
+
const edge = 8;
|
|
20
|
+
const positionKey = 'tabby-quick-buttons.floating-position';
|
|
21
|
+
const commandDragType = 'application/x-tabby-quick-button';
|
|
18
22
|
let QuickButtonsComponent = class QuickButtonsComponent {
|
|
19
23
|
app;
|
|
20
24
|
config;
|
|
25
|
+
notifications;
|
|
21
26
|
target = null;
|
|
22
27
|
scopes = [];
|
|
23
28
|
managing = false;
|
|
24
29
|
editor = null;
|
|
25
30
|
busy = false;
|
|
26
31
|
error = '';
|
|
32
|
+
dragged = null;
|
|
33
|
+
dropTarget = null;
|
|
34
|
+
movingBall = false;
|
|
35
|
+
pinned = false;
|
|
36
|
+
ballPosition = this.loadBallPosition();
|
|
37
|
+
ballDrag = null;
|
|
38
|
+
suppressBallClick = false;
|
|
39
|
+
viewport = { width: window.innerWidth, height: window.innerHeight };
|
|
27
40
|
panelContext;
|
|
28
|
-
|
|
41
|
+
groupKeys = new WeakMap();
|
|
42
|
+
trackEntry = (_index, entry) => entry.kind === 'group' ? this.groupKey(entry) : entry;
|
|
43
|
+
constructor(app, config, notifications) {
|
|
29
44
|
this.app = app;
|
|
30
45
|
this.config = config;
|
|
46
|
+
this.notifications = notifications;
|
|
31
47
|
}
|
|
32
48
|
get activeTerminal() {
|
|
33
49
|
const tab = this.app.activeTab;
|
|
@@ -40,9 +56,113 @@ let QuickButtonsComponent = class QuickButtonsComponent {
|
|
|
40
56
|
get settings() {
|
|
41
57
|
return this.config.store.quickButtons;
|
|
42
58
|
}
|
|
59
|
+
get layout() {
|
|
60
|
+
const { width, height } = this.viewport;
|
|
61
|
+
const x = this.clamp(this.ballPosition?.x ?? width - ballSize - 24, width - ballSize - edge);
|
|
62
|
+
const y = this.clamp(this.ballPosition?.y ?? height - ballSize - 16, height - ballSize - edge);
|
|
63
|
+
const below = y + ballSize / 2 < height / 2;
|
|
64
|
+
const anchorRight = x + ballSize / 2 >= width / 2;
|
|
65
|
+
const panelWidth = Math.min(380, anchorRight ? x + ballSize - edge : width - x - edge);
|
|
66
|
+
const panelHeight = (below ? height - y : y + ballSize) - edge;
|
|
67
|
+
return { x, y, panelWidth, panelHeight, panelOffset: anchorRight ? ballSize - panelWidth : 0, below, anchorRight };
|
|
68
|
+
}
|
|
69
|
+
updateViewport() {
|
|
70
|
+
this.viewport = { width: window.innerWidth, height: window.innerHeight };
|
|
71
|
+
}
|
|
72
|
+
clamp(value, limit) {
|
|
73
|
+
return Math.max(edge, Math.min(value, limit));
|
|
74
|
+
}
|
|
75
|
+
loadBallPosition() {
|
|
76
|
+
try {
|
|
77
|
+
const position = JSON.parse(window.localStorage.getItem(positionKey) ?? 'null');
|
|
78
|
+
return Number.isFinite(position?.x) && Number.isFinite(position?.y) ? position : null;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
startBallDrag(event) {
|
|
85
|
+
if (event.button !== 0 || !event.isPrimary) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.suppressBallClick = false;
|
|
89
|
+
const { x, y } = this.layout;
|
|
90
|
+
const listeners = new AbortController();
|
|
91
|
+
this.ballDrag = {
|
|
92
|
+
pointerId: event.pointerId,
|
|
93
|
+
pointer: { x: event.clientX, y: event.clientY },
|
|
94
|
+
origin: { x, y },
|
|
95
|
+
listeners,
|
|
96
|
+
};
|
|
97
|
+
const { signal } = listeners;
|
|
98
|
+
window.addEventListener('pointermove', move => this.moveBall(move), { signal });
|
|
99
|
+
window.addEventListener('pointerup', up => this.finishBallDrag(up), { signal });
|
|
100
|
+
window.addEventListener('pointercancel', cancel => this.finishBallDrag(cancel), { signal });
|
|
101
|
+
const button = event.currentTarget;
|
|
102
|
+
button.setPointerCapture(event.pointerId);
|
|
103
|
+
}
|
|
104
|
+
moveBall(event) {
|
|
105
|
+
const drag = this.ballDrag;
|
|
106
|
+
if (!drag || drag.pointerId !== event.pointerId) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const dx = event.clientX - drag.pointer.x;
|
|
110
|
+
const dy = event.clientY - drag.pointer.y;
|
|
111
|
+
if (!this.movingBall && Math.hypot(dx, dy) < 5) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.movingBall = true;
|
|
115
|
+
this.ballPosition = {
|
|
116
|
+
x: this.clamp(drag.origin.x + dx, this.viewport.width - ballSize - edge),
|
|
117
|
+
y: this.clamp(drag.origin.y + dy, this.viewport.height - ballSize - edge),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
finishBallDrag(event) {
|
|
121
|
+
if (this.ballDrag?.pointerId !== event.pointerId) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.ballDrag.listeners.abort();
|
|
125
|
+
this.ballDrag = null;
|
|
126
|
+
if (!this.movingBall) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.movingBall = false;
|
|
130
|
+
this.suppressBallClick = true;
|
|
131
|
+
if (!this.pinned && !this.managing) {
|
|
132
|
+
this.close();
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
window.localStorage.setItem(positionKey, JSON.stringify(this.ballPosition));
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
this.notifications.info('Quick Buttons moved. This window could not save its position.');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
clickBall(event) {
|
|
142
|
+
if (event.detail && this.suppressBallClick) {
|
|
143
|
+
this.suppressBallClick = false;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.togglePinned();
|
|
147
|
+
}
|
|
148
|
+
togglePinned() {
|
|
149
|
+
if (!this.activeTerminal) {
|
|
150
|
+
this.notifications.info('Open a terminal to use Quick Buttons.');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (this.busy) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (this.pinned || this.managing) {
|
|
157
|
+
this.close();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.open();
|
|
161
|
+
this.pinned = true;
|
|
162
|
+
}
|
|
43
163
|
open() {
|
|
44
164
|
const terminal = this.activeTerminal;
|
|
45
|
-
if (!terminal || this.expanded || this.busy) {
|
|
165
|
+
if (!terminal || this.expanded || this.busy || this.movingBall) {
|
|
46
166
|
return;
|
|
47
167
|
}
|
|
48
168
|
this.target = terminal;
|
|
@@ -65,14 +185,19 @@ let QuickButtonsComponent = class QuickButtonsComponent {
|
|
|
65
185
|
this.panelContext?.unsubscribe();
|
|
66
186
|
this.target = null;
|
|
67
187
|
this.managing = false;
|
|
188
|
+
this.pinned = false;
|
|
68
189
|
this.editor = null;
|
|
69
190
|
this.error = '';
|
|
191
|
+
this.endCommandDrag();
|
|
192
|
+
this.ballDrag?.listeners.abort();
|
|
193
|
+
this.ballDrag = null;
|
|
194
|
+
this.movingBall = false;
|
|
70
195
|
}
|
|
71
196
|
ngOnDestroy() {
|
|
72
|
-
this.
|
|
197
|
+
this.close();
|
|
73
198
|
}
|
|
74
199
|
leave() {
|
|
75
|
-
if (!this.managing) {
|
|
200
|
+
if (!this.managing && !this.pinned && !this.ballDrag) {
|
|
76
201
|
this.close();
|
|
77
202
|
}
|
|
78
203
|
}
|
|
@@ -109,6 +234,80 @@ let QuickButtonsComponent = class QuickButtonsComponent {
|
|
|
109
234
|
this.editor = null;
|
|
110
235
|
this.error = '';
|
|
111
236
|
}
|
|
237
|
+
startCommandDrag(event, scope, parentPath, entries, index) {
|
|
238
|
+
if (!this.managing || this.editor || this.busy || !event.dataTransfer) {
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
this.error = '';
|
|
243
|
+
this.dragged = { scope, parentPath, entries, index };
|
|
244
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
245
|
+
event.dataTransfer.setData(commandDragType, 'command');
|
|
246
|
+
}
|
|
247
|
+
dragOver(event, entries, rowIndex) {
|
|
248
|
+
const position = this.dropPosition(event, entries, rowIndex);
|
|
249
|
+
this.dropTarget = position ?? null;
|
|
250
|
+
if (!position || !event.dataTransfer) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
event.dataTransfer.dropEffect = 'move';
|
|
255
|
+
}
|
|
256
|
+
dragLeave(event, entries, rowIndex) {
|
|
257
|
+
const target = event.currentTarget;
|
|
258
|
+
if (this.dropTarget?.entries === entries && this.dropTarget.rowIndex === rowIndex &&
|
|
259
|
+
!target.contains(event.relatedTarget)) {
|
|
260
|
+
this.dropTarget = null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
dropPosition(event, entries, rowIndex) {
|
|
264
|
+
const drag = this.dragged;
|
|
265
|
+
if (!drag) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
let after = false;
|
|
269
|
+
if (rowIndex !== undefined) {
|
|
270
|
+
const row = event.currentTarget.getBoundingClientRect();
|
|
271
|
+
after = event.clientY >= row.top + row.height / 2;
|
|
272
|
+
}
|
|
273
|
+
const insertAt = rowIndex === undefined ? entries.length : rowIndex + Number(after);
|
|
274
|
+
if (drag.entries === entries && (rowIndex === undefined || insertAt === drag.index || insertAt === drag.index + 1)) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
return { entries, rowIndex, after, insertAt };
|
|
278
|
+
}
|
|
279
|
+
endCommandDrag() {
|
|
280
|
+
this.dragged = null;
|
|
281
|
+
this.dropTarget = null;
|
|
282
|
+
}
|
|
283
|
+
async dropCommand(event, scope, path, entries, rowIndex) {
|
|
284
|
+
const drag = this.dragged;
|
|
285
|
+
const position = this.dropPosition(event, entries, rowIndex);
|
|
286
|
+
if (!drag || !position || event.dataTransfer?.getData(commandDragType) !== 'command') {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
event.preventDefault();
|
|
290
|
+
this.endCommandDrag();
|
|
291
|
+
if (!this.managing || !this.expanded || this.editor || this.busy) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const source = this.copyScope(drag.scope);
|
|
295
|
+
const destination = drag.scope === scope ? source : this.copyScope(scope);
|
|
296
|
+
const from = this.entriesAt(source.entries, drag.parentPath);
|
|
297
|
+
const to = this.entriesAt(destination.entries, path);
|
|
298
|
+
const command = from?.[drag.index];
|
|
299
|
+
if (!from || !to || command?.kind !== 'command') {
|
|
300
|
+
this.error = 'The command or group is missing. Start the move again.';
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const insertAt = position.insertAt - Number(from === to && drag.index < position.insertAt);
|
|
304
|
+
from.splice(drag.index, 1);
|
|
305
|
+
to.splice(insertAt, 0, command);
|
|
306
|
+
const changes = destination === source
|
|
307
|
+
? new Map([[scope, source]])
|
|
308
|
+
: new Map([[drag.scope, source], [scope, destination]]);
|
|
309
|
+
await this.persist(changes);
|
|
310
|
+
}
|
|
112
311
|
async save() {
|
|
113
312
|
const editor = this.editor;
|
|
114
313
|
if (!editor || this.busy) {
|
|
@@ -120,41 +319,79 @@ let QuickButtonsComponent = class QuickButtonsComponent {
|
|
|
120
319
|
this.error = entry.kind === 'group' ? 'Enter a group name.' : 'Enter an alias and a single line of terminal text.';
|
|
121
320
|
return;
|
|
122
321
|
}
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.refreshScopes();
|
|
128
|
-
this.editor = null;
|
|
129
|
-
this.error = 'Shortcuts changed elsewhere. Start the edit again.';
|
|
322
|
+
const updated = this.copyScope(scope);
|
|
323
|
+
const entries = this.entriesAt(updated.entries, parentPath);
|
|
324
|
+
if (!entries) {
|
|
325
|
+
this.error = 'The original group is missing. Start the edit again.';
|
|
130
326
|
return;
|
|
131
327
|
}
|
|
132
|
-
const updated = { profileId: scope.profileId, entries: structuredClone(scope.entries) };
|
|
133
|
-
let entries = updated.entries;
|
|
134
|
-
for (const groupIndex of parentPath) {
|
|
135
|
-
const group = entries[groupIndex];
|
|
136
|
-
if (group?.kind !== 'group') {
|
|
137
|
-
this.error = 'The original group is missing. Start the edit again.';
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
entries = group.entries;
|
|
141
|
-
}
|
|
142
328
|
if (deleting && index !== undefined) {
|
|
143
329
|
entries.splice(index, 1);
|
|
144
330
|
}
|
|
145
331
|
else {
|
|
146
|
-
const
|
|
332
|
+
const title = entry.title.trim();
|
|
147
333
|
if (index === undefined) {
|
|
148
|
-
entries.push(
|
|
334
|
+
entries.push({ ...entry, title });
|
|
149
335
|
}
|
|
150
336
|
else {
|
|
151
|
-
entries[index]
|
|
337
|
+
const existing = entries[index];
|
|
338
|
+
if (existing.kind === 'group') {
|
|
339
|
+
existing.title = title;
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
entries[index] = { ...entry, title };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
await this.persist(new Map([[scope, updated]]));
|
|
347
|
+
}
|
|
348
|
+
copyScope(scope) {
|
|
349
|
+
return { profileId: scope.profileId, entries: this.copyEntries(scope.entries) };
|
|
350
|
+
}
|
|
351
|
+
copyEntries(entries) {
|
|
352
|
+
return entries.map(entry => {
|
|
353
|
+
if (entry.kind === 'command') {
|
|
354
|
+
return entry;
|
|
355
|
+
}
|
|
356
|
+
const group = { ...entry, entries: this.copyEntries(entry.entries) };
|
|
357
|
+
this.groupKeys.set(group, this.groupKey(entry));
|
|
358
|
+
return group;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
groupKey(group) {
|
|
362
|
+
let key = this.groupKeys.get(group);
|
|
363
|
+
if (!key) {
|
|
364
|
+
key = Symbol();
|
|
365
|
+
this.groupKeys.set(group, key);
|
|
366
|
+
}
|
|
367
|
+
return key;
|
|
368
|
+
}
|
|
369
|
+
entriesAt(entries, path) {
|
|
370
|
+
for (const index of path) {
|
|
371
|
+
const group = entries[index];
|
|
372
|
+
if (group?.kind !== 'group') {
|
|
373
|
+
return undefined;
|
|
152
374
|
}
|
|
375
|
+
entries = group.entries;
|
|
153
376
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
377
|
+
return entries;
|
|
378
|
+
}
|
|
379
|
+
async persist(changes) {
|
|
380
|
+
const settings = this.settings;
|
|
381
|
+
const previous = settings.scopes;
|
|
382
|
+
for (const scope of changes.keys()) {
|
|
383
|
+
if (previous.find(item => item.profileId === scope.profileId) !== scope.saved) {
|
|
384
|
+
this.refreshScopes();
|
|
385
|
+
this.editor = null;
|
|
386
|
+
this.error = 'Shortcuts changed elsewhere. Try again.';
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
157
389
|
}
|
|
390
|
+
const updated = [...changes.values()];
|
|
391
|
+
const next = [
|
|
392
|
+
...previous.filter(item => !updated.some(scope => scope.profileId === item.profileId)),
|
|
393
|
+
...updated.filter(scope => scope.entries.length),
|
|
394
|
+
];
|
|
158
395
|
this.busy = true;
|
|
159
396
|
this.error = '';
|
|
160
397
|
settings.scopes = next;
|
|
@@ -184,7 +421,13 @@ let QuickButtonsComponent = class QuickButtonsComponent {
|
|
|
184
421
|
return { ...scope, saved, entries: saved?.entries ?? [] };
|
|
185
422
|
});
|
|
186
423
|
}
|
|
424
|
+
trackScope(_index, scope) {
|
|
425
|
+
return scope.profileId;
|
|
426
|
+
}
|
|
187
427
|
};
|
|
428
|
+
__decorate([
|
|
429
|
+
(0, core_1.HostListener)('window:resize')
|
|
430
|
+
], QuickButtonsComponent.prototype, "updateViewport", null);
|
|
188
431
|
QuickButtonsComponent = __decorate([
|
|
189
432
|
(0, core_1.Component)({
|
|
190
433
|
selector: 'tabby-quick-buttons',
|
|
@@ -192,6 +435,7 @@ QuickButtonsComponent = __decorate([
|
|
|
192
435
|
styles: [quickButtons_view_1.styles],
|
|
193
436
|
}),
|
|
194
437
|
__param(0, (0, core_1.Inject)(tabby_core_1.AppService)),
|
|
195
|
-
__param(1, (0, core_1.Inject)(tabby_core_1.ConfigService))
|
|
438
|
+
__param(1, (0, core_1.Inject)(tabby_core_1.ConfigService)),
|
|
439
|
+
__param(2, (0, core_1.Inject)(tabby_core_1.NotificationsService))
|
|
196
440
|
], QuickButtonsComponent);
|
|
197
441
|
exports.QuickButtonsComponent = QuickButtonsComponent;
|
|
@@ -2,23 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.styles = exports.template = void 0;
|
|
4
4
|
exports.template = `
|
|
5
|
-
<div class="dock" *ngIf="activeTerminal"
|
|
5
|
+
<div class="dock" *ngIf="activeTerminal && layout as position"
|
|
6
|
+
[style.left.px]="position.x" [style.top.px]="position.y"
|
|
6
7
|
(pointerenter)="open()" (pointerleave)="leave()"
|
|
7
8
|
(keydown.escape)="$event.stopPropagation(); close()">
|
|
8
|
-
<button type="button" class="ball btn btn-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
<button type="button" class="ball btn btn-primary" [class.moving]="movingBall"
|
|
10
|
+
[class.integrated]="expanded && !movingBall" aria-label="Quick Buttons"
|
|
11
|
+
title="Quick Buttons · Drag to move" [attr.aria-expanded]="expanded && !movingBall"
|
|
12
|
+
(pointerdown)="startBallDrag($event)"
|
|
13
|
+
(lostpointercapture)="finishBallDrag($event)" (click)="clickBall($event)">
|
|
14
|
+
<svg viewBox="0 0 24 24" width="25" height="25" fill="none" stroke="currentColor" stroke-width="2"
|
|
15
|
+
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 7 5 5-5 5m8 0h7"/></svg>
|
|
11
16
|
</button>
|
|
12
17
|
|
|
13
|
-
<div class="panel-position" *ngIf="expanded"
|
|
14
|
-
|
|
18
|
+
<div class="panel-position" *ngIf="expanded && !movingBall" [class.below]="position.below"
|
|
19
|
+
[class.anchor-right]="position.anchorRight"
|
|
20
|
+
[style.left.px]="position.panelOffset" [style.width.px]="position.panelWidth">
|
|
21
|
+
<section class="panel" aria-label="Quick commands panel" [style.max-height.px]="position.panelHeight">
|
|
15
22
|
<header class="panel-header">
|
|
16
|
-
<strong>Quick
|
|
17
|
-
<
|
|
18
|
-
|
|
23
|
+
<strong>Quick Buttons</strong>
|
|
24
|
+
<div *ngIf="!managing" class="actions">
|
|
25
|
+
<button type="button" class="btn btn-sm btn-outline-secondary"
|
|
26
|
+
(click)="managing = true">Manage</button>
|
|
27
|
+
<button type="button" class="btn btn-sm btn-outline-secondary" aria-label="Close Quick Buttons"
|
|
28
|
+
(click)="close()">×</button>
|
|
29
|
+
</div>
|
|
19
30
|
<button *ngIf="managing" type="button" class="btn btn-sm btn-outline-secondary"
|
|
20
31
|
[disabled]="busy" (click)="close()">Done</button>
|
|
21
32
|
</header>
|
|
33
|
+
<p *ngIf="managing && !editor" class="move-hint" aria-live="polite">
|
|
34
|
+
{{ busy ? 'Saving shortcuts…' : 'Drag between commands to reorder, or onto a group to move.' }}
|
|
35
|
+
</p>
|
|
22
36
|
|
|
23
37
|
<form *ngIf="editor as draft" class="editor" (submit)="$event.preventDefault(); save()">
|
|
24
38
|
<ng-container *ngIf="!draft.deleting; else deletePrompt">
|
|
@@ -57,8 +71,13 @@ exports.template = `
|
|
|
57
71
|
<p class="error text-danger" *ngIf="error" role="alert">{{ error }}</p>
|
|
58
72
|
|
|
59
73
|
<div class="scope-list">
|
|
60
|
-
<section class="scope" *ngFor="let scope of scopes">
|
|
61
|
-
<div class="row-heading"
|
|
74
|
+
<section class="scope" *ngFor="let scope of scopes; trackBy: trackScope">
|
|
75
|
+
<div class="row-heading"
|
|
76
|
+
[class.drop-ready]="dragged && dragged.entries !== scope.entries"
|
|
77
|
+
[class.drop-active]="dropTarget?.entries === scope.entries && dropTarget?.rowIndex === undefined"
|
|
78
|
+
(dragover)="dragOver($event, scope.entries)"
|
|
79
|
+
(dragleave)="dragLeave($event, scope.entries)"
|
|
80
|
+
(drop)="dropCommand($event, scope, [], scope.entries)">
|
|
62
81
|
<strong class="scope-title">{{ scope.title }}</strong>
|
|
63
82
|
<span class="scope-tag" *ngIf="scope.profileId !== null">Current profile</span>
|
|
64
83
|
</div>
|
|
@@ -82,73 +101,101 @@ exports.template = `
|
|
|
82
101
|
[disabled]="editor || busy" (click)="add(scope, path, 'group')">Add group</button>
|
|
83
102
|
</div>
|
|
84
103
|
<p *ngIf="!entries.length && !managing" class="empty">No commands yet</p>
|
|
85
|
-
<div
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
<
|
|
104
|
+
<div class="entries" [class.managing]="managing">
|
|
105
|
+
<div *ngFor="let entry of entries; let index = index; trackBy: trackEntry"
|
|
106
|
+
class="entry" [class.is-group]="entry.kind === 'group'">
|
|
107
|
+
<ng-container *ngIf="entry.kind === 'group'; else command">
|
|
108
|
+
<details open>
|
|
109
|
+
<summary [class.drop-ready]="dragged && dragged.entries !== entry.entries"
|
|
110
|
+
[class.drop-active]="dropTarget?.entries === entry.entries && dropTarget?.rowIndex === undefined"
|
|
111
|
+
(dragover)="dragOver($event, entry.entries)"
|
|
112
|
+
(dragleave)="dragLeave($event, entry.entries)"
|
|
113
|
+
(drop)="dropCommand($event, scope, path.concat(index), entry.entries)">
|
|
114
|
+
<span class="group-title">{{ entry.title }}</span>
|
|
115
|
+
<span class="actions group-controls" *ngIf="managing">
|
|
116
|
+
<ng-container *ngTemplateOutlet="editActions"></ng-container>
|
|
117
|
+
</span>
|
|
118
|
+
</summary>
|
|
119
|
+
<div class="nested">
|
|
120
|
+
<ng-container *ngTemplateOutlet="entryList; context: {
|
|
121
|
+
$implicit: entry.entries, scope: scope, path: path.concat(index)
|
|
122
|
+
}"></ng-container>
|
|
123
|
+
</div>
|
|
124
|
+
</details>
|
|
125
|
+
</ng-container>
|
|
126
|
+
<ng-template #command>
|
|
127
|
+
<div class="command-row"
|
|
128
|
+
[class.drop-before]="dropTarget?.entries === entries && dropTarget?.rowIndex === index && !dropTarget?.after"
|
|
129
|
+
[class.drop-after]="dropTarget?.entries === entries && dropTarget?.rowIndex === index && dropTarget?.after"
|
|
130
|
+
(dragover)="dragOver($event, entries, index)"
|
|
131
|
+
(dragleave)="dragLeave($event, entries, index)"
|
|
132
|
+
(drop)="dropCommand($event, scope, path, entries, index)">
|
|
133
|
+
<span class="command-drag" *ngIf="managing" [attr.draggable]="!editor && !busy"
|
|
134
|
+
(dragstart)="startCommandDrag($event, scope, path, entries, index)"
|
|
135
|
+
(dragend)="endCommandDrag()" title="Drag to reorder or move">
|
|
136
|
+
<span aria-hidden="true" class="grip">⠿</span>
|
|
137
|
+
<span class="command-alias">{{ entry.title }}</span>
|
|
138
|
+
</span>
|
|
139
|
+
<button *ngIf="!managing" type="button" class="command-run"
|
|
140
|
+
[disabled]="!target?.session?.open" (click)="execute(entry, scope)">
|
|
141
|
+
<span class="command-alias">{{ entry.title }}</span>
|
|
142
|
+
</button>
|
|
143
|
+
<div class="actions" *ngIf="managing">
|
|
91
144
|
<ng-container *ngTemplateOutlet="editActions"></ng-container>
|
|
92
145
|
</div>
|
|
93
|
-
<ng-container *ngTemplateOutlet="entryList; context: {
|
|
94
|
-
$implicit: entry.entries, scope: scope, path: path.concat(index)
|
|
95
|
-
}"></ng-container>
|
|
96
146
|
</div>
|
|
97
|
-
</
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
<button
|
|
103
|
-
[disabled]="
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<div class="actions" *ngIf="managing">
|
|
108
|
-
<ng-container *ngTemplateOutlet="editActions"></ng-container>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
</ng-template>
|
|
112
|
-
<ng-template #editActions>
|
|
113
|
-
<button type="button" class="btn btn-sm btn-outline-secondary"
|
|
114
|
-
[disabled]="editor || busy" [attr.aria-label]="'Edit ' + entry.title"
|
|
115
|
-
(click)="edit(scope, path, index, entry)">Edit</button>
|
|
116
|
-
<button type="button" class="btn btn-sm btn-outline-danger"
|
|
117
|
-
[disabled]="editor || busy" [attr.aria-label]="'Delete ' + entry.title"
|
|
118
|
-
(click)="edit(scope, path, index, entry, true)">Delete</button>
|
|
119
|
-
</ng-template>
|
|
147
|
+
</ng-template>
|
|
148
|
+
<ng-template #editActions>
|
|
149
|
+
<button type="button" class="btn btn-sm btn-outline-secondary"
|
|
150
|
+
[disabled]="editor || busy" [attr.aria-label]="'Edit ' + entry.title"
|
|
151
|
+
(click)="edit(scope, path, index, entry)">Edit</button>
|
|
152
|
+
<button type="button" class="btn btn-sm btn-outline-danger"
|
|
153
|
+
[disabled]="editor || busy" [attr.aria-label]="'Delete ' + entry.title"
|
|
154
|
+
(click)="edit(scope, path, index, entry, true)">Delete</button>
|
|
155
|
+
</ng-template>
|
|
156
|
+
</div>
|
|
120
157
|
</div>
|
|
121
158
|
</ng-template>
|
|
122
159
|
`;
|
|
123
160
|
exports.styles = `
|
|
124
161
|
.dock {
|
|
125
162
|
position: fixed;
|
|
126
|
-
right: 24px;
|
|
127
|
-
bottom: 16px;
|
|
128
163
|
z-index: 1020;
|
|
129
164
|
}
|
|
130
165
|
.ball {
|
|
131
166
|
display: grid;
|
|
132
167
|
place-items: center;
|
|
133
|
-
|
|
134
|
-
height: 36px;
|
|
168
|
+
place-content: center;
|
|
135
169
|
border-radius: 50%;
|
|
136
170
|
padding: 0;
|
|
137
|
-
|
|
138
|
-
|
|
171
|
+
width: 52px;
|
|
172
|
+
height: 52px;
|
|
173
|
+
box-shadow: 0 0 0 2px var(--bs-body-bg, #252525), 0 4px 14px #0006;
|
|
174
|
+
cursor: grab;
|
|
175
|
+
touch-action: none;
|
|
176
|
+
user-select: none;
|
|
177
|
+
}
|
|
178
|
+
.ball.moving { cursor: grabbing; }
|
|
179
|
+
.ball svg { pointer-events: none; }
|
|
180
|
+
.ball.integrated {
|
|
181
|
+
position: relative;
|
|
182
|
+
z-index: 1;
|
|
183
|
+
border-color: transparent;
|
|
184
|
+
border-radius: 8px;
|
|
185
|
+
color: var(--bs-body-color);
|
|
186
|
+
background: transparent;
|
|
187
|
+
box-shadow: none;
|
|
139
188
|
}
|
|
140
|
-
.ball:hover
|
|
189
|
+
.ball.integrated:hover { background: #80808026; }
|
|
190
|
+
.ball.integrated:focus-visible { outline: 2px solid var(--bs-primary, #9689eb); outline-offset: -3px; }
|
|
141
191
|
.panel-position {
|
|
142
192
|
position: absolute;
|
|
143
|
-
|
|
144
|
-
bottom: 100%;
|
|
145
|
-
padding-bottom: 8px;
|
|
146
|
-
width: min(360px, calc(100vw - 40px));
|
|
193
|
+
bottom: 0;
|
|
147
194
|
}
|
|
195
|
+
.panel-position.below { top: 0; bottom: auto; }
|
|
148
196
|
.panel {
|
|
149
197
|
display: flex;
|
|
150
198
|
flex-direction: column;
|
|
151
|
-
max-height: min(570px, calc(100vh - 78px));
|
|
152
199
|
border: 1px solid var(--bs-border-color, #555);
|
|
153
200
|
border-radius: 8px;
|
|
154
201
|
color: var(--bs-body-color);
|
|
@@ -161,39 +208,74 @@ exports.styles = `
|
|
|
161
208
|
align-items: center;
|
|
162
209
|
gap: 8px;
|
|
163
210
|
}
|
|
164
|
-
.panel-header {
|
|
165
|
-
|
|
166
|
-
|
|
211
|
+
.panel-header {
|
|
212
|
+
order: 1;
|
|
213
|
+
flex: none;
|
|
214
|
+
justify-content: space-between;
|
|
215
|
+
min-height: 52px;
|
|
216
|
+
padding: 6px 12px 6px 58px;
|
|
217
|
+
border-top: 1px solid var(--bs-border-color, #555);
|
|
218
|
+
}
|
|
219
|
+
.panel-position.below .panel-header {
|
|
220
|
+
order: 0;
|
|
221
|
+
border-top: none;
|
|
222
|
+
border-bottom: 1px solid var(--bs-border-color, #555);
|
|
223
|
+
}
|
|
224
|
+
.panel-position.anchor-right .panel-header { padding: 6px 58px 6px 12px; }
|
|
225
|
+
.editor { border-bottom: 1px solid var(--bs-border-color, #555); }
|
|
226
|
+
.move-hint { margin: 7px 12px 0; font-size: .85em; opacity: .8; }
|
|
227
|
+
.scope-list { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 10px; }
|
|
167
228
|
.scope { padding: 8px 0; }
|
|
168
229
|
.scope + .scope { border-top: 1px solid var(--bs-border-color, #555); }
|
|
169
230
|
.row-heading { margin-bottom: 5px; }
|
|
170
|
-
.scope-title,
|
|
231
|
+
.scope-title, .group-title, .command-alias { overflow-wrap: anywhere; }
|
|
171
232
|
.scope-tag { flex: none; opacity: .72; font-size: .8em; }
|
|
172
233
|
.empty { margin: 3px 0; opacity: .75; font-size: .9em; }
|
|
173
234
|
.profile-hint { padding-bottom: 4px; }
|
|
174
|
-
.
|
|
175
|
-
|
|
235
|
+
.entries { display: flex; flex-wrap: wrap; gap: 5px; }
|
|
236
|
+
.entry { min-width: 0; max-width: 100%; }
|
|
237
|
+
.entry.is-group, .entries.managing > .entry { flex: 0 0 100%; }
|
|
238
|
+
summary { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px; }
|
|
239
|
+
summary::-webkit-details-marker { display: none; }
|
|
240
|
+
summary::before { content: '▸'; flex: none; }
|
|
241
|
+
details[open] > summary::before { transform: rotate(90deg); }
|
|
242
|
+
.group-title { flex: 1; min-width: 0; }
|
|
243
|
+
.actions.group-controls { flex: none; flex-wrap: nowrap; }
|
|
244
|
+
.row-heading { padding: 3px 4px; }
|
|
245
|
+
.drop-ready { outline: 1px dashed var(--bs-primary, #9689eb); border-radius: 4px; }
|
|
246
|
+
.drop-active { background: var(--bs-primary-bg-subtle, #80808040); outline-style: solid; }
|
|
176
247
|
.nested {
|
|
177
248
|
border-left: 1px solid var(--bs-border-color, #555);
|
|
178
249
|
margin-left: 5px;
|
|
179
250
|
padding-left: 9px;
|
|
180
251
|
}
|
|
181
|
-
.command-row { justify-content: space-between; min-height: 30px; }
|
|
252
|
+
.command-row { position: relative; justify-content: space-between; min-height: 30px; }
|
|
253
|
+
.command-row.drop-before::before,
|
|
254
|
+
.command-row.drop-after::after {
|
|
255
|
+
content: '';
|
|
256
|
+
position: absolute;
|
|
257
|
+
inset-inline: 0;
|
|
258
|
+
height: 2px;
|
|
259
|
+
background: var(--bs-primary, #9689eb);
|
|
260
|
+
pointer-events: none;
|
|
261
|
+
}
|
|
262
|
+
.command-row.drop-before::before { top: -3px; }
|
|
263
|
+
.command-row.drop-after::after { bottom: -3px; }
|
|
264
|
+
.command-drag { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
265
|
+
.command-drag[draggable="true"] { cursor: grab; user-select: none; }
|
|
266
|
+
.grip { opacity: .68; }
|
|
182
267
|
.command-run {
|
|
183
|
-
display:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
width: 100%;
|
|
187
|
-
padding: 4px 6px;
|
|
268
|
+
display: block;
|
|
269
|
+
max-width: 100%;
|
|
270
|
+
padding: 3px 8px;
|
|
188
271
|
text-align: left;
|
|
189
272
|
color: inherit;
|
|
190
|
-
background:
|
|
191
|
-
border:
|
|
273
|
+
background: #80808017;
|
|
274
|
+
border: 1px solid #80808052;
|
|
192
275
|
border-radius: 4px;
|
|
193
276
|
}
|
|
194
277
|
.command-run:hover:not(:disabled) { background: #80808030; }
|
|
195
278
|
.command-run:disabled { opacity: .5; }
|
|
196
|
-
.prompt { font-family: ui-monospace, monospace; opacity: .7; }
|
|
197
279
|
.actions { flex-wrap: wrap; }
|
|
198
280
|
.command-row > .actions { flex: none; }
|
|
199
281
|
.group-actions { margin: 4px 0; }
|
|
@@ -204,7 +286,6 @@ summary { cursor: pointer; padding: 4px 0; }
|
|
|
204
286
|
.command-input { font-family: ui-monospace, monospace; }
|
|
205
287
|
.error { margin: 6px 12px; }
|
|
206
288
|
@media (max-height: 420px) {
|
|
207
|
-
.
|
|
208
|
-
.scope-list { overflow: visible; }
|
|
289
|
+
.editor { overflow: auto; max-height: 52vh; }
|
|
209
290
|
}
|
|
210
291
|
`;
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tabby-quick-buttons",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Floating command shortcuts with shared and per-profile groups for Tabby.",
|
|
5
5
|
"author": "zp",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/vzpd/tabby-quick-buttons.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/vzpd/tabby-quick-buttons#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/vzpd/tabby-quick-buttons/issues"
|
|
14
|
+
},
|
|
7
15
|
"keywords": [
|
|
8
16
|
"tabby-plugin"
|
|
9
17
|
],
|