DLynch has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/248370

Change subject: Include sequences in the command help dialog
......................................................................

Include sequences in the command help dialog

The command help dialog currently only shows keyboard shortcuts. If we
use the sequence registry, we can add the sequences to the relevant
commands.

Currently ignored in this is a way to represent "you must be at the
start of a paragraph".

Change-Id: I21fd47f5809dce36d10edc483121ecbdc12071f6
---
M src/init/sa/ve.init.sa.Target.js
M src/ui/dialogs/ve.ui.CommandHelpDialog.js
M src/ui/styles/dialogs/ve.ui.CommandHelpDialog.css
M src/ui/tools/ve.ui.DialogTool.js
M src/ui/ve.ui.CommandRegistry.js
M src/ui/ve.ui.Sequence.js
6 files changed, 77 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/70/248370/1

diff --git a/src/init/sa/ve.init.sa.Target.js b/src/init/sa/ve.init.sa.Target.js
index 84e7d9f..6fdbb43 100644
--- a/src/init/sa/ve.init.sa.Target.js
+++ b/src/init/sa/ve.init.sa.Target.js
@@ -49,7 +49,7 @@
                type: 'list',
                icon: 'menu',
                title: OO.ui.deferMsg( 'visualeditor-pagemenu-tooltip' ),
-               include: [ 'findAndReplace', 'commandHelp' ]
+               include: [ 'findAndReplace', 'commandHelp', 'sequenceHelp' ]
        }
 ];
 
diff --git a/src/ui/dialogs/ve.ui.CommandHelpDialog.js 
b/src/ui/dialogs/ve.ui.CommandHelpDialog.js
index f3c0b49..c670eb4 100644
--- a/src/ui/dialogs/ve.ui.CommandHelpDialog.js
+++ b/src/ui/dialogs/ve.ui.CommandHelpDialog.js
@@ -52,7 +52,7 @@
  */
 ve.ui.CommandHelpDialog.prototype.initialize = function () {
        var i, j, jLen, k, kLen, triggerList, commands, shortcut, platform, 
platformKey,
-               $list, $shortcut, commandGroups;
+               $list, $shortcut, commandGroups, sequence;
 
        // Parent method
        ve.ui.CommandHelpDialog.super.prototype.initialize.call( this );
@@ -76,14 +76,16 @@
                                triggerList = ve.ui.triggerRegistry.lookup( 
commands[ j ].trigger );
                        } else {
                                triggerList = [];
-                               for ( k = 0, kLen = commands[ j 
].shortcuts.length; k < kLen; k++ ) {
-                                       shortcut = commands[ j ].shortcuts[ k ];
-                                       triggerList.push(
-                                               new ve.ui.Trigger(
-                                                       ve.isPlainObject( 
shortcut ) ? shortcut[ platformKey ] : shortcut,
-                                                       true
-                                               )
-                                       );
+                               if ( commands[ j ].shortcuts ) {
+                                       for ( k = 0, kLen = commands[ j 
].shortcuts.length; k < kLen; k++ ) {
+                                               shortcut = commands[ j 
].shortcuts[ k ];
+                                               triggerList.push(
+                                                       new ve.ui.Trigger(
+                                                               
ve.isPlainObject( shortcut ) ? shortcut[ platformKey ] : shortcut,
+                                                               true
+                                                       )
+                                               );
+                                       }
                                }
                        }
                        $shortcut = $( '<dt>' );
@@ -91,6 +93,14 @@
                                $shortcut.append( $( '<kbd>' ).text(
                                        triggerList[ k ].getMessage().replace( 
/\+/g, ' + ' )
                                ) );
+                       }
+                       if ( commands[ j ].sequence ) {
+                               for ( k = 0, kLen = commands[ j 
].sequence.length; k < kLen; k++ ) {
+                                       sequence = 
ve.ui.sequenceRegistry.lookup( commands[ j ].sequence[ k ] );
+                                       $shortcut.append( $( '<kbd>' ).html(
+                                               sequence.toString().replace( / 
/g, '<span class="ve-ui-commandHelpDialog-symbol-space">space</span>' )
+                                       ) );
+                               }
                        }
                        $list.append(
                                $shortcut,
@@ -170,7 +180,9 @@
                                { trigger: 'preformatted', msg: 
'visualeditor-formatdropdown-format-preformatted' },
                                { trigger: 'blockquote', msg: 
'visualeditor-formatdropdown-format-blockquote' },
                                { trigger: 'indent', msg: 
'visualeditor-indentationbutton-indent-tooltip' },
-                               { trigger: 'outdent', msg: 
'visualeditor-indentationbutton-outdent-tooltip' }
+                               { trigger: 'outdent', msg: 
'visualeditor-indentationbutton-outdent-tooltip' },
+                               { sequence: [ 'bulletStar' ], msg: 
'visualeditor-listbutton-bullet-tooltip' },
+                               { sequence: [ 'numberDot' ], msg: 
'visualeditor-listbutton-number-tooltip' }
                        ]
                },
                history: {
diff --git a/src/ui/styles/dialogs/ve.ui.CommandHelpDialog.css 
b/src/ui/styles/dialogs/ve.ui.CommandHelpDialog.css
index 41f4e92..c60c971 100644
--- a/src/ui/styles/dialogs/ve.ui.CommandHelpDialog.css
+++ b/src/ui/styles/dialogs/ve.ui.CommandHelpDialog.css
@@ -59,6 +59,12 @@
        margin-top: 0.2em;
 }
 
+.ve-ui-commandHelpDialog-symbol-space {
+       border: 1px solid #ccc;
+       padding: 0 2px;
+       text-transform: uppercase;
+}
+
 .ve-ui-commandHelpDialog-list dd,
 .ve-ui-commandHelpDialog-list dt {
        line-height: 110%;
diff --git a/src/ui/tools/ve.ui.DialogTool.js b/src/ui/tools/ve.ui.DialogTool.js
index f2aef73..ac53dec 100644
--- a/src/ui/tools/ve.ui.DialogTool.js
+++ b/src/ui/tools/ve.ui.DialogTool.js
@@ -96,3 +96,26 @@
 ve.ui.CommandHelpDialogTool.static.autoAddToGroup = false;
 ve.ui.CommandHelpDialogTool.static.commandName = 'commandHelp';
 ve.ui.toolFactory.register( ve.ui.CommandHelpDialogTool );
+
+/**
+ * Sequence help tool.
+ *
+ * @class
+ * @extends ve.ui.DialogTool
+ * @constructor
+ * @param {OO.ui.ToolGroup} toolGroup
+ * @param {Object} [config] Configuration options
+ */
+ve.ui.SequenceHelpDialogTool = function VeUiSequenceHelpDialogTool() {
+       ve.ui.SequenceHelpDialogTool.super.apply( this, arguments );
+};
+OO.inheritClass( ve.ui.SequenceHelpDialogTool, ve.ui.DialogTool );
+ve.ui.SequenceHelpDialogTool.static.name = 'sequenceHelp';
+ve.ui.SequenceHelpDialogTool.static.group = 'dialog';
+ve.ui.SequenceHelpDialogTool.static.icon = 'help';
+ve.ui.SequenceHelpDialogTool.static.title =
+       OO.ui.deferMsg( 'visualeditor-dialog-sequence-help-title' );
+ve.ui.SequenceHelpDialogTool.static.autoAddToCatchall = false;
+ve.ui.SequenceHelpDialogTool.static.autoAddToGroup = false;
+ve.ui.SequenceHelpDialogTool.static.commandName = 'sequenceHelp';
+ve.ui.toolFactory.register( ve.ui.SequenceHelpDialogTool );
diff --git a/src/ui/ve.ui.CommandRegistry.js b/src/ui/ve.ui.CommandRegistry.js
index 8cb8159..50252b3 100644
--- a/src/ui/ve.ui.CommandRegistry.js
+++ b/src/ui/ve.ui.CommandRegistry.js
@@ -141,6 +141,11 @@
 );
 ve.ui.commandRegistry.register(
        new ve.ui.Command(
+               'sequenceHelp', 'window', 'open', { args: [ 'sequenceHelp' ] }
+       )
+);
+ve.ui.commandRegistry.register(
+       new ve.ui.Command(
                'findAndReplace', 'window', 'toggle', { args: [ 
'findAndReplace' ] }
        )
 );
diff --git a/src/ui/ve.ui.Sequence.js b/src/ui/ve.ui.Sequence.js
index fe3f428..dd40a0d 100644
--- a/src/ui/ve.ui.Sequence.js
+++ b/src/ui/ve.ui.Sequence.js
@@ -116,3 +116,23 @@
 ve.ui.Sequence.prototype.getCommandName = function () {
        return this.commandName;
 };
+
+/**
+ * Get a string representation of the sequence.
+ *
+ * @return {string} string
+ */
+ve.ui.Sequence.prototype.toString = function () {
+       if ( typeof this.data === 'string' ) {
+               return this.data;
+       }
+       if ( this.data instanceof RegExp ) {
+               return this.data.toString();
+       }
+       return this.data.map( function ( key ) {
+               if ( ve.isPlainObject( key ) ) {
+                       return '';
+               }
+               return key;
+       } ).join( '' );
+};

-- 
To view, visit https://gerrit.wikimedia.org/r/248370
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21fd47f5809dce36d10edc483121ecbdc12071f6
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to