Yahoo! UI Library

editor  3.3.0pr1

Yahoo! UI Library > editor > EditorBase
Search:
 
Filters

Class EditorBase - extends Base

Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.

Constructor

EditorBase ( )

Properties

_currentSelection - private object

Caches a copy of the selection for key events. Only creating the selection on keydown

_currentSelectionClear - private object

Flag to determine if we can clear the selection or not.

_currentSelectionTimer - private object

Holds the timer for selection clearing

_lastBookmark - private object

Holder for the selection bookmark in IE.

bq - object

When executing execCommand 'indent or 'outdent' Webkit applies a class to the BLOCKQUOTE that adds left/right margin to it This strips that style so it is just a normal BLOCKQUOTE

frame - object

Internal reference to the Y.Frame instance

NAME - static object

The Class Name: editorBase

NC_KEYS - static Object

Hash table of keys to fire a nodeChange event for.

STRINGS - static object

Editor Strings

STRINGS.title - static object

Title of frame document: Rich Text Editor

TABKEY - static object

The HTML markup to use for the tabkey

TAG2CMD - static object

A hash table of tags to their execcomand's

USE - static Array

The default modules to use inside the Frame

Properties inherited from Plugin.Host:

Properties inherited from Attribute:

Properties inherited from Base:

Methods

_afterFrameReady

private void _afterFrameReady ( )
After frame ready, bind mousedown & keyup listeners

_defNodeChangeFn

private void _defNodeChangeFn ( e )
The default handler for the nodeChange event.
Parameters:
e <Event> The event

_onFrameActivate

private void _onFrameActivate ( )
Moves the cached selection bookmark back so IE can place the cursor in the right place.

_onFrameKeyDown

private void _onFrameKeyDown ( )
Fires nodeChange event

_onFrameKeyPress

private void _onFrameKeyPress ( )
Fires nodeChange event

_onFrameKeyUp

private void _onFrameKeyUp ( )
Fires nodeChange event for keyup on specific keys

_onFrameMouseDown

private void _onFrameMouseDown ( )
Fires nodeChange event

_onFrameMouseUp

private void _onFrameMouseUp ( )
Fires nodeChange event

_resolveChangedNode

private void _resolveChangedNode ( n )
Resolves the e.changedNode in the nodeChange event if it comes from the document. If the event came from the document, it will get the last child of the last child of the document and return that instead.
Parameters:
n <Node> The node to resolve

copyStyles

void copyStyles ( from , to )
Copy certain styles from one node instance to another (used for new paragraph creation mainly)
Parameters:
from <Node> The Node instance to copy the styles from
to <Node> The Node instance to copy the styles to

execCommand

Node/NodeList execCommand ( cmd , val )
Pass through to the frame.execCommand method
Parameters:
cmd <String> The command to pass: inserthtml, insertimage, bold
val <String> The optional value of the command: Helvetica
Returns: Node/NodeList
The Node or Nodelist affected by the command. Only returns on override commands, not browser defined commands.

FILTER_RGB

static FILTER_RGB ( String )
Converts an RGB color string to a hex color, example: rgb(0, 255, 0) converts to #00ff00
Parameters:
String <object> css The CSS string containing rgb(#,#,#);
Returns:
String

focus

EditorBase focus ( fn )
Focus the contentWindow of the iframe
Parameters:
fn <Function> Callback function to execute after focus happens
Chainable: This method is chainable.

getContent

String getContent ( )
(Un)Filters the content of the Editor, cleaning YUI related code. //TODO better filtering
Returns: String
The filtered content of the Editor

getDomPath

void getDomPath ( node )
Walk the dom tree from this node up to body, returning a reversed array of parents.
Parameters:
node <Node> The Node to start from

getInstance

YUI getInstance ( )
Get the YUI instance of the frame
Returns: YUI
The YUI instance bound to the frame.

hide

EditorBase hide ( )
Handles the hiding of the Editor instance. Currently only handles the iframe
Chainable: This method is chainable.

NORMALIZE_FONTSIZE

static void NORMALIZE_FONTSIZE ( )
Pulls the fontSize from a node, then checks for string values (x-large, x-small) and converts them to pixel sizes. If the parsed size is different from the original, it calls node.setStyle to update the node with a pixel size for normalization.

render

EditorBase render ( node )
Renders the Y.Frame to the passed node.
Parameters:
node <Selector/HTMLElement/Node> The node to append the Editor to
Chainable: This method is chainable.

show

EditorBase show ( )
Handles the showing of the Editor instance. Currently only handles the iframe
Chainable: This method is chainable.

Events

contentChange

contentChange ( event )
Fires when the value for the configuration attribute 'content' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

defaultblockChange

defaultblockChange ( event )
Fires when the value for the configuration attribute 'defaultblock' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

dirChange

dirChange ( event )
Fires when the value for the configuration attribute 'dir' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

extracssChange

extracssChange ( event )
Fires when the value for the configuration attribute 'extracss' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

linkedcssChange

linkedcssChange ( event )
Fires when the value for the configuration attribute 'linkedcss' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.
Parameters:
event <Event.Facade> An Event Facade object with the following attribute specific properties added:
prevVal
The value of the attribute, prior to it being set
newVal
The value the attribute is to be set to
attrName
The name of the attribute being set
subAttrName
If setting a property within the attribute's value, the name of the sub-attribute property being set

nodeChange

nodeChange ( event )
Fired from mouseup & keyup.
Parameters:
event <Event.Facade> An Event Facade object with the following specific properties added:
changedEvent
The event that caused the nodeChange
changedNode
The node that was interacted with
changedType
The type of change: mousedown, mouseup, right, left, backspace, tab, enter, etc..
commands
The list of execCommands that belong to this change and the dompath that's associated with the changedNode
classNames
An array of classNames that are applied to the changedNode and all of it's parents
dompath
A sorted array of node instances that make up the DOM path from the changedNode to body.
backgroundColor
The cascaded backgroundColor of the changedNode
fontColor
The cascaded fontColor of the changedNode
fontFamily
The cascaded fontFamily of the changedNode
fontSize
The cascaded fontSize of the changedNode

ready

ready ( event )
Fired after the frame is ready.
Parameters:
event <Event.Facade> An Event Facade object.

Events inherited from Base:

Configuration Attributes

content - object

The content to load into the Editor Frame

defaultblock - String

The default tag to use for block level items, defaults to: p

dir - object

The value of the dir attribute on the HTML element of the frame. Default: ltr

extracss - String

A string of CSS to add to the Head of the Editor

linkedcss - String

An array of url's to external linked style sheets

Configuration attributes inherited from Base:


Copyright © 2010 Yahoo! Inc. All rights reserved.