summaryrefslogtreecommitdiff
path: root/.demo/example-editor.html
blob: f6505bc1cfca0a7a6075118e50e9e89be95e2ccb (plain) (blame)
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>Adelie Editor - Standalone Example</title>
    <link rel="stylesheet" href="dist/bundle.css" />
</head>
<body>
    <header>
        <h1>Adelie Editor Standalone Example</h1>
        <input type="checkbox" id="theme-toggle" class="toggle" aria-label="Toggle dark mode" />
    </header>

    <main style="max-width: 1000px; margin: 0 auto; padding: 2rem;">
        <article>
            <h2>Simple Usage</h2>
            <div id="my-editor"></div>
        </article>

        <article style="margin-top: 3rem;">
            <h2>With Options</h2>
            <div id="css-editor"></div>
        </article>
    </main>

    <!-- Load the standalone editor bundle -->
    <script src="dist/adelie-editor.js"></script>

    <script>
        // Simple initialization
        const editor1 = adelieEditor.init('#my-editor', {
            language: 'javascript',
            initialCode: `// Type your code here
function hello() {
  console.log("Hello from Adelie Editor!");
}`
        });

        // With custom options
        const editor2 = adelieEditor.init('#css-editor', {
            language: 'css',
            initialCode: `/* Adelie Editor with CSS */
.my-class {
  color: var(--primary);
  background: var(--surface);
}`
        });

        // Theme toggle
        const toggle = document.getElementById('theme-toggle');
        toggle.addEventListener('change', () => {
            const theme = toggle.checked ? 'dark' : 'light';
            document.documentElement.setAttribute('data-theme', theme);
        });
    </script>
</body>
</html>