fix: add cancel action to batch prompt

Change-Id: Ic3922d55d776d369959eff4e5c811c5d3434db2b
This commit is contained in:
wujunchen 2026-04-29 14:13:47 +08:00
parent 57c1c0e124
commit 310c81a073
4 changed files with 12 additions and 1 deletions

View file

@ -546,6 +546,7 @@ class ParallelReaderPlugin extends Plugin {
this.t('batchSelectFolder'),
this.t('batchFolderPrompt'),
this.t('batchFolderConfirm'),
this.t('batchFolderCancel'),
);
if (folderPath === null) return;
const validation = validateBatchFolderInput(folderPath, (path) => {

View file

@ -109,6 +109,7 @@ export function promptForBatchFolder(
selectText: string,
promptText: string,
confirmText: string,
cancelText: string,
): Promise<string | null> {
return new Promise<string | null>((resolve) => {
const modal = new Modal(app);
@ -123,7 +124,12 @@ export function promptForBatchFolder(
modal.close();
}
});
modal.contentEl.createEl('button', { text: confirmText }).addEventListener('click', () => {
const actions = modal.contentEl.createDiv({ cls: 'modal-button-container' });
actions.createEl('button', { text: cancelText }).addEventListener('click', () => {
resolve(null);
modal.close();
});
actions.createEl('button', { text: confirmText, cls: 'mod-cta' }).addEventListener('click', () => {
resolve(input.value.trim());
modal.close();
});

View file

@ -159,6 +159,7 @@ export const STRINGS: Record<string, Record<string, string>> = {
batchSelectFolder: '请输入要批量处理的文件夹路径(留空为 Vault 根目录)',
batchFolderPrompt: '文件夹路径',
batchFolderConfirm: '确定',
batchFolderCancel: '取消',
batchAlreadyRunning: '批量生成正在运行',
batchCancelRequested: '已请求取消批量生成;当前文件结束后停止',
batchInvalidFolderInput: '文件夹路径无效:{path}',
@ -334,6 +335,7 @@ export const STRINGS: Record<string, Record<string, string>> = {
batchSelectFolder: 'Enter the folder path to batch-process (leave blank for Vault root)',
batchFolderPrompt: 'Folder path',
batchFolderConfirm: 'OK',
batchFolderCancel: 'Cancel',
batchAlreadyRunning: 'Batch generation is already running',
batchCancelRequested: 'Batch cancellation requested; it will stop after the current note',
batchInvalidFolderInput: 'Invalid folder path: {path}',

View file

@ -32,5 +32,7 @@ assert.strictEqual(
'Export file already exists: Reading/A.md\nOverwrite it?',
);
assert.strictEqual(t.translate({ uiLanguage: 'zh' }, 'batchFolderConfirm'), '确定');
assert.strictEqual(t.translate({ uiLanguage: 'zh' }, 'batchFolderCancel'), '取消');
assert.strictEqual(t.translate({ uiLanguage: 'en' }, 'batchFolderCancel'), 'Cancel');
console.log('i18n tests passed');