editor-debug.js revision 9f2068537ef4a78d9a11fb5a136991d9d9e059a0
var Frame = function() {
_ready: null,
_rendered: null,
_iframe: null,
_instance: null,
_create: function() {
* @return {Object} Object hash of window and document references, if a YUI config was passed, it is returned.
_resolveWinDoc: function(c) {
var config = (c) ? c : {};
return config;
* takes the current EventFacade and augments it to fire on the Frame host. It adds two new properties
_onDomEvent: function(e) {
e.frameEvent = e;
emitFacade: true,
initializer: function() {
emitFacade: true,
_defReadyFn: function() {
* @description Called once the content is available in the frame/window and calls the final use call
_onContentReady: function(e) {
if (!this._ready) {
this._ready = true;
* @description Resolves the basehref of the page the frame is created on. Only applies to dynamic content.
return href;
if (this._ready) {
return html;
if (this._ready) {
}, this, html));
return html;
if (this._ready) {
return css;
extra_css = ((this.get('extracss')) ? '<style id="extra_css">' + this.get('extracss') + '</style>' : ''),
} catch (err) {}
* @description This is a scoped version of the normal YUI.use method & is bound to this frame/window.
use: function() {
cb = false;
if (cb) {
* @param {String} cont The container to act as a delegate, if no "sel" passed, the body is assumed as the container.
if (!inst) {
Y.log('Delegate events can not be attached until after the ready event has fired.', 'error', 'iframe');
if (!sel) {
getInstance: function() {
return this._instance;
* @param {String/HTMLElement/Node} node The node to render to
if (this._rendered) {
this._rendered = true;
if (node) {
this._instanceLoaded(i);
config = {
debug: false,
bootstrap: false,
if (timer) {
fn();
focus: function() {
} catch (ferr) {
show: function() {
this.focus();
hide: function() {
DEFAULT_CSS: 'html { height: 95%; } body { padding: 7px; background-color: #fff; font: 13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } img { cursor: pointer !important; border: none; }',
HTML: '<iframe border="0" frameBorder="0" marginWidth="0" marginHeight="0" leftMargin="0" topMargin="0" allowTransparency="true" width="100%" height="100%"></iframe>',
PAGE_HTML: '<html dir="{DIR}" lang="{LANG}"><head><title>{TITLE}</title>{META}<base href="{BASE_HREF}"/><style id="editor_css">{DEFAULT_CSS}</style>{EXTRA_CSS}</head><body>{CONTENT}</body></html>',
* @description The DOCTYPE to prepend to the new document when created. Should match the one on the page being served.
DOC_TYPE: '<!DOCTYPE HTML PUBLIC "-/'+'/W3C/'+'/DTD HTML 4.01/'+'/EN" "http:/'+'/www.w3.org/TR/html4/strict.dtd">',
ATTRS: {
title: {
dir: {
lang: {
src: {
designMode: {
writeOnce: true,
value: false
content: {
basehref: {
value: false,
* @description Array of modules to include in the scoped YUI instance at render time. Default: ['none', 'selector-css2']
use: {
writeOnce: true,
* @type String/HTMLElement/Node
container: {
setter: function(n) {
return Y.one(n);
id: {
writeOnce: true,
if (!id) {
return id;
extracss: {
host: {
value: false
Y.Selection = function() {
if (this.isCollapsed) {
if (ieNode) {
this.anchorOffset = this.focusOffset = (this.anchorNode.nodeValue) ? this.anchorNode.nodeValue.length : 0 ;
* 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
ls;
v.remove();
* Method attempts to replace all "orphined" text nodes in the main body by wrapping them with a <p>. Called from filter.
if (childs) {
doit = true;
doit = false;
if (doit) {
if (!wrapped) {
wrapped = [];
if (wrapped) {
n.remove();
return html;
n = n.parentNode;
return Y.one(n);
text: null,
isCollapsed: null,
anchorNode: null,
anchorOffset: null,
anchorTextNode: null,
focusNode: null,
focusOffset: null,
focusTextNode: null,
_selection: null,
getSelected: function() {
items = [];
* Insert HTML at the current cursor position and return a Node instance of the newly inserted element.
* 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.
var cur = Y.Node.create('<' + Y.Selection.DEFAULT_TAG + ' class="yui-non"></' + Y.Selection.DEFAULT_TAG + '>'),
node = b;
if (inHTML) {
return newNode;
return newNode;
* Get all elements inside a selection and wrap them with a new element and return a NodeList of all elements touched.
if (!this.isCollapsed) {
return changed;
return Y.all([]);
return newNode;
remove: function() {
createRange: function() {
if (collapse) {
if (collapse) {
setCursor: function() {
getCursor: function() {
focusCursor: function() {
if (cur) {
toString: function() {
var ExecCommand = function() {
_inst: null,
if (fn) {
getInstance: function() {
if (!this._inst) {
return this._inst;
initializer: function() {
ATTRS: {
host: {
value: false
COMMANDS: {
bidi: function() {
return blockItem;
n = this.command('inserthtml', '<span style="background-color: ' + val + '"><span> </span> </span>');
hilitecolor: function() {
var EditorTab = function() {
_onNodeChange: function(e) {
e.preventDefault();
initializer: function() {
ATTRS: {
host: {
value: false
* Adds prompt style link creation. Adds an override for the <a href="Plugin.ExecCommand.html#method_COMMANDS.createlink">createlink execCommand</a>.
* Adds prompt style link creation. Adds an override for the <a href="Plugin.ExecCommand.html#method_COMMANDS.createlink">createlink execCommand</a>.
var CreateLinkBase = {};
* Override for the createlink method from the <a href="Plugin.CreateLinkBase.html">CreateLinkBase</a> plugin.
if (url) {
* Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
* Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
var EditorBase = function() {
frame: null,
initializer: function() {
designMode: true,
host: this
emitFacade: true,
bubbles: true,
newStyles = {};
_fixFirstPara: function() {
} catch (er) {}
_defNodeChangeFn: function(e) {
switch (e.changedType) {
this._fixFirstPara();
this._fixFirstPara();
if (prev) {
while (!found) {
if (lc) {
if (lc2) {
found = true;
found = true;
if (lc) {
if (e.commands) {
if (cmd) {
if (family2) {
if (!e.fontFamily) {
if (!e.fontSize) {
if (!e.fontColor) {
if (!e.backgroundColor) {
var domPath = [],
while (node !== null) {
node = null;
node = null;
node = null;
_afterFrameReady: function() {
_onFrameMouseDown: function(e) {
_onFrameKeyUp: function(e) {
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keyup', selection: sel, changedEvent: e });
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-up', selection: sel, changedEvent: e });
_onFrameKeyDown: function(e) {
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode], changedEvent: e });
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-down', changedEvent: e });
_onFrameKeyPress: function(e) {
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-press', changedEvent: e });
* @return {Node/NodeList} The Node or Nodelist affected by the command. Only returns on override commands, not browser defined commands.
switch (cmd) {
return ret;
getInstance: function() {
destructor: function() {
* @param {Selector/HTMLElement/Node} node The node to append the Editor to
focus: function() {
show: function() {
hide: function() {
getContent: function() {
return html;
* @description Converts an RGB color string to a hex color, example: rgb(0, 255, 0) converts to #00ff00
var exp = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
return css;
TAG2CMD: {
NC_KEYS: {
STRINGS: {
ATTRS: {
content: {
getter: function() {
dir: {
writeOnce: true,
extracss: {
value: false,
if (this.frame) {
return css;
* <dt>changedType</dt><dd>The type of change: mousedown, mouseup, right, left, backspace, tab, enter, etc..</dd>
* <dt>commands</dt><dd>The list of execCommands that belong to this change and the dompath that's associated with the changedNode</dd>
* <dt>classNames</dt><dd>An array of classNames that are applied to the changedNode and all of it's parents</dd>
* <dt>dompath</dt><dd>A sorted array of node instances that make up the DOM path from the changedNode to body.</dd>
* Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
* Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
var EditorLists = function() {
* Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
_onNodeChange: function(e) {
e.preventDefault();
e.preventDefault();
if (sTab) {
moved = true;
moved = true;
if (moved) {
initializer: function() {
ATTRS: {
host: {
value: false
* Override for the insertunorderedlist method from the <a href="Plugin.EditorLists.html">EditorLists</a> plugin.
return out;
* Override for the insertorderedlist method from the <a href="Plugin.EditorLists.html">EditorLists</a> plugin.
return out;