2010-03-25 116 views
0

我试图解决Nicedit,特别是“removeFormat”函数。帮助Nicedit - removeFormat函数

问题是我无法在下面的代码中找到“removeFormat”方法源代码。 JS语法对我来说看起来很奇怪。有人能帮我吗 ?

对不起,代码太长。 Nicedit在这里:http://nicedit.com/download.php

以下是我在'源代码中的removeFormat'中找到的内容。但没有“removeformat”命令??! :

var nicEditorConfig = bkClass.extend({ 
buttons: { 
    'removeformat': { 
     name: __('Supprimer la mise en forme'), 
     command: 'removeformat', 
     noActive: true 
    } 
}, 
iconsPath: 'http://js.nicedit.com/nicEditIcons-latest.gif', 
buttonList: ['save', 'bold', 'italic', 'underline', 'left', 'center', 'right', 'justify', 'ol', 'ul', 'fontSize', 'fontFamily', 'fontFormat', 'indent', 'outdent', 'image', 'upload', 'link', 'unlink', 'forecolor', 'bgcolor'], 
iconList: { 
    "xhtml": 1, 
    "bgcolor": 2, 
    "forecolor": 3, 
    "bold": 4, 
    "center": 5, 
    "hr": 6, 
    "indent": 7, 
    "italic": 8, 
    "justify": 9, 
    "left": 10, 
    "ol": 11, 
    "outdent": 12, 
    "removeformat": 13, 
    "right": 14, 
    "save": 25, 
    "strikethrough": 16, 
    "subscript": 17, 
    "superscript": 18, 
    "ul": 19, 
    "underline": 20, 
    "image": 21, 
    "link": 22, 
    "unlink": 23, 
    "close": 24, 
    "arrow": 26, 
    "upload": 27, 
    "question":2 
} 

});`

回答

1

同样的问题在这里,神秘..
有没有像在源 'removeformat' 或 'removeFormat' 被发现。不过,我找到了原因:

许多命令字符串被重定向到这个功能:

nicCommand : function(cmd,args) { 
    document.execCommand(cmd,false,args); 
} 

execCommand被许多主流浏览器(包括IE)的支持。

+0

是的,你懂了! Nicedit使用浏览器内部命令。 – Franck 2010-09-07 13:37:04

0

命令removeFormat不在代码,这可以解释为什么你不能找到它:)

它实际上是一个ExecCommand函数浏览器实现。

请参阅http://www.quirksmode.org/dom/execCommand.html了解每个浏览器支持的命令列表(尽管有点过时)。

因此,要完成答案,所有nicedit做的是调用命令execCommand(removeFormat,false,null);以免浏览器处理它。