const sax = require("sax"); const stream = require('stream'); const {Throttle} = require('stream-throttle'); const log = require("../log"); const utils = require("../utils"); const sql = require("../sql"); const noteService = require("../notes"); const imageService = require("../image"); const protectedSessionService = require('../protected_session'); const htmlSanitizer = require("../html_sanitizer"); const attributeService = require("../attributes"); const {sanitizeAttributeName} = require("../sanitize_attribute_name.js"); // date format is e.g. 20181121T193703Z function parseDate(text) { // insert - and : to make it ISO format text = `${text.substr(0, 4)}-${text.substr(4, 2)}-${text.substr(6, 2)} ${text.substr(9, 2)}:${text.substr(11, 2)}:${text.substr(13, 2)}.000Z`; return text; } let note = {}; let resource; function importEnex(taskContext, file, parentNote) { const saxStream = sax.createStream(true); const rootNoteTitle = file.originalname.toLowerCase().endsWith(".enex") ? file.originalname.substr(0, file.originalname.length - 5) : file.originalname; // root note is new note into all ENEX/notebook's notes will be imported const rootNote = noteService.createNewNote({ parentNoteId: parentNote.noteId, title: rootNoteTitle, content: "", type: 'text', mime: 'text/html', isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), }).note; function extractContent(content) { const openingNoteIndex = content.indexOf(''); if (openingNoteIndex !== -1) { content = content.substr(openingNoteIndex + 9); } const closingNoteIndex = content.lastIndexOf(''); if (closingNoteIndex !== -1) { content = content.substr(0, closingNoteIndex); } content = content.trim(); // workaround for https://github.com/ckeditor/ckeditor5-list/issues/116 content = content.replace(/
  • \s*
    /g, "
  • "); content = content.replace(/<\/div>\s*<\/li>/g, "
  • "); // workaround for https://github.com/ckeditor/ckeditor5-list/issues/115 content = content.replace(/