feat: remove toolbar open/print buttons (keep Ctrl+O/Ctrl+P)
This commit is contained in:
32
src/main.rs
32
src/main.rs
@@ -144,9 +144,7 @@ struct Strings {
|
||||
btn_preview: &'static str,
|
||||
btn_new: &'static str,
|
||||
new_filename: &'static str,
|
||||
btn_open: &'static str,
|
||||
btn_search: &'static str,
|
||||
btn_print: &'static str,
|
||||
btn_zoom: &'static str,
|
||||
btn_zoom_out: &'static str,
|
||||
btn_zoom_reset: &'static str,
|
||||
@@ -172,9 +170,7 @@ impl Strings {
|
||||
btn_preview: "预览 (Cmd/Ctrl+E)",
|
||||
btn_new: "新建 Markdown (Cmd/Ctrl+N)",
|
||||
new_filename: "新建.md",
|
||||
btn_open: "Open File (Cmd/Ctrl+O)",
|
||||
btn_search: "搜索 (Cmd/Ctrl+F)",
|
||||
btn_print: "打印 (Cmd/Ctrl+P)",
|
||||
btn_zoom: "正文缩放",
|
||||
btn_zoom_out: "缩小正文 (Cmd/Ctrl+-)",
|
||||
btn_zoom_reset: "重置正文缩放 (Cmd/Ctrl+0)",
|
||||
@@ -196,9 +192,7 @@ impl Strings {
|
||||
btn_preview: "Preview (Cmd/Ctrl+E)",
|
||||
btn_new: "New Markdown (Cmd/Ctrl+N)",
|
||||
new_filename: "Untitled.md",
|
||||
btn_open: "Open File (Cmd/Ctrl+O)",
|
||||
btn_search: "Find (Cmd/Ctrl+F)",
|
||||
btn_print: "Print (Cmd/Ctrl+P)",
|
||||
btn_zoom: "Content zoom",
|
||||
btn_zoom_out: "Zoom out (Cmd/Ctrl+-)",
|
||||
btn_zoom_reset: "Reset zoom (Cmd/Ctrl+0)",
|
||||
@@ -1311,9 +1305,7 @@ body.empty .toolbar {{ display: none !important; }}
|
||||
body.editing #preview {{ display: none; }}
|
||||
body.editing #editor {{ display: block; padding: 16px 24px; }}
|
||||
body.editing #app {{ max-width: none; padding: 0; }}
|
||||
body.editing #btn-open,
|
||||
body.editing #btn-search,
|
||||
body.editing #btn-print {{ display: none; }}
|
||||
body.editing #btn-search {{ display: none; }}
|
||||
|
||||
@page {{
|
||||
margin: 12mm;
|
||||
@@ -1328,10 +1320,8 @@ body.editing #btn-print {{ display: none; }}
|
||||
</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="toolbar">
|
||||
<button id="btn-open" title="{btn_open}" aria-label="{btn_open}"></button>
|
||||
<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-print" title="{btn_print}" aria-label="{btn_print}"></button>
|
||||
<div class="zoom-control" id="zoom-control">
|
||||
<button id="btn-zoom" title="{btn_zoom}" aria-label="{btn_zoom}"></button>
|
||||
<div class="zoom-popover">
|
||||
@@ -1356,19 +1346,15 @@ body.editing #btn-print {{ display: none; }}
|
||||
(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_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_OPEN = '<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="m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6A2 2 0 0 1 18.45 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/></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_PRINT = '<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 2 18 2 18 9"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></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_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 L_EDIT = '{btn_edit}', L_VIEW = '{btn_preview}';
|
||||
|
||||
var btnOpen = document.getElementById('btn-open');
|
||||
var btnSearch = document.getElementById('btn-search');
|
||||
var btnToggle = document.getElementById('btn-toggle');
|
||||
var btnPrint = document.getElementById('btn-print');
|
||||
var btnZoom = document.getElementById('btn-zoom');
|
||||
var btnZoomOut = document.getElementById('btn-zoom-out');
|
||||
var btnZoomReset = document.getElementById('btn-zoom-reset');
|
||||
@@ -1402,10 +1388,8 @@ body.editing #btn-print {{ display: none; }}
|
||||
var ZOOM_STEP = 10;
|
||||
var zoomPercent = 100;
|
||||
|
||||
btnOpen.innerHTML = ICON_OPEN;
|
||||
btnSearch.innerHTML = ICON_SEARCH;
|
||||
btnToggle.innerHTML = ICON_EDIT;
|
||||
btnPrint.innerHTML = ICON_PRINT;
|
||||
btnZoom.innerHTML = ICON_ZOOM;
|
||||
findPrev.innerHTML = ICON_UP;
|
||||
findNext.innerHTML = ICON_DOWN;
|
||||
@@ -1680,7 +1664,6 @@ body.editing #btn-print {{ display: none; }}
|
||||
if (activeTabId) requestTabAction('close', activeTabId);
|
||||
}};
|
||||
|
||||
btnOpen.addEventListener('click', openFile);
|
||||
tabOpen.addEventListener('click', newFile);
|
||||
btnSearch.addEventListener('click', showFind);
|
||||
document.addEventListener('click', function(e) {{
|
||||
@@ -1740,12 +1723,6 @@ body.editing #btn-print {{ display: none; }}
|
||||
btnZoomOut.addEventListener('click', function() {{ changeZoom(-ZOOM_STEP); }});
|
||||
btnZoomReset.addEventListener('click', function() {{ applyZoom(100, true); }});
|
||||
btnZoomIn.addEventListener('click', function() {{ changeZoom(ZOOM_STEP); }});
|
||||
btnPrint.addEventListener('click', function() {{
|
||||
if (inEdit()) leaveEdit();
|
||||
// Route through Rust: WKWebView ignores window.print(); wry's
|
||||
// WebView::print() calls the right native API on each platform.
|
||||
setTimeout(function(){{ window.ipc.postMessage('print'); }}, 0);
|
||||
}});
|
||||
ta.addEventListener('input', function() {{ setDirty(true); scheduleAutosave(); autoResize(); updateDocumentStats(ta.value); }});
|
||||
window.addEventListener('resize', function() {{ if (inEdit()) autoResize(); }});
|
||||
document.addEventListener('click', function(e) {{
|
||||
@@ -1965,12 +1942,10 @@ if(window.__enhancePreview)window.__enhancePreview();
|
||||
base_tag = base_tag,
|
||||
preview_html = preview_html,
|
||||
raw_md_escaped = html_escape_ta(raw_md),
|
||||
btn_open = s.btn_open,
|
||||
btn_new = s.btn_new,
|
||||
btn_search = s.btn_search,
|
||||
btn_edit = s.btn_edit,
|
||||
btn_preview = s.btn_preview,
|
||||
btn_print = s.btn_print,
|
||||
btn_zoom = s.btn_zoom,
|
||||
btn_zoom_out = s.btn_zoom_out,
|
||||
btn_zoom_reset = s.btn_zoom_reset,
|
||||
@@ -2285,7 +2260,8 @@ mod tests {
|
||||
|
||||
assert!(page.contains("document.addEventListener('contextmenu'"));
|
||||
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-search\""));
|
||||
assert!(page.contains("window.ipc.postMessage('open')"));
|
||||
assert!(page.contains("window.__mdPreviewOpenFile = openFile"));
|
||||
@@ -2294,7 +2270,7 @@ mod tests {
|
||||
assert!(page.contains("Cmd/Ctrl+F"));
|
||||
assert!(page
|
||||
.contains("if (inEdit()) return;\n\t e.preventDefault();\n\t showFind();"));
|
||||
assert!(page.contains("body.editing #btn-open"));
|
||||
assert!(page.contains("body.editing #btn-search"));
|
||||
assert!(page.contains("ta.focus({ preventScroll: true })"));
|
||||
assert!(page.contains("window.__setEmptyPreview"));
|
||||
assert!(page.contains("id=\"tabbar\""));
|
||||
|
||||
Reference in New Issue
Block a user