Main javascript functions of WYM editor.

Global variables

  • var selectedElement=null;
  • var bCleanPaste=true;

Initialisation (called at body.onload)

  • function init()

These functions return base objects from the interface

  • function editor()
  • function txthtml()
  • function container()
  • function classespanel()

Returns selected image

  • function selected()
  • function selectedId()
  • function release() : to release the image selection

Cursor position

  • function saveCaret() : get the cursor position
  • function getCaretPos() : little hack to get the current cursor position

Insert / retrieve HTML

  • function insertAtCursor(sHtml) : insert value at cursor position
  • function insertAfter(elem,currentElem) : insert an HTML element after the current one
  • function getHTML() : put editor value in variable txthtml
  • function getCleanHTML() : put cleaned editor value in variable txthtml (uses function cleanupHTML)
  • function setHTML() : put txthtml value in editor
  • function htmlVisible() : set txthtml (in)visible

Current containers functions

  • function getSelectedContainer() : get the current selected container
  • function getMainContainer(elem) : get the top container (the first editor's child which contains the element)
  • function getContainerOfType(elem,sContainerType) : recursive function which returns the element's parent having a particular type
  • function getContainerOfTypeArray(elem,aContainerTypes) : the same as getContainerOfType, but we use an array of possible types
  • function getAllowedContainer(container,aAllowedContainers) : check if we can apply the class to the container
  • function setContainer(sType) : switch the container to a new one
  • function setClass(sValue,sAllowedContainers,sConflictingClasses) : set the class the container
  • function displayClasses() : highlight the container's classes
  • function removeClassAttr() : remove the class attribute
  • function removeAttrs() : remove all attributes

Open windows

  • function openDialog(sDialogType) : open a dialog
  • function openPreview() : open the preview


  • function setImgIds() : set a unique id to images (when needed)
  • function setImgEvent() : handles click events on images so we can modify images
  • function img_mousedown_handler(img)
  • function img_dblclick_handler(img)


  • function table_insertObject(sObjectType,bBefore) : insert a row or column
  • function table_deleteObject(sObjectType) : delete a row or column


  • function displayPasteCleanup(bln) : display a visual feedback while copying-cutting-pasting
  • function pasteData() : paste data from any application