Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shift Enter 打开参数编辑框 #20

Open
linonetwo opened this issue May 22, 2024 · 2 comments
Open

Shift Enter 打开参数编辑框 #20

linonetwo opened this issue May 22, 2024 · 2 comments

Comments

@linonetwo
Copy link
Contributor

linonetwo commented May 22, 2024

有的 message 和 actionString 需要参数,在命令菜单里输入容易误触回车触发,导致命令在缺少参数的情况下运行,让用户需要小心翼翼的。

为让用户放心和防呆操作,最好是打开一个弹框,里面展示所有可用参数,填完再次回车才触发。可以用超级标签来做表单,不过那样会有较大依赖,最好还是通过某个条目上简单的字段反射展示简单的表单。

如果命令没有参数或已有默认参数,那么回车可以直接执行;Shift + 回车才是打开弹框。如果有未填的参数,那么回车和 Shift + 回车都会打开弹框。

@linonetwo
Copy link
Contributor Author

可以通过 AST 看 actionString 里用到了哪些自由变量,然后检查 Widget 上下文里提供了哪些变量,缺失的就生成输入框。未缺失的生成带默认值的输入框并隐藏。

@linonetwo
Copy link
Contributor Author

As said on the post, tiddlers with tags like $:/tags/Actions are executable

caption: Executable test
tags: $:/tags/Actions
title: ramdomtitlexxx

<$action-navigate $to="$:/ControlPanel"/>

const variables = { currentTiddler: focusedTiddler ?? '', commandpaletteinput: parameters.query.slice(1) };
const { widget } = parameters.state.context as IContext;
const onSelect = (item: ITiddlerFields) => {
parameters.setContext({ noNavigate: true } satisfies IContext);
// this calls `invokeActions` under the hood
widget?.invokeActionString(item.text, widget, null, variables);

缺失 selected text 功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant