File: ve.init.mw.CollabTarget.js

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (186 lines) | stat: -rw-r--r-- 4,967 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*!
 * VisualEditor MediaWiki Initialization CollabTarget class.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */

/**
 * MediaWiki mobile article target.
 *
 * @class
 * @extends ve.init.mw.Target
 *
 * @constructor
 * @param {mw.Title} title Page sub-title
 * @param {string} rebaserUrl Rebaser server URL
 * @param {Object} [config] Configuration options
 * @param {mw.Title} [config.importTitle] Title to import
 */
ve.init.mw.CollabTarget = function VeInitMwCollabTarget( title, rebaserUrl, config ) {
	config = config || {};
	config.toolbarConfig = ve.extendObject( {
		shadow: true,
		actions: true,
		floatable: true
	}, config.toolbarConfig );

	this.title = title;
	this.rebaserUrl = rebaserUrl;
	this.importTitle = config.importTitle || null;

	// Parent constructor
	ve.init.mw.CollabTarget.super.call( this, config );

	// HACK: Disable redo command until supported (T185706)
	ve.ui.commandRegistry.unregister( 'redo' );

	// HACK: Disable references until supported (T194838)
	ve.ui.commandRegistry.unregister( 'reference' );
	ve.ui.commandRegistry.unregister( 'referencesList' );
	ve.ui.commandRegistry.unregister( 'citoid' );

	// eslint-disable-next-line no-jquery/no-global-selector
	this.$editableContent = $( '#mw-content-text' );

	// Initialization
	this.$element.addClass( 've-init-mw-articleTarget ve-init-mw-collabTarget' );
};

/* 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';

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' ]
} );
// HACK: Disable references until supported (T194838)
ve.init.mw.CollabTarget.static.toolbarGroups = ve.init.mw.CollabTarget.static.toolbarGroups.filter( ( group ) => group.name !== 'reference' );
ve.init.mw.CollabTarget.static.toolbarGroups.push(
	{
		name: 'help',
		align: 'after',
		include: [ 'help' ]
	},
	{
		name: 'pageMenu',
		align: 'after',
		type: 'list',
		icon: 'menu',
		indicator: null,
		title: ve.msg( 'visualeditor-pagemenu-tooltip' ),
		label: ve.msg( 'visualeditor-pagemenu-tooltip' ),
		invisibleLabel: true,
		include: [ 'changeDirectionality', 'findAndReplace' ]
	},
	{
		name: 'authorList',
		align: 'after',
		include: [ 'authorList' ]
	},
	{
		name: 'export',
		align: 'after',
		include: [ 'export' ]
	}
);

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;

/* Methods */

/**
 * @inheritdoc
 */
ve.init.mw.CollabTarget.prototype.getSurfaceConfig = function ( config ) {
	return ve.init.mw.CollabTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
		nullSelectionOnBlur: false
	}, config ) );
};

/**
 * @inheritdoc
 */
ve.init.mw.CollabTarget.prototype.getSurfaceClasses = function () {
	const classes = ve.init.mw.CollabTarget.super.prototype.getSurfaceClasses.call( this );
	return classes.concat( [ 'mw-body-content' ] );
};

/**
 * Page modifications after editor load.
 */
ve.init.mw.CollabTarget.prototype.transformPage = function () {
};

/**
 * Page modifications after editor teardown.
 */
ve.init.mw.CollabTarget.prototype.restorePage = function () {
};

/**
 * MWBackTool calls tryTeardown
 */
ve.init.mw.CollabTarget.prototype.tryTeardown = function () {
	this.emit( 'close' );
};

/**
 * 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;
};

/**
 * @inheritdoc
 */
ve.init.mw.CollabTarget.prototype.getPageName = function () {
	return this.getImportTitle() || this.pageName;
};

/* Registration */

ve.init.mw.targetFactory.register( ve.init.mw.CollabTarget );

/**
 * Export tool
 */
ve.ui.MWExportTool = function VeUiMWExportTool() {
	// Parent constructor
	ve.ui.MWExportTool.super.apply( this, arguments );

	if ( OO.ui.isMobile() ) {
		this.setIcon( 'upload' );
		this.setTitle( null );
	}
};
OO.inheritClass( ve.ui.MWExportTool, ve.ui.Tool );
ve.ui.MWExportTool.static.name = 'export';
ve.ui.MWExportTool.static.displayBothIconAndLabel = !OO.ui.isMobile();
ve.ui.MWExportTool.static.group = 'export';
ve.ui.MWExportTool.static.autoAddToCatchall = false;

ve.ui.MWExportTool.static.flags = [ 'progressive', 'primary' ];
ve.ui.MWExportTool.static.title =
	OO.ui.deferMsg( 'visualeditor-rebase-client-export-start' );
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' ] }
	)
);