From 305975a3e511af105260c393b9cec22fb53fd942 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 24 Nov 2022 08:26:08 +0800 Subject: [PATCH] MDL-76460 tiny_recordrtc: Respect audio/video capabilities in editor --- .../recordrtc/amd/build/commands_audio.min.js | 4 +-- .../amd/build/commands_audio.min.js.map | 2 +- .../recordrtc/amd/build/commands_video.min.js | 4 +-- .../amd/build/commands_video.min.js.map | 2 +- .../recordrtc/amd/build/options.min.js | 4 +-- .../recordrtc/amd/build/options.min.js.map | 2 +- .../recordrtc/amd/src/commands_audio.js | 5 +++ .../recordrtc/amd/src/commands_video.js | 7 ++++- .../tiny/plugins/recordrtc/amd/src/options.js | 31 ++++++++++++++++++- .../plugins/recordrtc/classes/plugininfo.php | 4 ++- 10 files changed, 53 insertions(+), 12 deletions(-) diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js index fd739eeced7..2e27d3e46c9 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js +++ b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js @@ -1,10 +1,10 @@ -define("tiny_recordrtc/commands_audio",["exports","core/str","editor_tiny/utils","./common","./audio_recorder"],(function(_exports,_str,_utils,_common,_audio_recorder){var obj; +define("tiny_recordrtc/commands_audio",["exports","core/str","editor_tiny/utils","./common","./audio_recorder","./options"],(function(_exports,_str,_utils,_common,_audio_recorder,_options){var obj; /** * Tiny Record RTC - record audio command. * * @module tiny_recordrtc/recordAudioCommands * @copyright 2022, Stevani Andolo * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_audio_recorder=(obj=_audio_recorder)&&obj.__esModule?obj:{default:obj};return _exports.default=async()=>{if(!_audio_recorder.default.isBrowserCompatible())return()=>!1;const[audioButtonTitle,audio]=await Promise.all([(0,_str.get_string)("audiobuttontitle",_common.component),(0,_utils.getButtonImage)("audio",_common.component)]);return editor=>{editor.ui.registry.addIcon("audio",audio.html),editor.ui.registry.addButton(_common.audioButtonName,{icon:"audio",tooltip:audioButtonTitle,onAction:()=>_audio_recorder.default.display(editor)}),editor.ui.registry.addMenuItem(_common.audioButtonName,{icon:"audio",text:audioButtonTitle,onAction:()=>_audio_recorder.default.display(editor)})}},_exports.default})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_audio_recorder=(obj=_audio_recorder)&&obj.__esModule?obj:{default:obj};return _exports.default=async()=>{if(!_audio_recorder.default.isBrowserCompatible())return()=>!1;const[audioButtonTitle,audio]=await Promise.all([(0,_str.get_string)("audiobuttontitle",_common.component),(0,_utils.getButtonImage)("audio",_common.component)]);return editor=>{if(!(0,_options.isAudioAllowed)(editor))return;editor.ui.registry.addIcon("audio",audio.html),editor.ui.registry.addButton(_common.audioButtonName,{icon:"audio",tooltip:audioButtonTitle,onAction:()=>_audio_recorder.default.display(editor)}),editor.ui.registry.addMenuItem(_common.audioButtonName,{icon:"audio",text:audioButtonTitle,onAction:()=>_audio_recorder.default.display(editor)})}},_exports.default})); //# sourceMappingURL=commands_audio.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js.map b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js.map index 00c5f1797db..2ef3c305245 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js.map +++ b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_audio.min.js.map @@ -1 +1 @@ -{"version":3,"file":"commands_audio.min.js","sources":["../src/commands_audio.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - record audio command.\n *\n * @module tiny_recordrtc/recordAudioCommands\n * @copyright 2022, Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport {getButtonImage} from 'editor_tiny/utils';\nimport {\n audioButtonName,\n component\n} from './common';\nimport Recorder from './audio_recorder';\n\nexport default async() => {\n if (!Recorder.isBrowserCompatible()) {\n // The browser doesn't support the plugin, so just don't show it.\n return () => false;\n }\n\n const [\n audioButtonTitle,\n audio,\n ] = await Promise.all([\n getString('audiobuttontitle', component),\n getButtonImage('audio', component),\n ]);\n\n return (editor) => {\n const icon = 'audio';\n editor.ui.registry.addIcon(icon, audio.html);\n\n editor.ui.registry.addButton(audioButtonName, {\n icon,\n tooltip: audioButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n\n editor.ui.registry.addMenuItem(audioButtonName, {\n icon,\n text: audioButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n };\n};\n"],"names":["async","Recorder","isBrowserCompatible","audioButtonTitle","audio","Promise","all","component","editor","ui","registry","addIcon","html","addButton","audioButtonName","icon","tooltip","onAction","display","addMenuItem","text"],"mappings":";;;;;;;qLA+BeA,cACNC,wBAASC,4BAEH,KAAM,QAIbC,iBACAC,aACMC,QAAQC,IAAI,EAClB,mBAAU,mBAAoBC,oBAC9B,yBAAe,QAASA,4BAGpBC,SAEJA,OAAOC,GAAGC,SAASC,QADN,QACoBP,MAAMQ,MAEvCJ,OAAOC,GAAGC,SAASG,UAAUC,wBAAiB,CAC1CC,KAJS,QAKTC,QAASb,iBACTc,SAAU,IAAMhB,wBAASiB,QAAQV,UAGrCA,OAAOC,GAAGC,SAASS,YAAYL,wBAAiB,CAC5CC,KAVS,QAWTK,KAAMjB,iBACNc,SAAU,IAAMhB,wBAASiB,QAAQV"} \ No newline at end of file +{"version":3,"file":"commands_audio.min.js","sources":["../src/commands_audio.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - record audio command.\n *\n * @module tiny_recordrtc/recordAudioCommands\n * @copyright 2022, Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport {getButtonImage} from 'editor_tiny/utils';\nimport {\n audioButtonName,\n component\n} from './common';\nimport Recorder from './audio_recorder';\nimport {isAudioAllowed} from './options';\n\nexport default async() => {\n if (!Recorder.isBrowserCompatible()) {\n // The browser doesn't support the plugin, so just don't show it.\n return () => false;\n }\n\n const [\n audioButtonTitle,\n audio,\n ] = await Promise.all([\n getString('audiobuttontitle', component),\n getButtonImage('audio', component),\n ]);\n\n return (editor) => {\n if (!isAudioAllowed(editor)) {\n return;\n }\n\n const icon = 'audio';\n editor.ui.registry.addIcon(icon, audio.html);\n\n editor.ui.registry.addButton(audioButtonName, {\n icon,\n tooltip: audioButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n\n editor.ui.registry.addMenuItem(audioButtonName, {\n icon,\n text: audioButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n };\n};\n"],"names":["async","Recorder","isBrowserCompatible","audioButtonTitle","audio","Promise","all","component","editor","ui","registry","addIcon","html","addButton","audioButtonName","icon","tooltip","onAction","display","addMenuItem","text"],"mappings":";;;;;;;qLAgCeA,cACNC,wBAASC,4BAEH,KAAM,QAIbC,iBACAC,aACMC,QAAQC,IAAI,EAClB,mBAAU,mBAAoBC,oBAC9B,yBAAe,QAASA,4BAGpBC,cACC,2BAAeA,eAKpBA,OAAOC,GAAGC,SAASC,QADN,QACoBP,MAAMQ,MAEvCJ,OAAOC,GAAGC,SAASG,UAAUC,wBAAiB,CAC1CC,KAJS,QAKTC,QAASb,iBACTc,SAAU,IAAMhB,wBAASiB,QAAQV,UAGrCA,OAAOC,GAAGC,SAASS,YAAYL,wBAAiB,CAC5CC,KAVS,QAWTK,KAAMjB,iBACNc,SAAU,IAAMhB,wBAASiB,QAAQV"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js index 75d38339c0a..bb20a74a4b1 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js +++ b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js @@ -1,10 +1,10 @@ -define("tiny_recordrtc/commands_video",["exports","core/str","editor_tiny/utils","./common","./video_recorder"],(function(_exports,_str,_utils,_common,_video_recorder){var obj; +define("tiny_recordrtc/commands_video",["exports","core/str","editor_tiny/utils","./common","./options","./video_recorder"],(function(_exports,_str,_utils,_common,_options,_video_recorder){var obj; /** * Tiny Record RTC - record video command. * * @module tiny_recordrtc/recordVideoCommands * @copyright 2022, Stevani Andolo * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_video_recorder=(obj=_video_recorder)&&obj.__esModule?obj:{default:obj};return _exports.default=async()=>{if(!_video_recorder.default.isBrowserCompatible())return()=>!1;const[videoButtonTitle,buttonImage]=await Promise.all([(0,_str.get_string)("videobuttontitle",_common.component),(0,_utils.getButtonImage)("video",_common.component)]);return editor=>{editor.ui.registry.addIcon("video",buttonImage.html),editor.ui.registry.addButton(_common.videoButtonName,{icon:"video",tooltip:videoButtonTitle,onAction:()=>_video_recorder.default.display(editor)}),editor.ui.registry.addMenuItem(_common.videoButtonName,{icon:"video",text:videoButtonTitle,onAction:()=>_video_recorder.default.display(editor)})}},_exports.default})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_video_recorder=(obj=_video_recorder)&&obj.__esModule?obj:{default:obj};return _exports.default=async()=>{if(!_video_recorder.default.isBrowserCompatible())return()=>!1;const[videoButtonTitle,buttonImage]=await Promise.all([(0,_str.get_string)("videobuttontitle",_common.component),(0,_utils.getButtonImage)("video",_common.component)]);return editor=>{if(!(0,_options.isVideoAllowed)(editor))return;editor.ui.registry.addIcon("video",buttonImage.html),editor.ui.registry.addButton(_common.videoButtonName,{icon:"video",tooltip:videoButtonTitle,onAction:()=>_video_recorder.default.display(editor)}),editor.ui.registry.addMenuItem(_common.videoButtonName,{icon:"video",text:videoButtonTitle,onAction:()=>_video_recorder.default.display(editor)})}},_exports.default})); //# sourceMappingURL=commands_video.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js.map b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js.map index a48cced9e4b..ffc1f6c218e 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js.map +++ b/lib/editor/tiny/plugins/recordrtc/amd/build/commands_video.min.js.map @@ -1 +1 @@ -{"version":3,"file":"commands_video.min.js","sources":["../src/commands_video.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - record video command.\n *\n * @module tiny_recordrtc/recordVideoCommands\n * @copyright 2022, Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport {getButtonImage as getVideoIcon} from 'editor_tiny/utils';\nimport {\n videoButtonName,\n component\n} from './common';\nimport Recorder from './video_recorder';\n\nexport default async() => {\n if (!Recorder.isBrowserCompatible()) {\n // The browser doesn't support the plugin, so just don't show it.\n return () => false;\n }\n\n const [\n videoButtonTitle,\n buttonImage,\n ] = await Promise.all([\n getString('videobuttontitle', component),\n getVideoIcon('video', component),\n ]);\n\n return (editor) => {\n let icon = 'video';\n editor.ui.registry.addIcon(icon, buttonImage.html);\n\n editor.ui.registry.addButton(videoButtonName, {\n icon,\n tooltip: videoButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n\n editor.ui.registry.addMenuItem(videoButtonName, {\n icon,\n text: videoButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n };\n};\n"],"names":["async","Recorder","isBrowserCompatible","videoButtonTitle","buttonImage","Promise","all","component","editor","ui","registry","addIcon","html","addButton","videoButtonName","icon","tooltip","onAction","display","addMenuItem","text"],"mappings":";;;;;;;qLA+BeA,cACNC,wBAASC,4BAEH,KAAM,QAIbC,iBACAC,mBACMC,QAAQC,IAAI,EAClB,mBAAU,mBAAoBC,oBAC9B,yBAAa,QAASA,4BAGlBC,SAEJA,OAAOC,GAAGC,SAASC,QADR,QACsBP,YAAYQ,MAE7CJ,OAAOC,GAAGC,SAASG,UAAUC,wBAAiB,CAC1CC,KAJO,QAKPC,QAASb,iBACTc,SAAU,IAAMhB,wBAASiB,QAAQV,UAGrCA,OAAOC,GAAGC,SAASS,YAAYL,wBAAiB,CAC5CC,KAVO,QAWPK,KAAMjB,iBACNc,SAAU,IAAMhB,wBAASiB,QAAQV"} \ No newline at end of file +{"version":3,"file":"commands_video.min.js","sources":["../src/commands_video.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Tiny Record RTC - record video command.\n *\n * @module tiny_recordrtc/recordVideoCommands\n * @copyright 2022, Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport {getButtonImage as getVideoIcon} from 'editor_tiny/utils';\nimport {\n videoButtonName,\n component\n} from './common';\nimport {isVideoAllowed} from './options';\nimport Recorder from './video_recorder';\n\nexport default async() => {\n if (!Recorder.isBrowserCompatible()) {\n // The browser doesn't support the plugin, so just don't show it.\n return () => false;\n }\n\n const [\n videoButtonTitle,\n buttonImage,\n ] = await Promise.all([\n getString('videobuttontitle', component),\n getVideoIcon('video', component),\n ]);\n\n return (editor) => {\n if (!isVideoAllowed(editor)) {\n return;\n }\n\n const icon = 'video';\n editor.ui.registry.addIcon(icon, buttonImage.html);\n\n editor.ui.registry.addButton(videoButtonName, {\n icon,\n tooltip: videoButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n\n editor.ui.registry.addMenuItem(videoButtonName, {\n icon,\n text: videoButtonTitle,\n onAction: () => Recorder.display(editor),\n });\n };\n};\n"],"names":["async","Recorder","isBrowserCompatible","videoButtonTitle","buttonImage","Promise","all","component","editor","ui","registry","addIcon","html","addButton","videoButtonName","icon","tooltip","onAction","display","addMenuItem","text"],"mappings":";;;;;;;qLAgCeA,cACNC,wBAASC,4BAEH,KAAM,QAIbC,iBACAC,mBACMC,QAAQC,IAAI,EAClB,mBAAU,mBAAoBC,oBAC9B,yBAAa,QAASA,4BAGlBC,cACC,2BAAeA,eAKpBA,OAAOC,GAAGC,SAASC,QADN,QACoBP,YAAYQ,MAE7CJ,OAAOC,GAAGC,SAASG,UAAUC,wBAAiB,CAC1CC,KAJS,QAKTC,QAASb,iBACTc,SAAU,IAAMhB,wBAASiB,QAAQV,UAGrCA,OAAOC,GAAGC,SAASS,YAAYL,wBAAiB,CAC5CC,KAVS,QAWTK,KAAMjB,iBACNc,SAAU,IAAMhB,wBAASiB,QAAQV"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js b/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js index a00f2f8761a..4d37317242b 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js +++ b/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js @@ -1,4 +1,4 @@ -define("tiny_recordrtc/options",["exports","./common"],(function(_exports,_common){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.register=_exports.getData=void 0; +define("tiny_recordrtc/options",["exports","./common","editor_tiny/options"],(function(_exports,_common,_options){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.register=_exports.isVideoAllowed=_exports.isAudioAllowed=_exports.getData=void 0; /** * Options helper for Tiny Record RTC plugin. * @@ -6,6 +6,6 @@ define("tiny_recordrtc/options",["exports","./common"],(function(_exports,_commo * @copyright 2022, Stevani Andolo * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -const dataName="".concat(_common.pluginName,":data");_exports.register=editor=>{(0,editor.options.register)(dataName,{processor:"object"})};_exports.getData=editor=>editor.options.get(dataName)})); +const dataName=(0,_options.getPluginOptionName)(_common.pluginName,"data"),videoAllowedName=(0,_options.getPluginOptionName)(_common.pluginName,"videoAllowed"),audioAllowedName=(0,_options.getPluginOptionName)(_common.pluginName,"audioAllowed");_exports.register=editor=>{const registerOption=editor.options.register;registerOption(dataName,{processor:"object"}),registerOption(videoAllowedName,{processor:"boolean",default:!1}),registerOption(audioAllowedName,{processor:"boolean",default:!1})};_exports.getData=editor=>editor.options.get(dataName);_exports.isAudioAllowed=editor=>editor.options.get(audioAllowedName);_exports.isVideoAllowed=editor=>editor.options.get(videoAllowedName)})); //# sourceMappingURL=options.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js.map b/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js.map index 1833df1018a..3e197a67d13 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js.map +++ b/lib/editor/tiny/plugins/recordrtc/amd/build/options.min.js.map @@ -1 +1 @@ -{"version":3,"file":"options.min.js","sources":["../src/options.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Options helper for Tiny Record RTC plugin.\n *\n * @module tiny_recordrtc/options\n * @copyright 2022, Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {pluginName} from './common';\n\nconst dataName = `${pluginName}:data`;\n\nexport const register = (editor) => {\n const registerOption = editor.options.register;\n\n registerOption(dataName, {\n processor: 'object',\n });\n};\n\nexport const getData = (editor) => editor.options.get(dataName);\n"],"names":["dataName","pluginName","editor","registerOption","options","register","processor","get"],"mappings":";;;;;;;;MAyBMA,mBAAcC,8CAEKC,UAGrBC,EAFuBD,OAAOE,QAAQC,UAEvBL,SAAU,CACrBM,UAAW,6BAIKJ,QAAWA,OAAOE,QAAQG,IAAIP"} \ No newline at end of file +{"version":3,"file":"options.min.js","sources":["../src/options.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Options helper for Tiny Record RTC plugin.\n *\n * @module tiny_recordrtc/options\n * @copyright 2022, Stevani Andolo \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {pluginName} from './common';\nimport {getPluginOptionName} from 'editor_tiny/options';\n\nconst dataName = getPluginOptionName(pluginName, 'data');\nconst videoAllowedName = getPluginOptionName(pluginName, 'videoAllowed');\nconst audioAllowedName = getPluginOptionName(pluginName, 'audioAllowed');\n\nexport const register = (editor) => {\n const registerOption = editor.options.register;\n\n registerOption(dataName, {\n processor: 'object',\n });\n\n registerOption(videoAllowedName, {\n processor: 'boolean',\n \"default\": false,\n });\n\n registerOption(audioAllowedName, {\n processor: 'boolean',\n \"default\": false,\n });\n};\n\nexport const getData = (editor) => editor.options.get(dataName);\n\n/**\n * Whether video may be recorded in this instance.\n *\n * @param {TinyMCE} editor\n * @returns {boolean}\n */\nexport const isAudioAllowed = (editor) => editor.options.get(audioAllowedName);\n\n/**\n * Whether audio may be recorded in this instance.\n *\n * @param {TinyMCE} editor\n * @returns {boolean}\n */\nexport const isVideoAllowed = (editor) => editor.options.get(videoAllowedName);\n"],"names":["dataName","pluginName","videoAllowedName","audioAllowedName","editor","registerOption","options","register","processor","get"],"mappings":";;;;;;;;MA0BMA,UAAW,gCAAoBC,mBAAY,QAC3CC,kBAAmB,gCAAoBD,mBAAY,gBACnDE,kBAAmB,gCAAoBF,mBAAY,kCAEhCG,eACfC,eAAiBD,OAAOE,QAAQC,SAEtCF,eAAeL,SAAU,CACrBQ,UAAW,WAGfH,eAAeH,iBAAkB,CAC7BM,UAAW,mBACA,IAGfH,eAAeF,iBAAkB,CAC7BK,UAAW,mBACA,sBAIKJ,QAAWA,OAAOE,QAAQG,IAAIT,kCAQvBI,QAAWA,OAAOE,QAAQG,IAAIN,0CAQ9BC,QAAWA,OAAOE,QAAQG,IAAIP"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/recordrtc/amd/src/commands_audio.js b/lib/editor/tiny/plugins/recordrtc/amd/src/commands_audio.js index a95080c9e5a..c1c9f05c01e 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/src/commands_audio.js +++ b/lib/editor/tiny/plugins/recordrtc/amd/src/commands_audio.js @@ -28,6 +28,7 @@ import { component } from './common'; import Recorder from './audio_recorder'; +import {isAudioAllowed} from './options'; export default async() => { if (!Recorder.isBrowserCompatible()) { @@ -44,6 +45,10 @@ export default async() => { ]); return (editor) => { + if (!isAudioAllowed(editor)) { + return; + } + const icon = 'audio'; editor.ui.registry.addIcon(icon, audio.html); diff --git a/lib/editor/tiny/plugins/recordrtc/amd/src/commands_video.js b/lib/editor/tiny/plugins/recordrtc/amd/src/commands_video.js index 91000223c5b..7bdc602b1e5 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/src/commands_video.js +++ b/lib/editor/tiny/plugins/recordrtc/amd/src/commands_video.js @@ -27,6 +27,7 @@ import { videoButtonName, component } from './common'; +import {isVideoAllowed} from './options'; import Recorder from './video_recorder'; export default async() => { @@ -44,7 +45,11 @@ export default async() => { ]); return (editor) => { - let icon = 'video'; + if (!isVideoAllowed(editor)) { + return; + } + + const icon = 'video'; editor.ui.registry.addIcon(icon, buttonImage.html); editor.ui.registry.addButton(videoButtonName, { diff --git a/lib/editor/tiny/plugins/recordrtc/amd/src/options.js b/lib/editor/tiny/plugins/recordrtc/amd/src/options.js index 4f16258ff3f..d410328eccb 100644 --- a/lib/editor/tiny/plugins/recordrtc/amd/src/options.js +++ b/lib/editor/tiny/plugins/recordrtc/amd/src/options.js @@ -22,8 +22,11 @@ */ import {pluginName} from './common'; +import {getPluginOptionName} from 'editor_tiny/options'; -const dataName = `${pluginName}:data`; +const dataName = getPluginOptionName(pluginName, 'data'); +const videoAllowedName = getPluginOptionName(pluginName, 'videoAllowed'); +const audioAllowedName = getPluginOptionName(pluginName, 'audioAllowed'); export const register = (editor) => { const registerOption = editor.options.register; @@ -31,6 +34,32 @@ export const register = (editor) => { registerOption(dataName, { processor: 'object', }); + + registerOption(videoAllowedName, { + processor: 'boolean', + "default": false, + }); + + registerOption(audioAllowedName, { + processor: 'boolean', + "default": false, + }); }; export const getData = (editor) => editor.options.get(dataName); + +/** + * Whether video may be recorded in this instance. + * + * @param {TinyMCE} editor + * @returns {boolean} + */ +export const isAudioAllowed = (editor) => editor.options.get(audioAllowedName); + +/** + * Whether audio may be recorded in this instance. + * + * @param {TinyMCE} editor + * @returns {boolean} + */ +export const isVideoAllowed = (editor) => editor.options.get(videoAllowedName); diff --git a/lib/editor/tiny/plugins/recordrtc/classes/plugininfo.php b/lib/editor/tiny/plugins/recordrtc/classes/plugininfo.php index 8eba29befc5..98da2d5f819 100644 --- a/lib/editor/tiny/plugins/recordrtc/classes/plugininfo.php +++ b/lib/editor/tiny/plugins/recordrtc/classes/plugininfo.php @@ -116,7 +116,9 @@ class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menu ]; return [ - 'data' => $data + 'data' => $data, + 'videoAllowed' => $videoallowed, + 'audioAllowed' => $audioallowed, ]; } }