Merge branch 'stable'

This commit is contained in:
zadam 2023-11-14 00:19:15 +01:00
commit 5d52498da1
6 changed files with 16 additions and 27 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1174,14 +1174,8 @@ class BNote extends AbstractBeccaEntity {
/** @returns {BAttachment} */
getAttachmentByTitle(title) {
return sql.getRows(`
SELECT attachments.*
FROM attachments
WHERE ownerId = ?
AND title = ?
AND isDeleted = 0
ORDER BY position`, [this.noteId, title])
.map(row => new BAttachment(row))[0];
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
/**

View File

@ -157,14 +157,8 @@ class BRevision extends AbstractBeccaEntity {
/** @returns {BAttachment} */
getAttachmentByTitle(title) {
return sql.getRows(`
SELECT attachments.*
FROM attachments
WHERE ownerId = ?
AND title = ?
AND isDeleted = 0
ORDER BY position`, [this.revisionId, title])
.map(row => new BAttachment(row))[0];
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
beforeSaving() {

View File

@ -268,7 +268,9 @@ function linkContextMenu(e) {
}
async function loadReferenceLinkTitle($el, href = null) {
href = href || $el.find("a").attr("href");
const $link = $el[0].tagName === 'A' ? $el : $el.find("a");
href = href || $link.attr("href");
if (!href) {
console.warn("Empty URL for parsing: " + $el[0].outerHTML);
return;
@ -286,7 +288,7 @@ async function loadReferenceLinkTitle($el, href = null) {
if (note) {
const icon = await getLinkIcon(noteId, viewScope.viewMode);
k
$el.prepend($("<span>").addClass(icon));
}
}

View File

@ -75,15 +75,14 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true)
* @return {string}
*/
function getDataFileName(type, mime, baseFileName, existingFileNames) {
let fileName = baseFileName;
let fileName = baseFileName.trim();
if (fileName.length > 30) {
fileName = fileName.substr(0, 30).trim();
}
let existingExtension = path.extname(fileName).toLowerCase();
let newExtension;
if (fileName.length > 30) {
fileName = fileName.substr(0, 30);
}
// the following two are handled specifically since we always want to have these extensions no matter the automatic detection
// and/or existing detected extensions in the note name
if (type === 'text' && format === 'markdown') {
@ -108,7 +107,7 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true)
}
}
// if the note is already named with extension (e.g. "jquery"), then it's silly to append the exact same extension again
// if the note is already named with the extension (e.g. "image.jpg"), then it's silly to append the exact same extension again
if (newExtension && existingExtension !== `.${newExtension.toLowerCase()}`) {
fileName += `.${newExtension}`;
}