%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/ava/lib/editor/tiny/amd/build/
Upload File :
Create Path :
Current File : /home/vacivi36/ava/lib/editor/tiny/amd/build/uploader.min.js.map

{"version":3,"file":"uploader.min.js","sources":["../src/uploader.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Tiny Media plugin for Moodle.\n *\n * @module      editor_tiny/uploade\n * @copyright   2022 Andrew Lyons <andrew@nicols.co.uk>\n * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {\n    notifyUploadStarted,\n    notifyUploadCompleted,\n} from 'core_form/events';\nimport {getFilePicker} from 'editor_tiny/options';\n\n// This image uploader is based on advice given at:\n// https://www.tiny.cloud/docs/tinymce/6/upload-images/\nexport default (editor, filePickerType, blob, fileName, progress) => new Promise((resolve, reject) => {\n    notifyUploadStarted(editor.targetElm.id);\n\n    const xhr = new XMLHttpRequest();\n\n    // Add the progress handler.\n    xhr.upload.addEventListener('progress', (e) => {\n        progress(e.loaded / e.total * 100);\n    });\n\n    xhr.addEventListener('load', () => {\n        if (xhr.status === 403) {\n            reject({\n                message: `HTTP error: ${xhr.status}`,\n                remove: true,\n            });\n            return;\n        }\n\n        if (xhr.status < 200 || xhr.status >= 300) {\n            reject(`HTTP Error: ${xhr.status}`);\n            return;\n        }\n\n        const response = JSON.parse(xhr.responseText);\n\n        if (!response) {\n            reject(`Invalid JSON: ${xhr.responseText}`);\n            return;\n        }\n\n        notifyUploadCompleted(editor.targetElm.id);\n\n        let location;\n        if (response.url) {\n            location = response.url;\n        } else if (response.event && response.event === 'fileexists' && response.newfile) {\n            // A file with this name is already in use here - rename to avoid conflict.\n            // Chances are, it's a different image (stored in a different folder on the user's computer).\n            // If the user wants to reuse an existing image, they can copy/paste it within the editor.\n            location = response.newfile.url;\n        }\n\n        if (location && typeof location === 'string') {\n            resolve(location);\n            return;\n        }\n\n        reject(`Unable to handle file result: ${xhr.responseText}`);\n    });\n\n    xhr.addEventListener('error', () => {\n        reject({\n            message: `Upload failed due to an XHR transport error. Code: ${xhr.status}`,\n            remove: true,\n        });\n    });\n\n    const formData = new FormData();\n    const options = getFilePicker(editor, filePickerType);\n\n    formData.append('repo_upload_file', blob, fileName);\n    formData.append('itemid', options.itemid);\n    Object.values(options.repositories).some((repository) => {\n        if (repository.type === 'upload') {\n            formData.append('repo_id', repository.id);\n            return true;\n        }\n        return false;\n    });\n\n    formData.append('env', options.env);\n    formData.append('sesskey', M.cfg.sesskey);\n    formData.append('client_id', options.client_id);\n    formData.append('savepath', options.savepath ?? '/');\n    formData.append('ctx_id', options.context.id);\n\n    xhr.open('POST', `${M.cfg.wwwroot}/repository/repository_ajax.php?action=upload`, true);\n    xhr.send(formData);\n});\n"],"names":["editor","filePickerType","blob","fileName","progress","Promise","resolve","reject","targetElm","id","xhr","XMLHttpRequest","upload","addEventListener","e","loaded","total","status","message","remove","response","JSON","parse","responseText","location","url","event","newfile","formData","FormData","options","append","itemid","Object","values","repositories","some","repository","type","env","M","cfg","sesskey","client_id","savepath","context","open","wwwroot","send"],"mappings":"gOA8Be,CAACA,OAAQC,eAAgBC,KAAMC,SAAUC,WAAa,IAAIC,SAAQ,CAACC,QAASC,gEACnEP,OAAOQ,UAAUC,UAE/BC,IAAM,IAAIC,eAGhBD,IAAIE,OAAOC,iBAAiB,YAAaC,IACrCV,SAASU,EAAEC,OAASD,EAAEE,MAAQ,QAGlCN,IAAIG,iBAAiB,QAAQ,QACN,MAAfH,IAAIO,mBACJ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