TinyMCE Classic Block: fix repositioning of the inline toolbar on scrolling.

Props iseulde, azaozz.
Fixes #46062.

git-svn-id: https://develop.svn.wordpress.org/trunk@44697 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2019-01-24 11:23:28 +00:00
parent 3b14a06c8c
commit e01f30ae20
1 changed files with 12 additions and 4 deletions

View File

@ -1064,12 +1064,20 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}
}
// For full height editor.
editor.on( 'resizewindow scrollwindow', hide );
// For scrollable editor.
editor.dom.bind( editor.getWin(), 'resize scroll', hide );
editor.dom.bind( editor.getWin(), 'resize', hide );
if ( editor.inline ) {
// Enable `capture` for the event.
// This will hide/reposition the toolbar on any scrolling in the document.
document.addEventListener( 'scroll', hide, true );
} else {
editor.dom.bind( editor.getWin(), 'scroll', hide );
// For full height iframe editor.
editor.on( 'resizewindow scrollwindow', hide );
}
editor.on( 'remove', function() {
document.removeEventListener( 'scroll', hide, true );
editor.off( 'resizewindow scrollwindow', hide );
editor.dom.unbind( editor.getWin(), 'resize scroll', hide );
} );