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/note context menu: add "Edit note" for read-only notes
Adorian Doranbec47c0bb209
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsxindex 1c1c17502c..3b396e0706 100644--- a/apps/client/src/widgets/ribbon/NoteActions.tsx+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx@@ -1,19 +1,20 @@import { ConvertToAttachmentResponse } from "@triliumnext/commons";-import appContext, { CommandNames } from "../../components/app_context";-import FNote from "../../entities/fnote"-import dialog from "../../services/dialog";-import { t } from "../../services/i18n"-import server from "../../services/server";-import toast from "../../services/toast";-import ws from "../../services/ws";-import ActionButton from "../react/ActionButton"-import Dropdown from "../react/Dropdown";import { FormDropdownDivider, FormListItem } from "../react/FormList";import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/utils";import { ParentComponent } from "../react/react_utils";+import { t } from "../../services/i18n"import { useContext } from "preact/hooks";-import NoteContext from "../../components/note_context";+import { useIsNoteReadOnly } from "../react/hooks";+import ActionButton from "../react/ActionButton"+import appContext, { CommandNames } from "../../components/app_context";import branches from "../../services/branches";+import dialog from "../../services/dialog";+import Dropdown from "../react/Dropdown";+import FNote from "../../entities/fnote"+import NoteContext from "../../components/note_context";+import server from "../../services/server";+import toast from "../../services/toast";+import ws from "../../services/ws";interface NoteActionsProps {note?: FNote;@@ -52,6 +53,7 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: Notconst isMac = getIsMac();const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap"].includes(note.type);const isSearchOrBook = ["search", "book"].includes(note.type);+ const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);return (<Dropdown@@ -59,8 +61,15 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: NotclassName="note-actions"hideToggleArrownoSelectButtonStyle- iconAction- >+ iconAction>++ {isReadOnly && <>+ <FormListItem icon="bx bx-pencil" onClick={() => enableEditing()}>+ {t("read-only-info.edit-note")}+ </FormListItem>+ <FormDropdownDivider />+ </>}+{canBeConvertedToAttachment && <ConvertToAttachment note={note} /> }{note.type === "render" && <CommandItem command="renderActiveNote" icon="bx bx-extension" text={t("note_actions.re_render_note")} />}<CommandItem command="findInText" icon="bx bx-search" disabled={!isSearchable} text={t("note_actions.search_in_note")} />