editor-base.js revision 1f5da3ee0a7dfb278ab235231e5af6aad13326d4
1537N/A * Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
1537N/A * Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
1537N/A var EditorBase = function() {
1537N/A initializer: function() {
1537N/A designMode: true,
host: this
emitFacade: true,
bubbles: true,
destructor: function() {
this.detachAll();
newStyles = {};
_lastBookmark: null,
_resolveChangedNode: function(n) {
while (!found) {
if (lc) {
if (lc2) {
found = true;
found = true;
if (lc) {
if (lc) {
n = lc;
_defNodeChangeFn: function(e) {
} catch (ie) {}
switch (e.changedType) {
if (!EditorBase.NC_KEYS[e.changedEvent.keyCode] && !e.changedEvent.shiftKey && !e.changedEvent.ctrlKey && (e.changedEvent.keyCode !== 13)) {
if (e.commands) {
if (cmd) {
if (family2) {
if (family) {
if (!e.fontFamily) {
if (!e.fontSize) {
if (!e.fontColor) {
if (!e.backgroundColor) {
while (domNode !== null) {
if ((domNode === inst.config.doc.documentElement) || (domNode === inst.config.doc) || !domNode.tagName) {
domNode = null;
domNode = null;
domNode = null;
if (nodeList) {
_afterFrameReady: function() {
_beforeFrameDeactivate: function() {
_onFrameActivate: function() {
n.remove();
_onFrameMouseUp: function(e) {
this.fire('nodeChange', { changedNode: e.frameTarget, changedType: 'mouseup', changedEvent: e.frameEvent });
_onFrameMouseDown: function(e) {
this.fire('nodeChange', { changedNode: e.frameTarget, changedType: 'mousedown', changedEvent: e.frameEvent });
_currentSelection: null,
_currentSelectionTimer: null,
_currentSelectionClear: null,
_onFrameKeyDown: function(e) {
if (!this._currentSelection) {
if (this._currentSelectionTimer) {
this._currentSelectionClear = true;
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keydown', changedEvent: e.frameEvent });
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode], changedEvent: e.frameEvent });
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-down', changedEvent: e.frameEvent });
_onFrameKeyPress: function(e) {
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keypress', changedEvent: e.frameEvent });
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-press', changedEvent: e.frameEvent });
_onFrameKeyUp: function(e) {
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: 'keyup', selection: sel, changedEvent: e.frameEvent });
this.fire('nodeChange', { changedNode: sel.anchorNode, changedType: EditorBase.NC_KEYS[e.keyCode] + '-up', selection: sel, changedEvent: e.frameEvent });
if (this._currentSelectionClear) {
* @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() {
* @param {Selector/HTMLElement/Node} node The node to append the Editor to
show: function() {
hide: function() {
getContent: function() {
return html;
NORMALIZE_FONTSIZE: function(n) {
switch (size) {
return size;
* @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,
linkedcss: {
if (this.frame) {
return css;
extracss: {
value: false,
if (this.frame) {
return css;
defaultblock: {
* <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>