make file attachments accessible in revisions dialog

This commit is contained in:
zadam 2023-07-10 20:30:04 +02:00
parent ac9a4b3afc
commit a748710b01
3 changed files with 7 additions and 3 deletions

View file

@ -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});

View file

@ -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;

View file

@ -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()) {