Allow editor access to the full page's wikitext

Make a new route which uses `#/editor/all` to trigger loading the full page's
text in the editor, rather than defaulting to the first section. This isn't
exposed through the UI, but will be what's used when intercepting action=edit
links, which already loaded the full page's wikitext in the non- overlay
editor.

Bug: T196915
Change-Id: I6c7e3443756fd72749964d1eda37e3d123b201b3
This commit is contained in:
David Lynch 2018-06-11 10:55:30 -05:00
parent 4a84008a84
commit 2d930cedbb
1 changed files with 6 additions and 3 deletions

View File

@ -165,7 +165,7 @@
router.navigate( '#/editor/' + $( this ).data( 'section' ) );
return false;
} );
overlayManager.add( /^\/editor\/(\d+)$/, function ( sectionId ) {
overlayManager.add( /^\/editor\/(\d+|all)$/, function ( sectionId ) {
var
$content = $( '#mw-content-text' ),
result = $.Deferred(),
@ -224,7 +224,9 @@
} );
}
editorOptions.sectionId = page.isWikiText() ? parseInt( sectionId, 10 ) : null;
if ( sectionId !== 'all' ) {
editorOptions.sectionId = page.isWikiText() ? +sectionId : null;
}
// Check whether VisualEditor should be loaded
if ( isVisualEditorEnabled &&
@ -317,11 +319,12 @@
editorOverride = 'SourceEditor';
}
// else: action=edit, for which we allow the default to take effect
fragment = '#/editor/' + ( mw.util.getParamValue( 'section' ) || '0' );
fragment = '#/editor/' + ( mw.util.getParamValue( 'section' ) || ( mw.util.getParamValue( 'action' ) === 'edit' && 'all' ) || '0' );
if ( window.history && history.pushState ) {
uri = mw.Uri();
delete uri.query.action;
delete uri.query.veaction;
delete uri.query.section;
// Note: replaceState rather than pushState, because we're
// just reformatting the URL to the equivalent-meaning for the
// mobile site.