From 9cbc59811f623d5e0f04673b0412382162da1b78 Mon Sep 17 00:00:00 2001 From: charlie Date: Mon, 4 Nov 2024 11:57:30 +0800 Subject: [PATCH] enhance(ux): copy raw code editor content --- src/main/frontend/components/block.cljs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index a51b36eac3e..af0220e54b2 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -3759,11 +3759,13 @@ (shui/button {:variant :text :size :sm - :on-click (fn [e] + :on-click (fn [^js e] (util/stop-propagation e) - (editor-handler/copy-block-content! block))} - (ui/icon "copy") - "Copy")] + (when-let [^js cm (util/get-cm-instance (util/rec-get-node (.-target e) "ls-block"))] + (util/copy-to-clipboard! (.getValue cm)) + (notification/show! "Copied!" :success)))} + (ui/icon "copy") + "Copy")] (lazy-editor/editor config (str (d/squuid)) attr code options) (let [options (:options options) block (:block config)] (when (and (= language "clojure") (contains? (set options) ":results"))