mirror of
https://github.com/gregory-jagermeister/Fantasy-Content-Generator.git
synced 2026-07-22 07:30:31 +00:00
Added a Command to "Open Fantasy Generator"
This commit is contained in:
parent
9b6a1d580d
commit
3f5606ff2e
1 changed files with 27 additions and 0 deletions
27
main.ts
27
main.ts
|
|
@ -30,6 +30,33 @@ export default class FantasyPlugin extends Plugin {
|
|||
}
|
||||
});
|
||||
|
||||
//Command to open Modal dialog
|
||||
this.addCommand({
|
||||
id: 'open-fantasy-generator',
|
||||
name: 'Open Fantasy Generator',
|
||||
callback: () => {
|
||||
new GeneratorModal(this.app, (result) => {
|
||||
const copyContent = async () => {
|
||||
//Try to see if any generators spit out an Error or if copying the string fails.
|
||||
try {
|
||||
if (result instanceof Error) {
|
||||
new Notice(`${result}`);
|
||||
} else {
|
||||
await navigator.clipboard.writeText(result);
|
||||
new Notice(`${result} was copied to the clipboard.`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to copy: ', err);
|
||||
new Notice("Failed to copy, Check error in console.");
|
||||
}
|
||||
}
|
||||
|
||||
copyContent();
|
||||
|
||||
}, this).open();
|
||||
},
|
||||
});
|
||||
|
||||
//Register the InlineGeneratorSuggester to the Editor suggester.
|
||||
this.registerEditorSuggest(new InlineGeneratorSuggester(this.getOptionsForSuggest, this));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue