Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 49daab0

Browse files
committed
multiple editor image toolbar action effects all instances bugfix
1 parent 42c7d1a commit 49daab0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/js/images.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
function Images (el, options) {
9090
this.el = el;
9191
this.$el = $(el);
92+
this.$currentImage = null;
9293
this.templates = window.MediumInsert.Templates;
9394
this.core = this.$el.data('plugin_'+ pluginName);
9495

@@ -427,6 +428,8 @@
427428
var $image = $(e.target),
428429
that = this;
429430

431+
this.$currentImage = $image;
432+
430433
// Hide keyboard on mobile devices
431434
this.$el.blur();
432435

@@ -469,6 +472,7 @@
469472
} else if ($el.is('figcaption') === false) {
470473
this.core.removeCaptions();
471474
}
475+
this.$currentImage = null;
472476
};
473477

474478
/**
@@ -595,6 +599,7 @@
595599
*/
596600

597601
Images.prototype.toolbarAction = function (e) {
602+
if (this.$currentImage === null) return;
598603
var $button = $(e.target).is('button') ? $(e.target) : $(e.target).closest('button'),
599604
$li = $button.closest('li'),
600605
$ul = $li.closest('ul'),
@@ -636,6 +641,7 @@
636641
*/
637642

638643
Images.prototype.toolbar2Action = function (e) {
644+
if (this.$currentImage === null) return;
639645
var $button = $(e.target).is('button') ? $(e.target) : $(e.target).closest('button'),
640646
callback = this.options.actions[$button.data('action')].clicked;
641647

0 commit comments

Comments
 (0)