-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.html
More file actions
443 lines (373 loc) · 17.3 KB
/
Copy patheditor.html
File metadata and controls
443 lines (373 loc) · 17.3 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Markdown Editor - 离线文本编辑器</title>
<meta name="description" content="功能强大的离线Markdown编辑器,支持实时预览和H5导出">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- CodeMirror 6 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/theme/material-darker.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/markdown/markdown.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/edit/continuelist.min.js"></script>
<!-- Marked.js -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<!-- Highlight.js -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<!-- Anime.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--primary-color: #1e293b;
--secondary-color: #3b82f6;
--bg-color: #fefefe;
--surface-color: #f1f5f9;
--text-color: #1e293b;
--text-muted: #64748b;
--border-color: #e2e8f0;
}
[data-theme="dark"] {
--bg-color: #0f172a;
--surface-color: #1e293b;
--text-color: #f8fafc;
--text-muted: #94a3b8;
--border-color: #334155;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
height: 100vh;
overflow: hidden;
transition: all 0.3s ease;
}
.editor-container {
display: grid;
grid-template-columns: 1fr 1fr;
height: calc(100vh - 140px);
gap: 1px;
background-color: var(--border-color);
}
.editor-panel, .preview-panel {
background-color: var(--bg-color);
overflow: auto;
position: relative;
}
.CodeMirror {
height: 100%;
font-family: 'Fira Code', 'Consolas', monospace;
font-size: 14px;
line-height: 1.6;
}
.preview-content {
padding: 2rem;
max-width: none;
line-height: 1.7;
}
.preview-content h1, .preview-content h2, .preview-content h3,
.preview-content h4, .preview-content h5, .preview-content h6 {
margin-top: 1.5rem;
margin-bottom: 0.75rem;
font-weight: 600;
line-height: 1.3;
}
.preview-content h1 { font-size: 2rem; }
.preview-content h2 { font-size: 1.5rem; }
.preview-content h3 { font-size: 1.25rem; }
.preview-content h4 { font-size: 1.125rem; }
.preview-content h5 { font-size: 1rem; }
.preview-content h6 { font-size: 0.875rem; }
.preview-content p {
margin-bottom: 1rem;
}
.preview-content ul, .preview-content ol {
margin-bottom: 1rem;
padding-left: 2rem;
}
.preview-content li {
margin-bottom: 0.25rem;
}
.preview-content blockquote {
border-left: 4px solid var(--secondary-color);
padding-left: 1rem;
margin: 1rem 0;
color: var(--text-muted);
font-style: italic;
}
.preview-content code {
background-color: var(--surface-color);
padding: 0.125rem 0.375rem;
border-radius: 0.25rem;
font-family: 'Fira Code', monospace;
font-size: 0.875em;
}
.preview-content pre {
background-color: var(--surface-color);
padding: 1rem;
border-radius: 0.5rem;
overflow-x: auto;
margin: 1rem 0;
}
.preview-content pre code {
background: none;
padding: 0;
}
.preview-content table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
}
.preview-content th, .preview-content td {
border: 1px solid var(--border-color);
padding: 0.5rem;
text-align: left;
}
.preview-content th {
background-color: var(--surface-color);
font-weight: 600;
}
.toolbar-btn {
padding: 0.5rem 0.75rem;
border: 1px solid var(--border-color);
background-color: var(--bg-color);
color: var(--text-color);
border-radius: 0.375rem;
cursor: pointer;
transition: all 0.2s ease;
font-size: 0.875rem;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.toolbar-btn:hover {
background-color: var(--surface-color);
border-color: var(--secondary-color);
}
.toolbar-btn:active {
transform: translateY(1px);
}
.status-bar {
background-color: var(--surface-color);
border-top: 1px solid var(--border-color);
padding: 0.5rem 1rem;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.75rem;
color: var(--text-muted);
}
.mobile-tabs {
display: none;
}
@media (max-width: 768px) {
.editor-container {
grid-template-columns: 1fr;
height: calc(100vh - 180px);
}
.mobile-tabs {
display: flex;
background-color: var(--surface-color);
border-bottom: 1px solid var(--border-color);
}
.mobile-tab {
flex: 1;
padding: 0.75rem;
text-align: center;
cursor: pointer;
border-bottom: 2px solid transparent;
transition: all 0.2s ease;
}
.mobile-tab.active {
border-bottom-color: var(--secondary-color);
color: var(--secondary-color);
}
.editor-panel, .preview-panel {
display: none;
}
.editor-panel.active, .preview-panel.active {
display: block;
}
}
.fade-in {
animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.highlight {
background-color: rgba(59, 130, 246, 0.1);
border-radius: 0.25rem;
}
</style>
</head>
<body>
<!-- 顶部工具栏 -->
<header class="bg-white dark:bg-slate-800 border-b border-gray-200 dark:border-slate-700 px-4 py-3">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
<h1 class="text-xl font-semibold text-gray-900 dark:text-white">Markdown Editor</h1>
<div class="text-sm text-gray-500 dark:text-gray-400" id="document-title">untitled.md</div>
</div>
<div class="flex items-center space-x-2">
<button class="toolbar-btn" id="new-btn" title="新建文档">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
<span class="hidden sm:inline">新建</span>
</button>
<button class="toolbar-btn" id="open-btn" title="打开文件">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"></path>
</svg>
<span class="hidden sm:inline">打开</span>
</button>
<button class="toolbar-btn" id="save-btn" title="保存文件">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3-3m0 0l-3 3m3-3v12"></path>
</svg>
<span class="hidden sm:inline">保存</span>
</button>
<button class="toolbar-btn bg-blue-500 text-white hover:bg-blue-600" id="export-btn" title="导出为H5">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
<span class="hidden sm:inline">导出H5</span>
</button>
<button class="toolbar-btn" id="theme-toggle" title="切换主题">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
</svg>
</button>
</div>
</div>
<!-- Markdown工具栏 -->
<div class="flex items-center space-x-1 mt-3 pt-3 border-t border-gray-200 dark:border-slate-700">
<button class="toolbar-btn" id="heading-btn" title="标题">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 20l4-16m2 16l4-16M6 9h14M4 15h14"></path>
</svg>
</button>
<button class="toolbar-btn" id="bold-btn" title="粗体">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z"></path>
</svg>
</button>
<button class="toolbar-btn" id="italic-btn" title="斜体">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 4h4M8 20h8M12 4l-2 16"></path>
</svg>
</button>
<button class="toolbar-btn" id="link-btn" title="链接">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"></path>
</svg>
</button>
<button class="toolbar-btn" id="image-btn" title="图片">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
</button>
<button class="toolbar-btn" id="list-ul-btn" title="无序列表">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"></path>
</svg>
</button>
<button class="toolbar-btn" id="list-ol-btn" title="有序列表">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 20l4-16m2 16l4-16M6 9h14M4 15h14"></path>
</svg>
</button>
<button class="toolbar-btn" id="code-btn" title="代码块">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"></path>
</svg>
</button>
<button class="toolbar-btn" id="quote-btn" title="引用">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 8h10M7 12h10M7 16h10"></path>
</svg>
</button>
</div>
</header>
<!-- 移动端标签 -->
<div class="mobile-tabs">
<div class="mobile-tab active" data-panel="editor">编辑</div>
<div class="mobile-tab" data-panel="preview">预览</div>
</div>
<!-- 主要内容区域 -->
<main class="editor-container">
<!-- 编辑器面板 -->
<div class="editor-panel active" id="editor-panel">
<textarea id="markdown-editor" placeholder="开始编写你的 Markdown 文档...
支持以下语法:
# 一级标题
## 二级标题
### 三级标题
**粗体文本**
*斜体文本*
- 无序列表项
- 另一个列表项
1. 有序列表项
2. 第二个列表项
[链接文本](https://example.com)

```javascript
// 代码块
function hello() {
console.log('Hello, World!');
}
```
> 引用文本
> 可以有多行
| 表格 | 示例 |
|------|------|
| 单元格1 | 单元格2 |
"></textarea>
</div>
<!-- 预览面板 -->
<div class="preview-panel" id="preview-panel">
<div class="preview-content" id="preview-content">
<div class="text-gray-500 dark:text-gray-400 text-center mt-8">
<svg class="w-16 h-16 mx-auto mb-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path>
</svg>
<p>开始编写 Markdown 文档,预览将在这里实时显示</p>
</div>
</div>
</div>
</main>
<!-- 状态栏 -->
<footer class="status-bar">
<div class="flex items-center space-x-4">
<span id="word-count">字数: 0</span>
<span id="char-count">字符: 0</span>
<span id="save-status">已保存</span>
</div>
<div class="flex items-center space-x-2">
<button class="toolbar-btn text-xs" id="fullscreen-btn" title="全屏模式">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"></path>
</svg>
</button>
</div>
</footer>
<!-- 隐藏的文件输入 -->
<input type="file" id="file-input" accept=".md,.markdown,.txt" style="display: none;">
<script src="main.js"></script>
</body>
</html>