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

Commit 947bfef

Browse files
committed
v2.2.1
1 parent d964f57 commit 947bfef

9 files changed

+35
-24
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
2.2.1 / 2016-02-05
3+
==================
4+
5+
* Fix when `uploadCompleted()` is called - wait until uploaded image replaces preview
6+
* Fix uploading high quality images
7+
* Fix bug when an image toolbar action effects all instances of the editor (when using multiple editors on the same page)
8+
29
2.2.0 / 2016-01-11
310
==================
411

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "medium-editor-insert-plugin",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "jQuery insert plugin for MediumEditor",
55
"main": [
66
"dist/js/medium-editor-insert-plugin.js",

dist/css/medium-editor-insert-plugin-frontend.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* medium-editor-insert-plugin v2.2.0 - jQuery insert plugin for MediumEditor
2+
* medium-editor-insert-plugin v2.2.1 - jQuery insert plugin for MediumEditor
33
*
44
* https://github.com/orthes/medium-editor-insert-plugin
55
*

dist/css/medium-editor-insert-plugin-frontend.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/css/medium-editor-insert-plugin.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* medium-editor-insert-plugin v2.2.0 - jQuery insert plugin for MediumEditor
2+
* medium-editor-insert-plugin v2.2.1 - jQuery insert plugin for MediumEditor
33
*
44
* https://github.com/orthes/medium-editor-insert-plugin
55
*

dist/css/medium-editor-insert-plugin.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/medium-editor-insert-plugin.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* medium-editor-insert-plugin v2.2.0 - jQuery insert plugin for MediumEditor
2+
* medium-editor-insert-plugin v2.2.1 - jQuery insert plugin for MediumEditor
33
*
44
* https://github.com/orthes/medium-editor-insert-plugin
55
*
@@ -315,15 +315,10 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
315315
*/
316316

317317
Core.prototype.editorUpdatePlaceholder = function (el) {
318-
var $clone = $(el).clone(),
319-
cloneHtml;
318+
var contents = $(el).children()
319+
.not('.medium-insert-buttons').contents();
320320

321-
$clone.find('.medium-insert-buttons').remove();
322-
cloneHtml = $clone.html()
323-
.replace(/^\s+|\s+$/g, '')
324-
.replace(/^<p( class="medium-insert-active")?><br><\/p>$/, '');
325-
326-
if (!(el.querySelector('img, blockquote')) && cloneHtml === '') {
321+
if (contents.length === 1 && contents[0].nodeName.toLowerCase() === 'br') {
327322
this.showPlaceholder(el);
328323
this.base._hideInsertButtons($(el));
329324
} else {
@@ -1484,6 +1479,7 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
14841479
function Images (el, options) {
14851480
this.el = el;
14861481
this.$el = $(el);
1482+
this.$currentImage = null;
14871483
this.templates = window.MediumInsert.Templates;
14881484
this.core = this.$el.data('plugin_'+ pluginName);
14891485

@@ -1735,14 +1731,10 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
17351731
*/
17361732

17371733
Images.prototype.uploadDone = function (e, data) {
1738-
var $el = $.proxy(this, 'showImage', data.result.files[0].url, data)();
1734+
$.proxy(this, 'showImage', data.result.files[0].url, data)();
17391735

17401736
this.core.clean();
17411737
this.sorting();
1742-
1743-
if (this.options.uploadCompleted) {
1744-
this.options.uploadCompleted($el, data);
1745-
}
17461738
};
17471739

17481740
/**
@@ -1767,8 +1759,13 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
17671759
domImage = this.getDOMImage();
17681760
domImage.onload = function () {
17691761
data.context.find('img').attr('src', domImage.src);
1762+
1763+
if (this.options.uploadCompleted) {
1764+
this.options.uploadCompleted(data.context, data);
1765+
}
1766+
17701767
that.core.triggerInput();
1771-
};
1768+
}.bind(this);
17721769
domImage.src = img;
17731770
} else {
17741771
data.context = $(this.templates['src/js/templates/images-image.hbs']({
@@ -1798,6 +1795,8 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
17981795

17991796
if (this.options.preview) {
18001797
data.submit();
1798+
} else if (this.options.uploadCompleted) {
1799+
this.options.uploadCompleted(data.context, data);
18011800
}
18021801
}
18031802

@@ -1822,6 +1821,8 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
18221821
var $image = $(e.target),
18231822
that = this;
18241823

1824+
this.$currentImage = $image;
1825+
18251826
// Hide keyboard on mobile devices
18261827
this.$el.blur();
18271828

@@ -1864,6 +1865,7 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
18641865
} else if ($el.is('figcaption') === false) {
18651866
this.core.removeCaptions();
18661867
}
1868+
this.$currentImage = null;
18671869
};
18681870

18691871
/**
@@ -1990,6 +1992,7 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
19901992
*/
19911993

19921994
Images.prototype.toolbarAction = function (e) {
1995+
if (this.$currentImage === null) return;
19931996
var $button = $(e.target).is('button') ? $(e.target) : $(e.target).closest('button'),
19941997
$li = $button.closest('li'),
19951998
$ul = $li.closest('ul'),
@@ -2031,6 +2034,7 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
20312034
*/
20322035

20332036
Images.prototype.toolbar2Action = function (e) {
2037+
if (this.$currentImage === null) return;
20342038
var $button = $(e.target).is('button') ? $(e.target) : $(e.target).closest('button'),
20352039
callback = this.options.actions[$button.data('action')].clicked;
20362040

dist/js/medium-editor-insert-plugin.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "medium-editor-insert-plugin",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "jQuery insert plugin for MediumEditor",
55
"license": "MIT",
66
"homepage": "https://github.com/orthes/medium-editor-insert-plugin",

0 commit comments

Comments
 (0)