-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathmarkdown-editor.html
More file actions
229 lines (212 loc) · 7.21 KB
/
markdown-editor.html
File metadata and controls
229 lines (212 loc) · 7.21 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/logo.png">
<link rel="apple-touch-icon" href="images/logo.png">
<title>Markdown Editor - DevDunia</title>
<meta name="description" content="Write and preview Markdown with live rendering, syntax highlighting, and export options. Perfect for documentation, README files, and content creation.">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="icon" type="image/png" href="images/logo.png">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
<style>
body {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
min-height: 100vh;
}
.markdown-preview {
height: 100vh;
overflow-y: auto;
}
.markdown-editor-container {
height: 100vh;
}
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
color: #f1f5f9;
margin-top: 1.5rem;
margin-bottom: 0.5rem;
}
.markdown-preview h1 {
font-size: 2rem;
border-bottom: 2px solid #3b82f6;
padding-bottom: 0.5rem;
}
.markdown-preview h2 {
font-size: 1.5rem;
border-bottom: 1px solid #64748b;
padding-bottom: 0.25rem;
}
.markdown-preview h3 {
font-size: 1.25rem;
}
.markdown-preview p {
margin-bottom: 1rem;
line-height: 1.6;
}
.markdown-preview code {
background-color: #1e293b;
padding: 0.125rem 0.25rem;
border-radius: 0.25rem;
font-family: 'Courier New', monospace;
}
.markdown-preview pre {
background-color: #1e293b;
padding: 1rem;
border-radius: 0.5rem;
overflow-x: auto;
margin: 1rem 0;
}
.markdown-preview blockquote {
border-left: 4px solid #3b82f6;
padding-left: 1rem;
margin: 1rem 0;
color: #94a3b8;
font-style: italic;
}
.markdown-preview table {
border-collapse: collapse;
width: 100%;
margin: 1rem 0;
}
.markdown-preview th, .markdown-preview td {
border: 1px solid #475569;
padding: 0.5rem;
text-align: left;
}
.markdown-preview th {
background-color: #334155;
font-weight: bold;
}
.markdown-preview ul, .markdown-preview ol {
margin: 1rem 0;
padding-left: 2rem;
}
.markdown-preview li {
margin-bottom: 0.25rem;
}
.markdown-preview a {
color: #60a5fa;
text-decoration: underline;
}
.markdown-preview a:hover {
color: #93c5fd;
}
.markdown-preview img {
max-width: 100%;
height: auto;
border-radius: 0.5rem;
margin: 1rem 0;
}
.markdown-preview hr {
border: none;
border-top: 2px solid #475569;
margin: 2rem 0;
}
</style>
</head>
<body>
<!-- Sidebar -->
<div id="sidebar-container"></div>
<!-- Main Content -->
<div class="main-content ml-0 lg:ml-64 h-screen">
<!-- Editor and Preview -->
<div class="grid grid-cols-1 lg:grid-cols-2 h-full">
<!-- Editor -->
<div class="bg-slate-800/50 backdrop-blur-lg border-r border-slate-700/50 flex flex-col">
<div class="p-4 border-b border-slate-700/50 flex-shrink-0">
<h3 class="text-lg font-semibold text-gray-300">Markdown Editor</h3>
</div>
<div class="p-4 flex-1">
<textarea
id="markdown-editor"
class="markdown-editor-container w-full px-4 py-3 bg-slate-700/50 border border-slate-600 rounded-lg text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none font-mono text-sm"
placeholder="Start writing your Markdown here...
# Welcome to Markdown Editor
This is a **live preview** editor. Try these features:
## Features
- **Bold text**
- *Italic text*
- `Inline code`
- [Links](https://example.com)
- 
### Code Blocks
```javascript
function hello() {
console.log('Hello, World!');
}
```
### Lists
1. First item
2. Second item
3. Third item
### Tables
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Data 1 | Data 2 | Data 3 |
> This is a blockquote
---
"
></textarea>
</div>
</div>
<!-- Preview -->
<div class="bg-slate-800/50 backdrop-blur-lg flex flex-col">
<div class="p-4 border-b border-slate-700/50 flex-shrink-0">
<h3 class="text-lg font-semibold text-gray-300">Live Preview</h3>
</div>
<div class="p-4 flex-1 overflow-hidden">
<div id="markdown-preview" class="markdown-preview text-gray-200">
<p class="text-gray-400 italic">Start typing in the editor to see the live preview...</p>
</div>
</div>
</div>
</div>
</div>
<!-- Sidebar Include Script -->
<script src="sidebar-include.js"></script>
<script>
// Configure marked
marked.setOptions({
highlight: function(code, lang) {
if (lang && hljs.getLanguage(lang)) {
return hljs.highlight(code, { language: lang }).value;
}
return hljs.highlightAuto(code).value;
},
breaks: true,
gfm: true
});
// DOM elements
const editor = document.getElementById('markdown-editor');
const preview = document.getElementById('markdown-preview');
// Update preview
function updatePreview() {
const markdown = editor.value;
const html = marked.parse(markdown);
preview.innerHTML = html;
}
// Live preview
editor.addEventListener('input', updatePreview);
// Initialize
window.addEventListener('load', () => {
updatePreview();
});
</script>
<!-- Include Final Sidebar -->
<div id="sidebar-container"></div>
<script>
// Load final_sidebar.html content
fetch('final_sidebar.html')
.then(response => response.text())
.then(html => {
document.getElementById('sidebar-container').innerHTML = html;
})
.catch(error => {
console.error('Error loading sidebar:', error);
});
</script>
</body>
</html>