forked from editor-js/embed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.js
121 lines (114 loc) · 4.54 KB
/
services.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
export default {
vimeo: {
regex: /(?:http[s]?:\/\/)?(?:www.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,
embedUrl: 'https://player.vimeo.com/video/<%= remote_id %>?title=0&byline=0',
html: '<iframe style="width:100%;" height="320" frameborder="0"></iframe>',
height: 320,
width: 580
},
youtube: {
regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/,
embedUrl: 'https://www.youtube.com/embed/<%= remote_id %>',
html: '<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',
height: 320,
width: 580,
id: ([id, params]) => {
if (!params && id) {
return id;
}
const paramsMap = {
start: 'start',
end: 'end',
t: 'start',
'time_continue': 'start',
list: 'list'
};
params = params.slice(1)
.split('&')
.map(param => {
const [name, value] = param.split('=');
if (!id && name === 'v') {
id = value;
return;
}
if (!paramsMap[name]) return;
return `${paramsMap[name]}=${value}`;
})
.filter(param => !!param);
return id + '?' + params.join('&');
}
},
coub: {
regex: /https?:\/\/coub\.com\/view\/([^\/\?\&]+)/,
embedUrl: 'https://coub.com/embed/<%= remote_id %>',
html: '<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',
height: 320,
width: 580
},
vine: {
regex: /https?:\/\/vine\.co\/v\/([^\/\?\&]+)/,
embedUrl: 'https://vine.co/v/<%= remote_id %>/embed/simple/',
html: '<iframe style="width:100%;" height="320" frameborder="0" allowfullscreen></iframe>',
height: 320,
width: 580
},
imgur: {
regex: /https?:\/\/(?:i\.)?imgur\.com.*\/([a-zA-Z0-9]+)(?:\.gifv)?/,
embedUrl: 'http://imgur.com/<%= remote_id %>/embed',
html: '<iframe allowfullscreen="true" scrolling="no" id="imgur-embed-iframe-pub-<%= remote_id %>" class="imgur-embed-iframe-pub" style="height: 500px; width: 100%; border: 1px solid #000"></iframe>',
height: 500,
width: 540
},
gfycat: {
regex: /https?:\/\/gfycat\.com(?:\/detail)?\/([a-zA-Z]+)/,
embedUrl: 'https://gfycat.com/ifr/<%= remote_id %>',
html: "<iframe frameborder='0' scrolling='no' style=\"width:100%;\" height='436' allowfullscreen ></iframe>",
height: 436,
width: 580
},
'twitch-channel': {
regex: /https?:\/\/www\.twitch\.tv\/([^\/\?\&]*)\/?$/,
embedUrl: 'https://player.twitch.tv/?channel=<%= remote_id %>',
html: '<iframe frameborder="0" allowfullscreen="true" scrolling="no" height="366" style="width:100%;"></iframe>',
height: 366,
width: 600
},
'twitch-video': {
regex: /https?:\/\/www\.twitch\.tv\/(?:[^\/\?\&]*\/v|videos)\/([0-9]*)/,
embedUrl: 'https://player.twitch.tv/?video=v<%= remote_id %>',
html: '<iframe frameborder="0" allowfullscreen="true" scrolling="no" height="366" style="width:100%;"></iframe>',
height: 366,
width: 600
},
'yandex-music-album': {
regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/?$/,
embedUrl: 'https://music\.yandex\.ru/iframe/#album/<%= remote_id %>/',
html: '<iframe frameborder=\"0\" style=\"border:none;width:540px;height:400px;\" style=\"width:100%;\" height=\"400\"></iframe>',
height: 400,
width: 540
},
'yandex-music-track': {
regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/track\/([0-9]*)/,
embedUrl: 'https://music\.yandex\.ru/iframe/#track/<%= remote_id %>/',
html: '<iframe frameborder="0" style="border:none;width:540px;height:100px;" style="width:100%;" height="100"></iframe>',
height: 100,
width: 540,
id: (ids) => ids.join('/')
},
'yandex-music-playlist': {
regex: /https?:\/\/music\.yandex\.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/,
embedUrl: 'https://music\.yandex\.ru/iframe/#playlist/<%= remote_id %>/show/cover/description/',
html: '<iframe frameborder="0" style="border:none;width:540px;height:400px;" width="540" height="400"></iframe>',
height: 400,
width: 540,
id: (ids) => ids.join('/')
},
codepen: {
regex: /https?:\/\/codepen\.io\/([^\/\?\&]*)\/pen\/([^\/\?\&]*)/,
embedUrl: 'https://codepen.io/<%= remote_id %>?height=300&theme-id=0&default-tab=css,result&embed-version=2',
html: "<iframe height='300' scrolling='no' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'></iframe>",
height: 300,
width: 600,
id: (ids) => ids.join('/embed/')
}
};