1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Desktop: Fixes #4073: Resource links could not be opened from Rich Text editor on Linux

This commit is contained in:
Laurent Cozic
2020-11-14 10:59:26 +00:00
parent 6463af0c31
commit 2b95bce272
2 changed files with 16 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ const ArrayUtils = require('../ArrayUtils.js');
const lodash = require('lodash');
const urlUtils = require('../urlUtils.js');
const markdownUtils = require('../markdownUtils').default;
const { isImageMimeType } = require('../resourceUtils');
const { MarkupToHtml } = require('@joplin/renderer');
const { ALL_NOTES_FILTER_ID } = require('../reserved-ids');
@@ -149,7 +150,14 @@ class Note extends BaseItem {
const id = resourceIds[i];
const resource = await Resource.load(id);
if (!resource) continue;
const resourcePath = options.useAbsolutePaths ? `${`file://${Resource.fullPath(resource)}` + '?t='}${resource.updated_time}` : Resource.relativePath(resource);
const isImage = isImageMimeType(resource.mime);
// We add a timestamp parameter for images, so that when they
// change, the preview is updated inside the note. This is not
// needed for other resources since they are simple links.
const timestampParam = isImage ? `?t=${resource.updated_time}` : '';
const resourcePath = options.useAbsolutePaths ? `file://${Resource.fullPath(resource)}${timestampParam}` : Resource.relativePath(resource);
body = body.replace(new RegExp(`:/${id}`, 'gi'), markdownUtils.escapeLinkUrl(resourcePath));
}