diff --git a/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js b/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js index 5b3d99de..3170a54a 100644 --- a/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js +++ b/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js @@ -278,6 +278,10 @@ ve.ui.CodeMirrorAction.prototype.getPosFromOffset = function ( veOffset ) { /* Registration */ // eslint-disable-next-line no-jquery/no-global-selector -if ( $( '.mw-body-content .mw-parser-output' ).attr( 'dir' ) === 'ltr' ) { +var contentDir = $( '.mw-body-content .mw-parser-output' ).attr( 'dir' ) || + // New pages will use wgPageContentLanguage which is set on the html element. + document.documentElement.dir; + +if ( contentDir === 'ltr' ) { ve.ui.actionFactory.register( ve.ui.CodeMirrorAction ); } diff --git a/resources/modules/ve-cm/ve.ui.CodeMirrorTool.js b/resources/modules/ve-cm/ve.ui.CodeMirrorTool.js index ea23c29d..f3e42b18 100644 --- a/resources/modules/ve-cm/ve.ui.CodeMirrorTool.js +++ b/resources/modules/ve-cm/ve.ui.CodeMirrorTool.js @@ -83,13 +83,15 @@ ve.ui.CodeMirrorTool.prototype.onSurfaceChange = function ( oldSurface, newSurfa ve.ui.CodeMirrorTool.prototype.onUpdateState = function () {}; // eslint-disable-next-line no-jquery/no-global-selector -if ( $( '.mw-body-content .mw-parser-output' ).attr( 'dir' ) === 'ltr' ) { - /* Registration */ +var contentDir = $( '.mw-body-content .mw-parser-output' ).attr( 'dir' ) || + // New pages will use wgPageContentLanguage which is set on the html element. + document.documentElement.dir; +if ( contentDir === 'ltr' ) { + /* Registration */ ve.ui.toolFactory.register( ve.ui.CodeMirrorTool ); /* Command */ - ve.ui.commandRegistry.register( new ve.ui.Command( 'codeMirror', 'codeMirror', 'toggle'