-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
58 lines (53 loc) · 1.98 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Development Playground</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/theme/dracula.min.css">
<style>
body {
margin: 0;
display: flex;
height: 100vh;
overflow: hidden;
}
#editor {
flex: 1;
height: 100%;
}
#output {
flex: 1;
height: 100%;
overflow: auto;
padding: 10px;
background-color: #f8f8f8;
box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<div id="editor"></div>
<iframe id="output" sandbox="allow-scripts allow-same-origin"></iframe>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/htmlmixed/htmlmixed.min.js"></script>
<script>
const editor = CodeMirror(document.getElementById('editor'), {
value: '<!DOCTYPE html>\n<html lang="en">\n<head>\n\t<meta charset="UTF-8">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\t<title>HTML Playground</title>\n</head>\n<body>\n\t<h1>Hello, HTML Playground!</h1>\n</body>\n</html>',
mode: 'htmlmixed',
theme: 'dracula',
lineNumbers: true,
lineWrapping: true,
autofocus: true,
});
const outputFrame = document.getElementById('output');
const updateOutput = () => {
const code = editor.getValue();
outputFrame.srcdoc = code;
};
editor.on('changes', updateOutput);
updateOutput();
</script>
</body>
</html>