|
1 | 1 | /* |
2 | | - Redactor 10.2.3 |
3 | | - Updated: August 15, 2015 |
| 2 | + Redactor 10.2.4 |
| 3 | + Updated: September 25, 2015 |
4 | 4 |
|
5 | 5 | http://imperavi.com/redactor/ |
6 | 6 |
|
|
92 | 92 |
|
93 | 93 | // Functionality |
94 | 94 | $.Redactor = Redactor; |
95 | | - $.Redactor.VERSION = '10.2.3'; |
| 95 | + $.Redactor.VERSION = '10.2.4'; |
96 | 96 | $.Redactor.modules = ['alignment', 'autosave', 'block', 'buffer', 'build', 'button', |
97 | 97 | 'caret', 'clean', 'code', 'core', 'dropdown', 'file', 'focus', |
98 | 98 | 'image', 'indent', 'inline', 'insert', 'keydown', 'keyup', |
|
477 | 477 | set: function(type) |
478 | 478 | { |
479 | 479 | // focus |
480 | | - if (!this.utils.browser('msie')) this.$editor.focus(); |
481 | | - |
482 | | - this.buffer.set(); |
483 | | - this.selection.save(); |
| 480 | + if (!this.utils.browser('msie') && !this.opts.linebreaks) |
| 481 | + { |
| 482 | + this.$editor.focus(); |
| 483 | + } |
484 | 484 |
|
485 | 485 | // get blocks |
486 | 486 | this.alignment.blocks = this.selection.getBlocks(); |
487 | 487 | this.alignment.type = type; |
488 | 488 |
|
| 489 | + this.buffer.set(); |
| 490 | + this.selection.save(); |
| 491 | + |
489 | 492 | // set alignment |
490 | 493 | if (this.alignment.isLinebreaksOrNoBlocks()) |
491 | 494 | { |
|
1363 | 1366 | setEvents: function() |
1364 | 1367 | { |
1365 | 1368 | // drop |
| 1369 | + this.$editor.on('dragover.redactor dragenter.redactor', function(e) |
| 1370 | + { |
| 1371 | + e.preventDefault(); |
| 1372 | + e.stopPropagation(); |
| 1373 | + }); |
| 1374 | + |
1366 | 1375 | this.$editor.on('drop.redactor', $.proxy(function(e) |
1367 | 1376 | { |
1368 | 1377 | e = e.originalEvent || e; |
|
1585 | 1594 |
|
1586 | 1595 | $button.on('mouseover', function() |
1587 | 1596 | { |
1588 | | - if ($(this).hasClass('redactor-button-disabled')) return; |
| 1597 | + if ($(this).hasClass('redactor-button-disabled')) |
| 1598 | + { |
| 1599 | + return; |
| 1600 | + } |
1589 | 1601 |
|
1590 | 1602 | var pos = $button.offset(); |
1591 | 1603 |
|
1592 | | - $tooltip.show(); |
1593 | 1604 | $tooltip.css({ |
1594 | 1605 | top: (pos.top + $button.innerHeight()) + 'px', |
1595 | 1606 | left: (pos.left + $button.innerWidth()/2 - $tooltip.innerWidth()/2) + 'px' |
1596 | 1607 | }); |
| 1608 | + $tooltip.show(); |
| 1609 | + |
1597 | 1610 | }); |
1598 | 1611 |
|
1599 | 1612 | $button.on('mouseout', function() |
|
3432 | 3445 | // disable scroll whan dropdown scroll |
3433 | 3446 | $dropdown.on('mouseover.redactor-dropdown', $.proxy(this.utils.disableBodyScroll, this)).on('mouseout.redactor-dropdown', $.proxy(this.utils.enableBodyScroll, this)); |
3434 | 3447 |
|
3435 | | - |
3436 | 3448 | e.stopPropagation(); |
3437 | 3449 | }, |
3438 | 3450 | closeHandler: function(e) |
|
3466 | 3478 |
|
3467 | 3479 | if (!$dropdown.hasClass('dropact') && !$dropdown.hasClass('redactor-dropdown-link-inactive')) |
3468 | 3480 | { |
3469 | | - $dropdown.removeClass('dropact'); |
3470 | | - $dropdown.off('mouseover mouseout'); |
| 3481 | + if ($dropdown.hasClass('redactor-dropdown')) |
| 3482 | + { |
| 3483 | + $dropdown.removeClass('dropact'); |
| 3484 | + $dropdown.off('mouseover mouseout'); |
| 3485 | + } |
3471 | 3486 |
|
3472 | 3487 | this.dropdown.hideAll(); |
3473 | 3488 | } |
|
4428 | 4443 | }); |
4429 | 4444 | } |
4430 | 4445 |
|
| 4446 | + if (tag != 'u') |
| 4447 | + { |
| 4448 | + var _this = this; |
| 4449 | + this.$editor.find('unline').each(function(i,s) |
| 4450 | + { |
| 4451 | + _this.utils.replaceToTag(s, 'u'); |
| 4452 | + }); |
| 4453 | + } |
| 4454 | + |
4431 | 4455 | this.selection.restore(); |
4432 | 4456 | this.code.sync(); |
4433 | 4457 |
|
|
4487 | 4511 | }); |
4488 | 4512 | } |
4489 | 4513 |
|
| 4514 | + if (tag != 'u') |
| 4515 | + { |
| 4516 | + this.$editor.find('u').each(function(i,s) |
| 4517 | + { |
| 4518 | + self.utils.replaceToTag(s, 'unline'); |
| 4519 | + }); |
| 4520 | + } |
| 4521 | + |
4490 | 4522 | if (tag != 'span') |
4491 | 4523 | { |
4492 | 4524 | this.$editor.find(tag).each(function() |
|
5644 | 5676 | $(this.keyup.current).remove(); |
5645 | 5677 | } |
5646 | 5678 |
|
| 5679 | + this.keyup.removeEmptyLists(); |
| 5680 | + |
5647 | 5681 | // if empty |
5648 | 5682 | return this.keyup.formatEmpty(e); |
5649 | 5683 | } |
|
5671 | 5705 |
|
5672 | 5706 | this.caret.setEnd(node); |
5673 | 5707 | }, |
| 5708 | + removeEmptyLists: function() |
| 5709 | + { |
| 5710 | + var removeIt = function() |
| 5711 | + { |
| 5712 | + var html = $.trim(this.innerHTML).replace(/\/t\/n/g, ''); |
| 5713 | + if (html === '') |
| 5714 | + { |
| 5715 | + $(this).remove(); |
| 5716 | + } |
| 5717 | + }; |
| 5718 | + |
| 5719 | + this.$editor.find('li').each(removeIt); |
| 5720 | + this.$editor.find('ul, ol').each(removeIt); |
| 5721 | + }, |
5674 | 5722 | formatEmpty: function(e) |
5675 | 5723 | { |
5676 | 5724 | var html = $.trim(this.$editor.html()); |
|
6289 | 6337 | toggle: function(cmd) |
6290 | 6338 | { |
6291 | 6339 | this.placeholder.remove(); |
6292 | | - if (!this.utils.browser('msie')) this.$editor.focus(); |
| 6340 | + |
| 6341 | + if (!this.utils.browser('msie') && !this.opts.linebreaks) |
| 6342 | + { |
| 6343 | + this.$editor.focus(); |
| 6344 | + } |
6293 | 6345 |
|
6294 | 6346 | this.buffer.set(); |
6295 | 6347 | this.selection.save(); |
|
7240 | 7292 | else |
7241 | 7293 | { |
7242 | 7294 | // bootstrap modal |
7243 | | - if ($('.modal-body').length > 0) |
| 7295 | + if ($('.modal-body:visible').length > 0) |
7244 | 7296 | { |
7245 | 7297 |
|
7246 | | - $('.modal.in .modal-body').append(this.$pasteBox); |
| 7298 | + $('.modal.in .modal-body:visible').append(this.$pasteBox); |
7247 | 7299 | } |
7248 | 7300 | else |
7249 | 7301 | { |
|
7488 | 7540 | nodes = (typeof nodes == 'undefined') ? this.selection.getNodes() : nodes; |
7489 | 7541 | $.each(nodes, $.proxy(function(i,node) |
7490 | 7542 | { |
7491 | | - if (this.utils.isBlock(node)) |
| 7543 | + var parent = $(node).parent(); |
| 7544 | + if (i === 0 && this.utils.isBlock(parent)) |
| 7545 | + { |
| 7546 | + this.selection.lastBlock = parent[0]; |
| 7547 | + blocks.push(parent[0]); |
| 7548 | + } |
| 7549 | + else if (this.utils.isBlock(node)) |
7492 | 7550 | { |
7493 | 7551 | this.selection.lastBlock = node; |
7494 | 7552 | blocks.push(node); |
|
0 commit comments