gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/06: fix ref for copy and paste


From: gnunet
Subject: [taler-wallet-core] 02/06: fix ref for copy and paste
Date: Mon, 11 Apr 2022 16:36:50 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit df7c249c95bd5583f7cee7cfaabe29b8508babcd
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Apr 11 11:32:20 2022 -0300

    fix ref for copy and paste
---
 .../build-fast-with-linaria.mjs                    |  2 +-
 .../src/components/BankDetailsByPaytoType.tsx      | 22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/packages/taler-wallet-webextension/build-fast-with-linaria.mjs 
b/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
index 77106a4f..f6de6788 100755
--- a/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
+++ b/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
@@ -60,7 +60,7 @@ export const buildConfig = {
   ],
   format: 'iife',
   platform: 'browser',
-  sourcemap: 'external',
+  sourcemap: true, 
   jsxFactory: 'h',
   jsxFragment: 'Fragment',
   // define: {
diff --git 
a/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx 
b/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
index aff2bada..182e82a3 100644
--- 
a/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
+++ 
b/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
@@ -16,7 +16,7 @@
 
 import { PaytoUri } from "@gnu-taler/taler-util";
 import { Fragment, h, VNode } from "preact";
-import { useEffect, useState } from "preact/hooks";
+import { useEffect, useRef, useState } from "preact/hooks";
 import { useTranslationContext } from "../context/translation.js";
 import { CopiedIcon, CopyIcon } from "../svg/index.js";
 import { ButtonBox, TooltipRight } from "./styled/index.js";
@@ -25,7 +25,7 @@ export interface BankDetailsProps {
   payto: PaytoUri | undefined;
   exchangeBaseUrl: string;
   subject: string;
-  amount: string;
+  amount: string | VNode;
 }
 
 export function BankDetailsByPaytoType({
@@ -84,12 +84,17 @@ function Row({
   literal,
 }: {
   name: VNode;
-  value: string;
+  value: string | VNode;
   literal?: boolean;
 }): VNode {
   const [copied, setCopied] = useState(false);
+  const preRef = useRef<HTMLPreElement>(null);
+  const tdRef = useRef<HTMLTableCellElement>(null);
   function copyText(): void {
-    navigator.clipboard.writeText(value);
+    const content = literal
+      ? preRef.current?.textContent
+      : tdRef.current?.textContent;
+    navigator.clipboard.writeText(content || "");
     setCopied(true);
   }
   useEffect(() => {
@@ -98,7 +103,7 @@ function Row({
         setCopied(false);
       }, 1000);
     }
-  }, [copied]);
+  }, [copied, preRef]);
   return (
     <tr>
       <td>
@@ -119,12 +124,15 @@ function Row({
       </td>
       {literal ? (
         <td>
-          <pre style={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}>
+          <pre
+            ref={preRef}
+            style={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}
+          >
             {value}
           </pre>
         </td>
       ) : (
-        <td>{value}</td>
+        <td ref={tdRef}>{value}</td>
       )}
     </tr>
   );

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]