mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 01:28:35 +02:00
Add descriptions to template functions
This commit is contained in:
@@ -95,7 +95,12 @@ export type SendHttpRequestResponse = { httpResponse: HttpResponse, };
|
|||||||
|
|
||||||
export type ShowToastRequest = { message: string, color?: Color, icon?: Icon, };
|
export type ShowToastRequest = { message: string, color?: Color, icon?: Icon, };
|
||||||
|
|
||||||
export type TemplateFunction = { name: string, aliases?: Array<string>, args: Array<TemplateFunctionArg>, };
|
export type TemplateFunction = { name: string, description?: string,
|
||||||
|
/**
|
||||||
|
* Also support alternative names. This is useful for not breaking existing
|
||||||
|
* tags when changing the `name` property
|
||||||
|
*/
|
||||||
|
aliases?: Array<string>, args: Array<TemplateFunctionArg>, };
|
||||||
|
|
||||||
export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg | { "type": "file" } & TemplateFunctionFileArg;
|
export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg | { "type": "file" } & TemplateFunctionFileArg;
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,12 @@ export type SendHttpRequestResponse = { httpResponse: HttpResponse, };
|
|||||||
|
|
||||||
export type ShowToastRequest = { message: string, color?: Color, icon?: Icon, };
|
export type ShowToastRequest = { message: string, color?: Color, icon?: Icon, };
|
||||||
|
|
||||||
export type TemplateFunction = { name: string, aliases?: Array<string>, args: Array<TemplateFunctionArg>, };
|
export type TemplateFunction = { name: string, description?: string,
|
||||||
|
/**
|
||||||
|
* Also support alternative names. This is useful for not breaking existing
|
||||||
|
* tags when changing the `name` property
|
||||||
|
*/
|
||||||
|
aliases?: Array<string>, args: Array<TemplateFunctionArg>, };
|
||||||
|
|
||||||
export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg | { "type": "file" } & TemplateFunctionFileArg;
|
export type TemplateFunctionArg = { "type": "text" } & TemplateFunctionTextArg | { "type": "select" } & TemplateFunctionSelectArg | { "type": "checkbox" } & TemplateFunctionCheckboxArg | { "type": "http_request" } & TemplateFunctionHttpRequestArg | { "type": "file" } & TemplateFunctionFileArg;
|
||||||
|
|
||||||
|
|||||||
@@ -294,6 +294,8 @@ pub struct GetTemplateFunctionsResponse {
|
|||||||
#[ts(export, export_to = "events.ts")]
|
#[ts(export, export_to = "events.ts")]
|
||||||
pub struct TemplateFunction {
|
pub struct TemplateFunction {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
#[ts(optional)]
|
||||||
|
pub description: Option<String>,
|
||||||
|
|
||||||
/// Also support alternative names. This is useful for not breaking existing
|
/// Also support alternative names. This is useful for not breaking existing
|
||||||
/// tags when changing the `name` property
|
/// tags when changing the `name` property
|
||||||
|
|||||||
@@ -285,12 +285,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.cm-completionInfo-right {
|
&.cm-completionInfo {
|
||||||
@apply ml-1 -mt-0.5 font-sans;
|
@apply mx-0.5 -mt-0.5 font-sans;
|
||||||
}
|
|
||||||
|
|
||||||
&.cm-completionInfo-right-narrow {
|
|
||||||
@apply ml-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export const Editor = forwardRef<EditorView | undefined, EditorProps>(function E
|
|||||||
id: 'template-function',
|
id: 'template-function',
|
||||||
size: 'sm',
|
size: 'sm',
|
||||||
title: 'Configure Function',
|
title: 'Configure Function',
|
||||||
|
description: fn.description || null,
|
||||||
render: ({ hide }) => (
|
render: ({ hide }) => (
|
||||||
<TemplateFunctionDialog
|
<TemplateFunctionDialog
|
||||||
templateFunction={fn}
|
templateFunction={fn}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export type TwigCompletionOption = (
|
|||||||
) & {
|
) & {
|
||||||
name: string;
|
name: string;
|
||||||
label: string;
|
label: string;
|
||||||
|
description?: string;
|
||||||
onClick: (rawTag: string, startPos: number) => void;
|
onClick: (rawTag: string, startPos: number) => void;
|
||||||
value: string | null;
|
value: string | null;
|
||||||
invalid?: boolean;
|
invalid?: boolean;
|
||||||
@@ -63,10 +64,11 @@ export function twigCompletion({ options }: TwigCompletionConfig) {
|
|||||||
|
|
||||||
// If not on the last segment, only complete the namespace
|
// If not on the last segment, only complete the namespace
|
||||||
if (matchSegments.length < optionSegments.length) {
|
if (matchSegments.length < optionSegments.length) {
|
||||||
|
const prefix = optionSegments.slice(0, matchSegments.length).join('.');
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: optionSegments.slice(0, matchSegments.length).join('.') + '…',
|
label: prefix + '.*',
|
||||||
apply: optionSegments.slice(0, matchSegments.length).join('.'),
|
apply: prefix,
|
||||||
type: 'namespace',
|
type: 'namespace',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -78,6 +80,8 @@ export function twigCompletion({ options }: TwigCompletionConfig) {
|
|||||||
{
|
{
|
||||||
label: o.name,
|
label: o.name,
|
||||||
apply: openTag + inner + closeTag,
|
apply: openTag + inner + closeTag,
|
||||||
|
info: o.description,
|
||||||
|
detail: o.type,
|
||||||
type: o.type === 'variable' ? 'variable' : 'function',
|
type: o.type === 'variable' ? 'variable' : 'function',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export function twig({
|
|||||||
name: fn.name,
|
name: fn.name,
|
||||||
aliases: fn.aliases,
|
aliases: fn.aliases,
|
||||||
type: 'function',
|
type: 'function',
|
||||||
|
description: fn.description,
|
||||||
args: fn.args.map((a) => ({ name: a.name })),
|
args: fn.args.map((a) => ({ name: a.name })),
|
||||||
value: null,
|
value: null,
|
||||||
label: `${fn.name}(${shortArgs})`,
|
label: `${fn.name}(${shortArgs})`,
|
||||||
|
|||||||
Reference in New Issue
Block a user