feat: always-dark VS code blocks, remove Find button
- Replace github light/dark hljs themes with assets/hljs/vs-dark.css (#1e1e1e bg, VS token colors) - Drop the prefers-color-scheme stylesheet switch; code blocks stay dark in both themes - Remove the toolbar Find button and its strings/icon; Ctrl+F and the findbar are unchanged - Print keeps the dark background via print-color-adjust: exact - Delete unused github.min.css / github-dark.min.css
This commit is contained in:
@@ -34,18 +34,24 @@
|
|||||||
|
|
||||||
保留:`Ctrl+O`、`Ctrl+P`、`window.__mdPreviewOpenFile`(脏标签时 Rust 回调用)。
|
保留:`Ctrl+O`、`Ctrl+P`、`window.__mdPreviewOpenFile`(脏标签时 Rust 回调用)。
|
||||||
|
|
||||||
验收:工具栏只剩 搜索 / 编辑 / 缩放;`Ctrl+O`、`Ctrl+P`、空状态 Open、Recent 均正常;`cargo test` 全绿。
|
验收:工具栏只剩 编辑 / 缩放;`Ctrl+O`、`Ctrl+P`、空状态 Open、Recent 均正常;`cargo test` 全绿。
|
||||||
|
|
||||||
## 步骤 3:代码配色(Visual Studio 风格)
|
## 步骤 3:代码配色(始终使用 Visual Studio Dark)
|
||||||
|
|
||||||
- 新增 `assets/hljs/vs2015.min.css`(深色)与 `vs.min.css` 或 `atom-one-light.min.css`(浅色),替换现有 GitHub 主题。
|
已确认的决策:
|
||||||
- 同步调整 `#preview pre` 背景:浅色 `#f6f8fa` 或 `#fff`,深色 `#1e1e1e`。
|
|
||||||
- 不改 JS,不加库;仍由 `prefers-color-scheme` 切换。
|
|
||||||
- 用 `tests/fixtures/code-samples.md` 目测 C# / Rust / JS / JSON / YAML / PowerShell / diff 的对比度。
|
|
||||||
|
|
||||||
验收:浅色/深色都不刺眼;字符串、注释、关键字、类型、数字有明显区分;代码块背景与主题一致。
|
- Windows 版**没有主题设置**(`theme.txt` / 主题菜单只接了 macOS;Windows 一直跟随系统 `prefers-color-scheme`,没有 UI 可切)。
|
||||||
|
- 因此**不做主题切换,也不加主题按钮**;代码块**始终深色**,即使应用是浅色。
|
||||||
|
- 删除工具栏的 Find(搜索)按钮;`Ctrl+F`、`window.__mdPreviewShowFind` 保留,查找条不变。
|
||||||
|
|
||||||
可选:加“代码配色”独立切换(localStorage),+2–3 h。
|
实现:
|
||||||
|
|
||||||
|
- 新增 `assets/hljs/vs-dark.css`(约 1.3 KB):背景 `#1e1e1e`,前景 `#d4d4d4`,关键字 `#569cd6`、字符串 `#ce9178`、注释 `#6a9955`、数字 `#b5cea8`、类型 `#4ec9b0`、函数 `#dcdcaa`、变量/参数 `#9cdcfe`、meta `#c586c0`、diff 增删色。
|
||||||
|
- 删除 `github.min.css` / `github-dark.min.css` 与 `prefers-color-scheme` 切换脚本;页面只保留一个 `<style id="hljs-code">`。
|
||||||
|
- `#preview pre` 固定 `background:#1e1e1e; color:#d4d4d4`;行内代码仍跟随应用主题。
|
||||||
|
- 打印时给 `pre` 加 `print-color-adjust: exact`,避免深色背景被打印机丢掉。
|
||||||
|
|
||||||
|
验收:任意系统主题下代码块都是深色;C# / Rust / JS / JSON / YAML / PowerShell / diff 的关键字、字符串、注释、类型、数字可区分;行内代码在浅色主题仍为浅底;工具栏无 Find;`Ctrl+F` 仍能打开查找。
|
||||||
|
|
||||||
## 步骤 4:Ctrl + 滚轮
|
## 步骤 4:Ctrl + 滚轮
|
||||||
|
|
||||||
@@ -86,14 +92,14 @@
|
|||||||
## 回归清单(每次发版)
|
## 回归清单(每次发版)
|
||||||
|
|
||||||
- [ ] 窗口标题 `文件名 — MD Preview`,脏状态显示 `•`
|
- [ ] 窗口标题 `文件名 — MD Preview`,脏状态显示 `•`
|
||||||
- [ ] 工具栏无 Open / Print
|
- [ ] 工具栏无 Open / Print / Find
|
||||||
- [ ] 多标签、关闭、会话恢复、缺失文件重定位
|
- [ ] 多标签、关闭、会话恢复、缺失文件重定位
|
||||||
- [ ] 编辑 700ms 自动保存;关闭前落盘
|
- [ ] 编辑 700ms 自动保存;关闭前落盘
|
||||||
- [ ] 外部修改提示与保护
|
- [ ] 外部修改提示与保护
|
||||||
- [ ] 查找(含中文输入法组合输入)
|
- [ ] 查找(含中文输入法组合输入)
|
||||||
- [ ] Ctrl+滚轮、Ctrl+0、50%–300%
|
- [ ] Ctrl+滚轮、Ctrl+0、50%–300%
|
||||||
- [ ] 折叠状态与自动保存共存
|
- [ ] 折叠状态与自动保存共存
|
||||||
- [ ] 代码配色浅/深
|
- [ ] 代码块始终深色(VS Dark),行内代码随主题
|
||||||
- [ ] 打印预览完整
|
- [ ] 打印预览完整
|
||||||
- [ ] 单实例转发
|
- [ ] 单实例转发
|
||||||
- [ ] `agent/scripts/build.ps1` 通过,exe 为 Medium
|
- [ ] `agent/scripts/build.ps1` 通过,exe 为 Medium
|
||||||
|
|||||||
BIN
agent/reports/feature3-dark-code.png
Normal file
BIN
agent/reports/feature3-dark-code.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 139 KiB |
10
assets/hljs/github-dark.min.css
vendored
10
assets/hljs/github-dark.min.css
vendored
@@ -1,10 +0,0 @@
|
|||||||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
|
||||||
Theme: GitHub Dark
|
|
||||||
Description: Dark theme as seen on github.com
|
|
||||||
Author: github.com
|
|
||||||
Maintainer: @Hirse
|
|
||||||
Updated: 2021-05-15
|
|
||||||
|
|
||||||
Outdated base version: https://github.com/primer/github-syntax-dark
|
|
||||||
Current colors taken from GitHub's CSS
|
|
||||||
*/.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}
|
|
||||||
10
assets/hljs/github.min.css
vendored
10
assets/hljs/github.min.css
vendored
@@ -1,10 +0,0 @@
|
|||||||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
|
||||||
Theme: GitHub
|
|
||||||
Description: Light theme as seen on github.com
|
|
||||||
Author: github.com
|
|
||||||
Maintainer: @Hirse
|
|
||||||
Updated: 2021-05-15
|
|
||||||
|
|
||||||
Outdated base version: https://github.com/primer/github-syntax-light
|
|
||||||
Current colors taken from GitHub's CSS
|
|
||||||
*/.hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}
|
|
||||||
94
assets/hljs/vs-dark.css
Normal file
94
assets/hljs/vs-dark.css
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/* Visual Studio Dark inspired highlight.js theme.
|
||||||
|
Code blocks are always dark, independent of the app (system) theme. */
|
||||||
|
|
||||||
|
.hljs {
|
||||||
|
color: #d4d4d4;
|
||||||
|
background: #1e1e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-comment,
|
||||||
|
.hljs-quote {
|
||||||
|
color: #6a9955;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-keyword,
|
||||||
|
.hljs-selector-tag,
|
||||||
|
.hljs-literal,
|
||||||
|
.hljs-section,
|
||||||
|
.hljs-link,
|
||||||
|
.hljs-doctag {
|
||||||
|
color: #569cd6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-string,
|
||||||
|
.hljs-regexp,
|
||||||
|
.hljs-attribute,
|
||||||
|
.hljs-template-tag {
|
||||||
|
color: #ce9178;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-number,
|
||||||
|
.hljs-symbol,
|
||||||
|
.hljs-bullet,
|
||||||
|
.hljs-variable,
|
||||||
|
.hljs-template-variable,
|
||||||
|
.hljs-constant {
|
||||||
|
color: #b5cea8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-title,
|
||||||
|
.hljs-title.class_,
|
||||||
|
.hljs-title.function_,
|
||||||
|
.hljs-function .hljs-title {
|
||||||
|
color: #dcdcaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-type,
|
||||||
|
.hljs-class .hljs-title,
|
||||||
|
.hljs-built_in,
|
||||||
|
.hljs-builtin-name,
|
||||||
|
.hljs-namespace {
|
||||||
|
color: #4ec9b0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-attr,
|
||||||
|
.hljs-property,
|
||||||
|
.hljs-params,
|
||||||
|
.hljs-selector-attr,
|
||||||
|
.hljs-selector-pseudo {
|
||||||
|
color: #9cdcfe;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-tag,
|
||||||
|
.hljs-name,
|
||||||
|
.hljs-selector-id,
|
||||||
|
.hljs-selector-class {
|
||||||
|
color: #569cd6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-meta {
|
||||||
|
color: #c586c0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-meta .hljs-string {
|
||||||
|
color: #ce9178;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-emphasis {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-strong {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-addition {
|
||||||
|
color: #b5cea8;
|
||||||
|
background: rgba(78, 201, 176, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-deletion {
|
||||||
|
color: #f48771;
|
||||||
|
background: rgba(244, 135, 113, 0.12);
|
||||||
|
}
|
||||||
42
src/main.rs
42
src/main.rs
@@ -144,7 +144,6 @@ struct Strings {
|
|||||||
btn_preview: &'static str,
|
btn_preview: &'static str,
|
||||||
btn_new: &'static str,
|
btn_new: &'static str,
|
||||||
new_filename: &'static str,
|
new_filename: &'static str,
|
||||||
btn_search: &'static str,
|
|
||||||
btn_zoom: &'static str,
|
btn_zoom: &'static str,
|
||||||
btn_zoom_out: &'static str,
|
btn_zoom_out: &'static str,
|
||||||
btn_zoom_reset: &'static str,
|
btn_zoom_reset: &'static str,
|
||||||
@@ -170,7 +169,6 @@ impl Strings {
|
|||||||
btn_preview: "预览 (Cmd/Ctrl+E)",
|
btn_preview: "预览 (Cmd/Ctrl+E)",
|
||||||
btn_new: "新建 Markdown (Cmd/Ctrl+N)",
|
btn_new: "新建 Markdown (Cmd/Ctrl+N)",
|
||||||
new_filename: "新建.md",
|
new_filename: "新建.md",
|
||||||
btn_search: "搜索 (Cmd/Ctrl+F)",
|
|
||||||
btn_zoom: "正文缩放",
|
btn_zoom: "正文缩放",
|
||||||
btn_zoom_out: "缩小正文 (Cmd/Ctrl+-)",
|
btn_zoom_out: "缩小正文 (Cmd/Ctrl+-)",
|
||||||
btn_zoom_reset: "重置正文缩放 (Cmd/Ctrl+0)",
|
btn_zoom_reset: "重置正文缩放 (Cmd/Ctrl+0)",
|
||||||
@@ -192,7 +190,6 @@ impl Strings {
|
|||||||
btn_preview: "Preview (Cmd/Ctrl+E)",
|
btn_preview: "Preview (Cmd/Ctrl+E)",
|
||||||
btn_new: "New Markdown (Cmd/Ctrl+N)",
|
btn_new: "New Markdown (Cmd/Ctrl+N)",
|
||||||
new_filename: "Untitled.md",
|
new_filename: "Untitled.md",
|
||||||
btn_search: "Find (Cmd/Ctrl+F)",
|
|
||||||
btn_zoom: "Content zoom",
|
btn_zoom: "Content zoom",
|
||||||
btn_zoom_out: "Zoom out (Cmd/Ctrl+-)",
|
btn_zoom_out: "Zoom out (Cmd/Ctrl+-)",
|
||||||
btn_zoom_reset: "Reset zoom (Cmd/Ctrl+0)",
|
btn_zoom_reset: "Reset zoom (Cmd/Ctrl+0)",
|
||||||
@@ -691,8 +688,8 @@ fn unique_heading_id(base: String, seen: &mut HashMap<String, usize>) -> String
|
|||||||
|
|
||||||
// Embedded highlight.js + themes (offline)
|
// Embedded highlight.js + themes (offline)
|
||||||
const HLJS_JS: &str = include_str!("../assets/hljs/highlight.min.js");
|
const HLJS_JS: &str = include_str!("../assets/hljs/highlight.min.js");
|
||||||
const HLJS_LIGHT: &str = include_str!("../assets/hljs/github.min.css");
|
// Always-dark code blocks; app chrome still follows the system theme.
|
||||||
const HLJS_DARK: &str = include_str!("../assets/hljs/github-dark.min.css");
|
const HLJS_CODE: &str = include_str!("../assets/hljs/vs-dark.css");
|
||||||
// Extra language pack(s) not in the `common` bundle. Each file
|
// Extra language pack(s) not in the `common` bundle. Each file
|
||||||
// ends with `hljs.registerLanguage(...)` and only works if evaluated
|
// ends with `hljs.registerLanguage(...)` and only works if evaluated
|
||||||
// in the same scope as the main bundle — we concat them into hljs-src.
|
// in the same scope as the main bundle — we concat them into hljs-src.
|
||||||
@@ -1003,18 +1000,7 @@ fn build_page(
|
|||||||
format!(
|
format!(
|
||||||
r#"<!DOCTYPE html><html><head><meta charset="utf-8">
|
r#"<!DOCTYPE html><html><head><meta charset="utf-8">
|
||||||
{base_tag}
|
{base_tag}
|
||||||
<style id="hljs-light">{css_light}</style>
|
<style id="hljs-code">{css_code}</style>
|
||||||
<style id="hljs-dark" media="not all">{css_dark}</style>
|
|
||||||
<script>
|
|
||||||
(function(){{
|
|
||||||
var mq = window.matchMedia('(prefers-color-scheme: dark)');
|
|
||||||
function apply(e) {{
|
|
||||||
document.getElementById('hljs-light').media = e.matches ? 'not all' : '';
|
|
||||||
document.getElementById('hljs-dark').media = e.matches ? '' : 'not all';
|
|
||||||
}}
|
|
||||||
apply(mq); mq.addEventListener('change', apply);
|
|
||||||
}})();
|
|
||||||
</script>
|
|
||||||
<style>
|
<style>
|
||||||
:root {{ color-scheme: light dark; --chrome-top: 10px; --content-scale: 1; }}
|
:root {{ color-scheme: light dark; --chrome-top: 10px; --content-scale: 1; }}
|
||||||
/* Reserve scrollbar space permanently so the fixed toolbar doesn't shift
|
/* Reserve scrollbar space permanently so the fixed toolbar doesn't shift
|
||||||
@@ -1051,7 +1037,8 @@ body.has-tabs {{ --chrome-top: 50px; }}
|
|||||||
#preview h1 {{ border-bottom: 1px solid #e1e4e8; padding-bottom: .3em; }}
|
#preview h1 {{ border-bottom: 1px solid #e1e4e8; padding-bottom: .3em; }}
|
||||||
#preview h2 {{ border-bottom: 1px solid #e1e4e8; padding-bottom: .2em; }}
|
#preview h2 {{ border-bottom: 1px solid #e1e4e8; padding-bottom: .2em; }}
|
||||||
#preview code {{ background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-size: 90%; }}
|
#preview code {{ background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-size: 90%; }}
|
||||||
#preview pre {{ background: #f6f8fa; padding: 16px; border-radius: 8px; overflow-x: auto; }}
|
/* Code blocks stay dark (VS Dark) even in the light app theme. */
|
||||||
|
#preview pre {{ background: #1e1e1e; color: #d4d4d4; padding: 16px; border-radius: 8px; overflow-x: auto; }}
|
||||||
#preview pre code {{ background: none; padding: 0; font-size: 14px; }}
|
#preview pre code {{ background: none; padding: 0; font-size: 14px; }}
|
||||||
#preview blockquote {{ border-left: 4px solid #ddd; margin: 0; padding: 0 1em; color: #666; }}
|
#preview blockquote {{ border-left: 4px solid #ddd; margin: 0; padding: 0 1em; color: #666; }}
|
||||||
#preview .markdown-alert-note,
|
#preview .markdown-alert-note,
|
||||||
@@ -1243,7 +1230,6 @@ body.empty .toolbar {{ display: none !important; }}
|
|||||||
#preview h1, #preview h2 {{ border-color: #333; }}
|
#preview h1, #preview h2 {{ border-color: #333; }}
|
||||||
#preview .front-matter {{ border-color: #333; color: #a9b1ba; }}
|
#preview .front-matter {{ border-color: #333; color: #a9b1ba; }}
|
||||||
#preview .front-matter pre {{ background: transparent !important; }}
|
#preview .front-matter pre {{ background: transparent !important; }}
|
||||||
#preview pre {{ background: #2d2d2d !important; }}
|
|
||||||
#preview code:not(pre code) {{ background: #2d2d2d; }}
|
#preview code:not(pre code) {{ background: #2d2d2d; }}
|
||||||
#preview blockquote {{ border-color: #444; color: #aaa; }}
|
#preview blockquote {{ border-color: #444; color: #aaa; }}
|
||||||
#preview .markdown-alert-note,
|
#preview .markdown-alert-note,
|
||||||
@@ -1305,7 +1291,6 @@ body.empty .toolbar {{ display: none !important; }}
|
|||||||
body.editing #preview {{ display: none; }}
|
body.editing #preview {{ display: none; }}
|
||||||
body.editing #editor {{ display: block; padding: 16px 24px; }}
|
body.editing #editor {{ display: block; padding: 16px 24px; }}
|
||||||
body.editing #app {{ max-width: none; padding: 0; }}
|
body.editing #app {{ max-width: none; padding: 0; }}
|
||||||
body.editing #btn-search {{ display: none; }}
|
|
||||||
|
|
||||||
@page {{
|
@page {{
|
||||||
margin: 12mm;
|
margin: 12mm;
|
||||||
@@ -1316,11 +1301,11 @@ body.editing #btn-search {{ display: none; }}
|
|||||||
#preview {{ display: block !important; }}
|
#preview {{ display: block !important; }}
|
||||||
#app {{ max-width: none; padding: 0; }}
|
#app {{ max-width: none; padding: 0; }}
|
||||||
#preview .mdp-table-wrap {{ width: auto; margin: 1em 0; transform: none; overflow: visible; }}
|
#preview .mdp-table-wrap {{ width: auto; margin: 1em 0; transform: none; overflow: visible; }}
|
||||||
|
#preview pre {{ -webkit-print-color-adjust: exact; print-color-adjust: exact; }}
|
||||||
}}
|
}}
|
||||||
</style></head><body class="{body_class}">
|
</style></head><body class="{body_class}">
|
||||||
<div class="tabbar" id="tabbar"><div class="tabs" id="tabs"></div><div class="doc-stats" id="doc-stats" aria-live="polite"></div><button class="tab-open" id="tab-open" type="button" title="{btn_new}" aria-label="{btn_new}">+</button></div>
|
<div class="tabbar" id="tabbar"><div class="tabs" id="tabs"></div><div class="doc-stats" id="doc-stats" aria-live="polite"></div><button class="tab-open" id="tab-open" type="button" title="{btn_new}" aria-label="{btn_new}">+</button></div>
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<button id="btn-search" title="{btn_search}" aria-label="{btn_search}"></button>
|
|
||||||
<button id="btn-toggle" title="{btn_edit}" aria-label="{btn_edit}"></button>
|
<button id="btn-toggle" title="{btn_edit}" aria-label="{btn_edit}"></button>
|
||||||
<div class="zoom-control" id="zoom-control">
|
<div class="zoom-control" id="zoom-control">
|
||||||
<button id="btn-zoom" title="{btn_zoom}" aria-label="{btn_zoom}"></button>
|
<button id="btn-zoom" title="{btn_zoom}" aria-label="{btn_zoom}"></button>
|
||||||
@@ -1346,14 +1331,12 @@ body.editing #btn-search {{ display: none; }}
|
|||||||
(function(){{
|
(function(){{
|
||||||
var ICON_EDIT = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>';
|
var ICON_EDIT = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>';
|
||||||
var ICON_VIEW = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>';
|
var ICON_VIEW = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>';
|
||||||
var ICON_SEARCH = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>';
|
|
||||||
var ICON_ZOOM = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M8 11h6"/><path d="M11 8v6"/></svg>';
|
var ICON_ZOOM = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M8 11h6"/><path d="M11 8v6"/></svg>';
|
||||||
var ICON_UP = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>';
|
var ICON_UP = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>';
|
||||||
var ICON_DOWN = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>';
|
var ICON_DOWN = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>';
|
||||||
var ICON_CLOSE = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';
|
var ICON_CLOSE = '<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';
|
||||||
var L_EDIT = '{btn_edit}', L_VIEW = '{btn_preview}';
|
var L_EDIT = '{btn_edit}', L_VIEW = '{btn_preview}';
|
||||||
|
|
||||||
var btnSearch = document.getElementById('btn-search');
|
|
||||||
var btnToggle = document.getElementById('btn-toggle');
|
var btnToggle = document.getElementById('btn-toggle');
|
||||||
var btnZoom = document.getElementById('btn-zoom');
|
var btnZoom = document.getElementById('btn-zoom');
|
||||||
var btnZoomOut = document.getElementById('btn-zoom-out');
|
var btnZoomOut = document.getElementById('btn-zoom-out');
|
||||||
@@ -1390,7 +1373,6 @@ body.editing #btn-search {{ display: none; }}
|
|||||||
var zoomWheelAt = 0;
|
var zoomWheelAt = 0;
|
||||||
var zoomPercent = 100;
|
var zoomPercent = 100;
|
||||||
|
|
||||||
btnSearch.innerHTML = ICON_SEARCH;
|
|
||||||
btnToggle.innerHTML = ICON_EDIT;
|
btnToggle.innerHTML = ICON_EDIT;
|
||||||
btnZoom.innerHTML = ICON_ZOOM;
|
btnZoom.innerHTML = ICON_ZOOM;
|
||||||
findPrev.innerHTML = ICON_UP;
|
findPrev.innerHTML = ICON_UP;
|
||||||
@@ -1667,7 +1649,6 @@ body.editing #btn-search {{ display: none; }}
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
tabOpen.addEventListener('click', newFile);
|
tabOpen.addEventListener('click', newFile);
|
||||||
btnSearch.addEventListener('click', showFind);
|
|
||||||
document.addEventListener('click', function(e) {{
|
document.addEventListener('click', function(e) {{
|
||||||
var closeTab = e.target && e.target.closest ? e.target.closest('[data-close-tab]') : null;
|
var closeTab = e.target && e.target.closest ? e.target.closest('[data-close-tab]') : null;
|
||||||
if (closeTab) {{
|
if (closeTab) {{
|
||||||
@@ -1949,13 +1930,11 @@ window.__mdPreviewFeatureFlags = {{ math: {needs_math}, mermaid: {needs_mermaid}
|
|||||||
if(window.__enhancePreview)window.__enhancePreview();
|
if(window.__enhancePreview)window.__enhancePreview();
|
||||||
</script>
|
</script>
|
||||||
</body></html>"#,
|
</body></html>"#,
|
||||||
css_light = HLJS_LIGHT,
|
css_code = HLJS_CODE,
|
||||||
css_dark = HLJS_DARK,
|
|
||||||
base_tag = base_tag,
|
base_tag = base_tag,
|
||||||
preview_html = preview_html,
|
preview_html = preview_html,
|
||||||
raw_md_escaped = html_escape_ta(raw_md),
|
raw_md_escaped = html_escape_ta(raw_md),
|
||||||
btn_new = s.btn_new,
|
btn_new = s.btn_new,
|
||||||
btn_search = s.btn_search,
|
|
||||||
btn_edit = s.btn_edit,
|
btn_edit = s.btn_edit,
|
||||||
btn_preview = s.btn_preview,
|
btn_preview = s.btn_preview,
|
||||||
btn_zoom = s.btn_zoom,
|
btn_zoom = s.btn_zoom,
|
||||||
@@ -2274,15 +2253,16 @@ mod tests {
|
|||||||
assert!(page.contains("window.ipc.postMessage('refresh')"));
|
assert!(page.contains("window.ipc.postMessage('refresh')"));
|
||||||
assert!(!page.contains("id=\"btn-open\""));
|
assert!(!page.contains("id=\"btn-open\""));
|
||||||
assert!(!page.contains("id=\"btn-print\""));
|
assert!(!page.contains("id=\"btn-print\""));
|
||||||
assert!(page.contains("id=\"btn-search\""));
|
assert!(!page.contains("id=\"btn-search\""));
|
||||||
assert!(page.contains("window.ipc.postMessage('open')"));
|
assert!(page.contains("window.ipc.postMessage('open')"));
|
||||||
assert!(page.contains("window.__mdPreviewOpenFile = openFile"));
|
assert!(page.contains("window.__mdPreviewOpenFile = openFile"));
|
||||||
assert!(page.contains("window.__mdPreviewShowFind = showFind"));
|
assert!(page.contains("window.__mdPreviewShowFind = showFind"));
|
||||||
assert!(page.contains("window.__mdPreviewToggleEdit"));
|
assert!(page.contains("window.__mdPreviewToggleEdit"));
|
||||||
assert!(page.contains("Cmd/Ctrl+F"));
|
|
||||||
assert!(page
|
assert!(page
|
||||||
.contains("if (inEdit()) return;\n\t e.preventDefault();\n\t showFind();"));
|
.contains("if (inEdit()) return;\n\t e.preventDefault();\n\t showFind();"));
|
||||||
assert!(page.contains("body.editing #btn-search"));
|
assert!(page.contains("id=\"hljs-code\""));
|
||||||
|
assert!(page.contains("#preview pre { background: #1e1e1e;"));
|
||||||
|
assert!(!page.contains("hljs-light"));
|
||||||
assert!(page.contains("ta.focus({ preventScroll: true })"));
|
assert!(page.contains("ta.focus({ preventScroll: true })"));
|
||||||
assert!(page.contains("window.__setEmptyPreview"));
|
assert!(page.contains("window.__setEmptyPreview"));
|
||||||
assert!(page.contains("id=\"tabbar\""));
|
assert!(page.contains("id=\"tabbar\""));
|
||||||
|
|||||||
Reference in New Issue
Block a user