feat(editor): run markdown source editing on CodeMirror 5

This commit is contained in:
2026-11-06 08:23:13 +08:00
parent 8b4d1fa03e
commit 715c8068f8
5 changed files with 354 additions and 12 deletions

View File

@@ -373,4 +373,59 @@ body.editing #app { max-width: none; padding: 0; }
#preview pre { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#preview .mdp-fold-body { display: block !important; }
#preview .mdp-fold-toggle { display: none !important; }
}
}
/* ---- CodeMirror source editor ------------------------------------------- */
#cm-editor { display: none; }
body.editing.cm-active { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
body.editing.cm-active .tabbar { flex: none; }
body.editing.cm-active #app { flex: 1; min-height: 0; width: 100%; max-width: none; padding: 0; overflow: hidden; }
body.editing.cm-active #editor { display: none; }
body.editing.cm-active #cm-editor { display: block; height: 100%; padding: 10px 24px 0 14px; box-sizing: border-box; }
#cm-editor .CodeMirror { height: 100%; background: transparent; color: inherit; font: 14px/1.6 "SF Mono","Menlo","Consolas",monospace; }
#cm-editor .CodeMirror-gutters { background: transparent; border-right: 1px solid rgba(128,128,128,.18); }
#cm-editor .CodeMirror-linenumber { color: #9aa0a6; padding: 0 10px 0 4px; }
#cm-editor .CodeMirror-foldgutter { width: .9em; }
#cm-editor .CodeMirror-foldgutter-open, #cm-editor .CodeMirror-foldgutter-folded { color: #9aa0a6; }
#cm-editor .CodeMirror-cursor { border-left: 1.5px solid #333; }
#cm-editor .CodeMirror-selected { background: #d7e4f5; }
#cm-editor .CodeMirror-focused .CodeMirror-selected { background: #b9d3f2; }
#cm-editor .cm-searching { background: rgba(255, 213, 0, .45); }
#cm-editor .CodeMirror-matchingbracket { color: inherit; text-decoration: underline; }
#cm-editor .cm-header { font-weight: 700; color: #0550ae; }
#cm-editor .cm-strong { font-weight: 700; }
#cm-editor .cm-em { font-style: italic; }
#cm-editor .cm-link { color: #0969da; }
#cm-editor .cm-url { color: #6e7781; }
#cm-editor .cm-comment { color: #6e7781; }
#cm-editor .cm-quote { color: #57606a; font-style: italic; }
#cm-editor .cm-formatting { color: #8c959f; }
#cm-editor .cm-variable-2 { color: #953800; }
#cm-editor .CodeMirror-dialog { background: #fff; color: #1a1a1a; border-color: #ddd; }
#cm-editor .CodeMirror-dialog input { font: inherit; }
#cm-editor .CodeMirror-dialog button { color: #1a1a1a; }
#cm-editor .CodeMirror-foldmarker { color: #0550ae; text-shadow: none; background: rgba(9,105,218,.08); border-radius: 3px; padding: 0 .3em; }
#cm-editor .CodeMirror-lines { padding: 4px 0 24px; }
@media (prefers-color-scheme: dark) {
#cm-editor .CodeMirror { color: #d4d4d4; }
#cm-editor .CodeMirror-gutters { border-color: rgba(255,255,255,.12); }
#cm-editor .CodeMirror-linenumber { color: #6b7280; }
#cm-editor .CodeMirror-foldgutter-open, #cm-editor .CodeMirror-foldgutter-folded { color: #6b7280; }
#cm-editor .CodeMirror-cursor { border-left-color: #e6e6e6; }
#cm-editor .CodeMirror-selected { background: #264f78; }
#cm-editor .CodeMirror-focused .CodeMirror-selected { background: #2f5f8f; }
#cm-editor .cm-header { color: #79c0ff; }
#cm-editor .cm-link { color: #58a6ff; }
#cm-editor .cm-url, #cm-editor .cm-comment { color: #8b949e; }
#cm-editor .cm-quote { color: #a8b1bb; }
#cm-editor .cm-formatting { color: #7d8590; }
#cm-editor .cm-variable-2 { color: #ffa657; }
#cm-editor .CodeMirror-dialog { background: #2a2a2a; color: #ddd; border-color: #444; }
#cm-editor .CodeMirror-dialog button { color: #ddd; }
#cm-editor .CodeMirror-foldmarker { color: #79c0ff; background: rgba(88,166,255,.12); }
}
@media print {
#cm-editor { display: none !important; }
}