diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index d108b48..ade588c 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -19,6 +19,9 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { const OPTION_BACK_TO_TOP = 'backToTop'; const OPTION_TOGGLING = 'toggling'; const OPTIONS_MOBILE_BETA = 'beta'; + /** @const LEAD_SECTION_NUMBER integer which corresponds to the lead section + in editing mode */ + const LEAD_SECTION_NUMBER = 0; /** @var string $skinname Name of this skin */ public $skinname = 'minerva'; @@ -1063,6 +1066,13 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { * @return array A map compatible with BaseTemplate#makeListItem */ protected function createEditPageAction() { + $title = $this->getTitle(); + $editArgs = [ 'action' => 'edit' ]; + if ( $title->isWikitextPage() ) { + // If the content model is wikitext we'll default to editing the lead section. + // Full wikitext editing is not possible via the api and hard on mobile devices. + $editArgs['section'] = self::LEAD_SECTION_NUMBER; + } return [ 'id' => 'ca-edit', 'text' => '', @@ -1070,7 +1080,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { 'class' => MobileUI::iconClass( 'edit-enabled', 'element' ), 'links' => [ 'edit' => [ - 'href' => $this->getTitle()->getLocalURL( [ 'action' => 'edit', 'section' => 0 ] ) + 'href' => $title->getLocalURL( $editArgs ) ], ], 'is_js_only' => false @@ -1240,7 +1250,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { if ( !$title->isTalkPage() ) { $title = $title->getTalkPage(); } - return $title->getContentModel() === CONTENT_MODEL_WIKITEXT; + return $title->isWikitextPage(); } /** diff --git a/resources/skins.minerva.editor/init.js b/resources/skins.minerva.editor/init.js index c6b5b6d..862180b 100644 --- a/resources/skins.minerva.editor/init.js +++ b/resources/skins.minerva.editor/init.js @@ -24,6 +24,7 @@ popup = M.require( 'mobile.startup/toast' ), // FIXME: Disable on IE < 10 for time being blacklisted = /MSIE \d\./.test( navigator.userAgent ), + contentModel = mw.config.get( 'wgPageContentModel' ), isEditingSupported = router.isSupported() && !blacklisted, // FIXME: Use currentPage.getId() isNewPage = currentPage.options.id === 0, @@ -345,7 +346,11 @@ } ); } - if ( !isEditingSupported ) { + if ( contentModel !== 'wikitext' ) { + // Only load the wikitext editor on wikitext. Otherwise we'll rely on the fallback behaviour + // (You can test this on MediaWiki:Common.css) ?action=edit url (T173800) + return; + } else if ( !isEditingSupported ) { // Editing is disabled (or browser is blacklisted) $caEdit.removeClass( 'hidden' ); showSorryToast( mw.msg( 'mobile-frontend-editor-unavailable' ) );