zoukankan      html  css  js  c++  java
  • Fckeditor编辑区域高度固定

      fckeditor提供了编辑器高度的设置,但是只对整个编辑器,包括工具条。另外它也提供了一个插件autogrow,处理编辑器高度的自适应。

      但目前这边有个需求,需要只固定可编辑区域高度。上面所述无法满足,尝试修改源码增加这个配置。

      修改办法如下:

      1.修改fckconfig.js,在文件最后增加:

    FCKConfig.AutoHeight = true;    //也可以默认为false

      2.修改fcktoolbarset.js,增加如下红色代码:

      function FCKToolbarSet_Create( overhideLocation )
      {
          var oToolbarSet ;
          var initHeight;
          var sLocation = overhideLocation || FCKConfig.ToolbarLocation ;
          …………………………………………………………………………………….
      
      var FCKToolbarSet = function( targetDocument )
      {
          this._Document = targetDocument ;
          initHeight = parseInt(parent.document.getElementById(FCK.Name+ '___Frame').style.height, 10);
          // Get the element that will hold the elements structure.
          this._TargetElement    = targetDocument.getElementById( 'xToolbar' ) ;
          
          // Setup the expand and collapse handlers.
          var eExpandHandle    = targetDocument.getElementById( 'xExpandHandle' ) ;
          var eCollapseHandle    = targetDocument.getElementById( 'xCollapseHandle' ) ;
      
      ……………………………………………………
      
      FCKToolbarSet.prototype._ChangeVisibility = function( collapse )
      {
          this._Document.getElementById( 'xCollapsed' ).style.display = collapse ? '' : 'none' ;
          this._Document.getElementById( 'xExpanded' ).style.display = collapse ? 'none' : '' ;
          var toolbarHeight = this._Document.getElementById( 'xToolbar' ).scrollHeight;
      
          if(FCKConfig.AutoHeight) {
              if (collapse) {
                  if ( !FCKConfig.ToolbarCanCollapse || FCKConfig.ToolbarStartExpanded ) {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight - toolbarHeight+10 +'px';
                  }else {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight + 'px';    
                  }
              } else {                
                  if ( !FCKConfig.ToolbarCanCollapse || FCKConfig.ToolbarStartExpanded ) {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight+"px";
                  }else {
                      parent.document.getElementById(FCK.Name+'___Frame').style.height=initHeight + toolbarHeight -10+ 'px';    
                  }
              }
          }
          
          if ( window.onresize )
          {
              // I had to use "setTimeout" because Gecko was not responding in a right
              // way when calling window.onresize() directly.
              FCKTools.RunFunction( window.onresize ) ;
          }
      }
      
    …………………………………………………

      3.压缩fcktoolbarset.js并将修改移到fckeditorcode_XXXX.js中

      默认固定编辑区域高度,如要取消这功能,只需要在配置中加入:editor.Config["AutoHeight"] = false;

      至此,功德圆满。技术有限,欢迎拍砖!

  • 相关阅读:
    Kubernetes学习之路(21)之网络模型和网络策略
    Kubernetes学习之路(16)之存储卷
    Kubernetes学习之路(18)之statefulset控制器
    Kubernetes学习之路(28)之镜像仓库Harbor部署
    Kubernetes学习之路(六)之创建K8S应用
    Kubernetes学习之路(十五)之Ingress和Ingress Controller
    nali一款linux下显示IP来源的小工具
    Redis 及RedisBloom 安装
    对java注解与反射的理解
    Java 8 stream的详细用法
  • 原文地址:https://www.cnblogs.com/zhangchaozheng/p/2608125.html
Copyright © 2011-2022 走看看