I am trying to create a joplin plugin to read a zip file from the user system and upload a specific makrdown file inside it (say data.md). I see that plugin looks like a node module but I am still able to use node packages like adm-zip (GitHub - cthackers/adm-zip: A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk).
Also, I want to know whether I would be able to use something like "fs.readFile" to read the content of .md file from a path and add it as a note in joplin.
Below is the sample code I have written to see if I can unzip a file and import .md file in the zip.
joplin.plugins.register({
onStart: async function() {
await joplin.interop.registerImportModule({
description: 'Import enhan(t) zip',
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);
},
});
},
});
The joplin documentation says that the imported file and context will be present inside onExec, but for me the function is never called. The joplin app gives a message "An object could not be cloned", and exits.