diff --git a/amd/build/embed.min.js b/amd/build/embed.min.js index 71ff74b..eeec346 100644 --- a/amd/build/embed.min.js +++ b/amd/build/embed.min.js @@ -1,10 +1,3 @@ -define("tiny_sketch/embed",["exports","core/str","core/modal_events","core/templates","core/modal_factory","core/config"],(function(_exports,_str,ModalEvents,_templates,Modal,_config){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default: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 _interopRequireWildcard(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]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj} -/** - * Tiny Sketch plugin Embed class for Moodle. - * - * @module tiny_sketch/embed - * @copyright 2023 Matt Davidson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.SketchEmbed=void 0,ModalEvents=_interopRequireWildcard(ModalEvents),_templates=_interopRequireDefault(_templates),Modal=_interopRequireWildcard(Modal),_config=_interopRequireDefault(_config);_exports.SketchEmbed=class{editor=null;canShowFilePicker=!1;helpStrings=null;isUpdating=!1;constructor(editor){this.editor=editor}async displayDialogue(){Modal.create({type:Modal.types.DEFAULT,title:(0,_str.get_string)("sketchtitle","tiny_sketch"),body:_templates.default.render("tiny_sketch/sketch_iframe",{src:this.getIframeURL()})}).then((modal=>(modal.getRoot().on(ModalEvents.hidden,(()=>{modal.destroy()})),modal.show(),document.querySelector(".modal-dialog").style.cssText="max-width: unset;width:100%;height:100vh;margin:0;padding:0;",document.querySelector(".modal-content").style.cssText="max-height: unset;height:100vh;",document.querySelector(".modal-body").style.cssText="padding:0",modal))).catch()}getIframeURL=()=>new URL(`${_config.default.wwwroot}/lib/editor/tiny/plugins/sketch/miniPaint/sketch.html`).toString()}})); +define("tiny_sketch/embed",["exports","core/str","core/modal_events","core/templates","core/modal_factory","core/config"],(function(_exports,_str,ModalEvents,_templates,Modal,_config){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default: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 _interopRequireWildcard(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]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}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.SketchEmbed=void 0,ModalEvents=_interopRequireWildcard(ModalEvents),_templates=_interopRequireDefault(_templates),Modal=_interopRequireWildcard(Modal),_config=_interopRequireDefault(_config);_exports.SketchEmbed=class{constructor(editor){_defineProperty(this,"editor",null),_defineProperty(this,"canShowFilePicker",!1),_defineProperty(this,"helpStrings",null),_defineProperty(this,"isUpdating",!1),_defineProperty(this,"getIframeURL",(()=>new URL("".concat(_config.default.wwwroot,"/lib/editor/tiny/plugins/sketch/miniPaint/sketch.html")).toString())),this.editor=editor}async displayDialogue(){Modal.create({type:Modal.types.DEFAULT,title:(0,_str.get_string)("sketchtitle","tiny_sketch"),body:_templates.default.render("tiny_sketch/sketch_iframe",{src:this.getIframeURL()})}).then((modal=>(modal.getRoot().on(ModalEvents.hidden,(()=>{modal.destroy()})),modal.getRoot().on(ModalEvents.shown,(()=>{const modalElement=modal.getRoot().get(0),dialog=modalElement.querySelector(".modal-dialog"),content=modalElement.querySelector(".modal-content"),body=modalElement.querySelector(".modal-body");dialog.style.cssText="max-width: unset;width:100%;height:100vh;margin:0;padding:0;",content.style.cssText="max-height: unset;height:100vh;",body.style.cssText="padding:0"})),modal.show(),modal))).catch()}}})); //# sourceMappingURL=embed.min.js.map \ No newline at end of file diff --git a/amd/build/embed.min.js.map b/amd/build/embed.min.js.map index d8d76b2..4d92c9e 100644 --- a/amd/build/embed.min.js.map +++ b/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 Sketch plugin Embed class for Moodle.\n *\n * @module tiny_sketch/embed\n * @copyright 2023 Matt Davidson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport * as ModalEvents from 'core/modal_events';\nimport Templates from 'core/templates';\nimport * as Modal from 'core/modal_factory';\nimport Config from 'core/config';\n\nexport const SketchEmbed = class {\n editor = null;\n canShowFilePicker = 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 constructor(editor) {\n this.editor = editor;\n }\n\n async displayDialogue() {\n Modal.create({\n type: Modal.types.DEFAULT,\n title: getString('sketchtitle', 'tiny_sketch'),\n body: Templates.render('tiny_sketch/sketch_iframe', {\n src: this.getIframeURL()\n })\n }).then(modal => {\n modal.getRoot().on(ModalEvents.hidden, () => {\n modal.destroy();\n });\n modal.show();\n document.querySelector('.modal-dialog').style.cssText = \"max-width: unset;width:100%;height:100vh;margin:0;padding:0;\";\n document.querySelector('.modal-content').style.cssText = \"max-height: unset;height:100vh;\";\n document.querySelector('.modal-body').style.cssText = \"padding:0\";\n return modal;\n }).catch();\n }\n\n getIframeURL = () => {\n const url = new URL(`${Config.wwwroot}/lib/editor/tiny/plugins/sketch/miniPaint/sketch.html`);\n return url.toString();\n };\n};\n"],"names":["editor","canShowFilePicker","helpStrings","isUpdating","constructor","Modal","create","type","types","DEFAULT","title","body","Templates","render","src","this","getIframeURL","then","modal","getRoot","on","ModalEvents","hidden","destroy","show","document","querySelector","style","cssText","catch","URL","Config","wwwroot","toString"],"mappings":";;;;;;;0RA6B2B,MACvBA,OAAS,KACTC,mBAAoB,EAKpBC,YAAc,KAKdC,YAAa,EAEbC,YAAYJ,aACHA,OAASA,+BAIdK,MAAMC,OAAO,CACTC,KAAMF,MAAMG,MAAMC,QAClBC,OAAO,mBAAU,cAAe,eAChCC,KAAMC,mBAAUC,OAAO,4BAA6B,CAChDC,IAAKC,KAAKC,mBAEfC,MAAKC,QACJA,MAAMC,UAAUC,GAAGC,YAAYC,QAAQ,KACnCJ,MAAMK,aAEVL,MAAMM,OACNC,SAASC,cAAc,iBAAiBC,MAAMC,QAAU,+DACxDH,SAASC,cAAc,kBAAkBC,MAAMC,QAAU,kCACzDH,SAASC,cAAc,eAAeC,MAAMC,QAAU,YAC/CV,SACRW,QAGPb,aAAe,IACC,IAAIc,IAAK,GAAEC,gBAAOC,gEACnBC"} \ 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 Sketch plugin Embed class for Moodle.\n *\n * @module tiny_sketch/embed\n * @copyright 2023 Matt Davidson \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {get_string as getString} from 'core/str';\nimport * as ModalEvents from 'core/modal_events';\nimport Templates from 'core/templates';\nimport * as Modal from 'core/modal_factory';\nimport Config from 'core/config';\n\nexport const SketchEmbed = class {\n editor = null;\n canShowFilePicker = 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 constructor(editor) {\n this.editor = editor;\n }\n\n async displayDialogue() {\n Modal.create({\n type: Modal.types.DEFAULT,\n title: getString('sketchtitle', 'tiny_sketch'),\n body: Templates.render('tiny_sketch/sketch_iframe', {\n src: this.getIframeURL()\n })\n }).then(modal => {\n modal.getRoot().on(ModalEvents.hidden, () => {\n modal.destroy();\n });\n\n modal.getRoot().on(ModalEvents.shown, () => {\n const modalElement = modal.getRoot().get(0);\n const dialog = modalElement.querySelector('.modal-dialog');\n const content = modalElement.querySelector('.modal-content');\n const body = modalElement.querySelector('.modal-body');\n\n dialog.style.cssText = \"max-width: unset;width:100%;height:100vh;margin:0;padding:0;\";\n content.style.cssText = \"max-height: unset;height:100vh;\";\n body.style.cssText = \"padding:0\";\n });\n modal.show();\n return modal;\n }).catch();\n }\n\n getIframeURL = () => {\n const url = new URL(`${Config.wwwroot}/lib/editor/tiny/plugins/sketch/miniPaint/sketch.html`);\n return url.toString();\n };\n};\n"],"names":["constructor","editor","URL","Config","wwwroot","toString","Modal","create","type","types","DEFAULT","title","body","Templates","render","src","this","getIframeURL","then","modal","getRoot","on","ModalEvents","hidden","destroy","shown","modalElement","get","dialog","querySelector","content","style","cssText","show","catch"],"mappings":"0nDA6B2B,MAcvBA,YAAYC,sCAbH,gDACW,sCAKN,yCAKD,wCAiCE,IACC,IAAIC,cAAOC,gBAAOC,kEACnBC,kBAhCNJ,OAASA,+BAIdK,MAAMC,OAAO,CACTC,KAAMF,MAAMG,MAAMC,QAClBC,OAAO,mBAAU,cAAe,eAChCC,KAAMC,mBAAUC,OAAO,4BAA6B,CAChDC,IAAKC,KAAKC,mBAEfC,MAAKC,QACJA,MAAMC,UAAUC,GAAGC,YAAYC,QAAQ,KACnCJ,MAAMK,aAGVL,MAAMC,UAAUC,GAAGC,YAAYG,OAAO,WAC5BC,aAAeP,MAAMC,UAAUO,IAAI,GACnCC,OAASF,aAAaG,cAAc,iBACpCC,QAAUJ,aAAaG,cAAc,kBACrCjB,KAAOc,aAAaG,cAAc,eAExCD,OAAOG,MAAMC,QAAU,+DACvBF,QAAQC,MAAMC,QAAU,kCACxBpB,KAAKmB,MAAMC,QAAU,eAEzBb,MAAMc,OACCd,SACRe"} \ No newline at end of file diff --git a/amd/src/embed.js b/amd/src/embed.js index 17bf898..bc41d69 100644 --- a/amd/src/embed.js +++ b/amd/src/embed.js @@ -56,10 +56,18 @@ export const SketchEmbed = class { modal.getRoot().on(ModalEvents.hidden, () => { modal.destroy(); }); + + modal.getRoot().on(ModalEvents.shown, () => { + const modalElement = modal.getRoot().get(0); + const dialog = modalElement.querySelector('.modal-dialog'); + const content = modalElement.querySelector('.modal-content'); + const body = modalElement.querySelector('.modal-body'); + + dialog.style.cssText = "max-width: unset;width:100%;height:100vh;margin:0;padding:0;"; + content.style.cssText = "max-height: unset;height:100vh;"; + body.style.cssText = "padding:0"; + }); modal.show(); - document.querySelector('.modal-dialog').style.cssText = "max-width: unset;width:100%;height:100vh;margin:0;padding:0;"; - document.querySelector('.modal-content').style.cssText = "max-height: unset;height:100vh;"; - document.querySelector('.modal-body').style.cssText = "padding:0"; return modal; }).catch(); }