added ImportContext

This commit is contained in:
zadam
2019-02-10 19:36:03 +01:00
parent 5baa251944
commit e4c78f3887
8 changed files with 118 additions and 58 deletions

View File

@@ -4,7 +4,7 @@ const noteService = require('../../services/notes');
const commonmark = require('commonmark');
const path = require('path');
async function importMarkdown(file, parentNote) {
async function importMarkdown(importContext, file, parentNote) {
const markdownContent = file.buffer.toString("UTF-8");
const reader = new commonmark.Parser();
@@ -20,10 +20,13 @@ async function importMarkdown(file, parentNote) {
mime: 'text/html'
});
importContext.increaseCount();
importContext.importFinished(note.noteId);
return note;
}
async function importHtml(file, parentNote) {
async function importHtml(importContext, file, parentNote) {
const title = getFileNameWithoutExtension(file.originalname);
const content = file.buffer.toString("UTF-8");
@@ -32,6 +35,9 @@ async function importHtml(file, parentNote) {
mime: 'text/html'
});
importContext.increaseCount();
importContext.importFinished(note.noteId);
return note;
}