diff --git a/CLAUDE.md b/CLAUDE.md index bc88a72..b251155 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -25,3 +25,4 @@ pnpm typecheck # tsc -b のみ - ハイライト条件(キャラ選択 ∧ ボイス不要でない)は `src/lib/dialogue.ts` の `isHighlighted` に集約。件数集計・表示判定・連番付与がすべてこれを共有する - `Dialogue.character === ""` が地の文を表す(null ではなく空文字) - `toggleCharacter` は選んだ名前を部分文字列として含む全キャラを一括トグルする(例 「田中」で「田中A」「田中B」も切り替わる) +- `Dialogue.text` は `toZenKaku` で全角化済みの表示用、`Dialogue.rawText` は元の「」の中身そのまま(変換なし)。txt 書き出し(`src/lib/exportDialogue.ts`)は `rawText` を使う diff --git a/README.md b/README.md index 3d693a1..056da5f 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ - 縦書きの日本語台本を表示 - txt ファイルからのデータ読み込み - キャラクター名別にセリフの強調表示 +- 選択キャラのセリフを 1 行 1 セリフのプレーンテキスト txt で書き出し(元の「」の中身を変換せずそのまま出力) - 印刷用のスタイル設定(背景色、フォントサイズなど) - ブラウザ上での直接印刷サポート @@ -25,6 +26,7 @@ 2. txt ファイルを選択してアップロードします。 3. キャラクター名のチェックボックスを使用してセリフの表示をトグルします。 4. ブラウザから印刷します。 +5. 右下の「txt」ボタンで、選択中キャラのセリフをプレーンテキストの txt として書き出せます。 ## ローカルでのセットアップ diff --git a/src/App.tsx b/src/App.tsx index 3b2ce08..af3a89c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,7 @@ import { ScriptSummary } from "./components/ScriptSummary"; import { ScriptView } from "./components/ScriptView"; import { toggleCharactersByMatch } from "./lib/characterToggle"; import { isHighlighted } from "./lib/dialogue"; +import { buildDialogueText, exportFileName } from "./lib/exportDialogue"; import { parseScript, type ParseWarning } from "./lib/parseScript"; import { toggleInSet } from "./lib/setOps"; import type { Dialogue } from "./types"; @@ -72,6 +73,17 @@ export function App() { setNoVoice((prev) => toggleInSet(prev, id)); }; + const exportText = () => { + const text = buildDialogueText(dialogues, selected, noVoice); + const blob = new Blob([text], { type: "text/plain;charset=utf-8" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = exportFileName(title); + a.click(); + URL.revokeObjectURL(url); + }; + return ( <> - + ); } diff --git a/src/components/FloatingActions.tsx b/src/components/FloatingActions.tsx index 3140edf..487e10b 100644 --- a/src/components/FloatingActions.tsx +++ b/src/components/FloatingActions.tsx @@ -1,4 +1,8 @@ -export function FloatingActions() { +type Props = { + onExportText: () => void; +}; + +export function FloatingActions({ onExportText }: Props) { const scrollToStart = () => window.scrollTo({ left: 0, top: 0, behavior: "smooth" }); const scrollToEnd = () => @@ -27,6 +31,14 @@ export function FloatingActions() { > ← +