if no selected text, how to prompt user to enter new text #1451
Unanswered
micahmorgan1
asked this question in
Help
Replies: 1 comment
-
I kept working on it, and came up with this, which seems to work // assign selected text to variable or prompt for new text
let quote = "";
if(tp.file.selection() == "") {
quote = await tp.system.prompt("Enter Quote");
} else {
quote = tp.file.selection();
}
tR += "quote: '" + quote + "'" + newLine; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm writing a quote template to help me extract existing quotes from existing documents or add new quotes to a file while filing each quote away in its own file. I also want to save the quote itself as a property for easier access and sorting in dataview. I have managed to put together a template that will fill in the selected text as a property value in a new quote file, but I would ALSO like it to prompt the user to enter the text if no text exists.
There is also a lot of language in here that is propmpting for an author file based on existing files with metadata property "type: Author". I'm sure it could be cleaner though as I've pieced it together from various existing threads doing their own thing.
*This file is also being launched by another template that will begin the creation of the new quote file and embed the note back into the original note.
Any help or advice I can get would be appreciated
Credit to the following sources:
#656
https://zachyoung.dev/posts/templater-snippets
Beta Was this translation helpful? Give feedback.
All reactions