-
Notifications
You must be signed in to change notification settings - Fork 109
[a11y] add aria-keyshortcuts #2762
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
Changes from all commits
c1e9821
2d73c6a
e264032
2117819
bef30c8
6d8b6ac
c600ec4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * @copyright Copyright (c) 2022 Vinicius Reis <[email protected]> | ||
| * | ||
| * @author Vinicius Reis <[email protected]> | ||
| * | ||
| * @license AGPL-3.0-or-later | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| import { randHash } from '../utils/index.js' | ||
|
|
||
| const randUser = randHash() | ||
|
|
||
| const prepareTest = () => { | ||
| return cy.openFile(`${Cypress.currentTest.title}.md`) | ||
| .then(() => { | ||
| return cy.getContent() | ||
| .type(Cypress.currentTest.title) | ||
| .type('{selectall}') | ||
| }) | ||
| } | ||
|
|
||
| const applyTest = (shortcut, tag) => { | ||
| cy.getContent() | ||
| .type(shortcut) | ||
|
|
||
| return cy.getContent() | ||
| .find(tag) | ||
| .should('contain', Cypress.currentTest.title) | ||
| } | ||
|
|
||
| const shortcuts = { | ||
| bold: ['{ctrl}b', 'strong'], | ||
| italic: ['{ctrl}i', 'em'], | ||
| underline: ['{ctrl}u', 'u'], | ||
| strikethrough: ['{ctrl}{shift}x', 's'], | ||
| blockquote: ['{ctrl}{shift}b', 'blockquote'], | ||
| codeblock: ['{ctrl}{alt}c', 'pre'], | ||
| 'ordered-list': ['{ctrl}{shift}7', 'ol'], | ||
| 'unordered-list': ['{ctrl}{shift}8', 'ul'], | ||
| 'task-list': ['{ctrl}{shift}9', 'ul[data-type="taskList"]'], | ||
| ...Array.from({ length: 6 }).reduce((acc, _, index) => { | ||
| const num = index + 1 | ||
| const tag = `h${num}` | ||
| acc[`heading-${tag}`] = [`{ctrl}{shift}${num}`, tag] | ||
|
|
||
| return acc | ||
| }, {}), | ||
| } | ||
|
|
||
| describe('keyboard shortcuts', () => { | ||
| before(() => { | ||
| cy.nextcloudCreateUser(randUser, 'password') | ||
| }) | ||
|
|
||
| beforeEach(() => { | ||
| cy.login(randUser, 'password') | ||
| .then(() => { | ||
| return cy.uploadFile( | ||
| 'empty.md', | ||
| 'text/markdown', | ||
| `${Cypress.currentTest.title}.md` | ||
| ) | ||
| }) | ||
| .then(() => cy.reloadFileList()) | ||
| }) | ||
|
|
||
| Object.entries(shortcuts) | ||
| .forEach(([name, [shortcut, tag]]) => { | ||
| it(name, () => { | ||
| prepareTest() | ||
| .then(() => applyTest(shortcut, tag)) | ||
| }) | ||
| }) | ||
|
|
||
| }) |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const isMac = (navigator.userAgent.includes('Mac')) | ||
|
|
||
| const MODIFIERS = { | ||
| Mod: isMac ? 'Meta' : 'Control', | ||
| Alt: 'Alt', // Option key, on Apple computers. | ||
| Control: 'Control', | ||
| Shift: 'Shift', | ||
|
|
||
| // unused | ||
| // AltGraph: 'AltGraph', | ||
| // Meta: 'Meta', // Command key on Apple computers | ||
| } | ||
|
|
||
| const TRANSLATIONS = { | ||
| [MODIFIERS.Mod]: isMac ? t('text', 'Command') : t('text', 'Control'), | ||
| [MODIFIERS.Control]: t('text', 'Ctrl'), | ||
vinicius73 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [MODIFIERS.Alt]: t('text', isMac ? 'Option' : 'Alt'), | ||
| [MODIFIERS.Shift]: t('text', 'Shift'), | ||
| } | ||
|
|
||
| export { | ||
| MODIFIERS, | ||
| TRANSLATIONS, | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.