diff --git a/README.md b/README.md index 62775372f..efd0f0005 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,10 @@ Stable releases are published bi-weekly in the ComfyUI main repository.
v1.5: Native translation (i18n) - ComfyUI now includes built-in translation support, replacing the need for third-party translation extensions. Select your language - in `Comfy > Locale > Language` to translate the interface into English, Chinese (Simplified), Russian, Japanese, or Korean. This native + ComfyUI now includes built-in translation support, replacing the need for third-party translation extensions. Select your language + in `Comfy > Locale > Language` to translate the interface into English, Chinese (Simplified), Russian, Japanese, or Korean. This native implementation offers better performance, reliability, and maintainability compared to previous solutions.
- + More details available here: https://blog.comfy.org/p/native-localization-support-i18n
@@ -230,11 +230,18 @@ https://github.com/user-attachments/assets/c142c43f-2fe9-4030-8196-b3bfd4c6977d ### Developer APIs
- v1.6.13: Prompt dialog + v1.6.13: prompt/confirm/alert replacements for ComfyUI desktop -`window.prompt` is not available in ComfyUI desktop's electron environment. Please use the following API to show a prompt dialog. +Several browser-only APIs are not available in ComfyUI desktop's electron environment. + +- `window.prompt` +- `window.confirm` +- `window.alert` + +Please use the following APIs as replacements. ```js +// window.prompt window['app'].extensionManager.dialog .prompt({ title: 'Test Prompt', @@ -247,6 +254,28 @@ window['app'].extensionManager.dialog ![image](https://github.com/user-attachments/assets/c73f74d0-9bb4-4555-8d56-83f1be4a1d7e) +```js +// window.confirm +window['app'].extensionManager.dialog + .confirm({ + title: 'Test Confirm', + message: 'Test Confirm Message' + }) + .then((value: boolean) => { + // Do something with the value user entered + }) +``` + +![image](https://github.com/user-attachments/assets/8dec7a42-7443-4245-85be-ceefb1116e96) + +```js +// window.alert +window['app'].extensionManager.toast + .addAlert("Test Alert") +``` + +![image](https://github.com/user-attachments/assets/9b18bdca-76ef-4432-95de-5cd2369684f2) +
diff --git a/browser_tests/extensionAPI.spec.ts b/browser_tests/extensionAPI.spec.ts index 6615b4fb6..1c1e4184a 100644 --- a/browser_tests/extensionAPI.spec.ts +++ b/browser_tests/extensionAPI.spec.ts @@ -177,5 +177,23 @@ test.describe('Topbar commands', () => { 'Hello, world!' ) }) + + test('Should allow showing a confirmation dialog', async ({ + comfyPage + }) => { + await comfyPage.page.evaluate(() => { + window['app'].extensionManager.dialog + .confirm({ + title: 'Test Confirm', + message: 'Test Confirm Message' + }) + .then((value: boolean) => { + window['value'] = value + }) + }) + + await comfyPage.confirmDialog.click('confirm') + expect(await comfyPage.page.evaluate(() => window['value'])).toBe(true) + }) }) }) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index ea83f3042..d1e2f68a6 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -91,11 +91,13 @@ class ConfirmDialog { public readonly delete: Locator public readonly overwrite: Locator public readonly reject: Locator + public readonly confirm: Locator constructor(public readonly page: Page) { this.delete = page.locator('button.p-button[aria-label="Delete"]') this.overwrite = page.locator('button.p-button[aria-label="Overwrite"]') this.reject = page.locator('button.p-button[aria-label="Cancel"]') + this.confirm = page.locator('button.p-button[aria-label="Confirm"]') } async click(locator: KeysOfType) { diff --git a/src/components/dialog/content/ConfirmationDialogContent.vue b/src/components/dialog/content/ConfirmationDialogContent.vue index cb3c364d8..ecde16c98 100644 --- a/src/components/dialog/content/ConfirmationDialogContent.vue +++ b/src/components/dialog/content/ConfirmationDialogContent.vue @@ -13,7 +13,14 @@ autofocus />