-
Notifications
You must be signed in to change notification settings - Fork 4
/
soundcloud.js
55 lines (38 loc) · 1.52 KB
/
soundcloud.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
SirTrevor.Blocks.Soundcloud = (function(){
return SirTrevor.Block.extend({
provider: {
regex: /soundcloud.com\/tracks\/(\d+)&/,
html: "<iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/{{remote_id}}&color=ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false\"></iframe>"
},
type: "soundcloud",
title: "SoundCloud",
pastable: true,
paste_options: {
html: "<div style=\"text-align:center; padding:20px;\">Enter <b>SoundCloud</b> embed code<br /><input type=\"text\" class=\"st-paste-block\" style=\"width: 100%\" placeholder=\"Enter embed code\"></div>"
},
icon_name: "iframe",
loadData: function(data) {
this.$editor.addClass("st-block__editor--with-square-media");
var embed_string = this.provider.html
.replace("{{remote_id}}", data.remote_id);
this.$editor.html(embed_string);
},
onContentPasted: function(event){
this.handleDropPaste($(event.target).val());
},
handleDropPaste: function(url){
var match, data;
match = this.provider.regex.exec(url);
if (match !== null && !_.isUndefined(match[1])) {
data = {
remote_id: match[1]
};
this.setAndLoadData(data);
}
},
onDrop: function(transferData){
var url = transferData.getData("text/plain");
this.handleDropPaste(url);
}
});
})();