[FR] New API - this.app.embedRegistry.registerExtension to allow embedding custom files inside our notes

Problem Statement

As Obsidian is getting more and more powerful, its now possible to view different kinds of files inside Obsidian. It will be great, if we can also embed these different files inside our notes and render them as they usually render in their custom view/leaf.

Right now this is possible to achieve in our plugins using “unofficial” method/APIs. We can implement it something like this :

import { EmbedRegistry } from "obsidian-typings";


const embedRegistry = this.app.embedRegistry as EmbedRegistry;
if (
	!embedRegistry?.isExtensionRegistered(TASKBOARD_FILE_EXTENSION)
) {
	embedRegistry?.registerExtension(
		TASKBOARD_FILE_EXTENSION,
		(context, file, subPath) => {
			return new TaskBoardEmbedComponent(
				context.containerEl,
				this,
				file,
				context.containerEl.getAttr("alt") || undefined,
			);
		},
	);
}

Possible Solution

It will be nice if Obsidian can provide an official API for this which will make it much easier to integrate this feature inside plugins.

But thats not all why I created this post.

I really want to request to also provide the parent WorkspaceLeaf inside the context which I really need in my plugin. For example, to make use of onResize() and to get the leaf.view which I need to pass it on to MarkdownRendere.render() to track the lifecycle of the component.

My current solution includes creating a dummy component inside the parent component and pass it on to the child component where I am using the MarkdownRendere.render() : fix : use dummy `Component` as a parentComponent for context · tu2-atmanand/Task-Board@b513bdf · GitHub