Fomafix has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378026 )

Change subject: Wrap preview with lang und dir attributes
......................................................................

Wrap preview with lang und dir attributes

Like live preview in core the content should wrapped by a
<div lang="$lang" dir="$dir" class="mw-content-$dir"> container.

This ensures the right direction of the preview on mixed directions
where the direction of the user interface language differ to the
direction of the content language.

Change-Id: I2606355db4f786005149580373dbee4e3d843661
---
M modules/jquery.wikiEditor.preview.js
1 file changed, 15 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiEditor 
refs/changes/26/378026/1

diff --git a/modules/jquery.wikiEditor.preview.js 
b/modules/jquery.wikiEditor.preview.js
index d25dbd1..b80311b 100644
--- a/modules/jquery.wikiEditor.preview.js
+++ b/modules/jquery.wikiEditor.preview.js
@@ -55,7 +55,8 @@
                                                if ( 
context.modules.preview.previewText === wikitext ) {
                                                        return;
                                                }
-                                               
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty();
+                                               
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' )
+                                                       .children( 
'.mw-content-ltr,.mw-content-rtl' ).empty();
                                                
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show();
                                                api.post( {
                                                        formatversion: 2,
@@ -71,7 +72,7 @@
                                                } ).always( function () {
                                                        
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide();
                                                } ).done( function ( data ) {
-                                                       var loadmodules, 
$content;
+                                                       var loadmodules, 
$wikiPreview, $content;
                                                        if ( !data.parse || 
!data.parse.text ) {
                                                                return;
                                                        }
@@ -86,7 +87,9 @@
                                                        mw.loader.load( 
loadmodules );
 
                                                        
context.modules.preview.previewText = wikitext;
-                                                       $content = 
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' )
+                                                       $wikiPreview = 
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' );
+                                                       $content = 
$wikiPreview.children( '.mw-content-ltr,.mw-content-rtl' );
+                                                       $content
                                                                .detach()
                                                                .html( 
data.parse.text );
                                                        $content.append( '<div 
class="visualClear"></div>' )
@@ -94,7 +97,7 @@
                                                                        .click( 
false );
 
                                                        mw.hook( 
'wikipage.content' ).fire( $content );
-                                                       
context.modules.preview.$preview.append( $content );
+                                                       $wikiPreview.append( 
$content );
                                                } );
                                        }
                                } );
@@ -169,6 +172,14 @@
                                        )
                                        .append( $( '<div>' )
                                                .addClass( 
'wikiEditor-preview-contents' )
+                                               .append(
+                                                       $( '<div>' )
+                                                       .attr( {
+                                                               lang: 
context.$textarea.attr( 'lang' ),
+                                                               dir: 
context.$textarea.attr( 'dir' )
+                                                       } )
+                                                       .addClass( 
'mw-content-' + context.$textarea.attr( 'dir' ) )
+                                               )
                                        );
                                context.$changesTab.find( 
'.wikiEditor-preview-contents' )
                                        .html( '<table class="diff"><col 
class="diff-marker"/><col class="diff-content"/>' +

-- 
To view, visit https://gerrit.wikimedia.org/r/378026
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2606355db4f786005149580373dbee4e3d843661
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiEditor
Gerrit-Branch: master
Gerrit-Owner: Fomafix <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to