@@ -12,6 +12,7 @@ import WysiwygInstanceInterface from "wysiwygAdapter";
12
12
import { AdditionalDataConfigInterface } from "../content-type-config.types" ;
13
13
import DataStore from "../data-store" ;
14
14
import checkStageFullScreen from "../utils/check-stage-full-screen" ;
15
+ import delayUntil from "../utils/delay-until" ;
15
16
import pageBuilderHeaderHeight from "../utils/pagebuilder-header-height" ;
16
17
import WysiwygInterface from "./wysiwyg-interface" ;
17
18
@@ -172,35 +173,39 @@ export default class Wysiwyg implements WysiwygInterface {
172
173
events . trigger ( "stage:interactionStart" ) ;
173
174
174
175
// Wait for everything else to finish
175
- _ . defer ( ( ) => {
176
- const $inlineToolbar = this . getFixedToolbarContainer ( ) . find ( ".tox-tinymce-inline" ) ;
177
- const self = this ;
178
-
179
- $inlineToolbar . css ( "min-width" , this . config . adapter_config . minToolbarWidth + "px" ) ;
180
-
181
- this . invertInlineEditorToAccommodateOffscreenToolbar ( ) ;
182
-
183
- // Update toolbar when the height changes
184
- this . toolbarHeight = $inlineToolbar . height ( ) ;
185
- if ( $inlineToolbar . length ) {
186
- this . resizeObserver = new ResizeObserver ( ( entries ) => {
187
- for ( const entry of entries ) {
188
- if ( entry . target === $inlineToolbar . get ( 0 )
189
- && entry . target . clientHeight !== self . toolbarHeight
190
- ) {
191
- self . invertInlineEditorToAccommodateOffscreenToolbar ( ) ;
192
- self . toolbarHeight = entry . target . clientHeight ;
176
+ _ . defer ( ( ) => delayUntil (
177
+ ( ) => {
178
+ const $inlineToolbar = this . getFixedToolbarContainer ( ) . find ( ".tox-tinymce-inline" ) ;
179
+ const self = this ;
180
+
181
+ $inlineToolbar . css ( "min-width" , this . config . adapter_config . minToolbarWidth + "px" ) ;
182
+
183
+ this . invertInlineEditorToAccommodateOffscreenToolbar ( ) ;
184
+
185
+ // Update toolbar when the height changes
186
+ this . toolbarHeight = $inlineToolbar . height ( ) ;
187
+ if ( $inlineToolbar . length ) {
188
+ this . resizeObserver = new ResizeObserver ( ( entries ) => {
189
+ for ( const entry of entries ) {
190
+ if ( entry . target === $inlineToolbar . get ( 0 )
191
+ && entry . target . clientHeight !== self . toolbarHeight
192
+ ) {
193
+ self . invertInlineEditorToAccommodateOffscreenToolbar ( ) ;
194
+ self . toolbarHeight = entry . target . clientHeight ;
195
+ }
193
196
}
194
- }
195
- } ) ;
196
- this . resizeObserver . observe ( $inlineToolbar . get ( 0 ) ) ;
197
- }
198
- const dialogContainer = document . querySelector ( `#${ this . elementId } ~ .tox-tinymce-aux` ) ;
199
- if ( ! ! dialogContainer ) {
200
- dialogContainer . setAttribute ( "data-editor-aux" , this . elementId ) ;
201
- document . body . appendChild ( dialogContainer ) ;
202
- }
203
- } ) ;
197
+ } ) ;
198
+ this . resizeObserver . observe ( $inlineToolbar . get ( 0 ) ) ;
199
+ }
200
+ const dialogContainer = document . querySelector ( `#${ this . elementId } ~ .tox-tinymce-aux` ) ;
201
+ if ( ! ! dialogContainer ) {
202
+ dialogContainer . setAttribute ( "data-editor-aux" , this . elementId ) ;
203
+ document . body . appendChild ( dialogContainer ) ;
204
+ }
205
+ } ,
206
+ ( ) => document . querySelector ( `#${ this . elementId } ` ) . classList . contains ( "mce-edit-focus" ) ,
207
+ 10 ,
208
+ ) ) ;
204
209
}
205
210
206
211
/**
0 commit comments