diff --git a/workflowy-helper/main.js b/workflowy-helper/main.js index a0cb045..fb54355 100644 --- a/workflowy-helper/main.js +++ b/workflowy-helper/main.js @@ -86,6 +86,44 @@ // }}} + function isIosSafari() { // {{{ + const ua = navigator.userAgent; + return ( + /iPhone|iPad|iPod/.test(ua) && + /Safari/.test(ua) + ); + } + + // }}} + + function removeKeyboard(contentElement) { // {{{ + if (!('allowEditing' in contentElement)) { + contentElement.allowEditing = false; + } + + contentElement.addEventListener('focus', (e) => { + if (!contentElement.allowEditing) { + e.preventDefault(); + contentElement.blur(); + } + }); + + contentElement.addEventListener('dblclick', (e) => { + contentElement.allowEditing = true; + + // Small delay to ensure focus is handled correctly + setTimeout(() => { + contentElement.focus(); + }, 0); + }); + + contentElement.addEventListener('blur', () => { + contentElement.allowEditing = false; + }); + } + + // }}} + // }}} function updateProject(projectNode) { @@ -146,6 +184,12 @@ time.classList.add("time-" + relative); }); }); + + if (isIosSafari()) { + const content = n.querySelector('.content'); + removeKeyboard(content); + } + } }); } @@ -181,4 +225,5 @@ updateAll(); + })();