ve.collab: Create BetaFeature

Change-Id: I36b8361f4fce8d690841e9048498bd5d52131942
This commit is contained in:
Ed Sanders 2024-03-04 21:29:36 +00:00 committed by David Chan
parent 2359b587ed
commit b3853721c8
6 changed files with 137 additions and 2 deletions

View file

@ -108,6 +108,10 @@
"VisualEditorRebaserURL": {
"value": false
},
"VisualEditorEnableCollabBeta": {
"description": "Enable the experimental ve.collab beta feature.",
"value": false
},
"VisualEditorShowBetaWelcome": {
"value": true
},
@ -222,6 +226,7 @@
"TextSlotDiffRendererTablePrefix": "VisualEditorHooks",
"EditPage::showEditForm:fields": "VisualEditorHooks",
"GetPreferences": "VisualEditorHooks",
"GetBetaFeaturePreferences": "VisualEditorHooks",
"ListDefinedTags": "VisualEditorHooks",
"MakeGlobalVariablesScript": "VisualEditorHooks",
"OutputPageBodyAttributes": "VisualEditorHooks",
@ -2741,6 +2746,7 @@
"DefaultUserOptions": {
"visualeditor-autodisable": 0,
"visualeditor-betatempdisable": 0,
"visualeditor-collab": 0,
"visualeditor-editor": "visualeditor",
"visualeditor-enable": 0,
"visualeditor-hidebetawelcome": 0,

View file

@ -333,6 +333,10 @@
"visualeditor-preference-tabs-prefer-ve": "Always give me the visual editor if possible",
"visualeditor-preference-tabs-prefer-wt": "Always give me the source editor",
"visualeditor-preference-tabs-remember-last": "Remember my last editor",
"visualeditor-preference-collab-label": "Collaborative editing",
"visualeditor-preference-collab-description": "Invite other users to join your edit session in the visual editor.",
"visualeditor-preference-collab-info-link": "//mediawiki.org/wiki/VisualEditor/Real-time_collaboration",
"visualeditor-preference-collab-discussion-link": "//mediawiki.org/wiki/VisualEditor/Talk:Real-time_collaboration",
"visualeditor-quick-access-characters.json": "null",
"visualeditor-rebase-client-export": "Export",
"visualeditor-rebase-client-export-start": "Export…",

View file

@ -354,6 +354,10 @@
"visualeditor-preference-tabs-prefer-ve": "Used in [[Special:Preferences]].\n\nUsed as label for a radio button to have VisualEditor be the preferred editor. Shown together with the following buttons, so consider formulating them consistently:\n* {{msg-mw|Visualeditor-preference-tabs-multi-tab}}\n* {{msg-mw|Visualeditor-preference-tabs-prefer-wt}}\n* {{msg-mw|Visualeditor-preference-tabs-remember-last}}",
"visualeditor-preference-tabs-prefer-wt": "Used in [[Special:Preferences]].\n\nUsed as label for a radio button to have the wikitext editor be the preferred editor. Shown together with the following buttons, so consider formulating them consistently:\n* {{msg-mw|Visualeditor-preference-tabs-multi-tab}}\n* {{msg-mw|Visualeditor-preference-tabs-prefer-ve}}\n* {{msg-mw|Visualeditor-preference-tabs-remember-last}}",
"visualeditor-preference-tabs-remember-last": "Used in [[Special:Preferences]].\n\nUsed as label for a radio button to have VisualEditor remember whether it was the last editor or not. Shown together with the following buttons, so consider formulating them consistently:\n* {{msg-mw|Visualeditor-preference-tabs-multi-tab}}\n* {{msg-mw|Visualeditor-preference-tabs-prefer-ve}}\n* {{msg-mw|Visualeditor-preference-tabs-prefer-wt}}",
"visualeditor-preference-collab-label": "Used in [[Special:Preferences]].\n\nUsed as label for checkbox to enable collaborative editing.\n\nThe description for this checkbox is {{msg-mw|visualeditor-preference-collab-description}}",
"visualeditor-preference-collab-description": "Used in [[Special:Preferences]].\n\nUsed as description for the checkbox to enable collaborative editing.\n\nThe label for this checkbox is {{msg-mw|visualeditor-preference-collab-label}}.",
"visualeditor-preference-collab-info-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can learn about this Beta Feature. Defaults to a page on MediaWiki.org.}}",
"visualeditor-preference-collab-discussion-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can discuss this Beta Feature. Defaults to a page on MediaWiki.org.}}",
"visualeditor-quick-access-characters.json": "{{notranslate}}\n{{ignored}}\nJSON object mapping character labels to actual characters that can be inserted using the special character inserter.",
"visualeditor-rebase-client-export": "Label for button to export a document\n{{Identical|Export}}",
"visualeditor-rebase-client-export-start": "Label for button to start a process to export a document\n\nSee also:\n* {{msg-mw|visualeditor-rebase-client-export}}",

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="264" height="162" version="1.1" viewBox="0 0 264 162" xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="jagged-edge">
<path d="M0 0v152l12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10V0z"/>
</clipPath>
</defs>
<g clip-path="url(#jagged-edge)" fill="#eaecf0">
<path id="background" d="M0 0h264v162H0" fill="#fff"/>
<path id="logo" d="M11 22c0-8 6-14 14-14s14 6 14 14-6 14-14 14-14-6-14-14M38 45v-5H13v5h25"/>
<path id="sidebar" d="M38 163V58H13v106h25"/>
<path id="personal-tools" d="M233 5h26v6h-26V5zm-24 0h22v6h-22zm-24 0h22v6h-22zm-23 0h13v6h-13zm15 0h6v6h-6zm-23 0h6v6h-6z"/>
<path id="search-input" d="m258 16v4h-92v-4h92m1-1h-94v6h94v-6z"/>
<path id="search-icon" d="m168 17h2v2h-2z"/>
<path id="article" d="M252 162V29H48v133z"/>
<path id="border" d="M0 0v162h264V0zm1 1h262v150.533l-11 9.166-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-11-9.167z"/>
<path d="m48.083 29h204.08v20.75h-204.08z" fill="#cdd1d6"/>
<path d="m59 58.333h54v6h-54z" fill="#c8ccd1"/>
<path d="M240 70.334h-39v30h39zm-26.348 13.043h1.403l8.7 8.604 4.725-2.833 7.117 5.943v.025H204.45z" fill="#a2a9b1" opacity=".412"/>
<path d="M59 34.333h25v10H59v-10zm33.5 0h10v10h-10zm17 0h10v10h-10z" fill="#fff"/>
</g>
<g transform="translate(0 -3.9153)" stroke-linecap="round" stroke-width="4.0828">
<g stroke="#ccc">
<path d="m61.006 76.662h31.982"/>
<path d="m101.83 76.662h29.941"/>
<path d="m140.62 76.662h49.674"/>
</g>
<path d="m61.006 86.272h93.905" stroke="#ffcb33"/>
<path d="m163.08 86.272h27.219" stroke="#ccc"/>
<path d="m61.006 95.881h57.84" stroke="#e857c8"/>
<g stroke="#ccc">
<path d="m127.69 95.881h62.603"/>
<path d="m61.006 105.49h11.568"/>
<path d="m81.42 105.49h53.077"/>
</g>
<path d="m143.34 105.49h46.952" stroke="#00af89"/>
<g stroke="#ccc">
<path d="m61.006 115.1h177.16"/>
<path d="m61.006 124.71h46.272"/>
<path d="m116.12 124.71h121.48"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="264" height="162" version="1.1" viewBox="0 0 264 162" xmlns="http://www.w3.org/2000/svg">
<defs>
<clipPath id="jagged-edge">
<path d="M0 0v152l12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10V0z"/>
</clipPath>
</defs>
<g transform="matrix(-1 0 0 1 264 0)" clip-path="url(#jagged-edge)" fill="#eaecf0">
<path id="background" d="M0 0h264v162H0" fill="#fff"/>
<path id="logo" d="M11 22c0-8 6-14 14-14s14 6 14 14-6 14-14 14-14-6-14-14M38 45v-5H13v5h25"/>
<path id="sidebar" d="M38 163V58H13v106h25"/>
<path id="personal-tools" d="M233 5h26v6h-26V5zm-24 0h22v6h-22zm-24 0h22v6h-22zm-23 0h13v6h-13zm15 0h6v6h-6zm-23 0h6v6h-6z"/>
<path id="search-input" d="m258 16v4h-92v-4h92m1-1h-94v6h94v-6z"/>
<path id="search-icon" d="m168 17h2v2h-2z"/>
<path id="article" d="M252 162V29H48v133z"/>
<path id="border" d="M0 0v162h264V0zm1 1h262v150.533l-11 9.166-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-11-9.167z"/>
<path d="m48.083 29h204.08v20.75h-204.08z" fill="#cdd1d6"/>
<path d="M240 70.334h-39v30h39zm-26.348 13.043h1.403l8.7 8.604 4.725-2.833 7.117 5.943v.025H204.45z" fill="#a2a9b1" opacity=".412"/>
<path d="M59 34.333h25v10H59v-10zm33.5 0h10v10h-10zm17 0h10v10h-10z" fill="#fff"/>
<g transform="translate(0 -3.9153)" stroke-linecap="round" stroke-width="4.0828">
<g stroke="#ccc">
<path d="m61.006 76.662h31.982"/>
<path d="m101.83 76.662h29.941"/>
<path d="m140.62 76.662h49.674"/>
</g>
<path d="m61.006 86.272h93.905" stroke="#ffcb33"/>
<path d="m163.08 86.272h27.219" stroke="#ccc"/>
<path d="m61.006 95.881h57.84" stroke="#e857c8"/>
<g stroke="#ccc">
<path d="m127.69 95.881h62.603"/>
<path d="m61.006 105.49h11.568"/>
<path d="m81.42 105.49h53.077"/>
</g>
<path d="m143.34 105.49h46.952" stroke="#00af89"/>
<g stroke="#ccc">
<path d="m61.006 115.1h177.16"/>
<path d="m61.006 124.71h46.272"/>
<path d="m116.12 124.71h121.48"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -25,6 +25,7 @@ use MediaWiki\ChangeTags\Hook\ListDefinedTagsHook;
use MediaWiki\Diff\Hook\DifferenceEngineViewHeaderHook;
use MediaWiki\Diff\Hook\TextSlotDiffRendererTablePrefixHook;
use MediaWiki\EditPage\EditPage;
use MediaWiki\Extension\BetaFeatures\Hooks\GetBetaFeaturePreferencesHook;
use MediaWiki\Hook\BeforeInitializeHook;
use MediaWiki\Hook\BeforePageDisplayHook;
use MediaWiki\Hook\CustomEditorHook;
@ -68,6 +69,7 @@ class Hooks implements
DifferenceEngineViewHeaderHook,
EditPage__showEditForm_fieldsHook,
GetPreferencesHook,
GetBetaFeaturePreferencesHook,
ListDefinedTagsHook,
MakeGlobalVariablesScriptHook,
OutputPageBodyAttributesHook,
@ -153,8 +155,11 @@ class Hooks implements
] );
$output->addModuleStyles( [ 'ext.visualEditor.desktopArticleTarget.noscript' ] );
}
// Joining a collab session
if ( $output->getRequest()->getVal( 'collabSession' ) ) {
if (
$services->getUserOptionsLookup()->getOption( $skin->getUser(), 'visualeditor-collab' ) ||
// Joining a collab session
$output->getRequest()->getVal( 'collabSession' )
) {
$output->addModules( 'ext.visualEditor.collab' );
}
@ -1045,6 +1050,37 @@ class Hooks implements
$preferences['visualeditor-findAndReplace-word'] = $api;
}
/**
* Handler for the GetBetaFeaturePreferences hook, to add and hide user beta preferences as configured
*
* @param User $user
* @param array &$preferences
*/
public function onGetBetaFeaturePreferences( User $user, array &$preferences ) {
$services = MediaWikiServices::getInstance();
$veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
if ( $veConfig->get( 'VisualEditorEnableCollabBeta' ) ) {
$coreConfig = RequestContext::getMain()->getConfig();
$iconpath = $coreConfig->get( 'ExtensionAssetsPath' ) . '/VisualEditor/images';
$preferences['visualeditor-collab'] = [
'version' => '1.0',
'label-message' => 'visualeditor-preference-collab-label',
'desc-message' => 'visualeditor-preference-collab-description',
'screenshot' => [
'ltr' => "$iconpath/betafeatures-icon-collab-ltr.svg",
'rtl' => "$iconpath/betafeatures-icon-collab-rtl.svg",
],
'info-message' => 'visualeditor-preference-collab-info-link',
'discussion-message' => 'visualeditor-preference-collab-discussion-link',
'requirements' => [
'javascript' => true
]
];
}
}
/**
* Implements the PreferencesFormPreSave hook, to remove the 'autodisable' flag
* when the user it was set on explicitly enables VE.