mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 22:40:26 +01:00
feat: add ctx.prompt.form() plugin API for multi-field form dialogs (#359)
This commit is contained in:
@@ -21,6 +21,7 @@ import { stringToColor } from './color';
|
||||
import { generateId } from './generateId';
|
||||
import { jotaiStore } from './jotai';
|
||||
import { showPrompt } from './prompt';
|
||||
import { showPromptForm } from './prompt-form';
|
||||
import { invokeCmd } from './tauri';
|
||||
import { showToast } from './toast';
|
||||
|
||||
@@ -47,6 +48,27 @@ export function initGlobalListeners() {
|
||||
},
|
||||
};
|
||||
await emit(event.id, result);
|
||||
} else if (event.payload.type === 'prompt_form_request') {
|
||||
const values = await showPromptForm({
|
||||
id: event.payload.id,
|
||||
title: event.payload.title,
|
||||
description: event.payload.description,
|
||||
inputs: event.payload.inputs,
|
||||
confirmText: event.payload.confirmText,
|
||||
cancelText: event.payload.cancelText,
|
||||
});
|
||||
const result: InternalEvent = {
|
||||
id: generateId(),
|
||||
replyId: event.id,
|
||||
pluginName: event.pluginName,
|
||||
pluginRefId: event.pluginRefId,
|
||||
context: event.context,
|
||||
payload: {
|
||||
type: 'prompt_form_response',
|
||||
values,
|
||||
},
|
||||
};
|
||||
await emit(event.id, result);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user