root / drupal7 / sites / all / modules / ckeditor / plugins / media / plugin.js @ 6fd71452
1 |
/*
|
---|---|
2 |
Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
|
3 |
For licensing, see LICENSE.html or http://ckeditor.com/license
|
4 |
*/
|
5 |
|
6 |
/**
|
7 |
* @file Plugin for inserting images from Drupal media module
|
8 |
*/
|
9 |
( function() {
|
10 |
CKEDITOR.plugins.add( 'media',
|
11 |
{ |
12 |
// Wrap Drupal plugin in a proxy plugin.
|
13 |
init: function(editor) |
14 |
{ |
15 |
var pluginCommand = {
|
16 |
exec: function (editor) { |
17 |
var data = {
|
18 |
format: 'html', |
19 |
node: null, |
20 |
content: '' |
21 |
}; |
22 |
var selection = editor.getSelection();
|
23 |
|
24 |
if (selection) {
|
25 |
data.node = selection.getSelectedElement(); |
26 |
if (data.node) {
|
27 |
data.node = data.node.$;
|
28 |
} |
29 |
if (selection.getType() == CKEDITOR.SELECTION_TEXT) {
|
30 |
data.content = selection.getSelectedText(); |
31 |
} |
32 |
else if (data.node) { |
33 |
// content is supposed to contain the "outerHTML".
|
34 |
data.content = data.node.parentNode.innerHTML; |
35 |
} |
36 |
} |
37 |
Drupal.settings.ckeditor.plugins['media'].invoke(data, Drupal.settings.ckeditor.plugins['media'], editor.name); |
38 |
} |
39 |
}; |
40 |
editor.addCommand( 'media', pluginCommand );
|
41 |
|
42 |
editor.ui.addButton( 'Media',
|
43 |
{ |
44 |
label: 'Add media', |
45 |
command: 'media', |
46 |
icon: this.path + 'images/icon.gif' |
47 |
}); |
48 |
} |
49 |
}); |
50 |
|
51 |
} )(); |
52 |
|
53 |
|