Wraps some common Selection/Range functionality into a simple object
EditorSelection_swapn
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
_wrapn
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
_wrapBlockWraps an array of elements in a Block level tag
cleanCursorCalled from Editor keydown to remove the "extra" space before the cursor.
createRangeWrapper for the different range creation methods.
filterPerforms 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.
filterBlocksMethod attempts to replace all "orphined" text nodes in the main body by wrapping them with a
. Called from filter.
focusCursorGets 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
getSelectedGet 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.
getTextnode
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
insertAtCursorhtml
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.
insertContenthtml
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.
removeCursorkeep
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.
removeFontFamilyUtility method to remove dead font-family styles from an element.
replacese
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.
resolven
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
selectNodenode
collapse
Select a Node (hilighting it).
_selectionThe actual Selection/Range object
ALLThe selector to use when looking for Nodes to cache the value of: [style],font[face]
BLOCKSThe selector to use when looking for block level items.
CUR_WRAPIDThe id used to wrap the inner space of the cursor position
CURIDThe id of the outer cursor wrapper
CURSORThe default HTML used to focus the cursor..
DEFAULT_TAGThe default tag to use when creating elements: span
REG_CHARRegular Expression to determine if a string has a character in it
REG_FONTFAMILYRegular Expression used to find dead font-family styles
REG_NOHTMLRegular Expression to remove all HTML from a string
REG_NONRegular Expression to determine if a string has a non-character in it
ROOTThe default HTML element from which data will be retrieved. Default: body
TMPThe temporary fontname applied to a selection to retrieve their values: yui-tmp