diff --git a/main.ts b/main.ts index 45c4887..c41419c 100644 --- a/main.ts +++ b/main.ts @@ -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) => { diff --git a/src/batch.ts b/src/batch.ts index fdca8ed..689d23d 100644 --- a/src/batch.ts +++ b/src/batch.ts @@ -109,6 +109,7 @@ export function promptForBatchFolder( selectText: string, promptText: string, confirmText: string, + cancelText: string, ): Promise { return new Promise((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(); }); diff --git a/src/i18n-strings.ts b/src/i18n-strings.ts index 546c838..6e6becd 100644 --- a/src/i18n-strings.ts +++ b/src/i18n-strings.ts @@ -159,6 +159,7 @@ export const STRINGS: Record> = { batchSelectFolder: '请输入要批量处理的文件夹路径(留空为 Vault 根目录)', batchFolderPrompt: '文件夹路径', batchFolderConfirm: '确定', + batchFolderCancel: '取消', batchAlreadyRunning: '批量生成正在运行', batchCancelRequested: '已请求取消批量生成;当前文件结束后停止', batchInvalidFolderInput: '文件夹路径无效:{path}', @@ -334,6 +335,7 @@ export const STRINGS: Record> = { 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}', diff --git a/tests/i18n.test.js b/tests/i18n.test.js index 68fb76c..ddaa091 100644 --- a/tests/i18n.test.js +++ b/tests/i18n.test.js @@ -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');