mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
Re-enable keyboard sequences for template, table etc. in new topic tool
They were only disabled in the reply tool, because their wikitext markup doesn't work when indented. This is not a concern in the new topic tool. Rename our sequences that display the wikitext warning to avoid these items showing up in the command help dialog, and remove overrides for global ve.ui.commandHelpRegistry. (As a result, the dialog now lists the blockquote command, which was previously missing even though it was enabled, but only with the 'Ctrl+8' shortcut and not 'Type ":"'.) Also remove filtering rules for external paste. Bug: T311653 Change-Id: I4557c376fcf099d81e91ae5c2b18301d97921180
This commit is contained in:
parent
4da2ecf32f
commit
e5abfdbe8a
|
@ -88,21 +88,30 @@ if ( OO.ui.isMobile() ) {
|
||||||
|
|
||||||
CommentTarget.static.importRules = ve.copy( CommentTarget.static.importRules );
|
CommentTarget.static.importRules = ve.copy( CommentTarget.static.importRules );
|
||||||
|
|
||||||
CommentTarget.static.importRules.external.conversions = ve.extendObject(
|
|
||||||
{},
|
|
||||||
CommentTarget.static.importRules.external.conversions,
|
|
||||||
{
|
|
||||||
mwHeading: 'paragraph'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
CommentTarget.static.importRules.external.blacklist = ve.extendObject(
|
CommentTarget.static.importRules.external.blacklist = ve.extendObject(
|
||||||
{},
|
{},
|
||||||
CommentTarget.static.importRules.external.blacklist,
|
CommentTarget.static.importRules.external.blacklist,
|
||||||
{
|
{
|
||||||
// Annotations
|
// Annotations
|
||||||
// Allow pasting external links
|
// Allow pasting external links
|
||||||
'link/mwExternal': false,
|
'link/mwExternal': false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
CommentTarget.static.importRulesForReplyTool = ve.copy( CommentTarget.static.importRules );
|
||||||
|
|
||||||
|
CommentTarget.static.importRulesForReplyTool.external.conversions = ve.extendObject(
|
||||||
|
{},
|
||||||
|
CommentTarget.static.importRulesForReplyTool.external.conversions,
|
||||||
|
{
|
||||||
|
mwHeading: 'paragraph'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
CommentTarget.static.importRulesForReplyTool.external.blacklist = ve.extendObject(
|
||||||
|
{},
|
||||||
|
CommentTarget.static.importRulesForReplyTool.external.blacklist,
|
||||||
|
{
|
||||||
// Strip all table structure
|
// Strip all table structure
|
||||||
mwTable: true,
|
mwTable: true,
|
||||||
tableSection: true,
|
tableSection: true,
|
||||||
|
@ -122,8 +131,10 @@ CommentTarget.prototype.getSurfaceConfig = function ( config ) {
|
||||||
config = ve.extendObject( { mode: this.defaultMode }, config );
|
config = ve.extendObject( { mode: this.defaultMode }, config );
|
||||||
return CommentTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
|
return CommentTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
|
||||||
commandRegistry: config.mode === 'source' ? registries.wikitextCommandRegistry : registries.commandRegistry,
|
commandRegistry: config.mode === 'source' ? registries.wikitextCommandRegistry : registries.commandRegistry,
|
||||||
sequenceRegistry: config.mode === 'source' ? registries.wikitextSequenceRegistry : registries.sequenceRegistry,
|
sequenceRegistry: config.mode === 'source' ? registries.wikitextSequenceRegistry :
|
||||||
|
this.replyWidget.isNewTopic ? registries.sequenceRegistry : registries.sequenceRegistryForReplyTool,
|
||||||
dataTransferHandlerFactory: config.mode === 'source' ? ve.ui.wikitextDataTransferHandlerFactory : ve.ui.dataTransferHandlerFactory,
|
dataTransferHandlerFactory: config.mode === 'source' ? ve.ui.wikitextDataTransferHandlerFactory : ve.ui.dataTransferHandlerFactory,
|
||||||
|
importRules: this.replyWidget.isNewTopic ? this.constructor.static.importRules : this.constructor.static.importRulesForReplyTool,
|
||||||
// eslint-disable-next-line no-jquery/no-global-selector
|
// eslint-disable-next-line no-jquery/no-global-selector
|
||||||
$overlayContainer: $( '#content' )
|
$overlayContainer: $( '#content' )
|
||||||
}, config ) );
|
}, config ) );
|
||||||
|
|
|
@ -11,8 +11,23 @@ var CommentTarget = require( './CommentTarget.js' );
|
||||||
* @param {Object} [config] Configuration options
|
* @param {Object} [config] Configuration options
|
||||||
*/
|
*/
|
||||||
function CommentTargetWidget( replyWidget, config ) {
|
function CommentTargetWidget( replyWidget, config ) {
|
||||||
config = $.extend( {}, {
|
var excludeCommands = [
|
||||||
excludeCommands: [
|
'blockquoteWrap', // T258194
|
||||||
|
// Disable to allow Tab/Shift+Tab to move focus out of the widget (T172694)
|
||||||
|
'indent',
|
||||||
|
'outdent',
|
||||||
|
// Save commands get loaded from articletarget module, which we load
|
||||||
|
// to get the edit switching tool for mobile
|
||||||
|
'showSave',
|
||||||
|
'showChanges',
|
||||||
|
'showPreview',
|
||||||
|
'saveMinoredit',
|
||||||
|
'saveWatchthis'
|
||||||
|
];
|
||||||
|
|
||||||
|
if ( !replyWidget.isNewTopic ) {
|
||||||
|
excludeCommands = excludeCommands.concat( [
|
||||||
|
// Disable commands for things whose wikitext markup doesn't work when indented
|
||||||
'heading1',
|
'heading1',
|
||||||
'heading2',
|
'heading2',
|
||||||
'heading3',
|
'heading3',
|
||||||
|
@ -21,20 +36,12 @@ function CommentTargetWidget( replyWidget, config ) {
|
||||||
'heading6',
|
'heading6',
|
||||||
'insertTable',
|
'insertTable',
|
||||||
'transclusionFromSequence', // T253667
|
'transclusionFromSequence', // T253667
|
||||||
'blockquoteWrap', // T258194
|
'preformatted'
|
||||||
// Disable to allow Tab/Shift+Tab to move focus out of the widget (T172694)
|
] );
|
||||||
'indent',
|
}
|
||||||
'outdent',
|
|
||||||
// Disable preformatted
|
config = $.extend( {}, {
|
||||||
'preformatted',
|
excludeCommands: excludeCommands
|
||||||
// Save commands get loaded from articletarget module, which we load
|
|
||||||
// to get the edit switching tool for mobile
|
|
||||||
'showSave',
|
|
||||||
'showChanges',
|
|
||||||
'showPreview',
|
|
||||||
'saveMinoredit',
|
|
||||||
'saveWatchthis'
|
|
||||||
]
|
|
||||||
}, config );
|
}, config );
|
||||||
|
|
||||||
this.replyWidget = replyWidget;
|
this.replyWidget = replyWidget;
|
||||||
|
|
|
@ -57,43 +57,46 @@ sequenceRegistry.register(
|
||||||
|
|
||||||
// TODO: Show a warning when typing ~~~~ in wikitext mode?
|
// TODO: Show a warning when typing ~~~~ in wikitext mode?
|
||||||
|
|
||||||
// Show wikitext warnings for disabled sequences (disabled via excludeCommand):
|
// Show wikitext warnings for disabled sequences (disabled via excludeCommands):
|
||||||
|
var sequenceRegistryForReplyTool = new ve.ui.SequenceRegistry();
|
||||||
|
importRegistry( sequenceRegistry, sequenceRegistryForReplyTool );
|
||||||
|
|
||||||
// insertTable
|
// insertTable
|
||||||
sequenceRegistry.register(
|
sequenceRegistryForReplyTool.unregister( 'wikitextTable' );
|
||||||
new ve.ui.Sequence( 'wikitextTable', 'mwWikitextWarning', '{|' )
|
sequenceRegistryForReplyTool.register(
|
||||||
|
new ve.ui.Sequence( 'wikitextTableWarning', 'mwWikitextWarning', '{|' )
|
||||||
);
|
);
|
||||||
ve.ui.commandHelpRegistry.unregister( 'table' );
|
|
||||||
|
|
||||||
// transclusionFromSequence
|
// transclusionFromSequence
|
||||||
sequenceRegistry.register(
|
sequenceRegistryForReplyTool.unregister( 'wikitextTemplate' );
|
||||||
new ve.ui.Sequence( 'wikitextTemplate', 'mwWikitextWarning', '{{' )
|
sequenceRegistryForReplyTool.register(
|
||||||
|
new ve.ui.Sequence( 'wikitextTemplateWarning', 'mwWikitextWarning', '{{' )
|
||||||
);
|
);
|
||||||
ve.ui.commandHelpRegistry.unregister( 'template' );
|
|
||||||
|
|
||||||
// blockquoteWrap
|
// blockquoteWrap - note, this one applies to `sequenceRegistry` as well
|
||||||
|
sequenceRegistry.unregister( 'wikitextDescription' );
|
||||||
sequenceRegistry.register(
|
sequenceRegistry.register(
|
||||||
new ve.ui.Sequence( 'wikitextDescription', 'mwWikitextWarning', [ { type: 'paragraph' }, ':' ] )
|
new ve.ui.Sequence( 'wikitextDescriptionWarning', 'mwWikitextWarning', [ { type: 'paragraph' }, ':' ] )
|
||||||
);
|
);
|
||||||
ve.ui.commandHelpRegistry.unregister( 'blockquote' );
|
|
||||||
|
|
||||||
// heading1-6
|
// heading1-6
|
||||||
// This sequence doesn't usually have a command as we don't know what
|
// This sequence doesn't usually have a command as we don't know what
|
||||||
// heading level is required, but for warnings this doesn't matter.
|
// heading level is required, but for warnings this doesn't matter.
|
||||||
sequenceRegistry.register(
|
sequenceRegistryForReplyTool.unregister( 'wikitextHeading' );
|
||||||
new ve.ui.Sequence( 'wikitextHeading', 'mwWikitextWarning', [ { type: 'paragraph' }, '=', '=' ] )
|
sequenceRegistryForReplyTool.register(
|
||||||
|
new ve.ui.Sequence( 'wikitextHeadingWarning', 'mwWikitextWarning', [ { type: 'paragraph' }, '=', '=' ] )
|
||||||
);
|
);
|
||||||
ve.ui.commandHelpRegistry.unregister( 'heading2' );
|
|
||||||
|
|
||||||
// horizontal rule
|
// horizontal rule
|
||||||
sequenceRegistry.register(
|
sequenceRegistryForReplyTool.unregister( 'horizontalRule' );
|
||||||
new ve.ui.Sequence( 'horizontalRule', 'mwWikitextWarning', [ { type: 'paragraph' }, '-', '-', '-', '-' ] )
|
sequenceRegistryForReplyTool.register(
|
||||||
|
new ve.ui.Sequence( 'horizontalRuleWarning', 'mwWikitextWarning', [ { type: 'paragraph' }, '-', '-', '-', '-' ] )
|
||||||
);
|
);
|
||||||
ve.ui.commandHelpRegistry.unregister( 'horizontalRule' );
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
commandRegistry: commandRegistry,
|
commandRegistry: commandRegistry,
|
||||||
sequenceRegistry: sequenceRegistry,
|
sequenceRegistry: sequenceRegistry,
|
||||||
|
sequenceRegistryForReplyTool: sequenceRegistryForReplyTool,
|
||||||
wikitextCommandRegistry: wikitextCommandRegistry,
|
wikitextCommandRegistry: wikitextCommandRegistry,
|
||||||
wikitextSequenceRegistry: wikitextSequenceRegistry
|
wikitextSequenceRegistry: wikitextSequenceRegistry
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue