Folder Note Plugin: Add description note to folder

Thanks, I have modified the doc.

And I’ve updated mine to reference your plugin and describe the compatible settings.

I am new to js and ts and didn’t realize we could use await this.app.fileManager.renameFile.after();

The .after thing is because I basically hacked Obsidian internals. It’s not regular Javascript at all! (If you look at the bottom of the source code, you will see the function I am using to add an after() to those methods – serializeInstanceMethod().)

Unfortunately, I did it in a way that does not support more than one plugin doing the same trick. So if your plugin does it, too, then our plugins will be incompatible. The reason is that I am literally replacing methods on Obsidian’s file manager, so if you replace them as well, it isn’t really clear what will happen, especially if the plugins are deactivated in a different order than they were activated.

I am hoping that the Obsidian developers will take the idea (of serializing the rename API for safe access) or something like it and add it to the core app, so that it will be safe for all plugins to use. At this point my idea is more a technology demo of one way Obsidian can handle that.

If a safe way to rename files is added to Obsidian’s API, then we could both change our plugins to use it, and there would be no conflict between plugins.

However, I will also give some thought as to if there is a way to make the approach I am using safe for more than one plugin. I have a general idea that would work for serializing execution of the methods, but not a direct way of doing the after() part. If I come up with something I will let you know. I might be able to put it in a library so that other plugins can use it then.

2 Likes