Changeset 676
- Timestamp:
- 07/31/10 21:49:07 (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wymeditor/jquery.wymeditor.js
r673 r676 1271 1271 WYMeditor.editor.prototype.insert = function(html) { 1272 1272 // Do we have a selection? 1273 if (this._iframe.contentWindow.getSelection().focusNode != null) { 1273 var selection = this._iframe.contentWindow.getSelection(), 1274 range, 1275 node; 1276 if (selection.focusNode != null) { 1274 1277 // Overwrite selection with provided html 1275 this._exec( WYMeditor.INSERT_HTML, html); 1278 range = selection.getRangeAt(0); 1279 node = range.createContextualFragment(html); 1280 range.deleteContents(); 1281 range.insertNode(node); 1276 1282 } else { 1277 1283 // Fall back to the internal paste function if there's no selection … … 1281 1287 1282 1288 WYMeditor.editor.prototype.wrap = function(left, right) { 1283 // Do we have a selection? 1284 if (this._iframe.contentWindow.getSelection().focusNode != null) { 1285 // Wrap selection with provided html 1286 this._exec( WYMeditor.INSERT_HTML, left + this._iframe.contentWindow.getSelection().toString() + right); 1287 } 1289 this.insert(left + this._iframe.contentWindow.getSelection().toString() + right); 1288 1290 }; 1289 1291 1290 1292 WYMeditor.editor.prototype.unwrap = function() { 1291 // Do we have a selection? 1292 if (this._iframe.contentWindow.getSelection().focusNode != null) { 1293 // Unwrap selection 1294 this._exec( WYMeditor.INSERT_HTML, this._iframe.contentWindow.getSelection().toString() ); 1295 } 1293 this.insert(this._iframe.contentWindow.getSelection().toString()); 1296 1294 }; 1297 1295
Note: See TracChangeset
for help on using the changeset viewer.