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
feat(react/type_widget): add copy image reference floating button to image
Elian Doran3a68395ca772
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsxindex a423d0ccd1..1cdcf30cfd 100644--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx@@ -23,7 +23,7 @@ import { ViewTypeOptions } from "./collections/interface";export interface FloatingButtonContext {parentComponent: Component;- note: FNote;+ note: FNote;noteContext: NoteContext;isDefaultViewMode: boolean;isReadOnly: boolean;@@ -65,7 +65,7 @@ export const MOBILE_FLOATING_BUTTONS: FloatingButtonsList = [EditButton,RelationMapButtons,ExportImageButtons,- Backlinks+ Backlinks]function RefreshBackendLogButton({ note, parentComponent, noteContext, isDefaultViewMode }: FloatingButtonContext) {@@ -84,13 +84,13 @@ function SwitchSplitOrientationButton({ note, isReadOnly, isDefaultViewMode }: Freturn isEnabled && <FloatingButtontext={upcomingOrientation === "vertical" ? t("switch_layout_button.title_vertical") : t("switch_layout_button.title_horizontal")}- icon={upcomingOrientation === "vertical" ? "bx bxs-dock-bottom" : "bx bxs-dock-left"}+ icon={upcomingOrientation === "vertical" ? "bx bxs-dock-bottom" : "bx bxs-dock-left"}onClick={() => setSplitEditorOrientation(upcomingOrientation)}/>}function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: FloatingButtonContext) {- const [ isReadOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly");+ const [ isReadOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly");const isEnabled = (note.type === "mermaid" || viewType === "geoMap")&& note.isContentAvailable() && isDefaultViewMode;@@ -264,7 +264,7 @@ function GeoMapButtons({ triggerEvent, viewType, isReadOnly }: FloatingButtonConfunction CopyImageReferenceButton({ note, isDefaultViewMode }: FloatingButtonContext) {const hiddenImageCopyRef = useRef<HTMLDivElement>(null);- const isEnabled = ["mermaid", "canvas", "mindMap"].includes(note?.type ?? "")+ const isEnabled = ["mermaid", "canvas", "mindMap", "image"].includes(note?.type ?? "")&& note?.isContentAvailable() && isDefaultViewMode;return isEnabled && (@@ -325,7 +325,7 @@ function Backlinks({ note, isDefaultViewMode }: FloatingButtonContext) {let [ backlinkCount, setBacklinkCount ] = useState(0);let [ popupOpen, setPopupOpen ] = useState(false);const backlinksContainerRef = useRef<HTMLDivElement>(null);-+useEffect(() => {if (!isDefaultViewMode) return;@@ -338,7 +338,7 @@ function Backlinks({ note, isDefaultViewMode }: FloatingButtonContext) {const { windowHeight } = useWindowSize();useLayoutEffect(() => {const el = backlinksContainerRef.current;- if (popupOpen && el) {+ if (popupOpen && el) {const box = el.getBoundingClientRect();const maxHeight = windowHeight - box.top - 10;el.style.maxHeight = `${maxHeight}px`;@@ -374,7 +374,7 @@ function BacklinksList({ noteId }: { noteId: string }) {.filter(bl => "noteId" in bl).map((bl) => bl.noteId);await froca.getNotes(noteIds);- setBacklinks(backlinks);+ setBacklinks(backlinks);});}, [ noteId ]);@@ -395,4 +395,4 @@ function BacklinksList({ noteId }: { noteId: string }) {)}</div>));-}\ No newline at end of file+}