mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-18 20:16:34 +02:00
Desktop: Importing from OneNote: Make "module not found" message more useful (#14324)
This commit is contained in:
@@ -21,6 +21,19 @@ type PageIdMap = {
|
||||
get: (pageId: string)=> PageResolutionResult|null;
|
||||
};
|
||||
|
||||
type NativeOneNoteConverter = (notebookPath: string, outputDirectory: string, baseDir: string)=> Promise<void>;
|
||||
const getOneNoteConverter = (): NativeOneNoteConverter => {
|
||||
try {
|
||||
return shim.requireDynamic('@joplin/onenote-converter').oneNoteConverter;
|
||||
} catch (error) {
|
||||
// Log the original error for debugging:
|
||||
logger.warn('Failed to load the onenote importer:', error);
|
||||
|
||||
// Throw a more user and maintainer-friendly error:
|
||||
throw new Error('Failed to load @joplin/onenote-converter. Please check that the onenote-converter package was built correctly and bundled with this version of Joplin.\n\nFor build instructions, see https://github.com/laurent22/joplin/blob/dev/packages/onenote-converter/README.md#building.');
|
||||
}
|
||||
};
|
||||
|
||||
// See onenote-converter README.md for more information
|
||||
export default class InteropService_Importer_OneNote extends InteropService_Importer_Base {
|
||||
protected importedNotes: Record<string, NoteEntity> = {};
|
||||
@@ -76,7 +89,8 @@ export default class InteropService_Importer_OneNote extends InteropService_Impo
|
||||
const notebookFiles = files.filter(e => {
|
||||
return extname(e.path) !== '.onetoc2' && basename(e.path) !== 'OneNote_RecycleBin.onetoc2';
|
||||
});
|
||||
const { oneNoteConverter } = shim.requireDynamic('@joplin/onenote-converter');
|
||||
|
||||
const oneNoteConverter = getOneNoteConverter();
|
||||
|
||||
logger.info('Extracting OneNote to HTML');
|
||||
const skippedFiles = [];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This package is used to process OneNote backup files and output HTML that Joplin can import.
|
||||
|
||||
The code is based on the projects created by https://github.com/msiemens
|
||||
The code is based on the `one2html` and `onenote.rs` projects created by https://github.com/msiemens.
|
||||
|
||||
We adapted it to target WebAssembly, adding Node.js functions that could interface with the host machine. For that to happen we are using custom-made functions (see `node_functions.js`) and the Node.js standard library (see `src/utils.rs`).
|
||||
|
||||
@@ -58,15 +58,19 @@ To work with the project you will need:
|
||||
|
||||
- Rust https://www.rust-lang.org/learn/get-started
|
||||
|
||||
### Building
|
||||
|
||||
For most setups, the OneNote converter must be built manually:
|
||||
- Development build: `yarn buildDev`.
|
||||
- Includes additional logging.
|
||||
- Faster compilation.
|
||||
- Slower at runtime.
|
||||
- Production build: `IS_CONTINUOUS_INTEGRATION=1 yarn build`
|
||||
- **Important**: The `IS_CONTINUOUS_INTEGRATION` environment variable must be set. To simplify the development process for contributors without Rust installed, `yarn build` is disabled unless `IS_CONTINUOUS_INTEGRATION` is set.
|
||||
|
||||
### Running tests
|
||||
|
||||
Most tests for the project are located in the `lib` packages, but to make it work it is necessary to build this project first:
|
||||
|
||||
`IS_CONTINUOUS_INTEGRATION=1 yarn build # for production build`
|
||||
or
|
||||
`IS_CONTINUOUS_INTEGRATION=1 yarn buildDev # for build with more logs and compiles faster`
|
||||
|
||||
After that you should navigate to `lib` package and run the tests of `InteropService_Importer_OneNote.test.` file
|
||||
Most tests for this project are located in the `lib` package. After building the project, set the `IS_CONTINUOUS_INTEGRATION` environment variable and run the tests in `InteropService_Importer_OneNote.test.ts` file:
|
||||
|
||||
```
|
||||
cd ../lib
|
||||
|
||||
Reference in New Issue
Block a user