Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js

raw symbols SCIP
1 /*!
2 * VisualEditor user interface MWTransclusionDialog class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * Dialog for inserting and editing MediaWiki transclusions, i.e. a sequence of one or more template
10 * invocations that strictly belong to each other (e.g. because they are unbalanced), possibly
11 * mixed with raw wikitext snippets.
12 *
13 * Note the base class {@see ve.ui.MWTemplateDialog} alone does not allow to manage more than a
14 * single template invocation. Most of the code for this feature set is exclusive to this subclass.
15 *
16 * @class
17 * @extends ve.ui.MWTemplateDialog
18 *
19 * @constructor
20 * @param {Object} [config] Configuration options
21 */
22 ve.ui.MWTransclusionDialog = function VeUiMWTransclusionDialog( config ) {
23 // Parent constructor
24 ve.ui.MWTransclusionDialog.super.call( this, config );
25
26 // Properties
27 this.isSidebarExpanded = null;
28
29 this.hotkeyTriggers = {};
30 this.$element.on( 'keydown', this.onKeyDown.bind( this ) );
31 };
32
33 /* Inheritance */
34
35 OO.inheritClass( ve.ui.MWTransclusionDialog, ve.ui.MWTemplateDialog );
36
37 /* Static Properties */
38
39 ve.ui.MWTransclusionDialog.static.name = 'transclusion';
40
41 ve.ui.MWTransclusionDialog.static.size = 'larger';
42
43 ve.ui.MWTransclusionDialog.static.actions = [
44 ...ve.ui.MWTemplateDialog.static.actions,
45 {
46 action: 'mode',
47 modes: [ 'edit', 'insert' ],
48 // HACK: Will be set later, but we want measurements to be accurate in the mean time, this
49 // will not be needed when T93290 is resolved
50 label: $( document.createTextNode( '\u00a0' ) )
51 },
52 {
53 action: 'back',
54 label: OO.ui.deferMsg( 'visualeditor-dialog-action-goback' ),
55 modes: [ 'edit', 'insert' ],
56 flags: [ 'safe', 'back' ]
57 }
58 ];
59
60 ve.ui.MWTransclusionDialog.static.smallScreenMaxWidth = 540;
61
62 /* Static Methods */
63
64 /**
65 * @return {boolean}
66 */
67 ve.ui.MWTransclusionDialog.static.isSmallScreen = function () {
68 return $( window ).width() <= ve.ui.MWTransclusionDialog.static.smallScreenMaxWidth;
69 };
70
71 /* Methods */
72
73 /**
74 * Handle outline controls move events.
75 *
76 * @private
77 * @param {number} places Number of places to move the selected item
78 */
79 ve.ui.MWTransclusionDialog.prototype.onOutlineControlsMove = function ( places ) {
80 const part = this.transclusionModel.getPartFromId( this.bookletLayout.getSelectedTopLevelPartId() );
81 if ( !part ) {
82 return;
83 }
84
85 const newPlace = this.transclusionModel.getParts().indexOf( part ) + places;
86 if ( newPlace < 0 || newPlace >= this.transclusionModel.getParts().length ) {
87 return;
88 }
89
90 // Move part to new location, and if dialog is loaded switch to new part page
91 const promise = this.transclusionModel.addPart( part, newPlace );
92 if ( this.loaded && !this.preventReselection ) {
93 // FIXME: Should be handled internally {@see ve.ui.MWTwoPaneTransclusionDialogLayout}
94 promise.done( this.bookletLayout.focusPart.bind( this.bookletLayout, part.getId() ) );
95 }
96 };
97
98 /**
99 * Handle outline controls remove events.
100 *
101 * @private
102 */
103 ve.ui.MWTransclusionDialog.prototype.onOutlineControlsRemove = function () {
104 const controls = this.bookletLayout.getOutlineControls();
105 // T301914: Safe-guard for when a keyboard shortcut triggers this, instead of the actual button
106 if ( !controls.isVisible() ||
107 !controls.removeButton.isVisible() ||
108 controls.removeButton.isDisabled()
109 ) {
110 return;
111 }
112
113 const partId = this.bookletLayout.getSelectedTopLevelPartId(),
114 part = this.transclusionModel.getPartFromId( partId );
115 if ( part ) {
116 this.transclusionModel.removePart( part );
117 }
118 };
119
120 /**
121 * Create a new template part at the end of the transclusion.
122 *
123 * @private
124 */
125 ve.ui.MWTransclusionDialog.prototype.addTemplatePlaceholder = function () {
126 this.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ) );
127 };
128
129 /**
130 * Handle add wikitext button click or hotkey events.
131 *
132 * @private
133 */
134 ve.ui.MWTransclusionDialog.prototype.addWikitext = function () {
135 this.addPart( new ve.dm.MWTransclusionContentModel( this.transclusionModel ) );
136 };
137
138 /**
139 * Handle add parameter hotkey events.
140 *
141 * @private
142 * @param {jQuery.Event} e Key down event
143 */
144 ve.ui.MWTransclusionDialog.prototype.addParameter = function ( e ) {
145 // Check if the focus was in e.g. a parameter list or filter input when the hotkey was pressed
146 let partId = this.bookletLayout.sidebar.findPartIdContainingElement( e.target ),
147 part = this.transclusionModel.getPartFromId( partId );
148
149 if ( !( part instanceof ve.dm.MWTemplateModel ) ) {
150 // Otherwise add to the template that's currently selected via its title or parameter
151 partId = this.bookletLayout.getTopLevelPartIdForSelection();
152 part = this.transclusionModel.getPartFromId( partId );
153 }
154
155 if ( this.transclusionModel.isSingleTemplate() ) {
156 part = this.transclusionModel.getParts()[ 0 ];
157 }
158
159 if ( !( part instanceof ve.dm.MWTemplateModel ) ) {
160 return;
161 }
162
163 // TODO: Use a distinct class for placeholder model rather than
164 // these magical "empty" constants.
165 const placeholderParameter = new ve.dm.MWParameterModel( part );
166 part.addParameter( placeholderParameter );
167 this.bookletLayout.focusPart( placeholderParameter.getId() );
168
169 this.autoExpandSidebar();
170 };
171
172 /**
173 * @inheritdoc
174 */
175 ve.ui.MWTransclusionDialog.prototype.onReplacePart = function ( removed, added ) {
176 ve.ui.MWTransclusionDialog.super.prototype.onReplacePart.call( this, removed, added );
177 const parts = this.transclusionModel.getParts();
178
179 if ( parts.length === 0 ) {
180 this.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ) );
181 } else if ( parts.length > 1 ) {
182 this.$element.removeClass( 've-ui-mwTransclusionDialog-single-transclusion' );
183 }
184
185 // multipart message
186 this.bookletLayout.stackLayout.$element.prepend( this.multipartMessage.$element );
187 this.multipartMessage.toggle( parts.length > 1 );
188
189 this.autoExpandSidebar();
190 this.updateModeActionState();
191 this.updateActionSet();
192 };
193
194 /**
195 * @private
196 */
197 ve.ui.MWTransclusionDialog.prototype.setupHotkeyTriggers = function () {
198 // Lower-case modifier and key names as specified in {@see ve.ui.Trigger}
199 const isMac = ve.getSystemPlatform() === 'mac',
200 meta = isMac ? 'meta+' : 'ctrl+';
201 const hotkeys = {
202 addTemplate: meta + 'd',
203 addWikitext: meta + 'shift+y',
204 addParameter: meta + 'shift+d',
205 moveUp: meta + 'shift+up',
206 moveDown: meta + 'shift+down',
207 remove: meta + 'delete',
208 removeBackspace: meta + 'backspace'
209 };
210
211 const notInTextFields = /^(?!INPUT|TEXTAREA)/i;
212 this.connectHotKeyBinding( hotkeys.addTemplate, this.addTemplatePlaceholder.bind( this ) );
213 this.connectHotKeyBinding( hotkeys.addWikitext, this.addWikitext.bind( this ) );
214 this.connectHotKeyBinding( hotkeys.addParameter, this.addParameter.bind( this ) );
215 this.connectHotKeyBinding( hotkeys.moveUp, this.onOutlineControlsMove.bind( this, -1 ), notInTextFields );
216 this.connectHotKeyBinding( hotkeys.moveDown, this.onOutlineControlsMove.bind( this, 1 ), notInTextFields );
217 this.connectHotKeyBinding( hotkeys.remove, this.onOutlineControlsRemove.bind( this ), notInTextFields );
218 if ( isMac ) {
219 this.connectHotKeyBinding( hotkeys.removeBackspace, this.onOutlineControlsRemove.bind( this ), notInTextFields );
220 }
221
222 const controls = this.bookletLayout.getOutlineControls();
223 this.addHotkeyToTitle( controls.addTemplateButton, hotkeys.addTemplate );
224 this.addHotkeyToTitle( controls.addWikitextButton, hotkeys.addWikitext );
225 this.addHotkeyToTitle( controls.upButton, hotkeys.moveUp );
226 this.addHotkeyToTitle( controls.downButton, hotkeys.moveDown );
227 this.addHotkeyToTitle( controls.removeButton, hotkeys.remove );
228 };
229
230 /**
231 * @private
232 * @param {string} hotkey
233 * @param {Function} handler
234 * @param {RegExp} [validTypes]
235 */
236 ve.ui.MWTransclusionDialog.prototype.connectHotKeyBinding = function ( hotkey, handler, validTypes ) {
237 this.hotkeyTriggers[ hotkey ] = {
238 handler: handler,
239 validTypes: validTypes
240 };
241 };
242
243 /**
244 * @private
245 * @param {OO.ui.mixin.TitledElement} element
246 * @param {string} hotkey
247 */
248 ve.ui.MWTransclusionDialog.prototype.addHotkeyToTitle = function ( element, hotkey ) {
249 // Separated with a space as in {@see OO.ui.Tool.updateTitle}
250 element.setTitle( element.getTitle() + ' ' + new ve.ui.Trigger( hotkey ).getMessage() );
251 };
252
253 /**
254 * Handles key down events.
255 *
256 * @protected
257 * @param {jQuery.Event} e Key down event
258 */
259 ve.ui.MWTransclusionDialog.prototype.onKeyDown = function ( e ) {
260 const hotkey = new ve.ui.Trigger( e ).toString(),
261 trigger = this.hotkeyTriggers[ hotkey ];
262
263 if ( trigger && ( !trigger.validTypes || trigger.validTypes.test( e.target.nodeName ) ) ) {
264 trigger.handler( e );
265 e.preventDefault();
266 e.stopPropagation();
267 }
268 };
269
270 /**
271 * @inheritdoc
272 */
273 ve.ui.MWTransclusionDialog.prototype.getPageFromPart = function ( part ) {
274 const page = ve.ui.MWTransclusionDialog.super.prototype.getPageFromPart.call( this, part );
275 if ( !page && part instanceof ve.dm.MWTransclusionContentModel ) {
276 return new ve.ui.MWTransclusionContentPage( part, part.getId(), { $overlay: this.$overlay, isReadOnly: this.isReadOnly() } );
277 }
278 return page;
279 };
280
281 /**
282 * Automatically expand or collapse the sidebar according to default logic.
283 *
284 * @protected
285 */
286 ve.ui.MWTransclusionDialog.prototype.autoExpandSidebar = function () {
287 let expandSidebar;
288
289 const isSmallScreen = this.constructor.static.isSmallScreen();
290
291 const showOtherActions = isSmallScreen ||
292 // Check for unknown actions, show the toolbar if any are available.
293 this.actions.getOthers().some( ( action ) => action.action !== 'mode' );
294 this.actions.forEach( { actions: [ 'mode' ] }, ( action ) => {
295 action.toggle( isSmallScreen );
296 } );
297 this.$otherActions.toggleClass( 'oo-ui-element-hidden', !showOtherActions );
298
299 if ( isSmallScreen && this.transclusionModel.isEmpty() ) {
300 expandSidebar = false;
301 } else if ( isSmallScreen &&
302 // eslint-disable-next-line no-jquery/no-class-state
303 this.$content.hasClass( 've-ui-mwTransclusionDialog-small-screen' )
304 ) {
305 // We did this already. If the sidebar is visible or not is now the user's decision.
306 return;
307 } else {
308 expandSidebar = !isSmallScreen;
309 }
310
311 this.$content.toggleClass( 've-ui-mwTransclusionDialog-small-screen', isSmallScreen );
312
313 this.toggleSidebar( expandSidebar );
314 };
315
316 /**
317 * Set if the sidebar is visible (which means the dialog is expanded), or collapsed.
318 *
319 * @param {boolean} expandSidebar
320 * @private
321 */
322 ve.ui.MWTransclusionDialog.prototype.toggleSidebar = function ( expandSidebar ) {
323 if ( this.isSidebarExpanded === expandSidebar ) {
324 return;
325 }
326
327 this.isSidebarExpanded = expandSidebar;
328 this.$content
329 .toggleClass( 've-ui-mwTransclusionDialog-collapsed', !expandSidebar )
330 .toggleClass( 've-ui-mwTransclusionDialog-expanded', expandSidebar );
331
332 this.bookletLayout.toggleOutline( expandSidebar );
333 this.updateTitle();
334 this.updateModeActionState();
335
336 // HACK blur any active input so that its dropdown will be hidden and won't end
337 // up being mispositioned
338 this.$content.find( 'input:focus' ).trigger( 'blur' );
339
340 if ( this.loaded && this.constructor.static.isSmallScreen() ) {
341 // Updates the page sizes when the menu is toggled using the button. This needs
342 // to happen after the animation when the panel is visible.
343 setTimeout( () => {
344 this.bookletLayout.stackLayout.getItems().forEach( ( page ) => {
345 if ( page instanceof ve.ui.MWParameterPage ) {
346 page.updateSize();
347 }
348 } );
349 }, OO.ui.theme.getDialogTransitionDuration() );
350
351 // Reapply selection and scrolling when switching between panes.
352 const selectedPage = this.bookletLayout.getCurrentPage();
353 if ( selectedPage ) {
354 const name = selectedPage.getName();
355 // Align whichever panel is becoming visible, after animation completes.
356 // TODO: Should hook onto an animation promise—but is this possible when pure CSS?
357 setTimeout( () => {
358 if ( expandSidebar ) {
359 this.sidebar.setSelectionByPageName( name );
360 } else {
361 selectedPage.scrollElementIntoView( { alignToTop: true, padding: { top: 20 } } );
362 if ( !OO.ui.isMobile() ) {
363 selectedPage.focus();
364 }
365 }
366 }, OO.ui.theme.getDialogTransitionDuration() );
367 }
368 }
369 };
370
371 /**
372 * @inheritdoc
373 */
374 ve.ui.MWTransclusionDialog.prototype.updateTitle = function () {
375 if ( !this.transclusionModel.isSingleTemplate() ) {
376 this.title.setLabel( ve.msg( 'visualeditor-dialog-transclusion-title-edit-transclusion' ) );
377 } else {
378 // Parent method
379 ve.ui.MWTransclusionDialog.super.prototype.updateTitle.call( this );
380 }
381 };
382
383 /**
384 * Update the state of the 'mode' action
385 *
386 * @private
387 */
388 ve.ui.MWTransclusionDialog.prototype.updateModeActionState = function () {
389 const isExpanded = this.isSidebarExpanded,
390 label = ve.msg( isExpanded ?
391 'visualeditor-dialog-transclusion-collapse-options' :
392 'visualeditor-dialog-transclusion-expand-options' );
393
394 this.actions.forEach( { actions: [ 'mode' ] }, ( action ) => {
395 action.setLabel( label );
396 action.$button.attr( 'aria-expanded', isExpanded ? 1 : 0 );
397 } );
398
399 // The button is only visible on very narrow screens, {@see autoExpandSidebar}.
400 // It's always needed, except in the initial placeholder state.
401 const isInitialState = !isExpanded && this.transclusionModel.isEmpty(),
402 canCollapse = !isInitialState;
403 this.actions.setAbilities( { mode: canCollapse } );
404 };
405
406 /**
407 * Add a part to the transclusion.
408 *
409 * @param {ve.dm.MWTransclusionPartModel} part Part to add
410 */
411 ve.ui.MWTransclusionDialog.prototype.addPart = function ( part ) {
412 const parts = this.transclusionModel.getParts(),
413 partId = this.bookletLayout.getTopLevelPartIdForSelection(),
414 selectedPart = this.transclusionModel.getPartFromId( partId );
415 // Insert after selected part, or at the end if nothing is selected
416 const index = selectedPart ? parts.indexOf( selectedPart ) + 1 : parts.length;
417 // Add the part, and if dialog is loaded switch to part page
418 const promise = this.transclusionModel.addPart( part, index );
419 if ( this.loaded && !this.preventReselection ) {
420 promise.done( this.bookletLayout.focusPart.bind( this.bookletLayout, part.getId() ) );
421 }
422 };
423
424 /**
425 * Show a confirm prompt before closing the dialog
426 *
427 * @param {string} prompt Prompt
428 * @return {jQuery.Promise} Close promise
429 */
430 ve.ui.MWTransclusionDialog.prototype.closeConfirm = function ( prompt ) {
431 return OO.ui.confirm( prompt, {
432 actions: [
433 {
434 action: 'reject',
435 label: ve.msg( 'visualeditor-dialog-transclusion-confirmation-reject' ),
436 flags: 'safe'
437 },
438 {
439 action: 'accept',
440 label: ve.msg( 'visualeditor-dialog-transclusion-confirmation-discard' ),
441 // TODO: Destructive actions don't get focus by default, but maybe should here?
442 flags: 'destructive'
443 }
444 ]
445 } );
446 };
447
448 /**
449 * @inheritdoc
450 */
451 ve.ui.MWTransclusionDialog.prototype.getActionProcess = function ( action ) {
452 const willLoseProgress = this.getMode() === 'insert' ?
453 // A new template with no parameters is not considered valuable.
454 this.transclusionModel.containsValuableData() :
455 // The user has changed a parameter, and is not on the template search page.
456 ( this.altered && !this.transclusionModel.isEmpty() );
457
458 switch ( action ) {
459 case 'back':
460 return new OO.ui.Process( () => {
461 if ( willLoseProgress ) {
462 this.closeConfirm( ve.msg( 'visualeditor-dialog-transclusion-back-confirmation-prompt' ) ).then( ( confirmed ) => {
463 if ( confirmed ) {
464 this.resetDialog();
465 }
466 } );
467 } else {
468 this.resetDialog();
469 }
470 } );
471 case 'mode':
472 return new OO.ui.Process( () => {
473 this.toggleSidebar( !this.isSidebarExpanded );
474 } );
475 case '':
476 // close action
477 if ( willLoseProgress ) {
478 return new OO.ui.Process( () => {
479 this.closeConfirm( ve.msg( 'visualeditor-dialog-transclusion-close-confirmation-prompt' ) ).then( ( confirmed ) => {
480 if ( confirmed ) {
481 this.close();
482 }
483 } );
484 } );
485 }
486 }
487 return ve.ui.MWTransclusionDialog.super.prototype.getActionProcess.call( this, action );
488 };
489
490 /**
491 * Update the widgets in the dialog's action bar.
492 *
493 * @private
494 */
495 ve.ui.MWTransclusionDialog.prototype.updateActionSet = function () {
496 const backButton = this.actions.get( { flags: [ 'back' ] } ).pop(),
497 saveButton = this.actions.get( { actions: [ 'done' ] } ).pop();
498
499 if ( saveButton && this.getMode() === 'edit' ) {
500 saveButton.setLabel( ve.msg( 'visualeditor-dialog-transclusion-action-save' ) );
501 }
502
503 const closeButton = this.actions.get( { flags: [ 'close' ] } ).pop(),
504 canGoBack = this.getMode() === 'insert' && this.canGoBack && !this.transclusionModel.isEmpty();
505
506 closeButton.toggle( !canGoBack );
507 backButton.toggle( canGoBack );
508 };
509
510 /**
511 * Revert the dialog back to its initial state.
512 *
513 * @private
514 */
515 ve.ui.MWTransclusionDialog.prototype.resetDialog = function () {
516 this.transclusionModel.reset();
517 this.bookletLayout.clearPages();
518 const placeholderPage = new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel );
519 this.transclusionModel.addPart( placeholderPage )
520 .done( () => {
521 this.bookletLayout.focusPart( placeholderPage.getId() );
522 this.autoExpandSidebar();
523 } );
524 };
525
526 /**
527 * @inheritdoc
528 */
529 ve.ui.MWTransclusionDialog.prototype.initialize = function () {
530 // Parent method
531 ve.ui.MWTransclusionDialog.super.prototype.initialize.call( this );
532
533 this.setupHotkeyTriggers();
534
535 // multipart message gets attached in onReplacePart()
536 this.multipartMessage = new OO.ui.MessageWidget( {
537 label: mw.message( 'visualeditor-dialog-transclusion-multipart-message' ).parseDom(),
538 classes: [ 've-ui-mwTransclusionDialog-multipart-message' ]
539 } );
540 ve.targetLinksToNewWindow( this.multipartMessage.$element[ 0 ] );
541
542 const helpPopup = new ve.ui.MWFloatingHelpElement( {
543 label: mw.message( 'visualeditor-dialog-transclusion-help-title' ).text(),
544 title: mw.message( 'visualeditor-dialog-transclusion-help-title' ).text(),
545 $message: new OO.ui.FieldsetLayout( {
546 items: [
547 new OO.ui.LabelWidget( {
548 label: mw.message( 'visualeditor-dialog-transclusion-help-message' ).text()
549 } ),
550 this.getMessageButton( 'visualeditor-dialog-transclusion-help-page-help', 'helpNotice' ),
551 this.getMessageButton( 'visualeditor-dialog-transclusion-help-page-shortcuts', 'keyboard' )
552 ],
553 classes: [ 've-ui-mwTransclusionDialog-floatingHelpElement-fieldsetLayout' ]
554 } ).$element
555 } );
556 helpPopup.$element.addClass( 've-ui-mwTransclusionDialog-floatingHelpElement' );
557 helpPopup.$element.appendTo( this.$body );
558
559 // Events
560 this.getManager().connect( this, { resize: ve.debounce( this.onWindowResize.bind( this ) ) } );
561 this.bookletLayout.getOutlineControls().connect( this, {
562 addTemplate: 'addTemplatePlaceholder',
563 addWikitext: 'addWikitext',
564 move: 'onOutlineControlsMove',
565 remove: 'onOutlineControlsRemove'
566 } );
567 };
568
569 /**
570 * @inheritdoc
571 */
572 ve.ui.MWTransclusionDialog.prototype.getSetupProcess = function ( data ) {
573 return ve.ui.MWTransclusionDialog.super.prototype.getSetupProcess.call( this, data )
574 .next( () => {
575 this.bookletLayout.getOutlineControls().toggle( !this.transclusionModel.isSingleTemplate() );
576 this.$element.toggleClass(
577 've-ui-mwTransclusionDialog-single-transclusion',
578 this.transclusionModel.isSingleTemplate()
579 );
580
581 this.updateModeActionState();
582 this.autoExpandSidebar();
583
584 if ( !this.transclusionModel.isSingleTemplate() ) {
585 this.sidebar.hideAllUnusedParameters();
586 }
587 // We can do this only after the widget is visible on screen
588 this.sidebar.initializeAllStickyHeaderHeights();
589 } );
590 };
591
592 /**
593 * @private
594 */
595 ve.ui.MWTransclusionDialog.prototype.onWindowResize = function () {
596 if ( this.transclusionModel ) {
597 this.autoExpandSidebar();
598
599 this.bookletLayout.getPagesOrdered().forEach( ( page ) => {
600 if ( page instanceof ve.ui.MWParameterPage ) {
601 page.updateSize();
602 }
603 } );
604 }
605 };
606
607 /**
608 * @inheritdoc
609 */
610 ve.ui.MWTransclusionDialog.prototype.getSizeProperties = function () {
611 return ve.extendObject(
612 { height: '90%' },
613 ve.ui.MWTransclusionDialog.super.prototype.getSizeProperties.call( this )
614 );
615 };
616
617 /**
618 * Converts a message link into an OO.ui.ButtonWidget with an icon.
619 *
620 * @private
621 * @param {string} message i18n message key
622 * @param {string} icon icon name
623 * @return {OO.ui.ButtonWidget}
624 */
625 ve.ui.MWTemplateDialog.prototype.getMessageButton = function ( message, icon ) {
626 // Messages that can be used here:
627 // * visualeditor-dialog-transclusion-help-page-help
628 // * visualeditor-dialog-transclusion-help-page-shortcuts
629 const $link = mw.message( message ).parseDom(),
630 button = new OO.ui.ButtonWidget( {
631 label: $link.text(),
632 href: $link.attr( 'href' ),
633 target: '_blank',
634 flags: 'progressive',
635 icon: icon,
636 framed: false
637 } );
638 button.$button.attr( 'role', 'link' );
639 return button;
640 };
641
642 /* Registration */
643
644 ve.ui.windowFactory.register( ve.ui.MWTransclusionDialog );