Mholloway has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/278087

Change subject: Restore lead paragraph shifting to work with section divs
......................................................................

Restore lead paragraph shifting to work with section divs

Restored this functionality & tested it on en Barack Obama and the cases
in T111958.

This patch and the patch it depends on fix  the bug with incorrect section
output leading to incorrect section editing in the app.

Bug: T65874
Change-Id: Iaa2007128e83663eff8044fa2703fc809d187eaf
---
M lib/parsoid-access.js
M lib/transformations/relocateFirstParagraph.js
2 files changed, 10 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/87/278087/1

diff --git a/lib/parsoid-access.js b/lib/parsoid-access.js
index 15b4db6..a2e280e 100644
--- a/lib/parsoid-access.js
+++ b/lib/parsoid-access.js
@@ -236,7 +236,7 @@
             // content if this turns out to be a main page.
             //
             // TODO: should we also exclude file and other special pages?
-            //relocateFirstParagraph(doc);
+            relocateFirstParagraph(doc);
 
             page.sections = getSectionsText(doc);
             return page;
diff --git a/lib/transformations/relocateFirstParagraph.js 
b/lib/transformations/relocateFirstParagraph.js
index cf4b4fa..c4dd567 100644
--- a/lib/transformations/relocateFirstParagraph.js
+++ b/lib/transformations/relocateFirstParagraph.js
@@ -65,8 +65,8 @@
 // between the first paragraph as designated by <p></p> tags and other elements
 // (such as an unnumbered list) that may also be intended as part of the first
 // display paragraph.  See T111958.
-function createLeadSpan( content, childNodes ) {
-    var leadSpan = content.createElement( 'span' );
+function createLeadSpan( doc, childNodes ) {
+    var leadSpan = doc.createElement( 'span' );
     var firstGoodParagraphIndex = findFirstGoodParagraphIn( childNodes );
     if ( firstGoodParagraphIndex ) {
         addNode( leadSpan, childNodes[ firstGoodParagraphIndex ] );
@@ -80,20 +80,19 @@
 // to the top of the lead section.
 // This will have the effect of shifting the infobox and/or any images at the 
top of the page
 // below the first paragraph, allowing the user to start reading the page 
right away.
-function moveFirstGoodParagraphUp(content) {
-
-    var block_0 = content.body;
-    if ( !block_0 ) {
+function moveFirstGoodParagraphUp(doc) {
+    var leadSection = doc.getElementById('section_0');
+    if ( !leadSection ) {
         return;
     }
 
-    var block_0_children = block_0.childNodes;
-    if ( !block_0_children ) {
+    var childNodes = leadSection.childNodes;
+    if ( !childNodes ) {
         return;
     }
 
-    var leadSpan = createLeadSpan( content, block_0_children );
-    block_0.insertBefore( leadSpan, block_0.firstChild );
+    var leadSpan = createLeadSpan( doc, childNodes );
+    leadSection.insertBefore( leadSpan, leadSection.firstChild );
 }
 
 module.exports = moveFirstGoodParagraphUp;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa2007128e83663eff8044fa2703fc809d187eaf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to