Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(web): show a QR code for note and notebook share links (#610)

Dariusz Koryto5ac19b542b0d
diff --git a/apps/web/src/components/dialogs/ShareMemoDialog.tsx b/apps/web/src/components/dialogs/ShareMemoDialog.tsx
index e1fa87ea..cd14049b 100644
--- a/apps/web/src/components/dialogs/ShareMemoDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareMemoDialog.tsx
@@ -7,6 +7,7 @@ import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { SharePasswordControls } from "./SharePasswordControls";
+import { ShareQrCode } from "./ShareQrCode";
import { SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME, SHARE_DIALOG_WIDTH_CLASS_NAME } from "./share-dialog-layout";
import { api, getConfiguredDesktopApiBaseUrl } from "@/lib/api";
import { copyTextToClipboard } from "@/lib/clipboard";
@@ -174,6 +175,10 @@ export const ShareMemoDialog = ({
onChange={(enabled) => passwordMutation.mutate(enabled)}
/>
+ {share.passwordProtected ? null : (
+ <ShareQrCode key={`qr-${share.token}`} url={shareUrl} hint={t("sharing.qrCodeHint")} />
+ )}
+
<div className="flex items-center justify-between pt-2">
<Button variant="danger" disabled={isWorking} onClick={() => revokeMutation.mutate()}>
<Trash2 className="h-4 w-4" />
diff --git a/apps/web/src/components/dialogs/ShareNotebookDialog.tsx b/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
index 6c381e19..6d6bee26 100644
--- a/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
+++ b/apps/web/src/components/dialogs/ShareNotebookDialog.tsx
@@ -12,6 +12,7 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
import { SharePasswordControls } from "./SharePasswordControls";
+import { ShareQrCode } from "./ShareQrCode";
import { SHARE_DIALOG_PRIMARY_BUTTON_CLASS_NAME, SHARE_DIALOG_WIDTH_CLASS_NAME } from "./share-dialog-layout";
import { Input } from "@/components/ui/input";
import { api, getConfiguredDesktopApiBaseUrl } from "@/lib/api";
@@ -185,6 +186,10 @@ export const ShareNotebookDialog = ({
onChange={(enabled) => passwordMutation.mutate(enabled)}
/>
+ {share.passwordProtected ? null : (
+ <ShareQrCode key={`qr-${share.token}`} url={shareUrl} hint={t("sharing.qrCodeNotebookHint")} />
+ )}
+
<div className="flex items-center justify-between pt-2">
<Button
variant="danger"
diff --git a/apps/web/src/components/dialogs/ShareQrCode.test.mjs b/apps/web/src/components/dialogs/ShareQrCode.test.mjs
new file mode 100644
index 00000000..5a9a92ef
--- /dev/null
+++ b/apps/web/src/components/dialogs/ShareQrCode.test.mjs
@@ -0,0 +1,40 @@
+import { describe, expect, test } from "bun:test";
+import { readFileSync } from "node:fs";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { QRCodeSVG } from "qrcode.react";
+
+const source = (name) => readFileSync(new URL(`./${name}`, import.meta.url), "utf8");
+
+describe("share link QR code", () => {
+ test("is offered in both share dialogs only for links without a password", () => {
+ for (const [dialog, hint] of [["ShareMemoDialog.tsx", "sharing.qrCodeHint"], ["ShareNotebookDialog.tsx", "sharing.qrCodeNotebookHint"]]) {
+ const code = source(dialog);
+ expect(code).toContain(`{share.passwordProtected ? null : (\n <ShareQrCode key={\`qr-\${share.token}\`} url={shareUrl} hint={t("${hint}")} />`);
+ // A sibling keyed with the bare token (SharePasswordControls) would make React duplicate rows.
+ expect(code.match(/key=\{share\.token\}/g)?.length ?? 0).toBeLessThanOrEqual(1);
+ }
+ });
+
+ test("renders an accessible SVG with dark modules on white and no native tooltip", () => {
+ const component = source("ShareQrCode.tsx");
+ expect(component).toContain('bgColor="#ffffff"');
+ expect(component).toContain('fgColor="#000000"');
+ expect(component).toContain('aria-label={t("sharing.qrCodeLabel")}');
+ expect(component).not.toMatch(/\btitle=/);
+
+ const markup = renderToStaticMarkup(createElement(QRCodeSVG, {
+ value: "https://notes.example/share/abc",
+ size: 176,
+ level: "M",
+ marginSize: 0,
+ role: "img",
+ "aria-label": "QR code for the share link",
+ }));
+ expect(markup).toStartWith("<svg");
+ expect(markup).toContain('role="img"');
+ expect(markup).toContain('aria-label="QR code for the share link"');
+ expect(markup).not.toContain("<title");
+ expect(markup).toContain("<path");
+ });
+});
diff --git a/apps/web/src/components/dialogs/ShareQrCode.tsx b/apps/web/src/components/dialogs/ShareQrCode.tsx
new file mode 100644
index 00000000..66a19ffa
--- /dev/null
+++ b/apps/web/src/components/dialogs/ShareQrCode.tsx
@@ -0,0 +1,43 @@
+import { ChevronDown, QrCode } from "lucide-react";
+import { QRCodeSVG } from "qrcode.react";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/components/ui/button";
+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
+
+/**
+ * Scannable share link for opening a share on another device. Callers render it
+ * only for links without a password, so the code never stands in for one.
+ */
+export const ShareQrCode = ({ url, hint }: { url: string; hint: string }) => {
+ const { t } = useTranslation();
+
+ return (
+ <Collapsible>
+ <CollapsibleTrigger asChild>
+ <Button variant="ghost" size="sm" className="group -ml-2.5">
+ <QrCode className="h-4 w-4" aria-hidden="true" />
+ {t("sharing.qrCode")}
+ <ChevronDown className="h-3.5 w-3.5 transition-transform group-data-[state=open]:rotate-180" aria-hidden="true" />
+ </Button>
+ </CollapsibleTrigger>
+ <CollapsibleContent className="pt-2">
+ <figure className="flex flex-col items-center gap-2">
+ {/* Keep dark modules on white in every theme so phone cameras can read the code. */}
+ <div className="rounded-lg border border-slate-200 bg-white p-3">
+ <QRCodeSVG
+ value={url}
+ size={176}
+ level="M"
+ marginSize={0}
+ bgColor="#ffffff"
+ fgColor="#000000"
+ role="img"
+ aria-label={t("sharing.qrCodeLabel")}
+ />
+ </div>
+ <figcaption className="text-center text-xs leading-5 text-muted-foreground">{hint}</figcaption>
+ </figure>
+ </CollapsibleContent>
+ </Collapsible>
+ );
+};
diff --git a/bun.lock b/bun.lock
index 86260805..88b09026 100644
--- a/bun.lock
+++ b/bun.lock
@@ -54,6 +54,7 @@
"marked": "^18.0.5",
"p-limit": "^6.2.0",
"pdfjs-dist": "^6.2.108",
+ "qrcode.react": "4.2.0",
"react": "~19.2.7",
"react-dom": "~19.2.7",
"react-dropzone": "^15.0.0",
@@ -102,7 +103,7 @@
},
"apps/desktop": {
"name": "@edgeever/desktop",
- "version": "1.120.0",
+ "version": "1.121.0",
"dependencies": {
"@agentclientprotocol/sdk": "^1.5.1",
"@edgeever/public-network": "workspace:*",
@@ -3671,6 +3672,8 @@
"pvutils": ["[email protected]", "", {}, "sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA=="],
+ "qrcode.react": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-QpgqWi8rD9DsS9EP3z7BT+5lY5SFhsqGjpgW5DY/i3mK4M9DTBNz3ErMi8BWYEfI3L0d8GIbGmcdFAS1uIRGjA=="],
+
"quansync": ["[email protected]", "", {}, "sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA=="],
"query-string": ["[email protected]", "", { "dependencies": { "decode-uri-component": "^0.2.2", "filter-obj": "^1.1.0", "split-on-first": "^1.0.0", "strict-uri-encode": "^2.0.0" } }, "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg=="],
diff --git a/package.json b/package.json
index 5e604790..7376e2a1 100644
--- a/package.json
+++ b/package.json
@@ -170,6 +170,7 @@
"marked": "^18.0.5",
"p-limit": "^6.2.0",
"pdfjs-dist": "^6.2.108",
+ "qrcode.react": "4.2.0",
"react": "~19.2.7",
"react-dom": "~19.2.7",
"react-dropzone": "^15.0.0",
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index c560f731..dd5ba9fc 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -2618,6 +2618,10 @@ export const enUS = {
expandOutlineHeading: "Expand {{name}}",
},
sharing: {
+ qrCode: "QR code",
+ qrCodeLabel: "QR code for the share link",
+ qrCodeHint: "Scan with a phone camera to open this note.",
+ qrCodeNotebookHint: "Scan with a phone camera to open this notebook.",
contentLabel: "Shared note content",
siteHideContents: "Hide contents",
siteShowContents: "Show contents",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index 53428ebd..3597580f 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -2607,6 +2607,10 @@ export const ja = {
expandOutlineHeading: "{{name}} を開く",
},
sharing: {
+ qrCode: "QR コード",
+ qrCodeLabel: "共有リンクの QR コード",
+ qrCodeHint: "スマートフォンのカメラで読み取ると、このノートを開けます。",
+ qrCodeNotebookHint: "スマートフォンのカメラで読み取ると、このノートブックを開けます。",
contentLabel: "共有されたノートの内容",
siteHideContents: "目次を隠す",
siteShowContents: "目次を表示",
diff --git a/packages/shared/src/i18n/pl.ts b/packages/shared/src/i18n/pl.ts
index 5ad5184d..faa62ab4 100644
--- a/packages/shared/src/i18n/pl.ts
+++ b/packages/shared/src/i18n/pl.ts
@@ -2607,6 +2607,10 @@ export const pl = {
expandOutlineHeading: "Rozwiń {{name}}",
},
sharing: {
+ qrCode: "Kod QR",
+ qrCodeLabel: "Kod QR linku udostępniania",
+ qrCodeHint: "Zeskanuj aparatem telefonu, aby otworzyć tę notatkę.",
+ qrCodeNotebookHint: "Zeskanuj aparatem telefonu, aby otworzyć ten notes.",
contentLabel: "Treść udostępnionej notatki",
siteHideContents: "Ukryj spis treści",
siteShowContents: "Pokaż spis treści",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 6f68dc66..2f1882aa 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -2616,6 +2616,10 @@ export const zhCN = {
expandOutlineHeading: "展开 {{name}}",
},
sharing: {
+ qrCode: "二维码",
+ qrCodeLabel: "分享链接二维码",
+ qrCodeHint: "用手机相机扫码即可打开这篇笔记。",
+ qrCodeNotebookHint: "用手机相机扫码即可打开这个笔记本。",
contentLabel: "分享的笔记内容",
siteHideContents: "收起目录",
siteShowContents: "展开目录",