gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (efd75a533 -> 6307c6d66)


From: gnunet
Subject: [taler-wallet-core] branch master updated (efd75a533 -> 6307c6d66)
Date: Sun, 11 Aug 2024 19:34:04 +0200

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

nora-grothoff pushed a change to branch master
in repository wallet-core.

    from efd75a533 bump version to 0.12.10
     new 46b6607b2 fix: make printWindow have DOCTYPE html
     new 3c286023d fix: provide native {create,revoke}ObjectURL implementation 
aliases
     new e0e4fb390 fix: use QR images
     new 6307c6d66 fix: use a half decent pdf saving mechanism

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/components/exception/QR.tsx                |  6 ++++-
 .../src/paths/instance/templates/qr/QrPage.tsx     | 26 ++++++++++++++--------
 packages/taler-util/src/whatwg-url.ts              | 18 ++++++++++++++-
 3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/packages/merchant-backoffice-ui/src/components/exception/QR.tsx 
b/packages/merchant-backoffice-ui/src/components/exception/QR.tsx
index 246ce0229..029a87879 100644
--- a/packages/merchant-backoffice-ui/src/components/exception/QR.tsx
+++ b/packages/merchant-backoffice-ui/src/components/exception/QR.tsx
@@ -25,9 +25,13 @@ export function QR({ text }: { text: string }): VNode {
     qr.addData(text);
     qr.make();
     if (divRef.current) {
-      divRef.current.innerHTML = qr.createSvgTag({
+      const image = qr.createSvgTag({
         scalable: true,
       });
+      const imageURL = `data:image/svg+xml,${encodeURIComponent(image)}`;
+      divRef.current.innerHTML = `<img src=${JSON.stringify(
+        imageURL,
+      )} alt=${JSON.stringify(`QR Code containing the data ${text}`)} />`;
     }
   });
 
diff --git 
a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx 
b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
index 93a21bd80..c66361e17 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx
@@ -86,18 +86,26 @@ export function QrPage({ id: templateId, onBack }: Props): 
VNode {
 }
 
 function saveAsPDF(name: string): void {
-  const printWindow = window.open("", "", "height=400,width=800");
-  if (!printWindow) return;
+  // TODO: Look into using media queries in the current page, to print the 
current page, instead of opening a new window
+
   const divContents = document.getElementById("printThis");
   if (!divContents) return;
-  printWindow.document.write(
-    `<html><head><title>Order template for ${name}</title><style>`,
-  );
-  printWindow.document.write("</style></head><body>&nbsp;</body></html>");
-  printWindow.document.close();
-  printWindow.document.body.appendChild(divContents.cloneNode(true));
+
+  let dom = `<!DOCTYPE html>
+<html>
+  <head>
+    <title>Order template for ${name}</title>
+  </head>
+  <body>
+    ${divContents.outerHTML}
+  </body>
+</html>`;
+  const blobUrl = URL.createObjectURL(new Blob([dom]));
+  const printWindow = window.open(blobUrl, "", "height=400,width=800");
+  if (!printWindow) return;
   printWindow.addEventListener("load", () => {
     printWindow.print();
-    // printWindow.close();
+    printWindow.close();
+    URL.revokeObjectURL(blobUrl);
   });
 }
diff --git a/packages/taler-util/src/whatwg-url.ts 
b/packages/taler-util/src/whatwg-url.ts
index 869b304ed..bc2c682fc 100644
--- a/packages/taler-util/src/whatwg-url.ts
+++ b/packages/taler-util/src/whatwg-url.ts
@@ -425,7 +425,7 @@ export class URLSearchParamsImpl {
   }
 
   entries() {
-    return [...this._list.map(x => [x[0], x[1]])];
+    return [...this._list.map((x) => [x[0], x[1]])];
   }
 
   forEach(
@@ -1911,6 +1911,7 @@ function parseURL(
   });
 }
 
+const NativeURL = typeof URL !== "undefined" ? URL : undefined;
 export class URLImpl {
   //Include URL type for "url" and "base" params.
   constructor(url: string | URL, base?: string | URL) {
@@ -2124,6 +2125,21 @@ export class URLImpl {
     return this.href;
   }
 
+  static createObjectURL(blob: Blob) {
+    if (!NativeURL)
+      throw new Error(
+        "This method requires a native implementation, which does not exist",
+      );
+    return NativeURL.createObjectURL(blob);
+  }
+  static revokeObjectURL(url: string) {
+    if (!NativeURL)
+      throw new Error(
+        "This method requires a native implementation, which does not exist",
+      );
+    return NativeURL.revokeObjectURL(url);
+  }
+
   // FIXME: type!
   _url: any;
   _query: any;

-- 
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]