@@ -45,16 +45,15 @@ const GlobalSettingsLoader = () => {
4545 */
4646 useEffect ( ( ) => {
4747 const editorBody = editorDom ?. closest ( 'body' )
48- if ( editorBody ) {
49- // No need to check for firstChild, since there will always be at least one
50- // e.g. the post title wrapper and the actual root container.
51- const firstChild = editorBody . firstChild
52- editorBody . insertBefore ( globalTypographyWrapper , firstChild )
53- editorBody . insertBefore ( globalColorWrapper , firstChild )
54- editorBody . insertBefore ( globalSpacingAndBorderWrapper , firstChild )
55- editorBody . insertBefore ( globalButtonsAndIconsWrapper , firstChild )
56- editorBody . insertBefore ( globalColorSchemesWrapper , firstChild )
57- editorBody . insertBefore ( globalPresetControlsWrapper , firstChild )
48+ const editorHead = editorBody ?. ownerDocument ?. head
49+
50+ if ( editorHead ) {
51+ editorHead . appendChild ( globalTypographyWrapper )
52+ editorHead . appendChild ( globalColorWrapper )
53+ editorHead . appendChild ( globalSpacingAndBorderWrapper )
54+ editorHead . appendChild ( globalButtonsAndIconsWrapper )
55+ editorHead . appendChild ( globalColorSchemesWrapper )
56+ editorHead . appendChild ( globalPresetControlsWrapper )
5857 }
5958 } , [ deviceType , editorDom ] )
6059
@@ -78,12 +77,12 @@ globalButtonsAndIconsWrapper?.setAttribute( 'id', 'stk-global-buttons-and-icons-
7877globalColorSchemesWrapper ?. setAttribute ( 'id' , 'stk-global-color-schemes-styles' )
7978globalPresetControlsWrapper ?. setAttribute ( 'id' , 'stk-global-preset-controls-styles' )
8079domReady ( ( ) => {
81- document ?. body ?. appendChild ( globalTypographyWrapper )
82- document ?. body ?. appendChild ( globalColorWrapper )
83- document ?. body ?. appendChild ( globalSpacingAndBorderWrapper )
84- document ?. body ?. appendChild ( globalButtonsAndIconsWrapper )
85- document ?. body ?. appendChild ( globalColorSchemesWrapper )
86- document ?. body ?. appendChild ( globalPresetControlsWrapper )
80+ document ?. head ?. appendChild ( globalTypographyWrapper )
81+ document ?. head ?. appendChild ( globalColorWrapper )
82+ document ?. head ?. appendChild ( globalSpacingAndBorderWrapper )
83+ document ?. head ?. appendChild ( globalButtonsAndIconsWrapper )
84+ document ?. head ?. appendChild ( globalColorSchemesWrapper )
85+ document ?. head ?. appendChild ( globalPresetControlsWrapper )
8786 createRoot ( globalTypographyWrapper ) . render ( < GlobalTypographyStyles /> )
8887 createRoot ( globalColorWrapper ) . render ( < GlobalColorStyles /> )
8988 createRoot ( globalSpacingAndBorderWrapper ) . render ( < GlobalSpacingAndBordersStyles /> )
0 commit comments