Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Tiny Record RTC - record audio command.
18
 *
19
 * @module      tiny_recordrtc/commands_audio
20
 * @copyright   2022, Stevani Andolo <stevani@hotmail.com.au>
21
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
import {getString} from 'core/str';
25
import {getButtonImage} from 'editor_tiny/utils';
26
import {
27
    audioButtonName,
28
    component
29
} from './common';
30
import Recorder from './audio_recorder';
31
import {isAudioAllowed} from './options';
32
 
33
export default async() => {
34
    if (!Recorder.isBrowserCompatible()) {
35
        // The browser doesn't support the plugin, so just don't show it.
36
        return () => false;
37
    }
38
 
39
    const [
40
        audioButtonTitle,
41
        audio,
42
    ] = await Promise.all([
43
        getString('audiobuttontitle', component),
44
        getButtonImage('audio', component),
45
    ]);
46
 
47
    return (editor) => {
48
        if (!isAudioAllowed(editor)) {
49
            return;
50
        }
51
 
52
        const icon = 'audio';
53
        editor.ui.registry.addIcon(icon, audio.html);
54
 
55
        editor.ui.registry.addButton(audioButtonName, {
56
            icon,
57
            tooltip: audioButtonTitle,
58
            onAction: () => Recorder.display(editor),
59
        });
60
 
61
        editor.ui.registry.addMenuItem(audioButtonName, {
62
            icon,
63
            text: audioButtonTitle,
64
            onAction: () => Recorder.display(editor),
65
        });
66
    };
67
};