ArunKr commited on
Commit
d0bd0a2
·
verified ·
1 Parent(s): 8dd3dd4

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +17 -7
index.html CHANGED
@@ -35,6 +35,7 @@
35
  <!-- Top Controls -->
36
  <div id="toolbar" class="flex items-center bg-gray-100 p-2 border-b transition-transform duration-300">
37
  <button id="toggleSidebarBtn" class="p-1 mr-2 hover:bg-gray-200 rounded"><svg class="w-5 h-5 text-gray-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path d="M4 6h16M4 12h16M4 18h16"/></svg></button>
 
38
  <input id="pageTitle" class="flex-1 px-2 py-1 border rounded focus:outline-none mr-2" placeholder="Page Title..." />
39
  <button id="saveBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded">Save</button>
40
  </div>
@@ -42,7 +43,7 @@
42
  <!-- Editor & Preview Panes -->
43
  <div class="flex flex-1 overflow-hidden">
44
  <!-- Editor Pane -->
45
- <div class="relative w-1/2">
46
  <div id="editorToolbar" class="absolute top-2 left-2 flex space-x-1 z-10">
47
  <button data-action="bold" class="px-2 py-1 bg-gray-200 hover:bg-gray-300 rounded">B</button>
48
  <button data-action="italic" class="px-2 py-1 bg-gray-200 hover:bg-gray-300 rounded">I</button>
@@ -53,7 +54,7 @@
53
  </div>
54
 
55
  <!-- Preview Pane -->
56
- <div id="preview" class="w-1/2 p-6 overflow-auto scrollbar-thin prose prose-indigo max-w-none"></div>
57
  </div>
58
  </main>
59
 
@@ -72,9 +73,11 @@
72
  const saveBtn = document.getElementById('saveBtn');
73
  const pageTitleInput = document.getElementById('pageTitle');
74
  const editor = document.getElementById('editor');
75
- const preview = document.getElementById('preview');
76
  const toggleSidebarBtn = document.getElementById('toggleSidebarBtn');
 
77
  const editorToolbar = document.getElementById('editorToolbar');
 
78
 
79
  // Render file tree
80
  function renderTree() {
@@ -101,8 +104,8 @@
101
  // Update preview with syntax highlighting
102
  function updatePreview() {
103
  const html = marked.parse(editor.value || '');
104
- preview.innerHTML = html;
105
- preview.querySelectorAll('pre code').forEach(block => hljs.highlightBlock(block));
106
  }
107
 
108
  // Save current page
@@ -127,7 +130,7 @@
127
  localStorage.setItem('docPages', JSON.stringify(pages));
128
  const ids = Object.keys(pages);
129
  if (ids.length) loadPage(ids[0]);
130
- else { currentId = null; editor.value = ''; pageTitleInput.value = ''; preview.innerHTML = ''; renderTree(); }
131
  };
132
 
133
  saveBtn.onclick = () => { savePage(); alert('Saved!'); };
@@ -141,6 +144,13 @@
141
  toolbarDiv.classList.toggle('pl-0');
142
  };
143
 
 
 
 
 
 
 
 
144
  // Editor formatting toolbar
145
  editorToolbar.onclick = e => {
146
  if (!e.target.dataset.action) return;
@@ -167,4 +177,4 @@
167
  if (!currentId && Object.keys(pages).length) loadPage(Object.keys(pages)[0]);
168
  </script>
169
  </body>
170
- </html>
 
35
  <!-- Top Controls -->
36
  <div id="toolbar" class="flex items-center bg-gray-100 p-2 border-b transition-transform duration-300">
37
  <button id="toggleSidebarBtn" class="p-1 mr-2 hover:bg-gray-200 rounded"><svg class="w-5 h-5 text-gray-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path d="M4 6h16M4 12h16M4 18h16"/></svg></button>
38
+ <button id="toggleEditorBtn" class="p-1 mr-2 hover:bg-gray-200 rounded"><svg class="w-5 h-5 text-gray-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path d="M8 4h8v16H8z"/></svg></button>
39
  <input id="pageTitle" class="flex-1 px-2 py-1 border rounded focus:outline-none mr-2" placeholder="Page Title..." />
40
  <button id="saveBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded">Save</button>
41
  </div>
 
43
  <!-- Editor & Preview Panes -->
44
  <div class="flex flex-1 overflow-hidden">
45
  <!-- Editor Pane -->
46
+ <div id="editorPane" class="relative w-1/2 transition-all duration-300">
47
  <div id="editorToolbar" class="absolute top-2 left-2 flex space-x-1 z-10">
48
  <button data-action="bold" class="px-2 py-1 bg-gray-200 hover:bg-gray-300 rounded">B</button>
49
  <button data-action="italic" class="px-2 py-1 bg-gray-200 hover:bg-gray-300 rounded">I</button>
 
54
  </div>
55
 
56
  <!-- Preview Pane -->
57
+ <div id="previewPane" class="w-1/2 p-6 overflow-auto scrollbar-thin prose prose-indigo max-w-none transition-all duration-300"></div>
58
  </div>
59
  </main>
60
 
 
73
  const saveBtn = document.getElementById('saveBtn');
74
  const pageTitleInput = document.getElementById('pageTitle');
75
  const editor = document.getElementById('editor');
76
+ const previewPane = document.getElementById('previewPane');
77
  const toggleSidebarBtn = document.getElementById('toggleSidebarBtn');
78
+ const toggleEditorBtn = document.getElementById('toggleEditorBtn');
79
  const editorToolbar = document.getElementById('editorToolbar');
80
+ const editorPane = document.getElementById('editorPane');
81
 
82
  // Render file tree
83
  function renderTree() {
 
104
  // Update preview with syntax highlighting
105
  function updatePreview() {
106
  const html = marked.parse(editor.value || '');
107
+ previewPane.innerHTML = html;
108
+ previewPane.querySelectorAll('pre code').forEach(block => hljs.highlightBlock(block));
109
  }
110
 
111
  // Save current page
 
130
  localStorage.setItem('docPages', JSON.stringify(pages));
131
  const ids = Object.keys(pages);
132
  if (ids.length) loadPage(ids[0]);
133
+ else { currentId = null; editor.value = ''; pageTitleInput.value = ''; previewPane.innerHTML = ''; renderTree(); }
134
  };
135
 
136
  saveBtn.onclick = () => { savePage(); alert('Saved!'); };
 
144
  toolbarDiv.classList.toggle('pl-0');
145
  };
146
 
147
+ // Toggle editor visibility
148
+ toggleEditorBtn.onclick = () => {
149
+ const hidden = editorPane.classList.toggle('hidden');
150
+ if (hidden) previewPane.classList.replace('w-1/2', 'w-full');
151
+ else previewPane.classList.replace('w-full', 'w-1/2');
152
+ };
153
+
154
  // Editor formatting toolbar
155
  editorToolbar.onclick = e => {
156
  if (!e.target.dataset.action) return;
 
177
  if (!currentId && Object.keys(pages).length) loadPage(Object.keys(pages)[0]);
178
  </script>
179
  </body>
180
+ </html>