Dotclear


Ignore:
Timestamp:
10/27/16 11:19:34 (9 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Adjust inner height of the CKEDitor (using rows attributes of the textarea), fixes #2136

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcCKEditor/_post_config.php

    r3362 r3367  
    1212 
    1313if (!defined('DC_CONTEXT_ADMIN')) { return; } 
     14 
    1415header('Content-type: text/javascript'); 
     16 
    1517if (!empty($_GET['context'])) { 
    1618     $context = $_GET['context']; 
     
    1820     $context = ''; 
    1921} 
     22 
    2023$__extraPlugins = new ArrayObject(); 
    2124$core->callBehavior('ckeditorExtraPlugins',$__extraPlugins,$context); 
    2225$extraPlugins = $__extraPlugins->getArrayCopy(); 
    23 ?> 
     26 
     27?> 
     28 
    2429(function($) { 
    2530     $.toolbarPopup = function toolbarPopup(url) { 
     
    5964          return $.active_editor; 
    6065     } 
    61      chainHandler(window, 'onbeforeunload', function(e) { 
     66     chainHandler(window,'onbeforeunload',function(e) { 
    6267          if (e == undefined && window.event) { 
    6368               e = window.event; 
     
    6570 
    6671          var editor = CKEDITOR.instances[$.getEditorName()]; 
    67           if (editor!==undefined && !confirmClosePage.formSubmit && editor.checkDirty()) { 
     72          if (editor !== undefined && !confirmClosePage.formSubmit && editor.checkDirty()) { 
    6873               e.returnValue = confirmClosePage.prompt; 
    6974               return confirmClosePage.prompt; 
     
    7984 
    8085     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): ?> 
    8288     CKEDITOR.config.disableNativeSpellChecker = true; 
    83 <?php else:?> 
     89<?php else: ?> 
    8490     CKEDITOR.config.disableNativeSpellChecker = false; 
    85 <?php endif;?> 
     91<?php endif; ?> 
     92 
    8693     CKEDITOR.config.skin = 'dotclear,'+dotclear.dcckeditor_plugin_url+'/js/ckeditor-skins/dotclear/'; 
    8794     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)): ?> 
    9198     CKEDITOR.config.toolbarCanCollapse = true; 
    92 <?php endif;?> 
     99<?php endif; ?> 
    93100 
    94101     CKEDITOR.plugins.addExternal('entrylink',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/entrylink/'); 
     
    96103     CKEDITOR.plugins.addExternal('media',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/media/'); 
    97104     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)): ?> 
    99107     // button add "More Colors..." can be added if colordialog plugin is enabled 
    100108     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) { 
    110119          return; 
    111120     } 
    112121     $(dotclear.ckeditor_tags_context[dotclear.ckeditor_context].join(',')).ckeditor({ 
     122 
    113123<?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; ?>', 
    122132 
    123133          keystrokes: [ 
    124134               [ CKEDITOR.CTRL + (CKEDITOR.env.mac ? CKEDITOR.ALT : CKEDITOR.SHIFT) + 
    125                     dotclear.msg.link_accesskey.toUpperCase().charCodeAt(0), 'dcLinkCommand' ],    // Ctrl+Alt+l 
     135                    dotclear.msg.link_accesskey.toUpperCase().charCodeAt(0),'dcLinkCommand' ],    // Ctrl+Alt+l 
    126136               [ CKEDITOR.CTRL + (CKEDITOR.env.mac ? CKEDITOR.ALT : CKEDITOR.SHIFT) + 
    127                     dotclear.msg.img_select_accesskey.toUpperCase().charCodeAt(0), 'mediaCommand' ],    // Ctrl+Alt+m 
     137                    dotclear.msg.img_select_accesskey.toUpperCase().charCodeAt(0),'mediaCommand' ],    // Ctrl+Alt+m 
    128138          ], 
    129139 
    130           <?php if (!empty($dcckeditor_format_select)):?> 
     140<?php if (!empty($dcckeditor_format_select)): ?> 
    131141          // 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: ?> 
    135146          format_tags: 'p;h1;h2;h3;h4;h5;h6;pre;address', 
    136 <?php endif;?> 
     147     <?php endif; ?> 
     148 
    137149          // following definition are needed to be specialized 
    138150          format_p: { element: 'p' }, 
     
    145157          format_pre: { element: 'pre' }, 
    146158          format_address: { element: 'address' }, 
    147           <?php endif;?> 
     159<?php endif; ?> 
    148160 
    149161          entities: false, 
     
    154166                    name: 'basicstyles', 
    155167                    items: [ 
    156 <?php if (!empty($dcckeditor_format_select)):?> 
     168 
     169<?php if (!empty($dcckeditor_format_select)): ?> 
    157170                         'Format', 
    158171<?php endif;?> 
     172 
    159173                         'Bold','Italic','Underline','Strike','Subscript','Superscript','Code','Blockquote', 
    160174 
    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 
    164179                         'RemoveFormat' 
    165180                    ] 
    166181               }, 
    167 <?php if (!empty($dcckeditor_clipboard_buttons)):?> 
     182 
     183<?php if (!empty($dcckeditor_clipboard_buttons)): ?> 
    168184               { 
    169185                    name: 'clipoard', 
    170186                    items: ['Cut','Copy','Paste','PasteText','PasteFromWord'] 
    171187               }, 
    172 <?php endif;?> 
    173 <?php if (!empty($dcckeditor_alignment_buttons)):?> 
     188<?php endif; ?> 
     189 
     190<?php if (!empty($dcckeditor_alignment_buttons)): ?> 
    174191               { 
    175192                    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)): ?> 
    180198               { 
    181199                    name: 'table', 
    182200                    items: ['Table'] 
    183201               }, 
    184 <?php endif;?> 
     202<?php endif; ?> 
     203 
    185204               { 
    186205                    name: 'custom', 
     
    188207                         'EntryLink','dcLink','Media','img','-', 
    189208                         'Source' 
    190 <?php if (!empty($dcckeditor_textcolor_button)):?> 
     209 
     210<?php if (!empty($dcckeditor_textcolor_button)): ?> 
    191211                         ,'TextColor' 
    192 <?php endif;?> 
    193 <?php if (!empty($dcckeditor_background_textcolor_button)):?> 
     212<?php endif; ?> 
     213 
     214<?php if (!empty($dcckeditor_background_textcolor_button)): ?> 
    194215                         ,'BGColor' 
    195 <?php endif;?> 
     216<?php endif; ?> 
    196217                    ] 
    197218               }, 
     
    202223                    ] 
    203224               }, 
    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); 
    212251               } 
    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) { 
    219258               $('#cke_post_excerpt').removeClass('hide'); 
    220259          } else { 
     
    229268     // @TODO: find a better way to retrieve active editor 
    230269     for (var id in CKEDITOR.instances) { 
    231           CKEDITOR.instances[id].on('focus', function(e) { 
     270          CKEDITOR.instances[id].on('focus',function(e) { 
    232271               $.active_editor = e.editor.name; 
    233272          }); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map