2010-03-25 118 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);以免瀏覽器處理它。