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:
Bartosz Dziewoński 2022-07-31 01:57:22 +02:00
parent 4da2ecf32f
commit e5abfdbe8a
3 changed files with 63 additions and 42 deletions

View file

@ -88,21 +88,30 @@ if ( OO.ui.isMobile() ) {
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,
{
// Annotations
// 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
mwTable: true,
tableSection: true,
@ -122,8 +131,10 @@ CommentTarget.prototype.getSurfaceConfig = function ( config ) {
config = ve.extendObject( { mode: this.defaultMode }, config );
return CommentTarget.super.prototype.getSurfaceConfig.call( this, ve.extendObject( {
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,
importRules: this.replyWidget.isNewTopic ? this.constructor.static.importRules : this.constructor.static.importRulesForReplyTool,
// eslint-disable-next-line no-jquery/no-global-selector
$overlayContainer: $( '#content' )
}, config ) );

View file

@ -11,8 +11,23 @@ var CommentTarget = require( './CommentTarget.js' );
* @param {Object} [config] Configuration options
*/
function CommentTargetWidget( replyWidget, config ) {
config = $.extend( {}, {
excludeCommands: [
var 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',
'heading2',
'heading3',
@ -21,20 +36,12 @@ function CommentTargetWidget( replyWidget, config ) {
'heading6',
'insertTable',
'transclusionFromSequence', // T253667
'blockquoteWrap', // T258194
// Disable to allow Tab/Shift+Tab to move focus out of the widget (T172694)
'indent',
'outdent',
// Disable preformatted
'preformatted',
// Save commands get loaded from articletarget module, which we load
// to get the edit switching tool for mobile
'showSave',
'showChanges',
'showPreview',
'saveMinoredit',
'saveWatchthis'
]
'preformatted'
] );
}
config = $.extend( {}, {
excludeCommands: excludeCommands
}, config );
this.replyWidget = replyWidget;

View file

@ -57,43 +57,46 @@ sequenceRegistry.register(
// 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
sequenceRegistry.register(
new ve.ui.Sequence( 'wikitextTable', 'mwWikitextWarning', '{|' )
sequenceRegistryForReplyTool.unregister( 'wikitextTable' );
sequenceRegistryForReplyTool.register(
new ve.ui.Sequence( 'wikitextTableWarning', 'mwWikitextWarning', '{|' )
);
ve.ui.commandHelpRegistry.unregister( 'table' );
// transclusionFromSequence
sequenceRegistry.register(
new ve.ui.Sequence( 'wikitextTemplate', 'mwWikitextWarning', '{{' )
sequenceRegistryForReplyTool.unregister( 'wikitextTemplate' );
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(
new ve.ui.Sequence( 'wikitextDescription', 'mwWikitextWarning', [ { type: 'paragraph' }, ':' ] )
new ve.ui.Sequence( 'wikitextDescriptionWarning', 'mwWikitextWarning', [ { type: 'paragraph' }, ':' ] )
);
ve.ui.commandHelpRegistry.unregister( 'blockquote' );
// heading1-6
// 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.
sequenceRegistry.register(
new ve.ui.Sequence( 'wikitextHeading', 'mwWikitextWarning', [ { type: 'paragraph' }, '=', '=' ] )
sequenceRegistryForReplyTool.unregister( 'wikitextHeading' );
sequenceRegistryForReplyTool.register(
new ve.ui.Sequence( 'wikitextHeadingWarning', 'mwWikitextWarning', [ { type: 'paragraph' }, '=', '=' ] )
);
ve.ui.commandHelpRegistry.unregister( 'heading2' );
// horizontal rule
sequenceRegistry.register(
new ve.ui.Sequence( 'horizontalRule', 'mwWikitextWarning', [ { type: 'paragraph' }, '-', '-', '-', '-' ] )
sequenceRegistryForReplyTool.unregister( 'horizontalRule' );
sequenceRegistryForReplyTool.register(
new ve.ui.Sequence( 'horizontalRuleWarning', 'mwWikitextWarning', [ { type: 'paragraph' }, '-', '-', '-', '-' ] )
);
ve.ui.commandHelpRegistry.unregister( 'horizontalRule' );
module.exports = {
commandRegistry: commandRegistry,
sequenceRegistry: sequenceRegistry,
sequenceRegistryForReplyTool: sequenceRegistryForReplyTool,
wikitextCommandRegistry: wikitextCommandRegistry,
wikitextSequenceRegistry: wikitextSequenceRegistry
};