mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Refactor how namespaces with subpages are exposed to JavaScript"
This commit is contained in:
commit
02e3aff969
|
@ -1008,14 +1008,19 @@ class VisualEditorHooks {
|
||||||
);
|
);
|
||||||
|
|
||||||
$namespacesWithSubpages = $coreConfig->get( 'NamespacesWithSubpages' );
|
$namespacesWithSubpages = $coreConfig->get( 'NamespacesWithSubpages' );
|
||||||
// $namespacesWithSubpages is a map of namespace id to boolean value, we want
|
// Export as a list of namespaces where subpages are enabled instead of an object
|
||||||
// to filter out namespaces that don't exist, not need to include those and it
|
// mapping namespaces to if subpages are enabled or not, so filter out disabled
|
||||||
// would increase the JavaScript config size. See T291727
|
// namespaces and then just use the keys. See T291729.
|
||||||
|
$namespacesWithSubpages = array_filter( $namespacesWithSubpages );
|
||||||
|
$namespacesWithSubpagesEnabled = array_keys( $namespacesWithSubpages );
|
||||||
|
// $wgNamespacesWithSubpages can include namespaces that don't exist, no need
|
||||||
|
// to include those in the JavaScript data. See T291727.
|
||||||
|
// Run this filtering after the filter for subpages being enabled, to reduce
|
||||||
|
// the number of calls needed to namespace info.
|
||||||
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
||||||
$namespacesWithSubpages = array_filter(
|
$namespacesWithSubpagesEnabled = array_filter(
|
||||||
$namespacesWithSubpages,
|
$namespacesWithSubpagesEnabled,
|
||||||
[ $nsInfo, 'exists' ],
|
[ $nsInfo, 'exists' ]
|
||||||
ARRAY_FILTER_USE_KEY
|
|
||||||
);
|
);
|
||||||
$vars['wgVisualEditorConfig'] = [
|
$vars['wgVisualEditorConfig'] = [
|
||||||
'usePageImages' => $extensionRegistry->isLoaded( 'PageImages' ),
|
'usePageImages' => $extensionRegistry->isLoaded( 'PageImages' ),
|
||||||
|
@ -1046,7 +1051,7 @@ class VisualEditorHooks {
|
||||||
$veConfig->get( 'VisualEditorEnableWikitextBetaFeature' )
|
$veConfig->get( 'VisualEditorEnableWikitextBetaFeature' )
|
||||||
),
|
),
|
||||||
'useChangeTagging' => $veConfig->get( 'VisualEditorUseChangeTagging' ),
|
'useChangeTagging' => $veConfig->get( 'VisualEditorUseChangeTagging' ),
|
||||||
'namespacesWithSubpages' => $namespacesWithSubpages,
|
'namespacesWithSubpages' => $namespacesWithSubpagesEnabled,
|
||||||
'specialBooksources' => urldecode( SpecialPage::getTitleFor( 'Booksources' )->getPrefixedURL() ),
|
'specialBooksources' => urldecode( SpecialPage::getTitleFor( 'Booksources' )->getPrefixedURL() ),
|
||||||
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),
|
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),
|
||||||
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
||||||
|
|
|
@ -112,7 +112,7 @@ ve.ui.MWInternalLinkAnnotationWidget.prototype.onTextChange = function ( value )
|
||||||
value = targetData.title;
|
value = targetData.title;
|
||||||
this.input.query.setValue( targetData.title );
|
this.input.query.setValue( targetData.title );
|
||||||
}
|
}
|
||||||
} else if ( namespacesWithSubpages[ basePageObj.namespace ] && value[ 0 ] === '/' ) {
|
} else if ( namespacesWithSubpages.indexOf( basePageObj.namespace ) !== -1 && value[ 0 ] === '/' ) {
|
||||||
// This does make it more-difficult to deliberately link to a page in the
|
// This does make it more-difficult to deliberately link to a page in the
|
||||||
// default namespace that starts with a / when you're on a subpage-allowing
|
// default namespace that starts with a / when you're on a subpage-allowing
|
||||||
// namespace. However, the exact same trick you need to know to make it work
|
// namespace. However, the exact same trick you need to know to make it work
|
||||||
|
|
Loading…
Reference in a new issue