zhaoshenzhai / obsidian-mathlinks

An Obsidian.md plugin to render MathJax in your links.
MIT License
60 stars 4 forks source link

API fix #60

Closed RyotaUshio closed 12 months ago

RyotaUshio commented 12 months ago

API functions now throw an error properly when MathLinks is in the list of enabled plugins but not fully loaded yet.

Details

The isPluginEnabled function seems to just check whether the given plugin id is in the list of "enabled plugins" (i.e. the array in community-plugins.json). This means it is possible that this function returns true but MathLinks has not been loaded at the moment of the function call.

https://github.com/zhaoshenzhai/obsidian-mathlinks/blob/5cd0836b973bfe090df3476ed937684adacceb9a/src/api/index.ts#L18-L20

As a result, app.plugins.plugins.mathlinks can be undefined even when isPluginEnabled() returns true. So the following as MathLinks turned out to be wrong. This PR fixes it.

https://github.com/zhaoshenzhai/obsidian-mathlinks/blob/5cd0836b973bfe090df3476ed937684adacceb9a/src/api/index.ts#L11-L12