mirror of
https://github.com/moodle/moodle.git
synced 2025-03-19 23:20:09 +01:00
MDL-79501 tiny: Fix editing multiple videos
The selection gets lost while opening the modal dialogue to update an embedded media. Caching the current selection allows us to update the previously selected node instead of updating the first embedded media. Signed-off-by: Gregor Eichelberger <gregor.eichelberger@tuwien.ac.at>
This commit is contained in:
parent
b660e6979a
commit
0b28c6a254
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user