Wraps some common Selection/Range functionality into a simple object
EditorSelection
_swap
n
tag
Swap an element, with another element
n
HTMLElement
The node to swap
tag
String
The tag to use when creating the new element.
The new node
_wrap
n
tag
Wrap an element, with another element
n
HTMLElement
The node to wrap
tag
String
The tag to use when creating the new element.
The wrapped node
_wrapBlock
Wraps an array of elements in a Block level tag
cleanCursor
Called from Editor keydown to remove the "extra" space before the cursor.
createRange
Wrapper for the different range creation methods.
filter
Performs a prefilter on all nodes in the editor. Looks for nodes with a style: fontFamily or font face It then creates a dynamic class assigns it and removed the property. This is so that we don't lose the fontFamily when selecting nodes.
filterBlocks
Method attempts to replace all "orphined" text nodes in the main body by wrapping them with a
. Called from filter.
focusCursor
Gets a stored cursor and focuses it for editing, must be called sometime after setCursor
getEditorOffset
[node]
Gets the offset of the selection for the selection within the current editor
[node]
Y.Node
optional
Element used to measure the offset to
Number Number of characters the selection is from the beginning
getSelected
Get all the nodes in the current selection. This method will actually perform a filter first. Then it calls doc.execCommand('fontname', null, 'yui-tmp') to touch all nodes in the selection. The it compiles a list of all nodes affected by the execCommand and builds a NodeList to return.
A NodeList of all items in the selection.
getText
node
Returns the innerHTML of a node with all HTML tags removed.
node
Node
The Node instance to remove the HTML from
The string of text
insertAtCursor
html
node
offset
collapse
Insert HTML at the current cursor position, this method gives you control over the text node to insert into and the offset where to put it.
The inserted Node.
insertContent
html
Insert HTML at the current cursor position and return a Node instance of the newly inserted element.
html
String
The HTML to insert.
The inserted Node.
removeCursor
keep
Remove the cursor placeholder from the DOM.
keep
Boolean
Setting this to true will keep the node, but remove the unique parts that make it the cursor.
removeFontFamily
Utility method to remove dead font-family styles from an element.
replace
se
re
Find and replace a string inside a text node and replace it with HTML focusing the node after to allow you to continue to type.
The node inserted.
resolve
n
Resolve a node from the selection object and return a Node instance
n
HTMLElement
The HTMLElement to resolve. Might be a TextNode, gives parentNode.
The Resolved node
selectNode
node
collapse
Select a Node (hilighting it).
_selection
The actual Selection/Range object
ALL
The selector to use when looking for Nodes to cache the value of: [style],font[face]
BLOCKS
The selector to use when looking for block level items.
CUR_WRAPID
The id used to wrap the inner space of the cursor position
CURID
The id of the outer cursor wrapper
CURSOR
The default HTML used to focus the cursor..
DEFAULT_TAG
The default tag to use when creating elements: span
REG_CHAR
Regular Expression to determine if a string has a character in it
REG_FONTFAMILY
Regular Expression used to find dead font-family styles
REG_NOHTML
Regular Expression to remove all HTML from a string
REG_NON
Regular Expression to determine if a string has a non-character in it
ROOT
The default HTML element from which data will be retrieved. Default: body
TMP
The temporary fontname applied to a selection to retrieve their values: yui-tmp