tabby-quick-buttons 1.0.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 CHANGED
@@ -6,7 +6,7 @@ Hover over the floating button in a Tabby terminal to open the command panel. Th
6
6
 
7
7
  - **Shared** groups are available in every terminal. Add commands directly or organize them in nested groups.
8
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.
9
- - Select **Manage** to add, edit, or delete commands and groups. Drag a command 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.
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.
10
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.
11
11
 
12
12
  Use shortcuts at an empty shell prompt. The plugin stores commands in Tabby's configuration. Keep passwords and tokens out of command text.
@@ -23,7 +23,7 @@ npm pack
23
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:
24
24
 
25
25
  ```sh
26
- npm install /absolute/path/to/tabby-quick-buttons-1.0.0.tgz
26
+ npm install /absolute/path/to/tabby-quick-buttons-1.0.1.tgz
27
27
  ```
28
28
 
29
29
  Quit and reopen Tabby, then open a terminal. The plugin uses the Angular and terminal APIs bundled with Tabby.
@@ -38,6 +38,8 @@ let QuickButtonsComponent = class QuickButtonsComponent {
38
38
  suppressBallClick = false;
39
39
  viewport = { width: window.innerWidth, height: window.innerHeight };
40
40
  panelContext;
41
+ groupKeys = new WeakMap();
42
+ trackEntry = (_index, entry) => entry.kind === 'group' ? this.groupKey(entry) : entry;
41
43
  constructor(app, config, notifications) {
42
44
  this.app = app;
43
45
  this.config = config;
@@ -61,7 +63,7 @@ let QuickButtonsComponent = class QuickButtonsComponent {
61
63
  const below = y + ballSize / 2 < height / 2;
62
64
  const anchorRight = x + ballSize / 2 >= width / 2;
63
65
  const panelWidth = Math.min(380, anchorRight ? x + ballSize - edge : width - x - edge);
64
- const panelHeight = Math.min(570, (below ? height - y : y + ballSize) - edge);
66
+ const panelHeight = (below ? height - y : y + ballSize) - edge;
65
67
  return { x, y, panelWidth, panelHeight, panelOffset: anchorRight ? ballSize - panelWidth : 0, below, anchorRight };
66
68
  }
67
69
  updateViewport() {
@@ -242,27 +244,46 @@ let QuickButtonsComponent = class QuickButtonsComponent {
242
244
  event.dataTransfer.effectAllowed = 'move';
243
245
  event.dataTransfer.setData(commandDragType, 'command');
244
246
  }
245
- overGroup(event, entries) {
246
- if (!this.dragged || this.dragged.entries === entries || !event.dataTransfer) {
247
+ dragOver(event, entries, rowIndex) {
248
+ const position = this.dropPosition(event, entries, rowIndex);
249
+ this.dropTarget = position ?? null;
250
+ if (!position || !event.dataTransfer) {
247
251
  return;
248
252
  }
249
253
  event.preventDefault();
250
254
  event.dataTransfer.dropEffect = 'move';
251
- this.dropTarget = entries;
252
255
  }
253
- leaveGroup(event, entries) {
256
+ dragLeave(event, entries, rowIndex) {
254
257
  const target = event.currentTarget;
255
- if (this.dropTarget === entries && !target.contains(event.relatedTarget)) {
258
+ if (this.dropTarget?.entries === entries && this.dropTarget.rowIndex === rowIndex &&
259
+ !target.contains(event.relatedTarget)) {
256
260
  this.dropTarget = null;
257
261
  }
258
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
+ }
259
279
  endCommandDrag() {
260
280
  this.dragged = null;
261
281
  this.dropTarget = null;
262
282
  }
263
- async dropCommand(event, scope, path, entries) {
283
+ async dropCommand(event, scope, path, entries, rowIndex) {
264
284
  const drag = this.dragged;
265
- if (!drag || drag.entries === entries || event.dataTransfer?.getData(commandDragType) !== 'command') {
285
+ const position = this.dropPosition(event, entries, rowIndex);
286
+ if (!drag || !position || event.dataTransfer?.getData(commandDragType) !== 'command') {
266
287
  return;
267
288
  }
268
289
  event.preventDefault();
@@ -279,8 +300,9 @@ let QuickButtonsComponent = class QuickButtonsComponent {
279
300
  this.error = 'The command or group is missing. Start the move again.';
280
301
  return;
281
302
  }
303
+ const insertAt = position.insertAt - Number(from === to && drag.index < position.insertAt);
282
304
  from.splice(drag.index, 1);
283
- to.push(command);
305
+ to.splice(insertAt, 0, command);
284
306
  const changes = destination === source
285
307
  ? new Map([[scope, source]])
286
308
  : new Map([[drag.scope, source], [scope, destination]]);
@@ -307,18 +329,42 @@ let QuickButtonsComponent = class QuickButtonsComponent {
307
329
  entries.splice(index, 1);
308
330
  }
309
331
  else {
310
- const savedEntry = { ...structuredClone(entry), title: entry.title.trim() };
332
+ const title = entry.title.trim();
311
333
  if (index === undefined) {
312
- entries.push(savedEntry);
334
+ entries.push({ ...entry, title });
313
335
  }
314
336
  else {
315
- entries[index] = savedEntry;
337
+ const existing = entries[index];
338
+ if (existing.kind === 'group') {
339
+ existing.title = title;
340
+ }
341
+ else {
342
+ entries[index] = { ...entry, title };
343
+ }
316
344
  }
317
345
  }
318
346
  await this.persist(new Map([[scope, updated]]));
319
347
  }
320
348
  copyScope(scope) {
321
- return { profileId: scope.profileId, entries: structuredClone(scope.entries) };
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;
322
368
  }
323
369
  entriesAt(entries, path) {
324
370
  for (const index of path) {
@@ -375,6 +421,9 @@ let QuickButtonsComponent = class QuickButtonsComponent {
375
421
  return { ...scope, saved, entries: saved?.entries ?? [] };
376
422
  });
377
423
  }
424
+ trackScope(_index, scope) {
425
+ return scope.profileId;
426
+ }
378
427
  };
379
428
  __decorate([
380
429
  (0, core_1.HostListener)('window:resize')
@@ -30,7 +30,9 @@ exports.template = `
30
30
  <button *ngIf="managing" type="button" class="btn btn-sm btn-outline-secondary"
31
31
  [disabled]="busy" (click)="close()">Done</button>
32
32
  </header>
33
- <p *ngIf="managing && !editor" class="move-hint">Drag a command onto a group heading to move it.</p>
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>
34
36
 
35
37
  <form *ngIf="editor as draft" class="editor" (submit)="$event.preventDefault(); save()">
36
38
  <ng-container *ngIf="!draft.deleting; else deletePrompt">
@@ -69,12 +71,12 @@ exports.template = `
69
71
  <p class="error text-danger" *ngIf="error" role="alert">{{ error }}</p>
70
72
 
71
73
  <div class="scope-list">
72
- <section class="scope" *ngFor="let scope of scopes">
74
+ <section class="scope" *ngFor="let scope of scopes; trackBy: trackScope">
73
75
  <div class="row-heading"
74
76
  [class.drop-ready]="dragged && dragged.entries !== scope.entries"
75
- [class.drop-active]="dropTarget === scope.entries"
76
- (dragover)="overGroup($event, scope.entries)"
77
- (dragleave)="leaveGroup($event, 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)"
78
80
  (drop)="dropCommand($event, scope, [], scope.entries)">
79
81
  <strong class="scope-title">{{ scope.title }}</strong>
80
82
  <span class="scope-tag" *ngIf="scope.profileId !== null">Current profile</span>
@@ -100,18 +102,21 @@ exports.template = `
100
102
  </div>
101
103
  <p *ngIf="!entries.length && !managing" class="empty">No commands yet</p>
102
104
  <div class="entries" [class.managing]="managing">
103
- <div *ngFor="let entry of entries; let index = index" class="entry" [class.is-group]="entry.kind === 'group'">
105
+ <div *ngFor="let entry of entries; let index = index; trackBy: trackEntry"
106
+ class="entry" [class.is-group]="entry.kind === 'group'">
104
107
  <ng-container *ngIf="entry.kind === 'group'; else command">
105
108
  <details open>
106
109
  <summary [class.drop-ready]="dragged && dragged.entries !== entry.entries"
107
- [class.drop-active]="dropTarget === entry.entries"
108
- (dragover)="overGroup($event, entry.entries)"
109
- (dragleave)="leaveGroup($event, entry.entries)"
110
- (drop)="dropCommand($event, scope, path.concat(index), entry.entries)">{{ entry.title }}</summary>
111
- <div class="nested">
112
- <div class="actions group-actions" *ngIf="managing">
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">
113
116
  <ng-container *ngTemplateOutlet="editActions"></ng-container>
114
- </div>
117
+ </span>
118
+ </summary>
119
+ <div class="nested">
115
120
  <ng-container *ngTemplateOutlet="entryList; context: {
116
121
  $implicit: entry.entries, scope: scope, path: path.concat(index)
117
122
  }"></ng-container>
@@ -119,10 +124,15 @@ exports.template = `
119
124
  </details>
120
125
  </ng-container>
121
126
  <ng-template #command>
122
- <div class="command-row">
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)">
123
133
  <span class="command-drag" *ngIf="managing" [attr.draggable]="!editor && !busy"
124
134
  (dragstart)="startCommandDrag($event, scope, path, entries, index)"
125
- (dragend)="endCommandDrag()" title="Drag to another group">
135
+ (dragend)="endCommandDrag()" title="Drag to reorder or move">
126
136
  <span aria-hidden="true" class="grip">⠿</span>
127
137
  <span class="command-alias">{{ entry.title }}</span>
128
138
  </span>
@@ -214,18 +224,23 @@ exports.styles = `
214
224
  .panel-position.anchor-right .panel-header { padding: 6px 58px 6px 12px; }
215
225
  .editor { border-bottom: 1px solid var(--bs-border-color, #555); }
216
226
  .move-hint { margin: 7px 12px 0; font-size: .85em; opacity: .8; }
217
- .scope-list { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 12px 10px; }
227
+ .scope-list { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 10px; }
218
228
  .scope { padding: 8px 0; }
219
229
  .scope + .scope { border-top: 1px solid var(--bs-border-color, #555); }
220
230
  .row-heading { margin-bottom: 5px; }
221
- .scope-title, summary, .command-alias { overflow-wrap: anywhere; }
231
+ .scope-title, .group-title, .command-alias { overflow-wrap: anywhere; }
222
232
  .scope-tag { flex: none; opacity: .72; font-size: .8em; }
223
233
  .empty { margin: 3px 0; opacity: .75; font-size: .9em; }
224
234
  .profile-hint { padding-bottom: 4px; }
225
235
  .entries { display: flex; flex-wrap: wrap; gap: 5px; }
226
236
  .entry { min-width: 0; max-width: 100%; }
227
237
  .entry.is-group, .entries.managing > .entry { flex: 0 0 100%; }
228
- summary { cursor: pointer; padding: 4px; }
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; }
229
244
  .row-heading { padding: 3px 4px; }
230
245
  .drop-ready { outline: 1px dashed var(--bs-primary, #9689eb); border-radius: 4px; }
231
246
  .drop-active { background: var(--bs-primary-bg-subtle, #80808040); outline-style: solid; }
@@ -234,7 +249,18 @@ summary { cursor: pointer; padding: 4px; }
234
249
  margin-left: 5px;
235
250
  padding-left: 9px;
236
251
  }
237
- .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; }
238
264
  .command-drag { display: flex; align-items: center; gap: 6px; min-width: 0; }
239
265
  .command-drag[draggable="true"] { cursor: grab; user-select: none; }
240
266
  .grip { opacity: .68; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabby-quick-buttons",
3
- "version": "1.0.0",
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",