flow-tracer 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/public/index.html +34 -3
package/package.json
CHANGED
package/src/public/index.html
CHANGED
|
@@ -54,9 +54,15 @@
|
|
|
54
54
|
.message .content tr:hover { background: rgba(51, 65, 85, 0.5); }
|
|
55
55
|
|
|
56
56
|
/* Mermaid */
|
|
57
|
-
.mermaid-container { background: #ffffff; border-radius: 8px;
|
|
57
|
+
.mermaid-container { background: #ffffff; border-radius: 8px; margin: 12px 0; overflow-x: auto; position: relative; }
|
|
58
|
+
.mermaid-container .mermaid-toolbar { display: flex; gap: 6px; padding: 8px 12px; background: #f1f5f9; border-radius: 8px 8px 0 0; border-bottom: 1px solid #e2e8f0; }
|
|
59
|
+
.mermaid-container .mermaid-content { padding: 20px; }
|
|
58
60
|
.mermaid-container svg { max-width: 100%; height: auto; }
|
|
59
61
|
.mermaid-error { color: #ef4444; background: #1e293b; padding: 12px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
|
|
62
|
+
.copy-btn { padding: 4px 10px; border-radius: 6px; border: 1px solid #cbd5e1; background: #ffffff; color: #475569; font-size: 12px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 4px; transition: all 0.15s; }
|
|
63
|
+
.copy-btn:hover { background: #e2e8f0; color: #1e293b; }
|
|
64
|
+
.copy-btn.copied { background: #22c55e; color: white; border-color: #22c55e; }
|
|
65
|
+
.copy-btn svg { width: 14px; height: 14px; }
|
|
60
66
|
|
|
61
67
|
/* Input */
|
|
62
68
|
.input-bar { display: flex; gap: 8px; padding: 16px; border-top: 1px solid #334155; }
|
|
@@ -251,10 +257,17 @@
|
|
|
251
257
|
// Parse markdown with marked (handles tables, lists, code blocks, etc.)
|
|
252
258
|
const html = marked.parse(text);
|
|
253
259
|
|
|
254
|
-
// Replace mermaid placeholders with actual diagram containers
|
|
260
|
+
// Replace mermaid placeholders with actual diagram containers + toolbar
|
|
255
261
|
const finalHtml = html.replace(/<!--MERMAID:(\w+-\d+)-->/g, (_, id) => {
|
|
256
262
|
const code = mermaidPlaceholders[id] || '';
|
|
257
|
-
return `<div class="mermaid-container"
|
|
263
|
+
return `<div class="mermaid-container" data-mermaid-code="${escapeHtml(code)}">` +
|
|
264
|
+
`<div class="mermaid-toolbar">` +
|
|
265
|
+
`<button class="copy-btn" onclick="copyMermaidCode(this)" title="Copy Mermaid code">` +
|
|
266
|
+
`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>` +
|
|
267
|
+
`Copy Code</button>` +
|
|
268
|
+
`</div>` +
|
|
269
|
+
`<div class="mermaid-content"><div class="mermaid" id="${id}">${escapeHtml(code)}</div></div>` +
|
|
270
|
+
`</div>`;
|
|
258
271
|
});
|
|
259
272
|
|
|
260
273
|
return finalHtml;
|
|
@@ -281,6 +294,24 @@
|
|
|
281
294
|
}
|
|
282
295
|
}
|
|
283
296
|
}
|
|
297
|
+
|
|
298
|
+
// ── Copy Functions ──────────────────────────────────────
|
|
299
|
+
|
|
300
|
+
function flashCopied(btn) {
|
|
301
|
+
const original = btn.innerHTML;
|
|
302
|
+
btn.classList.add('copied');
|
|
303
|
+
btn.innerHTML = btn.innerHTML.replace(/Copy \w+/, 'Copied!');
|
|
304
|
+
setTimeout(() => { btn.classList.remove('copied'); btn.innerHTML = original; }, 1500);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function copyMermaidCode(btn) {
|
|
308
|
+
const container = btn.closest('.mermaid-container');
|
|
309
|
+
const code = container.getAttribute('data-mermaid-code');
|
|
310
|
+
navigator.clipboard.writeText(code)
|
|
311
|
+
.then(() => flashCopied(btn))
|
|
312
|
+
.catch(() => {});
|
|
313
|
+
}
|
|
314
|
+
|
|
284
315
|
</script>
|
|
285
316
|
</body>
|
|
286
317
|
</html>
|