feat: enhance Mermaid toolbar with improved hint display and interactive controls for zoom and fullscreen functionality

This commit is contained in:
Ümit Tunç
2026-05-25 07:59:49 +03:00
parent ba98e17d2d
commit 910e912b05
+30 -35
View File
@@ -196,6 +196,7 @@
backdrop-filter: blur(8px);
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
border-radius: 16px 16px 0 0;
position: relative;
}
.dark .mermaid-toolbar {
background: rgba(15, 23, 42, 0.9);
@@ -207,8 +208,32 @@
letter-spacing: 0.08em;
text-transform: uppercase;
color: #94a3b8;
margin-right: 4px;
flex: 1;
flex-shrink: 0;
}
.mermaid-toolbar-hint {
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 0.72rem;
font-weight: 600;
color: #64748b;
white-space: nowrap;
pointer-events: none;
transition: opacity 0.2s ease;
}
.dark .mermaid-toolbar-hint {
color: #94a3b8;
}
.mermaid-container.mermaid-active .mermaid-toolbar-hint {
opacity: 0;
visibility: hidden;
}
.mermaid-toolbar-controls {
display: flex;
align-items: center;
gap: 4px;
margin-left: auto;
flex-shrink: 0;
}
.mermaid-zoom-btn {
display: inline-flex;
@@ -273,34 +298,6 @@
.mermaid-container.mermaid-active {
box-shadow: 0 0 0 2px var(--accent-color, #4f46e5);
}
.mermaid-canvas-hint {
position: absolute;
inset: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
transition: opacity 0.2s ease;
}
.mermaid-canvas-hint span {
font-size: 0.75rem;
font-weight: 600;
color: #64748b;
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(0, 0, 0, 0.08);
padding: 6px 14px;
border-radius: 999px;
}
.dark .mermaid-canvas-hint span {
color: #94a3b8;
background: rgba(30, 41, 59, 0.9);
border-color: rgba(255, 255, 255, 0.08);
}
.mermaid-container.mermaid-active .mermaid-canvas-hint {
opacity: 0;
visibility: hidden;
}
/* Fullscreen overlay */
.mermaid-fullscreen-overlay {
@@ -1049,6 +1046,8 @@
toolbar.className = 'mermaid-toolbar';
toolbar.innerHTML = `
<span class="mermaid-toolbar-label">Diyagram Görünümü</span>
<span class="mermaid-toolbar-hint">Zoom ve kaydırma için tıklayın</span>
<div class="mermaid-toolbar-controls">
<button class="mermaid-zoom-btn" title="Yakınlaştır (Zoom In)" onclick="mermaidZoomIn(${index})">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
</button>
@@ -1062,6 +1061,7 @@
<button class="mermaid-zoom-btn" title="Tam Ekran" onclick="mermaidFullscreen(${index})">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>
</button>
</div>
`;
// Canvas wrapper
@@ -1069,17 +1069,12 @@
canvas.className = 'mermaid-canvas';
canvas.id = 'mermaid-canvas-' + index;
const hint = document.createElement('div');
hint.className = 'mermaid-canvas-hint';
hint.innerHTML = '<span>Zoom ve kaydırma için tıklayın</span>';
const graphDiv = document.createElement('div');
graphDiv.className = 'mermaid w-full';
graphDiv.id = 'mermaid-graph-' + index;
graphDiv.textContent = rawMermaid;
canvas.appendChild(graphDiv);
canvas.appendChild(hint);
wrapper.appendChild(toolbar);
wrapper.appendChild(canvas);
preContainer.parentNode.replaceChild(wrapper, preContainer);