diff --git a/README.md b/README.md index 5cdbc1f..b58644b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ This can be useful when developing plugins, or for "light-weight" scripting with A range of convenience functions partly inspired by emacs is also provided. +# Demo +![demo](demo.gif) + # Installation In your obsidian vault there should be a `.obsidian/plugins` directory. You can clone this repo into that directory and then run the following to build the plugin: @@ -70,8 +73,8 @@ openSetting(name: string) - Open settings and display the tab (see left hand sid * lineAtPoint(p?:string) - Retunrs the line at the cursor position. Default to current positiong. ### Reading and files -* writeToFile(name, string) - Overwrite the markdown file called name with the given string -* appendToFile(name, string) - Append to the markdown file called `name` with the given string +* writeToFile(name: string) - Overwrite the markdown file called name with the given string +* appendToFile(name: string) - Append to the markdown file called `name` with the given string ### Processes * runProc(s: string) - Parse the bash-style command string s (e.g "ls /home") and call runProc on it diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000..3aa96d0 Binary files /dev/null and b/demo.gif differ diff --git a/fuzzy.ts b/fuzzy.ts index de967ab..a214bd7 100644 --- a/fuzzy.ts +++ b/fuzzy.ts @@ -1,5 +1,14 @@ import { FuzzySuggestModal, App } from 'obsidian'; + +export function fuzzySelect(app: App, choices: Array, prompt?: string) { + // doc: fuzzily select from a list of strings + return new Promise((reject, resolve) => { + let selector = new FuzzySelector(app, prompt || "select:", choices, [reject, resolve]) + selector.run() + }) +} + export class FuzzySelector extends FuzzySuggestModal { resolve: (_: any) => void reject: (_: any) => void