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 <[email protected]>
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -48,6 +48,11 @@ export default class MediaEmbed {
|
||||
*/
|
||||
isUpdating = false;
|
||||
|
||||
/**
|
||||
* @property {Object} The currently selected media.
|
||||
*/
|
||||
selectedMedia = null;
|
||||
|
||||
constructor(editor) {
|
||||
const permissions = getEmbedPermissions(editor);
|
||||
this.canShowFilePicker = permissions.filepicker;
|
||||
@@ -95,6 +100,7 @@ export default class MediaEmbed {
|
||||
}
|
||||
|
||||
async displayDialogue() {
|
||||
this.selectedMedia = this.getSelectedMedia();
|
||||
const data = Object.assign({}, this.getCurrentEmbedData());
|
||||
this.isUpdating = Object.keys(data).length !== 0;
|
||||
|
||||
@@ -157,7 +163,7 @@ export default class MediaEmbed {
|
||||
};
|
||||
const sources = [];
|
||||
|
||||
const medium = this.getSelectedMedia();
|
||||
const medium = this.selectedMedia;
|
||||
if (!medium) {
|
||||
return null;
|
||||
}
|
||||
@@ -419,8 +425,7 @@ export default class MediaEmbed {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user