Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const menuBtn = document.querySelector('.menu-btn');
+ const sidebar = document.querySelector('.sidebar');
+ const editor = document.querySelector('.editor-content');
+
+ // Toggle sidebar on mobile
+ menuBtn.addEventListener('click', () => {
+ sidebar.classList.toggle('active');
+ });
+
+ // Handle block creation with '/' command
+ editor.addEventListener('keydown', (e) => {
+ if (e.key === '/') {
+ e.preventDefault();
+ const selection = window.getSelection();
+ const range = selection.getRangeAt(0);
+ const commandMenu = document.createElement('div');
+ commandMenu.className = 'command-menu';
+ commandMenu.innerHTML = `
+ `;
+ range.insertNode(commandMenu);
+ }
+ });
+
+ // Auto-save functionality
+ let saveTimeout;
+ editor.addEventListener('input', () => {
+ clearTimeout(saveTimeout);
+ saveTimeout = setTimeout(() => {
+ console.log('Saving...'); // Replace with actual save functionality
+ }, 1000);
+ });
+
+ // Make page items clickable
+ const pageItems = document.querySelectorAll('.page-item');
+ pageItems.forEach(item => {
+ item.addEventListener('click', () => {
+ pageItems.forEach(p => p.classList.remove('active'));
+ item.classList.add('active');
+ });
+ });
+
+ // Handle new page creation
+ const newPageBtn = document.querySelector('.new-page-btn');
+ newPageBtn.addEventListener('click', () => {
+ const pageList = document.querySelector('.page-list');
+ const newPage = document.createElement('div');
+ newPage.className = 'page-item';
+ newPage.innerHTML = `
+ 📝
+ New Page
+ `;
+ pageList.appendChild(newPage);
+ });
+ });