2016-10-25 20:44:26 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization CollabTarget class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2016-10-25 20:44:26 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki mobile article target.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.init.mw.Target
|
|
|
|
*
|
|
|
|
* @constructor
|
2017-05-20 21:26:42 +00:00
|
|
|
* @param {mw.Title} title Page sub-title
|
2019-04-16 15:17:29 +00:00
|
|
|
* @param {string} rebaserUrl Rebaser server URL
|
2016-10-25 20:44:26 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2018-05-21 14:20:25 +00:00
|
|
|
* @cfg {mw.Title} [importTitle] Title to import
|
2016-10-25 20:44:26 +00:00
|
|
|
*/
|
2017-05-20 21:26:42 +00:00
|
|
|
ve.init.mw.CollabTarget = function VeInitMwCollabTarget( title, rebaserUrl, config ) {
|
2016-10-25 20:44:26 +00:00
|
|
|
config = config || {};
|
2021-11-15 17:25:51 +00:00
|
|
|
config.toolbarConfig = ve.extendObject( {
|
2016-10-25 20:44:26 +00:00
|
|
|
shadow: true,
|
|
|
|
actions: true,
|
|
|
|
floatable: true
|
|
|
|
}, config.toolbarConfig );
|
|
|
|
|
2017-05-20 21:26:42 +00:00
|
|
|
this.title = title;
|
|
|
|
this.rebaserUrl = rebaserUrl;
|
2018-08-12 15:13:00 +00:00
|
|
|
this.importTitle = config.importTitle || null;
|
2017-05-20 21:26:42 +00:00
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
// Parent constructor
|
|
|
|
ve.init.mw.CollabTarget.super.call( this, config );
|
|
|
|
|
2019-06-01 17:00:41 +00:00
|
|
|
// HACK: Disable redo command until supported (T185706)
|
2018-01-25 18:16:58 +00:00
|
|
|
ve.ui.commandRegistry.unregister( 'redo' );
|
|
|
|
|
2018-08-04 13:41:12 +00:00
|
|
|
// HACK: Disable references until supported (T194838)
|
|
|
|
ve.ui.commandRegistry.unregister( 'reference' );
|
|
|
|
ve.ui.commandRegistry.unregister( 'referencesList' );
|
2019-04-02 21:04:08 +00:00
|
|
|
ve.ui.commandRegistry.unregister( 'citoid' );
|
2018-08-04 13:41:12 +00:00
|
|
|
|
2019-02-20 20:23:43 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2016-10-25 20:44:26 +00:00
|
|
|
this.$editableContent = $( '#mw-content-text' );
|
|
|
|
|
|
|
|
// Initialization
|
2018-09-17 14:24:27 +00:00
|
|
|
this.$element.addClass( 've-init-mw-articleTarget ve-init-mw-collabTarget' );
|
2016-10-25 20:44:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.init.mw.CollabTarget, ve.init.mw.Target );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.init.mw.CollabTarget.static.name = 'collab';
|
|
|
|
|
|
|
|
ve.init.mw.CollabTarget.static.trackingName = 'collab';
|
|
|
|
|
2018-05-18 17:36:00 +00:00
|
|
|
ve.init.mw.CollabTarget.static.toolbarGroups = ve.copy( ve.init.mw.CollabTarget.static.toolbarGroups );
|
|
|
|
ve.init.mw.CollabTarget.static.toolbarGroups.splice( 4, 0, {
|
|
|
|
name: 'commentAnnotation',
|
|
|
|
include: [ 'commentAnnotation' ]
|
|
|
|
} );
|
2018-08-04 13:41:12 +00:00
|
|
|
// HACK: Disable references until supported (T194838)
|
2024-04-30 16:44:25 +00:00
|
|
|
ve.init.mw.CollabTarget.static.toolbarGroups = ve.init.mw.CollabTarget.static.toolbarGroups.filter( ( group ) => group.name !== 'reference' );
|
2023-06-29 18:14:07 +00:00
|
|
|
ve.init.mw.CollabTarget.static.toolbarGroups.push(
|
2017-09-07 21:32:16 +00:00
|
|
|
{
|
2018-05-12 15:18:07 +00:00
|
|
|
name: 'help',
|
2023-06-29 18:14:07 +00:00
|
|
|
align: 'after',
|
2018-05-12 15:18:07 +00:00
|
|
|
include: [ 'help' ]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'pageMenu',
|
2023-06-29 18:14:07 +00:00
|
|
|
align: 'after',
|
2017-09-07 21:32:16 +00:00
|
|
|
type: 'list',
|
|
|
|
icon: 'menu',
|
|
|
|
indicator: null,
|
|
|
|
title: ve.msg( 'visualeditor-pagemenu-tooltip' ),
|
2020-03-13 21:03:50 +00:00
|
|
|
label: ve.msg( 'visualeditor-pagemenu-tooltip' ),
|
|
|
|
invisibleLabel: true,
|
2017-09-07 21:32:16 +00:00
|
|
|
include: [ 'changeDirectionality', 'findAndReplace' ]
|
|
|
|
},
|
2018-05-12 15:18:07 +00:00
|
|
|
{
|
|
|
|
name: 'authorList',
|
2023-06-29 18:14:07 +00:00
|
|
|
align: 'after',
|
2018-05-12 15:18:07 +00:00
|
|
|
include: [ 'authorList' ]
|
2019-05-09 15:56:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'export',
|
2023-06-29 18:14:07 +00:00
|
|
|
align: 'after',
|
2019-05-09 15:56:43 +00:00
|
|
|
include: [ 'export' ]
|
2018-05-12 15:18:07 +00:00
|
|
|
}
|
2023-06-29 18:14:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
ve.init.mw.CollabTarget.static.importRules = ve.copy( ve.init.mw.CollabTarget.static.importRules );
|
|
|
|
ve.init.mw.CollabTarget.static.importRules.external.blacklist[ 'link/mwExternal' ] = false;
|
2017-05-23 16:21:16 +00:00
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2019-05-17 14:29:53 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.getSurfaceConfig = function ( config ) {
|
|
|
|
return ve.init.mw.CollabTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
|
|
|
|
nullSelectionOnBlur: false
|
|
|
|
}, config ) );
|
|
|
|
};
|
|
|
|
|
2021-05-17 21:39:22 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.getSurfaceClasses = function () {
|
|
|
|
var classes = ve.init.mw.CollabTarget.super.prototype.getSurfaceClasses.call( this );
|
|
|
|
return classes.concat( [ 'mw-body-content' ] );
|
|
|
|
};
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
/**
|
|
|
|
* Page modifications after editor load.
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.transformPage = function () {
|
|
|
|
};
|
|
|
|
|
2017-05-20 19:22:44 +00:00
|
|
|
/**
|
|
|
|
* Page modifications after editor teardown.
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.restorePage = function () {
|
|
|
|
};
|
|
|
|
|
2020-07-31 15:41:18 +00:00
|
|
|
/**
|
|
|
|
* MWBackTool calls tryTeardown
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.tryTeardown = function () {
|
|
|
|
this.emit( 'close' );
|
|
|
|
};
|
|
|
|
|
2018-08-12 15:13:00 +00:00
|
|
|
/**
|
|
|
|
* Get the title of the imported document, if there was one
|
|
|
|
*
|
|
|
|
* @return {mw.Title|null} Title of imported document
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.getImportTitle = function () {
|
|
|
|
return this.importTitle;
|
|
|
|
};
|
|
|
|
|
2018-08-13 18:17:45 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.getPageName = function () {
|
|
|
|
return this.getImportTitle() || this.pageName;
|
|
|
|
};
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.init.mw.targetFactory.register( ve.init.mw.CollabTarget );
|
2019-05-09 15:56:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Export tool
|
|
|
|
*/
|
|
|
|
ve.ui.MWExportTool = function VeUiMWExportTool() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWExportTool.super.apply( this, arguments );
|
2019-02-01 18:24:20 +00:00
|
|
|
|
|
|
|
if ( OO.ui.isMobile() ) {
|
|
|
|
this.setIcon( 'upload' );
|
|
|
|
this.setTitle( null );
|
|
|
|
}
|
2019-05-09 15:56:43 +00:00
|
|
|
};
|
|
|
|
OO.inheritClass( ve.ui.MWExportTool, ve.ui.Tool );
|
|
|
|
ve.ui.MWExportTool.static.name = 'export';
|
2019-02-01 18:24:20 +00:00
|
|
|
ve.ui.MWExportTool.static.displayBothIconAndLabel = !OO.ui.isMobile();
|
2019-05-09 15:56:43 +00:00
|
|
|
ve.ui.MWExportTool.static.group = 'export';
|
|
|
|
ve.ui.MWExportTool.static.autoAddToCatchall = false;
|
2024-04-30 16:44:25 +00:00
|
|
|
|
2019-05-09 15:56:43 +00:00
|
|
|
ve.ui.MWExportTool.static.flags = [ 'progressive', 'primary' ];
|
|
|
|
ve.ui.MWExportTool.static.title =
|
2020-07-30 15:23:02 +00:00
|
|
|
OO.ui.deferMsg( 'visualeditor-rebase-client-export-start' );
|
2019-05-09 15:56:43 +00:00
|
|
|
ve.ui.MWExportTool.static.commandName = 'mwExportWikitext';
|
|
|
|
ve.ui.toolFactory.register( ve.ui.MWExportTool );
|
|
|
|
|
|
|
|
ve.ui.commandRegistry.register(
|
|
|
|
new ve.ui.Command(
|
|
|
|
'mwExportWikitext', 'window', 'open',
|
|
|
|
{ args: [ 'mwExportWikitext' ] }
|
|
|
|
)
|
|
|
|
);
|