From 0f1cf55e7c44a5cac73d50ee7974aadcdcb13778 Mon Sep 17 00:00:00 2001 From: taminororo <169162271+taminororo@users.noreply.github.com> Date: Fri, 27 Feb 2026 18:30:08 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[feat]=20Google=20=E3=83=89=E3=82=AD?= =?UTF-8?q?=E3=83=A5=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE=E3=83=97=E3=83=AC?= =?UTF-8?q?=E3=83=93=E3=83=A5=E3=83=BC=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/prototypes/manual-preview.tsx | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 admin/next-project/seeft-admin/src/pages/prototypes/manual-preview.tsx diff --git a/admin/next-project/seeft-admin/src/pages/prototypes/manual-preview.tsx b/admin/next-project/seeft-admin/src/pages/prototypes/manual-preview.tsx new file mode 100644 index 00000000..f25a7c56 --- /dev/null +++ b/admin/next-project/seeft-admin/src/pages/prototypes/manual-preview.tsx @@ -0,0 +1,133 @@ +import React, { useState } from "react"; + +// 入力された Google ドキュメントの URL を iframe 用の /preview URL に変換する +// (/export?format=pdf は Content-Disposition: attachment でダウンロードになるため、表示には /preview を使う) +const toEmbedPreviewUrl = (originalUrl: string): string | null => { + const trimmed = originalUrl.trim(); + if (!trimmed) return null; + + try { + const url = new URL(trimmed); + + if (url.hostname.includes("docs.google.com")) { + // パスからドキュメントID部分だけ残し、/preview に統一(iframe 内でその場表示される) + const match = url.pathname.match(/\/document\/d\/([^/]+)/); + if (match) { + return `https://docs.google.com/document/d/${match[1]}/preview`; + } + } + + return trimmed; + } catch { + return null; + } +}; + +const ManualPreviewPrototype: React.FC = () => { + const [inputUrl, setInputUrl] = useState(""); + const [previewUrl, setPreviewUrl] = useState(null); + const [isOpen, setIsOpen] = useState(false); + const [error, setError] = useState(null); + + const handlePreview = () => { + const converted = toEmbedPreviewUrl(inputUrl); + if (!converted) { + setError("有効な URL を入力してください。"); + setPreviewUrl(null); + setIsOpen(false); + return; + } + + setError(null); + setPreviewUrl(converted); + setIsOpen(true); + }; + + return ( +
+

+ Google ドキュメント プレビュー(プロトタイプ) +

+ +

+ 共有リンク(edit や view の URL)を入力すると、 + /preview に書き換えて iframe 内にその場で表示します(ダウンロードされません)。 + 既存機能とは独立したサンプルページです。 +

+ +
+ + setInputUrl(e.target.value)} + placeholder="https://docs.google.com/document/d/..." + style={{ + width: "100%", + padding: "8px 12px", + borderRadius: 4, + border: "1px solid #ccc", + fontSize: 14, + }} + /> +
+ + + + {error && ( +

{error}

+ )} + + {previewUrl && ( +
+ + + {isOpen && ( +
+