mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
Merge branch 'stable'
# Conflicts: # src/services/build.js
This commit is contained in:
@@ -1 +1 @@
|
||||
module.exports = { buildDate:"", buildRevision: "9881e6de3e4966af39ec6245562dca6ac7b25eaa" };
|
||||
module.exports = { buildDate:"2023-04-17T21:40:35+02:00", buildRevision: "1d3272e9f8c27106a66227fbb580677ae5d70427" };
|
||||
|
||||
@@ -21,6 +21,7 @@ const dayjs = require("dayjs");
|
||||
const htmlSanitizer = require("./html_sanitizer");
|
||||
const ValidationError = require("../errors/validation_error");
|
||||
const noteTypesService = require("./note_types");
|
||||
const fs = require("fs");
|
||||
|
||||
function getNewNotePosition(parentNote) {
|
||||
if (parentNote.isLabelTruthy('newNotesOnTop')) {
|
||||
@@ -375,7 +376,24 @@ const imageUrlToNoteIdMapping = {};
|
||||
|
||||
async function downloadImage(noteId, imageUrl) {
|
||||
try {
|
||||
const imageBuffer = await request.getImage(imageUrl);
|
||||
let imageBuffer;
|
||||
|
||||
if (imageUrl.toLowerCase().startsWith("file://")) {
|
||||
imageBuffer = await new Promise((res, rej) => {
|
||||
const localFilePath = imageUrl.substr("file://".length);
|
||||
|
||||
return fs.readFile(localFilePath, (err, data) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else {
|
||||
res(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
imageBuffer = await request.getImage(imageUrl);
|
||||
}
|
||||
|
||||
const parsedUrl = url.parse(imageUrl);
|
||||
const title = path.basename(parsedUrl.pathname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user