Abmacode12's picture
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.47.0/min/vs/loader.min.js"></script>
6a662eb verified
<!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>