System Module
This module contains system related functions.
Documentation
Function documentation is using a specific syntax. More information here
tp.system.clipboard()
Retrieves the clipboard's content
tp.system.prompt(prompt_text?: string, default_value?: string, throw_on_cancel: boolean = false)
Spawns a prompt modal and returns the user's input.
Arguments
-
default_value: A default value for the input field -
prompt_text: Text placed above the input field -
throw_on_cancel: Throws an error if the prompt is canceled, instead of returning anullvalue
tp.system.suggester(text_items: string[] ⎮ ((item: T) => string), items: T[], throw_on_cancel: boolean = false, placeholder: string = "", limit?: number = undefined)
Spawns a suggester prompt and returns the user's chosen item.
Arguments
-
items: Array containing the values of each item in the correct order. -
limit: Limit the number of items rendered at once (useful to improve performance when displaying large lists) -
placeholder: Placeholder string of the prompt -
text_items: Array of strings representing the text that will be displayed for each item in the suggester prompt. This can also be a function that maps an item to its text representation. -
throw_on_cancel: Throws an error if the prompt is canceled, instead of returning anullvalue
Examples
Clipboard content: <% tp.system.clipboard() %>
Entered value: <% tp.system.prompt("Please enter a value") %>
Mood today: <% tp.system.prompt("What is your mood today ?", "happy") %>
Mood today: <% tp.system.suggester(["Happy", "Sad", "Confused"], ["Happy", "Sad", "Confused"]) %>
Picked file: [[<% (await tp.system.suggester((item) => item.basename, app.vault.getMarkdownFiles())).basename %>]]