# Yahoo! UI Library

### editor 2.5.0

Yahoo! UI Library > editor > YAHOO.widget.Editor

Show Private Show Protected

## Class YAHOO.widget.Editor - extends YAHOO.widget.SimpleEditor

The Rich Text Editor is a UI control that replaces a standard HTML textarea; it allows for the rich formatting of text content, including common structural treatments like lists, formatting treatments like bold and italic text, and drag-and-drop inclusion and sizing of images. The Rich Text Editor's toolbar is extensible via a plugin architecture so that advanced implementations can achieve a high degree of customization.

### Constructor

YAHOO.widget.Editor `( el , attrs )`

Parameters:
  `el <String/HTMLElement>` The textarea element to turn into an editor.
  `attrs <Object>` Object liternal containing configuration parameters.

### Properties

#### _alwaysDisabled `- private Object`

The Toolbar items that should ALWAYS be disabled event if there is a selection present in the editor.

#### _alwaysEnabled `- private Object`

The Toolbar items that should ALWAYS be enabled event if there isn't a selection present in the editor.

#### _disabled `- private Array`

The Toolbar items that should be disabled if there is no selection present in the editor.

#### CLASS_HIDDEN `- protected String`

CSS class applied to the body when the hiddenelements button is pressed.

#### CLASS_LOCAL_FILE `- protected String`

CSS class applied to an element when it's found to have a local url.

#### STR_BEFORE_EDITOR `- String`

The accessibility string for the element before the iFrame

#### STR_CLOSE_WINDOW `- String`

The Title of the close button in the Editor Window

#### STR_CLOSE_WINDOW_NOTE `- String`

A note appearing in the Editor Window to tell the user that the Escape key will close the window

#### STR_IMAGE_BORDER `- String`

The label string for the image border.

#### STR_IMAGE_COPY `- String`

The label string for the image copy and paste message for Opera and Safari

#### STR_IMAGE_ORIG_SIZE `- String`

The label string for Original Image Size

#### STR_IMAGE_PADDING `- String`

The label string for the image padding.

#### STR_IMAGE_PROP_TITLE `- String`

The title for the Image Property Editor Window

#### STR_IMAGE_SIZE `- String`

The label string for Image Size

#### STR_IMAGE_TEXTFLOW `- String`

The label string for the image text flow.

#### STR_IMAGE_TITLE `- String`

The label string for Image Description

#### STR_IMAGE_URL `- String`

The label string for Image URL

#### STR_LINK_NEW_WINDOW `- String`

The string for the open in a new window label.

#### STR_LINK_PROP_REMOVE `- String`

The label string for the Remove link from text link inside the property editor.

#### STR_LINK_PROP_TITLE `- String`

The label string for the Link Property Editor Window.

#### STR_LINK_TITLE `- String`

The string for the link description.

#### STR_LOCAL_FILE_WARNING `- String`

The label string for the local file warning.

#### Properties inherited from YAHOO.widget.SimpleEditor:

`_alwaysDisabled, _alwaysEnabled, _baseHREF, _blankImageLoaded, _contentTimer, _contentTimerCounter, _defaultCSS, _defaultToolbar, _disabled, _docType, _fixNodesTimer, _lastButton, _lastImage, _lastNodeChange, _lastNodeChangeEvent, _mask, _nodeChangeTimer, _rendered, _selection, _semantic, _showingHiddenElements, _tag2cmd, afterElement, beforeElement, browser, CLASS_CONTAINER, CLASS_EDITABLE, CLASS_EDITABLE_CONT, CLASS_NOEDIT, CLASS_PREFIX, currentElement, currentEvent, currentFont, currentWindow, dompath, DOMReady, EDITOR_PANEL_ID, editorDirty, el, invalidHTML, operaEvent, sel, SEP_DOMPATH, STOP_EXEC_COMMAND, STOP_NODE_CHANGE, STR_BEFORE_EDITOR, STR_IMAGE_HERE, STR_LEAVE_EDITOR, STR_LINK_URL, STR_TITLE, toolbar`

#### Properties inherited from YAHOO.util.Element:

`DOM_EVENTS`

#### Properties inherited from YAHOO.util.AttributeProvider:

`_configs`

#### Properties inherited from YAHOO.util.EventProvider:

`__yui_events, __yui_subscribers`

### Methods

#### _cleanClassName

`private String _cleanClassName ( str )`
Makes a useable classname from dynamic data, by dropping it to lowercase and replacing spaces with -'s.

Parameters:
  `str <String>` The classname to clean up

Returns: `String`

#### _closeWindow

`private void _closeWindow ( ev )`
Close the currently open EditorWindow with the Escape key.

Parameters:
  `ev <Event>` The keypress Event that we are trapping

Returns: `void`

#### _fixNodes

`private void _fixNodes ( )`
Fix href and imgs as well as remove invalid HTML.

Returns: `void`

#### _handleCreateLinkWindowClose

`private void _handleCreateLinkWindowClose ( )`
Handles the closing of the Link Properties Window.

Returns: `void`

#### _handleInsertImageClick

`private void _handleInsertImageClick ( )`
Opens the Image Properties Window when the insert Image button is clicked or an Image is Double Clicked.

Returns: `void`

#### _handleInsertImageWindowClose

`private void _handleInsertImageWindowClose ( )`
Handles the closing of the Image Properties Window.

Returns: `void`

#### _handleKeyDown

`private void _handleKeyDown ( ev )`
Override method that handles some new keydown events inside the iFrame document.

Parameters:
  `ev <Event>` The event we are working on.

Returns: `void`

#### _renderPanel

`private YAHOO.widget.Overlay _renderPanel ( )`
Renders the panel used for Editor Windows to the document so we can start using it..

Returns: `YAHOO.widget.Overlay`

#### closeWindow

`void closeWindow ( )`
Close the currently open EditorWindow.

Returns: `void`

#### cmd_heading

`void cmd_heading ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('heading') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_hiddenelements

`void cmd_hiddenelements ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('hiddenelements') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_indent

`void cmd_indent ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('indent') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_outdent

`void cmd_outdent ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('outdent') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_removeformat

`void cmd_removeformat ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('removeformat') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_script

`void cmd_script ( action , value )`
This is a combined execCommand override method. It is called from the cmd_superscript and cmd_subscript methods.

Parameters:
  `action <object>` action passed from the execCommand method
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_subscript

`void cmd_subscript ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('subscript') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### cmd_superscript

`void cmd_superscript ( value )`
This is an execCommand override method. It is called from execCommand when the execCommand('superscript') is used.

Parameters:
  `value <object>` Value passed from the execCommand method

Returns: `void`

#### init

`void init ( )`
The Editor class' initialization method

Returns: `void`

#### initAttributes

`void initAttributes ( attr )`
Initializes all of the configuration attributes used to create the editor.

Parameters:
  `attr <Object>` Object literal specifying a set of configuration attributes used to create the editor.

Returns: `void`

#### moveWindow

`void moveWindow ( force )`
Realign the window with the currentElement and reposition the knob above the panel.

Parameters:
  `force <Boolean>` Boolean to tell it to move but not use any animation (Usually done the first time the window is loaded.)

Returns: `void`

#### openWindow

`void openWindow ( win )`
Opens a new "window/panel"

Parameters:
  `win <YAHOO.widget.EditorWindow>` A YAHOO.widget.EditorWindow instance

Returns: `void`

#### toString

`String toString ( )`
Returns a string representing the editor.

Returns: `String`

#### Methods inherited from YAHOO.widget.SimpleEditor:

`_checkLoaded, _cleanClassName, _cleanIncomingHTML, _closeWindow, _createCurrentElement, _createIframe, _disableEditor, _fixNodes, _focusWindow, _getBlankImage, _getDoc, _getDomPath, _getRange, _getSelectedElement, _getSelection, _getWindow, _handleAfterNodeChange, _handleAlign, _handleAutoHeight, _handleClick, _handleColorPicker, _handleCreateLinkClick, _handleCreateLinkWindowClose, _handleDoubleClick, _handleFontSize, _handleFormSubmit, _handleInsertImageClick, _handleInsertImageWindowClose, _handleKeyDown, _handleKeyPress, _handleKeyUp, _handleMouseDown, _handleMouseUp, _handleToolbarClick, _hasParent, _hasSelection, _initEditor, _isElement, _isLocalFile, _isNonEditable, _listFix, _render, _renderPanel, _selectNode, _setCurrentEvent, _setDesignMode, _setEditorStyle, _setInitialContent, _setMarkupType, _setupAfterElement, _swapEl, _toggleDesignMode, _updateMenuChecked, _writeDomPath, cleanHTML, clearEditorDoc, closeWindow, cmd_backcolor, cmd_createlink, cmd_fontname, cmd_fontsize, cmd_forecolor, cmd_inserthtml, cmd_insertimage, cmd_insertorderedlist, cmd_insertunorderedlist, cmd_list, cmd_unlink, destroy, execCommand, filter_all_rgb, filter_internals, filter_invalid_lists, filter_rgb, filter_safari, getEditorHTML, hide, init, initAttributes, moveWindow, nodeChange, openWindow, post_filter_linebreaks, pre_filter_linebreaks, render, saveHTML, setEditorHTML, show, toString`

#### Methods inherited from YAHOO.util.Element:

`_registerHTMLAttr, addClass, addListener, appendChild, appendTo, fireQueue, getElementsByClassName, getElementsByTagName, getStyle, hasChildNodes, hasClass, initAttributes, insertBefore, on, removeChild, removeClass, removeListener, replaceChild, replaceClass, setStyle, subscribe`

#### Methods inherited from YAHOO.util.AttributeProvider:

`configureAttribute, fireBeforeChangeEvent, fireChangeEvent, get, getAttributeConfig, getAttributeKeys, refresh, register, resetAttributeConfig, resetValue, set, setAttributeConfig, setAttributes`

#### Methods inherited from YAHOO.util.EventProvider:

`createEvent, fireEvent, hasEvent, subscribe, unsubscribe, unsubscribeAll`

### Events

#### beforeHiddencssChange

`beforeHiddencssChange ( eventInfo )`
Fires before the value for the configuration attribute 'hiddencss' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### beforeLocalfilewarningChange

`beforeLocalfilewarningChange ( eventInfo )`
Fires before the value for the configuration attribute 'localFileWarning' changes. Return false to cancel the attribute change.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the current attribute value and the new value.

#### hiddencssChange

`hiddencssChange ( eventInfo )`
Fires when the value for the configuration attribute 'hiddencss' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### localFileWarningChange

`localFileWarningChange ( eventInfo )`
Fires when the value for the configuration attribute 'localFileWarning' changes.

Parameters:
  `eventInfo <{oldValue: any, newValue: any}>` An object containing the previous attribute value and the new value.

#### Events inherited from YAHOO.widget.SimpleEditor:

`afterExecCommand, afterNodeChange, afterRender, animateChange, beforeAnimateChange, beforeBlankimageChange, beforeCssChange, beforeDisabledChange, beforeDompathChange, beforeExecCommand, beforeExtracssChange, beforeFocusatstartChange, beforeHandlesubmitChange, beforeHeightChange, beforeHtmlChange, beforeMarkupChange, beforeNodeChange, beforeRemovelinebreaksChange, beforeToolbarChange, beforeWidthChange, blankimageChange, cleanHTML, cssChange, disabledChange, dompathChange, editorContentLoaded, editorDoubleClick, editorKeyDown, editorKeyPress, editorKeyUp, editorMouseDown, editorMouseUp, extracssChange, focusAtStartChange, handleSubmitChange, heightChange, htmlChange, markupChange, removeLineBreaksChange, toolbarChange, toolbarLoaded, widthChange,`

#### Events inherited from YAHOO.util.Element:

`appendTo, available, beforeAppendTo, beforeElementChange, contentReady, elementChange,`

### Configuration Attributes

#### hiddencss `- String`

The CSS used to show/hide hidden elements on the page, these rules must be prefixed with the class provided in `this.CLASS_HIDDEN`
Default Value: `

    .yui-hidden font, .yui-hidden strong, .yui-hidden b, .yui-hidden em, .yui-hidden i, .yui-hidden u, .yui-hidden div, .yui-hidden p, .yui-hidden span, .yui-hidden img, .yui-hidden ul, .yui-hidden ol, .yui-hidden li, .yui-hidden table {
    border: 1px dotted #ccc;
    }
    .yui-hidden .yui-non {
    border: none;
    }
    .yui-hidden img {
    padding: 2px;
    }

`

#### localFileWarning `- Boolean`

Should we throw the warning if we detect a file that is local to their machine?
Default Value: true

#### Configuration attributes inherited from YAHOO.widget.SimpleEditor:

`allowNoEdit, animate, autoHeight, blankimage, container, css, disabled, dompath, editor_wrapper, element_cont, extracss, focusAtStart, handleSubmit, height, html, iframe, limitCommands, markup, nodeChangeThreshold, panel, plainText, removeLineBreaks, textarea, toolbar, toolbar_cont, width,`

#### Configuration attributes inherited from YAHOO.util.Element:

`element,`

Copyright © 2007 Yahoo! Inc. All rights reserved.