Revision 2868:2f77d528185b,
1.4 KB
checked in by Nicolas <nikrou77@…>, 11 years ago
(diff) |
Add external media for CKEditor
Allow link around external media
|
Line | |
---|
1 | (function() { |
---|
2 | CKEDITOR.plugins.add('dclink', { |
---|
3 | icons: 'dclink', |
---|
4 | init: function(editor) { |
---|
5 | editor.addCommand('dcLinkCommand', { |
---|
6 | exec: function(editor) { |
---|
7 | if (editor.getSelection().getSelectedElement()!=null |
---|
8 | || editor.getSelection().getNative().toString().replace(/\s*/,'')!='') { |
---|
9 | $.toolbarPopup('popup_link.php?plugin_id=dcCKEditor'); |
---|
10 | } |
---|
11 | } |
---|
12 | }); |
---|
13 | |
---|
14 | editor.ui.addButton('dcLink', { |
---|
15 | label: dotclear.msg.link_title, |
---|
16 | command: 'dcLinkCommand', |
---|
17 | toolbar: 'insert' |
---|
18 | }); |
---|
19 | |
---|
20 | editor.on('doubleclick',function(e) { |
---|
21 | var element = CKEDITOR.plugins.link.getSelectedLink(editor) || e.data.element; |
---|
22 | if (!element.isReadOnly()) { |
---|
23 | if (element.is('a') |
---|
24 | && !element.hasClass('media-link') // link to original media @see js/popup_media.js |
---|
25 | && !element.hasClass('post')) { // link to an entry @see js/popup_posts.js |
---|
26 | |
---|
27 | editor.getSelection().selectElement(element); |
---|
28 | |
---|
29 | var popup_url = 'popup_link.php?plugin_id=dcCKEditor'; |
---|
30 | if (element.getAttribute('href')) { |
---|
31 | popup_url += '&href='+element.getAttribute('href'); |
---|
32 | } |
---|
33 | if (element.getAttribute('hreflang')) { |
---|
34 | popup_url += '&hreflang='+element.getAttribute('hreflang'); |
---|
35 | } |
---|
36 | if (element.getAttribute('title')) { |
---|
37 | popup_url += '&title='+element.getAttribute('title'); |
---|
38 | } |
---|
39 | |
---|
40 | $.toolbarPopup(popup_url); |
---|
41 | return false; |
---|
42 | } |
---|
43 | } |
---|
44 | }); |
---|
45 | } |
---|
46 | }); |
---|
47 | })(); |
---|
Note: See
TracBrowser
for help on using the repository browser.