File tree Expand file tree Collapse file tree 3 files changed +13
-29
lines changed Expand file tree Collapse file tree 3 files changed +13
-29
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ var content = (function() {
10
10
var zeroWidthNonBreakingSpace = / \uFEFF / g;
11
11
12
12
return {
13
+
14
+ /**
15
+ * Clean up the Html.
16
+ */
17
+ tidyHtml : function ( element ) {
18
+ this . normalizeTags ( element ) ;
19
+ } ,
20
+
21
+
13
22
/**
14
23
* Remove empty tags and merge consecutive tags (they must have the same
15
24
* attributes).
@@ -164,27 +173,6 @@ var content = (function() {
164
173
}
165
174
} ,
166
175
167
- /**
168
- * Convert the first and last space to a non breaking space charcter to
169
- * prevent visual collapse by some browser.
170
- *
171
- * @method normalizeSpaces
172
- * @param {HTMLElement } element The element to process.
173
- */
174
- normalizeSpaces : function ( element ) {
175
- var nonBreakingSpace = '\u00A0' ;
176
-
177
- if ( ! element ) return ;
178
-
179
- if ( element . nodeType === nodeType . textNode ) {
180
- element . nodeValue = element . nodeValue . replace ( / ^ ( \s ) / , nonBreakingSpace ) . replace ( / ( \s ) $ / , nonBreakingSpace ) ;
181
- }
182
- else {
183
- this . normalizeSpaces ( element . firstChild ) ;
184
- this . normalizeSpaces ( element . lastChild ) ;
185
- }
186
- } ,
187
-
188
176
/**
189
177
* Get all tags that start or end inside the range
190
178
*/
Original file line number Diff line number Diff line change @@ -141,8 +141,7 @@ Editable.prototype.enable = function($elem, normalize) {
141
141
142
142
if ( normalize ) {
143
143
$elem . each ( function ( index , el ) {
144
- content . normalizeTags ( el ) ;
145
- content . normalizeSpaces ( el ) ;
144
+ content . tidyHtml ( el ) ;
146
145
} ) ;
147
146
}
148
147
Original file line number Diff line number Diff line change @@ -102,10 +102,8 @@ var createDefaultBehavior = function(editable) {
102
102
}
103
103
element . appendChild ( after ) ;
104
104
105
- content . normalizeTags ( newNode ) ;
106
- content . normalizeSpaces ( newNode ) ;
107
- content . normalizeTags ( element ) ;
108
- content . normalizeSpaces ( element ) ;
105
+ content . tidyHtml ( newNode ) ;
106
+ content . tidyHtml ( element ) ;
109
107
element . focus ( ) ;
110
108
} ,
111
109
@@ -136,8 +134,7 @@ var createDefaultBehavior = function(editable) {
136
134
merger . parentNode . removeChild ( merger ) ;
137
135
138
136
cursor . save ( ) ;
139
- content . normalizeTags ( container ) ;
140
- content . normalizeSpaces ( container ) ;
137
+ content . tidyHtml ( container ) ;
141
138
cursor . restore ( ) ;
142
139
cursor . setVisibleSelection ( ) ;
143
140
} ,
You can’t perform that action at this time.
0 commit comments