You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop: Accessibility: Add a new shortcut to set focus to editor toolbar (#11764)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { CommandRuntime, CommandDeclaration } from '@joplin/lib/services/CommandService';
|
||||
import { _ } from '@joplin/lib/locale';
|
||||
import { focus } from '@joplin/lib/utils/focusHandler';
|
||||
import { WindowCommandDependencies } from '../utils/types';
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'focusElementToolbar',
|
||||
label: () => _('Toolbar'),
|
||||
parentLabel: () => _('Focus'),
|
||||
};
|
||||
|
||||
export const runtime = (dependencies: WindowCommandDependencies): CommandRuntime => {
|
||||
return {
|
||||
execute: async () => {
|
||||
if (!dependencies || !dependencies.containerRef || !dependencies.containerRef.current) return;
|
||||
|
||||
const firstButtonOnRTEToolbar = dependencies.containerRef.current.querySelector(
|
||||
'.tox-toolbar__group button',
|
||||
);
|
||||
|
||||
if (firstButtonOnRTEToolbar) {
|
||||
focus('focusElementToolbar', firstButtonOnRTEToolbar);
|
||||
return;
|
||||
}
|
||||
|
||||
const firstButtonOnMarkdownToolbar = dependencies.containerRef.current.querySelector(
|
||||
'#CodeMirrorToolbar .button:not(.disabled)',
|
||||
);
|
||||
|
||||
if (firstButtonOnMarkdownToolbar) {
|
||||
focus('focusElementToolbar', firstButtonOnMarkdownToolbar);
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user