editor-base.js revision a3a305284c3c0e607754b4841fc99d730508f0a6
2976N/A * Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
2976N/A * Base class for Editor. Handles the business logic of Editor, no GUI involved only utility methods and events.
2976N/A var EditorBase = function() {
2976N/A initializer: function() {
5636N/A designMode: true,
emitFacade: true,
bubbles: true,
destructor: function() {
this.detachAll();
newStyles = {};
_lastBookmark: null,
_defNodeChangeFn: function(e) {
switch (e.changedType) {
if (this._lastPara) {
delete this._lastPara;
b.remove();
if (para2) {
para2 = null;
if (prev) {
while (!found) {
if (lc) {
if (lc2) {
found = true;
found = true;
if (lc) {
this._lastPara = p;
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() {
_onFrameActivate: function() {
if (this._lastBookmark) {
this._lastBookmark = null;
_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;
* @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;
* <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>