File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
app/assets/javascripts/ckeditor/plugins/cortex_media_insert Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ ( function ( global ) {
2
+ 'use strict' ;
3
+
4
+ global . CKEDITOR . plugins . add ( 'cortex_media_insert' , {
5
+ icons : 'media' ,
6
+ init : function ( editor ) {
7
+ editor . addCommand ( 'insertMedia' , {
8
+ exec : function ( editor ) {
9
+ window . MODALS . featured . open ( ) ;
10
+
11
+ global . media_select = { } ;
12
+ global . media_select_defer = $ . Deferred ( ) ;
13
+ global . media_select_defer . promise ( global . media_select ) ;
14
+
15
+ global . media_select . done ( function ( media ) {
16
+ window . MODALS . featured . close ( ) ;
17
+
18
+ var mediaTag = editor . document . createElement ( 'media' ) ;
19
+ mediaTag . setAttribute ( 'id' , media . id ) ;
20
+ mediaTag . setText ( " " + media . title ) ;
21
+
22
+ editor . insertElement ( mediaTag ) ;
23
+ } ) ;
24
+ }
25
+ } ) ;
26
+
27
+ editor . ui . addButton ( 'cortexMediaInsert' , {
28
+ label : 'Insert Media' ,
29
+ command : 'insertMedia' ,
30
+ toolbar : 'insert,0'
31
+ } ) ;
32
+ }
33
+ } ) ;
34
+ } ( this ) ) ;
You can’t perform that action at this time.
0 commit comments