mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-25 00:38:33 +00:00
ee69365b82
Load 'ext.visualEditor.mwsignature' (which implements VE's existing handling for signatures), then subclass and override a bunch of things in order to: * Replace the context menu with a note that you don't need to type the signature when commenting using the reply widget * Override the sequence/command to insert signature so that it selects it afterwards and thus displays the context menu * Treat signatures as signature nodes when switching from wikitext, instead of the normal pre-save transform turning them into regular links and text Bug: T255738 Change-Id: Icb542451c2307ab51e56bd627804096c7b5552c8
39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
function DtUiMWSignatureContextItem() {
|
|
// Parent constructor
|
|
DtUiMWSignatureContextItem.super.apply( this, arguments );
|
|
}
|
|
|
|
OO.inheritClass( DtUiMWSignatureContextItem, ve.ui.MWSignatureContextItem );
|
|
|
|
DtUiMWSignatureContextItem.static.name = 'dtMwSignature';
|
|
|
|
DtUiMWSignatureContextItem.static.modelClasses = [ require( './dt.dm.MWSignatureNode.js' ) ];
|
|
|
|
DtUiMWSignatureContextItem.static.label =
|
|
OO.ui.deferMsg( 'discussiontools-replywidget-signature-title' );
|
|
|
|
// Get the formatted, localized, platform-specific shortcut key for the given command
|
|
DtUiMWSignatureContextItem.prototype.getShortcutKey = function ( commandName ) {
|
|
var commandInfo, triggerList, $shortcut;
|
|
// Adapted from ve.ui.CommandHelpDialog.prototype.initialize
|
|
commandInfo = ve.ui.commandHelpRegistry.lookup( commandName );
|
|
triggerList = ve.ui.triggerRegistry.lookup( commandInfo.trigger );
|
|
$shortcut = $( '<kbd>' ).addClass( 've-ui-commandHelpDialog-shortcut' ).append(
|
|
triggerList[ 0 ].getMessage( true ).map( ve.ui.CommandHelpDialog.static.buildKeyNode )
|
|
).find( 'kbd + kbd' ).before( '+' ).end();
|
|
return $shortcut;
|
|
};
|
|
|
|
// Add a description saying that typing a signature is not needed here
|
|
DtUiMWSignatureContextItem.prototype.renderBody = function () {
|
|
this.$body.empty().append( mw.message(
|
|
'discussiontools-replywidget-signature-body',
|
|
$( '<code>' ).text( '~~~~' ),
|
|
this.getShortcutKey( 'undo' )
|
|
).parseDom() );
|
|
};
|
|
|
|
ve.ui.contextItemFactory.register( DtUiMWSignatureContextItem );
|
|
|
|
module.exports = DtUiMWSignatureContextItem;
|