Merge branch 'MDL-79501-MOODLE_401_STABLE' of https://github.com/geichelberger/moodle into MOODLE_401_STABLE

This commit is contained in:
Ilya Tregubov 2023-10-10 15:07:24 +08:00
commit 11fe89c08e
No known key found for this signature in database
GPG Key ID: 0F58186F748E55C1
3 changed files with 10 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,11 @@ export const MediaEmbed = class {
*/
isUpdating = false;
/**
* @property {Object} The currently selected media.
*/
selectedMedia = null;
constructor(editor) {
const permissions = getEmbedPermissions(editor);
this.canShowFilePicker = permissions.filepicker;
@ -96,6 +101,7 @@ export const MediaEmbed = class {
}
async displayDialogue() {
this.selectedMedia = this.getSelectedMedia();
const data = Object.assign({}, this.getCurrentEmbedData());
this.isUpdating = Object.keys(data).length !== 0;
@ -163,7 +169,7 @@ export const MediaEmbed = class {
};
const sources = [];
const medium = this.getSelectedMedia();
const medium = this.selectedMedia;
if (!medium) {
return null;
}
@ -425,8 +431,7 @@ export const MediaEmbed = class {
const {html} = await this.getMediaHTML(modal.getRoot()[0]);
if (html) {
if (this.isUpdating) {
const selectedNode = this.getSelectedMedia();
selectedNode.outerHTML = html;
this.selectedMedia.outerHTML = html;
this.isUpdating = false;
} else {
this.editor.insertContent(html);