fckeditor提示"未知命令名称"高手帮忙解决

chenwei175528 2009-07-28 09:32:47
我在试着给fckeditor添加一个自定义的功能,代码是从网上找的

网上找的代码我不确定是否有问题,我感觉这段代码应该没问题,因为我在自己写
自定义插件或自定义功能的时候,也出现“未知命令名称”或“未知工具栏项目”的提示。

大家给解决下,或者提点建议?

menu的code

FCKConfig.ToolbarSets["Basic"] = [
['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About','Format168']
] ;


插件的配置文件

FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;
FCKConfig.Plugins.Add('formatcommands') ;


fckcommands文件夹下的fckplugin.js

var oFormat168Item = new FCKToolbarButton('Format168', FCKLang.Format168Btn);

oFormat168Item.IconPath = FCKPlugins.Items['formatcommands'].Path + 'format168.gif';

FCKToolbarItems.RegisterItem('Format168', oFormat168Item);

// The object used for all Format168 operations.
var FCKFormat168 = new Object();

FCKFormat168 = function(name){
this.Name = name;
}

FCKFormat168.prototype.GetState = function() {

return FCK_TRISTATE_OFF;
}

FCKFormat168.prototype.Execute = function(){
FormatText();
}

function FormatText() {
var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
{
var temps = new Array();
var sec = oEditor.EditorDocument.selection.createRange();
var tmpText = sec.text;
var isPart = tmpText != null && tmpText.trim().length > 0;
isPart = false;
if (!isPart) {
var imgs = oEditor.EditorDocument.images;
if (imgs != null && imgs.length > 0) {
for (j = 0; j < imgs.length; j++) {
var t = document.createElement("IMG");
t.alt = imgs[j].alt;
t.src = imgs[j].src;
t.width = imgs[j].width;
t.height = imgs[j].height;
t.align = imgs[j].align;
temps[temps.length] = t;
}
var formatImgCount = 0;
for (j = 0; j < imgs.length;) {
imgs[j].outerHTML = "#FormatImgID_" + formatImgCount + "#";
formatImgCount++;
}
}
var html = processFormatText(oEditor.EditorDocument.body.innerText);
if (temps != null && temps.length > 0) {
for (j = 0; j < temps.length; j++) {
var imghtml = "<img src=\"" + temps[j].src + "\" alt=\"" + temps[j].alt + "\" width=\"" + temps[j].width + "\" height=\"" + temps[j].height + "\" align=\"" + temps[j].align + "\">";
html = html.replace("#FormatImgID_" + j + "#", imghtml);
}
}
oEditor.SetHTML(html);
} else {
var html = processFormatText(tmpText);
sec.pasteHTML(html);
}
}
else
alert( 'alert' ) ;
}

function DBC2SBC(str) {
var result = '';
for (var i = 0; i < str.length; i++) {
code = str.charCodeAt(i);

if (code >= 65281 && code < 65373 && code != 65292 && code != 65306){

result += String.fromCharCode(str.charCodeAt(i) - 65248);
} else {
result += str.charAt(i);
}
}
return result;
}

function processFormatText(textContext) {
var text = DBC2SBC(textContext);
var prefix = "  ";
var tmps = text.split("\n");
var html = "";
for (i = 0; i < tmps.length; i++) {
var tmp = tmps[i].trim();
if (tmp.length > 0) {
html += "<p>  " + tmp + "</p>\n";
}
}
return html;
}

String.prototype.trim = function()
{
return this.replace(/(^[\s ]*)|([\s ]*$)/g, "");
};

String.prototype.leftTrim = function()
{
return this.replace(/(^\s*)/g, "");
};

String.prototype.rightTrim = function()
{
return this.replace(/(\s*$)/g, "");
};


// Register the related command
FCKCommands.RegisterCommand('Format168', new FCKFormat168('Format168'));
...全文
140 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenwei175528 2009-07-28
  • 打赏
  • 举报
回复
已解决

我太粗心了

把好几个关键字都写错了...
chenwei175528 2009-07-28
  • 打赏
  • 举报
回复
up

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧