Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

FIXED: Problem where inline styles may be applied beyond the end of t…

…he selection.

Signed-off-by: Adrian Sutton <adrian.sutton@ephox.com>
  • Loading branch information...
commit 8d02ec2a891c1511d69e797094795a9f8f84ecef 1 parent eae310d
Yonas Yanfa authored spocke committed
2  jscripts/tiny_mce/classes/dom/RangeUtils.js
@@ -93,7 +93,7 @@
93 93
94 94 // If index based end position then resolve it
95 95 if (endContainer.nodeType == 1 && endContainer.hasChildNodes())
96   - endContainer = endContainer.childNodes[Math.min(startOffset == endOffset ? endOffset : endOffset - 1, endContainer.childNodes.length - 1)];
  96 + endContainer = endContainer.childNodes[Math.min(endOffset - 1, endContainer.childNodes.length - 1)];
97 97
98 98 // Find common ancestor and end points
99 99 ancestor = dom.findCommonAncestor(startContainer, endContainer);
20 tests/tinymce.Formatter_apply.html
@@ -624,6 +624,26 @@
624 624 equals(getContent(), '<table><tbody><tr><td><span class="a b c" style="color: #ff0000;" title="test">cell 1</span></td><td>cell 2</td></tr></tbody></table>', 'Apply format on single element that matches a selector');
625 625 //'<p class="a b c" style="color: #ff0000;" title="test">1234</p>', 'Apply format on single element that matches a selector');
626 626 });
  627 +
  628 +test('Formatter - Bold and italics is applied to text that is not highlighted', function() {
  629 + editor.setContent('<p>test1 test2 test3 test4 test5 test6</p>');
  630 + editor.execCommand('SelectAll');
  631 + editor.execCommand('FontName',false,'Arial');
  632 + equals(editor.getContent(), '<p><span style="font-family: ' + fontFace('Arial') + ';">test1 test2 test3 test4 test5 test6</span></p>', 'Font face should be Arial.');
  633 +
  634 + rng = editor.dom.createRng();
  635 + rng.setStart(editor.dom.select('span')[0].firstChild, 0);
  636 + rng.setEnd(editor.dom.select('span')[0].firstChild, 12);
  637 + editor.selection.setRng(rng);
  638 + editor.execCommand('Bold');
  639 + equals(editor.getContent(), '<p><span style="font-family: ' + fontFace('Arial') + ';"><strong>test1 test2</strong> test3 test4 test5 test6</span></p>', 'Selected text should be bold.');
  640 +
  641 + rng.setStart(editor.dom.select('strong')[0].firstChild, 6);
  642 + rng.setEnd(editor.dom.select('strong')[0].firstChild, 11);
  643 + editor.selection.setRng(rng);
  644 + editor.execCommand('Italic');
  645 + equals(editor.getContent(), '<p><span style="font-family: ' + fontFace('Arial') + ';"><strong>test1 <em>test2</em></strong> test3 test4 test5 test6</span></p>', 'Selected text should be bold.');
  646 +});
627 647
628 648 /*
629 649 test('Formatter - apply (list block)', function() {

0 comments on commit 8d02ec2

Please sign in to comment.
Something went wrong with that request. Please try again.