mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
server-ts: Address requested changes
This commit is contained in:
@@ -7,7 +7,7 @@ import importUtils = require('./utils');
|
||||
function renderToHtml(content: string, title: string) {
|
||||
const html = marked.parse(content, {
|
||||
async: false
|
||||
}) as string; // FIXME: mangle and headerIds does not seem to exist in marked
|
||||
}) as string;
|
||||
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
|
||||
return htmlSanitizer.sanitize(h1Handled);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,7 @@ import mimeService = require('./mime');
|
||||
import utils = require('../../services/utils');
|
||||
import importUtils = require('./utils');
|
||||
import htmlSanitizer = require('../html_sanitizer');
|
||||
|
||||
interface File {
|
||||
originalname: string;
|
||||
mimetype: string;
|
||||
buffer: string | Buffer;
|
||||
}
|
||||
import { File } from "./common";
|
||||
|
||||
function importSingleFile(taskContext: TaskContext, file: File, parentNote: BNote) {
|
||||
const mime = mimeService.getMime(file.originalname) || file.mimetype;
|
||||
|
||||
@@ -35,8 +35,8 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
||||
// path => noteId, used only when meta file is not available
|
||||
/** path => noteId | attachmentId */
|
||||
const createdPaths: Record<string, string> = { '/': importRootNote.noteId, '\\': importRootNote.noteId };
|
||||
let metaFile!: MetaFile;
|
||||
let firstNote!: BNote;
|
||||
let metaFile: MetaFile | null = null;
|
||||
let firstNote: BNote | null = null;
|
||||
const createdNoteIds = new Set<string>();
|
||||
|
||||
function getNewNoteId(origNoteId: string) {
|
||||
@@ -99,7 +99,7 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
||||
dataFileName: ""
|
||||
};
|
||||
|
||||
let parent!: NoteMeta;
|
||||
let parent: NoteMeta | undefined = undefined;
|
||||
|
||||
for (const segment of pathSegments) {
|
||||
if (!cursor?.children?.length) {
|
||||
@@ -590,6 +590,10 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstNote) {
|
||||
throw new Error("Unable to determine first note.");
|
||||
}
|
||||
|
||||
return firstNote;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user