aboutsummaryrefslogtreecommitdiff
path: root/node_modules/labs/rich-text-editor.reel/rich-text-editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/labs/rich-text-editor.reel/rich-text-editor.js')
-rw-r--r--node_modules/labs/rich-text-editor.reel/rich-text-editor.js1716
1 files changed, 1716 insertions, 0 deletions
diff --git a/node_modules/labs/rich-text-editor.reel/rich-text-editor.js b/node_modules/labs/rich-text-editor.reel/rich-text-editor.js
new file mode 100644
index 00000000..b88d5868
--- /dev/null
+++ b/node_modules/labs/rich-text-editor.reel/rich-text-editor.js
@@ -0,0 +1,1716 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module "montage/ui/rich-text-editor.reel"
8 @requires montage/core/core
9*/
10var Montage = require("montage/core/core").Montage,
11 Component = require("montage/ui/component").Component,
12 MutableEvent = require("montage/core/event/mutable-event").MutableEvent,
13 Resizer = require("node_modules/labs/rich-text-editor.reel/rich-text-resizer").Resizer,
14 Sanitizer = require("node_modules/labs/rich-text-editor.reel/rich-text-sanitizer").Sanitizer;
15 Point = require("montage/core/geometry/point").Point;
16
17
18/**
19 @class module:"montage/ui/rich-text-editor.reel".RichTextEditor
20 @extends module:montage/ui/component.Component
21*/
22exports.RichTextEditor = Montage.create(Component,/** @lends module:"montage/ui/rich-text-editor.reel".RichTextEditor# */ {
23
24 /**
25 Description TODO
26 @private
27 */
28 _hasSelectionChangeEvent: {
29 enumerable: false,
30 value: null // Need to be preset to null, will be set to true or false later on
31 },
32
33 /**
34 Description TODO
35 @private
36 */
37 _uniqueId: {
38 enumerable: false,
39 value: Math.floor(Math.random() * 1000) + "-" + Math.floor(Math.random() * 1000)
40 },
41
42 /**
43 Description TODO
44 @private
45 */
46 _needsSelectionReset: {
47 enumerable: false,
48 value: false
49 },
50
51 /**
52 Description TODO
53 @private
54 */
55 _selectionChangeTimer: {
56 enumerable: false,
57 value: null
58 },
59
60 /**
61 Description TODO
62 @private
63 */
64 _activeLink: {
65 enumerable: false,
66 value: null
67 },
68
69 /**
70 Description TODO
71 @private
72 */
73 _needsActiveLinkOn: {
74 enumerable: false,
75 value: false
76 },
77
78 /**
79 Description TODO
80 @private
81 */
82 _hasFocus: {
83 enumerable: false,
84 value: false
85 },
86
87 /**
88 Description TODO
89 @type {Function}
90 */
91 hasFocus: {
92 enumerable: true,
93 get: function() {
94 return this._hasFocus;
95 }
96 },
97
98 /**
99 Description TODO
100 @private
101 */
102 _dirty: {
103 enumerable: false,
104 value: false
105 },
106
107 /**
108 Description TODO
109 @private
110 */
111 _value: {
112 enumerable: false,
113 value: ""
114 },
115
116 /**
117 Description TODO
118 @type {Function}
119 */
120 value: {
121 enumerable: true,
122 serializable: true,
123 get: function() {
124 var contentNode = this.element.firstChild,
125 content;
126
127 if (this._dirtyValue) {
128 if (this._resizer) {
129 contentNode = this._resizer.cleanup(contentNode);
130 }
131
132 contentNode = this._cleanupActiveLink(contentNode);
133
134 content = contentNode ? contentNode.innerHTML : "";
135 if (content == "<br>") {
136 // when the contentEditable div is emptied, Chrome add a <br>, let's filter it out
137 content = "";
138 }
139 if (this._sanitizer) {
140 content = this._sanitizer.didGetValue(content, this._uniqueId);
141 }
142
143 this._value = content;
144 this._dirtyValue = false;
145 }
146 return this._value;
147 },
148 set: function(value) {
149 if (this._value !== value || this._dirtyValue) {
150 if (this._resizer) {
151 this._needsHideResizer = true;
152 }
153 if (this._sanitizer) {
154 value = this._sanitizer.willSetValue(value, this._uniqueId);
155 }
156 this._value = value;
157 this._dirtyValue = false;
158 this._dirtyTextValue = true;
159 this._needsSelectionReset = true;
160 this._needsResetContent = true;
161 this.needsDraw = true;
162 }
163 }
164 },
165
166 /**
167 Description TODO
168 @private
169 */
170 _textValue: {
171 enumerable: false,
172 value: ""
173 },
174
175 /**
176 Description TODO
177 @type {Function}
178 */
179 textValue: {
180 enumerable: true,
181 get: function() {
182 var contentNode = this.element.firstChild,
183 childNodes;
184
185 if (this._dirtyTextValue) {
186 if (contentNode) {
187 if (this._resizer) {
188 contentNode = this._resizer.cleanup(contentNode);
189 }
190 contentNode = this._cleanupActiveLink(contentNode);
191 }
192
193 this._textValue = contentNode ? this._innerText(contentNode) : "";
194 this._dirtyTextValue = false;
195 }
196 return this._textValue;
197 },
198 set: function (value) {
199 if (this._textValue !== value || this._dirtyTextValue) {
200 if (this._resizer) {
201 this._needsHideResizer = true;
202 }
203
204 this._textValue = value;
205 this._dirtyTextValue = false;
206 this._dirtyValue = true;
207 this._needsSelectionReset = true;
208 this._needsResetContent = true;
209 this.needsDraw = true;
210 }
211 }
212 },
213
214 /**
215 Description TODO
216 @type {}
217 */
218 delegate: {
219 enumerable: true,
220 value: null
221 },