Kind Editor Documentation

Kind Editor API

Variables
  1. KE
    Global variable/namespace.
    Type:Object
  2. KE.version
    Editor version.
    Type:String
  3. KE.lang
    Language information.
    Type Object
  4. KE.scriptPath
    Path of kindeditor.js.
    Type:String
  5. KE.browser
    Browser type/version information. KE.browser.VERSION, KE.browser.IE, KE.browser.WEBKIT, KE.browser.GECKO, KE.browser.OPERA
    Type:Object
  6. KE.setting
    Editor configuration information.
    Type:Object
  7. KE.g
    Colloction of editor variables, including all attributes defined here , as well as the following variables. These variables can be access by KE.g[id].
    For example:KE.g["content_1"].iframeDoc is editor(with id "content_1") iframe document object.
    Type:Object
    Member Variables:
    • container: Editor parent element.
    • iframe: Editor iframe object.
    • iframeWin: Window object of editor iframe.
    • iframeDoc: Document object of editor iframe.
    • keSel: Current KE.selection object.
    • keRange: Current KE.range object.
    • sel: Current browser selection object.
    • range: Current browser range object.
    • hideDiv: Parent div object of popup dialog.
    • yesButton: [Yes] button of popup dialog.
    • noButton: [No] button of pouup dialog.
    • previewButton: [Preview] button of pouup dialog.
    • maskDiv: Gray mask(div) for popup dialog.
    • undoStack: Undo records.
    • redoStack: Redo records.
  8. KE.plugin
    Plugins loaded.
    Type:Object
Functions
  1. KE.$(id, doc)
    To get element by id. Equal to doc.getElementById.
    Parameters
    id:String. Id of element.
    doc:Object, document object where element is at. Optional, document by default
    return:
    Object,element object
  2. KE.$$(name, doc)
    Create element object, Equal to doc.createElement.
    Parameters
    name:String,element tag name
    doc:Object,document object where element is at. Optional, document by default.
    return:
    Object,element object
  3. KE.event.add(el, event, listener)
    Add event listener to an element.
    Parameters
    el:Object, listener to be added to.
    event:String, event type, for example, "click","change","mousedown".
    listener:Function, event handler.
    return:none
  4. KE.event.remove(el, event, listener)
    Remove event listener from an element.
    Parameters
    el:Object, listener to be removed from.
    event:String,event type, for example, "click","change","mousedown".
    listener:Function, event handler.
    return:none
  5. KE.event.input(el, func)
    Add listener for end user inputting.
    Parameters
    el:Object, listener to be added to.
    func:Function, event handler for user inputting.
    return:none
  6. KE.event.ctrl(el, key, func)
    Add event listener for Ctrl+[?] event.
    Parameters
    el:Object,listener to be added to.
    key:String, alpha from A to Z.
    func:Function,event handler.
    return:none
  7. KE.event.ready(func)
    Add event listener for DOMContentLoaded of document or equivalence.
    Parameters
    func:Function, event handler.
    return:none
  8. KE.each(obj, func)
    Go through all the members of an object, and apply func to these memebers.
    Parameters
    obj:Object, object to go through
    func:Function, function applied to members. Parameters are key/value.
    return:none
  9. KE.eachNode(node, func)
    Go through all the children of a node.
    Parameters
    node:Object, parent node to go through
    func:Function, function applied to children. Paramter is node(children node)
    return:none
  10. KE.format.getHtml(html, htmlTags)
    Convert HTML to XHTML. When htmlTags is specified, those not defined in htmlTags will be ignored.
    Parameters
    html:String. HTML to be convert.
    htmlTags:Object. Filter criteria, optional.
    return:
    String,XHTML string.
  11. KE.util.getDocumentElement()
    Get document element object.
    Parameters:none
    return:
    Object,element object
  12. KE.util.getDocumentWidth()
    Get width of current page.
    Parameters:none
    return:
    Int,document width, in pixel.
  13. KE.util.getDocumentHeight()
    Get height of current page.
    Parameters:none
    return:
    Int,document height.
  14. KE.util.loadStyle(path)
    Load a css file into current page.
    Parameters
    path:String. URL of css.
    return:none
  15. KE.util.inArray(str, arr)
    Determine if string exists in an array.
    Parameters
    str:String
    arr:Array
    return:
    Boolean, true for existing.
  16. KE.util.trim(str)
    This function returns a string with whitespace stripped from the beginning and end of str.
    Parameters
    str:String
    return:String
  17. KE.util.getJsKey(key)
    Convert css attributes in CSS to JavaScript class member name. For example, KE.util.getJsKey("font-size") will return "fontSize".
    Parameters
    key:String
    return:String
  18. KE.util.escape(html)
    Escape special character in HTML string.
    Parameters
    html:String,HTML string.
    return:String
  19. KE.util.getElementPos(el)
    Get cordinate of an element.
    Parameters
    el:Object,element object
    return:Object
  20. KE.util.getCoords(ev)
    Get cursor coordination.
    Parameters
    ev:Object, event object
    return:Object
  21. KE.util.setOpacity(el, opacity)
    Set element opacity.
    Parameters
    el:Object,element
    opacity:Int. Opacity index, range from 0 ot 100.
    return:none
  22. KE.util.getIframeDoc(iframe)
    Get iframe document object.
    Parameters
    iframe:Object,iframe
    return:Object
  23. KE.util.rgbToHex(str)
    Convert RGB color formate to Hex formate.
    Parameters
    str:String,RGB color.
    return:String
  24. KE.util.createRange(doc)
    Create range for doc.
    Parameters
    doc:Object,document object
    return:Object,range object
  25. KE.util.getFullHtml(id, tagLineMode)
    Get initial html text from editor's iframe.
    Parameters
    id:String. Editor id.
    tagLineMode:Boolean,true for displaying tag's outline.
    return:String
  26. KE.util.getData(id)
    Get HTML from editor.
    Parameters
    id:String. Editor id.
    return:String
  27. KE.util.getSrcData(id)
    Get raw HTML from editor. That equals to innerHTML of editor's iframe.
    Parameters
    id:String. Editor id.
    return:String
  28. KE.util.getPureData(id)
    Get text from editor without html tag.
    Parameters
    id:String. Editor id.
    return:String
  29. KE.util.setData(id)
    Fill TEXTAREA with html generated by editor.
    Parameters
    id:String. Editor id.
    return:none
  30. KE.util.focus(id)
    Let editor get focus.
    Parameters
    id:String, editor id.
    return:none
  31. KE.util.selection(id)
    Save current selection to KE.g[id].sel,KE.g[id].range,KE.g[id].keSel,KE.g[id].keRange.
    Parameters
    id:String,ID of editor.
    return:none
  32. KE.util.select(id)
    Select an range, for IE only.
    Parameters
    id:String, editor id.
    return:none
  33. KE.util.execCommand(id, cmd, value)
    Execute browser command. See API of document.execCommand for different browser.
    Parameters
    id:String, id of editor.
    cmd:String, same as execCommand of browser.
    value:String, same as execCommand of browser.
    return:none
  34. KE.util.insertHtml(id, html)
    Insert HTML to current cursor.
    Parameters
    id:String. Id of editor
    html:String. HTML to be inserted.
    return:none
    KE.util.selection(id) must be called before this function is called, because KE.g[id].sel and KE.g[id].range need to be set.
  35. KE.create(id, mode)
    Create an editor.
    Parameters
    id:String. Id of editor.
    mode:Int. Optional. 1 for creating editor at the end of body section. 0 or default for creating editor in front of TEXTAREA.
    return:none
  36. KE.remove(id, mode)
    Remove editor.
    Parameters
    id:String. Editor id.
    mode:Int. Optional. 1 for removing editor at the end of body section. 0 or default for removing editor in front of TEXTAREA.
    return:none
  37. KE.init(config)
    Set configuration for initialization.
    Parameters
    config:Object. Editor attributes. See attributes for more.
    return:none
  38. KE.show(config)
    Create and show editor up. This function will call KE.init first. When dom is loaded, KE.create will be call to show editor.
    Parameters
    config:Object. Editor attributes. See attributes for more.
    return:none
Classes
  1. KE.selection(win, doc)
    KindEditor selection class for get/set current range.
    Parameters
    win:Object,window object
    doc:Object,document object
    Member properties:
    • sel:Object. Browser selection object of current selection.
    • range:Object. Browser range object of current selection.
    • keRange:Object. KindEditor range object of current selection. See KE.range for more.
    Member method:
    • addRange(keRange): Set current selection.
    • focus(): Reselect. IE supported only.
  2. KE.range(doc)
    Universal range class for different types of browsers.
    Parameters
    doc:Object,document object
    Member properties:
    • startNode:Object. Start node.
    • startPos:Int. Position of start node.
    • endNode:Object. End node.
    • endPos:Int. Position of end node.
    Member method:
    • getParentElement(): Get direct paren node that holds range.
    • getNodeList(): Get node list within range.
    • comparePoints(how, range): Compare with opsition of another range. Parameter how could be "START_TO_START", "START_TO_END", "END_TO_START","END_TO_END".
    • setStart(node, pos): Set start point of range.
    • setEnd(node, pos):Set end point of range.
    • selectNode(node):Set one node as range's start point and end point.
    • extractContents():Extract content form range.
    • cloneContents():Copy content of range.
    • getText():Get text from range.
  3. KE.cmd(id)
    KindEditor command class.
    Parameters
    id:String. Editor id.
    Member properties:
    • doc:Object. Document of editor iframe.
    • keSel:Int. Kind editor selection object
    • keRange:Object. KindEditor range object of current selection
    Member method:
    • wrap(tagName, attributes): Wrap current selection with given tagName. Inline tag supported only. Parameter tagName is tag name. Parameter attributes is a attribute array for tagName.
    • remove(tags): Remove tags from current selection.