Plugin API: Expose "Add to Dictionary" functionality

I would like for there to be a programmatic way in the plugin API to trigger the “Add to Dictionary” functionality.

Use case or problem

I am developing a plugin that allows maintaining a vault “Glossary” of terms and their definitions. As part of the functionality for adding a word to the glossary, I would also like to add it to the dictionary.

Proposed solution

I know that Obsidian uses Electron’s spellcheck and dictionary functionality under the hood, but I’m looking for something higher level that performs the programmatic equivalent of a user selecting “Add to Dictionary” from the editor context menu. Something simple like editor.addToDictionary(word);. I can imagine that this API could be invoked just before (or after) Obsidian invokes Electron’s built-in functionality.

Current workaround (optional)

I’ve been working on a way to directly manipulate the underlying Custom Dictionary.txt files using Node, but challenges are arising regarding the checksum synchronization with the OS dictionary, as well as the inability to refresh Obsidian/Electron’s internal memory of words for spell checking (so the red underline does not go away).

Conclusion

I’m mostly building this for myself, as I use the same Obsidian vault on four different machines and work in a domain with a lot of non-standard terminology. It would be nice to not only use this “Glossary” to sync terms between machines, but also to define and reference them in my notes.