1.在fckplugin.js中,可以直接引用FCK对象进行各种操作。
2.弹窗型的插件,使用如下注册方式:
FCKCommands.RegisterCommand('PluginName',new FCKDialogCommand(parameters...));
3.选区型插件(Selection Based)似乎没有可以直接使用的Command类型,so,自己动手写一个也挺简单:
var FCKPLinkCommand = function(){}
FCKPLinkCommand.prototype = {
Name: 'PLink',
Execute:function(parameters...){},
GetState:function(){}
};
再传入注册函数即可:
FCKCommands.RegisterCommand('PLink',new FCKPLinkCommand(parameters...));
4.FCK中的函数都是大写开头的,JavaScript内致函数,都是小写开头的。例如Selection是FCK提供的,selection是JavaScript提供的。
5.工具栏图标的大小是16x16相素,如果图标大了,火狐会自动调节,IE嘛,被截掉一段。
6.选区操作区分浏览器。
IE:FCK.EditorDocument.selection.createRange().text;
火狐:FCK.EditorWindow.getSelection();
更多关于选区操作的函数参考这里:http://hi.baidu.com/17docnet/blog/item/a2ea22f4eede7422bc310988.html
摘录如下:
FCKeditor Selection 对象使用举例:
// The selection object
FCKeditorAPI.GetInstance("FCKeditor").Selection
// properties
FCKeditorAPI.GetInstance("FCKeditor").Selection.GetType();
FCKeditorAPI.GetInstance("FCKeditor").Selection.GetSelectedElement();
FCKeditorAPI.GetInstance("FCKeditor").Selection.GetParentElement(); // Doesn't seem to be working in Fx when the selection is only one character
// methods
// select node, e.g. select the parent node
FCKeditorAPI.GetInstance("FCKeditor").Selection.SelectNode(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetParentElement());
// Move cursor position before (toStart = true, default) or after (toStart = false) the selection
FCKeditorAPI.GetInstance("FCKeditor").Selection.Collapse(toStart);
// Check if the selection has a specified ancestor node, returns true or false. The "nodeTagName" parameter must be Upper Case.
alert(FCKeditorAPI.GetInstance("FCKeditor").Selection.HasAncestorNode(nodeTagName));
// Move selection to ancestor node. The "nodeTagName" parameter must be Upper Case.
FCKeditorAPI.GetInstance("FCKeditor").Selection.MoveToAncestorNode(nodeTagName);
// Delete selection
FCKeditorAPI.GetInstance("FCKeditor").Selection.Delete();
// so to get the element that is selected, first check the type of the selection
// Doesn't seem to be working in Fx when the selection is only one character - This is due to some bug in the 'GetParentElement' method
if(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetType() == 'Control')
{
alert(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetSelectedElement());
}
else if(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetType() == 'Text')
{
alert(FCKeditorAPI.GetInstance("FCKeditor").Selection.GetParentElement());
}
// Fetching the actual content of the selection can't be done through the 'Selection' Object...
if (document.all)
{
alert(FCKeditorAPI.GetInstance("FCKeditor").EditorDocument.selection.createRange().text);
}
else
{
alert(oSel = FCKeditorAPI.GetInstance("FCKeditor").EditorWindow.getSelection());
}
API参考:
GetParentBlock = function(){var A=this.GetParentElement();while (A){if (FCKListsLib.BlockBoundaries[A.nodeName.toLowerCase()]) break;A=A.parentNode;};return A;}
ApplyStyle = function(A){FCKStyles.ApplyStyle(new FCKStyle(A));}
GetType = function(){try{var A=FCK.EditorDocument.selection.type;if (A=='Control'||A=='Text') return A;if (FCK.EditorDocument.selection.createRange().parentElement) return 'Text';}catch(e){};return 'None';}
GetSelectedElement = function(){if (this.GetType()=='Control'){var A=FCK.EditorDocument.selection.createRange();if (A&&A.item) return FCK.EditorDocument.selection.createRange().item(0);};return null;}
GetParentElement = function(){switch (this.GetType()){case 'Control':var A=FCKSelection.GetSelectedElement();return A?A.parentElement:null;case 'None':return null;default:return FCK.EditorDocument.selection.createRange().parentElement();}}
GetBoundaryParentElement = function(A){switch (this.GetType()){case 'Control':var B=FCKSelection.GetSelectedElement();return B?B.parentElement:null;case 'None':return null;default:var C=FCK.EditorDocument;var D=C.selection.createRange();D.collapse(A!==false);var B=D.parentElement();return FCKTools.GetElementDocument(B)==C?B:null;}}
SelectNode = function(A){FCK.Focus();FCK.EditorDocument.selection.empty();var B;try{B=FCK.EditorDocument.body.createControlRange();B.addElement(A);}catch(e){B=FCK.EditorDocument.body.createTextRange();B.moveToElementText(A);};B.select();}
Collapse = function(A){FCK.Focus();if (this.GetType()=='Text'){var B=FCK.EditorDocument.selection.createRange();B.collapse(A==null||A===true);B.select();}}
HasAncestorNode = function(A){var B;if (FCK.EditorDocument.selection.type=="Control"){B=this.GetSelectedElement();}else{var C=FCK.EditorDocument.selection.createRange();B=C.parentElement();};while (B){if (B.tagName==A) return true;B=B.parentNode;};return false;}
MoveToAncestorNode = function(A){var B,oRange;if (!FCK.EditorDocument) return null;if (FCK.EditorDocument.selection.type=="Control"){oRange=FCK.EditorDocument.selection.createRange();for (i=0;i
Delete = function(){var A=FCK.EditorDocument.selection;if (A.type.toLowerCase()!="none"){A.clear();};return A;}
7.editor/_source/commandclass/fck_othercommands.js这里定义了FCKDialogCommand。
editor/_source/internal/fckcommands.js这里定义了大部分命名的Command,例如Source,Preview,Save等等在commandclass文件夹下找不到的command.