-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List all available hotkeys in the Accessibility Instructions dialog #569
Conversation
Please make sure that you remember about the following things:
|
@AnnaTomanek Generally entire command section, which was predefined in Accessibility Helper plugin now is removed and replaced by automatically generated table, where I'm not sure what is proper way in such case. Should those static translations remain in accessibility language files, even though are not used any longer? |
3e1b561
to
a446035
Compare
This case is a little tricky, as @AnnaTomanek said we would like to make as little changes as possible in language files (especially when translations are already there) especially when just moving language keys/strings around. However, as @msamsel pointed out the previous solution basically had predefined values which were used in Commands/Shortcuts section in @mlewand I think if we decide to go with such solution it will be good to extract it to a new issue (which will be a new feature introducing possibility for each command to contain/register additional information like command label and description). WDYT? |
Generally there wasn't much text to remain. Most of it had to be removed. Commands are now in a table which downloads label for them automatically. It takes values from command label or if there is no command label, then from command ui button label. So most of them should have translations already. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While checking lang relations I caught few minor things, marked as a comments.
core/commanddefinition.js
Outdated
@@ -160,3 +160,17 @@ | |||
* @since 4.6.0 | |||
* @property {Number} fakeKeystroke | |||
*/ | |||
|
|||
/** | |||
* Defines optional command label. Property is automatically used by accessibility helper to display it in Command table. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to say that some property is optional in the description. This should be marked by wrapping prop name within brackets.
plugins/a11yhelp/plugin.js
Outdated
* @class | ||
* @singleton | ||
*/ | ||
CKEDITOR.plugins.a11yhelp = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This namespace itself should be marked with @since
tag as it wasn't present before.
plugins/magicline/lang/af.js
Outdated
@@ -4,5 +4,13 @@ | |||
*/ | |||
|
|||
CKEDITOR.plugins.setLang( 'magicline', 'af', { | |||
title: 'Voeg paragraaf hier in' | |||
title: 'Voeg paragraaf hier in', | |||
commandsLabels: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better other way around, say:
commands: {
previousSpace: {
label: 'foo',
description: 'bar'
},
nextSpace: {
label: 'foo',
description: 'bar'
}
}
Sure, we need to retain translations whenever possible. Unfortunately in this case it won't be possible, as new translations will be different than the former one - new labels are much shorter/atomic. Old approach was bad, having redundant text and a knowledge about external plugins in Luckily it's set for a major release so there's plenty of time for our translation Contributors to pick it up. |
I correct problems mention by @mlewand, add milestone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are few things to polish:
- Update language meta files.
- Magicline plugin diff looks like whole plugin had changed, did you rearrange the code for some reason or did some bigger changes there?
The one thing I'm not sure about is keystrokeEntry
event. It looks a little redundant to me. It is used to give the possibility to alter command label/description. But this
is very specialized event and basically will be used only for this particular case only by Accessibility Help dialog (theoretically, it can be used by similar
plugins too).
Wouldn't it be better to mark commandDefiniton.label
, commandDefiniton.description
as private properties and then introduce default
getters which can be overridden to change default label/description value?
This also will be simpler to use by other plugins as you don't have to remember to fire an event to get proper command label/description, you just use a getter.
@@ -0,0 +1,15 @@ | |||
@bender-tags: manual, 456, tc, 4.8.0, feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop tc
tag.
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: wysiwygarea,a11yhelp | ||
|
||
1. Focus editor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to always end sentence with .
in lists (or ,
if it is a verbless sentence - well I wasn't 100% sure myself so here is some explanation) :)
|
||
1. Focus editor | ||
1. Press `Alt + 0`, there should be section **Commands table** | ||
1. Table should contain at least one keystroke `Alt + 0` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that point which is not an action/step, but rather a result of previous step is an expected behaviour. It can be a subitem like:
- Press
Alt + 0
- There should be section Commands table which contains at least one keystroke
Alt + 0
.
- There should be section Commands table which contains at least one keystroke
or
- Press
Alt + 0
- Expected: There should be section Commands table which contains at least one keystroke
Alt + 0
.
- Expected: There should be section Commands table which contains at least one keystroke
If scenario is short enough, expected results could be combined and placed after it (not in this case IMHO).
|
||
function addCommands() { | ||
editor.destroy(); | ||
editor =CKEDITOR.replace( 'editor1' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editor =CKEDITOR.replace( 'editor1' );
missing space after =
.
core/commanddefinition.js
Outdated
@@ -160,3 +160,17 @@ | |||
* @since 4.6.0 | |||
* @property {Number} fakeKeystroke | |||
*/ | |||
|
|||
/** | |||
* Defines command label. Property is automatically used by accessibility helper to display it in Command table. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this description more generic like:
Defines command label. This property is used by different plugins to display command information (by e.g. Accessibility Help).
Same for description
property above.
There was a lot of changes. About magicline, linters report many issues. Most of them was declaring something after usage. Changes are rearranging code to have most of variables declaration at the beginning, also some functions was invoked inside another which also had to be rearranged. As far as I remember I've made only significant changes here (https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/magicline/plugin.js#L892-L894) |
plugins/pastetext/plugin.js
Outdated
@@ -80,6 +90,13 @@ | |||
editor.on( 'pasteState', function( evt ) { | |||
editor.getCommand( commandName ).setState( evt.data ); | |||
} ); | |||
|
|||
editor.on( 'keystrokeEntry', function( evt ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all leftovers of keystrokeEntry
event (some left also in tests).
core/command.js
Outdated
@@ -116,6 +116,42 @@ CKEDITOR.command = function( editor, commandDefinition ) { | |||
return allowed = editor.activeFilter.checkFeature( this ); | |||
}; | |||
|
|||
/** | |||
* Providing this method will overwrite {@link CKEDITOR.commandDefinition#getLabel}, what allows on better customization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the description might be a little bit confusing/misleading.
- The main function of this method is just returning the label. So the description should say that it returns command label first.
-
Providing this method will overwrite {@link CKEDITOR.commandDefinition#getLabel}, what allows on better customization
As for providing this method - this method is already provided, the one which can be provided additionally is CKEDITOR.commandDefinition#getLabel
(and this is CKEDITOR.command#getLabel
) so this part should go to commandDefintion
specs. And the part from commandDefintion
about fallback should land here IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for getKeyDescription
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rearrange it, I hope it will be ok ;D
core/commanddefinition.js
Outdated
* Defines command label. This property is used by different plugins to display command information (by e.g. Accessibility Help). | ||
* For geting command's label please use {@link CKEDITOR.commandDefinition#getLabel}, instead of directly reading `label` property. | ||
* | ||
* @since 4.8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark as @private
. Same for keyDescription
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have doubts about it. If those will be marked as @private
, then some kind of 'setter' might be required. Users might not see those variables, or be afraid of modifying them. What do you think about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
core/commanddefinition.js
Outdated
|
||
/** | ||
* Defines command label. This property is used by different plugins to display command information (by e.g. Accessibility Help). | ||
* For geting command's label please use {@link CKEDITOR.commandDefinition#getLabel}, instead of directly reading `label` property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For geting command's label please use {@link CKEDITOR.commandDefinition#getLabel}
Here you should link to CKEDITOR.command#getLabel
.
@@ -100,3 +100,6 @@ openBracket = The label for the "Open Bracket" ([) key. | |||
backSlash = The label for the "Backslash" (\) key. | |||
closeBracket = The label for the "Close Bracket" (]) key. | |||
singleQuote = The label for the "Single Quote" (') key. | |||
commandsList.sectionName = Label for section, which displays table with command's keystrokes. | |||
commandsList.command = Label for headr of table column, which provides commands labels (names). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label for table column header, which contains command labels (names).
?
@@ -100,3 +100,6 @@ openBracket = The label for the "Open Bracket" ([) key. | |||
backSlash = The label for the "Backslash" (\) key. | |||
closeBracket = The label for the "Close Bracket" (]) key. | |||
singleQuote = The label for the "Single Quote" (') key. | |||
commandsList.sectionName = Label for section, which displays table with command's keystrokes. | |||
commandsList.command = Label for headr of table column, which provides commands labels (names). | |||
commandsList.keystroke = Label for header of table column, which provides keystroke for executing specific commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label for table column header, which contains keystrokes for executing specific commands.
?
plugins/a11yhelp/dialogs/a11yhelp.js
Outdated
var commandsSectionTpl = '<h1>%1</h1><table>%2</table>', | ||
commandRowTpl = '<tr><td>%1</td><td>%2</td></tr>', | ||
commandsTbodyTpl = '<tbody>%1</tbody>', | ||
commandsTbodyHtml = '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/core/command/command.js
Outdated
}, | ||
|
||
// #456 | ||
'test basic behavor of getLabel': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
behavior (missing i
)
tests/plugins/a11yhelp/a11yhelp.js
Outdated
} ); | ||
}, | ||
|
||
'test keystrokeEntry event': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some leftovers of keystrokeEntry
event in this file and also in tests/plugins/a11yhelp/manual/commandstable
manual test (which fails now).
} else if ( commandDefinition.label ) { | ||
return commandDefinition.label; | ||
} else if ( this.uiItems && this.uiItems.length && this.uiItems[ 0 ].label ) { | ||
return this.uiItems[ 0 ].label; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason for this fallback, was it used anywhere before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of fallback allows on reusing already created labels for buttons without modifying all other plugins.
So steps are to use getLabel
method if exist, then label
property, and then button's label if exist. So we use translations for button's label such as bold, italic, etc, without waiting for them being translate and just use what we have already.
core/commanddefinition.js
Outdated
* 2. If {@link CKEDITOR.commandDefinition#label} atribute exists, it is used to provide label. | ||
* 3. If {@link CKEDITOR.command#uiItems} is non empty, then label of first array's item is used as label | ||
* 4. Empty string. | ||
* Providing this method will overwrite {@link CKEDITOR.command#getLabel}, what allows on better customization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My previous comment might be misleading a little, sorry for that. You moved the description to the right place as I suggested, but still:
Providing this method will overwrite {@link CKEDITOR.command#getLabel}
Providing this method will not overwrite CKEDITOR.command#getLabel
. The provided method will be just used by CKEDITOR.command#getLabel
to return a label. I suggest to update the description to something like:
If present, this method will be used to provide command's label. It allows customizing label for a specific command.
Same for getKeyDescription
description.
core/commanddefinition.js
Outdated
* Defines command label. This property is used by different plugins to display command information (by e.g. Accessibility Help). | ||
* For geting command's label please use {@link CKEDITOR.commandDefinition#getLabel}, instead of directly reading `label` property. | ||
* | ||
* @since 4.8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good. Just few small things:
- I'm thinking that
keyDescription
should be namedkeystrokeDescription
WDYT? - Please remove
legendEdge
language entry as it is not used anymore (if it was not added to meta lang files you just need to regenerate lang files).
I also checked how it works with JAWS and it works the same way as before (except the fact that JAWS announces table content, but it works well). So there are no regressions in this regard.
plugins/a11yhelp/plugin.js
Outdated
|
||
editor.addCommand( commandName, { | ||
exec: function() { | ||
CKEDITOR.document.appendStyleSheet( CKEDITOR.getUrl( plugin.path + 'styles/a11yhelp.css' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stylesheet is appended every time dialog is opened. It should be appended only once. It should be placed in onLoad
plugin method.
plugins/a11yhelp/plugin.js
Outdated
coreLang = editor.lang.common.keyboard; | ||
|
||
// CharCode <-> KeyChar. | ||
var keyMap = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this map could be defined as CKEDITOR.plugins.a11yhelp
property? Now, every time the method is called, the map is defined again.
plugins/a11yhelp/styles/a11yhelp.css
Outdated
padding: 0.8em; | ||
} | ||
|
||
.cke_accessibility_legend tbody > tr:nth-child(odd) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not supported in IE8 😞 Maybe we could use .odd
class when generating the commands table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there :)
@@ -69,7 +69,7 @@ common.invalidCssLength = Error message displayed to the user when the specified | |||
common.invalidHtmlLength = Error message displayed to the user when the specified length value is not a valid HTML measurement unit. | |||
common.invalidInlineStyle = Error message displayed to the user when the specified style value is not a valid CSS declaration. | |||
common.cssLengthTooltip = Tooltip displayed for the Width and Height fields in the Table Properties dialog window explaining the correct format of these length values. | |||
common.unavailable = | |||
common.unavailable = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this lang entry get here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither. ;) I just use dev/langtool/langtool.sh
and it was somehow affected by this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW it was only added space at the end of lien if I see correct comparing to repository: https://github.com/ckeditor/ckeditor-dev/blob/master/dev/langtool/meta/ckeditor.core/meta.txt#L72
So I'm not sure what should with that :) any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we decided to left it as it is.
plugins/a11yhelp/plugin.js
Outdated
*/ | ||
representKeystroke: function( editor, keystroke ) { | ||
_renderKeyMap: function( editor ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify creating keyMap
even more, just creating singleton like method:
_renderKeyMap: ( function() {
var keyMapCache;
return function( editor ) {
if ( !keyMapCache ) {
// Here goes the body of the current function. Created keyMap should be assigned to keyMapCache variable.
}
return keyMapCache;
}
} )();
And then we can completely drop _keyMap
property and just use var keyMap = this._renderKeyMap( editor );
in other places.
Also renderKeyMap
is somehow misleading name, this functions does not render anything it creates/generates key map object so it can be e.g. [create/generate/get]keyMap
.
Ok this hidden comment is corrected also ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Very solid piece of work 👍
@mlewand, please check if your previous change requests were fulfilled or if you have any more comments. |
… dispaly keystrokes list.
… to be more accurate.
Pushed one commit with some code style adjustments. |
This feature should utilize features already available in tools, there's a keystrokeToString method that is perfect candidate. Currently However we can't use I have created an issue #856 for that - issue #856 will block this pull request. |
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
yes
This PR contains
What changes did you make?
editor.event
keystrokeEntry
which allows on modification displayed keystrokeslabel
anddescription
property which later on will be used by accessibility plugin to present it in a table.representKeystroke
to be available in editor.close #456