dsh-prompt-pool 1.0.1 → 1.0.2
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/client.js +85 -12
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
|
|
|
24
24
|
const NATIVE_TAB_ID = 'dsh-prompt-pool';
|
|
25
25
|
const NATIVE_TAB_KIND = 'prompt-pool';
|
|
26
26
|
/** Shown in the settings about card; keep in step with plugin/package.json. */
|
|
27
|
-
const PLUGIN_VERSION = '1.0.
|
|
27
|
+
const PLUGIN_VERSION = '1.0.2';
|
|
28
28
|
const PLUGIN_AUTHOR = 'GanttShen';
|
|
29
29
|
/** Replace once the public repository exists; the row hides while it is empty. */
|
|
30
30
|
const PLUGIN_REPO = 'https://github.com/Ganttfly/dsh-prompt-pool';
|
|
@@ -201,7 +201,7 @@ window.__ModuleLoader__.load({
|
|
|
201
201
|
'tray.release': '发送',
|
|
202
202
|
'tray.clear': '清空',
|
|
203
203
|
'tray.clearTitle': '清空待发送队列',
|
|
204
|
-
'tray.clearConfirm': '队列里的 {n}
|
|
204
|
+
'tray.clearConfirm': '队列里的 {n} 条会被一起移出。',
|
|
205
205
|
'tray.clearAction': '清空',
|
|
206
206
|
'tray.empty': '还没选中任何条目,点左侧「+」加入',
|
|
207
207
|
'tray.remove': '移出',
|
|
@@ -228,6 +228,7 @@ window.__ModuleLoader__.load({
|
|
|
228
228
|
'status.releaseStopped': '已释放 {n} 条,其余 {rest} 条没发出去:输入框繁忙或内容被改动',
|
|
229
229
|
'status.draftBusy': '输入框里还有内容,先清空或存进池子再释放',
|
|
230
230
|
'status.deleted': '已删除「{title}」',
|
|
231
|
+
'status.cleared': '已清空 {n} 条待发送',
|
|
231
232
|
'status.undo': '撤销',
|
|
232
233
|
'status.releasing': '正在释放 {n} 条…',
|
|
233
234
|
};
|
|
@@ -371,7 +372,7 @@ window.__ModuleLoader__.load({
|
|
|
371
372
|
'tray.release': 'Send',
|
|
372
373
|
'tray.clear': 'Clear',
|
|
373
374
|
'tray.clearTitle': 'Clear the send queue',
|
|
374
|
-
'tray.clearConfirm': 'All {n} queued items are removed at once.
|
|
375
|
+
'tray.clearConfirm': 'All {n} queued items are removed at once.',
|
|
375
376
|
'tray.clearAction': 'Clear',
|
|
376
377
|
'tray.empty': 'Nothing selected yet — use the + control on a row',
|
|
377
378
|
'tray.remove': 'Remove',
|
|
@@ -398,6 +399,7 @@ window.__ModuleLoader__.load({
|
|
|
398
399
|
'status.releaseStopped': 'Released {n}; {rest} left because the composer was busy or edited',
|
|
399
400
|
'status.draftBusy': 'The composer still has text. Clear it or save it to the pool first.',
|
|
400
401
|
'status.deleted': 'Deleted this item',
|
|
402
|
+
'status.cleared': 'Cleared {n} queued items',
|
|
401
403
|
'status.undo': 'Undo',
|
|
402
404
|
'status.releasing': 'Releasing {n}…',
|
|
403
405
|
};
|
|
@@ -831,9 +833,9 @@ window.__ModuleLoader__.load({
|
|
|
831
833
|
onAdd: (name) => {
|
|
832
834
|
const created = poolActions.addCategory(name);
|
|
833
835
|
if (!created) return;
|
|
834
|
-
// Folded
|
|
835
|
-
const
|
|
836
|
-
setTab(
|
|
836
|
+
// Folded groups share one tab; a hidden family has no tab to aim at.
|
|
837
|
+
const mode = normalizeSettings(pool.get().settings).display.custom;
|
|
838
|
+
setTab(mode === 'nested' ? 'nested:custom' : mode === 'hidden' ? 'all' : 'custom:' + created.id);
|
|
837
839
|
},
|
|
838
840
|
onRename: (id, name) => {
|
|
839
841
|
if (id.indexOf('custom:') === 0) poolActions.renameCategory(id.slice(7), name);
|
|
@@ -1491,8 +1493,25 @@ window.__ModuleLoader__.load({
|
|
|
1491
1493
|
return { ...state, tray };
|
|
1492
1494
|
});
|
|
1493
1495
|
},
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
+
/** Drop exactly these entries, so a release cannot overwrite concurrent edits. */
|
|
1497
|
+
removeTrayKeys(keys) {
|
|
1498
|
+
const drop = new Set(keys);
|
|
1499
|
+
mutate((state) => {
|
|
1500
|
+
const next = state.tray.filter((entry) => !drop.has(entry.key));
|
|
1501
|
+
if (next.length === state.tray.length) return null;
|
|
1502
|
+
return { ...state, tray: next };
|
|
1503
|
+
});
|
|
1504
|
+
},
|
|
1505
|
+
/** Put cleared entries back in front; anything queued since stays behind them. */
|
|
1506
|
+
restoreTray(entries) {
|
|
1507
|
+
const restore = Array.isArray(entries) ? entries : [];
|
|
1508
|
+
if (restore.length === 0) return;
|
|
1509
|
+
mutate((state) => {
|
|
1510
|
+
const present = new Set(state.tray.map((entry) => entry.key));
|
|
1511
|
+
const missing = restore.filter((entry) => !present.has(entry.key));
|
|
1512
|
+
if (missing.length === 0) return null;
|
|
1513
|
+
return { ...state, tray: [...missing, ...state.tray] };
|
|
1514
|
+
});
|
|
1496
1515
|
},
|
|
1497
1516
|
clearTray() {
|
|
1498
1517
|
mutate((state) => (state.tray.length === 0 ? null : { ...state, tray: [] }));
|
|
@@ -2286,6 +2305,18 @@ window.__ModuleLoader__.load({
|
|
|
2286
2305
|
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
2287
2306
|
};
|
|
2288
2307
|
|
|
2308
|
+
/**
|
|
2309
|
+
* Cancel drops an item the editor created and never saved, so no empty
|
|
2310
|
+
* row is left behind; an existing item keeps its stored content.
|
|
2311
|
+
*/
|
|
2312
|
+
const cancelEdit = () => {
|
|
2313
|
+
const current = editing;
|
|
2314
|
+
setEditing(null);
|
|
2315
|
+
if (!current) return;
|
|
2316
|
+
const stored = pool.get().items.find((item) => item.id === current.id);
|
|
2317
|
+
if (stored && !stored.body.trim() && !(stored.images && stored.images.length > 0)) poolActions.remove(stored.id);
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2289
2320
|
const rowOf = (item, index) => {
|
|
2290
2321
|
if (editing && editing.id === item.id) {
|
|
2291
2322
|
return h(
|
|
@@ -2353,7 +2384,7 @@ window.__ModuleLoader__.load({
|
|
|
2353
2384
|
: null,
|
|
2354
2385
|
),
|
|
2355
2386
|
h('span', { className: 'pp-grow' }),
|
|
2356
|
-
h('button', { type: 'button', className: 'pp-mini', onClick:
|
|
2387
|
+
h('button', { type: 'button', className: 'pp-mini', onClick: cancelEdit }, translate('row.cancel')),
|
|
2357
2388
|
h('button', { type: 'button', className: 'pp-primary', onClick: save }, translate('row.save')),
|
|
2358
2389
|
),
|
|
2359
2390
|
);
|
|
@@ -2484,8 +2515,18 @@ window.__ModuleLoader__.load({
|
|
|
2484
2515
|
? h(TrayClearConfirm, {
|
|
2485
2516
|
count: state.tray.length,
|
|
2486
2517
|
onConfirm: () => {
|
|
2518
|
+
const entries = pool.get().tray.slice();
|
|
2487
2519
|
poolActions.clearTray();
|
|
2488
2520
|
setConfirmClear(false);
|
|
2521
|
+
if (entries.length === 0) return;
|
|
2522
|
+
flash({
|
|
2523
|
+
kind: 'info',
|
|
2524
|
+
text: translate('status.cleared', { n: entries.length }),
|
|
2525
|
+
undo: () => {
|
|
2526
|
+
poolActions.restoreTray(entries);
|
|
2527
|
+
setStatus(null);
|
|
2528
|
+
},
|
|
2529
|
+
});
|
|
2489
2530
|
},
|
|
2490
2531
|
onCancel: () => setConfirmClear(false),
|
|
2491
2532
|
})
|
|
@@ -3576,6 +3617,8 @@ window.__ModuleLoader__.load({
|
|
|
3576
3617
|
const group = groupForTab(tab, inWorkspace && wsActive ? 'workspace:' + wsActive.slice(3) : '');
|
|
3577
3618
|
// The new row must land on a visible list, so plain tabs switch to the kind tab.
|
|
3578
3619
|
if (!inWorkspace && !familyOf(tab)) setTab(group);
|
|
3620
|
+
// A search would filter the brand-new empty row out of the list.
|
|
3621
|
+
setQuery('');
|
|
3579
3622
|
const item = poolActions.add({
|
|
3580
3623
|
id: uid(),
|
|
3581
3624
|
group,
|
|
@@ -3588,6 +3631,18 @@ window.__ModuleLoader__.load({
|
|
|
3588
3631
|
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
3589
3632
|
};
|
|
3590
3633
|
|
|
3634
|
+
/**
|
|
3635
|
+
* Cancel drops an item the editor created and never saved, so no empty
|
|
3636
|
+
* row is left behind; an existing item keeps its stored content.
|
|
3637
|
+
*/
|
|
3638
|
+
const cancelEdit = () => {
|
|
3639
|
+
const current = editing;
|
|
3640
|
+
setEditing(null);
|
|
3641
|
+
if (!current) return;
|
|
3642
|
+
const stored = pool.get().items.find((item) => item.id === current.id);
|
|
3643
|
+
if (stored && !stored.body.trim() && !(stored.images && stored.images.length > 0)) poolActions.remove(stored.id);
|
|
3644
|
+
};
|
|
3645
|
+
|
|
3591
3646
|
const startEdit = (item) => setEditing({ id: item.id, group: groupOf(item), title: item.title, body: item.body, images: normalizeImages(item.images) });
|
|
3592
3647
|
|
|
3593
3648
|
const saveEdit = () => {
|
|
@@ -3645,11 +3700,17 @@ window.__ModuleLoader__.load({
|
|
|
3645
3700
|
setBusy(true);
|
|
3646
3701
|
setStatus({ kind: 'info', text: translate('status.releasing', { n: entries.length }) });
|
|
3647
3702
|
let sent = 0;
|
|
3703
|
+
// Keys finished by this run; the queue is filtered by key afterwards so
|
|
3704
|
+
// rows queued (or removed) meanwhile are not overwritten.
|
|
3705
|
+
const done = [];
|
|
3648
3706
|
try {
|
|
3649
3707
|
for (const entry of entries) {
|
|
3650
3708
|
const body = typeof entry.body === 'string' ? entry.body : '';
|
|
3651
3709
|
const images = normalizeImages(entry.images);
|
|
3652
|
-
if (!body.trim() && images.length === 0)
|
|
3710
|
+
if (!body.trim() && images.length === 0) {
|
|
3711
|
+
done.push(entry.key);
|
|
3712
|
+
continue;
|
|
3713
|
+
}
|
|
3653
3714
|
const clear = await waitFor(() => draftRef.current.trim() === '' && phaseRef.current === 'plain', 2500);
|
|
3654
3715
|
if (!clear) break;
|
|
3655
3716
|
try {
|
|
@@ -3688,6 +3749,7 @@ window.__ModuleLoader__.load({
|
|
|
3688
3749
|
}
|
|
3689
3750
|
await waitFor(() => phaseRef.current === 'plain', 1500);
|
|
3690
3751
|
sent += 1;
|
|
3752
|
+
done.push(entry.key);
|
|
3691
3753
|
}
|
|
3692
3754
|
} catch (error) {
|
|
3693
3755
|
flash({ kind: 'error', text: String((error && error.message) || error) });
|
|
@@ -3695,7 +3757,7 @@ window.__ModuleLoader__.load({
|
|
|
3695
3757
|
busyRef.current = false;
|
|
3696
3758
|
setBusy(false);
|
|
3697
3759
|
}
|
|
3698
|
-
poolActions.
|
|
3760
|
+
poolActions.removeTrayKeys(done);
|
|
3699
3761
|
flash(
|
|
3700
3762
|
sent === entries.length
|
|
3701
3763
|
? { kind: 'ok', text: translate('status.released', { n: sent }) }
|
|
@@ -3770,7 +3832,7 @@ window.__ModuleLoader__.load({
|
|
|
3770
3832
|
: null,
|
|
3771
3833
|
),
|
|
3772
3834
|
h('span', { className: 'pp-grow' }),
|
|
3773
|
-
h('button', { type: 'button', className: 'pp-mini', onClick:
|
|
3835
|
+
h('button', { type: 'button', className: 'pp-mini', onClick: cancelEdit }, translate('row.cancel')),
|
|
3774
3836
|
h('button', { type: 'button', className: 'pp-primary', onClick: saveEdit }, translate('row.save')),
|
|
3775
3837
|
),
|
|
3776
3838
|
);
|
|
@@ -3801,6 +3863,7 @@ window.__ModuleLoader__.load({
|
|
|
3801
3863
|
onClick: () => poolActions.move(item.id, 1),
|
|
3802
3864
|
}),
|
|
3803
3865
|
h(IconButton, { name: 'edit', label: translate('row.edit'), onClick: () => startEdit(item) }),
|
|
3866
|
+
h(IconButton, { name: 'copy', label: translate('row.duplicate'), onClick: () => poolActions.duplicateItem(item.id) }),
|
|
3804
3867
|
h(IconButton, { name: 'trash', label: translate('row.delete'), danger: true, onClick: () => setPendingDelete(item) }),
|
|
3805
3868
|
),
|
|
3806
3869
|
);
|
|
@@ -3983,8 +4046,18 @@ window.__ModuleLoader__.load({
|
|
|
3983
4046
|
? h(TrayClearConfirm, {
|
|
3984
4047
|
count: tray.length,
|
|
3985
4048
|
onConfirm: () => {
|
|
4049
|
+
const entries = pool.get().tray.slice();
|
|
3986
4050
|
poolActions.clearTray();
|
|
3987
4051
|
setConfirmClear(false);
|
|
4052
|
+
if (entries.length === 0) return;
|
|
4053
|
+
flash({
|
|
4054
|
+
kind: 'info',
|
|
4055
|
+
text: translate('status.cleared', { n: entries.length }),
|
|
4056
|
+
undo: () => {
|
|
4057
|
+
poolActions.restoreTray(entries);
|
|
4058
|
+
setStatus(null);
|
|
4059
|
+
},
|
|
4060
|
+
});
|
|
3988
4061
|
},
|
|
3989
4062
|
onCancel: () => setConfirmClear(false),
|
|
3990
4063
|
})
|
package/package.json
CHANGED