editor-base.js revision 2bbe3ca8cfbb948b9b6356ae16759f1d6245433c
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass * var editor = new Y.EditorBase({
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass * content: 'Foo'
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass * editor.render('#demo');
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass * @main editor
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @class EditorBase
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * @for EditorBase
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @extends Base
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass * @module editor
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass * @submodule editor-base
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @constructor
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass var EditorBase = function() {
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass EditorBase.superclass.constructor.apply(this, arguments);
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Internal reference to the Y.Frame instance
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @property frame
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass initializer: function() {
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass frame.after('ready', Y.bind(this._afterFrameReady, this));
0db84e0da684308b0fd9ea9b5906c11bafa7a246Dav Glass //this.plug(Y.Plugin.EditorPara);
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass destructor: function() {
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass * Copy certain styles from one node instance to another (used for new paragraph creation mainly)
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass * @method copyStyles
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass * @param {Node} from The Node instance to copy the styles from
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass * @param {Node} to The Node instance to copy the styles to
a2cf1018c8c3c924dd3210ac6d5d796939a87876Dav Glass //Don't carry the A styles
f8b3e367f0b400ff8b4feeb35c56d9387a31f9e0Dav Glass var styles = ['color', 'fontSize', 'fontFamily', 'backgroundColor', 'fontStyle' ],
fe442de8408a276919d26a1110e8121844b1ba11Dav Glass * Holder for the selection bookmark in IE.
fe442de8408a276919d26a1110e8121844b1ba11Dav Glass * @property _lastBookmark
aa2ac226ad6e45232f8416eecc99d2165ce74d03Dav Glass * Resolves the e.changedNode in the nodeChange event if it comes from the document. If
aa2ac226ad6e45232f8416eecc99d2165ce74d03Dav Glass * the event came from the document, it will get the last child of the last child of the document
aa2ac226ad6e45232f8416eecc99d2165ce74d03Dav Glass * and return that instead.
aa2ac226ad6e45232f8416eecc99d2165ce74d03Dav Glass * @method _resolveChangedNode
aa2ac226ad6e45232f8416eecc99d2165ce74d03Dav Glass * @param {Node} n The node to resolve
2bbe3ca8cfbb948b9b6356ae16759f1d6245433cDav Glass //Fallback to make sure a node is attached to the event
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * The default handler for the nodeChange event.
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method _defNodeChangeFn
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @param {Event} e The event
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass //Y.log('Default nodeChange function: ' + e.changedType, 'info', 'editor');
3499692683cbc70ff10f1844350ff92b1d0eba3fDav Glass } catch (ie) {}
aa2ac226ad6e45232f8416eecc99d2165ce74d03Dav Glass e.changedNode = this._resolveChangedNode(e.changedNode);
323ca860aba4b2515b560796e2322d5eaae57e5aDav Glass * This whole method needs to be fixed and made more dynamic.
323ca860aba4b2515b560796e2322d5eaae57e5aDav Glass * Maybe static functions for the e.changeType and an object bag
323ca860aba4b2515b560796e2322d5eaae57e5aDav Glass * to walk through and filter to pass off the event to before firing..
edefd42ddde54932d14d9150369570db47822ab5Dav Glass case 'keydown':
577da64a9f0680112357f6595f47bfcab32d9adbDav Glass if (!EditorBase.NC_KEYS[e.changedEvent.keyCode] && !e.changedEvent.shiftKey && !e.changedEvent.ctrlKey && (e.changedEvent.keyCode !== 13)) {
1f5da3ee0a7dfb278ab235231e5af6aad13326d4Dav Glass //inst.later(100, inst, inst.Selection.cleanCursor);
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass if (!e.changedNode.test('li, li *') && !e.changedEvent.shiftKey) {
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass Y.log('Overriding TAB key to insert HTML: HALTING', 'info', 'editor');
d5c8641a4c8bb3bf024ae7fe517387163591d325Dav Glass this.frame.exec._command('inserthtml', EditorBase.TABKEY);
44631472b0626bcab1c9209949a75d069d3abf72Dav Glass this.execCommand('inserthtml', EditorBase.TABKEY);
0db84e0da684308b0fd9ea9b5906c11bafa7a246Dav Glass if (Y.UA.webkit && e.commands && (e.commands.indent || e.commands.outdent)) {
6dbc2e0b2c23ae7763959af9762fc50c84dbd937Dav Glass * When executing execCommand 'indent or 'outdent' Webkit applies
6dbc2e0b2c23ae7763959af9762fc50c84dbd937Dav Glass * a class to the BLOCKQUOTE that adds left/right margin to it
6dbc2e0b2c23ae7763959af9762fc50c84dbd937Dav Glass * This strips that style so it is just a normal BLOCKQUOTE
91085c33d52b89808c10ff61e5a94d7b35d57d65Dav Glass var changed = this.getDomPath(e.changedNode, false),
aa2601e36876d3453019dfe96691f3b796cf8e8bDav Glass var normal = false;
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass //Bold and Italic styles
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass if ((''+s.fontWeight) == 'bold') { //Cast this to a string
690dda02d518be26b6ee1c6530ee361081c9eb03Dav Glass var family2 = n.getStyle('fontFamily').split(',')[0].toLowerCase();
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass family = family.replace(/'/g, '').replace(/"/g, '');
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass fsize = EditorBase.NORMALIZE_FONTSIZE(n);
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass var cls = el.className.split(' ');
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass Y.each(cls, function(v) {
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass classes.push(v);
d0bccce76452becc96b65acaaa684aa6fabaf386Dav Glass fColor = EditorBase.FILTER_RGB(n.getStyle('color'));
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass var bColor2 = EditorBase.FILTER_RGB(s.backgroundColor);
d0bccce76452becc96b65acaaa684aa6fabaf386Dav Glass bColor = bColor2;
aa2601e36876d3453019dfe96691f3b796cf8e8bDav Glass if (normal) {
aa2601e36876d3453019dfe96691f3b796cf8e8bDav Glass delete cmds.bold;
aa2601e36876d3453019dfe96691f3b796cf8e8bDav Glass delete cmds.italic;
91085c33d52b89808c10ff61e5a94d7b35d57d65Dav Glass e.dompath = inst.all(changed);
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass e.classNames = classes;
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass e.commands = cmds;
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass Y.log('_defNodeChangeTimer 2: ' + (endTime - startTime) + 'ms', 'info', 'selection');
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass * Walk the dom tree from this node up to body, returning a reversed array of parents.
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass * @method getDomPath
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass * @param {Node} node The Node to start from
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass //return inst.all(domNode);
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass while (domNode !== null) {
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass if ((domNode === inst.config.doc.documentElement) || (domNode === inst.config.doc) || !domNode.tagName) {
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass //Check to see if we get el.nodeName and nodeType
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass if (domNode.nodeName && domNode.nodeType && (domNode.nodeType == 1)) {
e08067d50c8d5e4692441db53bba084c7a667e0aDav Glass /*{{{ Using Node
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass while (node !== null) {
573bad453b98b1e493f4abfcf507f85b22b6bf4aDav Glass if (node.test('html') || node.test('doc') || !node.get('tagName')) {
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass node = null;
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass if (!node.inDoc()) {
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass node = null;
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass //Check to see if we get el.nodeName and nodeType
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass if (node.get('nodeName') && node.get('nodeType') && (node.get('nodeType') == 1)) {
5cbdc947eb0c9c5e840d59ff8e1dd49a0e2a1887Dav Glass domPath.push(inst.Node.getDOMNode(node));
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass if (node.test('body')) {
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass node = null;
b80d65233fd7492f4b6487349f5364b9a8ca019eDav Glass node = node.get('parentNode');
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * After frame ready, bind mousedown & keyup listeners
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method _afterFrameReady
9d0be4bedcaad945c505994577198223ffc4ed9eDav Glass this.frame.on('dom:mouseup', Y.bind(this._onFrameMouseUp, this));
9d0be4bedcaad945c505994577198223ffc4ed9eDav Glass this.frame.on('dom:mousedown', Y.bind(this._onFrameMouseDown, this));
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.frame.on('dom:keydown', Y.bind(this._onFrameKeyDown, this));
406fbc8e9d992226194dfc2353a6ba1c1fd24b3aDav Glass this.frame.on('dom:activate', Y.bind(this._onFrameActivate, this));
406fbc8e9d992226194dfc2353a6ba1c1fd24b3aDav Glass this.frame.on('dom:beforedeactivate', Y.bind(this._beforeFrameDeactivate, this));
406fbc8e9d992226194dfc2353a6ba1c1fd24b3aDav Glass this.frame.on('dom:keyup', Y.bind(this._onFrameKeyUp, this));
406fbc8e9d992226194dfc2353a6ba1c1fd24b3aDav Glass this.frame.on('dom:keypress', Y.bind(this._onFrameKeyPress, this));
7a67e82a93bc7dc5bf9a62a3ad321c2424da37f7Dav Glass this.frame.on('dom:paste', Y.bind(this._onPaste, this));
406fbc8e9d992226194dfc2353a6ba1c1fd24b3aDav Glass * Caches the current cursor position in IE.
406fbc8e9d992226194dfc2353a6ba1c1fd24b3aDav Glass * @method _beforeFrameDeactivate
38b0027944b7fe09062a6befbf76146e73661096Dav Glass if (e.frameTarget.test('html')) { //Means it came from a scrollbar
e57824e27f47a76dae7b14c6ff1c7ed1186d16c1Dav Glass if (sel.compareEndPoints && !sel.compareEndPoints('StartToEnd', sel)) {
fe442de8408a276919d26a1110e8121844b1ba11Dav Glass * Moves the cached selection bookmark back so IE can place the cursor in the right place.
fe442de8408a276919d26a1110e8121844b1ba11Dav Glass * @method _onFrameActivate
38b0027944b7fe09062a6befbf76146e73661096Dav Glass if (e.frameTarget.test('html')) { //Means it came from a scrollbar
09c638a157dd9d2ed9027215d9e254badfa019b8Dav Glass if (moved === -1) { //Only move up if we actually moved back.
27a34eacb64bad3093c357e104c7bee249343ec1Dav Glass } catch (e) {}
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Fires nodeChange event
7a67e82a93bc7dc5bf9a62a3ad321c2424da37f7Dav Glass * @method _onPaste
7a67e82a93bc7dc5bf9a62a3ad321c2424da37f7Dav Glass _onPaste: function(e) {
7a67e82a93bc7dc5bf9a62a3ad321c2424da37f7Dav Glass this.fire('nodeChange', { changedNode: e.frameTarget, changedType: 'paste', changedEvent: e.frameEvent });
7a67e82a93bc7dc5bf9a62a3ad321c2424da37f7Dav Glass * Fires nodeChange event
9d0be4bedcaad945c505994577198223ffc4ed9eDav Glass * @method _onFrameMouseUp
9d0be4bedcaad945c505994577198223ffc4ed9eDav Glass _onFrameMouseUp: function(e) {
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: e.frameTarget, changedType: 'mouseup', changedEvent: e.frameEvent });
9d0be4bedcaad945c505994577198223ffc4ed9eDav Glass * Fires nodeChange event
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method _onFrameMouseDown
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: e.frameTarget, changedType: 'mousedown', changedEvent: e.frameEvent });
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass * Caches a copy of the selection for key events. Only creating the selection on keydown
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass * @property _currentSelection
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * Holds the timer for selection clearing
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * @property _currentSelectionTimer
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * Flag to determine if we can clear the selection or not.
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * @property _currentSelectionClear
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Fires nodeChange event
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method _onFrameKeyDown
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass _onFrameKeyDown: function(e) {
998d2791b549446db8394dc80d46a94a247857d9Dav Glass this._currentSelectionTimer = Y.later(850, this, function() {
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keydown', changedEvent: e.frameEvent });
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode], changedEvent: e.frameEvent });
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-down', changedEvent: e.frameEvent });
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass * Fires nodeChange event
b7bd9aa409761c479bb0a2e5794295d35ebe24eaDav Glass * @method _onFrameKeyPress
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keypress', changedEvent: e.frameEvent });
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-press', changedEvent: e.frameEvent });
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass * Fires nodeChange event for keyup on specific keys
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass * @method _onFrameKeyUp
e20a95dc78bf51b6544e7bfb4e53ed190ecec3c9Dav Glass _onFrameKeyUp: function(e) {
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keyup', selection: sel, changedEvent: e.frameEvent });
762b21413a7bbc38b5c7b2d94385fb44f26f9d39Dav Glass this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-up', selection: sel, changedEvent: e.frameEvent });
998d2791b549446db8394dc80d46a94a247857d9Dav Glass this._currentSelectionClear = this._currentSelection = null;
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Pass through to the frame.execCommand method
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method execCommand
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @param {String} cmd The command to pass: inserthtml, insertimage, bold
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @param {String} val The optional value of the command: Helvetica
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @return {Node/NodeList} The Node or Nodelist affected by the command. Only returns on override commands, not browser defined commands.
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass e = { changedNode: sel.anchorNode, changedType: 'execcommand', nodes: ret };
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass case 'forecolor':
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass case 'backcolor':
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass case 'fontsize':
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass case 'fontname':
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Get the YUI instance of the frame
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method getInstance
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @return {YUI} The YUI instance bound to the frame.
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass getInstance: function() {
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Renders the Y.Frame to the passed node.
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method render
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @param {Selector/HTMLElement/Node} node The node to append the Editor to
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @return {EditorBase}
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @chainable
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass return this;
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Focus the contentWindow of the iframe
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method focus
15e7d5bd8a8fb4068cc8df277bb857b83a0891f5Dav Glass * @param {Function} fn Callback function to execute after focus happens
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @return {EditorBase}
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @chainable
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass return this;
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * Handles the showing of the Editor instance. Currently only handles the iframe
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * @method show
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * @return {EditorBase}
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * @chainable
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass show: function() {
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass return this;
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * Handles the hiding of the Editor instance. Currently only handles the iframe
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * @method hide
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * @return {EditorBase}
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass * @chainable
a0c3229e02af852e4b15bf6d4cf4e862440bb00eDav Glass hide: function() {
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass return this;
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * (Un)Filters the content of the Editor, cleaning YUI related code. //TODO better filtering
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @method getContent
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @return {String} The filtered content of the Editor
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass getContent: function() {
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass //Removing the _yuid from the objects in IE
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * @method NORMALIZE_FONTSIZE
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * @description Pulls the fontSize from a node, then checks for string values (x-large, x-small)
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * and converts them to pixel sizes. If the parsed size is different from the original, it calls
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass * node.setStyle to update the node with a pixel size for normalization.
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case '-webkit-xxx-large':
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case 'xx-large':
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case 'x-large':
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case 'large':
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case 'medium':
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case 'small':
f7aa62ea2e8cf43fbb9d83db5060db540ff1893fDav Glass case 'x-small':
9f2068537ef4a78d9a11fb5a136991d9d9e059a0Dav Glass * @property TABKEY
9f2068537ef4a78d9a11fb5a136991d9d9e059a0Dav Glass * @description The HTML markup to use for the tabkey
d5c8641a4c8bb3bf024ae7fe517387163591d325Dav Glass TABKEY: '<span class="tab"> </span>',
9f2068537ef4a78d9a11fb5a136991d9d9e059a0Dav Glass * @method FILTER_RGB
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass * @param String css The CSS string containing rgb(#,#,#);
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass * @description Converts an RGB color string to a hex color, example: rgb(0, 255, 0) converts to #00ff00
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass * @return String
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass var exp = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
24e95e1c11b518e1aaaa7f04882febe32de00b5eDav Glass var rgb = css.replace(exp, "$1,$2,$3,$4,$5").split(',');
9f2068537ef4a78d9a11fb5a136991d9d9e059a0Dav Glass * @property TAG2CMD
9f2068537ef4a78d9a11fb5a136991d9d9e059a0Dav Glass * @description A hash table of tags to their execcomand's
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * Hash table of keys to fire a nodeChange event for.
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @property NC_KEYS
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @type Object
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * The default modules to use inside the Frame
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @property USE
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @type Array
9a68201f57ed1257e4735227620d7ec556fe99e5Dav Glass USE: ['substitute', 'node', 'selector-css3', 'selection', 'stylesheet'],
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * The Class Name: editorBase
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @property NAME
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * Editor Strings. By default contains only the `title` property for the
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * Title of frame document (default "Rich Text Editor").
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @property STRINGS
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * The content to load into the Editor Frame
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @attribute content
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass Y.log('Stripping first carriage return from content before injecting', 'warn', 'editor');
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass getter: function() {
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * The value of the dir attribute on the HTML element of the frame. Default: ltr
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @attribute dir
c145dba89e51cac0a247d52f4f4c0c8d8245027dDav Glass * @attribute linkedcss
c145dba89e51cac0a247d52f4f4c0c8d8245027dDav Glass * @description An array of url's to external linked style sheets
c145dba89e51cac0a247d52f4f4c0c8d8245027dDav Glass * @type String
f69da96c272d2efe7f43da5150c13c0fe6899646Dav Glass * @attribute extracss
f69da96c272d2efe7f43da5150c13c0fe6899646Dav Glass * @description A string of CSS to add to the Head of the Editor
f69da96c272d2efe7f43da5150c13c0fe6899646Dav Glass * @type String
162527ab925c04aa8d6bbf78d0484a133a8076f1Dav Glass * @attribute defaultblock
162527ab925c04aa8d6bbf78d0484a133a8076f1Dav Glass * @description The default tag to use for block level items, defaults to: p
162527ab925c04aa8d6bbf78d0484a133a8076f1Dav Glass * @type String
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @event nodeChange
7a67e82a93bc7dc5bf9a62a3ad321c2424da37f7Dav Glass * @description Fired from several mouse/key/paste event points.
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * @param {Event.Facade} event An Event Facade object with the following specific properties added:
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>changedEvent</dt><dd>The event that caused the nodeChange</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>changedNode</dt><dd>The node that was interacted with</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>changedType</dt><dd>The type of change: mousedown, mouseup, right, left, backspace, tab, enter, etc..</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>commands</dt><dd>The list of execCommands that belong to this change and the dompath that's associated with the changedNode</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>classNames</dt><dd>An array of classNames that are applied to the changedNode and all of it's parents</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>dompath</dt><dd>A sorted array of node instances that make up the DOM path from the changedNode to body.</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>backgroundColor</dt><dd>The cascaded backgroundColor of the changedNode</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>fontColor</dt><dd>The cascaded fontColor of the changedNode</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>fontFamily</dt><dd>The cascaded fontFamily of the changedNode</dd>
daeb6d531149c45a2ceb543ae2cf1e56e5235bbeDav Glass * <dt>fontSize</dt><dd>The cascaded fontSize of the changedNode</dd>
dbf2c770f8178b12e8fe3c36bfa29df58ef13959Dav Glass * @type {Event.Custom}
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass * @event ready
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass * @description Fired after the frame is ready.
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass * @param {Event.Facade} event An Event Facade object.
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass * @type {Event.Custom}