mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 22:03:28 +00:00
ext.CodeMirror.visualEditor: check language dir of html for new pages
New pages do not have body content yet, so the LTR check added with If3825d6e54 failed. This commit adds the document root (<html> element) as the fallback, so CodeMirror can be used on new pages. This is just a quick fix. CM6 for VE 2017 wikitext editor is almost done, and that will come with RTL support (T357482). Bug: T366201 Bug: T363752 Follow-Up: If3825d6e5467d2bcff2d83e838081bf041243920 Change-Id: I9d4a4b817ac2462396c159ceae6f1510c0fae64d
This commit is contained in:
parent
0c7044e764
commit
293a15725d
|
@ -278,6 +278,10 @@ ve.ui.CodeMirrorAction.prototype.getPosFromOffset = function ( veOffset ) {
|
||||||
/* Registration */
|
/* Registration */
|
||||||
|
|
||||||
// eslint-disable-next-line no-jquery/no-global-selector
|
// 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 );
|
ve.ui.actionFactory.register( ve.ui.CodeMirrorAction );
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,13 +83,15 @@ ve.ui.CodeMirrorTool.prototype.onSurfaceChange = function ( oldSurface, newSurfa
|
||||||
ve.ui.CodeMirrorTool.prototype.onUpdateState = function () {};
|
ve.ui.CodeMirrorTool.prototype.onUpdateState = function () {};
|
||||||
|
|
||||||
// eslint-disable-next-line no-jquery/no-global-selector
|
// 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' ) ||
|
||||||
/* Registration */
|
// 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 );
|
ve.ui.toolFactory.register( ve.ui.CodeMirrorTool );
|
||||||
|
|
||||||
/* Command */
|
/* Command */
|
||||||
|
|
||||||
ve.ui.commandRegistry.register(
|
ve.ui.commandRegistry.register(
|
||||||
new ve.ui.Command(
|
new ve.ui.Command(
|
||||||
'codeMirror', 'codeMirror', 'toggle'
|
'codeMirror', 'codeMirror', 'toggle'
|
||||||
|
|
Loading…
Reference in a new issue