mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 01:35:51 +01:00
chore(react/type_widget): start porting attachment actions
This commit is contained in:
@@ -13,40 +13,8 @@ import type AttachmentDetailWidget from "../attachment_detail.js";
|
|||||||
import type { NoteRow } from "@triliumnext/commons";
|
import type { NoteRow } from "@triliumnext/commons";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="dropdown attachment-actions">
|
<div class="dropdown">
|
||||||
<style>
|
|
||||||
.attachment-actions {
|
|
||||||
width: 35px;
|
|
||||||
height: 35px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-actions .dropdown-menu {
|
|
||||||
width: 20em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-actions .dropdown-item .bx {
|
|
||||||
position: relative;
|
|
||||||
top: 3px;
|
|
||||||
font-size: 120%;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.attachment-actions .dropdown-item[disabled], .attachment-actions .dropdown-item[disabled]:hover {
|
|
||||||
color: var(--muted-text-color) !important;
|
|
||||||
background-color: transparent !important;
|
|
||||||
pointer-events: none; /* makes it unclickable */
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<button type="button" data-bs-toggle="dropdown" aria-haspopup="true"
|
|
||||||
aria-expanded="false" class="icon-action icon-action-always-border bx bx-dots-vertical-rounded"
|
|
||||||
style="position: relative; top: 3px;"></button>
|
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
|
|
||||||
<li data-trigger-command="openAttachment" class="dropdown-item"
|
|
||||||
title="${t("attachments_actions.open_externally_title")}"><span class="bx bx-file-find"></span> ${t("attachments_actions.open_externally")}</li>
|
|
||||||
|
|
||||||
<li data-trigger-command="openAttachmentCustom" class="dropdown-item"
|
<li data-trigger-command="openAttachmentCustom" class="dropdown-item"
|
||||||
title="${t("attachments_actions.open_custom_title")}"><span class="bx bx-customize"></span> ${t("attachments_actions.open_custom")}</li>
|
title="${t("attachments_actions.open_custom_title")}"><span class="bx bx-customize"></span> ${t("attachments_actions.open_custom")}</li>
|
||||||
|
|
||||||
@@ -56,10 +24,8 @@ const TPL = /*html*/`
|
|||||||
<li data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item"><span class="bx bx-link">
|
<li data-trigger-command="copyAttachmentLinkToClipboard" class="dropdown-item"><span class="bx bx-link">
|
||||||
</span> ${t("attachments_actions.copy_link_to_clipboard")}</li>
|
</span> ${t("attachments_actions.copy_link_to_clipboard")}</li>
|
||||||
|
|
||||||
|
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
|
|
||||||
<li data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item"><span class="bx bx-upload">
|
<li data-trigger-command="uploadNewAttachmentRevision" class="dropdown-item"><span class="bx bx-upload">
|
||||||
</span> ${t("attachments_actions.upload_new_revision")}</li>
|
</span> ${t("attachments_actions.upload_new_revision")}</li>
|
||||||
|
|
||||||
@@ -69,13 +35,10 @@ const TPL = /*html*/`
|
|||||||
<li data-trigger-command="deleteAttachment" class="dropdown-item">
|
<li data-trigger-command="deleteAttachment" class="dropdown-item">
|
||||||
<span class="bx bx-trash destructive-action-icon"></span> ${t("attachments_actions.delete_attachment")}</li>
|
<span class="bx bx-trash destructive-action-icon"></span> ${t("attachments_actions.delete_attachment")}</li>
|
||||||
|
|
||||||
|
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
|
|
||||||
<li data-trigger-command="convertAttachmentIntoNote" class="dropdown-item"><span class="bx bx-note">
|
<li data-trigger-command="convertAttachmentIntoNote" class="dropdown-item"><span class="bx bx-note">
|
||||||
</span> ${t("attachments_actions.convert_attachment_into_note")}</li>
|
</span> ${t("attachments_actions.convert_attachment_into_note")}</li>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="file" class="attachment-upload-new-revision-input" style="display: none">
|
<input type="file" class="attachment-upload-new-revision-input" style="display: none">
|
||||||
@@ -137,10 +100,6 @@ export default class AttachmentActionsWidget extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async openAttachmentCommand() {
|
|
||||||
await openService.openAttachmentExternally(this.attachmentId, this.attachment.mime);
|
|
||||||
}
|
|
||||||
|
|
||||||
async openAttachmentCustomCommand() {
|
async openAttachmentCustomCommand() {
|
||||||
await openService.openAttachmentCustom(this.attachmentId, this.attachment.mime);
|
await openService.openAttachmentCustom(this.attachmentId, this.attachment.mime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,3 +102,32 @@
|
|||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
/* #endregion */
|
/* #endregion */
|
||||||
|
|
||||||
|
/* #region Attachment actions */
|
||||||
|
.attachment-actions {
|
||||||
|
width: 35px;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-actions .select-button {
|
||||||
|
position: relative;
|
||||||
|
top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-actions .dropdown-menu {
|
||||||
|
width: 20em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-actions .dropdown-item .bx {
|
||||||
|
position: relative;
|
||||||
|
top: 3px;
|
||||||
|
font-size: 120%;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-actions .dropdown-item[disabled], .attachment-actions .dropdown-item[disabled]:hover {
|
||||||
|
color: var(--muted-text-color) !important;
|
||||||
|
background-color: transparent !important;
|
||||||
|
pointer-events: none; /* makes it unclickable */
|
||||||
|
}
|
||||||
|
/* #endregion */
|
||||||
@@ -12,6 +12,10 @@ import utils from "../../services/utils";
|
|||||||
import content_renderer from "../../services/content_renderer";
|
import content_renderer from "../../services/content_renderer";
|
||||||
import { useTriliumEvent } from "../react/hooks";
|
import { useTriliumEvent } from "../react/hooks";
|
||||||
import froca from "../../services/froca";
|
import froca from "../../services/froca";
|
||||||
|
import Dropdown from "../react/Dropdown";
|
||||||
|
import Icon from "../react/Icon";
|
||||||
|
import { FormListItem } from "../react/FormList";
|
||||||
|
import open from "../../services/open";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the full list of attachments of a note and allows the user to interact with them.
|
* Displays the full list of attachments of a note and allows the user to interact with them.
|
||||||
@@ -126,7 +130,7 @@ function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment,
|
|||||||
<div className="attachment-detail-widget">
|
<div className="attachment-detail-widget">
|
||||||
<div className="attachment-detail-wrapper">
|
<div className="attachment-detail-wrapper">
|
||||||
<div className="attachment-title-line">
|
<div className="attachment-title-line">
|
||||||
<div className="attachment-actions-container"></div>
|
<AttachmentActions attachment={attachment} />
|
||||||
<h4 className="attachment-title">
|
<h4 className="attachment-title">
|
||||||
{!isFullDetail ? (
|
{!isFullDetail ? (
|
||||||
<NoteLink
|
<NoteLink
|
||||||
@@ -150,3 +154,22 @@ function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment,
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function AttachmentActions({ attachment }: { attachment: FAttachment }) {
|
||||||
|
return (
|
||||||
|
<div className="attachment-actions-container">
|
||||||
|
<Dropdown
|
||||||
|
className="attachment-actions"
|
||||||
|
text={<Icon icon="bx bx-dots-vertical-rounded" />}
|
||||||
|
buttonClassName="icon-action-always-border"
|
||||||
|
iconAction
|
||||||
|
>
|
||||||
|
<FormListItem
|
||||||
|
icon="bx bx-file-find"
|
||||||
|
title={t("attachments_actions.open_externally_title")}
|
||||||
|
onClick={(e) => open.openAttachmentExternally(attachment.attachmentId, attachment.mime)}
|
||||||
|
>{t("attachments_actions.open_externally")}</FormListItem>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user