FCKeditor提供了一個完整的JavaScript API

來源:互聯網
上載者:User

FCKeditor offers a complete JavaScript API so you can interact with it once the editor is loaded and running.
FCKeditor提供了一個完整的JavaScript API(Application Public Interface),你可以利用這些API來處理FCK編輯器,只要它被載入完成或在正在運行中.
Retrieving an editor instanceOnce loaded, the editor registers a global object called 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". So, to retrieve it, you must simply call the FCKeditorAPI.GetInstance method.
一旦編輯器執行個體化完成後,它都會註冊一個全域的對象,叫作FCKeditorAPI. 這個對象提供一個存取點去擷取在本頁面內的任何已執行個體化的對象(不止一個).當你在頁面產生一個編輯器時,你給了它一個執行個體名.所以,你只需簡單地調用 FCKeditorAPI.GetInstance方法就可以擷取到它的對象引用.
For example: var oEditor = FCKeditorAPI.GetInstance('InstanceName') ;
例如,var oEditor = FCKeditorAPI.GetInstance('InstanceName') ; 這裡就是擷取執行個體名為"InstanceName"的FCKeditor對象.
The GetInstance method returns the main FCKeditor object that gives the necessary bridge to interact with it.
This is a list of properties and methods of this object:
這是一個FCKeditor的屬性和方法的列表:

複製代碼 代碼如下:* 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()

EventsOnce 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. 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.
For example, the following code listens for the "OnSelectionChange" to execute custom code:
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). Note: In IE6, this event does not fire on every keystroke, but only on some random keystrokes. Handy!
OnAfterSetHTML: fired once the HTML is loaded in the editor (including when changing views).
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.
OnPaste: fired when something is pasted in the editor
配置選項:
AutoDetectLanguage=true/false 自動檢測語言
BaseHref="" _fcksavedurl="""" 相對連結的基地址
ContentLangDirection="ltr/rtl" 預設文字方向
ContextMenu=字串數組,右鍵菜單的內容
CustomConfigurationsPath="" 自訂設定檔路徑和名稱
Debug=true/false 是否開啟調試功能,這樣,當調用FCKDebug.Output()時,會在調試窗中輸出內容
DefaultLanguage="" 預設語言
EditorAreaCss="" 編輯區的樣式表檔案
EnableSourceXHTML=true/false 為TRUE時,當由可視化介面切換到字碼頁時,把HTML處理成XHTML
EnableXHTML=true/false 是否允許使用XHTML取代HTML
FillEmptyBlocks=true/false 使用這個功能,可以將空的區塊層級元素用空格來替代
FontColors="" 設定顯示顏色拾取器時文字顏色列表
FontFormats="" 設定顯示在文字格式列表中的命名
FontNames="" 字型列表中的字型名
FontSizes="" 字型大小中的字型大小列表
ForcePasteAsPlainText=true/false 強制粘貼為純文字
ForceSimpleAmpersand=true/false 是否不把&符號轉換為XML實體
FormatIndentator="" 當在源碼格式下縮排代碼使用的字元
FormatOutput=true/false 當輸出內容時是否自動格式化代碼
FormatSource=true/false 在切換到程式碼檢視時是否自動格式化代碼
FullPage=true/false 是否允許編輯整個HTML檔案,還是僅允許編輯BODY間的內容
GeckoUseSPAN=true/false 是否允許SPAN標記代替B,I,U標記
IeSpellDownloadUrl=""下載拼字檢查器的網址
ImageBrowser=true/false 是否允許瀏覽伺服器功能
ImageBrowserURL="" 瀏覽伺服器時啟動並執行URL
ImageBrowserWindowHeight="" 映像瀏覽器視窗高度
ImageBrowserWindowWidth="" 映像瀏覽器視窗寬度
LinkBrowser=true/false 是否允許在插入連結時瀏覽伺服器
LinkBrowserURL="" 插入連結時瀏覽伺服器的URL
LinkBrowserWindowHeight=""連結目標瀏覽器視窗高度
LinkBrowserWindowWidth=""連結目標瀏覽器視窗寬度
Plugins=object 註冊外掛程式
PluginsPath="" 外掛程式檔案夾
ShowBorders=true/false 合并邊框
SkinPath="" 皮膚檔案夾位置
SmileyColumns=12 圖符窗列數
SmileyImages=字元數組 圖符窗中圖片檔案名稱數組
SmileyPath="" 圖符檔案夾路徑
SmileyWindowHeight 圖符視窗高度
SmileyWindowWidth 圖符視窗寬度
SpellChecker="ieSpell/Spellerpages" 設定拼字檢查器
StartupFocus=true/false 開啟時FOCUS到編輯器
StylesXmlPath="" 設定定義CSS樣式列表的XML檔案的位置
TabSpaces=4 TAB鍵產生的空白字元數
ToolBarCanCollapse=true/false 是否允許展開/摺疊工具列
ToolbarSets=object 允許使用TOOLBAR集合
ToolbarStartExpanded=true/false 開啟是TOOLBAR是否展開
UseBROnCarriageReturn=true/false 當斷行符號時是產生BR標記還是P或者DIV標記

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.