-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
It'd be nice if invokable scripts accepted the various check-callbacks for addCommand, and passed them through when creating the command.
Details
- See: https://docs.obsidian.md/Reference/TypeScript+API/Command/editorCheckCallback + those it overrides for names for callbacks to be accepted.
- When parsing the scripts in the invocable scripts folder, check to see if these callbacks are exported.
- Pass them to the addCommand function if they exist.
Desired Behavior
See above
Current Behavior
Only the default callback is implemented.
Attachments
Possible codescript:
const { MarkdownView } = require('obsidian');
exports.checkCallback = (app) => (checking: boolean) => {
const markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
if (markdownView) {
if (!checking) {
console.log('It worked!');
}
return true;
}
}And be used as:
plugin.addCommand({
callback: /* ... larger-precedence-callbacks-nullable-chain ... */ checkCallback?.(app) ?? async () => {
await invoke(plugin, join(invocableScriptsFolder, scriptFile));
},
id: `${COMMAND_NAME_PREFIX}${scriptFile}`,
name: `Invoke Script: ${scriptFile}`
});Edit: On second thought, I don't think you need to bother implementing the precedence here. addCallback will just handle it.
Confirmations
- I attached a video showing the current behavior, or it is not necessary
- I attached a sample vault where the desired Feature Request could be applied, or it is not necessary
- I have tested the absence of the requested feature with the latest version of the plugin
- I have checked GitHub for existing Feature Requests
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request