Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files- frontend/app.js +88 -0
- frontend/index.html +55 -0
- frontend/style.css +238 -0
frontend/app.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Ensure Markmap libraries are loaded from CDN
|
| 2 |
+
const { markmap } = window;
|
| 3 |
+
const { Markmap, loadCSS, loadJS } = markmap;
|
| 4 |
+
const { Transformer } = window.markmap;
|
| 5 |
+
|
| 6 |
+
// Create Transformer instance
|
| 7 |
+
const transformer = new Transformer();
|
| 8 |
+
|
| 9 |
+
// Initialize Markmap on the SVG element
|
| 10 |
+
let mm;
|
| 11 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 12 |
+
mm = Markmap.create('#markmap');
|
| 13 |
+
|
| 14 |
+
// Initial dummy data to show something beautiful right away
|
| 15 |
+
const initialMarkdown = `
|
| 16 |
+
# マインドマップ自動生成
|
| 17 |
+
## 使い方
|
| 18 |
+
- 左側に文章を入力します
|
| 19 |
+
- 「マップを生成」ボタンを押します
|
| 20 |
+
## 特徴
|
| 21 |
+
- AIが文脈を理解して自動で構造化
|
| 22 |
+
- 専用カスタムAI(edha 1.0 3B)による情報抽出
|
| 23 |
+
`;
|
| 24 |
+
renderMindMap(initialMarkdown);
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
// Function to render Markdown to MindMap
|
| 28 |
+
function renderMindMap(markdownContent) {
|
| 29 |
+
// 1. Transform markdown to Markmap internal format
|
| 30 |
+
const { root, features } = transformer.transform(markdownContent);
|
| 31 |
+
|
| 32 |
+
// 2. Load necessary assets for features (like Katex or highlight.js) if used
|
| 33 |
+
const { styles, scripts } = transformer.getUsedAssets(features);
|
| 34 |
+
if (styles) loadCSS(styles);
|
| 35 |
+
if (scripts) loadJS(scripts, { getMarkmap: () => markmap });
|
| 36 |
+
|
| 37 |
+
// 3. Update the Markmap instance with new data
|
| 38 |
+
mm.setData(root);
|
| 39 |
+
mm.fit(); // Automatically fit to screen
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// Event Listeners
|
| 43 |
+
const generateBtn = document.getElementById('generateBtn');
|
| 44 |
+
const inputText = document.getElementById('inputText');
|
| 45 |
+
const loadingDiv = document.getElementById('loading');
|
| 46 |
+
|
| 47 |
+
generateBtn.addEventListener('click', async () => {
|
| 48 |
+
const text = inputText.value.trim();
|
| 49 |
+
if (!text) {
|
| 50 |
+
alert("Please enter some text to generate a map.");
|
| 51 |
+
return;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// Show loading
|
| 55 |
+
generateBtn.disabled = true;
|
| 56 |
+
generateBtn.classList.add('hidden');
|
| 57 |
+
loadingDiv.classList.remove('hidden');
|
| 58 |
+
|
| 59 |
+
try {
|
| 60 |
+
// --- PHASE 3: Real API Call ---
|
| 61 |
+
console.log("Sending request to backend...");
|
| 62 |
+
const response = await fetch('/generate', {
|
| 63 |
+
method: 'POST',
|
| 64 |
+
headers: {
|
| 65 |
+
'Content-Type': 'application/json',
|
| 66 |
+
},
|
| 67 |
+
body: JSON.stringify({ text: text })
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
if (!response.ok) {
|
| 71 |
+
throw new Error('API error: ' + response.status);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
const data = await response.json();
|
| 75 |
+
console.log("✅ RAW BACKEND RESPONSE:", data.markdown);
|
| 76 |
+
|
| 77 |
+
// Render the Markdown returned by the Python backend
|
| 78 |
+
renderMindMap(data.markdown);
|
| 79 |
+
|
| 80 |
+
} catch (error) {
|
| 81 |
+
alert("Error occurred: " + error.message);
|
| 82 |
+
} finally {
|
| 83 |
+
// Hide loading
|
| 84 |
+
generateBtn.disabled = false;
|
| 85 |
+
generateBtn.classList.remove('hidden');
|
| 86 |
+
loadingDiv.classList.add('hidden');
|
| 87 |
+
}
|
| 88 |
+
});
|
frontend/index.html
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ja">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>MindMap Studio</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css?v=3">
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/markmap-lib"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/markmap-view"></script>
|
| 11 |
+
</head>
|
| 12 |
+
<body>
|
| 13 |
+
<div class="app-layout">
|
| 14 |
+
<!-- Sidebar -->
|
| 15 |
+
<aside class="sidebar">
|
| 16 |
+
<div class="sidebar-header">
|
| 17 |
+
<div class="logo">
|
| 18 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>
|
| 19 |
+
<span>MindMap Studio</span>
|
| 20 |
+
</div>
|
| 21 |
+
</div>
|
| 22 |
+
|
| 23 |
+
<div class="sidebar-content">
|
| 24 |
+
<div class="input-group">
|
| 25 |
+
<label for="inputText">Source Text</label>
|
| 26 |
+
<textarea id="inputText" placeholder="議事録や講義のテキストをペーストしてください..."></textarea>
|
| 27 |
+
</div>
|
| 28 |
+
|
| 29 |
+
<button id="generateBtn" class="btn-primary">
|
| 30 |
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
|
| 31 |
+
マップを生成
|
| 32 |
+
</button>
|
| 33 |
+
|
| 34 |
+
<div id="loading" class="hidden">
|
| 35 |
+
<div class="spinner"></div>
|
| 36 |
+
<span>Processing text...</span>
|
| 37 |
+
</div>
|
| 38 |
+
</div>
|
| 39 |
+
|
| 40 |
+
<div class="sidebar-footer">
|
| 41 |
+
<p>Powered by edha 1.0 3B</p>
|
| 42 |
+
</div>
|
| 43 |
+
</aside>
|
| 44 |
+
|
| 45 |
+
<!-- Main Canvas -->
|
| 46 |
+
<main class="canvas-area">
|
| 47 |
+
<svg id="markmap"></svg>
|
| 48 |
+
<div class="disclaimer" style="position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); font-size: 11px; color: #a1a1aa; text-align: center; pointer-events: none; z-index: 1000; width: 100%;">
|
| 49 |
+
MindMap Studioの回答は正しいとは限らないので、重要な情報は必ず見直してください。
|
| 50 |
+
</div>
|
| 51 |
+
</main>
|
| 52 |
+
</div>
|
| 53 |
+
<script src="app.js?v=3"></script>
|
| 54 |
+
</body>
|
| 55 |
+
</html>
|
frontend/style.css
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
|
| 2 |
+
|
| 3 |
+
:root {
|
| 4 |
+
--bg-canvas: #fafafa;
|
| 5 |
+
--bg-sidebar: #ffffff;
|
| 6 |
+
--border-color: #eaeaea;
|
| 7 |
+
--text-primary: #171717;
|
| 8 |
+
--text-secondary: #666666;
|
| 9 |
+
--text-tertiary: #a1a1aa;
|
| 10 |
+
--focus-ring: rgba(0, 0, 0, 0.08);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
* {
|
| 14 |
+
box-sizing: border-box;
|
| 15 |
+
margin: 0;
|
| 16 |
+
padding: 0;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
body {
|
| 20 |
+
font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
|
| 21 |
+
color: var(--text-primary);
|
| 22 |
+
background-color: var(--bg-canvas);
|
| 23 |
+
height: 100vh;
|
| 24 |
+
overflow: hidden;
|
| 25 |
+
-webkit-font-smoothing: antialiased;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.app-layout {
|
| 29 |
+
display: flex;
|
| 30 |
+
height: 100vh;
|
| 31 |
+
width: 100vw;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/* Sidebar Styling (Vercel/Linear Style) */
|
| 35 |
+
.sidebar {
|
| 36 |
+
width: 360px;
|
| 37 |
+
background-color: var(--bg-sidebar);
|
| 38 |
+
border-right: 1px solid var(--border-color);
|
| 39 |
+
display: flex;
|
| 40 |
+
flex-direction: column;
|
| 41 |
+
box-shadow: 1px 0 10px rgba(0,0,0,0.02);
|
| 42 |
+
z-index: 10;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.sidebar-header {
|
| 46 |
+
padding: 24px;
|
| 47 |
+
border-bottom: 1px solid var(--border-color);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.logo {
|
| 51 |
+
display: flex;
|
| 52 |
+
align-items: center;
|
| 53 |
+
gap: 12px;
|
| 54 |
+
font-weight: 600;
|
| 55 |
+
font-size: 16px;
|
| 56 |
+
letter-spacing: -0.02em;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.sidebar-content {
|
| 60 |
+
flex-grow: 1;
|
| 61 |
+
padding: 24px;
|
| 62 |
+
display: flex;
|
| 63 |
+
flex-direction: column;
|
| 64 |
+
gap: 20px;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.input-group {
|
| 68 |
+
display: flex;
|
| 69 |
+
flex-direction: column;
|
| 70 |
+
gap: 8px;
|
| 71 |
+
flex-grow: 1;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.input-group label {
|
| 75 |
+
font-size: 13px;
|
| 76 |
+
font-weight: 500;
|
| 77 |
+
color: var(--text-secondary);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
textarea {
|
| 81 |
+
flex-grow: 1;
|
| 82 |
+
width: 100%;
|
| 83 |
+
resize: none;
|
| 84 |
+
border: 1px solid var(--border-color);
|
| 85 |
+
border-radius: 8px;
|
| 86 |
+
padding: 16px;
|
| 87 |
+
font-family: inherit;
|
| 88 |
+
font-size: 14px;
|
| 89 |
+
line-height: 1.6;
|
| 90 |
+
color: var(--text-primary);
|
| 91 |
+
background-color: #fff;
|
| 92 |
+
transition: all 0.2s ease;
|
| 93 |
+
box-shadow: 0 1px 2px rgba(0,0,0,0.02);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
textarea:focus {
|
| 97 |
+
outline: none;
|
| 98 |
+
border-color: #999;
|
| 99 |
+
box-shadow: 0 0 0 4px var(--focus-ring);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
textarea::placeholder {
|
| 103 |
+
color: #a1a1aa;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/* Minimalist Black Button */
|
| 107 |
+
.btn-primary {
|
| 108 |
+
background-color: #000;
|
| 109 |
+
color: #fff;
|
| 110 |
+
border: none;
|
| 111 |
+
border-radius: 6px;
|
| 112 |
+
padding: 12px 16px;
|
| 113 |
+
font-size: 14px;
|
| 114 |
+
font-weight: 500;
|
| 115 |
+
cursor: pointer;
|
| 116 |
+
transition: all 0.2s ease;
|
| 117 |
+
display: flex;
|
| 118 |
+
align-items: center;
|
| 119 |
+
justify-content: center;
|
| 120 |
+
gap: 8px;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.btn-primary:hover {
|
| 124 |
+
background-color: #333;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.btn-primary:active {
|
| 128 |
+
transform: scale(0.98);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.btn-primary:disabled {
|
| 132 |
+
background-color: #e5e5e5;
|
| 133 |
+
color: #a3a3a3;
|
| 134 |
+
cursor: not-allowed;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* Loading State */
|
| 138 |
+
#loading {
|
| 139 |
+
display: flex;
|
| 140 |
+
align-items: center;
|
| 141 |
+
justify-content: center;
|
| 142 |
+
gap: 12px;
|
| 143 |
+
font-size: 13px;
|
| 144 |
+
color: var(--text-secondary);
|
| 145 |
+
padding: 12px;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.spinner {
|
| 149 |
+
width: 16px;
|
| 150 |
+
height: 16px;
|
| 151 |
+
border: 2px solid var(--border-color);
|
| 152 |
+
border-top: 2px solid #000;
|
| 153 |
+
border-radius: 50%;
|
| 154 |
+
animation: spin 0.8s linear infinite;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
@keyframes spin {
|
| 158 |
+
0% { transform: rotate(0deg); }
|
| 159 |
+
100% { transform: rotate(360deg); }
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.hidden {
|
| 163 |
+
display: none !important;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.sidebar-footer {
|
| 167 |
+
padding: 16px 24px;
|
| 168 |
+
border-top: 1px solid var(--border-color);
|
| 169 |
+
font-size: 12px;
|
| 170 |
+
color: var(--text-tertiary);
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/* Canvas Area */
|
| 174 |
+
.canvas-area {
|
| 175 |
+
flex-grow: 1;
|
| 176 |
+
position: relative;
|
| 177 |
+
background-color: var(--bg-canvas);
|
| 178 |
+
/* Subtle dot pattern for the canvas */
|
| 179 |
+
background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
|
| 180 |
+
background-size: 20px 20px;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
#markmap {
|
| 184 |
+
width: 100%;
|
| 185 |
+
height: 100%;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.disclaimer {
|
| 189 |
+
position: absolute;
|
| 190 |
+
bottom: 16px;
|
| 191 |
+
left: 50%;
|
| 192 |
+
transform: translateX(-50%);
|
| 193 |
+
font-size: 11px;
|
| 194 |
+
color: var(--text-tertiary);
|
| 195 |
+
text-align: center;
|
| 196 |
+
pointer-events: none;
|
| 197 |
+
z-index: 100;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
/* Responsive Design for Mobile Devices */
|
| 201 |
+
@media (max-width: 768px) {
|
| 202 |
+
.app-layout {
|
| 203 |
+
flex-direction: column;
|
| 204 |
+
height: 100vh;
|
| 205 |
+
overflow-y: auto; /* Allow scrolling if content overflows */
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.sidebar {
|
| 209 |
+
width: 100%;
|
| 210 |
+
height: auto;
|
| 211 |
+
border-right: none;
|
| 212 |
+
border-bottom: 1px solid var(--border-color);
|
| 213 |
+
flex-shrink: 0;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.sidebar-header {
|
| 217 |
+
padding: 16px;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
.sidebar-content {
|
| 221 |
+
padding: 16px;
|
| 222 |
+
gap: 16px;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
textarea {
|
| 226 |
+
height: 120px; /* Reduce textarea height on mobile */
|
| 227 |
+
flex-grow: 0;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.canvas-area {
|
| 231 |
+
min-height: 50vh; /* Ensure canvas has enough space */
|
| 232 |
+
flex-grow: 1;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
.sidebar-footer {
|
| 236 |
+
padding: 12px 16px;
|
| 237 |
+
}
|
| 238 |
+
}
|