mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
fix in ENEX import
This commit is contained in:
parent
13b9f5231c
commit
d57a303251
@ -53,7 +53,7 @@ function addClipping(req) {
|
|||||||
clippingNote.setLabel('pageUrl', pageUrl);
|
clippingNote.setLabel('pageUrl', pageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rewrittenContent = addImagesToNote(images, clippingNote, content);
|
const rewrittenContent = processContent(images, clippingNote, content);
|
||||||
|
|
||||||
const existingContent = clippingNote.getContent();
|
const existingContent = clippingNote.getContent();
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ function createNote(req) {
|
|||||||
note.setLabel('pageUrl', pageUrl);
|
note.setLabel('pageUrl', pageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rewrittenContent = addImagesToNote(images, note, content);
|
const rewrittenContent = processContent(images, note, content);
|
||||||
|
|
||||||
note.setContent(rewrittenContent);
|
note.setContent(rewrittenContent);
|
||||||
|
|
||||||
@ -94,8 +94,11 @@ function createNote(req) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function addImagesToNote(images, note, content) {
|
function processContent(images, note, content) {
|
||||||
let rewrittenContent = content;
|
// H1 is not supported so convert it to H2
|
||||||
|
let rewrittenContent = content
|
||||||
|
.replace(/<h1/ig, "<h2")
|
||||||
|
.replace(/<\/h1/ig, "</h2");
|
||||||
|
|
||||||
if (images) {
|
if (images) {
|
||||||
for (const {src, dataUrl, imageId} of images) {
|
for (const {src, dataUrl, imageId} of images) {
|
||||||
|
@ -250,14 +250,14 @@ function importEnex(taskContext, file, parentNote) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createFileNote = () => {
|
const createFileNote = () => {
|
||||||
const resourceNote = (noteService.createNewNote({
|
const resourceNote = noteService.createNewNote({
|
||||||
parentNoteId: noteEntity.noteId,
|
parentNoteId: noteEntity.noteId,
|
||||||
title: resource.title,
|
title: resource.title,
|
||||||
content: resource.content,
|
content: resource.content,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
mime: resource.mime,
|
mime: resource.mime,
|
||||||
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
|
isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
|
||||||
})).note;
|
}).note;
|
||||||
|
|
||||||
for (const attr of resource.attributes) {
|
for (const attr of resource.attributes) {
|
||||||
noteEntity.addAttribute(attr.type, attr.name, attr.value);
|
noteEntity.addAttribute(attr.type, attr.name, attr.value);
|
||||||
|
@ -11,9 +11,9 @@ const IGNORED_ATTR_NAMES = [
|
|||||||
|
|
||||||
function filterLabelValue(value) {
|
function filterLabelValue(value) {
|
||||||
return value
|
return value
|
||||||
.replace(/https?:\/\//i, "")
|
.replace(/https?:\/\//ig, "")
|
||||||
.replace(/www\./i, "")
|
.replace(/www\./ig, "")
|
||||||
.replace(/(\.net|\.com|\.org|\.info|\.edu)/i, "");
|
.replace(/(\.net|\.com|\.org|\.info|\.edu)/ig, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,6 +55,8 @@ function deriveMime(type, mime) {
|
|||||||
mime = 'application/json';
|
mime = 'application/json';
|
||||||
} else if (['render', 'book'].includes(type)) {
|
} else if (['render', 'book'].includes(type)) {
|
||||||
mime = '';
|
mime = '';
|
||||||
|
} else {
|
||||||
|
mime = 'application/octet-stream';
|
||||||
}
|
}
|
||||||
|
|
||||||
return mime;
|
return mime;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user