mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
download offline images from libreoffice, fixes #3842
This commit is contained in:
parent
e4376bb9f2
commit
8226f62ded
1
package-lock.json
generated
1
package-lock.json
generated
@ -5,6 +5,7 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "trilium",
|
||||||
"version": "0.59.3",
|
"version": "0.59.3",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import libraryLoader from "../services/library_loader.js";
|
import libraryLoader from "../services/library_loader.js";
|
||||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||||
import froca from "../services/froca.js";
|
import froca from "../services/froca.js";
|
||||||
import server from "../services/server.js";
|
|
||||||
|
|
||||||
const TPL = `<div class="mermaid-widget">
|
const TPL = `<div class="mermaid-widget">
|
||||||
<style>
|
<style>
|
||||||
|
@ -21,6 +21,7 @@ const dayjs = require("dayjs");
|
|||||||
const htmlSanitizer = require("./html_sanitizer");
|
const htmlSanitizer = require("./html_sanitizer");
|
||||||
const ValidationError = require("../errors/validation_error");
|
const ValidationError = require("../errors/validation_error");
|
||||||
const noteTypesService = require("./note_types");
|
const noteTypesService = require("./note_types");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
function getNewNotePosition(parentNote) {
|
function getNewNotePosition(parentNote) {
|
||||||
if (parentNote.isLabelTruthy('newNotesOnTop')) {
|
if (parentNote.isLabelTruthy('newNotesOnTop')) {
|
||||||
@ -375,7 +376,24 @@ const imageUrlToNoteIdMapping = {};
|
|||||||
|
|
||||||
async function downloadImage(noteId, imageUrl) {
|
async function downloadImage(noteId, imageUrl) {
|
||||||
try {
|
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 parsedUrl = url.parse(imageUrl);
|
||||||
const title = path.basename(parsedUrl.pathname);
|
const title = path.basename(parsedUrl.pathname);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user