Skip to content

Commit

Permalink
Merge pull request #115 in TINYMCE/tinymce from GH-3237 to master
Browse files Browse the repository at this point in the history
* commit 'eb5f4f2cb7e604d763d3674ae7f49b587fa1138e':
  GH-3237: some PR cleanup
  Limit the width of the offscreen selection so that it does not accidentally become visible.
  Add a test that the cE=false offscreen selection remains offscreen.
  • Loading branch information
spocke committed Dec 7, 2016
2 parents d80bb52 + eb5f4f2 commit ca2b547
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/tinymce/classes/SelectionOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@ define("tinymce/SelectionOverrides", [
rootClass + ' .mce-offscreen-selection {' +
'position: absolute;' +
'left: -9999999999px;' +
'max-width: 1000000px;' +
'}' +
rootClass + ' *[contentEditable=false] {' +
'cursor: default;' +
Expand Down
26 changes: 26 additions & 0 deletions tests/tinymce/SelectionOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,30 @@ ModuleLoader.require([
// Since we can't do a real click we need to check if it gets sucked in towards the cE=false block
equal(editor.selection.getNode().nodeName !== 'P', true);
});

test('offscreen copy of cE=false block remains offscreen', function() {
if (tinymce.isIE || tinymce.isGecko || tinymce.isOpera) {
editor.setContent(
'<table contenteditable="false" style="width: 100%; table-layout: fixed">' +
'<tbody><tr><td>1</td><td>2</td></tr></tbody>' +
'</table>'
);

editor.selection.select(editor.dom.select('table')[0]);
var offscreenSelection = editor.dom.select('.mce-offscreen-selection')[0];

ok(offscreenSelection.offsetLeft !== undefined, 'The offscreen selection\'s left border is undefined');
ok(offscreenSelection.offsetLeft < 0, 'The offscreen selection\'s left border is onscreen');
ok(offscreenSelection.offsetWidth + offscreenSelection.offsetLeft < 0,
'The cE=false offscreen selection is visible on-screen. Right edge: ' +
offscreenSelection.offsetLeft + '+' + offscreenSelection.offsetWidth + '=' +
(offscreenSelection.offsetLeft + offscreenSelection.offsetWidth) + 'px'
);
} else {
// Chrome and Safari behave correctly, and PhantomJS also declares itself as WebKit but does not
// put the off-screen selection off-screen, so fails the above tests. However, it has no visible UI,
// so everything is off-screen anyway :-)
ok(true, 'Not a tested browser - Chrome & Safari work, PhantomJS does not put the selection off screen');
}
});
});

0 comments on commit ca2b547

Please sign in to comment.