Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284680

Change subject: Allow extensions to support extra namespaces and content models
......................................................................

Allow extensions to support extra namespaces and content models

Change-Id: If67bab93da355da609b6df274514b5c72a6ed91a
---
M ApiVisualEditor.php
M ApiVisualEditorEdit.php
M VisualEditor.hooks.php
M extension.json
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
5 files changed, 19 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/80/284680/1

diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index 535f430..ab05eaa 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -289,7 +289,10 @@
 
                $isSafeAction = in_array( $params['paction'], 
self::$SAFE_ACTIONS, true );
 
-               $availableNamespaces = $this->veConfig->get( 
'VisualEditorAvailableNamespaces' );
+               $availableNamespaces = array_replace(
+                       ExtensionRegistry::getInstance()->getAttribute( 
'VisualEditorAvailableNamespaces' ),
+                       $this->veConfig->get( 'VisualEditorAvailableNamespaces' 
)
+               );
                if ( !$isSafeAction && (
                        !isset( $availableNamespaces[$title->getNamespace()] ) 
||
                        !$availableNamespaces[$title->getNamespace()]
diff --git a/ApiVisualEditorEdit.php b/ApiVisualEditorEdit.php
index b334256..edb40ec 100644
--- a/ApiVisualEditorEdit.php
+++ b/ApiVisualEditorEdit.php
@@ -126,7 +126,10 @@
                if ( !$page ) {
                        $this->dieUsageMsg( 'invalidtitle', $params['page'] );
                }
-               $availableNamespaces = $this->veConfig->get( 
'VisualEditorAvailableNamespaces' );
+               $availableNamespaces = array_replace(
+                       ExtensionRegistry::getInstance()->getAttribute( 
'VisualEditorAvailableNamespaces' ),
+                       $this->veConfig->get( 'VisualEditorAvailableNamespaces' 
)
+               );
                if ( !isset( $availableNamespaces[$page->getNamespace()] ) ||
                        !$availableNamespaces[$page->getNamespace()] ) {
                        $this->dieUsage( "VisualEditor is not enabled in 
namespace " .
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 3c6fe77..e2f4b87 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -672,13 +672,20 @@
                $defaultUserOptions = $coreConfig->get( 'DefaultUserOptions' );
                $thumbLimits = $coreConfig->get( 'ThumbLimits' );
                $veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 
'visualeditor' );
-               $availableNamespaces = $veConfig->get( 
'VisualEditorAvailableNamespaces' );
+               $availableNamespaces = array_replace(
+                       ExtensionRegistry::getInstance()->getAttribute( 
'VisualEditorAvailableNamespaces' ),
+                       $veConfig->get( 'VisualEditorAvailableNamespaces' )
+               );
                $enabledNamespaces = array_keys( array_filter( 
$availableNamespaces ) );
 
                $vars['wgVisualEditorConfig'] = [
                        'disableForAnons' => $veConfig->get( 
'VisualEditorDisableForAnons' ),
                        'preferenceModules' => $veConfig->get( 
'VisualEditorPreferenceModules' ),
                        'namespaces' => $enabledNamespaces,
+                       'contentModels' =>  array_merge(
+                               ExtensionRegistry::getInstance()->getAttribute( 
'VisualEditorAvailableContentModels' ),
+                               $veConfig->get( 
'VisualEditorAvailableContentModels' )
+                       ),
                        'signatureNamespaces' => array_values(
                                array_filter( $enabledNamespaces, 
'MWNamespace::wantSignatures' )
                        ),
diff --git a/extension.json b/extension.json
index a29c674..be6f50a 100644
--- a/extension.json
+++ b/extension.json
@@ -101,6 +101,7 @@
                        "2": true,
                        "_merge_strategy": "array_plus"
                },
+               "VisualEditorAvailableContentModels": [ "wikitext" ],
                "VisualEditorSkinToolbarScrollOffset": [],
                "VisualEditorParsoidTimeout": 100,
                "VisualEditorUseSingleEditTab": false,
diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js 
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
index d84afcd..58e362a 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
@@ -651,8 +651,8 @@
                // Not on pages which are outputs of the Page Translation 
feature
                mw.config.get( 'wgTranslatePageTranslation' ) !== 'translation' 
&&
 
-               // Only for pages with a wikitext content model
-               mw.config.get( 'wgPageContentModel' ) === 'wikitext'
+               // Only for pages with a supported content model
+               conf.contentModels.indexOf( mw.config.get( 'wgPageContentModel' 
) ) !== -1
        );
 
        // FIXME: We should do this more elegantly

-- 
To view, visit https://gerrit.wikimedia.org/r/284680
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If67bab93da355da609b6df274514b5c72a6ed91a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to