|
19 | 19 | //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
20 | 20 | //SOFTWARE. |
21 | 21 |
|
22 | | -import utils from './modules/utils.es6'; |
23 | | -import Emoji from './modules/emoticons/emoji.es6'; |
24 | | -import Smiley from './modules/emoticons/smiley.es6'; |
25 | | -import Url from './modules/url.es6'; |
26 | | -import Code from './modules/code.es6'; |
| 22 | +import utils from './modules/utils.es6'; |
| 23 | +import Emoji from './modules/emoticons/emoji.es6'; |
| 24 | +import Smiley from './modules/emoticons/smiley.es6'; |
| 25 | +import Url from './modules/url.es6'; |
| 26 | +import Code from './modules/code.es6'; |
| 27 | +import Twitter from './modules/twitter.es6'; |
27 | 28 |
|
28 | | -(function () { |
| 29 | +(function() { |
29 | 30 |
|
30 | | - var defaultOptions = { |
31 | | - link : true, |
32 | | - linkTarget : 'self', |
33 | | - linkExclude : ['pdf'], |
34 | | - emoji : true, |
35 | | - fontIcons : true, |
36 | | - highlightCode : true |
37 | | - }; |
| 31 | + var defaultOptions = { |
| 32 | + link : true, |
| 33 | + linkTarget : 'self', |
| 34 | + linkExclude : ['pdf'], |
| 35 | + emoji : true, |
| 36 | + fontIcons : true, |
| 37 | + highlightCode : true, |
| 38 | + tweetsEmbed : true, |
| 39 | + tweetOptions: { |
| 40 | + maxWidth : 550, |
| 41 | + hideMedia : false, |
| 42 | + hideThread : false, |
| 43 | + align : 'none', |
| 44 | + lang : 'en' |
| 45 | + } |
| 46 | + }; |
38 | 47 |
|
39 | | - class EmbedJS { |
40 | | - constructor(options) { |
41 | | - this.options = utils.deepExtend(defaultOptions,options); |
42 | | - this.element = this.options.element; |
43 | | - this.input = this.element.innerHTML; |
44 | | - this.process(); |
45 | | - } |
| 48 | + class EmbedJS { |
| 49 | + constructor(options) { |
| 50 | + this.options = utils.deepExtend(defaultOptions, options); |
| 51 | + this.element = this.options.element; |
| 52 | + this.input = this.element.innerHTML; |
| 53 | + this.process(); |
| 54 | + } |
46 | 55 |
|
47 | | - async process(){ |
48 | | - let input = this.input; |
49 | | - let options = this.options; |
50 | | - input = options.link ? await (new Url(input, options).process()) : input; |
51 | | - input = options.emoji ? await (new Emoji(input, options).process()) : input; |
52 | | - input = options.fontIcons ? await (new Smiley(input, options).process()) : input; |
53 | | - input = options.highlightCode ? await (new Code(input, options).process()) : input; |
| 56 | + async process() { |
| 57 | + let input = this.input; |
| 58 | + let options = this.options; |
| 59 | + input = options.link ? await (new Url(input, options).process()) : input; |
| 60 | + input = options.emoji ? await (new Emoji(input, options).process()) : input; |
| 61 | + input = options.fontIcons ? await (new Smiley(input, options).process()) : input; |
| 62 | + input = options.highlightCode ? await (new Code(input, options).process()) : input; |
| 63 | + if (options.tweetsEmbed){ |
| 64 | + var twitter = new Twitter(input, options); |
| 65 | + input = options.tweetsEmbed ? await (twitter.process()) : input; |
| 66 | + } |
54 | 67 |
|
55 | | - options.element.innerHTML = input; |
56 | | - } |
57 | | - } |
| 68 | + options.element.innerHTML = input; |
| 69 | + twitter.load(); |
| 70 | + } |
| 71 | + } |
58 | 72 |
|
59 | | - window.EmbedJS = EmbedJS; |
| 73 | + window.EmbedJS = EmbedJS; |
60 | 74 | })(); |
0 commit comments