• 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的问题。

      欢迎拍砖!!!

     

  • 相关阅读:
    云主机上搭建squid3代理服务器
    常见问题集锦
    [DFNews] Guidance推出EnCase v7.06以及EnCase Imager 7.06
    [计算机取证] JumpLists file names and AppID calculator
    [eDiscovery] The Longterm Preservation of Digital Evidence
    [DFNews] GSI发布EnCase v7.07
    [DFNews] eDEC发布“狼蛛”2.0手机取证系统
    [手机取证] CelleBrite Android Lock Bypass
    [DFNews] CelleBrite发布可视化关联分析软件Link Analysis 1.7
    [DFNews] EnCE认证变化,v6认证及相关课程即将取消
  • 原文地址:https://www.cnblogs.com/zhangchaozheng/p/2607840.html
Copyright © 2020-2023  润新知