Class EditorBase
- extends Base
Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
Properties
Caches a copy of the selection for key events. Only creating the selection on keydown
Flag to determine if we can clear the selection or not.
Holds the timer for selection clearing
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
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.
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 Base:
Methods
private
void
_afterFrameReady
(
)
After frame ready, bind mousedown & keyup listeners
private
void
_defNodeChangeFn
(
e
)
The default handler for the nodeChange event.
- Parameters:
-
e
<Event>
The event
private
void
_onFrameActivate
(
)
Moves the cached selection bookmark back so IE can place the cursor in the right place.
private
void
_onFrameKeyDown
(
)
Fires nodeChange event
private
void
_onFrameKeyPress
(
)
Fires nodeChange event
private
void
_onFrameKeyUp
(
)
Fires nodeChange event for keyup on specific keys
private
void
_onFrameMouseDown
(
)
Fires nodeChange event
private
void
_onFrameMouseUp
(
)
Fires nodeChange event
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
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
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.
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
EditorBase
focus
(
fn
)
Focus the contentWindow of the iframe
- Parameters:
-
fn
<Function>
Callback function to execute after focus happens
Chainable: This method is chainable.
String
getContent
(
)
(Un)Filters the content of the Editor, cleaning YUI related code. //TODO better filtering
- Returns:
String
- The filtered content of the Editor
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
YUI
getInstance
(
)
Get the YUI instance of the frame
- Returns:
YUI
- The YUI instance bound to the frame.
EditorBase
hide
(
)
Handles the hiding of the Editor instance. Currently only handles the iframe
Chainable: This method is chainable.
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.
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.
EditorBase
show
(
)
Handles the showing of the Editor instance. Currently only handles the iframe
Chainable: This method is chainable.
Methods inherited from EventTarget:
_getType,
_monitor,
_parseType,
addTarget,
after,
before,
bubble,
detach,
detachAll,
fire,
getEvent,
getTargets,
on,
once,
publish,
removeTarget,
subscribe,
unsubscribe,
unsubscribeAll
Methods inherited from Attribute:
_addAttrs,
_addLazyAttr,
_defAttrChangeFn,
_fireAttrChange,
_getAttr,
_getAttrCfg,
_getAttrInitVal,
_getAttrs,
_getStateVal,
_isLazyAttr,
_normAttrVals,
_protectAttrs,
_set,
_setAttr,
_setAttrs,
_setAttrVal,
_setStateVal,
addAttr,
addAttrs,
attrAdded,
get,
getAttrs,
modifyAttr,
removeAttr,
reset,
set,
setAttrs
Methods inherited from Base:
_aggregateAttrs,
_defDestroyFn,
_defInitFn,
_destroyHierarchy,
_filterAttrCfs,
_getAttrCfgs,
_getClasses,
_initHierarchy,
_initHierarchyData,
_preInitEventCfg,
destroy,
init,
toString
Events
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
(
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
(
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
(
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
(
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
(
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
(
event
)
Fired after the frame is ready.
- Parameters:
-
event
<Event.Facade>
An Event Facade object.
Events inherited from Base:
Configuration Attributes
The content to load into the Editor Frame
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
A string of CSS to add to the Head of the Editor
An array of url's to external linked style sheets
Configuration attributes inherited from Base: