mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
alert for missing file preview
This commit is contained in:
parent
ae26f22114
commit
6b306ac426
@ -25,6 +25,10 @@ const TPL = `
|
||||
|
||||
<pre class="file-preview-content"></pre>
|
||||
|
||||
<div class="file-preview-not-available alert alert-info">
|
||||
File preview is not available for this file format.
|
||||
</div>
|
||||
|
||||
<iframe class="pdf-preview" style="width: 100%; height: 100%; flex-grow: 100;"></iframe>
|
||||
</div>`;
|
||||
|
||||
@ -35,6 +39,7 @@ export default class FileTypeWidget extends TypeWidget {
|
||||
this.$widget = $(TPL);
|
||||
this.contentSized();
|
||||
this.$previewContent = this.$widget.find(".file-preview-content");
|
||||
this.$previewNotAvailable = this.$widget.find(".file-preview-not-available");
|
||||
this.$pdfPreview = this.$widget.find(".pdf-preview");
|
||||
}
|
||||
|
||||
@ -50,12 +55,17 @@ export default class FileTypeWidget extends TypeWidget {
|
||||
this.$pdfPreview.attr('src', '').empty().hide();
|
||||
|
||||
if (noteComplement.content) {
|
||||
this.$previewNotAvailable.hide();
|
||||
this.$previewContent.show().scrollTop(0);
|
||||
this.$previewContent.text(noteComplement.content);
|
||||
}
|
||||
else if (note.mime === 'application/pdf') {
|
||||
this.$previewNotAvailable.hide();
|
||||
this.$pdfPreview.show();
|
||||
this.$pdfPreview.attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open"));
|
||||
}
|
||||
else {
|
||||
this.$previewNotAvailable.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href
|
||||
height: 50em; /* PDF is rendered in iframe and it's not possible to put full height so at least a large height */
|
||||
}
|
||||
|
||||
.alert-warning {
|
||||
.alert-warning, .alert-info {
|
||||
color: var(--main-text-color) !important;
|
||||
background-color: var(--accented-background-color) !important;
|
||||
border-color: var(--main-border-color) !important;
|
||||
|
@ -161,6 +161,8 @@ function getContentDisposition(filename) {
|
||||
const STRING_MIME_TYPES = [
|
||||
"application/javascript",
|
||||
"application/x-javascript",
|
||||
"application/json",
|
||||
"application/x-sql",
|
||||
"image/svg+xml"
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user