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
client/attachments page: allow uploading new attachments by drag and drop
Adorian Doran689b42c3cc99
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 96ff6b7901..afb2550778 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1583,6 +1583,7 @@"open_help_page": "Open help page on attachments","owning_note": "Owning note: ","upload_attachments": "Upload attachments",+ "drop_files": "Drop files to upload them as attachments","no_attachments": "This note has no attachments.","no_user_attachments": "This note has no attachments of its own.\nThe ones Trilium generated for it are below.","system_group": "Generated by Trilium ({{amount}})"diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 97bc681b0b..cafc30dd2d 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -1885,6 +1885,88 @@ async function warnIfArchivedNotesHidden(addedNoteIds: string[]) {toast.showMessage(t("book.archived_notes_hidden", { count: archivedCount }), 5000, "bx bx-archive");}+/**+ * Accepts files dragged onto `containerRef` from outside the page and passes them to `onDrop`.+ * Returns whether such a drag is over the container.+ */+export function useFileDrop(+ containerRef: RefObject<HTMLElement | null>,+ onDrop: (files: File[]) => void+) {+ const [ isDraggedOver, setIsDraggedOver ] = useState(false);+ const onDropRef = useRef(onDrop);+ onDropRef.current = onDrop;++ useEffect(() => {+ const container = containerRef.current;+ if (!container) return;++ // A drag that starts in the page, such as an image, can also carry files.+ let isDragFromPage = false;+ // `dragenter` and `dragleave` also fire when the drag moves between the children.+ let depth = 0;++ const carriesFiles = (e: DragEvent) =>+ !isDragFromPage && !!e.dataTransfer?.types.includes("Files");+ const markDragFromPage = () => { isDragFromPage = true; };+ const clearDragFromPage = () => { isDragFromPage = false; };++ function onDragEnter(e: DragEvent) {+ if (!carriesFiles(e)) return;+ e.preventDefault();+ depth++;+ setIsDraggedOver(true);+ }++ function onDragOver(e: DragEvent) {+ if (!carriesFiles(e) || !e.dataTransfer) return;+ e.preventDefault();+ e.dataTransfer.dropEffect = "copy";+ }++ function onDragLeave(e: DragEvent) {+ if (!carriesFiles(e)) return;+ depth = Math.max(0, depth - 1);+ if (depth === 0) {+ setIsDraggedOver(false);+ }+ }++ function onDropFiles(e: DragEvent) {+ if (!carriesFiles(e)) return;+ e.preventDefault();+ depth = 0;+ setIsDraggedOver(false);++ const files = Array.from(e.dataTransfer?.files ?? []);+ if (files.length) {+ onDropRef.current(files);+ }+ }++ document.addEventListener("dragstart", markDragFromPage, true);+ document.addEventListener("dragend", clearDragFromPage, true);+ // A drop can remove the dragged element, and its `dragend` then never reaches the document.+ document.addEventListener("drop", clearDragFromPage);+ container.addEventListener("dragenter", onDragEnter);+ container.addEventListener("dragover", onDragOver);+ container.addEventListener("dragleave", onDragLeave);+ container.addEventListener("drop", onDropFiles);++ return () => {+ document.removeEventListener("dragstart", markDragFromPage, true);+ document.removeEventListener("dragend", clearDragFromPage, true);+ document.removeEventListener("drop", clearDragFromPage);+ container.removeEventListener("dragenter", onDragEnter);+ container.removeEventListener("dragover", onDragOver);+ container.removeEventListener("dragleave", onDragLeave);+ container.removeEventListener("drop", onDropFiles);+ };+ }, [ containerRef ]);++ return isDraggedOver;+}+/*** Long-press + contextmenu handler bundle. `contextmenu` covers desktop right-click and* Android Chrome long-press; explicit touch handlers cover iOS/WKWebView wherediff --git a/apps/client/src/widgets/type_widgets/Attachment.css b/apps/client/src/widgets/type_widgets/Attachment.cssindex f5d7bbdabe..990e55c230 100644--- a/apps/client/src/widgets/type_widgets/Attachment.css+++ b/apps/client/src/widgets/type_widgets/Attachment.css@@ -1,3 +1,10 @@+:where(:root) {+ --attachment-list-drop-overlay-background:+ color-mix(in srgb, var(--main-background-color), transparent 10%);+ --attachment-list-drop-overlay-border-color: var(--main-text-color);+ --attachment-list-drop-overlay-color: var(--muted-text-color);+}+/* #region Attachment list */.attachment-list {padding-inline-start: 15px;@@ -165,9 +172,31 @@.attachment-list .attachment-list-container {display: flex;flex-direction: column;+ position: relative;height: 100%;}+.attachment-list .attachment-list-drop-overlay {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 0.5em;+ position: absolute;+ inset: 0;+ z-index: 2;+ border: 2px dashed var(--attachment-list-drop-overlay-border-color);+ border-radius: var(--card-border-radius, 8px);+ background: var(--attachment-list-drop-overlay-background);+ color: var(--attachment-list-drop-overlay-color);+ font-size: 1.2em;+ pointer-events: none;++ .tn-icon {+ font-size: 3em;+ }+}+.attachment-list .attachment-list-body {flex-grow: 1;overflow: auto;diff --git a/apps/client/src/widgets/type_widgets/Attachment.spec.tsx b/apps/client/src/widgets/type_widgets/Attachment.spec.tsxindex 764cd5368d..55745321fd 100644--- a/apps/client/src/widgets/type_widgets/Attachment.spec.tsx+++ b/apps/client/src/widgets/type_widgets/Attachment.spec.tsx@@ -6,13 +6,15 @@ import Component from "../../components/component";import FAttachment from "../../entities/fattachment";import froca from "../../services/froca";import LoadResults from "../../services/load_results";+import options from "../../services/options";import { renderInto } from "../../test/render";import { ParentComponent } from "../react/react_utils";const CANVAS_MIME = "application/vnd.excalidraw+json";-const { getRenderedContent, drawingMounts } = vi.hoisted(() => ({+const { getRenderedContent, drawingMounts, uploadFiles } = vi.hoisted(() => ({getRenderedContent: vi.fn(async () => ({ $renderedContent: [] })),- drawingMounts: vi.fn()+ drawingMounts: vi.fn(),+ uploadFiles: vi.fn(async () => {})}));// Nothing initialises i18next in a unit test, and an uninitialised one answers every lookup with an@@ -44,6 +46,7 @@ vi.mock("./canvas/CanvasDrawing", () => ({vi.mock("../react/Dropdown", () => ({ default: () => <div class="dropdown-stub" /> }));vi.mock("../react/NoteLink", () => ({ default: () => <span class="note-link-stub" /> }));vi.mock("../dialogs/image_compression/image_compression_dialog", () => ({ showImageCompressionDialog: vi.fn() }));+vi.mock("../../services/import", () => ({ default: { uploadFiles } }));const { AttachmentDetail, AttachmentList } = await import("./Attachment");@@ -126,6 +129,57 @@ describe("AttachmentList", () => {expect(container.querySelector(".no-items")?.textContent).toBe("attachment_list.no_attachments");expect(container.querySelector(".no-items-small, .beside-folded-away")).toBeNull();});++ it("uploads files dropped from outside the app as attachments of the note", async () => {+ vi.spyOn(options, "is").mockReturnValue(true);+ uploadFiles.mockClear();+ const container = await mount([ role("image") ]);+ const list = container.querySelector(".attachment-list-container");+ const card = cards(container)[0];+ expect(list).not.toBeNull();+ expect(card).toBeDefined();+ if (!list) return;++ expect(drag(card, "dragenter", [ "Files" ]).defaultPrevented).toBe(true);+ expect(dropOverlay(container)?.textContent).toBe("attachment_list.drop_files");++ // Moving from the card to the list around it keeps the overlay.+ drag(list, "dragenter", [ "Files" ]);+ drag(card, "dragleave", [ "Files" ]);+ expect(dropOverlay(container)).not.toBeNull();+ expect(drag(list, "dragover", [ "Files" ]).defaultPrevented).toBe(true);++ const file = new File([ "x" ], "notes.txt");+ expect(drag(list, "drop", [ "Files" ], [ file ]).defaultPrevented).toBe(true);+ expect(uploadFiles).toHaveBeenCalledExactlyOnceWith(+ "attachments", "note1", [ file ], { shrinkImages: true });+ expect(dropOverlay(container)).toBeNull();+ });++ it("ignores a drag that carries no files or that started in the page", async () => {+ uploadFiles.mockClear();+ const container = await mount([ role("image") ]);+ const card = cards(container)[0];+ expect(card).toBeDefined();++ // Notes dragged from the tree.+ expect(drag(card, "dragenter", [ "text/plain" ]).defaultPrevented).toBe(false);+ expect(dropOverlay(container)).toBeNull();++ // An image dragged out of a card also carries files.+ drag(card, "dragstart", [ "Files" ]);+ expect(drag(card, "dragenter", [ "Files" ]).defaultPrevented).toBe(false);+ expect(drag(card, "dragover", [ "Files" ]).defaultPrevented).toBe(false);+ expect(dropOverlay(container)).toBeNull();+ drag(card, "drop", [ "Files" ], [ new File([ "x" ], "image.png") ]);+ expect(uploadFiles).not.toHaveBeenCalled();++ // Either a drop or a `dragend` ends the drag from the page.+ expect(drag(card, "dragover", [ "Files" ]).defaultPrevented).toBe(true);+ drag(card, "dragstart", [ "Files" ]);+ drag(card, "dragend", [ "Files" ]);+ expect(drag(card, "dragover", [ "Files" ]).defaultPrevented).toBe(true);+ });});describe("AttachmentDetail", () => {@@ -204,3 +258,17 @@ async function mount(attachments: FAttachment[]) {function cards(container: HTMLElement) {return container.querySelectorAll(".attachment-detail-widget");}++function dropOverlay(container: HTMLElement) {+ return container.querySelector(".attachment-list-drop-overlay");+}++/** Fires a drag event at `target` whose data has the given `types` and `files`. */+function drag(target: Element, type: string, types: string[], files: File[] = []) {+ const event = new Event(type, { bubbles: true, cancelable: true });+ Object.defineProperty(event, "dataTransfer", { value: { types, files, dropEffect: "none" } });+ act(() => {+ target.dispatchEvent(event);+ });+ return event;+}diff --git a/apps/client/src/widgets/type_widgets/Attachment.tsx b/apps/client/src/widgets/type_widgets/Attachment.tsxindex d275e352dc..8d5f6c0cbf 100644--- a/apps/client/src/widgets/type_widgets/Attachment.tsx+++ b/apps/client/src/widgets/type_widgets/Attachment.tsx@@ -23,6 +23,7 @@ import content_renderer, { hasRenderedPreview } from "../../services/content_renimport froca from "../../services/froca";import image from "../../services/image";import { getAttachmentImageUrl } from "../../services/image_urls";+import importService from "../../services/import";import { type ViewScope } from "../../services/link";import options from "../../services/options";import protected_session_holder from "../../services/protected_session_holder";@@ -35,7 +36,7 @@ import { ExternallyControlledCollapsible } from "../react/Collapsible";import Dropdown from "../react/Dropdown";import { FormDropdownDivider, FormListItem } from "../react/FormList";import HelpButton from "../react/HelpButton";-import { useAttachments, useTriliumEvent } from "../react/hooks";+import { useAttachments, useFileDrop, useTriliumEvent } from "../react/hooks";import Icon from "../react/Icon";import ImageViewer from "../react/ImageViewer";import NoItems from "../react/NoItems";@@ -54,14 +55,19 @@ const CanvasDrawingDetail = lazy(() =>* Displays the full list of attachments of a note and allows the user to interact with them.*/export function AttachmentList({ note }: TypeWidgetProps) {+ const containerRef = useRef<HTMLDivElement>(null);const attachments = useAttachments(note);const groups = useMemo(() => partitionAttachmentsByGroup(attachments), [ attachments ]);// Nothing to fold away until the app has made an attachment of its own, which most notes never give// it reason to — so an ordinary note's list looks exactly as it did.const hasFoldedAway = groups.system.length > 0;+ const isDraggingFiles = useFileDrop(containerRef, (files) => {+ const shrinkImages = options.is("compressImages");+ void importService.uploadFiles("attachments", note.noteId, files, { shrinkImages });+ });return (- <div className="attachment-list-container">+ <div ref={containerRef} className="attachment-list-container"><AttachmentListHeader noteId={note.noteId} /><div className="attachment-list-body">{groups.user.length ? (@@ -88,6 +94,12 @@ export function AttachmentList({ note }: TypeWidgetProps) {opened on the last. */}{hasFoldedAway && <SystemAttachments key={note.noteId} attachments={groups.system} />}</div>+ {isDraggingFiles && (+ <div className="attachment-list-drop-overlay">+ <Icon icon="bx bx-cloud-upload" />+ {t("attachment_list.drop_files")}+ </div>+ )}</div>);}diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex b1c6fca70a..7e235d235d 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -64,7 +64,7 @@"_help_BFs8mudNFgCS": "<p>Note is a central entity in Trilium. Main attributes of note are <a href=\"#root/_help_l7pigIGu01K2\">title</a> and content.</p><h3>Note types</h3><p>The main note type is a rich-text note type called <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>. For diagrams and drawing there is <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a> and <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>.</p><p>There are also more complex note types such as <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a>, <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a> that usually go hand-in-hand with <a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a>.</p><p>In Trilium there's no specific \"folder\" note type. Any note can have children and thus be a folder. To make a note that only shows its children, like a folder in other applications, use a <a class=\"reference-link\" href=\"#root/_help_8QqnMzx393bx\">Grid View</a> or <a class=\"reference-link\" href=\"#root/_help_mULW0Q3VojwY\">List View</a> collection. See also <a class=\"reference-link\" href=\"#root/_help_i6dbnitykE5D\">FAQ</a>.</p><h3>Root note</h3><p>There's one special note called \"root note\" which is root of the note tree. All other notes are placed below it in the structure.</p><h3>Tree structure</h3><p>Importantly, note itself doesn't carry information on its placement in note tree. See <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a> for details.</p><p>Tree structure of notes can resemble file system - but compared to that notes in Trilium can act as both file and directory - meaning that note can both have its own content and have children. \"Leaf note\" is a note which doesn't have any children.</p><h3>Deleting / undeleting notes</h3><p>When you delete a note in Trilium, it is actually only marked for deletion (soft-delete) - the actual content, title, attributes etc. are not deleted, only hidden.</p><p>Within (by default) 7 days, it is possible to undelete these soft-deleted notes - open the <a class=\"reference-link\" href=\"#root/_help_r5JGHN99bVKn\">Recent Changes</a> dialog, and you will see a list of all modified notes including the deleted ones. Notes available for undeletion have a link to do so. This is kind of \"trash can\" functionality known from e.g. Windows.</p><p>Clicking an undelete will recover the note, its content and attributes - note should be just as before being deleted. This action will also undelete note's children which have been deleted in the same action.</p><p>To be able to undelete a note, it is necessary that deleted note's parent must be undeleted (otherwise there's no place where we can undelete it to). This might become a problem when you delete more notes in succession - the solution is then undelete in the reverse order of your deletion.</p><p>After the 7 days (configurable) the notes will be \"erased\" - their title, content, revisions and attributes will be erased, and it will not be possible anymore to recover them (unless you restore a <a class=\"reference-link\" href=\"#root/_help_ODY7qQn5m2FT\">Backup</a>).</p><h2>See also</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a></li></ul>","_help_l7pigIGu01K2": "<p>Alongside its content, the <strong>title</strong> is one of the two main attributes of a <a href=\"#root/_help_BFs8mudNFgCS\">note</a>. It's the short, human-readable name shown in the editable field at the top of every note, and it's what identifies the note throughout the interface (in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, in tabs, in the <a class=\"reference-link\" href=\"#root/_help_I6p2a06hdnL6\">Breadcrumb</a> and win <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>.</p><p>Internally, notes are identified by a unique <a class=\"reference-link\" href=\"#root/_help_m1lbrzyKDaRB\">Note ID</a> rather than by their title, so the title is purely for your benefit. This has a few consequences:</p><ul><li><strong>Titles don't have to be unique.</strong> You can have any number of notes that share the same title without conflict.</li><li><strong>Renaming a note never breaks links to it.</strong> Links between notes point at the underlying note, so changing a title leaves existing links intact (they'll simply display the new title).</li><li><strong>The title can be left empty.</strong> Notes with no title display a placeholder (<em>type note's title here…</em>) but are otherwise perfectly valid.</li></ul><p>In addition:</p><ul><li>There is no limitation on the length of the title, however in exports the title might get trimmed.</li><li>There are no forbidden symbols, unsupported characters will get trimmed when exporting.</li><li>When exporting to a ZIP file, a meta file will contain the full title which will be recognized by Trilium when importing again.</li></ul><h2>Inline title</h2><p><a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes have a special title bar behavior in which the <a href=\"#root/_help_l7pigIGu01K2\">note title</a> is initially displayed in a larger font, while also displaying additional information such as the creation and the modification date.</p><p>Whenever the title is scrolled past, the fixed title is shown instead.</p><p>Note types that take the entirety of the screen, such as <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> and <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>, will always have only the fixed title bar.</p><p>Under the note title, the <a class=\"reference-link\" href=\"#root/_help_m3VlURMSeOrd\">New note type switcher</a> appears if the note is empty.</p><figure class=\"image\"><img style=\"aspect-ratio:899/122;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Title_image.png\" width=\"899\" height=\"122\"><figcaption>The <em>Inline title</em>, which is displayed at the top of the note and can be scrolled past.</figcaption></figure><figure class=\"image\"><img style=\"aspect-ratio:910/104;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/1_Title_image.png\" width=\"910\" height=\"104\"><figcaption>The fixed title bar. The title only appears after scrolling past the <em>Inline title</em>.</figcaption></figure><h3>Editing the title</h3><p>To rename a note, simply click into the title field and type. Changes are saved automatically as you type.</p><p>You can also begin editing the title directly from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> by selecting a note and pressing <kbd>Enter</kbd> (see <em>Edit note title</em> in <a class=\"reference-link\" href=\"#root/_help_A9Oc6YKKc65v\">Keyboard Shortcuts</a>), which focuses the title field for the active note.</p><aside class=\"admonition note\"><p>Titles may contain any characters, including Unicode and emoji. For security, any HTML in the title is stripped automatically, so the title is always treated as plain text.</p></aside><h3>Easily navigating between the title and the content</h3><p>When the cursor is in the title field, pressing <kbd>Enter</kbd> moves focus into the note's content. For <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes this also inserts a fresh empty paragraph at the very top of the document, so you can start writing immediately — much like other note-taking apps.</p><p>This makes it possible to create a note, type its title, press <kbd>Enter</kbd>, and continue straight into the body without reaching for the mouse.</p><h3>Working with new notes</h3><p>When you create a new note it's given a default title (<em>new note</em>) which is pre-selected, so you can type a name right away to replace it. The default title for new notes can be customized per-section — see <a class=\"reference-link\" href=\"#root/_help_47ZrP6FNuoG8\">Default Note Title</a>.</p><p>If you decide you don't want the note after all, pressing <kbd>Escape</kbd> while the title of a freshly created note is still focused will discard it.</p><h3>Automatically generated titles</h3><p>Some notes get their titles assigned automatically rather than typed:</p><ul><li><strong>Day, week, month and year notes</strong> in the <a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a> are named from a configurable date pattern.</li><li><a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> notes are named after the search they perform.</li><li>When a note is duplicated, a suffix is appended to the copy's title to tell it apart from the original.</li></ul><h3>Protected notes</h3><p>The titles of <a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a> are encrypted along with their content. Before entering your password, Trilium cannot decrypt the title: the note tree, the title field and the breadcrumb menus label the note <em>Protected</em>, the tab shows <code>[protected]</code>, and the title cannot be modified.</p><p>Once you enter your password and a protected session is active, the real title is decrypted and displayed, and becomes editable again.</p>","_help_p9kXRFAkwN4o": "<h2>Icons</h2><figure class=\"image image-style-align-right image_resized\" style=\"width:48.4%;\"><img style=\"aspect-ratio:1089/995;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Note%20Icons%20%26%20Colors_image.png\" width=\"1089\" height=\"995\"></figure><p>Icons are useful for distinguishing notes and are displayed near the note title, as well as in various places such as the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> or the <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a>.</p><p>While editing a note, click on the icon next to the title to bring up a chooser gallery.</p><p>Icons can be inherited through the use of <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, or <a class=\"reference-link\" href=\"#root/_help_bwZpz2ajCEwO\">Attribute Inheritance</a>.</p><aside class=\"admonition note\"><p>At the technical level, they are set by the <code>iconClass</code> attribute which adds a CSS class to the note. For example <code>#iconClass=\"bx bx-calendar\"</code> will show a calendar instead of the default page or folder icon. Looking up and remembering the CSS class names is not necessary.</p></aside><h2>Colors</h2><p>Notes can also carry a custom color. Similar to the note icon, this color will be shown in various places such as the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>.</p><p>To set a custom color, right click on the note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select a predefined color from there or use the color picker (last option).</p><p>Alternatively, a custom color can be set manually through the <code>#color</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>, whose value must be a valid hex color including the leading <code>#</code> (e.g. <code>#ff0000</code> for red). This color can be carried over across multiple notes via <a class=\"reference-link\" href=\"#root/_help_bwZpz2ajCEwO\">Attribute Inheritance</a>.</p>",- "_help_0vhv7lsOLy82": "<p>A <a href=\"#root/_help_BFs8mudNFgCS\">note</a> in Trilium can <em>own</em> one or more attachments, which can be either images or files. These attachments can be displayed or linked within the note that owns them.</p><p>This can be especially useful to include dependencies for your <a href=\"#root/_help_CdNpE2pqjmI6\">scripts</a>. The <a class=\"reference-link\" href=\"#root/_help_R7abl2fc6Mxi\">Weight Tracker</a> shows how to use <a href=\"https://chartjs.org/\">chartjs</a> which is attached to the script note.</p><p>Each note exclusively owns its attachments, meaning attachments cannot be shared or linked from one note to another. If an attachment link is copied to a different note, the attachment itself is duplicated, and the copies are managed independently thereafter.</p><p>Attachments, especially image files, are the recommended method for embedding visuals in notes. It is important to link image attachments within the text of the owning note; otherwise, they will be automatically deleted after a configurable timeout period if not referenced.</p><h2>Types of attachments</h2><p>There are two different types of attachment:</p><ul><li><em>User content</em>, representing files or images that are uploaded and part of the content of the note.</li><li><em>System attachments</em> which are used internally by Trilium and can be of multiple types, including:<ul><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> to store information about views such as the column information for the <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>.</li><li>Icons and cover images for <a class=\"reference-link\" href=\"#root/_help_UmgZAfcltxkS\">Link Previews</a>.</li><li>Debug information for some importers such as <a class=\"reference-link\" href=\"#root/_help_GnhlmrATVqcH\">Microsoft OneNote</a> (only if the debug flag was enabled at import time).</li><li>The transcript of a <a class=\"reference-link\" href=\"#root/_help_Y84QCbArmK3z\">Meeting transcription</a>, which is also shown above the note's content.</li></ul></li></ul><p>The system attachments are displayed at the end of the attachments list, in a dedicated section (<em>Generated by Trilium</em>).</p><h2>Attaching files from a text note</h2><p>To attach files to a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note and embed them in its content, press the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, choose <em>Attach and embed file</em> and select one or more files (see <em>Embedding an attachment</em> below). The same menu offers <em>Image</em>, which inserts pictures (see <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>), and <em>Attach file as a link</em>, which links the files instead. Both file actions are also available as <em>Attach file as a link</em> and <em>Attach and embed file</em> in the <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>. On a phone, the menu also offers <em>Camera</em> (see <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>).</p><p>When files are attached as links:</p><ul><li>Each file becomes an attachment of the note, and a link to it is inserted at the cursor. Several files produce several links, separated by a space.</li><li>While a file uploads, its link shows the file name and a toast shows the progress.</li><li>Pictures appear as links rather than images, and are attached exactly as they are, without being compressed. To display a picture in the text, use <em>Image</em> in the same menu instead (see <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>).</li></ul><p>Dragging a file that is not a picture from the file explorer onto the text also attaches it and inserts a link to it.</p><h2>Acting on an attachment link</h2><p>Right-clicking a link to an attachment shows the ways to open it, followed by actions on the attachment: opening it externally, downloading it, uploading a new revision, renaming or deleting it, and converting it into a note.</p><p>Links follow changes to their attachment: renaming it updates the title they show, and deleting it removes them from the text notes open for editing at that moment. Converting it into a note turns its links into links to the new note.</p><h2>Embedding an attachment</h2><p>An attachment can be shown in the text instead of linked, the way <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a> shows a note: a picture is displayed, a PDF, a video or a document is previewed, a code or text file is shown with syntax highlighting, and a Markdown file such as a <code>.md</code> file is shown rendered. An embedded code file can also be edited in place (see <em>Editing an include in place</em> in <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>), and an embedded Markdown file shows its source, its rendering or both, as an included Markdown note does (see <em>Included Markdown</em> there).</p><ul><li>To attach files and embed them straight away, press the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button and choose <em>Attach and embed file</em>. Each file gets an embed of its own, which shows the file name while the file uploads.</li><li>To embed an attachment that is already linked, right-click a link to it in a text note being edited and select <em>Convert link to an embed</em>, at the end of the menu.</li><li>A drawing canvas, inserted with <span class=\"tn-icon bx bx-pen\"></span><em>Drawing canvas</em> in the <span class=\"tn-icon cke cke-plus\"></span><em>Insert</em> menu, is an embed of a <code>Canvas.excalidraw</code> attachment that can be drawn on in place. An attached Excalidraw file (<code>.excalidraw</code>) is embedded as a drawing canvas too (see <em>Drawing canvases</em> in <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>).</li><li>An embed gets the box size that suits the attachment, as a new included note does (see <em>Box sizes</em> there). To change its size, select the embed and use the box size menu in its toolbar, or the <em>Size</em> submenu of its <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span><em>More actions</em> menu. A <em>Small</em>, <em>Medium</em> or <em>Expandable</em> embed can also be resized by dragging its handles (see <em>Resizing</em> there).</li><li>An embed can have a caption, as an included note can (see <em>Caption</em> there).</li><li>To show only the attachment, select the embed and press the <span class=\"tn-icon bx bx-window-alt\"></span> (<em>Show title)</em> button in its toolbar, as for an included note (see <em>Title</em> there).</li><li>To open the attachment in a new tab, press the <span class=\"tn-icon bx bx-link-external\"></span> (<em>Open in new tab)</em> button at the end of the embed's title.</li><li>An embed of size <em>Tiny</em> shows only the title of the attachment and its size, in a single row. Its buttons are <span class=\"tn-icon bx bx-file-find\"></span><em>Open externally</em> and <span class=\"tn-icon bx bx-download\"></span><em>Download</em>.</li><li>To show an embed of size <em>Medium</em> or <em>Full</em> on the whole screen, press the <span class=\"tn-icon bx bx-fullscreen\"></span> (<em>Fullscreen)</em> button at the end of its title. To return, press <span class=\"tn-icon bx bx-exit\"></span> (<em>Exit fullscreen)</em> in the top-right corner, or <kbd>Esc</kbd>.</li><li>To turn the embed back into a link, select it and press the <span class=\"tn-icon cke cke-link\"></span><em>Convert to link</em> button in its toolbar. <em>Convert to link</em> also ends the menu that right-clicking the title row of the embed or pressing its <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span><em>More actions</em> button opens.</li></ul><p>An embed follows its attachment like a link does. Converting the attachment into a note turns the embed into an included note. In a <a href=\"#root/_help_R9pX4DGra2Vt\">shared note</a>, an embedded picture is displayed with its caption, a drawing canvas as a picture of the drawing, and any other attachment, or a picture in a <em>Tiny</em> embed, appears as a link to download it.</p><h2>Converting notes to attachments</h2><p><a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> notes can be easily converted to attachments of the parent note.</p><p>To do so:</p><ul><li>For a single note, press the context menu from the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Convert into attachment</em>.</li><li>For multiple notes, select the given notes in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right click → Advanced → <em>Convert to attachment…</em>.</li></ul><h2>Attachment previews</h2><p>Attachments share the same content preview for images, videos, PDFs, etc. as the <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> note type. A Markdown attachment is previewed rendered, as a <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note is.</p>",+ "_help_0vhv7lsOLy82": "<p>A <a href=\"#root/_help_BFs8mudNFgCS\">note</a> in Trilium can <em>own</em> one or more attachments, which can be either images or files. These attachments can be displayed or linked within the note that owns them.</p><p>This can be especially useful to include dependencies for your <a href=\"#root/_help_CdNpE2pqjmI6\">scripts</a>. The <a class=\"reference-link\" href=\"#root/_help_R7abl2fc6Mxi\">Weight Tracker</a> shows how to use <a href=\"https://chartjs.org/\">chartjs</a> which is attached to the script note.</p><p>Each note exclusively owns its attachments, meaning attachments cannot be shared or linked from one note to another. If an attachment link is copied to a different note, the attachment itself is duplicated, and the copies are managed independently thereafter.</p><p>Attachments, especially image files, are the recommended method for embedding visuals in notes. It is important to link image attachments within the text of the owning note; otherwise, they will be automatically deleted after a configurable timeout period if not referenced.</p><h2>Types of attachments</h2><p>There are two different types of attachment:</p><ul><li><em>User content</em>, representing files or images that are uploaded and part of the content of the note.</li><li><em>System attachments</em> which are used internally by Trilium and can be of multiple types, including:<ul><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> to store information about views such as the column information for the <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>.</li><li>Icons and cover images for <a class=\"reference-link\" href=\"#root/_help_UmgZAfcltxkS\">Link Previews</a>.</li><li>Debug information for some importers such as <a class=\"reference-link\" href=\"#root/_help_GnhlmrATVqcH\">Microsoft OneNote</a> (only if the debug flag was enabled at import time).</li><li>The transcript of a <a class=\"reference-link\" href=\"#root/_help_Y84QCbArmK3z\">Meeting transcription</a>, which is also shown above the note's content.</li></ul></li></ul><p>The system attachments are displayed at the end of the attachments list, in a dedicated section (<em>Generated by Trilium</em>).</p><h2>Uploading attachments</h2><p>The <span class=\"tn-icon bx bx-paperclip\"></span><em>Attachments</em> item of the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> opens the list of the note's attachments.</p><ul><li>To upload files as attachments, press <em>Upload attachments</em> at the top of the list and select one or more files.</li><li>Alternatively, drag one or more files from the file explorer and drop them anywhere on the list. Pictures are compressed if <em>Automatic image compression</em> is enabled in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Media</em>.</li></ul><h2>Attaching files from a text note</h2><p>To attach files to a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note and embed them in its content, press the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, choose <em>Attach and embed file</em> and select one or more files (see <em>Embedding an attachment</em> below). The same menu offers <em>Image</em>, which inserts pictures (see <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>), and <em>Attach file as a link</em>, which links the files instead. Both file actions are also available as <em>Attach file as a link</em> and <em>Attach and embed file</em> in the <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>. On a phone, the menu also offers <em>Camera</em> (see <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>).</p><p>When files are attached as links:</p><ul><li>Each file becomes an attachment of the note, and a link to it is inserted at the cursor. Several files produce several links, separated by a space.</li><li>While a file uploads, its link shows the file name and a toast shows the progress.</li><li>Pictures appear as links rather than images, and are attached exactly as they are, without being compressed. To display a picture in the text, use <em>Image</em> in the same menu instead (see <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>).</li></ul><p>Dragging a file that is not a picture from the file explorer onto the text also attaches it and inserts a link to it.</p><h2>Acting on an attachment link</h2><p>Right-clicking a link to an attachment shows the ways to open it, followed by actions on the attachment: opening it externally, downloading it, uploading a new revision, renaming or deleting it, and converting it into a note.</p><p>Links follow changes to their attachment: renaming it updates the title they show, and deleting it removes them from the text notes open for editing at that moment. Converting it into a note turns its links into links to the new note.</p><h2>Embedding an attachment</h2><p>An attachment can be shown in the text instead of linked, the way <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a> shows a note: a picture is displayed, a PDF, a video or a document is previewed, a code or text file is shown with syntax highlighting, and a Markdown file such as a <code>.md</code> file is shown rendered. An embedded code file can also be edited in place (see <em>Editing an include in place</em> in <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>), and an embedded Markdown file shows its source, its rendering or both, as an included Markdown note does (see <em>Included Markdown</em> there).</p><ul><li>To attach files and embed them straight away, press the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button and choose <em>Attach and embed file</em>. Each file gets an embed of its own, which shows the file name while the file uploads.</li><li>To embed an attachment that is already linked, right-click a link to it in a text note being edited and select <em>Convert link to an embed</em>, at the end of the menu.</li><li>A drawing canvas, inserted with <span class=\"tn-icon bx bx-pen\"></span><em>Drawing canvas</em> in the <span class=\"tn-icon cke cke-plus\"></span><em>Insert</em> menu, is an embed of a <code>Canvas.excalidraw</code> attachment that can be drawn on in place. An attached Excalidraw file (<code>.excalidraw</code>) is embedded as a drawing canvas too (see <em>Drawing canvases</em> in <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>).</li><li>An embed gets the box size that suits the attachment, as a new included note does (see <em>Box sizes</em> there). To change its size, select the embed and use the box size menu in its toolbar, or the <em>Size</em> submenu of its <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span><em>More actions</em> menu. A <em>Small</em>, <em>Medium</em> or <em>Expandable</em> embed can also be resized by dragging its handles (see <em>Resizing</em> there).</li><li>An embed can have a caption, as an included note can (see <em>Caption</em> there).</li><li>To show only the attachment, select the embed and press the <span class=\"tn-icon bx bx-window-alt\"></span> (<em>Show title)</em> button in its toolbar, as for an included note (see <em>Title</em> there).</li><li>To open the attachment in a new tab, press the <span class=\"tn-icon bx bx-link-external\"></span> (<em>Open in new tab)</em> button at the end of the embed's title.</li><li>An embed of size <em>Tiny</em> shows only the title of the attachment and its size, in a single row. Its buttons are <span class=\"tn-icon bx bx-file-find\"></span><em>Open externally</em> and <span class=\"tn-icon bx bx-download\"></span><em>Download</em>.</li><li>To show an embed of size <em>Medium</em> or <em>Full</em> on the whole screen, press the <span class=\"tn-icon bx bx-fullscreen\"></span> (<em>Fullscreen)</em> button at the end of its title. To return, press <span class=\"tn-icon bx bx-exit\"></span> (<em>Exit fullscreen)</em> in the top-right corner, or <kbd>Esc</kbd>.</li><li>To turn the embed back into a link, select it and press the <span class=\"tn-icon cke cke-link\"></span><em>Convert to link</em> button in its toolbar. <em>Convert to link</em> also ends the menu that right-clicking the title row of the embed or pressing its <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span><em>More actions</em> button opens.</li></ul><p>An embed follows its attachment like a link does. Converting the attachment into a note turns the embed into an included note. In a <a href=\"#root/_help_R9pX4DGra2Vt\">shared note</a>, an embedded picture is displayed with its caption, a drawing canvas as a picture of the drawing, and any other attachment, or a picture in a <em>Tiny</em> embed, appears as a link to download it.</p><h2>Converting notes to attachments</h2><p><a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> notes can be easily converted to attachments of the parent note.</p><p>To do so:</p><ul><li>For a single note, press the context menu from the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Convert into attachment</em>.</li><li>For multiple notes, select the given notes in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right click → Advanced → <em>Convert to attachment…</em>.</li></ul><h2>Attachment previews</h2><p>Attachments share the same content preview for images, videos, PDFs, etc. as the <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> note type. A Markdown attachment is previewed rendered, as a <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note is.</p>","_help_IakOLONlIfGI": "<h2>Motivation</h2><p>Trilium's core feature is the ability to structure your notes into hierarchical tree-like structure.</p><p>It is expected then that you'll have an elaborate and deep note hierarchy - each subtree will represent a more refined and specialized view of your knowledge base.</p><p>This is a pretty powerful approach, but it also carries a hidden assumption that each \"subtopic\" is \"owned\" by one parent. I'll illustrate this with an example - let's say my basic structure is this:</p><ul><li>Technology<ul><li>Programming<ul><li>Kotlin</li><li>JavaScript</li></ul></li><li>Operating systems<ul><li>Linux</li><li>Windows</li></ul></li></ul></li></ul><p>Now, I'm starting to learn about <a href=\"https://en.wikipedia.org/wiki/Bash_(Unix_shell)\">Bash</a> and would like to create notes related to this topic. But now I'm facing a problem of where to categorize this. The issue here is that Bash is both a programming language and a tool (shell) very much tied into Linux. It seems it belongs to both of these, I can't (and don't want to) choose one over the other.</p><h2>Solution</h2><p>The solution to the problem shown above is to allow notes to have multiple parents.</p><p>I call these \"clones\", but that is a bit misleading - there's no original and cloned note - the notes in both of the parents categories are identical.</p><p>Another misleading thing about \"cloning\" is that it suggests that a copy of the note has been made. That's not really true, the note itself stays in just one original, it is just referenced in multiple places in the tree hierarchy. So changing it in one category changes it in all the others, because they're all the same note.</p><p>Here's the final structure with cloning:</p><ul><li>Technology<ul><li>Programming<ul><li>Kotlin</li><li>JavaScript</li><li>Bash<ul><li>some sub-notes ...</li></ul></li></ul></li><li>Operating systems<ul><li>Linux<ul><li>Bash<ul><li>some sub-notes ...</li></ul></li></ul></li><li>Windows</li></ul></li></ul></li></ul><p>So now the \"Bash\" subtree appears on multiple locations in the hierarchy. Both the Bash subtrees are the same and contain the same sub-categories and notes.</p><h3>Demo</h3><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Cloning%20Notes_create-clone.gif\"></p><p>In the demo, you can see how a clone can be created using the context menu. It's possible to do this also using the Add Link dialog or with <kbd>Ctrl</kbd>+<kbd>C</kbd> and <kbd>Ctrl</kbd>+<kbd>V</kbd> <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcuts</a>.</p><p>You can view the list of all available clones:</p><ul><li>In the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>, by looking for the <span class=\"tn-icon bx bx-directions\"></span> icon.</li><li>In the <a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a> of the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, by looking at the <em>Note paths</em> section.</li></ul><p>Titles of cloned notes in the tree view have an asterisk to the right to easily see that the note is also placed into some other location.</p><h2>Deleting notes/clones</h2><p>With clones, it might not be immediately obvious how deleting works.</p><p>If you try to delete a note, it works like this:</p><ol><li>if the note has multiple clones, delete just this clone and leave the actual note (and its other clones) as it is.</li><li>if this note doesn't have any other clones, delete the note<ul><li>Run the whole process starting with 1. on all note's children notes</li></ul></li></ol>","_help_TBwsyfadTA18": "<p>Since a single note can appear into multiple places in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> via a process called <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>, it's recommended to choose a generalized name that fits into all locations instead of something more specific to avoid confusion.</p><p>In some cases this isn't possible so Trilium provides \"branch prefixes\", which is shown before the note name in the tree and as such provides a specific kind of context.</p><p>The prefix is location-specific, so it's displayed only in the note tree.</p>","_help_bwg0e8ewQMak": "<p>Trilium is designed to store a wide variety of data, including sensitive information such as personal journals, credentials, or confidential documents. To safeguard this type of content, Trilium offers the option to protect notes, which involves the following measures:</p><ul><li><strong>Encryption:</strong> Protected notes are encrypted using a key derived from your password. This ensures that without the correct password, protected notes remain indecipherable. Even if someone gains access to your Trilium <a href=\"#root/_help_wX4HbRucYSDD\">database</a>, they won't be able to read your encrypted notes.</li><li><strong>Time-limited access:</strong> To access protected notes, you must first enter your password, which decrypts the note for reading and writing. However, after a specified period of inactivity (10 minutes by default), the note is unloaded from memory, requiring you to re-enter your password to access it again.<ul><li>The session timeout is extended automatically while you're interacting with the protected note, so if you're actively editing, the session remains open. However, if you switch to an unprotected note, the session timer starts, and the session expires after 10 minutes of inactivity unless you return to the protected notes.</li></ul></li><li><strong>Protection scope:</strong> Protected notes ensure the confidentiality of their content and partially their integrity. While unauthorized users cannot read or edit protected notes, they can still delete or move them outside of the protected session.</li></ul><h2>Using Protected Notes</h2><p>By default, notes are unprotected. To protect a note, simply click on the shield icon next to the note's title, as shown here:</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Protected%20Notes_protecting-note.gif\" alt=\"example animation of unlocking protected notes\"></p><h2>What is Encrypted?</h2><p>Trilium encrypts the data within protected notes but not their metadata. Specifically:</p><p><strong>Encrypted:</strong></p><ul><li>Note title</li><li>Note content</li><li>Images</li><li>File attachments</li></ul><p><strong>Not encrypted:</strong></p><ul><li>Note structure (i.e., it remains visible that there are protected notes)</li><li>Metadata, such as the last modified date</li><li><a href=\"#root/_help_zEY4DaJG4YT5\">Attributes</a></li></ul><h2>Encryption Details</h2><p>The following steps outline how encryption and decryption work in Trilium:</p><ol><li>The user enters a password.</li><li>The password is passed through the <a href=\"https://en.wikipedia.org/wiki/Scrypt\">scrypt</a> algorithm along with a \"password verification\" <a href=\"https://en.wikipedia.org/wiki/Salt_(cryptography)\">salt</a> to confirm that the password is correct.</li><li>The password is then processed again through scrypt with an \"encryption\" salt, which generates a hash.<ul><li>Scrypt is used for <a href=\"https://en.wikipedia.org/wiki/Key_stretching\">key stretching</a> to make the password harder to guess.</li></ul></li><li>The generated hash is used to decrypt the actual <em>data encryption key</em>.<ul><li>The data encryption key is encrypted using <a href=\"https://en.wikipedia.org/wiki/Advanced_Encryption_Standard\">AES-128</a> with a random <a href=\"https://en.wikipedia.org/wiki/Initialization_vector\">IV</a>.</li><li>The data encryption key is randomly generated during the <a href=\"#root/_help_wX4HbRucYSDD\">database</a> initialization and remains constant throughout the document’s lifetime. When the password is changed, only this key is re-encrypted.</li></ul></li><li>The data encryption key is then used to decrypt the actual content of the note, including its title and body.<ul><li>The encryption algorithm used is AES-128 with <a href=\"https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation\">CBC mode</a>, where a unique IV is generated for each encryption operation and stored with the cipher text.</li></ul></li></ol><h2>Sharing Protected Notes</h2><p>Protected notes cannot be shared in the same way as regular notes. Their encryption ensures that only authorized users with the correct password can access them.</p>",diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.md b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.mdindex d26209a533..ac3e744bd1 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Attachments.md@@ -20,6 +20,13 @@ There are two different types of attachment:The system attachments are displayed at the end of the attachments list, in a dedicated section (_Generated by Trilium_).+## Uploading attachments++The <span class="tn-icon bx bx-paperclip"></span>_Attachments_ item of the <a class="reference-link" href="../UI%20Elements/Note%20menu.md">Note menu</a> opens the list of the note's attachments.++* To upload files as attachments, press _Upload attachments_ at the top of the list and select one or more files.+* Alternatively, drag one or more files from the file explorer and drop them anywhere on the list. Pictures are compressed if _Automatic image compression_ is enabled in <a class="reference-link" href="../UI%20Elements/Options.md">Options</a> → _Media_.+## Attaching files from a text noteTo attach files to a <a class="reference-link" href="../../Note%20Types/Text.md">Text</a> note and embed them in its content, press the <span class="tn-icon cke cke-paper-clip"></span>_Attach file_ button in the <a class="reference-link" href="../../Note%20Types/Text/Formatting%20toolbar.md">Formatting toolbar</a>, choose _Attach and embed file_ and select one or more files (see _Embedding an attachment_ below). The same menu offers _Image_, which inserts pictures (see <a class="reference-link" href="../../Note%20Types/Text/Images.md">Images</a>), and _Attach file as a link_, which links the files instead. Both file actions are also available as _Attach file as a link_ and _Attach and embed file_ in the <a class="reference-link" href="../../Note%20Types/Text/Slash%20Commands.md">Slash Commands</a>. On a phone, the menu also offers _Camera_ (see <a class="reference-link" href="../../Installation%20%26%20Setup/Mobile%20Frontend.md">Mobile Frontend</a>).