Add more template tag plugins (#3)

This commit is contained in:
Gregory Schier
2024-10-02 06:56:07 -07:00
committed by GitHub
parent 9df586cb59
commit 54689d19ef
29 changed files with 412 additions and 7160 deletions

View File

@@ -0,0 +1,9 @@
{
"name": "@yaakapp/template-function-prompt",
"private": true,
"version": "0.0.1",
"scripts": {
"build": "yaakcli build ./src/index.ts",
"dev": "yaakcli dev ./src/index.js"
}
}

View File

@@ -0,0 +1,24 @@
import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
export const plugin: PluginDefinition = {
templateFunctions: [{
name: 'prompt.text',
args: [
{ type: 'text', name: 'title', label: 'Title' },
{ type: 'text', name: 'label', label: 'Label', optional: true },
{ type: 'text', name: 'defaultValue', label: 'Default Value', optional: true },
{ type: 'text', name: 'placeholder', label: 'Placeholder', optional: true },
],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (args.purpose !== 'send') return null;
return await ctx.prompt.text({
id: `prompt-${args.values.label}`,
label: args.values.label ?? '',
title: args.values.title ?? '',
defaultValue: args.values.defaultValue,
placeholder: args.values.placeholder,
});
},
}],
};