Closed rocketnova closed 1 year ago
JFYI: While working on a PR for another plugin, I found the source of truth for the obsidian API. Here's the change in the Obsidian CachedMetadata
class.
Bug: Map of Content does not invoke Update Map of Content
on file switch when a new properties
link is added
To Reproduce:
Prereqs:
Update when switching between files:
is checked
Inline behavior (Working as expected)
[[Foo]]
and mark it as your root MoC file[[Bar]]
and link it inline it to Foo
.
[[Zap]]
Bar
Bar -> Foo
Zap
Bar
Zap
Zap -> Bar -> Foo
Foo
in Zap
Zap
Zap -> Foo
Properties behavior (Bugged)
[[Foo]]
and mark it as your root MoC file[[Bar]]
and link it inline it to Foo
.
[[Zap]]
Bar
Bar -> Foo
Zap
Bar
Zap
Zap -> Bar -> Foo
Foo
in Zap
Zap
Zap -> Foo
Map of Content: Update Map of Content
Zap -> Foo
Also reproduced with:
properties
link is the first link added to a new file
property
link as string type
update map of content
not invokedproperty
link as list type
update map of content
not invokedThank you for contributing :+1:
Thanks for the quick turnaround and thanks for a very useful plugin!
You're welcome! I've also fixed the issue with frontmatter links not triggering an MOC update on note change. It will be fixed with the next release. I'm currently in the process of refactoring the codebase, using camelcase everywhere, using things like sets where useful and no longer using the obsoleted workspace.activeLeaf. Once that's done and tested, i'll release it all. Please feel free to make further suggestion towards improving the code quality or adding features.
I saw that! Looks great.
Release is out now
Changes
frontmatterLinks
property was added)Context
The new Obsidian 1.4.5 release added a new feature called Properties. One of the things it does is add support wiki-style links (e.g.
[[]]
) in the yaml frontmatter. These links are not added to the.links
property inCachedMetadata
. Instead they are added as a new and separate property called.frontmatterLinks
.I think that the code for building the list of links could probably get tidied a little bit by using a
Set
instead of an array forall_links
since it would naturally handle the de-duplication safety check, but I didn't want to exceed the scope of the problem, which is just to get frontmatter links intoall_links
.Testing
You can test this out by doing the following.
Verify that frontmatter links are not considered without this patch:
Verify that frontmatter links are considered with this patch:
Note about the API
The new property is visible in the Obsidian Developer Console, even if it isn't yet documented in the web API docs. Here are some screenshots of what is currently shown in the API docs (apparently incorrect or incomplete) and what you can see in the Obsidian Developer Console.