mirror of
https://github.com/abort-retry-ignore/joplock.git
synced 2026-10-19 02:09:26 +00:00
fix(escape): dismiss in-note search / clear nav-search from inside TinyMCE iframe
Some checks are pending
Build and push Joplock image / build-and-push (push) Waiting to run
Some checks are pending
Build and push Joplock image / build-and-push (push) Waiting to run
TinyMCE runs in an iframe (separate browsing context), so keydown events
fired inside it never bubble to the parent document's keydown listener.
This made Esc silently do nothing while focus was inside the note body
where search highlights live, even though the same key worked once focus
left the note. Wired the same two-stage Esc logic (dismiss highlight,
then clear nav-search) directly on editor.on('keydown'), following the
existing pattern used for the AI-completion shortcut and resource-viewer
overlay, both of which have the same iframe limitation.
This commit is contained in:
parent
feece750ef
commit
fb09c3d92e
1 changed files with 25 additions and 0 deletions
|
|
@ -1163,6 +1163,31 @@ function initPersistentTinyMCE(){
|
|||
e.preventDefault();
|
||||
try{requestTinyMCEProseCompletion({editor:editor})}catch(err){_clientLog('expander.tinymce.error',{message:String(err&&err.message||err)})}
|
||||
}
|
||||
// In-note find/highlight: the global document keydown handler cannot
|
||||
// see Escape while focus is inside the TinyMCE iframe (separate
|
||||
// browsing context, key events do not bubble to the parent
|
||||
// document), so replicate the two-stage Esc here too:
|
||||
// 1st Esc dismisses the in-note search-nav-bar/highlight,
|
||||
// 2nd Esc clears the nav-search field and exits results.
|
||||
if(e.key==='Escape'){
|
||||
_log('esc:TinyMCE iframe keydown Escape');
|
||||
var bar=document.getElementById('search-nav-bar');
|
||||
var sesActive=_searchSessionActive();
|
||||
_log('esc:TinyMCE bar hidden='+(bar?bar.hidden:'n/a')+' sesActive='+sesActive);
|
||||
if((bar&&!bar.hidden)||sesActive){
|
||||
_log('esc:TinyMCE dismissing search');
|
||||
e.preventDefault();
|
||||
searchNavDismiss();
|
||||
}else{
|
||||
var navSearch=document.getElementById('nav-search');
|
||||
if(navSearch&&navSearch.value){
|
||||
_log('esc:TinyMCE clearing nav-search field');
|
||||
e.preventDefault();
|
||||
navSearch.value='';
|
||||
htmx.trigger(navSearch,'search-submit');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Code block init is deferred to _setTinyMCEContent so it runs after
|
||||
// TinyMCE's codesample plugin has finished processing the content.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue