Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
wip
zadam8e913cb453c1
diff --git a/src/public/app/widgets/attachment_detail.js b/src/public/app/widgets/attachment_detail.jsindex 55c87caaf9..4644a02c3f 100644--- a/src/public/app/widgets/attachment_detail.js+++ b/src/public/app/widgets/attachment_detail.js@@ -170,8 +170,20 @@ export default class AttachmentDetailWidget extends BasicWidget {this.$wrapper.find('.attachment-content-wrapper').append((await contentRenderer.getRenderedContent(this.attachment)).$renderedContent);}- copyAttachmentReferenceToClipboard() {- imageService.copyImageReferenceToClipboard(this.$wrapper.find('.attachment-content-wrapper'));+ async copyAttachmentLinkToClipboard() {+ if (this.attachment.role === 'image') {+ imageService.copyImageReferenceToClipboard(this.$wrapper.find('.attachment-content-wrapper'));+ } else if (this.attachment.role === 'file') {+ const $link = await linkService.createNoteLink(this.attachment.parentId, {+ referenceLink: true,+ viewScope: {+ viewMode: 'attachments',+ attachmentId: this.attachment.attachmentId+ }+ });+ } else {+ throw new Error(`Unrecognized attachment role '${this.attachment.role}'.`);+ }}async entitiesReloadedEvent({loadResults}) {diff --git a/src/public/app/widgets/buttons/attachments_actions.js b/src/public/app/widgets/buttons/attachments_actions.jsindex 6a909e0ac2..269bdb9ccf 100644--- a/src/public/app/widgets/buttons/attachments_actions.js+++ b/src/public/app/widgets/buttons/attachments_actions.js@@ -33,7 +33,7 @@ const TPL = `title="File will be open in an external application and watched for changes. You'll then be able to upload the modified version back to Trilium.">Open externally</a><a data-trigger-command="downloadAttachment" class="dropdown-item">Download</a><a data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item">Upload new revision</a>- <a data-trigger-command="copyAttachmentReferenceToClipboard" class="dropdown-item">Copy reference to clipboard</a>+ <a data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item">Copy link to clipboard</a><a data-trigger-command="convertAttachmentIntoNote" class="dropdown-item">Convert attachment into note</a><a data-trigger-command="deleteAttachment" class="dropdown-item">Delete attachment</a></div>@@ -56,7 +56,7 @@ export default class AttachmentActionsWidget extends BasicWidget {doRender() {this.$widget = $(TPL);this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));- this.$widget.find("[data-trigger-command='copyAttachmentReferenceToClipboard']").toggle(this.attachment.role === 'image');+ this.$widget.find("[data-trigger-command='copyAttachmentLinkToClipboard']").toggle(this.attachment.role === 'image');this.$uploadNewRevisionInput = this.$widget.find(".attachment-upload-new-revision-input");this.$uploadNewRevisionInput.on('change', async () => {@@ -107,8 +107,8 @@ export default class AttachmentActionsWidget extends BasicWidget {this.$uploadNewRevisionInput.trigger('click');}- async copyAttachmentReferenceToClipboardCommand() {- this.parent.copyAttachmentReferenceToClipboard();+ async copyAttachmentLinkToClipboardCommand() {+ this.parent.copyAttachmentLinkToClipboard();}async deleteAttachmentCommand() {