fix in ENEX import

This commit is contained in:
zadam 2020-09-16 20:32:20 +02:00
parent 13b9f5231c
commit d57a303251
4 changed files with 14 additions and 9 deletions

View file

@ -53,7 +53,7 @@ function addClipping(req) {
clippingNote.setLabel('pageUrl', pageUrl);
}
const rewrittenContent = addImagesToNote(images, clippingNote, content);
const rewrittenContent = processContent(images, clippingNote, content);
const existingContent = clippingNote.getContent();
@ -85,7 +85,7 @@ function createNote(req) {
note.setLabel('pageUrl', pageUrl);
}
const rewrittenContent = addImagesToNote(images, note, content);
const rewrittenContent = processContent(images, note, content);
note.setContent(rewrittenContent);
@ -94,8 +94,11 @@ function createNote(req) {
};
}
function addImagesToNote(images, note, content) {
let rewrittenContent = content;
function processContent(images, note, content) {
// H1 is not supported so convert it to H2
let rewrittenContent = content
.replace(/<h1/ig, "<h2")
.replace(/<\/h1/ig, "</h2");
if (images) {
for (const {src, dataUrl, imageId} of images) {

View file

@ -250,14 +250,14 @@ function importEnex(taskContext, file, parentNote) {
}
const createFileNote = () => {
const resourceNote = (noteService.createNewNote({
const resourceNote = noteService.createNewNote({
parentNoteId: noteEntity.noteId,
title: resource.title,
content: resource.content,
type: 'file',
mime: resource.mime,
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
})).note;
}).note;
for (const attr of resource.attributes) {
noteEntity.addAttribute(attr.type, attr.name, attr.value);

View file

@ -11,9 +11,9 @@ const IGNORED_ATTR_NAMES = [
function filterLabelValue(value) {
return value
.replace(/https?:\/\//i, "")
.replace(/www\./i, "")
.replace(/(\.net|\.com|\.org|\.info|\.edu)/i, "");
.replace(/https?:\/\//ig, "")
.replace(/www\./ig, "")
.replace(/(\.net|\.com|\.org|\.info|\.edu)/ig, "");
}
/**

View file

@ -55,6 +55,8 @@ function deriveMime(type, mime) {
mime = 'application/json';
} else if (['render', 'book'].includes(type)) {
mime = '';
} else {
mime = 'application/octet-stream';
}
return mime;