Skip to content

Commit 06f96f9

Browse files
feat: split diagram preview into left code pane and right visual container
1 parent 850cd94 commit 06f96f9

3 files changed

Lines changed: 55 additions & 5 deletions

File tree

index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,15 @@ <h3 class="modal-section-title">Open-source credits</h3>
872872
<!-- Preview Container -->
873873
<div class="diagram-modal-preview-section">
874874
<p class="diagram-modal-preview-title">Preview</p>
875-
<div id="diagram-modal-preview" class="diagram-preview-container">
876-
<!-- Populated dynamically with selected template preview -->
875+
<div class="diagram-modal-preview-split">
876+
<!-- Left: Code -->
877+
<div class="diagram-preview-code-pane">
878+
<textarea id="diagram-modal-preview-code" readonly class="rename-modal-input diagram-preview-textarea" placeholder="Diagram source code..."></textarea>
879+
</div>
880+
<!-- Right: Visual Preview -->
881+
<div id="diagram-modal-preview" class="diagram-preview-container">
882+
<!-- Populated dynamically with selected template preview -->
883+
</div>
877884
</div>
878885
</div>
879886
</div>

script.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5559,11 +5559,12 @@ document.addEventListener("DOMContentLoaded", async function () {
55595559
const emptyMessage = document.getElementById('diagram-modal-empty');
55605560
const searchInput = document.getElementById('diagram-modal-search');
55615561
const previewContainer = document.getElementById('diagram-modal-preview');
5562+
const previewCode = document.getElementById('diagram-modal-preview-code');
55625563
const confirmBtn = document.getElementById('diagram-modal-insert');
55635564
const cancelBtn = document.getElementById('diagram-modal-cancel');
55645565
const closeBtn = document.getElementById('diagram-modal-close');
55655566

5566-
if (!modal || !sidebar || !grid || !emptyMessage || !searchInput || !previewContainer || !confirmBtn || !cancelBtn || !closeBtn) return;
5567+
if (!modal || !sidebar || !grid || !emptyMessage || !searchInput || !previewContainer || !previewCode || !confirmBtn || !cancelBtn || !closeBtn) return;
55675568

55685569
const start = markdownEditor.selectionStart;
55695570
const end = markdownEditor.selectionEnd;
@@ -5574,6 +5575,7 @@ document.addEventListener("DOMContentLoaded", async function () {
55745575
sidebar.textContent = '';
55755576
grid.textContent = '';
55765577
previewContainer.textContent = '';
5578+
if (previewCode) previewCode.value = '';
55775579
confirmBtn.disabled = true;
55785580

55795581
const categories = [
@@ -5833,6 +5835,7 @@ document.addEventListener("DOMContentLoaded", async function () {
58335835
card.classList.add('is-selected');
58345836

58355837
previewContainer.innerHTML = t.svg;
5838+
if (previewCode) previewCode.value = t.code.trim();
58365839
confirmBtn.disabled = false;
58375840
});
58385841

styles.css

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4580,16 +4580,48 @@ html[data-theme="dark"] .diagram-card-preview {
45804580
color: var(--text-color);
45814581
}
45824582

4583+
.diagram-modal-preview-split {
4584+
display: flex;
4585+
gap: 16px;
4586+
height: 200px;
4587+
}
4588+
4589+
.diagram-preview-code-pane {
4590+
flex: 1;
4591+
display: flex;
4592+
min-width: 0;
4593+
}
4594+
4595+
.diagram-preview-textarea {
4596+
width: 100%;
4597+
height: 100%;
4598+
resize: none;
4599+
font-family: var(--font-mono, monospace);
4600+
font-size: 0.85rem;
4601+
padding: 12px;
4602+
border: 1px solid var(--border-color);
4603+
border-radius: 8px;
4604+
background: var(--editor-bg, #ffffff);
4605+
color: var(--text-color);
4606+
outline: none;
4607+
}
4608+
4609+
html[data-theme="dark"] .diagram-preview-textarea {
4610+
background: #1e1e1e;
4611+
}
4612+
45834613
.diagram-preview-container {
4614+
flex: 1;
45844615
border: 1px solid var(--border-color);
45854616
border-radius: 8px;
45864617
background: #ffffff;
4587-
height: 200px;
4618+
height: 100%;
45884619
overflow: auto;
45894620
display: flex;
45904621
align-items: center;
45914622
justify-content: center;
45924623
padding: 16px;
4624+
min-width: 0;
45934625
}
45944626

45954627
html[data-theme="dark"] .diagram-preview-container {
@@ -4624,7 +4656,15 @@ html[data-theme="dark"] .diagram-preview-container {
46244656
.diagram-modal-box {
46254657
height: 95vh;
46264658
}
4659+
.diagram-modal-preview-split {
4660+
flex-direction: column;
4661+
height: auto;
4662+
gap: 12px;
4663+
}
4664+
.diagram-preview-code-pane {
4665+
height: 100px;
4666+
}
46274667
.diagram-preview-container {
4628-
height: 140px;
4668+
height: 120px;
46294669
}
46304670
}

0 commit comments

Comments
 (0)