Compare commits

2 Commits

3 changed files with 17 additions and 15 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<resources> <resources>
<string name="app_name">纯纯写作</string> <string name="app_name">简单写作</string>
<string name="title_activity_main">纯纯写作</string> <string name="title_activity_main">简单写作</string>
<string name="package_name">com.chunchun.xiezuo</string> <string name="package_name">com.jiandan.xiezuo</string>
<string name="custom_url_scheme">com.chunchun.xiezuo</string> <string name="custom_url_scheme">com.jiandan.xiezuo</string>
</resources> </resources>
+11 -10
View File
@@ -532,13 +532,20 @@ setInterval(() => {
// ---------- 阅读模式 ---------- // ---------- 阅读模式 ----------
function exitReadingMode() {
document.body.classList.remove("reading", "top-shown");
clearTimeout(readingHideTimer);
editor.contentEditable = "true";
editor.style.removeProperty("-webkit-user-modify");
editor.focus();
}
function toggleReading() { function toggleReading() {
const isReading = document.body.classList.toggle("reading"); const isReading = document.body.classList.toggle("reading");
if (isReading) { if (isReading) {
editor.contentEditable = "false"; editor.contentEditable = "false";
editor.style.setProperty("-webkit-user-modify", "read-only", "important");
} else { } else {
editor.contentEditable = "true"; exitReadingMode();
editor.focus();
} }
} }
@@ -908,9 +915,7 @@ setInterval(() => {
} }
// Esc 退出阅读模式 // Esc 退出阅读模式
if (e.key === "Escape" && document.body.classList.contains("reading")) { if (e.key === "Escape" && document.body.classList.contains("reading")) {
document.body.classList.remove("reading"); exitReadingMode();
editor.contentEditable = "true";
editor.focus();
} }
}); });
@@ -924,11 +929,7 @@ setInterval(() => {
const exitBtn = document.createElement("div"); const exitBtn = document.createElement("div");
exitBtn.className = "reading-exit"; exitBtn.className = "reading-exit";
exitBtn.textContent = "退出阅读 (Esc)"; exitBtn.textContent = "退出阅读 (Esc)";
exitBtn.addEventListener("click", () => { exitBtn.addEventListener("click", exitReadingMode);
document.body.classList.remove("reading");
editor.contentEditable = "true";
editor.focus();
});
document.body.appendChild(exitBtn); document.body.appendChild(exitBtn);
// 阅读模式下:鼠标/手指移到顶部才显示退出按钮 // 阅读模式下:鼠标/手指移到顶部才显示退出按钮
+2 -1
View File
@@ -333,6 +333,7 @@ body.reading .editor {
cursor: default; cursor: default;
-webkit-user-select: text; -webkit-user-select: text;
user-select: text; user-select: text;
-webkit-user-modify: read-only;
} }
body.reading .topbar, body.reading .topbar,
body.reading .sidebar { transition: all 0.3s; } body.reading .sidebar { transition: all 0.3s; }
@@ -356,7 +357,7 @@ body.reading .sidebar { transition: all 0.3s; }
/* 阅读模式下默认隐藏,鼠标/手指移到顶部才浮现 */ /* 阅读模式下默认隐藏,鼠标/手指移到顶部才浮现 */
body.reading .reading-exit { opacity: 0; pointer-events: none; } body.reading .reading-exit { opacity: 0; pointer-events: none; }
body.reading.top-shown .reading-exit { opacity: 0.75; pointer-events: auto; } body.reading.top-shown .reading-exit { opacity: 0.75; pointer-events: auto; }
.reading-exit:hover { opacity: 1 !important; } body.reading .reading-exit:hover { opacity: 1 !important; }
/* ---------- 移动端 ---------- */ /* ---------- 移动端 ---------- */
@media (max-width: 720px) { @media (max-width: 720px) {