-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.html
More file actions
105 lines (86 loc) · 2.71 KB
/
Copy pathdemo.html
File metadata and controls
105 lines (86 loc) · 2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RunCode Demo</title>
</head>
<body>
<div class="demo-1"></div>
<div class="demo-2"></div>
<h2>3. Extract</h2>
<pre id="layout"><code>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page</title>
</head>
<body>
<!-- app -->
<script>console.log("done")</script>
</body>
</html>
</code></pre>
<pre id="header"><code><header>Site Header</header></code></pre>
<pre id="content"><code><main>Main Content</main></code></pre>
<pre id="footer"><code><footer>Site Footer</footer></code></pre>
<div class="demo-3"></div>
<h2>4. Extract - Multiple Matches</h2>
<pre class="language-markup"><code><h1>Collected from first match</h1></code></pre>
<pre class="language-markup"><code><p>Collected from second match</p></code></pre>
<pre class="language-markup"><code><footer>Collected from third match</footer></code></pre>
<div class="demo-4"></div>
<script type="module">
import RunCode from "./src/index.ts";
new RunCode({
element: ".demo-1",
defaultTab: { editor: null, preview: true },
clickToLoad: true,
code: {
html: '<h3>Normal execution (clickToLoad: false)</h3>\n<p>This runs immediately.</p>',
css: 'h3 { color: #38bdf8; }\np { color: #94a3b8; }',
js: 'console.log("Normal execution OK");'
}
});
new RunCode({
element: ".demo-2",
clickToLoad: true,
defaultTab: { editor: "css", preview: true },
theme: 'light',
code: {
html: '<h3>clickToLoad: true - static preview (no JS, no animations until click)</h3>\n<p>This has JS + CSS animation.</p>',
css: `h3 {
animation: pulse 2s ease-in-out infinite alternate;
}
@keyframes pulse {
from { opacity: 0; transform: scale(0.8); }
to { opacity: 1; transform: scale(1); }
}`,
js: 'console.log("Now fully interactive!");'
}
});
new RunCode({
element: ".demo-3",
defaultTab: { editor: null, preview: true },
theme: 'dark',
extract: {
source: {
html: [
{ selector: "#layout" },
{ selector: ["#header", "#content", "#footer"], target: "<!-- app -->", position: "replace" },
{ selector: "#scripts", target: "</body>", position: "before" }
]
}
}
});
new RunCode({
element: ".demo-4",
extract: {
source: {
html: [{ selector: "pre.language-markup code" }]
}
}
});
</script>
</body>
</html>