Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): remove the floating copy image reference button

Elian Doraneedbf0128b07
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 35bdb64ef1..79c4a02e7b 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1204,9 +1204,6 @@
"opening_api_docs_message": "Opening API docs...",
"sql_console_saved_message": "SQL Console note has been saved into {{note_path}}"
},
- "copy_image_reference_button": {
- "button_title": "Copy image reference to the clipboard, can be pasted into a text note."
- },
"hide_floating_buttons_button": {
"button_title": "Hide buttons"
},
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
index 4ba422d64f..fc04c06ceb 100644
--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
@@ -10,12 +10,11 @@ import FNote from "../entities/fnote";
import attributes from "../services/attributes";
import froca from "../services/froca";
import { t } from "../services/i18n";
-import { copyImageReferenceToClipboard } from "../services/image";
import { getHelpUrlForNote } from "../services/in_app_help";
import LoadResults from "../services/load_results";
import { sanitizeNoteContentHtml } from "../services/sanitize_content";
import server from "../services/server";
-import { createImageSrcUrl, openInAppHelpFromUrl } from "../services/utils";
+import { openInAppHelpFromUrl } from "../services/utils";
import ActionButton, { ActionButtonProps } from "./react/ActionButton";
import { useTriliumEvent, useWindowSize } from "./react/hooks";
import NoItems from "./react/NoItems";
@@ -41,7 +40,6 @@ function FloatingButton({ className, ...props }: ActionButtonProps) {
export type FloatingButtonsList = ((context: FloatingButtonContext) => false | VNode)[];
export const DESKTOP_FLOATING_BUTTONS: FloatingButtonsList = [
- CopyImageReferenceButton,
ExportImageButtons,
ExportSpreadsheetButton,
InAppHelpButton,
@@ -55,35 +53,6 @@ export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [
InAppHelpButton
];
-function CopyImageReferenceButton({ note, isDefaultViewMode }: FloatingButtonContext) {
- const hiddenImageCopyRef = useRef<HTMLDivElement>(null);
- const isEnabled = (
- ["mermaid", "canvas", "mindMap", "image"].includes(note?.type ?? "")
- && note?.isContentAvailable() && isDefaultViewMode
- );
-
- return isEnabled && (
- <>
- <FloatingButton
- icon="bx bx-copy"
- text={t("copy_image_reference_button.button_title")}
- onClick={() => {
- if (!hiddenImageCopyRef.current) return;
- const imageEl = document.createElement("img");
- imageEl.src = createImageSrcUrl(note);
- hiddenImageCopyRef.current.replaceChildren(imageEl);
- copyImageReferenceToClipboard($(hiddenImageCopyRef.current));
- hiddenImageCopyRef.current.removeChild(imageEl);
- }}
- />
-
- <div ref={hiddenImageCopyRef} className="hidden-image-copy" style={{
- position: "absolute" // Take out of the the hidden image from flexbox to prevent the layout being affected
- }} />
- </>
- );
-}
-
function ExportImageButtons({ note, triggerEvent, isDefaultViewMode }: FloatingButtonContext) {
const isEnabled = ["mermaid", "mindMap"].includes(note?.type ?? "")
&& note?.isContentAvailable() && isDefaultViewMode;