您的位置:首页 > 其它

fckeditor全局api及中文翻译

2010-06-25 17:18 387 查看
试试翻译水平。。。

fckeditor看了几天,头都大了。。。

FCKeditor offers a complete JavaScript API so you can interact with it once the editor is loaded and running.
fckeditor提供了一个完全的javascript api,一旦编辑器被加载运行,你就可以使用这些api与它交互。

Retrieving an editor instance.
得到一个编辑器的实例。
Once loaded, the editor registers a global object called FCKeditorAPI.
一旦加载,编辑器生成了一个叫做fckeditorapi的全局对象。
This object offers the entry point to interact with any editor instance placed in a page (you can have more than one).
这个对象提供与任何放置在一个页面(你可以拥有多于一个的页面)里的编辑器实例进行交互的入口。
When placing the editor in the page, you give it an "instance name".
当你把一个编辑器放在页面里的时候,你给它命名为"instance name"
So, to retrieve it, you must simply call the FCKeditorAPI.GetInstance method. For example:
所以,为了获取它,你只须简单地调用FCKeditorAPI.GetInstance方法。例如:

var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;

The returned object
The GetInstance method returns the main FCKeditor object that gives the necessary bridge to interact with it.
getinstance方法返回了fckeditor对象,它可以提供必要的桥梁用来交互。
This is a list of properties and methods of this object:
下面是这个对象的属性和方法:

* Description = string
* EditMode = Integer
* Name = string
* Status = Integer
* function AttachToOnSelectionChange(functionPointer)
* function CleanAndPaste(html)
* function CreateElement(tag)
* function CreateLink(url)
* function ExecOnSelectionChange() //Fires OnSelectionChange event in event manager
* function ExecOnSelectionChangeTimer()
* function ExecuteNamedCommand(commandName, commandParameter)
* function ExecuteRedirectedNamedCommand(commandName, commandParameter)
* function Focus()
* function GetHTML(format) // doesnt work. Use GetXHTML instead.
* function GetNamedCommandState(commandName)
* function GetNamedCommandValue(commandName)
* function GetXHTML(format)
* function InitializeBehaviors()
* function InsertElement(element)
* function InsertElementAndGetIt(e)
* function InsertHtml(html)
* function IsDirty();
* function MakeEditable()
* function OnDoubleClick(element)
* function Paste()
* function PasteAsPlainText()
* function PasteFromWord()
* function Preview()
* function RegisterDoubleClickHandler(handlerFunction, tag)
* function ResetIsDirty();
* function SetHTML(html, forceWYSIWYG)
* function SetStatus()
* function ShowContextMenu(x, y)
* function SwitchEditMode()
* function UpdateLinkedField()

Events.
事件
Once the editor loading is complete and it is ready to use (and interact with JavaScript), a standard function is called in the page that contains the editor, if the function is defined.
当编辑器加载完成并且准备使用后,在包含这个编辑器的页面,一个标准的函数被调用,如果这个函数被定义了。
This function must be named "FCKeditor_OnComplete" and receives the related editor instance as the parameter.
这个函数必须被命名为FCKeditor_OnComplete,而且以与它相关联的编辑器实例作为参数。
Using it, you can execute any initial code that makes the initial interaction with the editor.
使用它,你可以执行任何初始化代码。作用是初始化编辑器的行为。
This is a declaration example:

function FCKeditor_OnComplete( editorInstance )
{
alert( editorInstance.Name ) ;
}

Apart the above standard event, every FCKeditor instance has a "Event" object that can be used to listen for events to be fired.
在标准事件部分,每个编辑器实例有一个叫做event的对象用来监听可能发生的事件。
For example, the following code listens for the "OnSelectionChange" to execute custom code:
例如,下面的代码监听用户的OnSelectionChange事件。

var counter = 0 ;
function DoSomething( editorInstance )
{
window.document.title = editorInstance.Name + ' : ' + ( ++counter ) ;
}
function FCKeditor_OnComplete( editorInstance )
{
editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
}

Note that every callback function receives the editor instance as a parameter.
注意每个回调函数用编辑器实例做为参数
The following is the list of events available:
下面是一些可用的事件方法列表
OnSelectionChange: fired when the actual selection in the editor area changes (by selection I mean the cursor position too... it changes on key strokes).
OnSelectionChange:当编辑器的area变化时,我的意思是也包括当前的光标位置,在键盘按下或弹起时。
Note: In IE6, this event does not fire on every keystroke, but only on some random keystrokes. Handy!
注意:在ie6下,这个事件不会响应每一个按键事件,只是会随机响应。。。好灵活。。。
OnAfterSetHTML: fired once the HTML is loaded in the editor (including when changing views).
在html加载时响应,包括改变视图时。
OnStatusChange: fired when the editor status changes.
在编辑器状态改变时。
The following constants are also available globally in the page: FCK_STATUS_NOTLOADED, FCK_STATUS_ACTIVE and FCK_STATUS_COMPLETE.
下面这几个常量在页面里全局有作用。
FCK_STATUS_NOTLOADED, FCK_STATUS_ACTIVE and FCK_STATUS_COMPLETE

OnPaste: fired when something is pasted in the editor
发生在编辑器粘贴时
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: