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

Commit f3ce5de

Browse files
committed
build dist files
2 parents 0b44972 + cfa252e commit f3ce5de

File tree

5 files changed

+89
-5
lines changed

5 files changed

+89
-5
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ this["MediumInsert"]["Templates"]["src/js/templates/core-buttons.hbs"] = Handleb
4242

4343
return " <li><button data-addon=\""
4444
+ container.escapeExpression(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper)))
45-
+ "\" data-action=\"add\" class=\"medium-insert-action\">"
45+
+ "\" data-action=\"add\" class=\"medium-insert-action\" type=\"button\">"
4646
+ ((stack1 = ((helper = (helper = helpers.label || (depth0 != null ? depth0.label : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"label","hash":{},"data":data}) : helper))) != null ? stack1 : "")
4747
+ "</button></li>\n";
4848
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
4949
var stack1;
5050

51-
return "<div class=\"medium-insert-buttons\" contenteditable=\"false\" style=\"display: none\">\n <button class=\"medium-insert-buttons-show\"><span>+</span></button>\n <ul class=\"medium-insert-buttons-addons\" style=\"display: none\">\n"
51+
return "<div class=\"medium-insert-buttons\" contenteditable=\"false\" style=\"display: none\">\n <button class=\"medium-insert-buttons-show\" type=\"button\"><span>+</span></button>\n <ul class=\"medium-insert-buttons-addons\" style=\"display: none\">\n"
5252
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.addons : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
5353
+ " </ul>\n</div>\n";
5454
},"useData":true});
@@ -833,6 +833,7 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
833833
oembedProxy: 'http://medium.iframe.ly/api/oembed?iframe=1',
834834
captions: true,
835835
captionPlaceholder: 'Type caption (optional)',
836+
storeMeta: false,
836837
styles: {
837838
wide: {
838839
label: '<span class="fa fa-align-justify"></span>'
@@ -1153,6 +1154,10 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
11531154
success: function (data) {
11541155
var html = data && data.html;
11551156

1157+
if (that.options.storeMeta) {
1158+
html += '<div class="medium-insert-embeds-meta"><script type="text/json">' + JSON.stringify(data) + '</script></div>';
1159+
}
1160+
11561161
if (data && !html && data.type === 'photo' && data.url) {
11571162
html = '<img src="' + data.url + '" alt="">';
11581163
}
@@ -1210,6 +1215,10 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
12101215
.replace(/^(https:\/\/www\.facebook\.com\/(.*))$/, '<script src="//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.2" async></script><div class="fb-post" data-href="$1"><div class="fb-xfbml-parse-ignore"><a href="$1">Loading Facebook post...</a></div></div>')
12111216
.replace(/^https?:\/\/instagram\.com\/p\/(.+)\/?$/, '<span class="instagram"><iframe src="//instagram.com/p/$1/embed/" width="612" height="710" frameborder="0" scrolling="no" allowtransparency="true"></iframe></span>');
12121217

1218+
if (this.options.storeMeta) {
1219+
html += '<div class="medium-insert-embeds-meta"><script type="text/json">' + JSON.stringify({}) + '</script></div>';
1220+
}
1221+
12131222
if ((/<("[^"]*"|'[^']*'|[^'">])*>/).test(html) === false) {
12141223
$.proxy(this, 'convertBadEmbed', url)();
12151224
return false;

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

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

spec/embeds.spec.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,5 +436,71 @@ describe('Embeds addon', function () {
436436
expect($serialized.find('[data-embed-code]').html()).toEqual('<div>good-value</div>');
437437
});
438438

439+
it('does include meta when storeMeta is set', function () {
440+
var $event = $.Event('keydown');
441+
442+
$event.which = 13;
443+
$('#fixtures').html('<div class="editable"><p class="medium-insert-embeds-input medium-insert-embeds-active">https://www.facebook.com/cneistat/videos/vb.210351389002863/922328184471843/?type=2&theater</p></div>');
444+
this.$el = $('.editable');
445+
this.$el.mediumInsert({
446+
addons: {
447+
embeds: {
448+
oembedProxy: false,
449+
storeMeta: true
450+
}
451+
}
452+
});
453+
this.$el.trigger($event);
454+
455+
expect(this.$el.find('.medium-insert-embeds').length).toEqual(1);
456+
expect(this.$el.find('.medium-insert-embeds .fb-post').length).toEqual(1);
457+
expect(this.$el.find('.medium-insert-embeds-meta').length).toEqual(1);
458+
expect(this.$el.find('.medium-insert-embeds-input').length).toEqual(0);
459+
});
460+
461+
it('does not include meta when storeMeta is not set', function () {
462+
var $event = $.Event('keydown');
463+
464+
$event.which = 13;
465+
$('#fixtures').html('<div class="editable"><p class="medium-insert-embeds-input medium-insert-embeds-active">https://www.facebook.com/cneistat/videos/vb.210351389002863/922328184471843/?type=2&theater</p></div>');
466+
this.$el = $('.editable');
467+
this.$el.mediumInsert({
468+
addons: {
469+
embeds: {
470+
oembedProxy: false,
471+
storeMeta: false
472+
}
473+
}
474+
});
475+
this.$el.trigger($event);
476+
477+
expect(this.$el.find('.medium-insert-embeds').length).toEqual(1);
478+
expect(this.$el.find('.medium-insert-embeds .fb-post').length).toEqual(1);
479+
expect(this.$el.find('.medium-insert-embeds-meta').length).toEqual(0);
480+
expect(this.$el.find('.medium-insert-embeds-input').length).toEqual(0);
481+
});
482+
483+
it('does not include meta for bad embeds', function () {
484+
var $event = $.Event('keydown');
485+
486+
$event.which = 13;
487+
$('#fixtures').html('<div class="editable"><p class="medium-insert-embeds-input medium-insert-embeds-active">test</p></div>');
488+
this.$el = $('.editable');
489+
490+
this.$el.mediumInsert({
491+
addons: {
492+
embeds: {
493+
oembedProxy: false,
494+
storeMeta: true
495+
}
496+
}
497+
});
498+
this.$el.trigger($event);
499+
500+
expect(this.$el.find('.medium-insert-embeds-input').length).toEqual(0);
501+
expect(this.$el.find('.medium-insert-embeds-meta').length).toEqual(0);
502+
expect(this.$el.find('p:first').html()).toBe('test');
503+
});
504+
439505

440506
});

src/js/embeds.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
oembedProxy: 'http://medium.iframe.ly/api/oembed?iframe=1',
1212
captions: true,
1313
captionPlaceholder: 'Type caption (optional)',
14+
storeMeta: false,
1415
styles: {
1516
wide: {
1617
label: '<span class="fa fa-align-justify"></span>'
@@ -331,6 +332,10 @@
331332
success: function (data) {
332333
var html = data && data.html;
333334

335+
if (that.options.storeMeta) {
336+
html += '<div class="medium-insert-embeds-meta"><script type="text/json">' + JSON.stringify(data) + '</script></div>';
337+
}
338+
334339
if (data && !html && data.type === 'photo' && data.url) {
335340
html = '<img src="' + data.url + '" alt="">';
336341
}
@@ -388,6 +393,10 @@
388393
.replace(/^(https:\/\/www\.facebook\.com\/(.*))$/, '<script src="//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.2" async></script><div class="fb-post" data-href="$1"><div class="fb-xfbml-parse-ignore"><a href="$1">Loading Facebook post...</a></div></div>')
389394
.replace(/^https?:\/\/instagram\.com\/p\/(.+)\/?$/, '<span class="instagram"><iframe src="//instagram.com/p/$1/embed/" width="612" height="710" frameborder="0" scrolling="no" allowtransparency="true"></iframe></span>');
390395

396+
if (this.options.storeMeta) {
397+
html += '<div class="medium-insert-embeds-meta"><script type="text/json">' + JSON.stringify({}) + '</script></div>';
398+
}
399+
391400
if ((/<("[^"]*"|'[^']*'|[^'">])*>/).test(html) === false) {
392401
$.proxy(this, 'convertBadEmbed', url)();
393402
return false;

src/js/templates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
126126
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.styles : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
127127
+ " </ul>\n</div>\n\n"
128128
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.actions : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
129-
},"useData":true});
129+
},"useData":true});

0 commit comments

Comments
 (0)