aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/cke/studip-a11y-dialog/command.js
blob: ab97515375df367df8c1b3f144303d5de25681d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Command } from '@ckeditor/ckeditor5-core';
import Dialog from '../../lib/dialog.js';

export default class A11YDialogCommand extends Command {
    refresh() {
        this.isEnabled = true;
    }

    execute() {
        const activeElement = document.activeElement;
        const id = 'cke-a11y-help';
        Dialog.fromURL(STUDIP.URLHelper.getURL('dispatch.php/wysiwyg/a11yhelp'), { id });
        $(document).one('dialog-close', function (event, { options }) {
            if (options.id === id) {
                activeElement?.focus();
            }
        });
    }
}