fix broken inline PDF viewer, #1833

This commit is contained in:
zadam 2021-04-24 20:27:42 +02:00
parent a74741343e
commit dcd35b1ea2
5 changed files with 13 additions and 12 deletions

View File

@ -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": {

View File

@ -59,7 +59,7 @@ async function getRenderedContent(note, options = {}) {
}
else if (type === 'audio') {
const $audioPreview = $('<audio controls></audio>')
.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 = $('<video controls></video>')
.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%");

View File

@ -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());
}

View File

@ -164,11 +164,6 @@ div.ui-tooltip {
overflow: auto;
}
.alert {
padding: 5px;
width: auto;
}
/*
* .search-inactive is added to search window <webview> 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;
}

View File

@ -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); }
}));