Debian Codegraph @

extensions/VisualEditor/modules/ve-mw-collab/ve.init.mw.CollabTarget.js

raw symbols SCIP
1 /*!
2 * VisualEditor MediaWiki Initialization CollabTarget class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * MediaWiki mobile article target.
10 *
11 * @class
12 * @extends ve.init.mw.Target
13 *
14 * @constructor
15 * @param {mw.Title} title Page sub-title
16 * @param {string} rebaserUrl Rebaser server URL
17 * @param {Object} [config] Configuration options
18 * @param {mw.Title} [config.importTitle] Title to import
19 */
20 ve.init.mw.CollabTarget = function VeInitMwCollabTarget( title, rebaserUrl, config ) {
21 config = config || {};
22 config.toolbarConfig = ve.extendObject( {
23 shadow: true,
24 actions: true,
25 floatable: true
26 }, config.toolbarConfig );
27
28 this.title = title;
29 this.rebaserUrl = rebaserUrl;
30 this.importTitle = config.importTitle || null;
31
32 // Parent constructor
33 ve.init.mw.CollabTarget.super.call( this, config );
34
35 // HACK: Disable redo command until supported (T185706)
36 ve.ui.commandRegistry.unregister( 'redo' );
37
38 // HACK: Disable references until supported (T194838)
39 ve.ui.commandRegistry.unregister( 'reference' );
40 ve.ui.commandRegistry.unregister( 'referencesList' );
41 ve.ui.commandRegistry.unregister( 'citoid' );
42
43 // eslint-disable-next-line no-jquery/no-global-selector
44 this.$editableContent = $( '#mw-content-text' );
45
46 // Initialization
47 this.$element.addClass( 've-init-mw-articleTarget ve-init-mw-collabTarget' );
48 };
49
50 /* Inheritance */
51
52 OO.inheritClass( ve.init.mw.CollabTarget, ve.init.mw.Target );
53
54 /* Static Properties */
55
56 ve.init.mw.CollabTarget.static.name = 'collab';
57
58 ve.init.mw.CollabTarget.static.trackingName = 'collab';
59
60 ve.init.mw.CollabTarget.static.toolbarGroups = ve.copy( ve.init.mw.CollabTarget.static.toolbarGroups );
61 ve.init.mw.CollabTarget.static.toolbarGroups.splice( 4, 0, {
62 name: 'commentAnnotation',
63 include: [ 'commentAnnotation' ]
64 } );
65 // HACK: Disable references until supported (T194838)
66 ve.init.mw.CollabTarget.static.toolbarGroups = ve.init.mw.CollabTarget.static.toolbarGroups.filter( ( group ) => group.name !== 'reference' );
67 ve.init.mw.CollabTarget.static.toolbarGroups.push(
68 {
69 name: 'help',
70 align: 'after',
71 include: [ 'help' ]
72 },
73 {
74 name: 'pageMenu',
75 align: 'after',
76 type: 'list',
77 icon: 'menu',
78 indicator: null,
79 title: ve.msg( 'visualeditor-pagemenu-tooltip' ),
80 label: ve.msg( 'visualeditor-pagemenu-tooltip' ),
81 invisibleLabel: true,
82 include: [ 'changeDirectionality', 'findAndReplace' ]
83 },
84 {
85 name: 'authorList',
86 align: 'after',
87 include: [ 'authorList' ]
88 },
89 {
90 name: 'export',
91 align: 'after',
92 include: [ 'export' ]
93 }
94 );
95
96 ve.init.mw.CollabTarget.static.importRules = ve.copy( ve.init.mw.CollabTarget.static.importRules );
97 ve.init.mw.CollabTarget.static.importRules.external.blacklist[ 'link/mwExternal' ] = false;
98
99 /* Methods */
100
101 /**
102 * @inheritdoc
103 */
104 ve.init.mw.CollabTarget.prototype.getSurfaceConfig = function ( config ) {
105 return ve.init.mw.CollabTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
106 nullSelectionOnBlur: false
107 }, config ) );
108 };
109
110 /**
111 * @inheritdoc
112 */
113 ve.init.mw.CollabTarget.prototype.getSurfaceClasses = function () {
114 const classes = ve.init.mw.CollabTarget.super.prototype.getSurfaceClasses.call( this );
115 return classes.concat( [ 'mw-body-content' ] );
116 };
117
118 /**
119 * Page modifications after editor load.
120 */
121 ve.init.mw.CollabTarget.prototype.transformPage = function () {
122 };
123
124 /**
125 * Page modifications after editor teardown.
126 */
127 ve.init.mw.CollabTarget.prototype.restorePage = function () {
128 };
129
130 /**
131 * MWBackTool calls tryTeardown
132 */
133 ve.init.mw.CollabTarget.prototype.tryTeardown = function () {
134 this.emit( 'close' );
135 };
136
137 /**
138 * Get the title of the imported document, if there was one
139 *
140 * @return {mw.Title|null} Title of imported document
141 */
142 ve.init.mw.CollabTarget.prototype.getImportTitle = function () {
143 return this.importTitle;
144 };
145
146 /**
147 * @inheritdoc
148 */
149 ve.init.mw.CollabTarget.prototype.getPageName = function () {
150 return this.getImportTitle() || this.pageName;
151 };
152
153 /* Registration */
154
155 ve.init.mw.targetFactory.register( ve.init.mw.CollabTarget );
156
157 /**
158 * Export tool
159 */
160 ve.ui.MWExportTool = function VeUiMWExportTool() {
161 // Parent constructor
162 ve.ui.MWExportTool.super.apply( this, arguments );
163
164 if ( OO.ui.isMobile() ) {
165 this.setIcon( 'upload' );
166 this.setTitle( null );
167 }
168 };
169 OO.inheritClass( ve.ui.MWExportTool, ve.ui.Tool );
170 ve.ui.MWExportTool.static.name = 'export';
171 ve.ui.MWExportTool.static.displayBothIconAndLabel = !OO.ui.isMobile();
172 ve.ui.MWExportTool.static.group = 'export';
173 ve.ui.MWExportTool.static.autoAddToCatchall = false;
174
175 ve.ui.MWExportTool.static.flags = [ 'progressive', 'primary' ];
176 ve.ui.MWExportTool.static.title =
177 OO.ui.deferMsg( 'visualeditor-rebase-client-export-start' );
178 ve.ui.MWExportTool.static.commandName = 'mwExportWikitext';
179 ve.ui.toolFactory.register( ve.ui.MWExportTool );
180
181 ve.ui.commandRegistry.register(
182 new ve.ui.Command(
183 'mwExportWikitext', 'window', 'open',
184 { args: [ 'mwExportWikitext' ] }
185 )
186 );