Replace window.prompt with custom prompt impl (#1847)

* Replace window.prompt with custom prompt impl

* Update locales [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-12-08 13:55:32 -08:00
committed by GitHub
parent 1671437fb3
commit aa04ab78c1
7 changed files with 59 additions and 7 deletions

View File

@@ -6,6 +6,8 @@ import { GroupNodeConfig, GroupNodeHandler } from './groupNode'
import { LGraphCanvas } from '@comfyorg/litegraph'
import { useToastStore } from '@/stores/toastStore'
import { deserialiseAndCreate } from '@/extensions/core/vintageClipboard'
import { showPromptDialog } from '@/services/dialogService'
import { t } from '@/i18n'
// Adds the ability to save and add multiple nodes as a template
// To save:
@@ -348,8 +350,12 @@ app.registerExtension({
options.push({
content: `Save Selected as Template`,
disabled: !Object.keys(app.canvas.selected_nodes || {}).length,
callback: () => {
const name = prompt('Enter name')
callback: async () => {
const name = await showPromptDialog({
title: t('nodeTemplates.saveAsTemplate'),
message: t('nodeTemplates.enterName'),
defaultValue: ''
})
if (!name?.trim()) return
clipboardAction(() => {