-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
203 lines (180 loc) · 5.71 KB
/
index.html
File metadata and controls
203 lines (180 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Debugger - CodeMirror</title>
<link href="codemirror/lib/codemirror.css" rel="stylesheet"/>
<link href="codemirror/addon/fold/foldgutter.css" rel="stylesheet"/>
<link href="codemirror/addon/runjs/runjs.css" rel="stylesheet"/>
<link href="codemirror/addon/debugger/debugger.css" rel="stylesheet"/>
<link href="codemirror/theme/dracula.css" rel="stylesheet"/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #e8e8e8;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
background: #1e1e2e;
}
.container {
display: flex;
flex-direction: column;
height: 100vh;
background: #1e1e2e;
}
.header {
background: linear-gradient(90deg, #2d2d44 0%, #3d3d5c 100%);
padding: 16px 24px;
border-bottom: 2px solid #44475a;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
flex-shrink: 0;
}
.header h1 {
font-size: 20px;
font-weight: 600;
color: #bd93f9;
letter-spacing: 0.5px;
}
.main-content {
display: flex;
flex: 1;
overflow: hidden;
gap: 1px;
background: #44475a;
}
/* ========== LEFT COLUMN - EDITOR ========== */
.editor-section {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
background: #282a36;
}
#editor {
display: none;
}
.CodeMirror {
font-family: 'Fira Code', 'Courier New', monospace !important;
font-size: 14px !important;
background: #282a36 !important;
color: #f8f8f2 !important;
flex: 1 !important;
height: auto !important;
}
.CodeMirror-scroll {
overflow-y: scroll !important;
}
/* ========== RIGHT COLUMN ========== */
.debug-section {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
background: #1e1e2e;
border-left: 1px solid #44475a;
}
/* ========== DEBUGGER PANEL TOP ========== */
.debugger-wrapper {
flex: 1;
overflow: hidden;
background: #282a36;
display: flex;
flex-direction: column;
}
.cm-breakpoint {
color: #ff5555;
text-align: center;
width: 16px;
cursor: pointer;
font-size: 14px;
line-height: 1;
}
/* ========== SCROLLBAR STYLING ========== */
.CodeMirror-scroll::-webkit-scrollbar,
.output-content::-webkit-scrollbar {
width: 8px;
}
.CodeMirror-scroll::-webkit-scrollbar-track,
.output-content::-webkit-scrollbar-track {
background: #21222c;
}
.CodeMirror-scroll::-webkit-scrollbar-thumb,
.output-content::-webkit-scrollbar-thumb {
background: #44475a;
border-radius: 4px;
}
.CodeMirror-scroll::-webkit-scrollbar-thumb:hover,
.output-content::-webkit-scrollbar-thumb:hover {
background: #6272a4;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🐛 JavaScript Debugger with CodeMirror</h1>
</div>
<div class="main-content">
<!-- LEFT: Editor -->
<div class="editor-section">
<textarea id="editor"></textarea>
</div>
<!-- RIGHT: Debugger Only -->
<div class="debug-section">
<div class="debugger-wrapper" id="debugger-wrapper"></div>
</div>
</div>
</div>
<script type="module">
// import ES-module core and expose global for UMD addons
import CodeMirror from './codemirror/src/codemirror.js';
window.CodeMirror = CodeMirror;
// helper to load UMD addon scripts after window.CodeMirror exists
function loadScript(src){
return new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
(async () => {
// load fold addon (UMD) after exposing window.CodeMirror
await loadScript('codemirror/addon/fold/foldcode.js');
await loadScript('codemirror/addon/fold/foldgutter.js');
await loadScript('codemirror/addon/debugger/debugger.js');
// create editor after addons are loaded
var editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
lineNumbers: true,
lineWrapping: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
foldGutter: true,
mode: "javascript",
theme: "dracula",
debug: true,
indentUnit: 2,
tabSize: 2,
indentWithTabs: false
});
// Move debugger panel to the right wrapper
const debuggerWrapper = document.getElementById('debugger-wrapper');
setTimeout(() => {
const debugPanel = document.querySelector('.cm-debug-panel');
if (debugPanel) {
debuggerWrapper.appendChild(debugPanel);
}
}, 100);
// Debugger addon handles all breakpoint and debugging functionality
})();
</script>
</body>
</html>