Closed carlonicora closed 1 year ago
There's not a direct way, but you could add it to the FC settings property directly and then call the saveCalendar
method, which saves the data and refreshes the view.
@valentine195 Thanks a lot for your reply, really appreciated.
I will dig into it and see how I can make it work!
@carlonicora FYI I just added this to the Fantasy Calendar API
See here https://github.com/fantasycalendar/obsidian-fantasy-calendar#plugin-api
Thank you! Much appreciated!
Hi @valentine195
Apologies for my ignorance. I added fantasy-calendar as dev in package, but I still can't find FantasyCalendarAPI
Also, if I just use the plugin as :any
and access it through app.plugins.getPlugin('fantasy-calendar')
I can see all the info in the console, but when I try and get the calendars through api.getCalendars()
I get an error (screenshot attached)
No worries, the API is available on the window, you can just use it. No need to install Fantasy Calendar as a dependency unless you want the typings
Hi @valentine195
What I meant to say is that I must be doing something wrong, as in any way I access the API, I get an error.
When I write the fantasy calendar api in the console, I can see everything, but when I run window.FantasyCalendarAPI.getCalendars()
(or app.plugins.getPlugin('fantasy-calendar').api.getCalendars()` I get the error above.
That’s weird. That method just grabs the calendars out of the plugin’s data object. What does app.plugins.getPlugin('fantasy-calendar').data
look like?
That's the strange thing. When I output the entire API I can see the data (see screenshot above), but if I try to get the data directly I get undefined
.
Weird. It works for me on my phone lol
Do any of the API methods work?
nope, and I have the latest version of Fantasy Calendar (2.3.10
) installed in obsidian (and it works, as I can change the calendar from the plugin itself)
Well I forgot to push the release for the new category functionality lol I'll do that later today.
Still doesn't solve this issue though. Not sure what's going on there, I'll have to investigate.
Thanks! Much appreciated!
@valentine195 So, I have understood the issue with data being undefined
. I call it from the onLayoutReady
event in Obsidian, but it seems that the data is not yet ready. If I add a delay, then the data becomes available and I can read it.
This is because the load of the calendars information is run in the onLayoutReady
, so my call reads the data before they are ready.
I need to write a wrapper that waits for the fantasy-calendars-settings-loaded
to be called before allowing the system to query the calendars!
Ah yeah, that was going to be the first thing I did actually was move that into the initial load...
You don't need a wrapper, use the FC's onSettingsLoad
method:
Hello!
Yes, I was thinking internally, to give access to Fantasy Calendar from my plugin only when FC is ready.
Thanks a lot again for the support!
Hello wonderful people at Fantasy Calendar,
I tried to check in the documentation (and even trying to tweak the Frontmatter), but did not manage to find an answer to this:
Is there a way of creating a new category through the Api or adding it in the Frontmatter?
So far, the only way of adding a Category I found is through the FC Settings, but I was wondering if a new one can be created programmatically as part of an Api integration.
Thanks a lot Carlo