/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
/**
@module "montage/ui/rich-text-editor.reel"
@requires montage/core/core
*/
var Montage = require("montage/core/core").Montage,
Component = require("montage/ui/component").Component,
MutableEvent = require("montage/core/event/mutable-event").MutableEvent,
Resizer = require("node_modules/labs/rich-text-editor.reel/rich-text-resizer").Resizer,
Sanitizer = require("node_modules/labs/rich-text-editor.reel/rich-text-sanitizer").Sanitizer;
/**
@class module:"montage/ui/rich-text-editor.reel".RichTextEditor
@extends module:montage/ui/component.Component
*/
exports.RichTextEditor = Montage.create(Component,/** @lends module:"montage/ui/rich-text-editor.reel".RichTextEditor# */ {
/**
Description TODO
@private
*/
_hasSelectionChangeEvent: {
enumerable: false,
value: null // Need to be preset to null, will be set to true or false later on
},
/**
Description TODO
@private
*/
_uniqueId: {
enumerable: false,
value: Math.floor(Math.random() * 1000) + "-" + Math.floor(Math.random() * 1000)
},
/**
Description TODO
@private
*/
_needsSelectionReset: {
enumerable: false,
value: false
},
/**
Description TODO
@private
*/
_selectionChangeTimer: {
enumerable: false,
value: null
},
/**
Description TODO
@private
*/
_activeLink: {
enumerable: false,
value: null
},
/**
Description TODO
@private
*/
_needsActiveLinkOn: {
enumerable: false,
value: false
},
/**
Description TODO
@private
*/
_hasFocus: {
enumerable: false,
value: false
},
/**
Description TODO
@type {Function}
*/
hasFocus: {
enumerable: true,
get: function() {
return this._hasFocus;
}
},
/**
Description TODO
@private
*/
_dirty: {
enumerable: false,
value: false
},
/**
Description TODO
@private
*/
_value: {
enumerable: false,
value: ""
},
/**
Description TODO
@type {Function}
*/
value: {
enumerable: true,
serializable: true,
get: function() {
var contentNode = this.element.firstChild,
content;
if (this._dirtyValue) {
if (this._resizer) {
contentNode = this._resizer.cleanup(contentNode);
}
contentNode = this._cleanupActiveLink(contentNode);
content = contentNode ? contentNode.innerHTML : "";
if (content == "<br>") {
// when the contentEditable div is emptied, Chrome add a <br>, let's filter it out
content = "";
}
if (this._sanitizer) {
content = this._sanitizer.didGetValue(content, this._uniqueId);
}
this._value = content;
this._dirtyValue = false;
}
return this._value;
|