From dcd35b1ea26df0d08642679b3a5943b559863040 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 24 Apr 2021 20:27:42 +0200 Subject: [PATCH] fix broken inline PDF viewer, #1833 --- package.json | 2 +- src/public/app/services/note_content_renderer.js | 4 ++-- src/public/app/widgets/type_widgets/file.js | 4 ++-- src/public/stylesheets/style.css | 12 ++++++------ src/routes/routes.js | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 4f280c338..e3d6192f1 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "jsdoc": "3.6.6", "lorem-ipsum": "2.0.3", "rcedit": "3.0.0", - "webpack": "5.35.0", + "webpack": "5.35.1", "webpack-cli": "4.6.0" }, "optionalDependencies": { diff --git a/src/public/app/services/note_content_renderer.js b/src/public/app/services/note_content_renderer.js index 1ae731ddd..e01fbd2fc 100644 --- a/src/public/app/services/note_content_renderer.js +++ b/src/public/app/services/note_content_renderer.js @@ -59,7 +59,7 @@ async function getRenderedContent(note, options = {}) { } else if (type === 'audio') { const $audioPreview = $('') - .attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open")) + .attr("src", openService.getUrlForStreaming("api/notes/" + note.noteId + "/open-partial")) .attr("type", note.mime) .css("width", "100%"); @@ -67,7 +67,7 @@ async function getRenderedContent(note, options = {}) { } else if (type === 'video') { const $videoPreview = $('') - .attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open")) + .attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open-partial")) .attr("type", note.mime) .css("width", "100%"); diff --git a/src/public/app/widgets/type_widgets/file.js b/src/public/app/widgets/type_widgets/file.js index ae88275eb..a5e7410bd 100644 --- a/src/public/app/widgets/type_widgets/file.js +++ b/src/public/app/widgets/type_widgets/file.js @@ -93,14 +93,14 @@ export default class FileTypeWidget extends TypeWidget { else if (note.mime.startsWith('video/')) { this.$videoPreview .show() - .attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open")) + .attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open-partial")) .attr("type", this.note.mime) .css("width", this.$widget.width()); } else if (note.mime.startsWith('audio/')) { this.$audioPreview .show() - .attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open")) + .attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open-partial")) .attr("type", this.note.mime) .css("width", this.$widget.width()); } diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 9b01b031d..afab962f5 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -164,11 +164,6 @@ div.ui-tooltip { overflow: auto; } -.alert { - padding: 5px; - width: auto; -} - /* * .search-inactive is added to search window when the window * is inactive. @@ -761,9 +756,14 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href width: 100%; } +.alert { + padding: 8px 14px; + width: auto; +} + .alert-warning, .alert-info { color: var(--main-text-color) !important; - background-color: var(--accented-background-color) !important; + background-color: transparent !important; border-color: var(--main-border-color) !important; } diff --git a/src/routes/routes.js b/src/routes/routes.js index 4c9e9a6c7..681c6afe5 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -178,7 +178,8 @@ function register(app) { route(PUT, '/api/notes/:noteId/file', [auth.checkApiAuthOrElectron, uploadMiddleware, csrfMiddleware], filesRoute.updateFile, apiResultHandler); - route(GET, '/api/notes/:noteId/open', [auth.checkApiAuthOrElectron], + route(GET, '/api/notes/:noteId/open', [auth.checkApiAuthOrElectron], filesRoute.openFile); + route(GET, '/api/notes/:noteId/open-partial', [auth.checkApiAuthOrElectron], createPartialContentHandler(filesRoute.fileContentProvider, { debug: (string, extra) => { console.log(string, extra); } }));