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.
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.
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 incommunity-plugins.json
). This means it is possible that this function returnstrue
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 beundefined
even whenisPluginEnabled()
returnstrue
. So the followingas MathLinks
turned out to be wrong. This PR fixes it.https://github.com/zhaoshenzhai/obsidian-mathlinks/blob/5cd0836b973bfe090df3476ed937684adacceb9a/src/api/index.ts#L11-L12