cwfryer / obsidian-callout-suggestions

Obsidian Plugin for autocompleting callouts.
MIT License
15 stars 0 forks source link

Suggestion does not contain custom created callouts #4

Closed tahamandviwala4 closed 5 months ago

tahamandviwala4 commented 5 months ago

Callout suggestion only contains obsidian default callout and does not suggest the custom-created callouts. image image from the callout manager plugin.

image callout suggestions do not contain custom-callout.

Thanks for the plugin :)

cwfryer commented 5 months ago

Possibly related to this? obsidian-callout-manager #15

If you just type the callout in using the base syntax does it work?

> [!Created Notes]
> yada yada yada
tahamandviwala4 commented 5 months ago

do you mean this ">[! ]" by base syntax? if yes, suggestions do not appear.

tahamandviwala4 commented 5 months ago

There must be a problem with the callout-manager plugin API. It doesn't return the custom created callouts.

cwfryer commented 5 months ago

Can you get the custom callout to even render if you type it in manually?

tahamandviwala4 commented 5 months ago

Can you get the custom callout to even render if you type it in manually?

Yes

cwfryer commented 5 months ago

If you look at the callout-manager API it seems to me that it adds custom callouts (e.g. ones created within the plugin) to the collection after initializing all of the other callout sources (builtin, theme, snippets, etc.)

        // Create the callout collection.
        // Use getCalloutProperties to resolve the callout's color and icon.
        this.callouts = new CalloutCollection((id) => {
            const { icon, color } = this.calloutResolver.getCalloutProperties(id);
            console.debug('Resolved Callout:', id, { icon, color });
            return {
                id,
                icon,
                color,
            };
        });

        // Add the custom callouts.
        this.callouts.custom.add(...settings.callouts.custom);

source

The API function for getCallouts is just a call to this.plugin.callouts.values() getting the values of the above defined collection. Based on the above definition, you'd expect to see the callouts at the very bottom of the suggestion modal.

In the code for callout-manager's settings UI it does a comparison function to sort by icon (here) so you'll see a different sorting order in the settings UI vs the API call results.

After a fresh install of both plugins, I can find custom ones all the way at the bottom of the list: Screenshot from 2024-06-05 12-54-29

You can try fuzzy finding your custom callouts with something like:

>!notes
tahamandviwala4 commented 5 months ago

If you look at the callout-manager API it seems to me that it adds custom callouts (e.g. ones created within the plugin) to the collection after initializing all of the other callout sources (builtin, theme, snippets, etc.)

This works for me. Thanks for helping :)