Best way to get files attached to a note

Hi,

I’m working on a plugin that adds the capability of rendering musicxml and mxl files inside of obsidian notes.
I managed to get the relevant span and replace it with a very basic version of the rendered sheet music. However, I have problems with getting the relevant files efficiently.

export default class MusicXmlPlugin extends Plugin {
	async onload() {
		try {
			this.registerExtensions(
				MUSICXML_FILE_EXTENSIONS,
				VIEW_TYPE_MUSICXML
			);
		} catch (error) {
			new Notice(
				`File extensions ${MUSICXML_FILE_EXTENSIONS} had been registered by other plugin!`
			);
		}

		
		this.registerMarkdownPostProcessor((element, context) => {
			const elWithEmbedFiles =
			element.querySelectorAll<HTMLElement>(".internal-embed");
			// Is this the the best practice way of getting all spans with embed content?

			
			const mxlFiles = app.vault.getFiles().filter((file) => {
				for (const extension of MUSICXML_FILE_EXTENSIONS) {
					if (file.extension === extension) return file;
				}
			});
			// This is how I get the musicxml/mxl files from the vault.
			// However, it seems inefficient to me since I only need to get the files of the currently opened note


			for (let index = 0; index < elWithEmbedFiles.length; index++) {
				const el = elWithEmbedFiles.item(index);
				const src = el.getAttribute("src");
				// Here I identify which embed sources exist in the note.
				// For some reason if the embed file lives in a nested folder not the entire path is found in the src-attribute
				// Only if 2 files with the same name exist the full path is found in the src-attribute
				const isMusicXml =
					src!.endsWith(".musicxml") || src!.endsWith(".mxl");

					// For all embed files that are musicxml/mxl-files and have a src the rendering is initiated
				if (isMusicXml && src) {
					// This only works for files in the root directory
					const srcFile = mxlFiles.find(element => element.name === src);		
					context.addChild(new RENDER_FUNCTION_CLASS_PLACEHOLDER(srcFile.path));
				}
			}
		});
	}
}

My questions can be found within the pasted code.

I’d appreciate any input as I’m totally new to plugin-development.

Thanks!