fix(mobile): bouton mode lecture visible uniquement fichier ouvert (BUG-016)
This commit is contained in:
@@ -603,6 +603,27 @@ function buildReadingControls() {
|
||||
document.body.appendChild(exit);
|
||||
}
|
||||
|
||||
/** True when the BooksLM assistant panel is expanded on screen. */
|
||||
function isAssistantOpen() {
|
||||
const panel = document.querySelector('.bookslm-panel');
|
||||
return !!(panel && panel.classList.contains('open') && !panel.classList.contains('hidden'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the floating reading-mode button only while a file is open and the
|
||||
* assistant panel is closed. Without this guard the button floats above the
|
||||
* full-screen mobile assistant and covers its send button.
|
||||
*
|
||||
* Called on init, whenever the content area changes and when the assistant
|
||||
* opens/closes.
|
||||
*/
|
||||
export function updateReadingButtonVisibility() {
|
||||
const btn = document.getElementById('me-reading-btn');
|
||||
if (!btn) return;
|
||||
const fileOpen = !!state.currentPath;
|
||||
btn.hidden = !fileOpen || isAssistantOpen();
|
||||
}
|
||||
|
||||
// ── Swipe gestures ─────────────────────────────────────────────────────────
|
||||
|
||||
function initSwipeGestures() {
|
||||
@@ -659,6 +680,19 @@ export function initMobileEditor() {
|
||||
buildReadingControls();
|
||||
initSwipeGestures();
|
||||
|
||||
// Keep the reading button in sync with the current view: visible only when
|
||||
// a file is open and the assistant is closed.
|
||||
updateReadingButtonVisibility();
|
||||
document.addEventListener('bookslm:opened', updateReadingButtonVisibility);
|
||||
document.addEventListener('bookslm:closed', updateReadingButtonVisibility);
|
||||
const readingArea = document.getElementById('content-area');
|
||||
if (readingArea && typeof MutationObserver !== 'undefined') {
|
||||
new MutationObserver(updateReadingButtonVisibility).observe(readingArea, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
|
||||
const bodyEl = document.getElementById('editor-body');
|
||||
if (bodyEl) {
|
||||
initPinchZoom(bodyEl);
|
||||
|
||||
@@ -9577,6 +9577,10 @@ body.bookslm-resizing { cursor: ew-resize; user-select: none; }
|
||||
.me-reading-exit {
|
||||
display: none;
|
||||
}
|
||||
/* Author `display: flex` would otherwise win over the `[hidden]` attribute. */
|
||||
.me-reading-btn[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.me-reading-btn {
|
||||
|
||||
Reference in New Issue
Block a user