Skip to content
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 168 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
d8fbf7c
bringing converter to project
pedr Apr 1, 2024
6650d5c
making it work on desktop
pedr Apr 1, 2024
947835e
allow to execute more than one time
pedr Apr 1, 2024
d184ece
using workspaces to link the dependency
pedr Apr 3, 2024
34e067b
process zip file from onenote exporter
pedr Apr 3, 2024
e9ec561
improving ux of developer with onenote dependecy
pedr Apr 4, 2024
9d08fd1
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Apr 4, 2024
472399c
remove workflow files
pedr Apr 4, 2024
d03ba41
allow to import more than one notebok at the time
pedr Apr 4, 2024
50d6d33
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Apr 6, 2024
f96b3b1
moving build step to package script
pedr Apr 6, 2024
8e1ae98
remove generated files from eslint rule
pedr Apr 6, 2024
51a7619
add generated file to correct eslint ignore
pedr Apr 6, 2024
221be30
add lib dependecy to Dockerfile
pedr Apr 8, 2024
112e3f4
add rust dependecy
pedr Apr 8, 2024
644c8cc
Merge branch 'dev' into add-onenote-parser-lib
laurent22 Apr 10, 2024
fa728f1
adding onenote-converter build package to version control
pedr Apr 10, 2024
0cc1e4b
cleaning up logs
pedr Apr 10, 2024
1196e10
fix a bug where files that don't exist are trying to be read
pedr Apr 10, 2024
e0f3687
add wasm-pack as a dependecy to speed up building
pedr Apr 10, 2024
0702216
include rust analyzer to rust package on vscode
pedr Apr 11, 2024
0ea2e14
Merge remote-tracking branch 'refs/remotes/origin/add-onenote-parser-…
pedr Apr 11, 2024
0a4a7c8
running cargo fmt
pedr Apr 11, 2024
ef21ac1
refactoring log macro
pedr Apr 17, 2024
4ec43d8
new build artfects
pedr Apr 17, 2024
f49887f
add a new html importer to modify onenote embed links
pedr Apr 18, 2024
c13f313
a better implementation of embed to anchor
pedr Apr 18, 2024
7ab9876
removing duplicated implementation
pedr Apr 18, 2024
73f6ef2
changing error type to log information about the type error
pedr Apr 30, 2024
b06c4df
fix problem when trying to find files that don't exist/are too long
pedr Apr 30, 2024
cee6389
implementing read dir in js
pedr Apr 30, 2024
124a7ad
trying to find a workaround for the line_spacing implementation
pedr Apr 30, 2024
e9ef6d9
fixing width to emulate onenote page
pedr Apr 30, 2024
4560d9a
line height implementation
pedr May 3, 2024
923e4b6
wasm build artifacts
pedr May 3, 2024
4f1a3e4
fmt changes
pedr May 3, 2024
3e8d229
remove exit call
pedr May 3, 2024
0fe80b7
updating artifact
pedr May 3, 2024
c28eee1
adding first test
pedr May 3, 2024
d5349eb
testing subpage indentation
pedr May 6, 2024
1722da5
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr May 6, 2024
7938646
fixing logs calls
pedr May 8, 2024
d5522d0
bring back error instead of panicking
pedr May 8, 2024
c002b72
make subsections work as noteboks
pedr May 9, 2024
c897e3b
fixing starting point to toc if available, else use .one files
pedr May 9, 2024
990dd54
fixing type error
pedr May 9, 2024
0deb4fc
allowing injection of id generator in BaseModel
pedr May 9, 2024
b7059e7
new build artifact
pedr May 9, 2024
85d1d40
adding basic snapshot testing
pedr May 9, 2024
8da0b30
disable logs in non dev builds
pedr May 9, 2024
ab19916
transform svg node into base64 images
pedr May 10, 2024
186dcb8
partially correct, in some cases pages are created not in the correct…
pedr May 20, 2024
afaa3eb
adding fallback paragraph style data
pedr May 21, 2024
6c615bc
formatting code
pedr May 21, 2024
5dd4820
making .one files work without a onetoc2 file
pedr May 21, 2024
0bb4684
improving logs
pedr May 21, 2024
9de766c
.onetoc2 should only exist on local onenote
pedr May 21, 2024
6e3fbae
updating tests
pedr May 21, 2024
f215b04
adding one more tests about group sections
pedr May 21, 2024
11106a7
removing .one files from recycle bin
pedr May 21, 2024
a151cdb
removing err since we are actually supporting section groups
pedr May 21, 2024
8f32d2a
updating artifact
pedr May 21, 2024
4ef75ef
add readme.md
pedr May 24, 2024
55313ed
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Jun 27, 2024
09ff050
Revert "transform svg node into base64 images"
pedr Jun 27, 2024
caf3f41
adding basic extractSvg and one test for it
pedr Jun 27, 2024
bdc383f
adding more tests
pedr Jul 22, 2024
b9921f7
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Jul 31, 2024
dacad7c
wip move svg to local file
pedr Aug 2, 2024
ded7d8c
fixing svg converter
pedr Aug 2, 2024
2257f0a
remove warnings from wasm build step
pedr Aug 2, 2024
632221c
cargo fmt
pedr Aug 2, 2024
ef4ffc7
removing generated files
pedr Aug 2, 2024
7a4f24d
update gitignore
pedr Aug 2, 2024
8db9c98
add simple script to build wasm files only on production
pedr Aug 2, 2024
b6efae8
update yarn.lock
pedr Aug 5, 2024
b4b8e02
renaming to remove warning on build
pedr Aug 5, 2024
0bf0dd2
dynamically importing onenote
pedr Aug 5, 2024
4685358
fix postinstall script, add rust version priniting to ci and inlcude …
pedr Aug 5, 2024
74629a4
remove warnings
pedr Aug 5, 2024
1ae7828
fixing error message
pedr Aug 5, 2024
e4e4808
updating readme.md
pedr Aug 5, 2024
af4212a
add rust-toolchain requirement to CI
pedr Aug 5, 2024
ce027c3
add type
pedr Aug 5, 2024
a6abc97
fixing tests
pedr Aug 5, 2024
8b49159
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Aug 5, 2024
ab65546
move functions inside class
pedr Aug 7, 2024
1299e11
changing id generation to base class to allow testing
pedr Aug 7, 2024
022ea04
updating snapshot tests
pedr Aug 7, 2024
4fbc996
don't modify notes that don't have svgs
pedr Aug 7, 2024
6b2f402
add console.log to help debug
pedr Aug 7, 2024
19c3965
update run_ci to debug cicd
pedr Aug 7, 2024
03c61f6
Revert "update run_ci to debug cicd"
pedr Aug 7, 2024
b8d882f
add more tests to check if file is writable
pedr Aug 8, 2024
b2db43d
update run_ci to only run interopservice tests
pedr Aug 8, 2024
2b0b15f
forcing test to fail
pedr Aug 8, 2024
c44ef16
trying to debug cicd
pedr Aug 8, 2024
571d778
adding throw error
pedr Aug 8, 2024
7e95be4
testing error
pedr Aug 8, 2024
23a76ca
testing
pedr Aug 8, 2024
b1ff069
testing basefolder
pedr Aug 8, 2024
e7a6a17
testing with path resolve
pedr Aug 8, 2024
898f338
testing 2
pedr Aug 8, 2024
8ecd749
testing if we are finding any files
pedr Aug 8, 2024
d852080
find what files we are getting from readdir
pedr Aug 8, 2024
f20fa12
simplifying imports
pedr Aug 8, 2024
213f7f4
removing only from test
pedr Aug 8, 2024
de5e9e2
removing testing code and using shim.fsDriver to disk operations
pedr Aug 8, 2024
73a3a77
undo change to testing
pedr Aug 8, 2024
63d2bda
Test commit
pedr Aug 9, 2024
a9a4b71
Revert "Test commit"
pedr Aug 9, 2024
5dcbc0d
testing if I can commit on CI
pedr Aug 9, 2024
1f086b4
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Aug 9, 2024
027f738
Test commit on CI
Aug 9, 2024
dcca507
adding rust as a requirement to the project
Aug 12, 2024
6f89768
updating readme from onenote-converter
Aug 12, 2024
09bc30a
removing unnecessary code from run_ci
Aug 12, 2024
10ee8a2
removing files from repository
Aug 12, 2024
5276727
build script to add more information if the build process fails
Aug 12, 2024
6b46994
fixes android release
Aug 12, 2024
b213300
updating dockerfile for server
Aug 12, 2024
0970f48
adding blank line to remove change to file
Aug 12, 2024
23ebef5
cleaning up onenote importer
Aug 12, 2024
fd6133b
removing unused function
Aug 12, 2024
811dd4e
removing comment
Aug 12, 2024
223e6fb
removing target folder to free space inside docker
Aug 13, 2024
bb7a8b9
removing target folder
Aug 13, 2024
9373ee7
cleaning up github action disk space
Aug 13, 2024
6878748
removing artifact of onenote-converter
Aug 13, 2024
de25024
fixing wrong directory to be deleted
Aug 13, 2024
ef07450
fixing ci
Aug 13, 2024
640ccf5
adding logs to CI to check disk space
Aug 14, 2024
c536c45
testing disk space
Aug 14, 2024
818152f
Revert "testing disk space"
pedr Aug 14, 2024
1fc2c91
Revert "adding logs to CI to check disk space"
pedr Aug 14, 2024
992820c
removing onenote-converter of server image
pedr Aug 16, 2024
bde496a
removing unnecessary deletions
pedr Aug 16, 2024
ac3821d
removing unnecessary changes
pedr Aug 23, 2024
9515828
refactoring to a better pattern
pedr Aug 23, 2024
3b5bed2
removing code that isn't used anymore
pedr Aug 23, 2024
b82e4ea
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Aug 23, 2024
8e9ee4e
WIP simpler extractSVG implementation
pedr Aug 29, 2024
23af21b
improving extract svgs
pedr Aug 29, 2024
447892f
fixing tests
pedr Aug 30, 2024
b67d6f7
moving test out of html utils to lib and fixtures to app-cli
pedr Aug 30, 2024
e73f441
logic moved to separate PR
pedr Aug 30, 2024
dbbbb11
removing file change
pedr Aug 30, 2024
60d3533
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Aug 30, 2024
ffd3358
updating yarnlock
pedr Aug 30, 2024
50c8697
fix paragraph styles being applied to the wrong text runs
pedr Sep 4, 2024
bd08834
removing log
pedr Sep 4, 2024
55c2ae6
adding test to weird bug
pedr Sep 25, 2024
0867d6b
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Sep 25, 2024
91c6081
Merge branch 'dev' into add-onenote-parser-lib
pedr Nov 5, 2024
6c8c269
updating readme
pedr Nov 5, 2024
545d148
removing duplicated snapshot
pedr Nov 5, 2024
d166ec9
add onenote importer instructions to joplin website
pedr Nov 5, 2024
4aec0cd
Merge branch 'dev' into add-onenote-parser-lib
pedr Nov 5, 2024
406ec68
using createHTMLDocument to extract svgs
pedr Nov 6, 2024
65c86e5
Merge branch 'dev' into add-onenote-parser-lib
laurent22 Nov 6, 2024
d868321
Merge branch 'dev' into add-onenote-parser-lib
personalizedrefrigerator Nov 8, 2024
d4710d2
WIP: empty files to be used as fallback
pedr Nov 11, 2024
0152449
updating file to throw error
pedr Nov 13, 2024
33976db
removing rust as requirement
pedr Nov 13, 2024
20dddd3
Merge remote-tracking branch 'refs/remotes/origin/add-onenote-parser-…
pedr Nov 13, 2024
2494e9a
Merge remote-tracking branch 'upstream/dev' into add-onenote-parser-lib
pedr Nov 13, 2024
56bed96
deleting empty files
pedr Nov 14, 2024
c02afc4
removing rust being a requirement on readme.md
pedr Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ plugin_types/
readme/
packages/react-native-vosk/lib/
packages/lib/countable/Countable.js
packages/onenote-converter/pkg/onenote_converter.js

# AUTO-GENERATED - EXCLUDED TYPESCRIPT BUILD
packages/app-cli/app/LinkSelector.js
Expand Down Expand Up @@ -1178,6 +1179,8 @@ packages/lib/services/interop/InteropService_Importer_Md.test.js
packages/lib/services/interop/InteropService_Importer_Md.js
packages/lib/services/interop/InteropService_Importer_Md_frontmatter.test.js
packages/lib/services/interop/InteropService_Importer_Md_frontmatter.js
packages/lib/services/interop/InteropService_Importer_OneNote.test.js
packages/lib/services/interop/InteropService_Importer_OneNote.js
packages/lib/services/interop/InteropService_Importer_Raw.test.js
packages/lib/services/interop/InteropService_Importer_Raw.js
packages/lib/services/interop/Module.test.js
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ echo "IS_MACOS=$IS_MACOS"
echo "Node $( node -v )"
echo "Npm $( npm -v )"
echo "Yarn $( yarn -v )"
echo "Rust $( rustc --version )"

# =============================================================================
# Install packages
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
node-version: '18'
cache: 'yarn'

- uses: dtolnay/rust-toolchain@stable

- name: Install Yarn
run: |
corepack enable
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/github-actions-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:

- uses: actions/checkout@v4
- uses: olegtarasov/[email protected]
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-node@v4
with:
# We need to pin the version to 18.15, because 18.16+ fails with this error:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,8 @@ packages/lib/services/interop/InteropService_Importer_Md.test.js
packages/lib/services/interop/InteropService_Importer_Md.js
packages/lib/services/interop/InteropService_Importer_Md_frontmatter.test.js
packages/lib/services/interop/InteropService_Importer_Md_frontmatter.js
packages/lib/services/interop/InteropService_Importer_OneNote.test.js
packages/lib/services/interop/InteropService_Importer_OneNote.js
packages/lib/services/interop/InteropService_Importer_Raw.test.js
packages/lib/services/interop/InteropService_Importer_Raw.js
packages/lib/services/interop/Module.test.js
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ COPY packages/utils ./packages/utils
COPY packages/lib ./packages/lib
COPY packages/server ./packages/server

# We don't want to build onenote-converter since it is not used by the server
RUN sed --in-place '/onenote-converter/d' ./packages/lib/package.json

# For some reason there's both a .yarn/cache and .yarn/berry/cache that are
# being generated, and both have the same content. Not clear why it does this
# but we can delete it anyway. We can delete the cache because we use
Expand Down
3 changes: 3 additions & 0 deletions joplin.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
},
],
"settings": {
"rust-analyzer.linkedProjects": [
"./packages/onenote-converter/Cargo.toml",
],
"files.exclude": {
"_mydocs/mdtest/": true,
"_releases/": true,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 42 additions & 0 deletions packages/app-cli/tests/support/onenote/many_svgs.html

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<body>

<div class="container-outline" style="left: 48px;position: absolute;top: 107px;width: 624px;">
<svg viewBox="0 0 240 80" xmlns="http://www.w3.org/2000/svg">
<style>
.small {
font: italic 13px sans-serif;
}
.heavy {
font: bold 30px sans-serif;
}
/* Note that the color of the text is set with the *
* fill property, the color property is for HTML only */
.Rrrrr {
font: italic 40px serif;
fill: red;
}
</style>
<text x="20" y="35" class="small">My</text>
<text x="40" y="35" class="heavy">cat</text>
<text x="55" y="55" class="small">is</text>
<text x="65" y="55" class="Rrrrr">Grumpy!</text>
</svg>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions packages/app-desktop/gui/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const { ResourceScreen } = require('./ResourceScreen.js');
import Navigator from './Navigator';
import WelcomeUtils from '@joplin/lib/WelcomeUtils';
import JoplinCloudLoginScreen from './JoplinCloudLoginScreen';
import InteropService from '@joplin/lib/services/interop/InteropService';
import WindowCommandsAndDialogs from './WindowCommandsAndDialogs/WindowCommandsAndDialogs';
import { defaultWindowId, stateUtils, WindowState } from '@joplin/lib/reducer';
import bridge from '../services/bridge';
Expand Down Expand Up @@ -91,6 +92,9 @@ async function initialize() {
type: 'NOTE_VISIBLE_PANES_SET',
panes: Setting.value('noteVisiblePanes'),
});

InteropService.instance().document = document;
InteropService.instance().xmlSerializer = new XMLSerializer();
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
Expand Down
15 changes: 13 additions & 2 deletions packages/lib/BaseModel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import paginationToSql from './models/utils/paginationToSql';
import Database from './database';
import uuid from './uuid';
import time from './time';
import JoplinDatabase, { TableField } from './JoplinDatabase';
import { LoadOptions, SaveOptions } from './models/utils/types';
import ActionLogger, { ItemActionType as ItemActionType } from './utils/ActionLogger';
import { BaseItemEntity, SqlQuery } from './services/database/types';
import uuid from './uuid';
const Mutex = require('async-mutex').Mutex;

// New code should make use of this enum
Expand Down Expand Up @@ -80,6 +80,8 @@ class BaseModel {
['TYPE_COMMAND', ModelType.Command],
];

private static uuidGenerator: ()=> string = uuid.create;

public static TYPE_NOTE = ModelType.Note;
public static TYPE_FOLDER = ModelType.Folder;
public static TYPE_SETTING = ModelType.Setting;
Expand Down Expand Up @@ -576,7 +578,7 @@ class BaseModel {

if (options.isNew) {
if (this.useUuid() && !o.id) {
modelId = uuid.create();
modelId = this.generateUuid();
o.id = modelId;
}

Expand Down Expand Up @@ -757,6 +759,15 @@ class BaseModel {
return this.db_;
}

public static generateUuid() {
return this.uuidGenerator();
}

public static setIdGenerator(generator: ()=> string) {
const previous = this.uuidGenerator;
this.uuidGenerator = generator;
return previous;
}
// static isReady() {
// return !!this.db_;
// }
Expand Down
5 changes: 5 additions & 0 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
},
"devDependencies": {
"@testing-library/react-hooks": "8.0.1",
"@types/adm-zip": "0.5.5",
"@types/fs-extra": "11.0.4",
"@types/jest": "29.5.12",
"@types/js-yaml": "4.0.9",
"@types/jsdom": "21.1.6",
"@types/markdown-it": "13.0.9",
"@types/mustache": "4.2.5",
"@types/node": "18.19.42",
Expand All @@ -29,6 +31,7 @@
"canvas": "2.11.2",
"clean-html": "1.5.0",
"jest": "29.7.0",
"jsdom": "23.2.0",
"pdfjs-dist": "3.11.174",
"react": "18.3.1",
"react-test-renderer": "18.3.1",
Expand All @@ -44,11 +47,13 @@
"@joplin/fork-sax": "^1.2.56",
"@joplin/fork-uslug": "^1.0.17",
"@joplin/htmlpack": "~3.2",
"@joplin/onenote-converter": "0.0.1",
"@joplin/renderer": "~3.2",
"@joplin/turndown": "^4.0.74",
"@joplin/turndown-plugin-gfm": "^1.0.56",
"@joplin/utils": "~3.2",
"@types/nanoid": "3.0.0",
"adm-zip": "0.5.12",
"async-mutex": "0.5.0",
"base-64": "1.0.0",
"base64-stream": "1.0.0",
Expand Down
28 changes: 28 additions & 0 deletions packages/lib/services/interop/InteropService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default class InteropService {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
private eventEmitter_: any = null;
private static instance_: InteropService;
private document_: Document;
private xmlSerializer_: XMLSerializer;

public static instance(): InteropService {
if (!this.instance_) this.instance_ = new InteropService();
Expand Down Expand Up @@ -133,6 +135,14 @@ export default class InteropService {
isNoteArchive: false, // Tells whether the file can contain multiple notes (eg. Enex or Jex format)
description: _('Text document'),
}, () => new InteropService_Importer_Md()),

makeImportModule({
format: 'zip',
fileExtensions: ['zip'],
sources: [FileSystemItem.File],
isNoteArchive: false, // Tells whether the file can contain multiple notes (eg. Enex or Jex format)
description: _('OneNote Notebook'),
}, dynamicRequireModuleFactory('./InteropService_Importer_OneNote')),
];

const exportModules = [
Expand Down Expand Up @@ -189,6 +199,22 @@ export default class InteropService {
this.eventEmitter_.emit('modulesChanged');
}

public set xmlSerializer(xmlSerializer: XMLSerializer) {
this.xmlSerializer_ = xmlSerializer;
}

public get xmlSerializer() {
return this.xmlSerializer_;
}

public set document(document: Document) {
this.document_ = document;
}

public get document() {
return this.document_;
}

// Find the module that matches the given type ("importer" or "exporter")
// and the given format. Some formats can have multiple associated importers
// or exporters, such as ENEX. In this case, the one marked as "isDefault"
Expand Down Expand Up @@ -273,6 +299,8 @@ export default class InteropService {
format: 'auto',
destinationFolderId: null,
destinationFolder: null,
xmlSerializer: this.xmlSerializer,
document: this.document,
...options,
};

Expand Down
Loading
Loading