Merge remote-tracking branch 'origin/stable'

# Conflicts:
#	src/public/app/dialogs/options/other.js
This commit is contained in:
zadam 2021-12-19 10:54:30 +01:00
commit 2ff6e50af4
7 changed files with 45 additions and 16 deletions

View file

@ -84,7 +84,7 @@ class Branch extends AbstractEntity {
/** @returns {Note} */
get childNote() {
if (!(this.noteId in this.becca.notes)) {
// entities can come out of order in sync, create skeleton which will be filled later
// entities can come out of order in sync/import, create skeleton which will be filled later
this.becca.addNote(this.noteId, new Note({noteId: this.noteId}));
}
@ -98,7 +98,7 @@ class Branch extends AbstractEntity {
/** @returns {Note} */
get parentNote() {
if (!(this.parentNoteId in this.becca.notes)) {
// entities can come out of order in sync, create skeleton which will be filled later
// entities can come out of order in sync/import, create skeleton which will be filled later
this.becca.addNote(this.parentNoteId, new Note({noteId: this.parentNoteId}));
}

View file

@ -47,8 +47,8 @@ const TPL = `
</div>
<div class="form-group">
<label for="image-jpeg-quality">JPEG quality (0 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
<input class="form-control" id="image-jpeg-quality" min="0" max="100" type="number">
<label for="image-jpeg-quality">JPEG quality (10 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
<input class="form-control" id="image-jpeg-quality" min="10" max="100" type="number">
</div>
</div>
</div>

View file

@ -44,7 +44,10 @@ export default class ButtonWidget extends NoteContextAwareWidget {
this.$widget.tooltip({
html: true,
title: () => {
const title = this.settings.title;
const title = typeof this.settings.title === "function"
? this.settings.title()
: this.settings.title;
const action = actions.find(act => act.actionName === this.settings.command);
if (action && action.effectiveShortcuts.length > 0) {

View file

@ -18,7 +18,12 @@ export default class OpenNoteButtonWidget extends ButtonWidget {
}
this.icon(note.getIcon());
this.title(note.title);
this.title(() => {
const n = froca.getNoteFromCache(noteId);
// always fresh, always decoded (when protected session is available)
return n.title;
});
this.refreshIcon();
});

View file

@ -50,7 +50,13 @@ function exportToZip(taskContext, branch, format, res) {
}
function getDataFileName(note, baseFileName, existingFileNames) {
const existingExtension = path.extname(baseFileName).toLowerCase();
let fileName = baseFileName;
if (fileName.length > 30) {
fileName = fileName.substr(0, 30);
}
let existingExtension = path.extname(fileName).toLowerCase();
let newExtension;
// following two are handled specifically since we always want to have these extensions no matter the automatic detection
@ -68,13 +74,12 @@ function exportToZip(taskContext, branch, format, res) {
newExtension = null;
}
else {
newExtension = mimeTypes.extension(note.mime) || "dat";
}
let fileName = baseFileName;
if (fileName.length > 30) {
fileName = fileName.substr(0, 30);
if (note.mime?.toLowerCase()?.trim() === "image/jpg") {
newExtension = 'jpg';
}
else {
newExtension = mimeTypes.extension(note.mime) || "dat";
}
}
// if the note is already named with extension (e.g. "jquery"), then it's silly to append exact same extension again

View file

@ -123,7 +123,11 @@ function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch,
}
async function shrinkImage(buffer, originalName) {
const jpegQuality = optionService.getOptionInt('imageJpegQuality');
let jpegQuality = optionService.getOptionInt('imageJpegQuality');
if (jpegQuality < 10 || jpegQuality > 100) {
jpegQuality = 75;
}
let finalImageBuffer;
try {

View file

@ -351,7 +351,19 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
let note = becca.getNote(noteId);
const isProtected = importRootNote.isProtected && protectedSessionService.isProtectedSessionAvailable();
if (note) {
// only skeleton was created because of altered order of cloned notes in ZIP, we need to update
// https://github.com/zadam/trilium/issues/2440
if (note.type === undefined) {
note.type = type;
note.mime = mime;
note.title = noteTitle;
note.isProtected = isProtected;
note.save();
}
note.setContent(content);
}
else {
@ -367,7 +379,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) {
// root notePosition should be ignored since it relates to original document
// now import root should be placed after existing notes into new parent
notePosition: (noteMeta && firstNote) ? noteMeta.notePosition : undefined,
isProtected: importRootNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),
isProtected: isProtected,
}));
createdNoteIds[note.noteId] = true;