1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

Add support for a transformFilter for prompts

This commit is contained in:
Jeremy Ruston 2024-10-20 13:02:47 +01:00
parent b31e2cd0db
commit e3714929f9
3 changed files with 11 additions and 3 deletions

View File

@ -146,7 +146,14 @@ Commander.prototype.stringifyToken = function(index,callback) {
promptText: token.prompt || "Please enter a value", promptText: token.prompt || "Please enter a value",
defaultResult: token["default"] || "", defaultResult: token["default"] || "",
callback: function(err,userText) { callback: function(err,userText) {
callback(err,userText); if(err) {
callback(err);
} else {
if(token.transformFilter) {
userText = self.wiki.filterTiddlers(token.transformFilter,null,self.wiki.makeTiddlerIterator([userText]))[0] || "";
}
callback(null,userText);
}
}, },
input: self.streams.input, input: self.streams.input,
output: self.streams.output, output: self.streams.output,

View File

@ -30,7 +30,7 @@ Command tokens can be a simple string or <<.from-version "5.3.6">> a command tok
* ''filter'': the value of the first result of a filter expression specified in the ''text'' property of the command token object * ''filter'': the value of the first result of a filter expression specified in the ''text'' property of the command token object
* ''wikify'': the result of wikifying a text string specified in the ''text'' property of the command token object * ''wikify'': the result of wikifying a text string specified in the ''text'' property of the command token object
* ''prompt'': the result of prompting the user for a string. The ''prompt'' property of the command token object specifies the textual prompt to be used. The optional ''default'' property specifies a string value to be used if the user presses enter in response to the prompt * ''prompt'': the result of prompting the user for a string. The ''prompt'' property of the command token object specifies the textual prompt to be used. The optional ''default'' property specifies a string value to be used if the user presses enter in response to the prompt. The optional ''transformFilter'' property specifies a filter to be applied to the user input to transform it into a command token. The string input by the user is available in the variable `user-input`
The EchoCommand is useful for debugging complex dynamic command tokens. The EchoCommand is useful for debugging complex dynamic command tokens.

View File

@ -39,7 +39,8 @@
{ {
"type": "prompt", "type": "prompt",
"prompt": "Please enter some text and type enter", "prompt": "Please enter some text and type enter",
"default": "Nothing" "default": "Nothing",
"transformFilter": "[addprefix[testing ]]"
} }
], ],
"index": [ "index": [