Merge "Move the diff-mode selector to the new DifferenceEngineBeforeDiffTable hook"

This commit is contained in:
jenkins-bot 2023-04-28 17:23:09 +00:00 committed by Gerrit Code Review
commit 86568aff16
4 changed files with 17 additions and 12 deletions

View file

@ -222,7 +222,7 @@
"BeforePageDisplay": "MediaWiki\\Extension\\VisualEditor\\Hooks::onBeforePageDisplay",
"ChangeTagsListActive": "MediaWiki\\Extension\\VisualEditor\\Hooks::onListDefinedTags",
"CustomEditor": "MediaWiki\\Extension\\VisualEditor\\Hooks::onCustomEditor",
"DifferenceEngineViewHeader": "MediaWiki\\Extension\\VisualEditor\\Hooks::onDifferenceEngineViewHeader",
"DifferenceEngineBeforeDiffTable": "VisualEditorHooks",
"EditPage::showEditForm:fields": "MediaWiki\\Extension\\VisualEditor\\Hooks::onEditPageShowEditFormFields",
"GetBetaFeaturePreferences": "MediaWiki\\Extension\\VisualEditor\\Hooks::onGetBetaPreferences",
"GetPreferences": "MediaWiki\\Extension\\VisualEditor\\Hooks::onGetPreferences",
@ -242,6 +242,11 @@
],
"UserLoggedIn": "MediaWiki\\Extension\\VisualEditor\\Hooks::onUserLoggedIn"
},
"HookHandlers": {
"VisualEditorHooks": {
"class": "MediaWiki\\Extension\\VisualEditor\\Hooks"
}
},
"ResourceModules": {
"socket.io": {
"scripts": [

View file

@ -19,6 +19,7 @@ use ExtensionRegistry;
use Html;
use Language;
use MediaWiki;
use MediaWiki\Diff\Hook\DifferenceEngineBeforeDiffTableHook;
use MediaWiki\MediaWikiServices;
use MediaWiki\ResourceLoader\ResourceLoader;
use MediaWiki\User\UserIdentity;
@ -35,7 +36,7 @@ use Title;
use User;
use WebRequest;
class Hooks {
class Hooks implements DifferenceEngineBeforeDiffTableHook {
// Known parameters that VE does not handle
// TODO: Other params too?
@ -141,7 +142,7 @@ class Hooks {
* @param DifferenceEngine $diff The difference engine
* @return void
*/
public static function onDifferenceEngineViewHeader( DifferenceEngine $diff ) {
public function onDifferenceEngineBeforeDiffTable( DifferenceEngine $diff, array &$parts ) {
$services = MediaWikiServices::getInstance();
$veConfig = $services->getConfigFactory()
->makeConfig( 'visualeditor' );
@ -158,8 +159,7 @@ class Hooks {
] );
$output->addModules( 'ext.visualEditor.diffPage.init' );
$output->enableOOUI();
$output->addHTML(
'<div class="ve-init-mw-diffPage-diffMode">' .
$parts['ve-init-mw-diffPage-diffMode'] = '<div class="ve-init-mw-diffPage-diffMode">' .
// Will be replaced by a ButtonSelectWidget in JS
new ButtonGroupWidget( [
'items' => [
@ -177,8 +177,7 @@ class Hooks {
] )
]
] ) .
'</div>'
);
'</div>';
}
/**

View file

@ -7,11 +7,6 @@
@import 'mediawiki.mixins';
.ve-init-mw-diffPage-diffMode {
text-align: right;
margin: 1em 0;
}
.client-nojs .ve-init-mw-diffPage-diffMode {
display: none;
}

View file

@ -15,6 +15,7 @@
progress = new OO.ui.ProgressBarWidget( { classes: [ 've-init-mw-diffPage-loading' ] } ),
originalUrl = new URL( location.href ),
initMode = originalUrl.searchParams.get( 'diffmode' ) || mw.user.options.get( 'visualeditor-diffmode-historical' ) || 'source',
initType = originalUrl.searchParams.get( 'diff-type' ),
conf = mw.config.get( 'wgVisualEditorConfig' ),
pluginModules = conf.pluginModules.filter( mw.loader.getState );
@ -45,6 +46,11 @@
$wikitextDiffBody.toggleClass( 'oo-ui-element-hidden', isVisual );
var $revSlider = $( '.mw-revslider-container' );
$revSlider.toggleClass( 've-init-mw-diffPage-revSlider-visual', isVisual );
if ( initType === 'inline' ) {
$( 'body' )
.toggleClass( 'mw-diff-type-not-inline', isVisual )
.toggleClass( 'mw-diff-type-inline', !isVisual );
}
if ( isVisual ) {
// Highlight the headers using the same styles as the diff, to better indicate
// the meaning of headers when not using two-column diff.