-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: Add OneNote Importer #11392
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lib' into add-onenote-parser-lib
…lib' into add-onenote-parser-lib
pedr
added
desktop
All desktop platforms
import
Related to importing files such as ENEX, JEX, etc.
labels
Nov 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following #10642 (comment) PR that was reverted to
Summary
We are adding a OneNote importer to Joplin Desktop. This change uses an implementation developed by https://github.com/msiemens/ to convert the binary OneNote backup into HTML.
To make it work with the Joplin project I made several changes to the project to be able to work on the WebAssembly environment provided by Electron. The changes include replacing Rust functions that don't exist on the WebAssembly environment with some alternative implementation for Node.js
Important
Project is not going to be build unless
IS_CONTINUOUS_INTEGRATION
environment variable is set during theyarn build
processTo not require all Joplin developers to have Rust in their machine to work in the repository, we made the build process optional, only running the tests related to OneNote and build process if it has this flag enabled.
Duplicating README.md here for more context:
README.md
OneNote Converter
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
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 (seesrc/utils.rs
).How the OneNote Importer Process Works
The requirement for this project was to simplify the migration process from OneNote to Joplin. The starting point of this migration is to export the notebook from OneNote as a
zip
file containing files in the binary format used by OneNote.The process looks like this:
onenote-converter
to read and convert the binary files to HTML (this project).See the
InteropService_Importer_OneNote
class in thelib
project for details.SVG Extraction
The OneNote drawing feature uses
<svg>
tags to save user drawings. Joplin doesn't support SVG rendering due to security concerns, so we added a step to extract the<svg>
elements as SVG images, replacing them with<img>
tags.For each HTML file, we:
svg
nodes.svg
node with animg
node that has a unique title, which will be used as the resource name.img
tags.After this, the HTML should look the same and is ready to be imported by the Importer HTML service.
Project structure:
Development requirements:
To work with the project you will need:
When working with the Rust code you will probably rather run
yarn buildDev
since it is faster and it has more logging messages (they can be disabled in the macrolog!()
)During development, it will be easier to test it where this library is called.
InteropService_Importer_Onenote.ts
is the code that depends on this and already has some tests.Running tests and IS_CONTINUOUS_INTEGRATION
We don't require developers that won't work on this project to have Rust installed on their machine.
To make this work we:
pkg/onenote_converter.js
).IS_CONTINUOUS_INTEGRATION
is not set (seebuild.js
).IS_CONTINUOUS_INTEGRATION
is not set (seelib/services/interop/InteropService_Importer_OneNote.test.ts
).The tests should still run on CI since
IS_CONTINUOUS_INTEGRATION
is used there.Security concerns
We are using WebAssembly with Node.js calls to the file system, reading and writing files and directories, which means
it is not isolated (no more than Node.js is, for that matter).
Tests
While we don't have automate test directly for this project, we added several tests for the
InteropService_Importer_OneNote
component, which is using this newly added package.Tests are set to skip unless
IS_CONTINUOUS_INTEGRATION
environment variable is set.