Changeset 3367:506dc982a0e3 for plugins/dcCKEditor
- Timestamp:
- 10/27/16 11:19:34 (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcCKEditor/_post_config.php
r3362 r3367 12 12 13 13 if (!defined('DC_CONTEXT_ADMIN')) { return; } 14 14 15 header('Content-type: text/javascript'); 16 15 17 if (!empty($_GET['context'])) { 16 18 $context = $_GET['context']; … … 18 20 $context = ''; 19 21 } 22 20 23 $__extraPlugins = new ArrayObject(); 21 24 $core->callBehavior('ckeditorExtraPlugins',$__extraPlugins,$context); 22 25 $extraPlugins = $__extraPlugins->getArrayCopy(); 23 ?> 26 27 ?> 28 24 29 (function($) { 25 30 $.toolbarPopup = function toolbarPopup(url) { … … 59 64 return $.active_editor; 60 65 } 61 chainHandler(window, 'onbeforeunload',function(e) {66 chainHandler(window,'onbeforeunload',function(e) { 62 67 if (e == undefined && window.event) { 63 68 e = window.event; … … 65 70 66 71 var editor = CKEDITOR.instances[$.getEditorName()]; 67 if (editor !==undefined && !confirmClosePage.formSubmit && editor.checkDirty()) {72 if (editor !== undefined && !confirmClosePage.formSubmit && editor.checkDirty()) { 68 73 e.returnValue = confirmClosePage.prompt; 69 74 return confirmClosePage.prompt; … … 79 84 80 85 CKEDITOR.timestamp = ''; 81 <?php if (!isset($dcckeditor_disable_native_spellchecker) || $dcckeditor_disable_native_spellchecker):?> 86 87 <?php if (!isset($dcckeditor_disable_native_spellchecker) || $dcckeditor_disable_native_spellchecker): ?> 82 88 CKEDITOR.config.disableNativeSpellChecker = true; 83 <?php else: ?>89 <?php else: ?> 84 90 CKEDITOR.config.disableNativeSpellChecker = false; 85 <?php endif;?> 91 <?php endif; ?> 92 86 93 CKEDITOR.config.skin = 'dotclear,'+dotclear.dcckeditor_plugin_url+'/js/ckeditor-skins/dotclear/'; 87 94 CKEDITOR.config.baseHref = dotclear.base_url; 88 CKEDITOR.config.height = '<?php echo $core->auth->getOption('edit_size') * 14; ?>px';89 90 <?php if (!empty($dcckeditor_cancollapse_button)): ?>95 CKEDITOR.config.height = '<?php echo $core->auth->getOption('edit_size') * 14; ?>px'; 96 97 <?php if (!empty($dcckeditor_cancollapse_button)): ?> 91 98 CKEDITOR.config.toolbarCanCollapse = true; 92 <?php endif; ?>99 <?php endif; ?> 93 100 94 101 CKEDITOR.plugins.addExternal('entrylink',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/entrylink/'); … … 96 103 CKEDITOR.plugins.addExternal('media',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/media/'); 97 104 CKEDITOR.plugins.addExternal('img',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/img/'); 98 <?php if (!empty($dcckeditor_textcolor_button) || !empty($dcckeditor_background_textcolor_button)):?> 105 106 <?php if (!empty($dcckeditor_textcolor_button) || !empty($dcckeditor_background_textcolor_button)): ?> 99 107 // button add "More Colors..." can be added if colordialog plugin is enabled 100 108 CKEDITOR.config.colorButton_enableMore = true; 101 <?php endif;?> 102 103 <?php if (!empty($extraPlugins) && count($extraPlugins)>0) { 104 foreach ($extraPlugins as $plugin) { 105 printf("\tCKEDITOR.plugins.addExternal('%s','%s');\n", $plugin['name'], $plugin['url']); 106 } 107 } 108 ?> 109 if (dotclear.ckeditor_context===undefined || dotclear.ckeditor_tags_context[dotclear.ckeditor_context]===undefined) { 109 <?php endif; ?> 110 111 <?php 112 if (!empty($extraPlugins) && count($extraPlugins) > 0) { 113 foreach ($extraPlugins as $plugin) { 114 printf("\tCKEDITOR.plugins.addExternal('%s','%s');\n",$plugin['name'],$plugin['url']); 115 } 116 } 117 ?> 118 if (dotclear.ckeditor_context === undefined || dotclear.ckeditor_tags_context[dotclear.ckeditor_context] === undefined) { 110 119 return; 111 120 } 112 121 $(dotclear.ckeditor_tags_context[dotclear.ckeditor_context].join(',')).ckeditor({ 122 113 123 <?php 114 $defautExtraPlugins = 'entrylink,dclink,media,justify,colorbutton,format,img';115 if (!empty($extraPlugins) && count($extraPlugins)>0) {116 foreach ($extraPlugins as $plugin) {117 $defautExtraPlugins .= ','. $plugin['name'];118 }119 }120 ?> 121 extraPlugins: '<?php echo $defautExtraPlugins; ?>',124 $defautExtraPlugins = 'entrylink,dclink,media,justify,colorbutton,format,img'; 125 if (!empty($extraPlugins) && count($extraPlugins)>0) { 126 foreach ($extraPlugins as $plugin) { 127 $defautExtraPlugins .= ','. $plugin['name']; 128 } 129 } 130 ?> 131 extraPlugins: '<?php echo $defautExtraPlugins; ?>', 122 132 123 133 keystrokes: [ 124 134 [ CKEDITOR.CTRL + (CKEDITOR.env.mac ? CKEDITOR.ALT : CKEDITOR.SHIFT) + 125 dotclear.msg.link_accesskey.toUpperCase().charCodeAt(0), 135 dotclear.msg.link_accesskey.toUpperCase().charCodeAt(0),'dcLinkCommand' ], // Ctrl+Alt+l 126 136 [ CKEDITOR.CTRL + (CKEDITOR.env.mac ? CKEDITOR.ALT : CKEDITOR.SHIFT) + 127 dotclear.msg.img_select_accesskey.toUpperCase().charCodeAt(0), 137 dotclear.msg.img_select_accesskey.toUpperCase().charCodeAt(0),'mediaCommand' ], // Ctrl+Alt+m 128 138 ], 129 139 130 <?php if (!empty($dcckeditor_format_select)):?>140 <?php if (!empty($dcckeditor_format_select)): ?> 131 141 // format tags 132 <?php if (!empty($dcckeditor_format_tags)):?> 133 format_tags: '<?php echo $dcckeditor_format_tags;?>', 134 <?php else:?> 142 143 <?php if (!empty($dcckeditor_format_tags)): ?> 144 format_tags: '<?php echo $dcckeditor_format_tags; ?>', 145 <?php else: ?> 135 146 format_tags: 'p;h1;h2;h3;h4;h5;h6;pre;address', 136 <?php endif;?> 147 <?php endif; ?> 148 137 149 // following definition are needed to be specialized 138 150 format_p: { element: 'p' }, … … 145 157 format_pre: { element: 'pre' }, 146 158 format_address: { element: 'address' }, 147 <?php endif;?>159 <?php endif; ?> 148 160 149 161 entities: false, … … 154 166 name: 'basicstyles', 155 167 items: [ 156 <?php if (!empty($dcckeditor_format_select)):?> 168 169 <?php if (!empty($dcckeditor_format_select)): ?> 157 170 'Format', 158 171 <?php endif;?> 172 159 173 'Bold','Italic','Underline','Strike','Subscript','Superscript','Code','Blockquote', 160 174 161 <?php if (!empty($dcckeditor_list_buttons)):?> 162 'NumberedList', 'BulletedList', 163 <?php endif;?> 175 <?php if (!empty($dcckeditor_list_buttons)): ?> 176 'NumberedList','BulletedList', 177 <?php endif; ?> 178 164 179 'RemoveFormat' 165 180 ] 166 181 }, 167 <?php if (!empty($dcckeditor_clipboard_buttons)):?> 182 183 <?php if (!empty($dcckeditor_clipboard_buttons)): ?> 168 184 { 169 185 name: 'clipoard', 170 186 items: ['Cut','Copy','Paste','PasteText','PasteFromWord'] 171 187 }, 172 <?php endif;?> 173 <?php if (!empty($dcckeditor_alignment_buttons)):?> 188 <?php endif; ?> 189 190 <?php if (!empty($dcckeditor_alignment_buttons)): ?> 174 191 { 175 192 name: 'paragraph', 176 items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] 177 }, 178 <?php endif;?> 179 <?php if (!empty($dcckeditor_table_button)):?> 193 items: ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'] 194 }, 195 <?php endif; ?> 196 197 <?php if (!empty($dcckeditor_table_button)): ?> 180 198 { 181 199 name: 'table', 182 200 items: ['Table'] 183 201 }, 184 <?php endif;?> 202 <?php endif; ?> 203 185 204 { 186 205 name: 'custom', … … 188 207 'EntryLink','dcLink','Media','img','-', 189 208 'Source' 190 <?php if (!empty($dcckeditor_textcolor_button)):?> 209 210 <?php if (!empty($dcckeditor_textcolor_button)): ?> 191 211 ,'TextColor' 192 <?php endif;?> 193 <?php if (!empty($dcckeditor_background_textcolor_button)):?> 212 <?php endif; ?> 213 214 <?php if (!empty($dcckeditor_background_textcolor_button)): ?> 194 215 ,'BGColor' 195 <?php endif; ?>216 <?php endif; ?> 196 217 ] 197 218 }, … … 202 223 ] 203 224 }, 204 <?php // add extra buttons comming from dotclear plugins 205 if (!empty($extraPlugins) && count($extraPlugins)>0) { 206 $extraPlugins_str = "{name: 'extra', items: [%s]},\n"; 207 $extra_icons = ''; 208 foreach ($extraPlugins as $plugin) { 209 $extra_icons .= sprintf("'%s',", $plugin['button']); 210 } 211 printf($extraPlugins_str, $extra_icons); 225 226 <?php // add extra buttons comming from dotclear plugins 227 if (!empty($extraPlugins) && count($extraPlugins)>0) { 228 $extraPlugins_str = "{name: 'extra', items: [%s]},\n"; 229 $extra_icons = ''; 230 foreach ($extraPlugins as $plugin) { 231 $extra_icons .= sprintf("'%s',",$plugin['button']); 232 } 233 printf($extraPlugins_str,$extra_icons); 234 } 235 ?> 236 ] 237 }); 238 239 CKEDITOR.on('instanceLoaded',function(e) { 240 241 // Retrieve textarea element of the instance, then its line-height (in px) and rows values, 242 // then apply line-height * rows (min = 6) to the inner height of the instance. 243 244 var ta = document.getElementById(e.editor.name); 245 if (ta !== undefined) { 246 var ta_rows = ta.rows; 247 var ta_line_height = parseFloat(window.getComputedStyle(ta,null).getPropertyValue('line-height')); 248 if (ta_rows > 0 && ta_line_height > 0) { 249 var ta_height = String(Math.max(ta_rows,6) * ta_line_height); 250 e.editor.resize('100%',ta_height,true); 212 251 } 213 ?>214 ]215 }); 216 217 CKEDITOR.on('instanceReady', function(e) { 218 if ($('label[for="post_excerpt"] a img').attr('src') ==dotclear.img_minus_src) {252 } 253 }); 254 255 CKEDITOR.on('instanceReady',function(e) { 256 257 if ($('label[for="post_excerpt"] a img').attr('src') == dotclear.img_minus_src) { 219 258 $('#cke_post_excerpt').removeClass('hide'); 220 259 } else { … … 229 268 // @TODO: find a better way to retrieve active editor 230 269 for (var id in CKEDITOR.instances) { 231 CKEDITOR.instances[id].on('focus', 270 CKEDITOR.instances[id].on('focus',function(e) { 232 271 $.active_editor = e.editor.name; 233 272 });
Note: See TracChangeset
for help on using the changeset viewer.