From a748710b01e2d5f93706f0d06d6cc0f0a020fed5 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 10 Jul 2023 20:30:04 +0200 Subject: [PATCH] make file attachments accessible in revisions dialog --- src/becca/entities/bnote.js | 6 +++++- src/public/app/services/froca.js | 2 +- src/public/app/services/link.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.js index ec7314b30..fdea88e26 100644 --- a/src/becca/entities/bnote.js +++ b/src/becca/entities/bnote.js @@ -1594,7 +1594,11 @@ class BNote extends AbstractBeccaEntity { revisionAttachment.setContent(noteAttachment.getContent(), {forceSave: true}); // content is rewritten to point to the revision attachments - noteContent = noteContent.replaceAll(`attachments/${noteAttachment.attachmentId}`, `attachments/${revisionAttachment.attachmentId}`); + noteContent = noteContent.replaceAll(`attachments/${noteAttachment.attachmentId}`, + `attachments/${revisionAttachment.attachmentId}`); + + noteContent = noteContent.replaceAll(new RegExp(`href="[^"]*attachmentId=${noteAttachment.attachmentId}[^"]*"`, 'gi'), + `href="api/attachments/${revisionAttachment.attachmentId}/download"`); } revision.setContent(noteContent, {forceSave: true}); diff --git a/src/public/app/services/froca.js b/src/public/app/services/froca.js index 6c947888e..9d45686fa 100644 --- a/src/public/app/services/froca.js +++ b/src/public/app/services/froca.js @@ -328,7 +328,7 @@ class Froca { } catch (e) { if (silentNotFoundError) { - logInfo(`Attachment '${attachmentId} not found, but silentNotFoundError is enabled: ` + e.message); + logInfo(`Attachment '${attachmentId}' not found, but silentNotFoundError is enabled: ` + e.message); return null; } else { throw e; diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index c96a5ad7b..f2c0e9ee3 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -228,7 +228,7 @@ function goToLink(evt) { || (withinEditLink && (leftClick || middleClick)) || (outsideOfCKEditor && (leftClick || middleClick)) ) { - if (hrefLink.toLowerCase().startsWith('http')) { + if (hrefLink.toLowerCase().startsWith('http') || hrefLink.startsWith("api/")) { window.open(hrefLink, '_blank'); } else if (hrefLink.toLowerCase().startsWith('file:') && utils.isElectron()) {