root / drupal7 / sites / all / modules / ckeditor / plugins / media / plugin.js @ 5a7e6170
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 |
if (CKEDITOR.env.ie) {
|
31 |
data.content = selection.getNative().createRange().text; |
32 |
} |
33 |
else {
|
34 |
data.content = selection.getNative().toString(); |
35 |
} |
36 |
} |
37 |
else if (data.node) { |
38 |
// content is supposed to contain the "outerHTML".
|
39 |
data.content = data.node.parentNode.innerHTML; |
40 |
} |
41 |
} |
42 |
Drupal.settings.ckeditor.plugins['media'].invoke(data, Drupal.settings.ckeditor.plugins['media'], editor.name); |
43 |
} |
44 |
}; |
45 |
editor.addCommand( 'media', pluginCommand );
|
46 |
|
47 |
editor.ui.addButton( 'Media',
|
48 |
{ |
49 |
label: 'Add media', |
50 |
command: 'media', |
51 |
icon: this.path + 'images/icon.gif' |
52 |
}); |
53 |
} |
54 |
}); |
55 |
|
56 |
} )(); |
57 |
|
58 |
|