forked from lukejacksonn/monacode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (52 loc) · 1.53 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
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Monacode</title>
<script type="module">
const search = new URLSearchParams(document.location.search.substring(1))
const overrides = Object.fromEntries(search);
const defaults = {
container: document.body,
value: `
const values = { a: "1324568675432456", b: 8796574356789976543678, c: [2345678754435678754635], d: true }
const add = (x: number, y: number) => x + y;
let x = 1;
let y = 2;
const result = add(x, y)
`.trim(),
}
import(window.location.hostname === "localhost"
? "./index.js"
: "./index.min.js"
).then(module => {
// Create a new editor and attatch to the document body
const editor = module.default({ ...defaults, ...overrides });
// Listen for changes within the editor
editor.getModel().onDidChangeContent(change => {
const newValue = editor.getValue();
console.log(newValue);
});
})
</script>
<style>
body {
background: #1e1e1e;
}
body {
margin: 0;
position: absolute;
top: 5vmin;
right: 5vmin;
bottom: 5vmin;
left: 5vmin;
display: grid;
grid-gap: 5vmin;
grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
grid-template-rows: repeat(auto-fit, minmax(20%, 1fr));
}
</style>
</head>
<body></body>
</html>