File size: 5,052 Bytes
6a662eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CodeCanvas - Monaco Magic Editor</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.47.0/min/vs/loader.min.js"></script>
</head>
<body class="bg-gray-100 min-h-screen">
    <custom-navbar></custom-navbar>
    
    <div class="container mx-auto px-4 py-8">
        <div class="flex flex-col lg:flex-row gap-6">
            <!-- Editor Panel -->
            <div class="flex-1">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                    <div class="flex justify-between items-center bg-gray-800 text-white px-4 py-3">
                        <div class="flex items-center space-x-2">
                            <i data-feather="code" class="w-5 h-5"></i>
                            <h2 class="font-semibold">Code Editor</h2>
                        </div>
                        <div class="flex space-x-3">
                            <button class="hover:text-blue-400 transition-colors">
                                <i data-feather="copy" class="w-5 h-5"></i>
                            </button>
                            <button class="hover:text-blue-400 transition-colors">
                                <i data-feather="download" class="w-5 h-5"></i>
                            </button>
                            <button class="hover:text-blue-400 transition-colors">
                                <i data-feather="settings" class="w-5 h-5"></i>
                            </button>
                        </div>
                    </div>
                    <div id="editor-container" class="h-96"></div>
                </div>
            </div>
            
            <!-- Output Panel -->
            <div class="flex-1">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                    <div class="flex justify-between items-center bg-gray-800 text-white px-4 py-3">
                        <div class="flex items-center space-x-2">
                            <i data-feather="monitor" class="w-5 h-5"></i>
                            <h2 class="font-semibold">Output</h2>
                        </div>
                        <div class="flex space-x-3">
                            <button class="hover:text-blue-400 transition-colors">
                                <i data-feather="refresh-cw" class="w-5 h-5"></i>
                            </button>
                            <button class="hover:text-blue-400 transition-colors">
                                <i data-feather="maximize" class="w-5 h-5"></i>
                            </button>
                        </div>
                    </div>
                    <div id="output-container" class="h-96 p-4 bg-gray-50 overflow-auto">
                        <div class="text-gray-500 text-center py-20">Your output will appear here...</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <custom-footer></custom-footer>

    <script src="components/navbar.js"></script>
    <script src="components/footer.js"></script>
    <script src="script.js"></script>
    <script>
        feather.replace();
        
        // Initialize Monaco Editor
        require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.47.0/min/vs' }});
        require(['vs/editor/editor.main'], function() {
            const editor = monaco.editor.create(document.getElementById('editor-container'), {
                value: '// Welcome to CodeCanvas!\n// Start coding here...\n\nfunction helloWorld() {\n  console.log("Hello, world!");\n}\n\nhelloWorld();',
                language: 'javascript',
                theme: 'vs-dark',
                automaticLayout: true,
                minimap: { enabled: true }
            });

            // Run code button functionality
            document.querySelector('#run-code-btn').addEventListener('click', function() {
                const code = editor.getValue();
                try {
                    // This is just a demo - in production you'd want to use a safer eval alternative
                    const output = new Function(code)();
                    document.getElementById('output-container').innerHTML = `<pre class="text-gray-800">${output || "Code executed successfully (no output)"}</pre>`;
                } catch (error) {
                    document.getElementById('output-container').innerHTML = `<pre class="text-red-600">Error: ${error.message}</pre>`;
                }
            });
        });
    </script>
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
</body>
</html>