lib/editor/tiny/plugins/recordrtc/amd/src/plugin.js

  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. * Tiny Record RTC plugin for Moodle.
  17. *
  18. * @module tiny_recordrtc/plugin
  19. * @copyright 2022, Stevani Andolo <stevani@hotmail.com.au>
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21. */
  22. import {getTinyMCE} from 'editor_tiny/loader';
  23. import {getPluginMetadata} from 'editor_tiny/utils';
  24. import getSetupAudioCommands from './commands_audio';
  25. import getSetupVideoCommands from './commands_video';
  26. import getSetupScreenCommands from './commands_screen';
  27. import getSetupVideoContextMenuCommands from './commands_video_context_menu';
  28. import * as Configuration from './configuration';
  29. import * as Options from './options';
  30. import {
  31. component,
  32. pluginName
  33. } from './common';
  34. // eslint-disable-next-line no-async-promise-executor
  35. export default new Promise(async(resolve) => {
  36. const [
  37. tinyMCE,
  38. setupAudioCommands,
  39. setupVideoCommands,
  40. setupScreenCommands,
  41. setupVideoContextMenuCommands,
  42. pluginMetadata,
  43. ] = await Promise.all([
  44. getTinyMCE(),
  45. getSetupAudioCommands(),
  46. getSetupVideoCommands(),
  47. getSetupScreenCommands(),
  48. getSetupVideoContextMenuCommands(),
  49. getPluginMetadata(component, pluginName),
  50. ]);
  51. tinyMCE.PluginManager.add(`${component}/plugin`, (editor) => {
  52. // Register options.
  53. Options.register(editor);
  54. // Setup the Commands (buttons, menu items, and so on) for video.
  55. setupVideoCommands(editor);
  56. // Setup the Commands (buttons, menu items, and so on) for audio.
  57. setupAudioCommands(editor);
  58. // Setup the Commands (buttons, menu items, and so on) for screen.
  59. setupScreenCommands(editor);
  60. // Setup the Commands (context menu) for video (recording and screen-sharing).
  61. setupVideoContextMenuCommands(editor);
  62. return pluginMetadata;
  63. });
  64. // Resolve the Media Plugin and include configuration.
  65. resolve([`${component}/plugin`, Configuration]);
  66. });