-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fembed.js
37 lines (28 loc) · 1.18 KB
/
Fembed.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
( function() {
tinymce.PluginManager.add( 'fembed', function( editor, url ) {
editor.addButton( 'fembed_button_key', {
text: 'Fembed',
icon: false,
onclick: function() {
editor.windowManager.open( {
title: 'Embed facebook video',
body: [{
type: 'textbox',
name: 'link',
label: 'link'
}],
onsubmit: function( e ) {
console.log(e.data.link);
var qlink = e.data.link;
if(/^https:\/\/www\.facebook\.com/.test(qlink)===false){
alert('Invalid facebook video link');
return false;
}
var clearq_id = /\d+/.exec(qlink);
editor.insertContent('<center><iframe src="https://www.facebook.com/video/embed?video_id='+clearq_id+'" width=90% height=400px></iframe></center>' );
}
} );
}
} );
} );
} )();