@@ -14,16 +14,11 @@ import initLoader from '../lib/loader';
14
14
initLoader ( ) . then ( ( monaco ) => {
15
15
let isMonacoEditorEnabled = false ;
16
16
17
- const isEditorEnabled = null !== document . getElementById ( 'content' ) ;
18
- const isVisualEditorEnabled =
19
- null !== document . getElementById ( 'content-tmce' ) &&
20
- null !== document . getElementById ( 'content-html' ) ;
17
+ const isEditorEnabled = ! ! document . getElementById ( 'content' ) ;
21
18
22
- const cookieHtml = document . cookie . indexOf ( 'editor%3Dhtml' ) ;
23
- const cookieTinyMce = document . cookie . indexOf ( 'editor%3Dtinymce' ) ;
24
- const isVisualEditMode =
25
- ( - 1 === cookieHtml && - 1 !== cookieTinyMce ) ||
26
- ( - 1 !== cookieHtml && - 1 !== cookieTinyMce && cookieTinyMce > cookieHtml ) ;
19
+ if ( ! isEditorEnabled ) {
20
+ return ;
21
+ }
27
22
28
23
const tabTmce = document . getElementById ( 'content-tmce' ) ;
29
24
const tabHtml = document . getElementById ( 'content-html' ) ;
@@ -308,20 +303,21 @@ initLoader().then( ( monaco ) => {
308
303
} ;
309
304
310
305
// Initialize
311
- if ( ! isEditorEnabled ) {
312
- return ;
313
- }
314
-
315
306
runObserve ( ) ;
316
307
317
- if ( ! isVisualEditorEnabled ) {
318
- runEditor ( ) ;
319
- replaceIndentButton . style . display = 'inline-block' ;
320
- } else if ( isVisualEditMode ) {
321
- tabHtml . onclick = toHtml ;
308
+ const isVisualEditorEnabled = document
309
+ . getElementById ( 'wp-content-wrap' )
310
+ . classList . contains ( 'tmce-active' ) ;
311
+
312
+ if ( isVisualEditorEnabled ) {
313
+ if ( tabHtml ) {
314
+ tabHtml . onclick = toHtml ;
315
+ }
322
316
} else {
323
317
runEditor ( ) ;
324
318
replaceIndentButton . style . display = 'inline-block' ;
325
- tabTmce . onclick = toVisual ;
319
+ if ( tabTmce ) {
320
+ tabTmce . onclick = toVisual ;
321
+ }
326
322
}
327
323
} ) ;
0 commit comments