From d9d3b3e8b1d20b290af931ef86bc217cee7c0485 Mon Sep 17 00:00:00 2001 From: Stevani Andolo Date: Wed, 31 Jul 2024 10:39:35 +0800 Subject: [PATCH] MDL-78428 tiny_media: Deprecated unused langs and templates --- .../tiny/plugins/media/amd/build/embed.min.js | 2 +- .../plugins/media/amd/build/embed.min.js.map | 2 +- .../plugins/media/amd/build/selectors.min.js | 2 +- .../media/amd/build/selectors.min.js.map | 2 +- .../tiny/plugins/media/amd/src/embed.js | 404 +-------- .../tiny/plugins/media/amd/src/selectors.js | 38 - .../tiny/plugins/media/lang/en/deprecated.txt | 15 + .../tiny/plugins/media/lang/en/tiny_media.php | 32 +- .../embed/body/insert_media_body.mustache | 50 ++ .../embed/body/media_details_body.mustache | 232 +++++ .../embed/body/media_thumbnail_body.mustache | 39 + .../{ => embed}/embed_media_audio.mustache | 2 +- .../{ => embed}/embed_media_link.mustache | 0 .../embed/embed_media_modal.mustache | 61 ++ .../{ => embed}/embed_media_video.mustache | 2 +- .../embed/footer/insert_media_footer.mustache | 55 ++ .../footer/media_details_footer.mustache | 40 + .../footer/media_thumbnail_footer.mustache | 36 + .../insert_media_subtitle_caption.mustache | 107 +++ .../embed/link_media_type_selector.mustache | 37 + .../embed/metadata/captions.mustache | 145 ++++ .../embed/metadata/chapters.mustache | 145 ++++ .../embed/metadata/descriptions.mustache | 145 ++++ .../embed/metadata/metadata.mustache | 145 ++++ .../embed/metadata/subtitles.mustache | 145 ++++ .../templates/embed_media_modal.mustache | 78 -- .../embed_media_modal_audio.mustache | 778 ----------------- .../templates/embed_media_modal_link.mustache | 41 - .../embed_media_modal_video.mustache | 806 ------------------ .../insert_image_modal_insert_footer.mustache | 2 +- 30 files changed, 1425 insertions(+), 2163 deletions(-) create mode 100644 lib/editor/tiny/plugins/media/templates/embed/body/insert_media_body.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/body/media_details_body.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/body/media_thumbnail_body.mustache rename lib/editor/tiny/plugins/media/templates/{ => embed}/embed_media_audio.mustache (94%) rename lib/editor/tiny/plugins/media/templates/{ => embed}/embed_media_link.mustache (100%) create mode 100644 lib/editor/tiny/plugins/media/templates/embed/embed_media_modal.mustache rename lib/editor/tiny/plugins/media/templates/{ => embed}/embed_media_video.mustache (95%) create mode 100644 lib/editor/tiny/plugins/media/templates/embed/footer/insert_media_footer.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/footer/media_details_footer.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/footer/media_thumbnail_footer.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/insert_media_subtitle_caption.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/link_media_type_selector.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/metadata/captions.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/metadata/chapters.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/metadata/descriptions.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/metadata/metadata.mustache create mode 100644 lib/editor/tiny/plugins/media/templates/embed/metadata/subtitles.mustache delete mode 100644 lib/editor/tiny/plugins/media/templates/embed_media_modal.mustache delete mode 100644 lib/editor/tiny/plugins/media/templates/embed_media_modal_audio.mustache delete mode 100644 lib/editor/tiny/plugins/media/templates/embed_media_modal_link.mustache delete mode 100644 lib/editor/tiny/plugins/media/templates/embed_media_modal_video.mustache diff --git a/lib/editor/tiny/plugins/media/amd/build/embed.min.js b/lib/editor/tiny/plugins/media/amd/build/embed.min.js index 61d33654688..016886330af 100644 --- a/lib/editor/tiny/plugins/media/amd/build/embed.min.js +++ b/lib/editor/tiny/plugins/media/amd/build/embed.min.js @@ -1,3 +1,3 @@ -define("tiny_media/embed",["exports","core/templates","core/str","core/modal_events","editor_tiny/utils","editor_tiny/options","./common","./embedmodal","./selectors","./options"],(function(_exports,_templates,_str,ModalEvents,_utils,_options,_common,_embedmodal,_selectors,_options2){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_templates=_interopRequireDefault(_templates),ModalEvents=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(ModalEvents),_embedmodal=_interopRequireDefault(_embedmodal),_selectors=_interopRequireDefault(_selectors);return _exports.default=class{constructor(editor){_defineProperty(this,"editor",null),_defineProperty(this,"canShowFilePicker",!1),_defineProperty(this,"canShowFilePickerPoster",!1),_defineProperty(this,"canShowFilePickerTrack",!1),_defineProperty(this,"helpStrings",null),_defineProperty(this,"isUpdating",!1),_defineProperty(this,"selectedMedia",null);const permissions=(0,_options2.getEmbedPermissions)(editor);this.canShowFilePicker=permissions.filepicker&&void 0!==(0,_options.getFilePicker)(editor,"media"),this.canShowFilePickerPoster=permissions.filepicker&&void 0!==(0,_options.getFilePicker)(editor,"image"),this.canShowFilePickerTrack=permissions.filepicker&&void 0!==(0,_options.getFilePicker)(editor,"subtitle"),this.editor=editor}async getHelpStrings(){if(!this.helpStrings){const[addSource,tracks,subtitles,captions,descriptions,chapters,metadata]=await(0,_str.getStrings)(["addsource_help","tracks_help","subtitles_help","captions_help","descriptions_help","chapters_help","metadata_help"].map((key=>({key:key,component:_common.component}))));this.helpStrings={addSource:addSource,tracks:tracks,subtitles:subtitles,captions:captions,descriptions:descriptions,chapters:chapters,metadata:metadata}}return this.helpStrings}async getTemplateContext(data){const languages=this.prepareMoodleLang(),helpIcons=Array.from(Object.entries(await this.getHelpStrings())).forEach((_ref=>{let[key,text]=_ref;data["".concat(key.toLowerCase(),"helpicon")]={text:text}}));return Object.assign({},{elementid:this.editor.getElement().id,showfilepicker:this.canShowFilePicker,showfilepickerposter:this.canShowFilePickerPoster,showfilepickertrack:this.canShowFilePickerTrack,langsinstalled:languages.installed,langsavailable:languages.available,link:!0,video:!1,audio:!1,isupdating:this.isUpdating},data,helpIcons)}async displayDialogue(){this.selectedMedia=this.getSelectedMedia();const data=Object.assign({},this.getCurrentEmbedData());this.isUpdating=0!==Object.keys(data).length,this.currentModal=await _embedmodal.default.create({title:(0,_str.getString)("createmedia","tiny_media"),templateContext:await this.getTemplateContext(data)}),await this.registerEventListeners(this.currentModal)}getCurrentEmbedData(){const properties=this.getMediumProperties();if(!properties)return{};const processedProperties={};return processedProperties[properties.type.toLowerCase()]=properties,processedProperties.link=!1,processedProperties}getSelectedMedia(){const mediaElm=this.editor.selection.getNode();return mediaElm?"video"===mediaElm.nodeName.toLowerCase()||"audio"===mediaElm.nodeName.toLowerCase()?mediaElm:mediaElm.querySelector("video")?mediaElm.querySelector("video"):mediaElm.querySelector("audio")?mediaElm.querySelector("audio"):null:null}getMediumProperties(){const boolAttr=(elem,attr)=>elem.hasAttribute(attr)&&(elem.getAttribute(attr)||""===elem.getAttribute(attr)),tracks={subtitles:[],captions:[],descriptions:[],chapters:[],metadata:[]},sources=[],medium=this.selectedMedia;return medium?(medium.querySelectorAll("track").forEach((track=>{tracks[track.getAttribute("kind")].push({src:track.getAttribute("src"),srclang:track.getAttribute("srclang"),label:track.getAttribute("label"),defaultTrack:boolAttr(track,"default")})})),medium.querySelectorAll("source").forEach((source=>{sources.push(source.src)})),{type:"video"===medium.nodeName.toLowerCase()?_selectors.default.EMBED.mediaTypes.video:_selectors.default.EMBED.mediaTypes.audio,sources:sources,poster:medium.getAttribute("poster"),title:medium.getAttribute("title"),width:medium.getAttribute("width"),height:medium.getAttribute("height"),autoplay:boolAttr(medium,"autoplay"),loop:boolAttr(medium,"loop"),muted:boolAttr(medium,"muted"),controls:boolAttr(medium,"controls"),tracks:tracks}):null}prepareMoodleLang(){const moodleLangs=(0,_options.getMoodleLang)(this.editor),currentLanguage=(0,_options.getCurrentLanguage)(this.editor);return{installed:Object.entries(moodleLangs.installed).map((_ref2=>{let[lang,code]=_ref2;return{lang:lang,code:code,default:lang===currentLanguage}})),available:Object.entries(moodleLangs.available).map((_ref3=>{let[lang,code]=_ref3;return{lang:lang,code:code,default:lang===currentLanguage}}))}}getMoodleLangObj(subtitleLang){const{available:available}=(0,_options.getMoodleLang)(this.editor);return available[subtitleLang]?{lang:subtitleLang,code:available[subtitleLang]}:null}filePickerCallback(params,element,fpType){if(""!==params.url){const tabPane=element.closest(".tab-pane");if(element.closest(_selectors.default.EMBED.elements.source).querySelector(_selectors.default.EMBED.elements.url).value=params.url,tabPane.id===this.editor.getElement().id+"_"+_selectors.default.EMBED.mediaTypes.link.toLowerCase()&&(tabPane.querySelector(_selectors.default.EMBED.elements.name).value=params.file),"subtitle"===fpType){const subtitleLang=params.file.split(".vtt")[0].split("-").slice(-1)[0],langObj=this.getMoodleLangObj(subtitleLang);if(langObj){const track=element.closest(_selectors.default.EMBED.elements.track);track.querySelector(_selectors.default.EMBED.elements.trackLabel).value=langObj.lang.trim(),track.querySelector(_selectors.default.EMBED.elements.trackLang).value=langObj.code}}}}addMediaSourceComponent(element,callback){const sourceElement=element.closest(_selectors.default.EMBED.elements.source+_selectors.default.EMBED.elements.mediaSource),clone=sourceElement.cloneNode(!0);sourceElement.querySelector(".removecomponent-wrapper").classList.remove("hidden"),sourceElement.querySelector(".addcomponent-wrapper").classList.add("hidden"),sourceElement.parentNode.insertBefore(clone,sourceElement.nextSibling),callback&&callback(clone)}removeMediaSourceComponent(element){element.closest(_selectors.default.EMBED.elements.source+_selectors.default.EMBED.elements.mediaSource).remove()}addTrackComponent(element,callback){const trackElement=element.closest(_selectors.default.EMBED.elements.track),clone=trackElement.cloneNode(!0);trackElement.querySelector(".removecomponent-wrapper").classList.remove("hidden"),trackElement.querySelector(".addcomponent-wrapper").classList.add("hidden"),trackElement.parentNode.insertBefore(clone,trackElement.nextSibling),callback&&callback(clone)}removeTrackComponent(element){element.closest(_selectors.default.EMBED.elements.track).remove()}getMediumTypeFromTabPane(tabPane){return tabPane.getAttribute("data-medium-type")}getTrackTypeFromTabPane(tabPane){return tabPane.getAttribute("data-track-kind")}getMediaHTML(form){const mediumType=this.getMediumTypeFromTabPane(form.querySelector(".root.tab-content > .tab-pane.active")),tabContent=form.querySelector(_selectors.default.EMBED.elements[mediumType.toLowerCase()+"Pane"]);return this["getMediaHTML"+mediumType[0].toUpperCase()+mediumType.substr(1)](tabContent)}getMediaHTMLLink(tab){const context={url:tab.querySelector(_selectors.default.EMBED.elements.url).value,name:tab.querySelector(_selectors.default.EMBED.elements.name).value||!1};return context.url?_templates.default.renderForPromise("tiny_media/embed_media_link",context):""}getMediaHTMLVideo(tab){const context=this.getContextForMediaHTML(tab);return context.width=tab.querySelector(_selectors.default.EMBED.elements.width).value||!1,context.height=tab.querySelector(_selectors.default.EMBED.elements.height).value||!1,context.poster=tab.querySelector("".concat(_selectors.default.EMBED.elements.posterSource," ").concat(_selectors.default.EMBED.elements.url)).value||!1,context.sources.length?_templates.default.renderForPromise("tiny_media/embed_media_video",context):""}getMediaHTMLAudio(tab){const context=this.getContextForMediaHTML(tab);return context.sources.length?_templates.default.renderForPromise("tiny_media/embed_media_audio",context):""}getContextForMediaHTML(tab){const tracks=Array.from(tab.querySelectorAll(_selectors.default.EMBED.elements.track)).map((track=>({track:track.querySelector(_selectors.default.EMBED.elements.trackSource+" "+_selectors.default.EMBED.elements.url).value,kind:this.getTrackTypeFromTabPane(track.closest(".tab-pane")),label:track.querySelector(_selectors.default.EMBED.elements.trackLabel).value||track.querySelector(_selectors.default.EMBED.elements.trackLang).value,srclang:track.querySelector(_selectors.default.EMBED.elements.trackLang).value,defaultTrack:track.querySelector(_selectors.default.EMBED.elements.trackDefault).checked?"true":null}))).filter((track=>!!track.track));return{sources:Array.from(tab.querySelectorAll(_selectors.default.EMBED.elements.mediaSource+" "+_selectors.default.EMBED.elements.url)).filter((source=>!!source.value)).map((source=>source.value)),description:tab.querySelector(_selectors.default.EMBED.elements.mediaSource+" "+_selectors.default.EMBED.elements.url).value||!1,tracks:tracks,showControls:tab.querySelector(_selectors.default.EMBED.elements.mediaControl).checked,autoplay:tab.querySelector(_selectors.default.EMBED.elements.mediaAutoplay).checked,muted:tab.querySelector(_selectors.default.EMBED.elements.mediaMute).checked,loop:tab.querySelector(_selectors.default.EMBED.elements.mediaLoop).checked,title:tab.querySelector(_selectors.default.EMBED.elements.title).value||!1}}getFilepickerTypeFromElement(element){return element.closest(_selectors.default.EMBED.elements.posterSource)?"image":element.closest(_selectors.default.EMBED.elements.trackSource)?"subtitle":"media"}async clickHandler(e){const element=e.target;if(element.closest(_selectors.default.EMBED.actions.mediaBrowser)){e.preventDefault();const fpType=this.getFilepickerTypeFromElement(element),params=await(0,_utils.displayFilepicker)(this.editor,fpType);this.filePickerCallback(params,element,fpType)}element.closest(_selectors.default.EMBED.elements.mediaSource+" .addcomponent")&&(e.preventDefault(),this.addMediaSourceComponent(element));element.closest(_selectors.default.EMBED.elements.mediaSource+" .removecomponent")&&(e.preventDefault(),this.removeMediaSourceComponent(element));element.closest(_selectors.default.EMBED.elements.track+" .addcomponent")&&(e.preventDefault(),this.addTrackComponent(element));element.closest(_selectors.default.EMBED.elements.track+" .removecomponent")&&(e.preventDefault(),this.removeTrackComponent(element));const trackDefaultAction=element.closest(_selectors.default.EMBED.elements.trackDefault);if(trackDefaultAction&&trackDefaultAction.checked){const getKind=el=>this.getTrackTypeFromTabPane(el.parentElement.closest(".tab-pane"));element.parentElement.closest(".root.tab-content").querySelectorAll(_selectors.default.EMBED.elements.trackDefault).forEach((select=>{select!==element&&getKind(element)===getKind(select)&&(select.checked=!1)}))}}async handleDialogueSubmission(event,modal){const{html:html}=await this.getMediaHTML(modal.getRoot()[0]);html&&(this.isUpdating?(this.selectedMedia.outerHTML=html,this.isUpdating=!1):this.editor.insertContent(html))}async registerEventListeners(modal){await modal.getBody();const $root=modal.getRoot(),root=$root[0];(this.canShowFilePicker||this.canShowFilePickerPoster||this.canShowFilePickerTrack)&&root.addEventListener("click",this.clickHandler.bind(this)),$root.on(ModalEvents.save,this.handleDialogueSubmission.bind(this)),$root.on(ModalEvents.hidden,(()=>{this.currentModal.destroy()})),$root.on(ModalEvents.shown,(()=>{root.querySelectorAll(_selectors.default.EMBED.elements.trackLang).forEach((dropdown=>{const defaultVal=dropdown.getAttribute("data-value");defaultVal&&(dropdown.value=defaultVal)}))}))}},_exports.default})); +define("tiny_media/embed",["exports","core/str","core/modal_events","./embedmodal","./options","editor_tiny/options"],(function(_exports,_str,ModalEvents,_embedmodal,_options,_options2){var obj;function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,ModalEvents=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(ModalEvents),_embedmodal=(obj=_embedmodal)&&obj.__esModule?obj:{default:obj};return _exports.default=class{constructor(editor){_defineProperty(this,"editor",null),_defineProperty(this,"canShowFilePicker",!1),_defineProperty(this,"canShowFilePickerPoster",!1),_defineProperty(this,"canShowFilePickerTrack",!1);const permissions=(0,_options.getEmbedPermissions)(editor);this.canShowFilePicker=permissions.filepicker&&void 0!==(0,_options2.getFilePicker)(editor,"media"),this.canShowFilePickerPoster=permissions.filepicker&&void 0!==(0,_options2.getFilePicker)(editor,"image"),this.canShowFilePickerTrack=permissions.filepicker&&void 0!==(0,_options2.getFilePicker)(editor,"subtitle"),this.editor=editor}async getTemplateContext(){return{elementid:this.editor.getElement().id,showfilepicker:this.canShowFilePicker,showfilepickerposter:this.canShowFilePickerPoster,showfilepickertrack:this.canShowFilePickerTrack}}async displayDialogue(){this.currentModal=await _embedmodal.default.create({title:(0,_str.getString)("createmedia","tiny_media"),templateContext:await this.getTemplateContext()}),await this.registerEventListeners(this.currentModal)}async registerEventListeners(modal){await modal.getBody();modal.getRoot().on(ModalEvents.hidden,(()=>{this.currentModal.destroy()}))}},_exports.default})); //# sourceMappingURL=embed.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/amd/build/embed.min.js.map b/lib/editor/tiny/plugins/media/amd/build/embed.min.js.map index e0f67170c6c..275173565ad 100644 --- a/lib/editor/tiny/plugins/media/amd/build/embed.min.js.map +++ b/lib/editor/tiny/plugins/media/amd/build/embed.min.js.map @@ -1 +1 @@ -{"version":3,"file":"embed.min.js","sources":["../src/embed.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 Media plugin Embed class for Moodle.\n *\n * @module tiny_media/embed\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Templates from 'core/templates';\nimport {\n getString,\n getStrings,\n} from 'core/str';\nimport * as ModalEvents from 'core/modal_events';\nimport {displayFilepicker} from 'editor_tiny/utils';\nimport {getCurrentLanguage, getMoodleLang} from 'editor_tiny/options';\nimport {component} from \"./common\";\nimport EmbedModal from './embedmodal';\nimport Selectors from './selectors';\nimport {getEmbedPermissions} from './options';\nimport {getFilePicker} from 'editor_tiny/options';\n\nexport default class MediaEmbed {\n editor = null;\n canShowFilePicker = false;\n canShowFilePickerPoster = false;\n canShowFilePickerTrack = false;\n\n /**\n * @property {Object} The names of the alignment options.\n */\n helpStrings = null;\n\n /**\n * @property {boolean} Indicate that the user is updating the media or not.\n */\n isUpdating = false;\n\n /**\n * @property {Object} The currently selected media.\n */\n selectedMedia = null;\n\n constructor(editor) {\n const permissions = getEmbedPermissions(editor);\n\n // Indicates whether the file picker can be shown.\n this.canShowFilePicker = permissions.filepicker && (typeof getFilePicker(editor, 'media') !== 'undefined');\n this.canShowFilePickerPoster = permissions.filepicker && (typeof getFilePicker(editor, 'image') !== 'undefined');\n this.canShowFilePickerTrack = permissions.filepicker && (typeof getFilePicker(editor, 'subtitle') !== 'undefined');\n\n this.editor = editor;\n }\n\n async getHelpStrings() {\n if (!this.helpStrings) {\n const [addSource, tracks, subtitles, captions, descriptions, chapters, metadata] = await getStrings([\n 'addsource_help',\n 'tracks_help',\n 'subtitles_help',\n 'captions_help',\n 'descriptions_help',\n 'chapters_help',\n 'metadata_help',\n ].map((key) => ({\n key,\n component,\n })));\n\n this.helpStrings = {addSource, tracks, subtitles, captions, descriptions, chapters, metadata};\n }\n\n return this.helpStrings;\n }\n\n async getTemplateContext(data) {\n const languages = this.prepareMoodleLang();\n\n const helpIcons = Array.from(Object.entries(await this.getHelpStrings())).forEach(([key, text]) => {\n data[`${key.toLowerCase()}helpicon`] = {text};\n });\n\n return Object.assign({}, {\n elementid: this.editor.getElement().id,\n showfilepicker: this.canShowFilePicker,\n showfilepickerposter: this.canShowFilePickerPoster,\n showfilepickertrack: this.canShowFilePickerTrack,\n langsinstalled: languages.installed,\n langsavailable: languages.available,\n link: true,\n video: false,\n audio: false,\n isupdating: this.isUpdating,\n }, data, helpIcons);\n }\n\n async displayDialogue() {\n this.selectedMedia = this.getSelectedMedia();\n const data = Object.assign({}, this.getCurrentEmbedData());\n this.isUpdating = Object.keys(data).length !== 0;\n\n this.currentModal = await EmbedModal.create({\n title: getString('createmedia', 'tiny_media'),\n templateContext: await this.getTemplateContext(data),\n });\n\n await this.registerEventListeners(this.currentModal);\n }\n\n getCurrentEmbedData() {\n const properties = this.getMediumProperties();\n if (!properties) {\n return {};\n }\n\n const processedProperties = {};\n processedProperties[properties.type.toLowerCase()] = properties;\n processedProperties.link = false;\n\n return processedProperties;\n }\n\n getSelectedMedia() {\n const mediaElm = this.editor.selection.getNode();\n\n if (!mediaElm) {\n return null;\n }\n\n if (mediaElm.nodeName.toLowerCase() === 'video' || mediaElm.nodeName.toLowerCase() === 'audio') {\n return mediaElm;\n }\n\n if (mediaElm.querySelector('video')) {\n return mediaElm.querySelector('video');\n }\n\n if (mediaElm.querySelector('audio')) {\n return mediaElm.querySelector('audio');\n }\n\n return null;\n }\n\n getMediumProperties() {\n const boolAttr = (elem, attr) => {\n // As explained in MDL-64175, some OS (like Ubuntu), are removing the value for these attributes.\n // So in order to check if attr=\"true\", we need to check if the attribute exists and if the value is empty or true.\n return (elem.hasAttribute(attr) && (elem.getAttribute(attr) || elem.getAttribute(attr) === ''));\n };\n\n const tracks = {\n subtitles: [],\n captions: [],\n descriptions: [],\n chapters: [],\n metadata: []\n };\n const sources = [];\n\n const medium = this.selectedMedia;\n if (!medium) {\n return null;\n }\n medium.querySelectorAll('track').forEach((track) => {\n tracks[track.getAttribute('kind')].push({\n src: track.getAttribute('src'),\n srclang: track.getAttribute('srclang'),\n label: track.getAttribute('label'),\n defaultTrack: boolAttr(track, 'default')\n });\n });\n\n medium.querySelectorAll('source').forEach((source) => {\n sources.push(source.src);\n });\n\n return {\n type: medium.nodeName.toLowerCase() === 'video' ? Selectors.EMBED.mediaTypes.video : Selectors.EMBED.mediaTypes.audio,\n sources,\n poster: medium.getAttribute('poster'),\n title: medium.getAttribute('title'),\n width: medium.getAttribute('width'),\n height: medium.getAttribute('height'),\n autoplay: boolAttr(medium, 'autoplay'),\n loop: boolAttr(medium, 'loop'),\n muted: boolAttr(medium, 'muted'),\n controls: boolAttr(medium, 'controls'),\n tracks,\n };\n }\n\n prepareMoodleLang() {\n const moodleLangs = getMoodleLang(this.editor);\n const currentLanguage = getCurrentLanguage(this.editor);\n\n const installed = Object.entries(moodleLangs.installed).map(([lang, code]) => ({\n lang,\n code,\n \"default\": lang === currentLanguage,\n }));\n\n const available = Object.entries(moodleLangs.available).map(([lang, code]) => ({\n lang,\n code,\n \"default\": lang === currentLanguage,\n }));\n\n return {\n installed,\n available,\n };\n }\n\n getMoodleLangObj(subtitleLang) {\n const {available} = getMoodleLang(this.editor);\n\n if (available[subtitleLang]) {\n return {\n lang: subtitleLang,\n code: available[subtitleLang],\n };\n }\n\n return null;\n }\n\n filePickerCallback(params, element, fpType) {\n if (params.url !== '') {\n const tabPane = element.closest('.tab-pane');\n element.closest(Selectors.EMBED.elements.source).querySelector(Selectors.EMBED.elements.url).value = params.url;\n\n if (tabPane.id === this.editor.getElement().id + '_' + Selectors.EMBED.mediaTypes.link.toLowerCase()) {\n tabPane.querySelector(Selectors.EMBED.elements.name).value = params.file;\n }\n\n if (fpType === 'subtitle') {\n // If the file is subtitle file. We need to match the language and label for that file.\n const subtitleLang = params.file.split('.vtt')[0].split('-').slice(-1)[0];\n const langObj = this.getMoodleLangObj(subtitleLang);\n if (langObj) {\n const track = element.closest(Selectors.EMBED.elements.track);\n track.querySelector(Selectors.EMBED.elements.trackLabel).value = langObj.lang.trim();\n track.querySelector(Selectors.EMBED.elements.trackLang).value = langObj.code;\n }\n }\n }\n }\n\n addMediaSourceComponent(element, callback) {\n const sourceElement = element.closest(Selectors.EMBED.elements.source + Selectors.EMBED.elements.mediaSource);\n const clone = sourceElement.cloneNode(true);\n\n sourceElement.querySelector('.removecomponent-wrapper').classList.remove('hidden');\n sourceElement.querySelector('.addcomponent-wrapper').classList.add('hidden');\n\n sourceElement.parentNode.insertBefore(clone, sourceElement.nextSibling);\n\n if (callback) {\n callback(clone);\n }\n }\n\n removeMediaSourceComponent(element) {\n const sourceElement = element.closest(Selectors.EMBED.elements.source + Selectors.EMBED.elements.mediaSource);\n sourceElement.remove();\n }\n\n addTrackComponent(element, callback) {\n const trackElement = element.closest(Selectors.EMBED.elements.track);\n const clone = trackElement.cloneNode(true);\n\n trackElement.querySelector('.removecomponent-wrapper').classList.remove('hidden');\n trackElement.querySelector('.addcomponent-wrapper').classList.add('hidden');\n\n trackElement.parentNode.insertBefore(clone, trackElement.nextSibling);\n\n if (callback) {\n callback(clone);\n }\n }\n\n removeTrackComponent(element) {\n const sourceElement = element.closest(Selectors.EMBED.elements.track);\n sourceElement.remove();\n }\n\n getMediumTypeFromTabPane(tabPane) {\n return tabPane.getAttribute('data-medium-type');\n }\n\n getTrackTypeFromTabPane(tabPane) {\n return tabPane.getAttribute('data-track-kind');\n }\n\n getMediaHTML(form) {\n const mediumType = this.getMediumTypeFromTabPane(form.querySelector('.root.tab-content > .tab-pane.active'));\n const tabContent = form.querySelector(Selectors.EMBED.elements[mediumType.toLowerCase() + 'Pane']);\n\n return this['getMediaHTML' + mediumType[0].toUpperCase() + mediumType.substr(1)](tabContent);\n }\n\n getMediaHTMLLink(tab) {\n const context = {\n url: tab.querySelector(Selectors.EMBED.elements.url).value,\n name: tab.querySelector(Selectors.EMBED.elements.name).value || false\n };\n\n return context.url ? Templates.renderForPromise('tiny_media/embed_media_link', context) : '';\n }\n\n getMediaHTMLVideo(tab) {\n const context = this.getContextForMediaHTML(tab);\n context.width = tab.querySelector(Selectors.EMBED.elements.width).value || false;\n context.height = tab.querySelector(Selectors.EMBED.elements.height).value || false;\n context.poster = tab.querySelector(\n `${Selectors.EMBED.elements.posterSource} ${Selectors.EMBED.elements.url}`\n ).value || false;\n\n return context.sources.length ? Templates.renderForPromise('tiny_media/embed_media_video', context) : '';\n }\n\n getMediaHTMLAudio(tab) {\n const context = this.getContextForMediaHTML(tab);\n\n return context.sources.length ? Templates.renderForPromise('tiny_media/embed_media_audio', context) : '';\n }\n\n getContextForMediaHTML(tab) {\n const tracks = Array.from(tab.querySelectorAll(Selectors.EMBED.elements.track)).map(track => ({\n track: track.querySelector(Selectors.EMBED.elements.trackSource + ' ' + Selectors.EMBED.elements.url).value,\n kind: this.getTrackTypeFromTabPane(track.closest('.tab-pane')),\n label: track.querySelector(Selectors.EMBED.elements.trackLabel).value ||\n track.querySelector(Selectors.EMBED.elements.trackLang).value,\n srclang: track.querySelector(Selectors.EMBED.elements.trackLang).value,\n defaultTrack: track.querySelector(Selectors.EMBED.elements.trackDefault).checked ? \"true\" : null\n })).filter((track) => !!track.track);\n\n const sources = Array.from(tab.querySelectorAll(Selectors.EMBED.elements.mediaSource + ' '\n + Selectors.EMBED.elements.url))\n .filter((source) => !!source.value)\n .map((source) => source.value);\n\n return {\n sources,\n description: tab.querySelector(Selectors.EMBED.elements.mediaSource + ' '\n + Selectors.EMBED.elements.url).value || false,\n tracks,\n showControls: tab.querySelector(Selectors.EMBED.elements.mediaControl).checked,\n autoplay: tab.querySelector(Selectors.EMBED.elements.mediaAutoplay).checked,\n muted: tab.querySelector(Selectors.EMBED.elements.mediaMute).checked,\n loop: tab.querySelector(Selectors.EMBED.elements.mediaLoop).checked,\n title: tab.querySelector(Selectors.EMBED.elements.title).value || false\n };\n }\n\n getFilepickerTypeFromElement(element) {\n if (element.closest(Selectors.EMBED.elements.posterSource)) {\n return 'image';\n }\n if (element.closest(Selectors.EMBED.elements.trackSource)) {\n return 'subtitle';\n }\n\n return 'media';\n }\n\n async clickHandler(e) {\n const element = e.target;\n\n const mediaBrowser = element.closest(Selectors.EMBED.actions.mediaBrowser);\n if (mediaBrowser) {\n e.preventDefault();\n const fpType = this.getFilepickerTypeFromElement(element);\n const params = await displayFilepicker(this.editor, fpType);\n this.filePickerCallback(params, element, fpType);\n }\n\n const addComponentSourceAction = element.closest(Selectors.EMBED.elements.mediaSource + ' .addcomponent');\n if (addComponentSourceAction) {\n e.preventDefault();\n this.addMediaSourceComponent(element);\n }\n\n const removeComponentSourceAction = element.closest(Selectors.EMBED.elements.mediaSource + ' .removecomponent');\n if (removeComponentSourceAction) {\n e.preventDefault();\n this.removeMediaSourceComponent(element);\n }\n\n const addComponentTrackAction = element.closest(Selectors.EMBED.elements.track + ' .addcomponent');\n if (addComponentTrackAction) {\n e.preventDefault();\n this.addTrackComponent(element);\n }\n\n const removeComponentTrackAction = element.closest(Selectors.EMBED.elements.track + ' .removecomponent');\n if (removeComponentTrackAction) {\n e.preventDefault();\n this.removeTrackComponent(element);\n }\n\n // Only allow one track per tab to be selected as \"default\".\n const trackDefaultAction = element.closest(Selectors.EMBED.elements.trackDefault);\n if (trackDefaultAction && trackDefaultAction.checked) {\n const getKind = (el) => this.getTrackTypeFromTabPane(el.parentElement.closest('.tab-pane'));\n\n element.parentElement\n .closest('.root.tab-content')\n .querySelectorAll(Selectors.EMBED.elements.trackDefault)\n .forEach((select) => {\n if (select !== element && getKind(element) === getKind(select)) {\n select.checked = false;\n }\n });\n }\n }\n\n async handleDialogueSubmission(event, modal) {\n const {html} = await this.getMediaHTML(modal.getRoot()[0]);\n if (html) {\n if (this.isUpdating) {\n this.selectedMedia.outerHTML = html;\n this.isUpdating = false;\n } else {\n this.editor.insertContent(html);\n }\n }\n }\n\n async registerEventListeners(modal) {\n await modal.getBody();\n const $root = modal.getRoot();\n const root = $root[0];\n if (this.canShowFilePicker || this.canShowFilePickerPoster || this.canShowFilePickerTrack) {\n root.addEventListener('click', this.clickHandler.bind(this));\n }\n\n $root.on(ModalEvents.save, this.handleDialogueSubmission.bind(this));\n $root.on(ModalEvents.hidden, () => {\n this.currentModal.destroy();\n });\n $root.on(ModalEvents.shown, () => {\n root.querySelectorAll(Selectors.EMBED.elements.trackLang).forEach((dropdown) => {\n const defaultVal = dropdown.getAttribute('data-value');\n if (defaultVal) {\n dropdown.value = defaultVal;\n }\n });\n });\n }\n}\n"],"names":["constructor","editor","permissions","canShowFilePicker","filepicker","canShowFilePickerPoster","canShowFilePickerTrack","this","helpStrings","addSource","tracks","subtitles","captions","descriptions","chapters","metadata","map","key","component","data","languages","prepareMoodleLang","helpIcons","Array","from","Object","entries","getHelpStrings","forEach","_ref","text","toLowerCase","assign","elementid","getElement","id","showfilepicker","showfilepickerposter","showfilepickertrack","langsinstalled","installed","langsavailable","available","link","video","audio","isupdating","isUpdating","selectedMedia","getSelectedMedia","getCurrentEmbedData","keys","length","currentModal","EmbedModal","create","title","templateContext","getTemplateContext","registerEventListeners","properties","getMediumProperties","processedProperties","type","mediaElm","selection","getNode","nodeName","querySelector","boolAttr","elem","attr","hasAttribute","getAttribute","sources","medium","querySelectorAll","track","push","src","srclang","label","defaultTrack","source","Selectors","EMBED","mediaTypes","poster","width","height","autoplay","loop","muted","controls","moodleLangs","currentLanguage","_ref2","lang","code","_ref3","getMoodleLangObj","subtitleLang","filePickerCallback","params","element","fpType","url","tabPane","closest","elements","value","name","file","split","slice","langObj","trackLabel","trim","trackLang","addMediaSourceComponent","callback","sourceElement","mediaSource","clone","cloneNode","classList","remove","add","parentNode","insertBefore","nextSibling","removeMediaSourceComponent","addTrackComponent","trackElement","removeTrackComponent","getMediumTypeFromTabPane","getTrackTypeFromTabPane","getMediaHTML","form","mediumType","tabContent","toUpperCase","substr","getMediaHTMLLink","tab","context","Templates","renderForPromise","getMediaHTMLVideo","getContextForMediaHTML","posterSource","getMediaHTMLAudio","trackSource","kind","trackDefault","checked","filter","description","showControls","mediaControl","mediaAutoplay","mediaMute","mediaLoop","getFilepickerTypeFromElement","e","target","actions","mediaBrowser","preventDefault","trackDefaultAction","getKind","el","parentElement","select","event","modal","html","getRoot","outerHTML","insertContent","getBody","$root","root","addEventListener","clickHandler","bind","on","ModalEvents","save","handleDialogueSubmission","hidden","destroy","shown","dropdown","defaultVal"],"mappings":"ssDA0DIA,YAAYC,sCApBH,gDACW,mDACM,kDACD,sCAKX,yCAKD,wCAKG,YAGNC,aAAc,iCAAoBD,aAGnCE,kBAAoBD,YAAYE,iBAAyD,KAAnC,0BAAcH,OAAQ,cAC5EI,wBAA0BH,YAAYE,iBAAyD,KAAnC,0BAAcH,OAAQ,cAClFK,uBAAyBJ,YAAYE,iBAA4D,KAAtC,0BAAcH,OAAQ,iBAEjFA,OAASA,kCAITM,KAAKC,YAAa,OACZC,UAAWC,OAAQC,UAAWC,SAAUC,aAAcC,SAAUC,gBAAkB,mBAAW,CAChG,iBACA,cACA,iBACA,gBACA,oBACA,gBACA,iBACFC,KAAKC,OACHA,IAAAA,IACAC,UAAAA,4BAGCV,YAAc,CAACC,UAAAA,UAAWC,OAAAA,OAAQC,UAAAA,UAAWC,SAAAA,SAAUC,aAAAA,aAAcC,SAAAA,SAAUC,SAAAA,iBAGjFR,KAAKC,qCAGSW,YACfC,UAAYb,KAAKc,oBAEjBC,UAAYC,MAAMC,KAAKC,OAAOC,cAAcnB,KAAKoB,mBAAmBC,SAAQC,WAAEZ,IAAKa,WACrFX,eAAQF,IAAIc,2BAA2B,CAACD,KAAAA,gBAGrCL,OAAOO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,iBAAiBQ,mBAAUC,MAAMwB,SAASS,WAAW1F,SAASqK,iBACzDC,WAAaD,SAASxH,aAAa,cACrCyH,aACAD,SAASnF,MAAQoF"} \ No newline at end of file +{"version":3,"file":"embed.min.js","sources":["../src/embed.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 Media plugin Embed class for Moodle.\n *\n * @module tiny_media/embed\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {getString} from 'core/str';\nimport * as ModalEvents from 'core/modal_events';\nimport EmbedModal from './embedmodal';\nimport {getEmbedPermissions} from './options';\nimport {getFilePicker} from 'editor_tiny/options';\n\nexport default class MediaEmbed {\n editor = null;\n canShowFilePicker = false;\n canShowFilePickerPoster = false;\n canShowFilePickerTrack = false;\n\n constructor(editor) {\n const permissions = getEmbedPermissions(editor);\n\n // Indicates whether the file picker can be shown.\n this.canShowFilePicker = permissions.filepicker && (typeof getFilePicker(editor, 'media') !== 'undefined');\n this.canShowFilePickerPoster = permissions.filepicker && (typeof getFilePicker(editor, 'image') !== 'undefined');\n this.canShowFilePickerTrack = permissions.filepicker && (typeof getFilePicker(editor, 'subtitle') !== 'undefined');\n\n this.editor = editor;\n }\n\n async getTemplateContext() {\n return {\n elementid: this.editor.getElement().id,\n showfilepicker: this.canShowFilePicker,\n showfilepickerposter: this.canShowFilePickerPoster,\n showfilepickertrack: this.canShowFilePickerTrack,\n };\n }\n\n async displayDialogue() {\n this.currentModal = await EmbedModal.create({\n title: getString('createmedia', 'tiny_media'),\n templateContext: await this.getTemplateContext(),\n });\n\n await this.registerEventListeners(this.currentModal);\n }\n\n async registerEventListeners(modal) {\n await modal.getBody();\n const $root = modal.getRoot();\n\n $root.on(ModalEvents.hidden, () => {\n this.currentModal.destroy();\n });\n }\n}\n"],"names":["constructor","editor","permissions","canShowFilePicker","filepicker","canShowFilePickerPoster","canShowFilePickerTrack","elementid","this","getElement","id","showfilepicker","showfilepickerposter","showfilepickertrack","currentModal","EmbedModal","create","title","templateContext","getTemplateContext","registerEventListeners","modal","getBody","getRoot","on","ModalEvents","hidden","destroy"],"mappings":"68CAmCIA,YAAYC,sCALH,gDACW,mDACM,kDACD,SAGfC,aAAc,gCAAoBD,aAGnCE,kBAAoBD,YAAYE,iBAAyD,KAAnC,2BAAcH,OAAQ,cAC5EI,wBAA0BH,YAAYE,iBAAyD,KAAnC,2BAAcH,OAAQ,cAClFK,uBAAyBJ,YAAYE,iBAA4D,KAAtC,2BAAcH,OAAQ,iBAEjFA,OAASA,wCAIP,CACHM,UAAWC,KAAKP,OAAOQ,aAAaC,GACpCC,eAAgBH,KAAKL,kBACrBS,qBAAsBJ,KAAKH,wBAC3BQ,oBAAqBL,KAAKF,qDAKzBQ,mBAAqBC,oBAAWC,OAAO,CACxCC,OAAO,kBAAU,cAAe,cAChCC,sBAAuBV,KAAKW,6BAG1BX,KAAKY,uBAAuBZ,KAAKM,2CAGdO,aACnBA,MAAMC,UACED,MAAME,UAEdC,GAAGC,YAAYC,QAAQ,UACpBZ,aAAaa"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/amd/build/selectors.min.js b/lib/editor/tiny/plugins/media/amd/build/selectors.min.js index e4e6972b697..e393fc6ad58 100644 --- a/lib/editor/tiny/plugins/media/amd/build/selectors.min.js +++ b/lib/editor/tiny/plugins/media/amd/build/selectors.min.js @@ -1,3 +1,3 @@ -define("tiny_media/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={IMAGE:{actions:{submit:".tiny_image_urlentrysubmit",imageBrowser:".openimagebrowser",addUrl:".tiny_image_addurl",deleteImage:".tiny_image_deleteicon"},elements:{form:"form.tiny_image_form",alignSettings:".tiny_image_button",alt:".tiny_image_altentry",altWarning:".tiny_image_altwarning",height:".tiny_image_heightentry",width:".tiny_image_widthentry",url:".tiny_image_urlentry",urlWarning:".tiny_image_urlwarning",size:".tiny_image_size",presentation:".tiny_image_presentation",constrain:".tiny_image_constrain",customStyle:".tiny_image_customstyle",preview:".tiny_image_preview",previewBox:".tiny_image_preview_box",loaderIcon:".tiny_image_loader",loaderIconContainer:".tiny_image_loader_container",insertImage:".tiny_image_insert_image",modalFooter:".modal-footer",dropzoneContainer:".tiny_image_dropzone_container",fileInput:"#tiny_image_fileinput",fileNameLabel:".tiny_image_filename",sizeOriginal:".tiny_image_sizeoriginal",sizeCustom:".tiny_image_sizecustom",properties:".tiny_image_properties"},styles:{responsive:"img-fluid"}},EMBED:{actions:{submit:".tiny_media_submit",mediaBrowser:".openmediabrowser"},elements:{form:"form.tiny_media_form",source:".tiny_media_source",track:".tiny_media_track",mediaSource:".tiny_media_media_source",linkSource:".tiny_media_link_source",linkSize:".tiny_media_link_size",posterSource:".tiny_media_poster_source",posterSize:".tiny_media_poster_size",displayOptions:".tiny_media_display_options",name:".tiny_media_name_entry",title:".tiny_media_title_entry",url:".tiny_media_url_entry",width:".tiny_media_width_entry",height:".tiny_media_height_entry",trackSource:".tiny_media_track_source",trackKind:".tiny_media_track_kind_entry",trackLabel:".tiny_media_track_label_entry",trackLang:".tiny_media_track_lang_entry",trackDefault:".tiny_media_track_default",mediaControl:".tiny_media_controls",mediaAutoplay:".tiny_media_autoplay",mediaMute:".tiny_media_mute",mediaLoop:".tiny_media_loop",advancedSettings:".tiny_media_advancedsettings",linkTab:'li[data-medium-type="link"]',videoTab:'li[data-medium-type="video"]',audioTab:'li[data-medium-type="audio"]',linkPane:'.tab-pane[data-medium-type="link"]',videoPane:'.tab-pane[data-medium-type="video"]',audioPane:'.tab-pane[data-medium-type="audio"]',trackSubtitlesTab:'li[data-track-kind="subtitles"]',trackCaptionsTab:'li[data-track-kind="captions"]',trackDescriptionsTab:'li[data-track-kind="descriptions"]',trackChaptersTab:'li[data-track-kind="chapters"]',trackMetadataTab:'li[data-track-kind="metadata"]',trackSubtitlesPane:'.tab-pane[data-track-kind="subtitles"]',trackCaptionsPane:'.tab-pane[data-track-kind="captions"]',trackDescriptionsPane:'.tab-pane[data-track-kind="descriptions"]',trackChaptersPane:'.tab-pane[data-track-kind="chapters"]',trackMetadataPane:'.tab-pane[data-track-kind="metadata"]'},mediaTypes:{link:"LINK",video:"VIDEO",audio:"AUDIO"},trackKinds:{subtitles:"SUBTITLES",captions:"CAPTIONS",descriptions:"DESCRIPTIONS",chapters:"CHAPTERS",metadata:"METADATA"}}},_exports.default})); +define("tiny_media/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={IMAGE:{actions:{submit:".tiny_image_urlentrysubmit",imageBrowser:".openimagebrowser",addUrl:".tiny_image_addurl",deleteImage:".tiny_image_deleteicon"},elements:{form:"form.tiny_image_form",alignSettings:".tiny_image_button",alt:".tiny_image_altentry",altWarning:".tiny_image_altwarning",height:".tiny_image_heightentry",width:".tiny_image_widthentry",url:".tiny_image_urlentry",urlWarning:".tiny_image_urlwarning",size:".tiny_image_size",presentation:".tiny_image_presentation",constrain:".tiny_image_constrain",customStyle:".tiny_image_customstyle",preview:".tiny_image_preview",previewBox:".tiny_image_preview_box",loaderIcon:".tiny_image_loader",loaderIconContainer:".tiny_image_loader_container",insertImage:".tiny_image_insert_image",modalFooter:".modal-footer",dropzoneContainer:".tiny_image_dropzone_container",fileInput:"#tiny_image_fileinput",fileNameLabel:".tiny_image_filename",sizeOriginal:".tiny_image_sizeoriginal",sizeCustom:".tiny_image_sizecustom",properties:".tiny_image_properties"},styles:{responsive:"img-fluid"}},EMBED:{actions:{mediaBrowser:".openmediabrowser"},elements:{source:".tiny_media_source",track:".tiny_media_track",posterSource:".tiny_media_poster_source",title:".tiny_media_title_entry",url:".tiny_media_url_entry",width:".tiny_media_width_entry",height:".tiny_media_height_entry",trackSource:".tiny_media_track_source",trackLabel:".tiny_media_track_label_entry",trackLang:".tiny_media_track_lang_entry",trackDefault:".tiny_media_track_default",mediaControl:".tiny_media_controls",mediaAutoplay:".tiny_media_autoplay",mediaMute:".tiny_media_mute",mediaLoop:".tiny_media_loop"}}},_exports.default})); //# sourceMappingURL=selectors.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/amd/build/selectors.min.js.map b/lib/editor/tiny/plugins/media/amd/build/selectors.min.js.map index 4dfafa3e965..cd98ca07930 100644 --- a/lib/editor/tiny/plugins/media/amd/build/selectors.min.js.map +++ b/lib/editor/tiny/plugins/media/amd/build/selectors.min.js.map @@ -1 +1 @@ -{"version":3,"file":"selectors.min.js","sources":["../src/selectors.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 Media plugin helper function to build queryable data selectors.\n *\n * @module tiny_media/selectors\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport default {\n IMAGE: {\n actions: {\n submit: '.tiny_image_urlentrysubmit',\n imageBrowser: '.openimagebrowser',\n addUrl: '.tiny_image_addurl',\n deleteImage: '.tiny_image_deleteicon',\n },\n elements: {\n form: 'form.tiny_image_form',\n alignSettings: '.tiny_image_button',\n alt: '.tiny_image_altentry',\n altWarning: '.tiny_image_altwarning',\n height: '.tiny_image_heightentry',\n width: '.tiny_image_widthentry',\n url: '.tiny_image_urlentry',\n urlWarning: '.tiny_image_urlwarning',\n size: '.tiny_image_size',\n presentation: '.tiny_image_presentation',\n constrain: '.tiny_image_constrain',\n customStyle: '.tiny_image_customstyle',\n preview: '.tiny_image_preview',\n previewBox: '.tiny_image_preview_box',\n loaderIcon: '.tiny_image_loader',\n loaderIconContainer: '.tiny_image_loader_container',\n insertImage: '.tiny_image_insert_image',\n modalFooter: '.modal-footer',\n dropzoneContainer: '.tiny_image_dropzone_container',\n fileInput: '#tiny_image_fileinput',\n fileNameLabel: '.tiny_image_filename',\n sizeOriginal: '.tiny_image_sizeoriginal',\n sizeCustom: '.tiny_image_sizecustom',\n properties: '.tiny_image_properties',\n },\n styles: {\n responsive: 'img-fluid',\n },\n },\n EMBED: {\n actions: {\n submit: '.tiny_media_submit',\n mediaBrowser: '.openmediabrowser',\n },\n elements: {\n form: 'form.tiny_media_form',\n source: '.tiny_media_source',\n track: '.tiny_media_track',\n mediaSource: '.tiny_media_media_source',\n linkSource: '.tiny_media_link_source',\n linkSize: '.tiny_media_link_size',\n posterSource: '.tiny_media_poster_source',\n posterSize: '.tiny_media_poster_size',\n displayOptions: '.tiny_media_display_options',\n name: '.tiny_media_name_entry',\n title: '.tiny_media_title_entry',\n url: '.tiny_media_url_entry',\n width: '.tiny_media_width_entry',\n height: '.tiny_media_height_entry',\n trackSource: '.tiny_media_track_source',\n trackKind: '.tiny_media_track_kind_entry',\n trackLabel: '.tiny_media_track_label_entry',\n trackLang: '.tiny_media_track_lang_entry',\n trackDefault: '.tiny_media_track_default',\n mediaControl: '.tiny_media_controls',\n mediaAutoplay: '.tiny_media_autoplay',\n mediaMute: '.tiny_media_mute',\n mediaLoop: '.tiny_media_loop',\n advancedSettings: '.tiny_media_advancedsettings',\n linkTab: 'li[data-medium-type=\"link\"]',\n videoTab: 'li[data-medium-type=\"video\"]',\n audioTab: 'li[data-medium-type=\"audio\"]',\n linkPane: '.tab-pane[data-medium-type=\"link\"]',\n videoPane: '.tab-pane[data-medium-type=\"video\"]',\n audioPane: '.tab-pane[data-medium-type=\"audio\"]',\n trackSubtitlesTab: 'li[data-track-kind=\"subtitles\"]',\n trackCaptionsTab: 'li[data-track-kind=\"captions\"]',\n trackDescriptionsTab: 'li[data-track-kind=\"descriptions\"]',\n trackChaptersTab: 'li[data-track-kind=\"chapters\"]',\n trackMetadataTab: 'li[data-track-kind=\"metadata\"]',\n trackSubtitlesPane: '.tab-pane[data-track-kind=\"subtitles\"]',\n trackCaptionsPane: '.tab-pane[data-track-kind=\"captions\"]',\n trackDescriptionsPane: '.tab-pane[data-track-kind=\"descriptions\"]',\n trackChaptersPane: '.tab-pane[data-track-kind=\"chapters\"]',\n trackMetadataPane: '.tab-pane[data-track-kind=\"metadata\"]',\n },\n mediaTypes: {\n link: 'LINK',\n video: 'VIDEO',\n audio: 'AUDIO',\n },\n trackKinds: {\n subtitles: 'SUBTITLES',\n captions: 'CAPTIONS',\n descriptions: 'DESCRIPTIONS',\n chapters: 'CHAPTERS',\n metadata: 'METADATA',\n },\n },\n};\n"],"names":["IMAGE","actions","submit","imageBrowser","addUrl","deleteImage","elements","form","alignSettings","alt","altWarning","height","width","url","urlWarning","size","presentation","constrain","customStyle","preview","previewBox","loaderIcon","loaderIconContainer","insertImage","modalFooter","dropzoneContainer","fileInput","fileNameLabel","sizeOriginal","sizeCustom","properties","styles","responsive","EMBED","mediaBrowser","source","track","mediaSource","linkSource","linkSize","posterSource","posterSize","displayOptions","name","title","trackSource","trackKind","trackLabel","trackLang","trackDefault","mediaControl","mediaAutoplay","mediaMute","mediaLoop","advancedSettings","linkTab","videoTab","audioTab","linkPane","videoPane","audioPane","trackSubtitlesTab","trackCaptionsTab","trackDescriptionsTab","trackChaptersTab","trackMetadataTab","trackSubtitlesPane","trackCaptionsPane","trackDescriptionsPane","trackChaptersPane","trackMetadataPane","mediaTypes","link","video","audio","trackKinds","subtitles","captions","descriptions","chapters","metadata"],"mappings":"sKAuBe,CACXA,MAAO,CACHC,QAAS,CACLC,OAAQ,6BACRC,aAAc,oBACdC,OAAQ,qBACRC,YAAa,0BAEjBC,SAAU,CACNC,KAAM,uBACNC,cAAe,qBACfC,IAAK,uBACLC,WAAY,yBACZC,OAAQ,0BACRC,MAAO,yBACPC,IAAK,uBACLC,WAAY,yBACZC,KAAM,mBACNC,aAAc,2BACdC,UAAW,wBACXC,YAAa,0BACbC,QAAS,sBACTC,WAAY,0BACZC,WAAY,qBACZC,oBAAqB,+BACrBC,YAAa,2BACbC,YAAa,gBACbC,kBAAmB,iCACnBC,UAAW,wBACXC,cAAe,uBACfC,aAAc,2BACdC,WAAY,yBACZC,WAAY,0BAEhBC,OAAQ,CACJC,WAAY,cAGpBC,MAAO,CACHhC,QAAS,CACLC,OAAQ,qBACRgC,aAAc,qBAElB5B,SAAU,CACNC,KAAM,uBACN4B,OAAQ,qBACRC,MAAO,oBACPC,YAAa,2BACbC,WAAY,0BACZC,SAAU,wBACVC,aAAc,4BACdC,WAAY,0BACZC,eAAgB,8BAChBC,KAAM,yBACNC,MAAO,0BACP/B,IAAK,wBACLD,MAAO,0BACPD,OAAQ,2BACRkC,YAAa,2BACbC,UAAW,+BACXC,WAAY,gCACZC,UAAW,+BACXC,aAAc,4BACdC,aAAc,uBACdC,cAAe,uBACfC,UAAW,mBACXC,UAAW,mBACXC,iBAAkB,+BAClBC,QAAS,8BACTC,SAAU,+BACVC,SAAU,+BACVC,SAAU,qCACVC,UAAW,sCACXC,UAAW,sCACXC,kBAAmB,kCACnBC,iBAAkB,iCAClBC,qBAAsB,qCACtBC,iBAAkB,iCAClBC,iBAAkB,iCAClBC,mBAAoB,yCACpBC,kBAAmB,wCACnBC,sBAAuB,4CACvBC,kBAAmB,wCACnBC,kBAAmB,yCAEvBC,WAAY,CACRC,KAAM,OACNC,MAAO,QACPC,MAAO,SAEXC,WAAY,CACRC,UAAW,YACXC,SAAU,WACVC,aAAc,eACdC,SAAU,WACVC,SAAU"} \ No newline at end of file +{"version":3,"file":"selectors.min.js","sources":["../src/selectors.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 Media plugin helper function to build queryable data selectors.\n *\n * @module tiny_media/selectors\n * @copyright 2022 Huong Nguyen \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport default {\n IMAGE: {\n actions: {\n submit: '.tiny_image_urlentrysubmit',\n imageBrowser: '.openimagebrowser',\n addUrl: '.tiny_image_addurl',\n deleteImage: '.tiny_image_deleteicon',\n },\n elements: {\n form: 'form.tiny_image_form',\n alignSettings: '.tiny_image_button',\n alt: '.tiny_image_altentry',\n altWarning: '.tiny_image_altwarning',\n height: '.tiny_image_heightentry',\n width: '.tiny_image_widthentry',\n url: '.tiny_image_urlentry',\n urlWarning: '.tiny_image_urlwarning',\n size: '.tiny_image_size',\n presentation: '.tiny_image_presentation',\n constrain: '.tiny_image_constrain',\n customStyle: '.tiny_image_customstyle',\n preview: '.tiny_image_preview',\n previewBox: '.tiny_image_preview_box',\n loaderIcon: '.tiny_image_loader',\n loaderIconContainer: '.tiny_image_loader_container',\n insertImage: '.tiny_image_insert_image',\n modalFooter: '.modal-footer',\n dropzoneContainer: '.tiny_image_dropzone_container',\n fileInput: '#tiny_image_fileinput',\n fileNameLabel: '.tiny_image_filename',\n sizeOriginal: '.tiny_image_sizeoriginal',\n sizeCustom: '.tiny_image_sizecustom',\n properties: '.tiny_image_properties',\n },\n styles: {\n responsive: 'img-fluid',\n },\n },\n EMBED: {\n actions: {\n mediaBrowser: '.openmediabrowser',\n },\n elements: {\n source: '.tiny_media_source',\n track: '.tiny_media_track',\n posterSource: '.tiny_media_poster_source',\n title: '.tiny_media_title_entry',\n url: '.tiny_media_url_entry',\n width: '.tiny_media_width_entry',\n height: '.tiny_media_height_entry',\n trackSource: '.tiny_media_track_source',\n trackLabel: '.tiny_media_track_label_entry',\n trackLang: '.tiny_media_track_lang_entry',\n trackDefault: '.tiny_media_track_default',\n mediaControl: '.tiny_media_controls',\n mediaAutoplay: '.tiny_media_autoplay',\n mediaMute: '.tiny_media_mute',\n mediaLoop: '.tiny_media_loop',\n },\n },\n};\n"],"names":["IMAGE","actions","submit","imageBrowser","addUrl","deleteImage","elements","form","alignSettings","alt","altWarning","height","width","url","urlWarning","size","presentation","constrain","customStyle","preview","previewBox","loaderIcon","loaderIconContainer","insertImage","modalFooter","dropzoneContainer","fileInput","fileNameLabel","sizeOriginal","sizeCustom","properties","styles","responsive","EMBED","mediaBrowser","source","track","posterSource","title","trackSource","trackLabel","trackLang","trackDefault","mediaControl","mediaAutoplay","mediaMute","mediaLoop"],"mappings":"sKAuBe,CACXA,MAAO,CACHC,QAAS,CACLC,OAAQ,6BACRC,aAAc,oBACdC,OAAQ,qBACRC,YAAa,0BAEjBC,SAAU,CACNC,KAAM,uBACNC,cAAe,qBACfC,IAAK,uBACLC,WAAY,yBACZC,OAAQ,0BACRC,MAAO,yBACPC,IAAK,uBACLC,WAAY,yBACZC,KAAM,mBACNC,aAAc,2BACdC,UAAW,wBACXC,YAAa,0BACbC,QAAS,sBACTC,WAAY,0BACZC,WAAY,qBACZC,oBAAqB,+BACrBC,YAAa,2BACbC,YAAa,gBACbC,kBAAmB,iCACnBC,UAAW,wBACXC,cAAe,uBACfC,aAAc,2BACdC,WAAY,yBACZC,WAAY,0BAEhBC,OAAQ,CACJC,WAAY,cAGpBC,MAAO,CACHhC,QAAS,CACLiC,aAAc,qBAElB5B,SAAU,CACN6B,OAAQ,qBACRC,MAAO,oBACPC,aAAc,4BACdC,MAAO,0BACPzB,IAAK,wBACLD,MAAO,0BACPD,OAAQ,2BACR4B,YAAa,2BACbC,WAAY,gCACZC,UAAW,+BACXC,aAAc,4BACdC,aAAc,uBACdC,cAAe,uBACfC,UAAW,mBACXC,UAAW"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/amd/src/embed.js b/lib/editor/tiny/plugins/media/amd/src/embed.js index 3e13bd1ddac..5903600e19e 100644 --- a/lib/editor/tiny/plugins/media/amd/src/embed.js +++ b/lib/editor/tiny/plugins/media/amd/src/embed.js @@ -21,17 +21,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -import Templates from 'core/templates'; -import { - getString, - getStrings, -} from 'core/str'; +import {getString} from 'core/str'; import * as ModalEvents from 'core/modal_events'; -import {displayFilepicker} from 'editor_tiny/utils'; -import {getCurrentLanguage, getMoodleLang} from 'editor_tiny/options'; -import {component} from "./common"; import EmbedModal from './embedmodal'; -import Selectors from './selectors'; import {getEmbedPermissions} from './options'; import {getFilePicker} from 'editor_tiny/options'; @@ -41,21 +33,6 @@ export default class MediaEmbed { canShowFilePickerPoster = false; canShowFilePickerTrack = false; - /** - * @property {Object} The names of the alignment options. - */ - helpStrings = null; - - /** - * @property {boolean} Indicate that the user is updating the media or not. - */ - isUpdating = false; - - /** - * @property {Object} The currently selected media. - */ - selectedMedia = null; - constructor(editor) { const permissions = getEmbedPermissions(editor); @@ -67,401 +44,30 @@ export default class MediaEmbed { this.editor = editor; } - async getHelpStrings() { - if (!this.helpStrings) { - const [addSource, tracks, subtitles, captions, descriptions, chapters, metadata] = await getStrings([ - 'addsource_help', - 'tracks_help', - 'subtitles_help', - 'captions_help', - 'descriptions_help', - 'chapters_help', - 'metadata_help', - ].map((key) => ({ - key, - component, - }))); - - this.helpStrings = {addSource, tracks, subtitles, captions, descriptions, chapters, metadata}; - } - - return this.helpStrings; - } - - async getTemplateContext(data) { - const languages = this.prepareMoodleLang(); - - const helpIcons = Array.from(Object.entries(await this.getHelpStrings())).forEach(([key, text]) => { - data[`${key.toLowerCase()}helpicon`] = {text}; - }); - - return Object.assign({}, { + async getTemplateContext() { + return { elementid: this.editor.getElement().id, showfilepicker: this.canShowFilePicker, showfilepickerposter: this.canShowFilePickerPoster, showfilepickertrack: this.canShowFilePickerTrack, - langsinstalled: languages.installed, - langsavailable: languages.available, - link: true, - video: false, - audio: false, - isupdating: this.isUpdating, - }, data, helpIcons); + }; } async displayDialogue() { - this.selectedMedia = this.getSelectedMedia(); - const data = Object.assign({}, this.getCurrentEmbedData()); - this.isUpdating = Object.keys(data).length !== 0; - this.currentModal = await EmbedModal.create({ title: getString('createmedia', 'tiny_media'), - templateContext: await this.getTemplateContext(data), + templateContext: await this.getTemplateContext(), }); await this.registerEventListeners(this.currentModal); } - getCurrentEmbedData() { - const properties = this.getMediumProperties(); - if (!properties) { - return {}; - } - - const processedProperties = {}; - processedProperties[properties.type.toLowerCase()] = properties; - processedProperties.link = false; - - return processedProperties; - } - - getSelectedMedia() { - const mediaElm = this.editor.selection.getNode(); - - if (!mediaElm) { - return null; - } - - if (mediaElm.nodeName.toLowerCase() === 'video' || mediaElm.nodeName.toLowerCase() === 'audio') { - return mediaElm; - } - - if (mediaElm.querySelector('video')) { - return mediaElm.querySelector('video'); - } - - if (mediaElm.querySelector('audio')) { - return mediaElm.querySelector('audio'); - } - - return null; - } - - getMediumProperties() { - const boolAttr = (elem, attr) => { - // As explained in MDL-64175, some OS (like Ubuntu), are removing the value for these attributes. - // So in order to check if attr="true", we need to check if the attribute exists and if the value is empty or true. - return (elem.hasAttribute(attr) && (elem.getAttribute(attr) || elem.getAttribute(attr) === '')); - }; - - const tracks = { - subtitles: [], - captions: [], - descriptions: [], - chapters: [], - metadata: [] - }; - const sources = []; - - const medium = this.selectedMedia; - if (!medium) { - return null; - } - medium.querySelectorAll('track').forEach((track) => { - tracks[track.getAttribute('kind')].push({ - src: track.getAttribute('src'), - srclang: track.getAttribute('srclang'), - label: track.getAttribute('label'), - defaultTrack: boolAttr(track, 'default') - }); - }); - - medium.querySelectorAll('source').forEach((source) => { - sources.push(source.src); - }); - - return { - type: medium.nodeName.toLowerCase() === 'video' ? Selectors.EMBED.mediaTypes.video : Selectors.EMBED.mediaTypes.audio, - sources, - poster: medium.getAttribute('poster'), - title: medium.getAttribute('title'), - width: medium.getAttribute('width'), - height: medium.getAttribute('height'), - autoplay: boolAttr(medium, 'autoplay'), - loop: boolAttr(medium, 'loop'), - muted: boolAttr(medium, 'muted'), - controls: boolAttr(medium, 'controls'), - tracks, - }; - } - - prepareMoodleLang() { - const moodleLangs = getMoodleLang(this.editor); - const currentLanguage = getCurrentLanguage(this.editor); - - const installed = Object.entries(moodleLangs.installed).map(([lang, code]) => ({ - lang, - code, - "default": lang === currentLanguage, - })); - - const available = Object.entries(moodleLangs.available).map(([lang, code]) => ({ - lang, - code, - "default": lang === currentLanguage, - })); - - return { - installed, - available, - }; - } - - getMoodleLangObj(subtitleLang) { - const {available} = getMoodleLang(this.editor); - - if (available[subtitleLang]) { - return { - lang: subtitleLang, - code: available[subtitleLang], - }; - } - - return null; - } - - filePickerCallback(params, element, fpType) { - if (params.url !== '') { - const tabPane = element.closest('.tab-pane'); - element.closest(Selectors.EMBED.elements.source).querySelector(Selectors.EMBED.elements.url).value = params.url; - - if (tabPane.id === this.editor.getElement().id + '_' + Selectors.EMBED.mediaTypes.link.toLowerCase()) { - tabPane.querySelector(Selectors.EMBED.elements.name).value = params.file; - } - - if (fpType === 'subtitle') { - // If the file is subtitle file. We need to match the language and label for that file. - const subtitleLang = params.file.split('.vtt')[0].split('-').slice(-1)[0]; - const langObj = this.getMoodleLangObj(subtitleLang); - if (langObj) { - const track = element.closest(Selectors.EMBED.elements.track); - track.querySelector(Selectors.EMBED.elements.trackLabel).value = langObj.lang.trim(); - track.querySelector(Selectors.EMBED.elements.trackLang).value = langObj.code; - } - } - } - } - - addMediaSourceComponent(element, callback) { - const sourceElement = element.closest(Selectors.EMBED.elements.source + Selectors.EMBED.elements.mediaSource); - const clone = sourceElement.cloneNode(true); - - sourceElement.querySelector('.removecomponent-wrapper').classList.remove('hidden'); - sourceElement.querySelector('.addcomponent-wrapper').classList.add('hidden'); - - sourceElement.parentNode.insertBefore(clone, sourceElement.nextSibling); - - if (callback) { - callback(clone); - } - } - - removeMediaSourceComponent(element) { - const sourceElement = element.closest(Selectors.EMBED.elements.source + Selectors.EMBED.elements.mediaSource); - sourceElement.remove(); - } - - addTrackComponent(element, callback) { - const trackElement = element.closest(Selectors.EMBED.elements.track); - const clone = trackElement.cloneNode(true); - - trackElement.querySelector('.removecomponent-wrapper').classList.remove('hidden'); - trackElement.querySelector('.addcomponent-wrapper').classList.add('hidden'); - - trackElement.parentNode.insertBefore(clone, trackElement.nextSibling); - - if (callback) { - callback(clone); - } - } - - removeTrackComponent(element) { - const sourceElement = element.closest(Selectors.EMBED.elements.track); - sourceElement.remove(); - } - - getMediumTypeFromTabPane(tabPane) { - return tabPane.getAttribute('data-medium-type'); - } - - getTrackTypeFromTabPane(tabPane) { - return tabPane.getAttribute('data-track-kind'); - } - - getMediaHTML(form) { - const mediumType = this.getMediumTypeFromTabPane(form.querySelector('.root.tab-content > .tab-pane.active')); - const tabContent = form.querySelector(Selectors.EMBED.elements[mediumType.toLowerCase() + 'Pane']); - - return this['getMediaHTML' + mediumType[0].toUpperCase() + mediumType.substr(1)](tabContent); - } - - getMediaHTMLLink(tab) { - const context = { - url: tab.querySelector(Selectors.EMBED.elements.url).value, - name: tab.querySelector(Selectors.EMBED.elements.name).value || false - }; - - return context.url ? Templates.renderForPromise('tiny_media/embed_media_link', context) : ''; - } - - getMediaHTMLVideo(tab) { - const context = this.getContextForMediaHTML(tab); - context.width = tab.querySelector(Selectors.EMBED.elements.width).value || false; - context.height = tab.querySelector(Selectors.EMBED.elements.height).value || false; - context.poster = tab.querySelector( - `${Selectors.EMBED.elements.posterSource} ${Selectors.EMBED.elements.url}` - ).value || false; - - return context.sources.length ? Templates.renderForPromise('tiny_media/embed_media_video', context) : ''; - } - - getMediaHTMLAudio(tab) { - const context = this.getContextForMediaHTML(tab); - - return context.sources.length ? Templates.renderForPromise('tiny_media/embed_media_audio', context) : ''; - } - - getContextForMediaHTML(tab) { - const tracks = Array.from(tab.querySelectorAll(Selectors.EMBED.elements.track)).map(track => ({ - track: track.querySelector(Selectors.EMBED.elements.trackSource + ' ' + Selectors.EMBED.elements.url).value, - kind: this.getTrackTypeFromTabPane(track.closest('.tab-pane')), - label: track.querySelector(Selectors.EMBED.elements.trackLabel).value || - track.querySelector(Selectors.EMBED.elements.trackLang).value, - srclang: track.querySelector(Selectors.EMBED.elements.trackLang).value, - defaultTrack: track.querySelector(Selectors.EMBED.elements.trackDefault).checked ? "true" : null - })).filter((track) => !!track.track); - - const sources = Array.from(tab.querySelectorAll(Selectors.EMBED.elements.mediaSource + ' ' - + Selectors.EMBED.elements.url)) - .filter((source) => !!source.value) - .map((source) => source.value); - - return { - sources, - description: tab.querySelector(Selectors.EMBED.elements.mediaSource + ' ' - + Selectors.EMBED.elements.url).value || false, - tracks, - showControls: tab.querySelector(Selectors.EMBED.elements.mediaControl).checked, - autoplay: tab.querySelector(Selectors.EMBED.elements.mediaAutoplay).checked, - muted: tab.querySelector(Selectors.EMBED.elements.mediaMute).checked, - loop: tab.querySelector(Selectors.EMBED.elements.mediaLoop).checked, - title: tab.querySelector(Selectors.EMBED.elements.title).value || false - }; - } - - getFilepickerTypeFromElement(element) { - if (element.closest(Selectors.EMBED.elements.posterSource)) { - return 'image'; - } - if (element.closest(Selectors.EMBED.elements.trackSource)) { - return 'subtitle'; - } - - return 'media'; - } - - async clickHandler(e) { - const element = e.target; - - const mediaBrowser = element.closest(Selectors.EMBED.actions.mediaBrowser); - if (mediaBrowser) { - e.preventDefault(); - const fpType = this.getFilepickerTypeFromElement(element); - const params = await displayFilepicker(this.editor, fpType); - this.filePickerCallback(params, element, fpType); - } - - const addComponentSourceAction = element.closest(Selectors.EMBED.elements.mediaSource + ' .addcomponent'); - if (addComponentSourceAction) { - e.preventDefault(); - this.addMediaSourceComponent(element); - } - - const removeComponentSourceAction = element.closest(Selectors.EMBED.elements.mediaSource + ' .removecomponent'); - if (removeComponentSourceAction) { - e.preventDefault(); - this.removeMediaSourceComponent(element); - } - - const addComponentTrackAction = element.closest(Selectors.EMBED.elements.track + ' .addcomponent'); - if (addComponentTrackAction) { - e.preventDefault(); - this.addTrackComponent(element); - } - - const removeComponentTrackAction = element.closest(Selectors.EMBED.elements.track + ' .removecomponent'); - if (removeComponentTrackAction) { - e.preventDefault(); - this.removeTrackComponent(element); - } - - // Only allow one track per tab to be selected as "default". - const trackDefaultAction = element.closest(Selectors.EMBED.elements.trackDefault); - if (trackDefaultAction && trackDefaultAction.checked) { - const getKind = (el) => this.getTrackTypeFromTabPane(el.parentElement.closest('.tab-pane')); - - element.parentElement - .closest('.root.tab-content') - .querySelectorAll(Selectors.EMBED.elements.trackDefault) - .forEach((select) => { - if (select !== element && getKind(element) === getKind(select)) { - select.checked = false; - } - }); - } - } - - async handleDialogueSubmission(event, modal) { - const {html} = await this.getMediaHTML(modal.getRoot()[0]); - if (html) { - if (this.isUpdating) { - this.selectedMedia.outerHTML = html; - this.isUpdating = false; - } else { - this.editor.insertContent(html); - } - } - } - async registerEventListeners(modal) { await modal.getBody(); const $root = modal.getRoot(); - const root = $root[0]; - if (this.canShowFilePicker || this.canShowFilePickerPoster || this.canShowFilePickerTrack) { - root.addEventListener('click', this.clickHandler.bind(this)); - } - $root.on(ModalEvents.save, this.handleDialogueSubmission.bind(this)); $root.on(ModalEvents.hidden, () => { this.currentModal.destroy(); }); - $root.on(ModalEvents.shown, () => { - root.querySelectorAll(Selectors.EMBED.elements.trackLang).forEach((dropdown) => { - const defaultVal = dropdown.getAttribute('data-value'); - if (defaultVal) { - dropdown.value = defaultVal; - } - }); - }); } } diff --git a/lib/editor/tiny/plugins/media/amd/src/selectors.js b/lib/editor/tiny/plugins/media/amd/src/selectors.js index 468b598465d..5ceb47e3ef3 100644 --- a/lib/editor/tiny/plugins/media/amd/src/selectors.js +++ b/lib/editor/tiny/plugins/media/amd/src/selectors.js @@ -61,26 +61,17 @@ export default { }, EMBED: { actions: { - submit: '.tiny_media_submit', mediaBrowser: '.openmediabrowser', }, elements: { - form: 'form.tiny_media_form', source: '.tiny_media_source', track: '.tiny_media_track', - mediaSource: '.tiny_media_media_source', - linkSource: '.tiny_media_link_source', - linkSize: '.tiny_media_link_size', posterSource: '.tiny_media_poster_source', - posterSize: '.tiny_media_poster_size', - displayOptions: '.tiny_media_display_options', - name: '.tiny_media_name_entry', title: '.tiny_media_title_entry', url: '.tiny_media_url_entry', width: '.tiny_media_width_entry', height: '.tiny_media_height_entry', trackSource: '.tiny_media_track_source', - trackKind: '.tiny_media_track_kind_entry', trackLabel: '.tiny_media_track_label_entry', trackLang: '.tiny_media_track_lang_entry', trackDefault: '.tiny_media_track_default', @@ -88,35 +79,6 @@ export default { mediaAutoplay: '.tiny_media_autoplay', mediaMute: '.tiny_media_mute', mediaLoop: '.tiny_media_loop', - advancedSettings: '.tiny_media_advancedsettings', - linkTab: 'li[data-medium-type="link"]', - videoTab: 'li[data-medium-type="video"]', - audioTab: 'li[data-medium-type="audio"]', - linkPane: '.tab-pane[data-medium-type="link"]', - videoPane: '.tab-pane[data-medium-type="video"]', - audioPane: '.tab-pane[data-medium-type="audio"]', - trackSubtitlesTab: 'li[data-track-kind="subtitles"]', - trackCaptionsTab: 'li[data-track-kind="captions"]', - trackDescriptionsTab: 'li[data-track-kind="descriptions"]', - trackChaptersTab: 'li[data-track-kind="chapters"]', - trackMetadataTab: 'li[data-track-kind="metadata"]', - trackSubtitlesPane: '.tab-pane[data-track-kind="subtitles"]', - trackCaptionsPane: '.tab-pane[data-track-kind="captions"]', - trackDescriptionsPane: '.tab-pane[data-track-kind="descriptions"]', - trackChaptersPane: '.tab-pane[data-track-kind="chapters"]', - trackMetadataPane: '.tab-pane[data-track-kind="metadata"]', - }, - mediaTypes: { - link: 'LINK', - video: 'VIDEO', - audio: 'AUDIO', - }, - trackKinds: { - subtitles: 'SUBTITLES', - captions: 'CAPTIONS', - descriptions: 'DESCRIPTIONS', - chapters: 'CHAPTERS', - metadata: 'METADATA', }, }, }; diff --git a/lib/editor/tiny/plugins/media/lang/en/deprecated.txt b/lib/editor/tiny/plugins/media/lang/en/deprecated.txt index 431de560cd8..39dd631cc23 100644 --- a/lib/editor/tiny/plugins/media/lang/en/deprecated.txt +++ b/lib/editor/tiny/plugins/media/lang/en/deprecated.txt @@ -5,3 +5,18 @@ alignment_middle,tiny_media alignment_right,tiny_media alignment_top,tiny_media helplinktext,tiny_media +addsource,tiny_media +addsource_help,tiny_media +advancedsettings,tiny_media +audio,tiny_media +audiosourcelabel,tiny_media +createmedia,tiny_media +displayoptions,tiny_media +entername,tiny_media +entersource,tiny_media +link,tiny_media +updatemedia,tiny_media +video,tiny_media +videoheight,tiny_media +videosourcelabel,tiny_media +videowidth,tiny_media diff --git a/lib/editor/tiny/plugins/media/lang/en/tiny_media.php b/lib/editor/tiny/plugins/media/lang/en/tiny_media.php index 8164186d326..b42abe6f16a 100644 --- a/lib/editor/tiny/plugins/media/lang/en/tiny_media.php +++ b/lib/editor/tiny/plugins/media/lang/en/tiny_media.php @@ -27,13 +27,8 @@ $string['addchapterstrack'] = 'Add chapter track'; $string['adddescriptionstrack'] = 'Add description track'; $string['addfilesdrop'] = 'Drag and drop an image to upload, or click to select'; $string['addmetadatatrack'] = 'Add metadata track'; -$string['addsource_help'] = 'You are recommended to provide an alternative media source, as desktop and mobile browsers support different file formats.'; -$string['addsource'] = 'Add alternative source'; $string['addsubtitlestrack'] = 'Add subtitle track'; $string['addurl'] = 'Add'; -$string['advancedsettings'] = 'Advanced settings'; -$string['audio'] = 'Audio'; -$string['audiosourcelabel'] = 'Audio source URL'; $string['autoplay'] = 'Play automatically'; $string['browserepositories'] = 'Browse repositories...'; $string['browserepositoriesimage'] = 'Browse repositories'; @@ -45,7 +40,6 @@ $string['chapters'] = 'Chapters'; $string['chapterssourcelabel'] = 'Chapter track URL'; $string['constrain'] = 'Keep proportion'; $string['controls'] = 'Show controls'; -$string['createmedia'] = 'Insert media'; $string['default'] = 'Default'; $string['deleteimage'] = 'Delete image'; $string['deleteimagewarning'] = 'Are you sure you want to remove the image?'; @@ -53,10 +47,7 @@ $string['deleteselected'] = 'Delete selected files'; $string['descriptions_help'] = 'Audio descriptions may be used to provide a narration which explains visual details not apparent from the audio alone.'; $string['descriptions'] = 'Descriptions'; $string['descriptionssourcelabel'] = 'Description track URL'; -$string['displayoptions'] = 'Display options'; -$string['enteralt'] = 'How would you describe this image to someone who can\'t see it?'; -$string['entername'] = 'Name'; -$string['entersource'] = 'Source URL'; +$string['enteralt'] = 'How would you describe this image to someone who can\'t see it:'; $string['entertitle'] = 'Title'; $string['enterurl'] = 'Add via URL'; $string['enterurlor'] = 'Or add via URL'; @@ -71,7 +62,6 @@ $string['insertimage'] = 'Insert image'; $string['label'] = 'Label'; $string['languagesavailable'] = 'Languages available'; $string['languagesinstalled'] = 'Languages installed'; -$string['link'] = 'Link'; $string['loading'] = 'Preparing the image'; $string['loop'] = 'Loop'; $string['managefiles'] = 'Manage files'; @@ -105,12 +95,7 @@ $string['tracks'] = 'Subtitles and captions'; $string['unusedfilesdesc'] = 'The following embedded files are not used in the text area:'; $string['unusedfilesheader'] = 'Unused files'; $string['unusedfilesremovalnotice'] = 'Any unused files will be automatically deleted when saving changes.'; -$string['updatemedia'] = 'Update media'; $string['uploading'] = 'Uploading'; -$string['video'] = 'Video'; -$string['videoheight'] = 'Video height'; -$string['videosourcelabel'] = 'Video source URL'; -$string['videowidth'] = 'Video width'; $string['width'] = 'Width'; // Deprecated since Moodle 4.4. @@ -122,4 +107,19 @@ $string['alignment_right'] = 'Right'; $string['alignment_top'] = 'Top'; // Deprecated since Moodle 4.5. +$string['addsource'] = 'Add alternative source'; +$string['addsource_help'] = 'You are recommended to provide an alternative media source, as desktop and mobile browsers support different file formats.'; +$string['advancedsettings'] = 'Advanced settings'; +$string['audio'] = 'Audio'; +$string['audiosourcelabel'] = 'Audio source URL'; +$string['createmedia'] = 'Insert media'; +$string['displayoptions'] = 'Display options'; +$string['entername'] = 'Name'; +$string['entersource'] = 'Source URL'; $string['helplinktext'] = 'Media helper'; +$string['link'] = 'Link'; +$string['updatemedia'] = 'Update media'; +$string['video'] = 'Video'; +$string['videoheight'] = 'Video height'; +$string['videosourcelabel'] = 'Video source URL'; +$string['videowidth'] = 'Video width'; diff --git a/lib/editor/tiny/plugins/media/templates/embed/body/insert_media_body.mustache b/lib/editor/tiny/plugins/media/templates/embed/body/insert_media_body.mustache new file mode 100644 index 00000000000..7feffa26b7c --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/body/insert_media_body.mustache @@ -0,0 +1,50 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/body/insert_media_body + + Insert media body template. + + Example context (json): + { + "showDropzone": true, + "showFilePicker": true + } + +}} +
+
+ {{#showDropzone}} +
+ {{/showDropzone}} + {{^showDropzone}} +
+ +
+

+ {{#showFilePicker}} + {{#str}} nofilepicker, tiny_media {{/str}} + {{/showFilePicker}} + {{^showFilePicker}} + {{#str}} nofilepickerrepository, tiny_media, {{fileType}} {{/str}} + {{/showFilePicker}} +

+
+
+ {{/showDropzone}} +
+
diff --git a/lib/editor/tiny/plugins/media/templates/embed/body/media_details_body.mustache b/lib/editor/tiny/plugins/media/templates/embed/body/media_details_body.mustache new file mode 100644 index 00000000000..8c95e0f8c52 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/body/media_details_body.mustache @@ -0,0 +1,232 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/body/media_details_body + + Media preview body template. + + Example context (json): + { + "isVideo": true, + "isAudio": true, + "isLink": true, + "canHaveThumbnail": true, + "isAudioTag": true, + "isVideoTag": true, + "elementid": "id", + "media" : { + "poster": "link/to/poster", + "title": "media name/title", + "isUpdating": true, + "controls": true, + "autoplay": false, + "muted": false, + "loop": false, + "width": "1200", + "height": "800" + } + } + +}} +
+
+
+
+
+ + {{#isVideo}} + + {{/isVideo}} + {{#isAudio}} + + {{/isAudio}} + {{#isLink}} + + {{/isLink}} +
+
+
+
+
+ +
+ +
+
+ {{#isLink}} + + {{/isLink}} + {{#canHaveThumbnail}} +
+
+ +
+ {{#media.poster}} +
+ +
+ {{/media.poster}} +
+ {{/canHaveThumbnail}} +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ {{#canHaveThumbnail}} +
+
+
+
+ + +
+
+ + + {{#isLink}} + {{#linkcustomsizehelpicon}} + {{> core/help_icon }} + {{/linkcustomsizehelpicon}} + {{/isLink}} + {{^isLink}} + {{#customsizehelpicon}} + {{> core/help_icon }} + {{/customsizehelpicon}} + {{/isLink}} +
+
+
+
+
+
+ + +
+
+
X
+
+
+ + +
+
+
+
+
+ {{/canHaveThumbnail}} +
+
+
+
+ +
+
+ {{> tiny_media/embed/insert_media_subtitle_caption }} +
+
diff --git a/lib/editor/tiny/plugins/media/templates/embed/body/media_thumbnail_body.mustache b/lib/editor/tiny/plugins/media/templates/embed/body/media_thumbnail_body.mustache new file mode 100644 index 00000000000..7a8b7a077ff --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/body/media_thumbnail_body.mustache @@ -0,0 +1,39 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/body/media_thumbnail_body + + Insert thumbnail preview body template. + + Example context (json): + { + + } + +}} +
+
+
+
+ + media thumbnail image +
+
+
+
diff --git a/lib/editor/tiny/plugins/media/templates/embed_media_audio.mustache b/lib/editor/tiny/plugins/media/templates/embed/embed_media_audio.mustache similarity index 94% rename from lib/editor/tiny/plugins/media/templates/embed_media_audio.mustache rename to lib/editor/tiny/plugins/media/templates/embed/embed_media_audio.mustache index 72b797c833d..e3021a86dbd 100644 --- a/lib/editor/tiny/plugins/media/templates/embed_media_audio.mustache +++ b/lib/editor/tiny/plugins/media/templates/embed/embed_media_audio.mustache @@ -24,7 +24,7 @@ } }} - . +}} +{{! + @template tiny_media/embed_media_modal + + Embed media modal template. + + Example context (json): + { + + } +}} +{{< core/modal }} + + {{$body}} +
+ +
+
+ + {{> core/loading }} + +
{{#str}} loadingmedia, tiny_media {{/str}}
+
+
+
+
+ {{/body}} + + {{$footer}} + + {{/footer}} + +{{/ core/modal }} diff --git a/lib/editor/tiny/plugins/media/templates/embed_media_video.mustache b/lib/editor/tiny/plugins/media/templates/embed/embed_media_video.mustache similarity index 95% rename from lib/editor/tiny/plugins/media/templates/embed_media_video.mustache rename to lib/editor/tiny/plugins/media/templates/embed/embed_media_video.mustache index 61531ebdcc9..6fbbd718838 100644 --- a/lib/editor/tiny/plugins/media/templates/embed_media_video.mustache +++ b/lib/editor/tiny/plugins/media/templates/embed/embed_media_video.mustache @@ -24,7 +24,7 @@ } }} - . +}} +{{! + @template tiny_media/embed/footer/insert_media_footer + + Insert media footer template. + + Example context (json): + { + "elementid": "id", + "isInsertThumbnail": false, + "showDropzone": true, + "showFilePicker": true + } + +}} +
+
+ {{#showDropzone}} + + {{/showDropzone}} + {{^showDropzone}} + + {{/showDropzone}} + + +
+
+ + {{#showFilePicker}} + + {{/showFilePicker}} +
+
diff --git a/lib/editor/tiny/plugins/media/templates/embed/footer/media_details_footer.mustache b/lib/editor/tiny/plugins/media/templates/embed/footer/media_details_footer.mustache new file mode 100644 index 00000000000..406b31e740b --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/footer/media_details_footer.mustache @@ -0,0 +1,40 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/footer/media_details_footer + + Media preview footer template. + + Example context (json): + { + "isLink": true, + "isUpdating": true, + "canHaveThumbnail": true + } + +}} + diff --git a/lib/editor/tiny/plugins/media/templates/embed/footer/media_thumbnail_footer.mustache b/lib/editor/tiny/plugins/media/templates/embed/footer/media_thumbnail_footer.mustache new file mode 100644 index 00000000000..d2e759bd4a0 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/footer/media_thumbnail_footer.mustache @@ -0,0 +1,36 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/footer/media_thumbnail_footer + + Media thumbnail preview footer template. + + Example context (json): + { + + } + +}} + diff --git a/lib/editor/tiny/plugins/media/templates/embed/insert_media_subtitle_caption.mustache b/lib/editor/tiny/plugins/media/templates/embed/insert_media_subtitle_caption.mustache new file mode 100644 index 00000000000..efd33972654 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/insert_media_subtitle_caption.mustache @@ -0,0 +1,107 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/insert_media_subtitle_caption + + Media preview footer template. + + Example context (json): + { + "elementid": "id", + "subtitleshelpicon": "subtitle help icon", + "captionshelpicon": "caption help icon", + "descriptionshelpicon": "description help icon", + "chaptershelpicon": "chapter help icon", + "metadatahelpicon": "metadata help icon", + "helpStrings": { + "metadata": "metadata" + } + } + +}} + diff --git a/lib/editor/tiny/plugins/media/templates/embed/link_media_type_selector.mustache b/lib/editor/tiny/plugins/media/templates/embed/link_media_type_selector.mustache new file mode 100644 index 00000000000..7ea52a430c0 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/link_media_type_selector.mustache @@ -0,0 +1,37 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/link_media_type_selector + + Show media type options. + + Example context (json): + { + } + +}} + +
+ + +
\ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/templates/embed/metadata/captions.mustache b/lib/editor/tiny/plugins/media/templates/embed/metadata/captions.mustache new file mode 100644 index 00000000000..0ab305a43ca --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/metadata/captions.mustache @@ -0,0 +1,145 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/metadata/captions + + Media preview footer template. + + Example context (json): + { + "media": { + "tracks": { + "captions": "captions" + } + }, + "showFilePickerTrack": true, + "langsInstalled": "installed langs", + "src": "http://moodle.com/link/to/source", + "srclang": "selected lang", + "default": true, + "langsAvailable": "avalialbe langs", + "defaultTrack": true, + "label": "selected track", + "code": "lang code", + "lang": "lang name" + } + +}} +{{#media.tracks.captions}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.captions}} +{{^media.tracks.captions}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.captions}} diff --git a/lib/editor/tiny/plugins/media/templates/embed/metadata/chapters.mustache b/lib/editor/tiny/plugins/media/templates/embed/metadata/chapters.mustache new file mode 100644 index 00000000000..e6381763fa2 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/metadata/chapters.mustache @@ -0,0 +1,145 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/metadata/chapters + + Media preview footer template. + + Example context (json): + { + "media": { + "tracks": { + "chapters": "chapters" + } + }, + "showFilePickerTrack": true, + "langsInstalled": "installed langs", + "src": "http://moodle.com/link/to/source", + "srclang": "selected lang", + "default": true, + "langsAvailable": "avalialbe langs", + "defaultTrack": true, + "label": "selected track", + "code": "lang code", + "lang": "lang name" + } + +}} +{{#media.tracks.chapters}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.chapters}} +{{^media.tracks.chapters}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.chapters}} diff --git a/lib/editor/tiny/plugins/media/templates/embed/metadata/descriptions.mustache b/lib/editor/tiny/plugins/media/templates/embed/metadata/descriptions.mustache new file mode 100644 index 00000000000..c81c0fc38a5 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/metadata/descriptions.mustache @@ -0,0 +1,145 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/metadata/descriptions + + Media preview footer template. + + Example context (json): + { + "media": { + "tracks": { + "descriptions": "descriptions" + } + }, + "showFilePickerTrack": true, + "langsInstalled": "installed langs", + "src": "http://moodle.com/link/to/source", + "srclang": "selected lang", + "default": true, + "langsAvailable": "avalialbe langs", + "defaultTrack": true, + "label": "selected track", + "code": "lang code", + "lang": "lang name" + } + +}} +{{#media.tracks.descriptions}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.descriptions}} +{{^media.tracks.descriptions}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.descriptions}} diff --git a/lib/editor/tiny/plugins/media/templates/embed/metadata/metadata.mustache b/lib/editor/tiny/plugins/media/templates/embed/metadata/metadata.mustache new file mode 100644 index 00000000000..83e97c8a61c --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/metadata/metadata.mustache @@ -0,0 +1,145 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/metadata/metadata + + Media preview footer template. + + Example context (json): + { + "media": { + "tracks": { + "metadata": "metadata" + } + }, + "showFilePickerTrack": true, + "langsInstalled": "installed langs", + "src": "http://moodle.com/link/to/source", + "srclang": "selected lang", + "default": true, + "langsAvailable": "avalialbe langs", + "defaultTrack": true, + "label": "selected track", + "code": "lang code", + "lang": "lang name" + } + +}} +{{#media.tracks.metadata}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.metadata}} +{{^media.tracks.metadata}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.metadata}} diff --git a/lib/editor/tiny/plugins/media/templates/embed/metadata/subtitles.mustache b/lib/editor/tiny/plugins/media/templates/embed/metadata/subtitles.mustache new file mode 100644 index 00000000000..6a461a16163 --- /dev/null +++ b/lib/editor/tiny/plugins/media/templates/embed/metadata/subtitles.mustache @@ -0,0 +1,145 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template tiny_media/embed/metadata/subtitles + + Media preview footer template. + + Example context (json): + { + "media": { + "tracks": { + "subtitles": "subtitles" + } + }, + "showFilePickerTrack": true, + "langsInstalled": "installed langs", + "src": "http://moodle.com/link/to/source", + "srclang": "selected lang", + "default": true, + "langsAvailable": "avalialbe langs", + "defaultTrack": true, + "label": "selected track", + "code": "lang code", + "lang": "lang name" + } + +}} +{{#media.tracks.subtitles}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.subtitles}} +{{^media.tracks.subtitles}} +
+
+
+ +
+ + {{#showFilePickerTrack}} + + + + {{/showFilePickerTrack}} +
+
+
+
+ + +
+
+ + +
+
+ + +
+ + +
+{{/media.tracks.subtitles}} diff --git a/lib/editor/tiny/plugins/media/templates/embed_media_modal.mustache b/lib/editor/tiny/plugins/media/templates/embed_media_modal.mustache deleted file mode 100644 index 0f36ea159bb..00000000000 --- a/lib/editor/tiny/plugins/media/templates/embed_media_modal.mustache +++ /dev/null @@ -1,78 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template tiny_media/embed_media_modal - - Embed media modal template. - - Example context (json): - { - - } -}} -{{< core/modal }} - - {{$title}} - {{#str}} modaltitle, tiny_h5p {{/str}} - {{/title}} - - {{$body}} -
- -
- -
- {{> tiny_media/embed_media_modal_video}} -
-
- {{> tiny_media/embed_media_modal_audio}} -
-
-
- {{/body}} - - {{$footer}} - - - {{/footer}} - -{{/ core/modal }} diff --git a/lib/editor/tiny/plugins/media/templates/embed_media_modal_audio.mustache b/lib/editor/tiny/plugins/media/templates/embed_media_modal_audio.mustache deleted file mode 100644 index 844880df0f5..00000000000 --- a/lib/editor/tiny/plugins/media/templates/embed_media_modal_audio.mustache +++ /dev/null @@ -1,778 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template tiny_media/embed_media_modal_audio - - Embed media audio modal template. - - Example context (json): - { - - } -}} -{{#audio.sources}} -
-
- -
- - {{#showfilepicker}} - - {{/showfilepicker}} -
-
-
- - {{#str}} addsource, tiny_media {{/str}} - - {{#addsourcehelpicon}} - {{> core/help_icon }} - {{/addsourcehelpicon}} -
- -
-{{/audio.sources}} -{{^audio}} -
-
- -
- - {{#showfilepicker}} - - {{/showfilepicker}} -
-
-
- - {{#str}} addsource, tiny_media {{/str}} - - {{#addsourcehelpicon}} - {{> core/help_icon }} - {{/addsourcehelpicon}} -
- -
-{{/audio}} - - - diff --git a/lib/editor/tiny/plugins/media/templates/embed_media_modal_link.mustache b/lib/editor/tiny/plugins/media/templates/embed_media_modal_link.mustache deleted file mode 100644 index 4dc4d7ce8cd..00000000000 --- a/lib/editor/tiny/plugins/media/templates/embed_media_modal_link.mustache +++ /dev/null @@ -1,41 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template tiny_media/embed_media_modal_link - - Embed media link modal template. - - Example context (json): - { - - } -}} -
-
- -
- - {{#showfilepicker}} - - {{/showfilepicker}} -
-
-
- - diff --git a/lib/editor/tiny/plugins/media/templates/embed_media_modal_video.mustache b/lib/editor/tiny/plugins/media/templates/embed_media_modal_video.mustache deleted file mode 100644 index fdfae281824..00000000000 --- a/lib/editor/tiny/plugins/media/templates/embed_media_modal_video.mustache +++ /dev/null @@ -1,806 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template tiny_media/embed_media_modal_video - - Embed media video modal template. - - Example context (json): - { - - } -}} -{{#video.sources}} -
-
- -
- - {{#showfilepicker}} - - {{/showfilepicker}} -
-
-
- - {{#str}} addsource, tiny_media {{/str}} - - {{#addsourcehelpicon}} - {{> core/help_icon }} - {{/addsourcehelpicon}} -
- -
-{{/video.sources}} -{{^video}} -
-
- -
- - {{#showfilepicker}} - - {{/showfilepicker}} -
-
-
- - {{#str}} addsource, tiny_media {{/str}} - - {{#addsourcehelpicon}} - {{> core/help_icon }} - {{/addsourcehelpicon}} -
- -
-{{/video}} - - - diff --git a/lib/editor/tiny/plugins/media/templates/insert_image_modal_insert_footer.mustache b/lib/editor/tiny/plugins/media/templates/insert_image_modal_insert_footer.mustache index be2c89fc5aa..b6b78821d83 100644 --- a/lib/editor/tiny/plugins/media/templates/insert_image_modal_insert_footer.mustache +++ b/lib/editor/tiny/plugins/media/templates/insert_image_modal_insert_footer.mustache @@ -49,7 +49,7 @@ {{#showfilepicker}} - + {{/showfilepicker}}