mobile: disable pinch zoom; only fullscreen editor if virtual keyboard is up and editor has focus
Hunter
Saturday, July 26th, 2025 at 1:24 AM
426 parent: document.getElementById('editor')
427 });
428
429 + // Track editor focus for mobile keyboard behavior
430 + editorView.contentDOM.addEventListener('focus', function() {
431 + isEditorFocused = true;
432 + handleViewportChange(); // Check if keyboard is already open
433 + });
434 +
435 + editorView.contentDOM.addEventListener('blur', function() {
436 + isEditorFocused = false;
437 + handleViewportChange(); // Exit fullscreen mode if keyboard is open
438 + });
439 +
440 // Initial render
441 updatePreview();
442
455 // Mobile keyboard detection
456 let initialViewportHeight = window.visualViewport ? window.visualViewport.height : window.innerHeight;
457 let keyboardOpenThreshold = 150; // pixels
458 + let isEditorFocused = false;
459
460 function isMobileDevice() {
461 return window.matchMedia("(pointer: coarse), (pointer: none)").matches;
468 const heightDifference = initialViewportHeight - currentHeight;
469 const isKeyboardOpen = heightDifference > keyboardOpenThreshold;
470
- if (isKeyboardOpen) {
471 + // Only activate fullscreen editor mode if the editor is focused
472 + if (isKeyboardOpen && isEditorFocused) {
473 document.body.classList.add('mobile-keyboard-open');
474 // Set CSS custom property for the visible height
475 document.documentElement.style.setProperty('--visible-height', `${currentHeight}px`);