From cc4bab9deb33a0fc2d1e8ea0ae63435422f53cdb Mon Sep 17 00:00:00 2001 From: Stevani Andolo Date: Thu, 1 Aug 2024 10:59:11 +0800 Subject: [PATCH] MDL-78428 tiny_media: Methods deprecation --- .../media/amd/build/imagehelpers.min.js | 4 +- .../media/amd/build/imagehelpers.min.js.map | 2 +- .../plugins/media/amd/src/imagehelpers.js | 100 +++++++----------- 3 files changed, 43 insertions(+), 63 deletions(-) diff --git a/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js b/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js index 8b25c78aba5..13de09432d3 100644 --- a/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js +++ b/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js @@ -1,10 +1,10 @@ -define("tiny_media/imagehelpers",["exports","core/templates"],(function(_exports,_templates){var obj; +define("tiny_media/imagehelpers",["exports","tiny_media/helpers"],(function(_exports,Helpers){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)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.showElements=_exports.isPercentageValue=_exports.hideElements=_exports.footerImageInsert=_exports.footerImageDetails=_exports.bodyImageInsert=_exports.bodyImageDetails=_exports.MAX_LENGTH_ALT=void 0,Helpers=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} /** * Tiny media plugin image helpers. * * @module tiny_media/imagehelpers * @copyright 2024 Meirza * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.showElements=_exports.isPercentageValue=_exports.hideElements=_exports.footerImageInsert=_exports.footerImageDetails=_exports.bodyImageInsert=_exports.bodyImageDetails=_exports.MAX_LENGTH_ALT=void 0,_templates=(obj=_templates)&&obj.__esModule?obj:{default:obj};_exports.MAX_LENGTH_ALT=750;_exports.bodyImageInsert=async(templateContext,root)=>_templates.default.renderForPromise("tiny_media/insert_image_modal_insert",{...templateContext}).then((_ref=>{let{html:html,js:js}=_ref;_templates.default.replaceNodeContents(root.querySelector(".tiny_image_body_template"),html,js)})).catch((error=>{window.console.log(error)}));_exports.footerImageInsert=async(templateContext,root)=>_templates.default.renderForPromise("tiny_media/insert_image_modal_insert_footer",{...templateContext}).then((_ref2=>{let{html:html,js:js}=_ref2;_templates.default.replaceNodeContents(root.querySelector(".tiny_image_footer_template"),html,js)})).catch((error=>{window.console.log(error)}));_exports.bodyImageDetails=async(templateContext,root)=>_templates.default.renderForPromise("tiny_media/insert_image_modal_details",{...templateContext}).then((_ref3=>{let{html:html,js:js}=_ref3;_templates.default.replaceNodeContents(root.querySelector(".tiny_image_body_template"),html,js)})).catch((error=>{window.console.log(error)}));_exports.footerImageDetails=async(templateContext,root)=>_templates.default.renderForPromise("tiny_media/insert_image_modal_details_footer",{...templateContext}).then((_ref4=>{let{html:html,js:js}=_ref4;_templates.default.replaceNodeContents(root.querySelector(".tiny_image_footer_template"),html,js)})).catch((error=>{window.console.log(error)}));_exports.showElements=(elements,root)=>{if(elements instanceof Array)elements.forEach((elementSelector=>{const element=root.querySelector(elementSelector);element&&element.classList.remove("d-none")}));else{const element=root.querySelector(elements);element&&element.classList.remove("d-none")}};_exports.hideElements=(elements,root)=>{if(elements instanceof Array)elements.forEach((elementSelector=>{const element=root.querySelector(elementSelector);element&&element.classList.add("d-none")}));else{const element=root.querySelector(elements);element&&element.classList.add("d-none")}};_exports.isPercentageValue=value=>value.match(/\d+%/)})); + */(Helpers);_exports.MAX_LENGTH_ALT=750;_exports.bodyImageInsert=async(templateContext,root)=>(window.console.warn("This function is deprecated. Please use core_editor/tiny/plugins/media/helpers.body instead."),templateContext.bodyTemplate="tiny_media/insert_image_modal_insert",templateContext.selector="IMAGE",Helpers.body(templateContext,root));_exports.footerImageInsert=async(templateContext,root)=>(window.console.warn("This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.footer instead."),templateContext.footerTemplate="tiny_media/insert_image_modal_insert_footer",templateContext.selector="IMAGE",Helpers.footer(templateContext,root));_exports.bodyImageDetails=async(templateContext,root)=>(window.console.warn("This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.body instead."),templateContext.bodyTemplate="tiny_media/insert_image_modal_details",templateContext.selector="IMAGE",Helpers.body(templateContext,root));_exports.footerImageDetails=async(templateContext,root)=>(window.console.warn("This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.footer instead."),templateContext.footerTemplate="tiny_media/insert_image_modal_details_footer",templateContext.selector="IMAGE",Helpers.footer(templateContext,root));_exports.showElements=(elements,root)=>{window.console.warn("This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.showElements instead."),Helpers.showElements(elements,root)};_exports.hideElements=(elements,root)=>{window.console.warn("This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.hideElements instead."),Helpers.hideElements(elements,root)};_exports.isPercentageValue=value=>(window.console.warn("This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.isPercentageValue instead."),Helpers.isPercentageValue(value))})); //# sourceMappingURL=imagehelpers.min.js.map \ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js.map b/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js.map index 125e4cdbdc6..7fba91c82bd 100644 --- a/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js.map +++ b/lib/editor/tiny/plugins/media/amd/build/imagehelpers.min.js.map @@ -1 +1 @@ -{"version":3,"file":"imagehelpers.min.js","sources":["../src/imagehelpers.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 image helpers.\n *\n * @module tiny_media/imagehelpers\n * @copyright 2024 Meirza \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Templates from 'core/templates';\n\n/**\n * Maximum length allowed for the alt attribute.\n */\nexport const MAX_LENGTH_ALT = 750;\n\n/**\n * Renders and inserts the body template for inserting an image into the modal.\n *\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n */\nexport const bodyImageInsert = async(templateContext, root) => {\n return Templates.renderForPromise('tiny_media/insert_image_modal_insert', {...templateContext})\n .then(({html, js}) => {\n Templates.replaceNodeContents(root.querySelector('.tiny_image_body_template'), html, js);\n return;\n })\n .catch(error => {\n window.console.log(error);\n });\n};\n\n/**\n * Renders and inserts the footer template for inserting an image into the modal.\n *\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n */\nexport const footerImageInsert = async(templateContext, root) => {\n return Templates.renderForPromise('tiny_media/insert_image_modal_insert_footer', {...templateContext})\n .then(({html, js}) => {\n Templates.replaceNodeContents(root.querySelector('.tiny_image_footer_template'), html, js);\n return;\n })\n .catch(error => {\n window.console.log(error);\n });\n};\n\n/**\n * Renders and inserts the body template for displaying image details in the modal.\n *\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n */\nexport const bodyImageDetails = async(templateContext, root) => {\n return Templates.renderForPromise('tiny_media/insert_image_modal_details', {...templateContext})\n .then(({html, js}) => {\n Templates.replaceNodeContents(root.querySelector('.tiny_image_body_template'), html, js);\n return;\n })\n .catch(error => {\n window.console.log(error);\n });\n};\n\n/**\n * Renders and inserts the footer template for displaying image details in the modal.\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n */\nexport const footerImageDetails = async(templateContext, root) => {\n return Templates.renderForPromise('tiny_media/insert_image_modal_details_footer', {...templateContext})\n .then(({html, js}) => {\n Templates.replaceNodeContents(root.querySelector('.tiny_image_footer_template'), html, js);\n return;\n })\n .catch(error => {\n window.console.log(error);\n });\n};\n\n/**\n * Show the element(s).\n *\n * @param {string|string[]} elements - The CSS selector for the elements to toggle.\n * @param {object} root - The CSS selector for the elements to toggle.\n */\nexport const showElements = (elements, root) => {\n if (elements instanceof Array) {\n elements.forEach((elementSelector) => {\n const element = root.querySelector(elementSelector);\n if (element) {\n element.classList.remove('d-none');\n }\n });\n } else {\n const element = root.querySelector(elements);\n if (element) {\n element.classList.remove('d-none');\n }\n }\n};\n\n/**\n * Hide the element(s).\n *\n * @param {string|string[]} elements - The CSS selector for the elements to toggle.\n * @param {object} root - The CSS selector for the elements to toggle.\n */\nexport const hideElements = (elements, root) => {\n if (elements instanceof Array) {\n elements.forEach((elementSelector) => {\n const element = root.querySelector(elementSelector);\n if (element) {\n element.classList.add('d-none');\n }\n });\n } else {\n const element = root.querySelector(elements);\n if (element) {\n element.classList.add('d-none');\n }\n }\n};\n\n/**\n * Checks if the given value is a percentage value.\n *\n * @param {string} value - The value to check.\n * @returns {boolean} True if the value is a percentage value, false otherwise.\n */\nexport const isPercentageValue = (value) => {\n return value.match(/\\d+%/);\n};\n"],"names":["async","templateContext","root","Templates","renderForPromise","then","_ref","html","js","replaceNodeContents","querySelector","catch","error","window","console","log","_ref2","_ref3","_ref4","elements","Array","forEach","elementSelector","element","classList","remove","add","value","match"],"mappings":";;;;;;;mWA4B8B,6BASCA,MAAMC,gBAAiBC,OAC3CC,mBAAUC,iBAAiB,uCAAwC,IAAIH,kBAC7EI,MAAKC,WAACC,KAACA,KAADC,GAAOA,4BACAC,oBAAoBP,KAAKQ,cAAc,6BAA8BH,KAAMC,OAGxFG,OAAMC,QACHC,OAAOC,QAAQC,IAAIH,qCAWMZ,MAAMC,gBAAiBC,OAC7CC,mBAAUC,iBAAiB,8CAA+C,IAAIH,kBACpFI,MAAKW,YAACT,KAACA,KAADC,GAAOA,6BACAC,oBAAoBP,KAAKQ,cAAc,+BAAgCH,KAAMC,OAG1FG,OAAMC,QACHC,OAAOC,QAAQC,IAAIH,oCAWKZ,MAAMC,gBAAiBC,OAC5CC,mBAAUC,iBAAiB,wCAAyC,IAAIH,kBAC9EI,MAAKY,YAACV,KAACA,KAADC,GAAOA,6BACAC,oBAAoBP,KAAKQ,cAAc,6BAA8BH,KAAMC,OAGxFG,OAAMC,QACHC,OAAOC,QAAQC,IAAIH,sCAUOZ,MAAMC,gBAAiBC,OAC9CC,mBAAUC,iBAAiB,+CAAgD,IAAIH,kBACrFI,MAAKa,YAACX,KAACA,KAADC,GAAOA,6BACAC,oBAAoBP,KAAKQ,cAAc,+BAAgCH,KAAMC,OAG1FG,OAAMC,QACHC,OAAOC,QAAQC,IAAIH,gCAUC,CAACO,SAAUjB,WAC/BiB,oBAAoBC,MACpBD,SAASE,SAASC,wBACRC,QAAUrB,KAAKQ,cAAcY,iBAC/BC,SACAA,QAAQC,UAAUC,OAAO,iBAG9B,OACGF,QAAUrB,KAAKQ,cAAcS,UAC/BI,SACAA,QAAQC,UAAUC,OAAO,kCAWT,CAACN,SAAUjB,WAC/BiB,oBAAoBC,MACpBD,SAASE,SAASC,wBACRC,QAAUrB,KAAKQ,cAAcY,iBAC/BC,SACAA,QAAQC,UAAUE,IAAI,iBAG3B,OACGH,QAAUrB,KAAKQ,cAAcS,UAC/BI,SACAA,QAAQC,UAAUE,IAAI,uCAWAC,OACvBA,MAAMC,MAAM"} \ No newline at end of file +{"version":3,"file":"imagehelpers.min.js","sources":["../src/imagehelpers.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 image helpers.\n *\n * @module tiny_media/imagehelpers\n * @copyright 2024 Meirza \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport * as Helpers from 'tiny_media/helpers';\n\n/**\n * Maximum length allowed for the alt attribute.\n */\nexport const MAX_LENGTH_ALT = 750;\n\n/**\n * Renders and inserts the body template for inserting an image into the modal.\n *\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.body}\n */\nexport const bodyImageInsert = async(templateContext, root) => {\n window.console.warn('This function is deprecated. Please use core_editor/tiny/plugins/media/helpers.body instead.');\n\n templateContext.bodyTemplate = 'tiny_media/insert_image_modal_insert';\n templateContext.selector = 'IMAGE';\n return Helpers.body(templateContext, root);\n};\n\n/**\n * Renders and inserts the footer template for inserting an image into the modal.\n *\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.footer}\n */\nexport const footerImageInsert = async(templateContext, root) => {\n window.console.warn(`This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.footer instead.`);\n\n templateContext.footerTemplate = 'tiny_media/insert_image_modal_insert_footer';\n templateContext.selector = 'IMAGE';\n return Helpers.footer(templateContext, root);\n};\n\n/**\n * Renders and inserts the body template for displaying image details in the modal.\n *\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.body}\n */\nexport const bodyImageDetails = async(templateContext, root) => {\n window.console.warn(`This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.body instead.`);\n\n templateContext.bodyTemplate = 'tiny_media/insert_image_modal_details';\n templateContext.selector = 'IMAGE';\n return Helpers.body(templateContext, root);\n};\n\n/**\n * Renders and inserts the footer template for displaying image details in the modal.\n * @param {object} templateContext - The context for rendering the template.\n * @param {HTMLElement} root - The root element where the template will be inserted.\n * @returns {Promise}\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.footer}\n */\nexport const footerImageDetails = async(templateContext, root) => {\n window.console.warn(`This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.footer instead.`);\n\n templateContext.footerTemplate = 'tiny_media/insert_image_modal_details_footer';\n templateContext.selector = 'IMAGE';\n return Helpers.footer(templateContext, root);\n};\n\n/**\n * Show the element(s).\n *\n * @param {string|string[]} elements - The CSS selector for the elements to toggle.\n * @param {object} root - The CSS selector for the elements to toggle.\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.showElements}\n */\nexport const showElements = (elements, root) => {\n window.console.warn(`This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.showElements instead.`);\n Helpers.showElements(elements, root);\n};\n\n/**\n * Hide the element(s).\n *\n * @param {string|string[]} elements - The CSS selector for the elements to toggle.\n * @param {object} root - The CSS selector for the elements to toggle.\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.hideElements}\n */\nexport const hideElements = (elements, root) => {\n window.console.warn(`This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.hideElements instead.`);\n Helpers.hideElements(elements, root);\n};\n\n/**\n * Checks if the given value is a percentage value.\n *\n * @param {string} value - The value to check.\n * @returns {boolean} True if the value is a percentage value, false otherwise.\n * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.isPercentageValue}\n */\nexport const isPercentageValue = (value) => {\n window.console.warn(`This function is deprecated.\n Please use core_editor/tiny/plugins/media/helpers.isPercentageValue instead.`);\n return Helpers.isPercentageValue(value);\n};\n"],"names":["async","templateContext","root","window","console","warn","bodyTemplate","selector","Helpers","body","footerTemplate","footer","elements","showElements","hideElements","value","isPercentageValue"],"mappings":";;;;;;;uCA4B8B,6BAUCA,MAAMC,gBAAiBC,QAClDC,OAAOC,QAAQC,KAAK,gGAEpBJ,gBAAgBK,aAAe,uCAC/BL,gBAAgBM,SAAW,QACpBC,QAAQC,KAAKR,gBAAiBC,kCAWRF,MAAMC,gBAAiBC,QACpDC,OAAOC,QAAQC,gHAGfJ,gBAAgBS,eAAiB,8CACjCT,gBAAgBM,SAAW,QACpBC,QAAQG,OAAOV,gBAAiBC,iCAWXF,MAAMC,gBAAiBC,QACnDC,OAAOC,QAAQC,8GAGfJ,gBAAgBK,aAAe,wCAC/BL,gBAAgBM,SAAW,QACpBC,QAAQC,KAAKR,gBAAiBC,mCAUPF,MAAMC,gBAAiBC,QACrDC,OAAOC,QAAQC,gHAGfJ,gBAAgBS,eAAiB,+CACjCT,gBAAgBM,SAAW,QACpBC,QAAQG,OAAOV,gBAAiBC,6BAUf,CAACU,SAAUV,QACnCC,OAAOC,QAAQC,sHAEfG,QAAQK,aAAaD,SAAUV,6BAUP,CAACU,SAAUV,QACnCC,OAAOC,QAAQC,sHAEfG,QAAQM,aAAaF,SAAUV,kCAUDa,QAC9BZ,OAAOC,QAAQC,2HAERG,QAAQQ,kBAAkBD"} \ No newline at end of file diff --git a/lib/editor/tiny/plugins/media/amd/src/imagehelpers.js b/lib/editor/tiny/plugins/media/amd/src/imagehelpers.js index 781c38ddc5e..e6fa0adf0d0 100644 --- a/lib/editor/tiny/plugins/media/amd/src/imagehelpers.js +++ b/lib/editor/tiny/plugins/media/amd/src/imagehelpers.js @@ -21,7 +21,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -import Templates from 'core/templates'; +import * as Helpers from 'tiny_media/helpers'; /** * Maximum length allowed for the alt attribute. @@ -34,16 +34,14 @@ export const MAX_LENGTH_ALT = 750; * @param {object} templateContext - The context for rendering the template. * @param {HTMLElement} root - The root element where the template will be inserted. * @returns {Promise} + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.body} */ export const bodyImageInsert = async(templateContext, root) => { - return Templates.renderForPromise('tiny_media/insert_image_modal_insert', {...templateContext}) - .then(({html, js}) => { - Templates.replaceNodeContents(root.querySelector('.tiny_image_body_template'), html, js); - return; - }) - .catch(error => { - window.console.log(error); - }); + window.console.warn('This function is deprecated. Please use core_editor/tiny/plugins/media/helpers.body instead.'); + + templateContext.bodyTemplate = 'tiny_media/insert_image_modal_insert'; + templateContext.selector = 'IMAGE'; + return Helpers.body(templateContext, root); }; /** @@ -52,16 +50,15 @@ export const bodyImageInsert = async(templateContext, root) => { * @param {object} templateContext - The context for rendering the template. * @param {HTMLElement} root - The root element where the template will be inserted. * @returns {Promise} + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.footer} */ export const footerImageInsert = async(templateContext, root) => { - return Templates.renderForPromise('tiny_media/insert_image_modal_insert_footer', {...templateContext}) - .then(({html, js}) => { - Templates.replaceNodeContents(root.querySelector('.tiny_image_footer_template'), html, js); - return; - }) - .catch(error => { - window.console.log(error); - }); + window.console.warn(`This function is deprecated. + Please use core_editor/tiny/plugins/media/helpers.footer instead.`); + + templateContext.footerTemplate = 'tiny_media/insert_image_modal_insert_footer'; + templateContext.selector = 'IMAGE'; + return Helpers.footer(templateContext, root); }; /** @@ -70,16 +67,15 @@ export const footerImageInsert = async(templateContext, root) => { * @param {object} templateContext - The context for rendering the template. * @param {HTMLElement} root - The root element where the template will be inserted. * @returns {Promise} + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.body} */ export const bodyImageDetails = async(templateContext, root) => { - return Templates.renderForPromise('tiny_media/insert_image_modal_details', {...templateContext}) - .then(({html, js}) => { - Templates.replaceNodeContents(root.querySelector('.tiny_image_body_template'), html, js); - return; - }) - .catch(error => { - window.console.log(error); - }); + window.console.warn(`This function is deprecated. + Please use core_editor/tiny/plugins/media/helpers.body instead.`); + + templateContext.bodyTemplate = 'tiny_media/insert_image_modal_details'; + templateContext.selector = 'IMAGE'; + return Helpers.body(templateContext, root); }; /** @@ -87,16 +83,15 @@ export const bodyImageDetails = async(templateContext, root) => { * @param {object} templateContext - The context for rendering the template. * @param {HTMLElement} root - The root element where the template will be inserted. * @returns {Promise} + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.footer} */ export const footerImageDetails = async(templateContext, root) => { - return Templates.renderForPromise('tiny_media/insert_image_modal_details_footer', {...templateContext}) - .then(({html, js}) => { - Templates.replaceNodeContents(root.querySelector('.tiny_image_footer_template'), html, js); - return; - }) - .catch(error => { - window.console.log(error); - }); + window.console.warn(`This function is deprecated. + Please use core_editor/tiny/plugins/media/helpers.footer instead.`); + + templateContext.footerTemplate = 'tiny_media/insert_image_modal_details_footer'; + templateContext.selector = 'IMAGE'; + return Helpers.footer(templateContext, root); }; /** @@ -104,21 +99,12 @@ export const footerImageDetails = async(templateContext, root) => { * * @param {string|string[]} elements - The CSS selector for the elements to toggle. * @param {object} root - The CSS selector for the elements to toggle. + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.showElements} */ export const showElements = (elements, root) => { - if (elements instanceof Array) { - elements.forEach((elementSelector) => { - const element = root.querySelector(elementSelector); - if (element) { - element.classList.remove('d-none'); - } - }); - } else { - const element = root.querySelector(elements); - if (element) { - element.classList.remove('d-none'); - } - } + window.console.warn(`This function is deprecated. + Please use core_editor/tiny/plugins/media/helpers.showElements instead.`); + Helpers.showElements(elements, root); }; /** @@ -126,21 +112,12 @@ export const showElements = (elements, root) => { * * @param {string|string[]} elements - The CSS selector for the elements to toggle. * @param {object} root - The CSS selector for the elements to toggle. + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.hideElements} */ export const hideElements = (elements, root) => { - if (elements instanceof Array) { - elements.forEach((elementSelector) => { - const element = root.querySelector(elementSelector); - if (element) { - element.classList.add('d-none'); - } - }); - } else { - const element = root.querySelector(elements); - if (element) { - element.classList.add('d-none'); - } - } + window.console.warn(`This function is deprecated. + Please use core_editor/tiny/plugins/media/helpers.hideElements instead.`); + Helpers.hideElements(elements, root); }; /** @@ -148,7 +125,10 @@ export const hideElements = (elements, root) => { * * @param {string} value - The value to check. * @returns {boolean} True if the value is a percentage value, false otherwise. + * @deprecated Since Moodle 4.5 See {@link module:core_editor/tiny/plugins/media/helpers.isPercentageValue} */ export const isPercentageValue = (value) => { - return value.match(/\d+%/); + window.console.warn(`This function is deprecated. + Please use core_editor/tiny/plugins/media/helpers.isPercentageValue instead.`); + return Helpers.isPercentageValue(value); };