zoukankan      html  css  js  c++  java
  • fckeditor只读状态下回车仍可输入的BUG

      我对Fckeditor设置为不可编辑状态,但仍可以通过ENTER或SHIFT+ENTER产生p或者br标签。如下是fckeditor设置为只读状态的代码。

    <script type="text/javascript">
    
    window.onload = function()
    {
        var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ;
    
        var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
        oFCKeditor.Config["AutoHeight"] = false;
        oFCKeditor.Config['ToolBarLess'] = 'Basic';
        oFCKeditor.Config["ToolbarStartExpanded"] = true;
        oFCKeditor.ToolbarSet = 'ComposeEmailReadOnly';
        //oFCKeditor.ToolbarSet = 'Advance';
        oFCKeditor.BasePath    = sBasePath ;
        oFCKeditor.ReplaceTextarea() ;
    }
    function FCKeditor_OnComplete( editor ) {
        editor.EditorDocument.body.contentEditable = false;
        editor.EditMode=FCK_EDITMODE_SOURCE;
        editor.ToolbarSet.RefreshModeState();
        editor.EditMode=FCK_EDITMODE_WYSIWYG;
        editor.ToolbarSet.RefreshModeState();
    } 
    </script>

      查看FCK的配置,并没有发现有方法可以解决这一问题。于是只好硬着头皮修改下源码。

    大概修改如下,修改fckenterkey.js文件。请看红色部分。

    var FCKEnterKey = function( targetWindow, enterMode, shiftEnterMode, tabSpaces )
    {
        this.Window            = targetWindow ;
        this.EnterMode        = enterMode || 'p' ;
        this.ShiftEnterMode    = shiftEnterMode || 'br' ;
    
        .........
    
    FCKEnterKey.prototype.DoEnter = function( mode, hasShift )
    {
        // Save an undo snapshot before doing anything
        FCKUndo.SaveUndoStep() ;
    
        this._HasShift = ( hasShift === true ) ;
    
        var parentElement = FCKSelection.GetParentElement() ;
        var parentPath = new FCKElementPath( parentElement ) ;
        var sMode = mode || this.EnterMode ;  

        if (sMode == '')  return;

    if ( sMode == 'br' || parentPath.Block && parentPath.Block.tagName.toLowerCase() == 'pre' )
            return this._ExecuteEnterBr() ;
        else
            return this._ExecuteEnterBlock( sMode ) ;
    }
    
    ...................

      修改后,使用js压缩工具进行压缩并更改到fckeditorcode_XXX.js文件中即可。

      然后使用时在只读状态的编辑吕配置中加入如下:

    editor.Config["EnterMode"] = '';
    editor.Config["ShiftEnterMode"] = '';

      个人水平有限,这并不是个很好的办法,但可以解决到这个bug的问题。

      欢迎拍砖!!!

     

  • 相关阅读:
    创建包含前后255天所有天数的视图。
    VC获取主机名和主机信息
    在PowerDesigner增加unique约束
    差集的几种计算方法
    动态列的处理(统计)。
    一个查询语句各个部分的执行顺序
    IDC机房跳线
    软件下载链接
    IDC装机检查思路
    运维工程师之IDC系列
  • 原文地址:https://www.cnblogs.com/zhangchaozheng/p/2607840.html
Copyright © 2011-2022 走看看