diff --git a/src/public/app/widgets/type_widgets/file.js b/src/public/app/widgets/type_widgets/file.js index 275138781..910ec5264 100644 --- a/src/public/app/widgets/type_widgets/file.js +++ b/src/public/app/widgets/type_widgets/file.js @@ -121,7 +121,7 @@ export default class FileTypeWidget extends TypeWidget { this.$pdfPreview.attr('src', '').empty().hide(); if (noteComplement.content) { - this.$previewContent.show(); + this.$previewContent.show().scrollTop(0); this.$previewContent.text(noteComplement.content); } else if (note.mime === 'application/pdf' && utils.isElectron()) { diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index 12f58540b..98f4edf9b 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -17,8 +17,9 @@ async function getNote(req) { if (note.isStringNote()) { note.content = await note.getContent(); - if (note.type === 'file') { - note.content = note.content.substr(0, 10000); + if (note.type === 'file' && note.content.length > 10000) { + note.content = note.content.substr(0, 10000) + + `\r\n\r\n... and ${note.content.length - 10000} more characters.`; } } diff --git a/src/services/utils.js b/src/services/utils.js index 78942a680..db75ce32f 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -159,7 +159,11 @@ function getContentDisposition(filename) { return `file; filename="${sanitizedFilename}"; filename*=UTF-8''${sanitizedFilename}`; } -const STRING_MIME_TYPES = ["application/x-javascript", "image/svg+xml"]; +const STRING_MIME_TYPES = [ + "application/javascript", + "application/x-javascript", + "image/svg+xml" +]; function isStringNote(type, mime) { return ["text", "code", "relation-map", "search"].includes(type)