Skip to content

Commit f6cec4f

Browse files
committed
fix(umd): added options to pass the global variable of 3rd party plugins
fixes ritz078#131
1 parent c2a1569 commit f6cec4f

10 files changed

Lines changed: 108 additions & 72 deletions

File tree

dist/embed.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.

src/embed.es2015.js

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

src/embed.es2015.js.map

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

src/embed.js

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

src/embed.js.map

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

src/js/main.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ var defaultOptions = {
7878
width : 350,
7979
height : 460
8080
},
81+
plugins : {
82+
marked : marked,
83+
videojs : videojs,
84+
highlightjs: hljs,
85+
prismjs : Prism,
86+
twitter : twttr
87+
},
8188
googleAuthKey : '',
8289
soundCloudOptions : {
8390
height : 160,
@@ -157,8 +164,8 @@ export default class EmbedJS {
157164
process() {
158165
const input = this.input;
159166
const options = processOptions(this.options);
160-
let embeds = [];
161-
let output = '';
167+
let embeds = [];
168+
let output = '';
162169

163170
this.options.beforeEmbedJSApply();
164171

@@ -168,7 +175,7 @@ export default class EmbedJS {
168175

169176
let openGraphPromise = options.openGraphEndpoint ? new OpenGraph(input, output, options, embeds).process() : Promise.resolve([output, embeds]);
170177

171-
openGraphPromise.then(function([output, embeds]) {
178+
openGraphPromise.then(function ([output, embeds]) {
172179
if (options.highlightCode) {
173180
output = new Highlight(output, options).process()
174181
}
@@ -205,16 +212,16 @@ export default class EmbedJS {
205212
}
206213

207214
return ifEmbed(options, 'youtube') ? new Youtube(input, output, options, embeds).process() : Promise.resolve([output, embeds]);
208-
}).then(function([output, embeds]){
215+
}).then(function ([output, embeds]) {
209216
return ifEmbed(options, 'vimeo') ? new Vimeo(input, output, options, embeds).process() : Promise.resolve([output, embeds]);
210-
}).then(function([output, embeds]){
217+
}).then(function ([output, embeds]) {
211218
return ifEmbed(options, 'opengraph') ? new Github(input, output, options, embeds).process() : Promise.resolve([output, embeds]);
212-
}).then(function([output, embeds]){
219+
}).then(function ([output, embeds]) {
213220
return options.locationEmbed && ifEmbed(options, 'gmap') ? new Gmap(input, output, options, embeds).process() : Promise.resolve([output, embeds])
214-
}).then(function([output, embeds]){
221+
}).then(function ([output, embeds]) {
215222
return ifEmbed(options, 'slideshare') ? new SlideShare(input, output, options, embeds).process() : Promise.resolve([output, embeds]);
216223
}).then(([output, embeds]) => {
217-
if (options.tweetsEmbed && ifEmbed(options,'twitter')) {
224+
if (options.tweetsEmbed && ifEmbed(options, 'twitter')) {
218225
this.twitter = new Twitter(input, output, options, embeds);
219226
return this.twitter.process()
220227
} else {
@@ -271,7 +278,7 @@ export default class EmbedJS {
271278
* events to be done after an element has been rendered. These
272279
* include twitter widget rendering, gist embedding, click event listeners .
273280
*/
274-
applyListeners(){
281+
applyListeners() {
275282
applyVideoJS(this.options);
276283

277284
playVideo(this.options);
@@ -290,10 +297,10 @@ export default class EmbedJS {
290297
*/
291298
update(options, template) {
292299

293-
if(options)
300+
if (options)
294301
this.options = deepExtend(this.options, options);
295302

296-
if(template)
303+
if (template)
297304
this.options.template = template;
298305

299306
if (!this.options.input || !(typeof this.options.input === 'string' || typeof this.options.input === 'object')) throw ReferenceError("You need to pass an element or the string that needs to be processed");

0 commit comments

Comments
 (0)