mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +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 is a map of namespace id to boolean value, we want
|
||||
// to filter out namespaces that don't exist, not need to include those and it
|
||||
// would increase the JavaScript config size. See T291727
|
||||
// Export as a list of namespaces where subpages are enabled instead of an object
|
||||
// mapping namespaces to if subpages are enabled or not, so filter out disabled
|
||||
// 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();
|
||||
$namespacesWithSubpages = array_filter(
|
||||
$namespacesWithSubpages,
|
||||
[ $nsInfo, 'exists' ],
|
||||
ARRAY_FILTER_USE_KEY
|
||||
$namespacesWithSubpagesEnabled = array_filter(
|
||||
$namespacesWithSubpagesEnabled,
|
||||
[ $nsInfo, 'exists' ]
|
||||
);
|
||||
$vars['wgVisualEditorConfig'] = [
|
||||
'usePageImages' => $extensionRegistry->isLoaded( 'PageImages' ),
|
||||
|
@ -1046,7 +1051,7 @@ class VisualEditorHooks {
|
|||
$veConfig->get( 'VisualEditorEnableWikitextBetaFeature' )
|
||||
),
|
||||
'useChangeTagging' => $veConfig->get( 'VisualEditorUseChangeTagging' ),
|
||||
'namespacesWithSubpages' => $namespacesWithSubpages,
|
||||
'namespacesWithSubpages' => $namespacesWithSubpagesEnabled,
|
||||
'specialBooksources' => urldecode( SpecialPage::getTitleFor( 'Booksources' )->getPrefixedURL() ),
|
||||
'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ),
|
||||
'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ),
|
||||
|
|
|
@ -112,7 +112,7 @@ ve.ui.MWInternalLinkAnnotationWidget.prototype.onTextChange = function ( value )
|
|||
value = 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
|
||||
// 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
|
||||
|
|
Loading…
Reference in a new issue