How to create import module in Joplin?

I am trying to create import module - which imports markdown file in joplin and makes sure that the path to images/ videos are correct as well. Below is the sample code:

joplin.plugins.register({
	onStart: async function() {

		await joplin.interop.registerImportModule({
			description: 'Import enhan(t) Markdown',
			format: 'md',
			sources: [FileSystemItem.File],
			isNoteArchive: false,
			outputFormat: ImportModuleOutputFormat.Markdown,
			onExec: async (context:any) => {
				// In this case importing is a lot more complicated due to the need to avoid
				// duplicate IDs, to validate data and ensure note links and 
				// resources are still working properly.
				// See InteropService_Importer_Raw for an example.
				console.log('Not implemented! Importing from:', context);
			},
		});
	},
});

Documentation mentions that onExec method will be called when import process starts but this never happens. Also, the comments here refer to InteropService_Importer_Raw (joplin/InteropService_Importer_Raw.ts at dev · laurent22/joplin · GitHub), but this is too complicated to understand. Can someone guide me here, it seems like a dead end.

I couldn't find any tests for it and I don't think anyone has created an import plugin yet, so this part of the code is probably one of the least used.

Do you at least see the menu item in GUI? I thought you need to add it separately.

Yes, I am able to see it in the menu, and it even imports the markdown file in Joplin but the images path are broken.

Refer the screenshot here for GUI (there is an option MD - Import enhan(t) Markdown):

Since the image path are relative to the folder of markdown file, they don't show up. I thought of creating resources in Joplin using the absolute path of these images during the markdown import and then using these resources in markdown file but since the import module does not fire the desired onExec event, I cant do that.

Can you suggest some other way to fix the broken image and video path in the imported markdown?

Ok, I read your post as if your import function is not called at all.

I suggest you add logging/breakpoints to that file you mentioned in your OP and see where things go wrong.

Sorry, if this is a naive question.

How do I test Joplin Plugin with VS Code debugger? I have used VSCode debugger with webpack with chrome but used to launch the chrome app from VS Code launch config.

Logging alone is not helping. There are logs in OnExec method which I dont see in the logs so I want to see the control jump while the plugin executes by adding breakpoints. Please help.

I've never tried using VS Code debugger, logging has been mostly enough for me, and when it's not enough I just use the built-in Electron dev tools.

If you open Joplin in dev mode (e.g. I run npm start from packages/app-desktop) and also install your plugin but providing path to dist rather than with a jpl, you should see a separate dev tools window with plugin logs.