From 397fb785d623f5807277e574452195a5f49261c3 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 7 Dec 2025 21:21:55 +0200 Subject: [PATCH] feat(ckeditor/watchdog): functional copy to clipboard button --- .../src/translations/en/translation.json | 3 +- apps/client/src/widgets/dialogs/info.tsx | 37 ++++++++++++++++--- .../src/widgets/dialogs/markdown_import.tsx | 5 +-- .../type_widgets/text/EditableText.tsx | 5 ++- apps/server/src/routes/api/other.ts | 15 ++++++-- apps/server/src/routes/routes.ts | 1 + packages/commons/src/lib/server_api.ts | 8 ++++ 7 files changed, 58 insertions(+), 16 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 54f1500c8..46aa54401 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -205,7 +205,8 @@ "info": { "modalTitle": "Info message", "closeButton": "Close", - "okButton": "OK" + "okButton": "OK", + "copy_to_clipboard": "Copy to clipboard" }, "jump_to_note": { "search_placeholder": "Search for note by its name or type > for commands...", diff --git a/apps/client/src/widgets/dialogs/info.tsx b/apps/client/src/widgets/dialogs/info.tsx index c292db68f..03fabbfa3 100644 --- a/apps/client/src/widgets/dialogs/info.tsx +++ b/apps/client/src/widgets/dialogs/info.tsx @@ -8,11 +8,19 @@ import { useTriliumEvent } from "../react/hooks"; import { isValidElement } from "preact"; import { ConfirmWithMessageOptions } from "./confirm"; import "./info.css"; +import server from "../../services/server"; +import { ToMarkdownResponse } from "@triliumnext/commons"; +import { copyTextWithToast } from "../../services/clipboard_ext"; + +export interface InfoExtraProps extends Partial> { + /** Adds a button in the footer that allows easily copying the content of the infobox to clipboard. */ + copyToClipboardButton?: boolean; +} -export type InfoExtraProps = Partial>; export type InfoProps = ConfirmWithMessageOptions & InfoExtraProps; export default function InfoDialog() { + const modalRef = useRef(null); const [ opts, setOpts ] = useState>(); const [ shown, setShown ] = useState(false); const okButtonRef = useRef(null); @@ -31,11 +39,28 @@ export default function InfoDialog() { setShown(false); }} onShown={() => okButtonRef.current?.focus?.()} - footer={