start project

This commit is contained in:
Gustavo Luigi committed 2023-11-27 18:56:41 -03:00
1 parent 88f09b93d5
commit c7373eb7c0
618 files changed
+281982 -1

No files matched your search

@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html>
<head>
<title>Automatic link tests</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script src="js/dsl.js"></script>
<script src="js/autolink.actions.js"></script>
<script src="js/states.js"></script>
<script><!--
window.robotUsesSymbols = true;
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Automatic Links", {
autostart: false,
setup: function() {
window.queue = new dsl.Queue();
}
});
if (!tinymce.isIE) {
asyncTest('Typing a HTTP URL', function() {
TypingHTTPURL.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPURL.inA(ParagraphWithMarginLeft).gives(new RegExp('^<p style="margin-left: 60px;"><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPURL.inA(ParagraphWithPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px;"><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPURL.inA(ParagraphWithMarginAndPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px; margin-left: 60px;"><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPURL.inA(NonEmptyHeading).gives(new RegExp('^<h1><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test</h1>$'));
TypingHTTPURL.inA(TableCellWithoutBrs2).gives(new RegExp('^<table><tbody><tr><td><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingHTTPURL.inA(TableCellWithBrsFirstLine2).gives(new RegExp('^<table><tbody><tr><td><a href="http://www.ephox.com">http://www.ephox.com</a>(\\s|&nbsp;)Test<br />Line 2</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingEclipsedHTTPURL.inA(NonEmptyParagraph).gives(new RegExp('^<p>\\(<a href="http://www.ephox.com">http://www.ephox.com</a>\\)(\\s|&nbsp;)Test</p>$'));
TypingHTTPURLAndNewline.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="http://www.ephox.com">http://www.ephox.com</a></p><p>(Test|<a href=\"http://www.ephox.com\"></a>Test)</p>$'));
queue.done();
});
asyncTest('Typing a HTTPS URL', function() {
TypingHTTPSURL.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPSURL.inA(ParagraphWithMarginLeft).gives(new RegExp('^<p style="margin-left: 60px;"><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPSURL.inA(ParagraphWithPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px;"><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPSURL.inA(ParagraphWithMarginAndPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px; margin-left: 60px;"><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingHTTPSURL.inA(NonEmptyHeading).gives(new RegExp('^<h1><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test</h1>$'));
TypingHTTPSURL.inA(TableCellWithoutBrs2).gives(new RegExp('^<table><tbody><tr><td><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingHTTPSURL.inA(TableCellWithBrsFirstLine2).gives(new RegExp('^<table><tbody><tr><td><a href="https://www.ephox.com">https://www.ephox.com</a>(\\s|&nbsp;)Test<br />Line 2</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingEclipsedHTTPSURL.inA(NonEmptyParagraph).gives(new RegExp('^<p>\\(<a href="https://www.ephox.com">https://www.ephox.com</a>\\)(\\s|&nbsp;)Test</p>$'));
TypingHTTPSURLAndNewline.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="https://www.ephox.com">https://www.ephox.com</a></p><p>(Test|<a href=\"https://www.ephox.com\"></a>Test)</p>$'));
queue.done();
});
asyncTest('Typing a SSH URL', function() {
TypingSSHURL.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingSSHURL.inA(ParagraphWithMarginLeft).gives(new RegExp('^<p style="margin-left: 60px;"><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingSSHURL.inA(ParagraphWithPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px;"><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingSSHURL.inA(ParagraphWithMarginAndPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px; margin-left: 60px;"><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingSSHURL.inA(NonEmptyHeading).gives(new RegExp('^<h1><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test</h1>$'));
TypingSSHURL.inA(TableCellWithoutBrs2).gives(new RegExp('^<table><tbody><tr><td><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingSSHURL.inA(TableCellWithBrsFirstLine2).gives(new RegExp('^<table><tbody><tr><td><a href="ssh://www.ephox.com">ssh://www.ephox.com</a>(\\s|&nbsp;)Test<br />Line 2</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingEclipsedSSHURL.inA(NonEmptyParagraph).gives(new RegExp('^<p>\\(<a href="ssh://www.ephox.com">ssh://www.ephox.com</a>\\)(\\s|&nbsp;)Test</p>$'));
TypingSSHURLAndNewline.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="ssh://www.ephox.com">ssh://www.ephox.com</a></p><p>(Test|<a href=\"ssh://www.ephox.com\"></a>Test)</p>$'));
queue.done();
});
asyncTest('Typing a FTP URL', function() {
TypingFTPURL.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingFTPURL.inA(ParagraphWithMarginLeft).gives(new RegExp('^<p style="margin-left: 60px;"><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingFTPURL.inA(ParagraphWithPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px;"><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingFTPURL.inA(ParagraphWithMarginAndPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px; margin-left: 60px;"><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingFTPURL.inA(NonEmptyHeading).gives(new RegExp('^<h1><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test</h1>$'));
TypingFTPURL.inA(TableCellWithoutBrs2).gives(new RegExp('^<table><tbody><tr><td><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingFTPURL.inA(TableCellWithBrsFirstLine2).gives(new RegExp('^<table><tbody><tr><td><a href="ftp://www.ephox.com">ftp://www.ephox.com</a>(\\s|&nbsp;)Test<br />Line 2</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingEclipsedFTPURL.inA(NonEmptyParagraph).gives(new RegExp('^<p>\\(<a href="ftp://www.ephox.com">ftp://www.ephox.com</a>\\)(\\s|&nbsp;)Test</p>$'));
TypingFTPURLAndNewline.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="ftp://www.ephox.com">ftp://www.ephox.com</a></p><p>(Test|<a href=\"ftp://www.ephox.com\"></a>Test)</p>$'));
queue.done();
});
asyncTest('Typing a WWW URL', function() {
TypingWWWURL.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingWWWURL.inA(ParagraphWithMarginLeft).gives(new RegExp('^<p style="margin-left: 60px;"><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingWWWURL.inA(ParagraphWithPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px;"><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingWWWURL.inA(ParagraphWithMarginAndPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px; margin-left: 60px;"><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test</p>$'));
TypingWWWURL.inA(NonEmptyHeading).gives(new RegExp('^<h1><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test</h1>$'));
TypingWWWURL.inA(TableCellWithoutBrs2).gives(new RegExp('^<table><tbody><tr><td><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingWWWURL.inA(TableCellWithBrsFirstLine2).gives(new RegExp('^<table><tbody><tr><td><a href="http://www.ephox.com">www.ephox.com</a>(\\s|&nbsp;)Test<br />Line 2</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingEclipsedWWWURL.inA(NonEmptyParagraph).gives(new RegExp('^<p>\\(<a href="http://www.ephox.com">www.ephox.com</a>\\)(\\s|&nbsp;)Test</p>$'));
TypingWWWURLAndNewline.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="http://www.ephox.com">www.ephox.com</a></p><p>(Test|<a href=\"http://www.ephox.com\"></a>Test)</p>$'));
queue.done();
});
asyncTest('Typing a WWW URL with end dot', function() {
TypingWWWURLWithEndDot.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test</p>$'));
TypingWWWURLWithEndDot.inA(ParagraphWithMarginLeft).gives(new RegExp('^<p style="margin-left: 60px;"><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test</p>$'));
TypingWWWURLWithEndDot.inA(ParagraphWithPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px;"><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test</p>$'));
TypingWWWURLWithEndDot.inA(ParagraphWithMarginAndPaddingLeft).gives(new RegExp('^<p style="padding-left: 60px; margin-left: 60px;"><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test</p>$'));
TypingWWWURLWithEndDot.inA(NonEmptyHeading).gives(new RegExp('^<h1><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test</h1>$'));
TypingWWWURLWithEndDot.inA(TableCellWithoutBrs2).gives(new RegExp('^<table><tbody><tr><td><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test</td><td>&nbsp;</td></tr></tbody></table>$'));
TypingWWWURLWithEndDot.inA(TableCellWithBrsFirstLine2).gives(new RegExp('^<table><tbody><tr><td><a href="http://www.site.com">www.site.com</a>.(\\s|&nbsp;)Test<br />Line 2</td><td>&nbsp;</td></tr></tbody></table>$'));
queue.done();
});
asyncTest('Typing a mail address', function() {
TypingMailAddr.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="mailto:user@domain.com">user@domain.com</a>(\\s|&nbsp;)Test</p>$'));
TypingDashedMailAddr.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="mailto:first-last@domain.com">first-last@domain.com</a>(\\s|&nbsp;)Test</p>$'));
queue.done();
});
asyncTest('Typing a mail address with protocol', function() {
TypingMailAddrWithProtocol.inA(NonEmptyParagraph).gives(new RegExp('^<p><a href="mailto:user@domain.com">mailto:user@domain.com</a>(\\s|&nbsp;)Test</p>$'));
queue.done();
});
} else {
test("IE has built in support", function() {
ok(true, "Skipped");
});
}
var initTinyFunction = function(){
tinymce.init({
mode : "exact",
elements : "elm1",
plugins : "autolink",
add_unload_trigger : false,
webkit_fake_resize: false,
theme_advanced_styles : 'test1=test1;test2=test2',
valid_styles : {
'*' : 'text-align,padding-left,color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display'
},
indent : 0,
init_instance_callback : function(ed) {
editor = ed;
}
});
}
--></script>
</head>
<body>
<h1 id="qunit-header">Automatic link tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
</div>
<script src="js/jsrobot/robot.js"></script>
<script>
initWhenTinyAndRobotAreReady(initTinyFunction);
</script>
</body>
</html>
@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html>
<head>
<title>Fullpage plugin tests</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Fullpage plugin", {
autostart: false,
teardown: function() {
editor.getBody().dir = 'ltr';
}
});
function normalizeHTML(html) {
return html.replace(/\s/g, '');
}
test('Keep header/footer intact', function() {
expect(2);
editor.setContent('<html><body><p>Test</p>');
equal(normalizeHTML(editor.getContent()), '<html><body><p>Test</p>', 'Invalid HTML content is still editable.');
editor.setContent('<html><body><p>Test</p></body></html>');
equal(normalizeHTML(editor.getContent()), '<html><body><p>Test</p></body></html>', 'Header/footer is intact.');
});
test('Default header/footer', function() {
expect(1);
editor.setContent('<p>Test</p>');
equal(editor.getContent(), '<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n<p>Test</p>\n</body>\n</html>', 'Invalid HTML content is still editable.');
});
test('Parse body attributes', function() {
expect(9);
editor.setContent('<html><body><p>Test</p></body></html>');
equal(editor.getBody().style.color, '', 'No color on body.');
equal(editor.getBody().dir, '', 'No dir on body.');
equal(editor.dom.getStyle(editor.getBody().firstChild, 'display', true), 'block', 'No styles added to iframe document');
editor.setContent('<html><body style="color:#FF0000"><p>Test</p></body></html>');
ok(editor.getBody().style.color.length > 0, 'Color added to body');
editor.setContent('<html><body dir="rtl"><p>Test</p></body></html>');
equal(editor.getBody().dir, 'rtl', 'Dir added to body');
editor.setContent('<html><head><style>p {text-align:right}</style></head><body dir="rtl"><p>Test</p></body></html>');
equal(editor.dom.getStyle(editor.getBody().firstChild, 'text-align', true), 'right', 'Styles added to iframe document');
editor.setContent('<html><body><p>Test</p></body></html>');
equal(editor.getBody().style.color, '', 'No color on body.');
equal(editor.getBody().dir, '', 'No dir on body.');
equal(editor.dom.getStyle(editor.getBody().firstChild, 'display', true), 'block', 'No styles added to iframe document');
});
test('fullpage_hide_in_source_view: false', function() {
editor.settings.fullpage_hide_in_source_view = false;
editor.setContent('<html><body><p>1</p></body></html>');
equal(editor.getContent({source_view: true}), '<html><body>\n<p>1</p>\n</body></html>');
});
test('fullpage_hide_in_source_view: false', function() {
editor.settings.fullpage_hide_in_source_view = true;
editor.setContent('<html><body><p>1</p></body></html>');
equal(editor.getContent({source_view: true}), '<p>1</p>');
});
tinymce.init({
mode : "exact",
elements : "elm1",
plugins : "fullpage",
add_unload_trigger : false,
valid_styles : {
'*' : 'text-align,padding-left,color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display'
},
indent : 0,
setup: function(ed) {
ed.on('NodeChange', false);
},
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Fullpage plugin tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
</body>
</html>
@@ -0,0 +1,124 @@
<!DOCTYPE html>
<html>
<head>
<title>jQuery Plugin tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
</script>
<script src="../js/tinymce/classes/jquery.tinymce.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("jQuery plugin", {
autostart: false
});
test("Get contents using jQuery", function() {
expect(4);
tinymce.get('elm1').setContent('<p>Editor 1</p>');
equal($('#elm1').html(), '<p>Editor 1</p>');
equal($('#elm1').val(), '<p>Editor 1</p>');
equal($('#elm1').attr('value'), '<p>Editor 1</p>');
equal($('#elm1').text(), 'Editor 1');
});
test("Set contents using jQuery", function() {
expect(4);
$('#elm1').html('Test 1');
equal($('#elm1').html(), '<p>Test 1</p>');
$('#elm1').val('Test 2');
equal($('#elm1').html(), '<p>Test 2</p>');
$('#elm1').text('Test 3');
equal($('#elm1').html(), '<p>Test 3</p>');
$('#elm1').attr('value', 'Test 4');
equal($('#elm1').html(), '<p>Test 4</p>');
});
test("append/prepend contents using jQuery", function() {
expect(2);
tinymce.get('elm1').setContent('<p>Editor 1</p>');
$('#elm1').append('<p>Test 1</p>');
equal($('#elm1').html(), '<p>Editor 1</p>\n<p>Test 1</p>');
$('#elm1').prepend('<p>Test 2</p>');
equal($('#elm1').html(), '<p>Test 2</p>\n<p>Editor 1</p>\n<p>Test 1</p>');
});
test("Find using :tinymce selector", function() {
expect(1);
equal($('textarea:tinymce').length, 2);
});
test("Set contents using :tinymce selector", function() {
expect(3);
$('textarea:tinymce').val('Test 1');
equal($('#elm1').val(), '<p>Test 1</p>');
equal($('#elm2').val(), '<p>Test 1</p>');
equal($('#elm3').val(), 'Textarea');
});
test("Get contents using :tinymce selector", function() {
expect(1);
$('textarea:tinymce').val('Test get');
equal($('textarea:tinymce').val(), '<p>Test get</p>');
});
$(function() {
$('textarea.tinymce').tinymce({
// Location of TinyMCE script
script_url : location.search.indexOf('min=true') > 0 ? '../js/tinymce/tinymce.min.js' : '../js/tinymce/tinymce.js',
// General options
plugins : "pagebreak,layer,table,save,emoticons,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,template",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emoticons,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
init_instance_callback : function(ed) {
var ed1 = tinymce.get('elm1'), ed2 = tinymce.get('elm2');
// When both editors are initialized
if (ed1 && ed1.initialized && ed2 && ed2.initialized)
QUnit.start();
}
});
});
</script>
</head>
<body>
<h1 id="qunit-header">TinyMCE jQuery plugin tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1" class="tinymce">Editor 1</textarea>
<textarea id="elm2" name="elm2" class="tinymce">Editor 2</textarea>
<textarea id="elm3" name="elm3">Textarea</textarea>
</div>
</body>
</html>
@@ -0,0 +1,52 @@
function fakeTypeAURL(url) {
return function(callback) {
// type the URL and then press the space bar
tinymce.execCommand('mceInsertContent', false, url);
window.robot.type(32, false, callback, editor.selection.getNode());
};
}
function fakeTypeAnEclipsedURL(url) {
return function(callback) {
// type the URL and then type ')'
tinymce.execCommand('mceInsertContent', false, '(' + url);
window.robot.typeSymbol(")", function() {
window.robot.type(32, false, callback, editor.selection.getNode());
}, editor.selection.getNode());
};
}
function fakeTypeANewlineURL(url) {
return function(callback) {
// type the URL and then press the enter key
tinymce.execCommand('mceInsertContent', false, url);
window.robot.type('\n', false, callback, editor.selection.getNode());
};
}
createAction('Typing HTTP URL', fakeTypeAURL('http://www.ephox.com'));
createAction('Typing HTTPS URL', fakeTypeAURL('https://www.ephox.com'));
createAction('Typing SSH URL', fakeTypeAURL('ssh://www.ephox.com'));
createAction('Typing FTP URL', fakeTypeAURL('ftp://www.ephox.com'));
createAction('Typing WWW URL', fakeTypeAURL('www.ephox.com'));
createAction('Typing WWW URL With End Dot', fakeTypeAURL('www.site.com.'));
createAction('Typing Mail Addr', fakeTypeAURL('user@domain.com'));
createAction('Typing Mail Addr With Protocol', fakeTypeAURL('mailto:user@domain.com'));
createAction('Typing Dashed Mail Addr', fakeTypeAURL('first-last@domain.com'));
createAction('Typing Eclipsed HTTP URL', fakeTypeAnEclipsedURL('http://www.ephox.com'));
createAction('Typing Eclipsed HTTPS URL', fakeTypeAnEclipsedURL('https://www.ephox.com'));
createAction('Typing Eclipsed SSH URL', fakeTypeAnEclipsedURL('ssh://www.ephox.com'));
createAction('Typing Eclipsed FTP URL', fakeTypeAnEclipsedURL('ftp://www.ephox.com'));
createAction('Typing Eclipsed WWW URL', fakeTypeAnEclipsedURL('www.ephox.com'));
createAction('Typing HTTP URL And Newline', fakeTypeANewlineURL('http://www.ephox.com'));
createAction('Typing HTTPS URL And Newline', fakeTypeANewlineURL('https://www.ephox.com'));
createAction('Typing SSH URL And Newline', fakeTypeANewlineURL('ssh://www.ephox.com'));
createAction('Typing FTP URL And Newline', fakeTypeANewlineURL('ftp://www.ephox.com'));
createAction('Typing WWW URL And Newline', fakeTypeANewlineURL('www.ephox.com'));
createAction('Applying OL', 'InsertOrderedList');
createAction('Applying UL', 'InsertUnorderedList');
createAction('Indenting', 'Indent');
createAction('Outdenting', 'Outdent');
createAction('Typing Enter', fakeKeyPressAction('\n'));
createAction('Typing Tab', fakeKeyPressAction('\t'));
createAction('Typing Shift Tab', fakeKeyPressAction('\t', true));
+138
View File
@@ -0,0 +1,138 @@
var editor;
function getFunctionName(func) {
if (func.name && func.name != "") {
return func.name;
} else if (typeof func == "function" || typeof func == "object") {
var fName = ("" + func).match(/function\s*([\w\$]+)\s*\(/);
if (fName !== null && fName != "") {
return fName[1];
} else {
for (var v in window) {
if (window[v] === func) {
func.name = v;
return v;
}
}
}
}
}
function assertState(expected, message) {
var content = editor.getContent().replace(/[\n\r]/g, '');
if (expected && expected.replace) expected = expected.replace(/[\n\r]/g, '');
// Safari reports "function", while Firefox and IE report "object"
if (typeof expected == "function" || typeof expected == "object") {
if (expected.test(content))
equal(content, content, message);
else
equal(content, expected.toString(), message);
} else {
equal(content, expected, message);
}
}
tinymce.create('dsl.Queue', {
Queue: function() {
this.queue = [];
},
add: function(task) {
this.queue.push(task);
},
next: function() {
if (this.queue.length > 0) {
var task = this.queue.shift();
task();
return true;
} else {
QUnit.start();
return false;
}
},
done: function() {
expect(this.queue.length);
this.next();
}
});
tinymce.create('dsl.Action', {
Action: function(name, action) {
this.name = name;
this.a = this.curryPreposition('a');
this.inA = this.curryPreposition('in a');
this.to = this.curryPreposition('to');
if (tinymce.is(action, 'string')) {
this.action = function(callback) {
editor.execCommand(action);
callback();
};
} else {
this.action = action;
}
},
curryPreposition: function(preposition) {
return function(state) {
return this.go(state, preposition);
};
},
go: function(state, preposition) {
var message = this.name + " " + preposition + " " + getFunctionName(state);
var action = this.action;
var actionPerformed = false;
function defer(callback) {
return function() {
var args = arguments;
queue.add(function() {
if (actionPerformed) {
callback.apply(undefined, args);
queue.next();
return;
}
editor.focus();
state();
action(function() {
actionPerformed = true;
callback.apply(undefined, args);
queue.next();
});
});
return this;
};
}
var dslState = {
gives: defer(function(expected) {
assertState(expected, message);
}),
enablesState: defer(function(state) {
ok(editor.queryCommandState(state), message + " enables " + state + " command");
}),
disablesState: defer(function(state) {
ok(!editor.queryCommandState(state), message + " disables " + state + " command");
})
};
dslState.andGives = dslState.gives;
return dslState;
}
});
// Action Utilities
function fakeKeyPressAction(keyCode, shiftKey) {
return function(callback) {
setTimeout(function() {
window.robot.type(keyCode, shiftKey, callback, editor.selection.getNode());
}, 1);
};
}
function createAction(name, action) {
window[name.replace(/\s+/g, '')] = new dsl.Action(name, action);
}
@@ -0,0 +1,176 @@
function createState(content, startSelector, startOffset, endSelector, endOffset) {
return function() {
editor.setContent(content);
setSelection(startSelector, startOffset, endSelector, endOffset);
};
}
/** Collapsed Selection States **/
function EmptyParagraph() {
var body = editor.getBody();
while (body.firstChild) {
editor.dom.remove(body.firstChild);
}
var p = body.ownerDocument.createElement('p');
p.appendChild(body.ownerDocument.createTextNode(''));
body.appendChild(p, body);
setSelection(p.firstChild, 0);
}
function EmptyHeading() {
EmptyParagraph();
editor.dom.rename(editor.getBody().firstChild, 'h1');
setSelection(editor.getBody().firstChild.firstChild, 0);
}
function TextAfterUL() {
editor.setContent('<ul><li>Item</li></ul>Test');
setSelection(editor.dom.getRoot().lastChild, 2);
}
function TextAfterOL() {
editor.setContent('<ol><li>Item</li></ol>Test');
setSelection(editor.dom.getRoot().lastChild, 2);
}
EmptyContent = createState('', 'body', 0);
PlainText = createState('Test', 'body', 0);
NonEmptyParagraph = createState('<p>Test</p>', 'p', 0);
ParagraphWithMarginLeft = createState('<p style="margin-left: 60px;">Test</p>', 'p', 0);
ParagraphWithPaddingLeft = createState('<p style="padding-left: 60px;">Test</p>', 'p', 0);
ParagraphWithMarginAndPaddingLeft = createState('<p style="margin-left: 60px; padding-left: 60px;">Test</p>', 'p', 0);
CenteredListItem = createState('<ul><li style="text-align: center;">Item1</li><li>Item2</li></ul>', 'li:nth-child(1)', 2);
ItemInCenteredList = createState('<ul style="text-align: center;"><li>Item1</li><li>Item2</li></ul>', 'li:nth-child(1)', 2);
RightAlignedListItem = createState('<ul><li style="text-align: right;">Item1</li><li>Item2</li></ul>', 'li:nth-child(1)', 2);
ItemInRightAlignedList = createState('<ul style="text-align: right;"><li>Item1</li><li>Item2</li></ul>', 'li:nth-child(1)', 2);
ParagraphBetweenOrderedLists = createState('<ol><li>Item1</li></ol><p>Test</p><ol><li>Item2</li></ol>', 'p', 2);
ParagraphBetweenUnorderedLists = createState('<ul><li>Item1</li></ul><p>Test</p><ul><li>Item2</li></ul>', 'p', 2);
ParagraphBetweenMixedLists = createState('<ol><li>Item1</li></ol><p>Test</p><ul><li>Item2</li></ul>', 'p', 2);
NonEmptyHeading = createState('<h1>Test</h1>', 'h1', 0);
TableCellWithoutBrs = createState('<table><tbody><tr><td>Test</td><td>&nbsp;</td></tr></tbody></table>', 'td', 4);
TableCellWithoutBrs2 = createState('<table><tbody><tr><td>Test</td><td>&nbsp;</td></tr></tbody></table>', 'td', 0);
TableCellWithBrsFirstLine = createState('<table><tbody><tr><td>Test<br>Line 2</td><td>&nbsp;</td></tr></tbody></table>', 'td', 1);
TableCellWithBrsFirstLine2 = createState('<table><tbody><tr><td>Test<br>Line 2</td><td>&nbsp;</td></tr></tbody></table>', 'td', 0);
TableCellWithBrsMiddleLine = createState('<table><tbody><tr><td>Test<br/>Line 2<br/>Line 3</td><td>&nbsp;</td></tr></tbody></table>', 'td br:nth-child(1)', 'afterNextCharacter');
TableCellWithBrsLastLine = createState('<table><tbody><tr><td>Test<br>Line 2</td><td>&nbsp;</td></tr></tbody></table>', 'td br:nth-child(1)', 'afterNextCharacter');
TableCellWithAdjacentBrsFirstLine = createState('<table><tbody><tr><td>Test<br><br>Line 2</td><td>&nbsp;</td></tr></tbody></table>', 'td', 1);
HeadingInOrderedList = createState('<ol><li><h2>Test</h2></li></ol>', 'h2', '2');
HeadingInUnorderedList = createState('<ul><li><h2>Test</h2></li></ul>', 'h2', '2');
HeadingInOrderedListBeforeParagraph = createState('<ol><li><h2>Test</h2></li></ol><p>Content<br />After</p>', 'h2', '2');
DefinitionListDescription = createState('<dl><dt>Term</dt><dd>Description</dd></dl>', 'dd', 2);
DefinitionListTerm = createState('<dl><dt>Term</dt><dd>Description</dd></dl>', 'dt', 2);
EndOfParagraphBeforeOL = createState('<p>Test</p><ol><li>Item</li></ol>', 'p', 4);
EndOfParagraphBeforeOLWithListType = createState('<p>Test</p><ol style="list-style-type: lower-alpha;"><li>Item</li></ol>', 'p', 4);
EndOfParagraphBeforeUL = createState('<p>Test</p><ul><li>Item</li></ul>', 'p', 4);
StartOfParagraphAfterOL = createState('<ol><li>Item</li></ol><p>Test</p>', 'p', 1);
StartOfParagraphAfterUL = createState('<ul><li>Item</li></ul><p>Test</p>', 'p', 1);
StartOfParagraphAfterOLWithListType = createState('<ol style="list-style-type: lower-alpha;"><li>Item</li></ol><p>Test</p>', 'p', 1);
EmptyOrderedListItem = createState('<ol><li>Before</li><li>&nbsp;</li><li>After</li></ol>', 'li:nth-child(2)', 0);
EmptyUnorderedListItem = createState('<ul><li>Before</li><li>&nbsp;</li><li>After</li></ul>', 'li:nth-child(2)', 0);
NonEmptyOrderedListItem = createState('<ol><li>Before</li><li>Test</li><li>After</li></ol>', 'li:nth-child(2)', 0);
NonEmptyUnorderedListItem = createState('<ul><li>Before</li><li>Test</li><li>After</li></ul>', 'li:nth-child(2)', 0);
NestedEmptyOrderedListItem = createState('<ol><li>Before<ol><li>&nbsp;</li></ol></li><li>After</li></ol>', 'li ol li', 0);
NestedEmptyUnorderedListItem = createState('<ul><li>Before<ul><li>&nbsp;</li></ul></li><li>After</li></ul>', 'li ul li', 0);
NestedNonEmptyOrderedListItem = createState('<ol><li>Before<ol><li>Test</li></ol></li><li>After</li></ol>', 'li ol li', 0);
NestedNonEmptyUnorderedListItem = createState('<ul><li>Before<ul><li>Test</li></ul></li><li>After</li></ul>', 'li ul li', 0);
NestedOrderedListWithMultipleItems = createState('<ol><li>Before<ol><li>Item1</li><li>Item2</li></ol></li></ol>', 'li ol li', 0);
NestedUnorderedListWithMultipleItems = createState('<ul><li>Before<ul><li>Item1</li><li>Item2</li></ul></li></ul>', 'li ul li', 0);
OrderedLowerAlphaListItem = createState('<ol style="list-style-type: lower-alpha;"><li>Item 1</li><li>Item 2</li></ol>', 'li:nth-child(2)', 0);
UnorderedSquareListItem = createState('<ul style="list-style-type: square;"><li>Item 1</li><li>Item 2</li></ul>', 'li:nth-child(2)', 0);
OrderedListItemWithNestedChild = createState('<ol><li>Item1<ol><li>Nested</li></ol></li></ol>', 'li:nth-child(1)', 2);
UnorderedListItemWithNestedChild = createState('<ul><li>Item1<ul><li>Nested</li></ul></li></ul>', 'li:nth-child(1)', 2);
OrderedListWithAdjacentNestedLists = createState('<ol><li style="list-style-type: none;"><ol><li>Item 1</li></ol></li><li>Item 2</li><li style="list-style-type: none;"><ol><li>Item 3</li></ol></li></ol>', 'li:nth-child(2)', 4);
UnorderedListWithAdjacentNestedLists = createState('<ul><li style="list-style-type: none;"><ul><li>Item 1</li></ul></li><li>Item 2</li><li style="list-style-type: none;"><ul><li>Item 3</li></ul></li></ul>', 'li:nth-child(2)', 4);
OrderedListItemWithMargin = createState('<ol><li style="margin-left: 60px;">Test</li></ol>', 'li', 0);
UnorderedListItemWithMargin = createState('<ul><li style="margin-left: 60px;">Test</li></ul>', 'li', 0);
OrderedListItemWithNestedAlphaList = createState('<ol><li>Item<ol style="list-style-type: lower-alpha;"><li>Nested</li></ol></li></ol>', 'li', 2);
/** Collapsed DIV Tests **/
OrderedListItemInsideDiv = createState('<div id="div"><ol>\n<li>Item1</li><li>Item2</li></ol></div>', 'li:nth-child(1)', 2);
UnorderedListItemInsideDiv = createState('<div id="div"><ul>\n<li>Item1</li><li>Item2</li></ul></div>', 'li:nth-child(1)', 2);
ParagraphInDiv = createState('<div><p>Item</p></div>', 'p', 2);
TextInDiv = createState('<div>Item</div>', 'div', 2);
TextWithBrsInDivFirstLine = createState('<div>Item1<br />Item2</div>', 'div', 2);
TextWithBrsInDivMiddleLine = createState('<div>Item1<br />Item2<br />Item3</div>', 'br:nth-child(1)', 'afterNextCharacter');
TextWithBrsInDivLastLine = createState('<div>Item1<br />Item2</div>', 'br:nth-child(1)', 'afterNextCharacter');
TextWithBrsInFormattingInDiv = function() {
var rng;
editor.setContent('<div><strong>Before<br /></strong>Item1<br />Item2<br />Item3</div>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('div')[0].childNodes[1], 0);
rng.setEnd(editor.dom.select('div')[0], 6);
editor.selection.setRng(rng);
};
TextWithBrInsideFormatting = function() {
var rng;
editor.setContent('<div><em><strong>Before<br /><span class="foo">Item1</span></strong></em>Item2<br />Item3</div>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('span')[0].childNodes[0], 2);
rng.setEnd(editor.dom.select('div')[0], 4);
editor.selection.setRng(rng);
};
/** Expanded Selection States **/
SingleParagraphSelection = createState('<p>This is a test</p>', 'p', 5, 'p', 7);
MultipleParagraphSelection = createState('<p>This is a test</p><p>Second paragraph</p>', 'p:nth-child(1)', 5, 'p:nth-child(2)', 6);
SingleHeadingSelection = createState('<h1>This is a test</h1>', 'h1', 5, 'h1', 7);
MultipleHeadingSelection = createState('<h1>This is a test</h1><h1>Second paragraph</h1>', 'h1:nth-child(1)', 5, 'h1:nth-child(2)', 6);
SingleBlockSelection = createState('<div>This is a test</div>', 'div', 5, 'div', 7);
MultipleBlockSelection = createState('<div>This is a test</div><div>Second paragraph</div>', 'div:nth-child(1)', 5, 'div:nth-child(2)', 6);
SingleBlockWithBrSelection = createState('<div>Item1<br />Item2</div>', 'div', 3, 'br', 'afterNextCharacter');
MultipleBlockWithBrSelection = createState('<div>Item1<br />Item2</div><div>Item3</div>', 'div:nth-child(1)', 2, 'div:nth-child(2)', 3);
MultipleBlockWithBrPartialSelection = createState('<div>Item1<br />Item2</div><div>Item3<br />Item4</div>', 'div:nth-child(1)', 2, 'div:nth-child(2)', 3);
MultipleBlockWithBrPartialSelectionAtEnd = createState('<div>Item1<br />Item2</div><div>Item3<br />Item4</div>', 'div:nth-child(1) br', 'afterNextCharacter', 'div:nth-child(2) br', 'afterNextCharacter');
MultipleBlockWithEmptyDivsAllSelected = createState('<div id="start">&nbsp;</div><div>a</div><div></div><div>b</div><div></div><div id="end">&nbsp;</div>', '#start', 0, '#end', 0);
CellWithoutBrSelection = createState('<table><tbody><tr><td>Cell 1</td></tr></tbody></table>', 'td', 1, 'td', 1); //selection is a single point so it will avoid table selection bugs in ie9.
CellWithBrSingleLineSelection = createState('<table><tbody><tr><td>Cell 1<br>Line 2</td></tr></tbody></table>', 'td', 1, 'td', 4);
CellWithBrMultipleLineSelection = createState('<table><tbody><tr><td>Cell 1<br>Line 2</td></tr></tbody></table>', 'td', 1, 'td', 4);
TableCellWithTextAfterUL = createState('<table><tbody><tr><td><ul><li>Existing</li></ul><span id="start">Line1</span><br />Line2<br id="end" />Line3<br />Line4</td></tr></tbody></table>', '#start', 1, '#end', 'afterNextCharacter');
ParagraphToHeadingSelection = createState('<p>This is a test</p><h1>Second paragraph</h1>', 'p', 5, 'h1', 6);
ParagraphToBlockSelection = createState('<p>This is a test</p><div>Second paragraph</div>', 'p', 5, 'div', 6);
HeadingToParagraphSelection = createState('<h1>This is a test</h1><p>Second paragraph</p>', 'h1', 5, 'p', 6);
BlockToParagraphSelection = createState('<div>This is a test</div><p>Second paragraph</p>', 'div', 5, 'p', 6);
MultipleParagraphAndHeadingSelection = createState('<p>This is a test</p><h1>Second paragraph</h1><div>Third paragraph</div>', 'p', 5, 'div', 5);
ThreeBoldDivsWithBrSelection = createState('<div><strong>One</strong></div><div><strong>Two</strong></div><div><strong>Three<br></strong></div>', 'div:nth-child(1) strong', 2, 'div:nth-child(3) strong', 2);
SingleLiOlSelection = createState('<ol><li>Item 1</li></ol>', 'li', 1, 'li', 4);
MultiLiOlSelection = createState('<ol><li>Item 1</li><li>Item 2</li></ol>', 'li:nth-child(1)', 1, 'li:nth-child(2)', 4);
SingleLiUlSelection = createState('<ul><li>Item 1</li></ul>', 'li', 1, 'li', 4);
MultiLiUlSelection = createState('<ul><li>Item 1</li><li>Item 2</li></ul>', 'li:nth-child(1)', 1, 'li:nth-child(2)', 4);
MultiNestedLiUlSelection = createState('<ul><li style="list-style-type: none;"><ul><li>Item 1</li><li>Item 2</li></ul></li></ul>', 'li li:nth-child(1)', 1, 'li li:nth-child(2)', 4);
MultiNestedLiOlSelection = createState('<ol><li style="list-style-type: none;"><ol><li>Item 1</li><li>Item 2</li></ol></li></ol>', 'li li:nth-child(1)', 1, 'li li:nth-child(2)', 4);
IndentedOlInOlCorrectSelection = createState('<ol><li>Item 1<ol><li>Indented</li></ol></li></ol>', 'li', 1, 'li li', 4);
IndentedUlInUlCorrectSelection = createState('<ul><li>Item 1<ul><li>Indented</li></ul></li></ul>', 'li', 1, 'li li', 4);
IndentedOlInOlIncorrectSelection = createState('<ol><li>Item 1</li><ol><li>Indented</li></ol></ol>', 'li', 1, 'ol ol li', 4);
IndentedUlInUlIncorrectSelection = createState('<ul><li>Item 1</li><ul><li>Indented</li></ul></ul>', 'li', 1, 'ul ul li', 4);
IndentedOlInUlCorrectSelection = createState('<ul><li>Item 1<ol><li>Indented</li></ol></li></ul>', 'li', 1, 'li li', 4);
IndentedUlInOlCorrectSelection = createState('<ol><li>Item 1<ul><li>Indented</li></ul></li></ol>', 'li', 1, 'li li', 4);
IndentedOlInUlIncorrectSelection = createState('<ul><li>Item 1</li><ol><li>Indented</li></ol></ul>', 'li', 1, 'ul ol li', 4);
IndentedUlInOlIncorrectSelection = createState('<ol><li>Item 1</li><ul><li>Indented</li></ul></ol>', 'li', 1, 'ol ul li', 4);
// TODO: Paragraph/heading to list combinations.
ParagraphBeforeOlSelection = createState('<p>Before</p><ol><li>Item 1</li></ol>', 'p', 3, 'li', 4);
ParagraphBeforeUlSelection = createState('<p>Before</p><ul><li>Item 1</li></ul>', 'p', 3, 'li', 4);
ParagraphAfterOlSelection = createState('<ol><li>Item 1</li></ol><p>After</p>', 'li', 4, 'p', 3);
ParagraphAfterUlSelection = createState('<ul><li>Item 1</li></ul><p>After</p>', 'li', 4, 'p', 3);
ParagraphBeforeAndAfterOlSelection = createState('<p>Before</p><ol><li>Item 1</li></ol><p id="after">After</p>', 'p', 4, '#after', 3);
ParagraphBeforeAndAfterUlSelection = createState('<p>Before</p><ul><li>Item 1</li></ul><p id="after">After</p>', 'p', 4, '#after', 3);
SelectionEndingAtBr = createState('<p>Item<br>After</p>', 'p', 2, 'br', 'after');
SelectionStartingAtBr = createState('<p>Before<br>Item</p>', 'p', 'after', 'br', 'afterNextCharacter');
@@ -0,0 +1,130 @@
<!DOCTYPE html>
<html>
<head>
<title>Unit tests for Media Plugin</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/tinymce_loader.js"></script>
<script src="js/utils.js"></script>
<script>
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Legacyoutput plugin", {
autostart: false
});
test("Font color", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('forecolor', false, '#FF0000');
equal(editor.getContent().toLowerCase(), '<p><font color="#ff0000">text</font></p>');
});
test("Font size", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('fontsize', false, 7);
equal(editor.getContent(), '<p><font size="7">text</font></p>');
});
test("Font face", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('fontname', false, "times");
equal(editor.getContent(), '<p><font face="times">text</font></p>');
});
test("Bold", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('bold');
equal(editor.getContent(), '<p><b>text</b></p>');
});
test("Italic", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('italic');
equal(editor.getContent(), '<p><i>text</i></p>');
});
test("Underline", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('underline');
equal(editor.getContent(), '<p><u>text</u></p>');
});
test("Strikethrough", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('strikethrough');
equal(editor.getContent(), '<p><strike>text</strike></p>');
});
test("Justifyleft", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('justifyleft');
equal(editor.getContent(), '<p align="left">text</p>');
});
test("Justifycenter", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('justifycenter');
equal(editor.getContent(), '<p align="center">text</p>');
});
test("Justifyright", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('justifyright');
equal(editor.getContent(), '<p align="right">text</p>');
});
test("Justifyfull", function() {
editor.setContent('<p>text</p>');
setSelection('p', 0, 'p', 4);
editor.execCommand('justifyfull');
equal(editor.getContent(), '<p align="justify">text</p>');
});
function initTiny(settings, load) {
var default_settings = {
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
document_base_url : '/tinymce/tinymce/trunk/tests/',
plugins : 'legacyoutput',
init_instance_callback : function(ed) {
editor = ed;
load();
}
};
var settings = tinymce.extend(default_settings, settings);
tinymce.init(settings);
}
initTiny({}, QUnit.start);
</script>
</head>
<body>
<h1 id="qunit-header">Unit tests for Legacyoutput Plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</body>
</html>
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,149 @@
<!DOCTYPE html>
<html>
<head>
<title>Unit tests for Media Plugin</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Media plugin", {
autostart: false
});
test("Object retain as is", function() {
editor.setContent(
'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355">' +
'<param name="movie" value="someurl">' +
'<param name="wmode" value="transparent">' +
'<embed src="someurl" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355" />' +
'</object>'
);
equal(editor.getContent(),
'<p><object width="425" height="355" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' +
'<param name="movie" value="someurl">' +
'<param name="wmode" value="transparent">' +
'<embed src="someurl" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355" />' +
'</object></p>'
);
});
test("Embed retain as is", function() {
editor.setContent(
'<video src="320x240.ogg" autoplay loop controls>text<a href="#">link</a></video>'
);
equal(editor.getContent(),
'<p><video width="300" height="150" src="320x240.ogg" autoplay="autoplay" loop="loop" controls="controls">text<a href="#">link</a></video></p>'
);
});
test("Video retain as is", function() {
editor.setContent(
'<video src="320x240.ogg" autoplay loop controls>text<a href="#">link</a></video>'
);
equal(editor.getContent(),
'<p><video width="300" height="150" src="320x240.ogg" autoplay="autoplay" loop="loop" controls="controls">text<a href="#">link</a></video></p>'
);
});
test("Iframe retain as is", function() {
editor.setContent(
'<iframe src="320x240.ogg" allowfullscreen>text<a href="#">link</a></iframe>'
);
equal(editor.getContent(),
'<p><iframe src="320x240.ogg" width="300" height="150" allowfullscreen="allowfullscreen">text<a href="#">link</a></iframe></p>'
);
});
test("Audio retain as is", function() {
editor.setContent(
'<audio src="sound.mp3">' +
'<track kind="captions" src="foo.en.vtt" srclang="en" label="English">' +
'<track kind="captions" src="foo.sv.vtt" srclang="sv" label="Svenska">' +
'text<a href="#">link</a>' +
'</audio>'
);
equal(editor.getContent(),
'<p>' +
'<audio src="sound.mp3">' +
'<track kind="captions" src="foo.en.vtt" srclang="en" label="English">' +
'<track kind="captions" src="foo.sv.vtt" srclang="sv" label="Svenska">' +
'text<a href="#">link</a>' +
'</audio>' +
'</p>'
);
});
test("Resize complex object", function() {
editor.setContent(
'<video width="300" height="150" controls="controls">' +
'<source src="s" />' +
'<object type="application/x-shockwave-flash" data="../js/tinymce/plugins/media/moxieplayer.swf" width="300" height="150">' +
'<param name="allowfullscreen" value="true" />' +
'<param name="allowscriptaccess" value="always" />' +
'<param name="flashvars" value="video_src=s" />' +
'<!--[if IE]><param name="movie" value="../js/tinymce/plugins/media/moxieplayer.swf" /><![endif]-->' +
'</object>' +
'</video>'
);
var placeholderElm = editor.getBody().firstChild.firstChild;
placeholderElm.width = 100;
placeholderElm.height = 200;
editor.fire('objectResized', {target: placeholderElm, width: placeholderElm.width, height: placeholderElm.height});
equal(editor.getContent(),
'<p>' +
'<video width="100" height="200" controls="controls">' +
'<source src="s" />' +
'<object type="application/x-shockwave-flash" data="../js/tinymce/plugins/media/moxieplayer.swf" width="100" height="200">' +
'<param name="allowfullscreen" value="true" />' +
'<param name="allowscriptaccess" value="always" />' +
'<param name="flashvars" value="video_src=s" />' +
'<!--[if IE]>' +
'<param name="movie" value="../js/tinymce/plugins/media/moxieplayer.swf" />' +
'<![endif]-->' +
'</object>' +
'</video>' +
'</p>'
);
});
tinymce.init({
mode: "exact",
elements: "elm1",
add_unload_trigger: false,
document_base_url: '/tinymce/tinymce/trunk/tests/',
plugins: 'media',
init_instance_callback: function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Unit tests for Media Plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</body>
</html>
@@ -0,0 +1,237 @@
<!DOCTYPE html>
<html>
<head>
<title>Unit tests for noneditable</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
var editor, rng;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Noneditable plugin", {
autostart: false
});
test('expand to noneditable (start)', function() {
editor.setContent('<p><span class="mceNonEditable">no</span>yes</p>');
rng = editor.dom.createRng();
rng.setStart(editor.getBody().firstChild.firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.lastChild, 1);
editor.selection.setRng(rng);
editor.dom.fire(editor.getBody(), 'mouseup');
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, 'P');
equal(rng.startOffset, 0);
equal(rng.endContainer.nodeName, '#text');
equal(rng.endOffset, 1);
});
test('expand to noneditable (end)', function() {
editor.setContent('<p>yes<span class="mceNonEditable">no</span></p>');
rng = editor.dom.createRng();
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.lastChild.firstChild, 1);
editor.selection.setRng(rng);
editor.dom.fire(editor.getBody(), 'mouseup');
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, '#text');
equal(rng.startOffset, 1);
equal(rng.endContainer.nodeName, 'P');
equal(rng.endOffset, 2);
});
test('expand to noneditable (start/end)', function() {
editor.setContent('<p>yes<span class="mceNonEditable">noedit</span>yes</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('span')[0].firstChild, 1);
rng.setEnd(editor.dom.select('span')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.dom.fire(editor.getBody(), 'mouseup');
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, 'P');
equal(rng.startOffset, 1);
equal(rng.endContainer.nodeName, 'P');
equal(rng.endOffset, 2);
});
test('type after non editable', function() {
editor.setContent('<p><span class="mceNonEditable">no</span>yes</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('span')[0].firstChild, 2);
rng.setEnd(editor.dom.select('span')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.dom.fire(editor.getBody(), 'mouseup');
type('X');
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.getAttribute('data-mce-bogus'), 'true');
equal(rng.startContainer.nodeName, 'SPAN');
equal(rng.startOffset, 1);
equal(rng.endContainer.nodeName, 'SPAN');
equal(rng.endOffset, 1);
equal(editor.getContent(), '<p><span class="mceNonEditable">no</span>Xyes</p>');
});
test('type between non editable', function() {
editor.setContent('<p><span class="mceNonEditable">no</span><span class="mceNonEditable">no</span></p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('span')[0].firstChild, 2);
rng.setEnd(editor.dom.select('span')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.dom.fire(editor.getBody(), 'mouseup');
type('X');
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.getAttribute('data-mce-bogus'), 'true');
equal(rng.startContainer.nodeName, 'SPAN');
equal(rng.startOffset, 1);
equal(rng.endContainer.nodeName, 'SPAN');
equal(rng.endOffset, 1);
equal(editor.getContent(), '<p><span class="mceNonEditable">no</span>X<span class="mceNonEditable">no</span></p>');
});
test('type after last non editable', function() {
editor.setContent('<p><span class="mceNonEditable">no</span></p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('span')[0].firstChild, 2);
rng.setEnd(editor.dom.select('span')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.dom.fire(editor.getBody(), 'mouseup');
type('X');
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.getAttribute('data-mce-bogus'), 'true');
equal(rng.startContainer.nodeName, 'SPAN');
equal(rng.startOffset, 1);
equal(rng.endContainer.nodeName, 'SPAN');
equal(rng.endOffset, 1);
equal(editor.getContent(), '<p><span class="mceNonEditable">no</span>X</p>');
});
test('escape noneditable inline element (left)', function() {
editor.setContent('<p>no <span class="mceNonEditable">yes</span> no</p><p class="mceNonEditable">no</p>');
var container = editor.dom.select('p')[0];
rng = editor.dom.createRng();
rng.selectNode(editor.dom.select('span')[0]);
editor.selection.setRng(rng);
type({keyCode: 37});
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, 'SPAN');
equal(rng.startContainer.parentNode.nodeName, 'P');
equal(editor.dom.nodeIndex(rng.startContainer), 1);
equal(rng.collapsed, true);
});
test('escape noneditable inline element (right)', function() {
editor.setContent('<p>no <span class="mceNonEditable">yes</span> no</p><p class="mceNonEditable">no</p>');
var container = editor.dom.select('p')[0];
rng = editor.dom.createRng();
rng.selectNode(editor.dom.select('span')[0]);
editor.selection.setRng(rng);
type({keyCode: 39});
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, 'SPAN');
equal(rng.startContainer.parentNode.nodeName, 'P');
equal(editor.dom.nodeIndex(rng.startContainer), 2);
equal(rng.collapsed, true);
});
test('escape noneditable block element (left)', function(){
editor.setContent('<p>yes</p><p class="mceNonEditable">no</p><p>yes</p>');
rng = editor.dom.createRng();
rng.selectNode(editor.dom.select('p')[1]);
editor.selection.setRng(rng);
type({keyCode: 37});
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, "P");
equal(editor.dom.nodeIndex(rng.startContainer), 0);
equal(rng.startOffset, 1);
equal(rng.collapsed, true);
});
test('escape noneditable block element (right)', function(){
editor.setContent('<p>yes</p><p class="mceNonEditable">no</p><p>yes</p>');
rng = editor.dom.createRng();
rng.selectNode(editor.dom.select('p')[1]);
editor.selection.setRng(rng);
type({keyCode: 39});
rng = normalizeRng(editor.selection.getRng(true));
equal(rng.startContainer.nodeName, "P");
equal(editor.dom.nodeIndex(rng.startContainer), 2);
equal(rng.startOffset, 0);
equal(rng.collapsed, true);
});
test('noneditable regexp', function() {
editor.setContent('<p>{test1}{test2}</p>');
equal(editor.dom.select('span').length, 2);
equal(editor.getContent(), '<p>{test1}{test2}</p>');
});
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
indent : false,
theme_advanced_styles : 'test1=test1;test2=test2',
noneditable_regexp : [/\{[^\}]+\}/g],
valid_elements : '@[contenteditable|id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong,b,em,i,strike,u,#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
plugins: 'noneditable',
forced_root_block : '',
convert_fonts_to_spans : false,
entities : 'raw',
valid_styles : {
'*' : 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display'
},
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Unit tests noneditable plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</body>
</html>
@@ -0,0 +1,275 @@
<!DOCTYPE html>
<html>
<head>
<title>Unit tests for the Paste plugin</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
</head>
<body>
<script>
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Paste plugin", {
autostart: false
});
test("Paste simple text content", function() {
var rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
editor.focus();
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : 'TEST'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>1TEST4</p>');
});
test("Paste styled text content", function() {
var rng = editor.dom.createRng();
editor.settings.paste_remove_styles_if_webkit = false;
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<strong><em><span style="color: red;">TEST</span></em></strong>'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>1<strong><em><span style="color: red;">TEST</span></em></strong>4</p>');
});
test("Paste paragraph in paragraph", function() {
var rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 1);
rng.setEnd(editor.getBody().firstChild.firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<p>TEST</p>'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), tinymce.isGecko ? '<p>1TEST4</p>' : '<p>1</p><p>TEST</p><p>4</p>'); // Gecko needed a workaround since copy of <h1>t[e]xt</h1> will become <h1>e</h1>
});
test("Paste paragraphs in complex paragraph", function() {
var rng = editor.dom.createRng();
editor.setContent('<p><strong><em>1234</em></strong></p>');
rng.setStart(editor.dom.select('em,i')[0].firstChild, 1);
rng.setEnd(editor.dom.select('em,i')[0].firstChild, 3);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<p>TEST 1</p><p>TEST 2</p>'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p><strong><em>1</em></strong></p><p>TEST 1</p><p>TEST 2</p><p><strong><em>4</em></strong></p>');
});
test("Paste Word fake list", function() {
var rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>SV</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="&#45;-"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/Line truncated
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li><li>Item 4</li><li>Item 5</li><li>Item 6</li></ul>');
editor.settings.paste_retain_style_properties = 'border';
rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<p class="ListStyle" style="margin-top:0cm;margin-right:0cm;margin-bottom:3.0pt;margin-left:18.0pt;mso-add-space:auto;text-align:justify;text-indent:-18.0pt;mso-list:l0 level1 lfo1;tab-stops:list 18.0pt"><span lang="DE" style="font-family:Verdana;mso-fareast-font-family:Verdana;mso-bidi-font-family:Verdana;color:black"><span style="mso-list:Ignore">\u25CF<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><span lang="DE" style="font-family:Arial;mso-fareast-font-family:Arial;mso-bidi-font-family:Arial;color:black">Item&nbsp; Spaces.<o:p></o:p></span></p>'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<ul><li>Item&nbsp; Spaces.</li></ul>');
rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<p class="ListStyle" style="margin-left:36.0pt;mso-add-space:auto;text-indent:-18.0pt;mso-list:l0 level1 lfo1;tab-stops:list 36.0pt"><span lang="EN-US" style="color:black;mso-ansi-language:EN-US"><span style="mso-list:Ignore">1.<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span lang="EN-US" style="font-family:Arial;mso-fareast-font-family:Arial;mso-bidi-font-family:Arial;color:black;mso-ansi-language:EN-US">Version 7.0</span><span lang="EN-US" style="font-family:Arial;mso-fareast-font-family:Arial;mso-bidi-font-family:Arial;color:black;mso-ansi-language:EN-US">:<o:p></o:p></span></p>'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<ol><li>Version 7.0:</li></ol>');
editor.settings.paste_retain_style_properties = '';
});
test("Paste Word fake list before BR", function() {
var rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertContent', false, '<br>a');
rng = editor.dom.createRng();
rng.setStart(editor.getBody().firstChild, 0);
rng.setEnd(editor.getBody().firstChild, 0);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>SV</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="&#45;-"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/Line truncated
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li><li>Item 4</li><li>Item 5</li><li>Item 6</li></ul><p><br />a</p>');
});
test("Paste Word table", function() {
var rng = editor.dom.createRng();
editor.setContent('<p>1234</p>');
rng.setStart(editor.getBody().firstChild.firstChild, 0);
rng.setEnd(editor.getBody().firstChild.firstChild, 4);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///C:%5CUsers%5Cspocke%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>SV</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="&#45;-"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/> <m:defJc m:val="centerGroup"/> <m:wrapIndent m:val="1440"/> <m:intLim m:val="subSup"/> <m:naryLim m:val="undOvr"/> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> <w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/> <w:LsdException Locked="false" Priority="39" Name="toc 1"/> <w:LsdException Locked="false" Priority="39" Name="toc 2"/> <w:LsdException Locked="false" Priority="39" Name="toc 3"/> <w:LsdException Locked="false" Priority="39" Name="toc 4"/> <w:LsdException Locked="false" Priority="39" Name="toc 5"/> <w:LsdException Locked="false" Priority="39" Name="toc 6"/> <w:LsdException Locked="false" Priority="39" Name="toc 7"/> <w:LsdException Locked="false" Priority="39" Name="toc 8"/> <w:LsdException Locked="false" Priority="39" Name="toc 9"/> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/> <w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/> <w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/> <w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/> <w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/> <w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/> <w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/> <w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/> <w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/> <w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/> <w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/> <w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/Line truncated
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<table><tbody><tr><td><p>Cell 1</p></td><td><p>Cell 2</p></td></tr><tr><td><p>Cell 3</p></td><td><p>Cell 4</p></td></tr></tbody></table><p>&nbsp;</p>');
});
test("Paste Word retain styles", function() {
var rng = editor.dom.createRng();
editor.settings.paste_retain_style_properties = 'color,background-color,font-family';
// Test color
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, {content : '<p class="MsoNormal" style="color: #ff0000">Test</p>'});
equal(trimContent(editor.getContent().replace(/[\r\n]+/g, '')), '<p style=\"color: #ff0000;\">Test</p>');
// Test background-color
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, {content : '<p class="MsoNormal" style="background-color: #ff0000">Test</p>'});
equal(trimContent(editor.getContent().replace(/[\r\n]+/g, '')), '<p style=\"background-color: #ff0000;\">Test</p>');
editor.settings.paste_retain_style_properties = '';
});
test("Paste part of list from IE", function() {
var rng = editor.dom.createRng();
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, {content : '<li>item2</li><li>item3</li>'});
equal(trimContent(editor.getContent().replace(/[\r\n]+/g, '')), '<ul><li>item2</li><li>item3</li></ul>', 'List tags are inferred when pasting LI');
});
test("Disable default filters", function() {
var rng = editor.dom.createRng();
editor.settings.paste_enable_default_filters = false;
// Test color
editor.setContent('');
editor.execCommand('SelectAll');
editor.execCommand('mceInsertClipboardContent', false, {content : '<p class="MsoNormal" style="color: #ff0000;">Test</p>'});
equal(trimContent(editor.getContent().replace(/[\r\n]+/g, '')), '<p class="MsoNormal" style="color: #ff0000;">Test</p>');
editor.settings.paste_enable_default_filters = true;
});
test('paste invalid content with spans on page', function(){
var startingContent = '<p>123 testing <span id="x">span later in document</span></p>',
insertedContent = '<ul><li>u</li><li>l</li></ul>';
editor.setContent(startingContent);
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 0);
rng.setEnd(editor.dom.select('p')[0].firstChild, 0);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {content : insertedContent});
equal(editor.getContent().replace(/[\r\n]+/g, ''), insertedContent + startingContent);
});
test('paste plain text with space', function(){
editor.setContent('<p>text</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {text : ' a '});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>t a xt</p>');
});
test('paste plain text with linefeeds', function(){
editor.setContent('<p>text</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {text : 'a\nb\n\c\n'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>ta<br />b<br />c<br />xt</p>');
});
test('paste plain text with double linefeeds', function(){
editor.setContent('<p>text</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {text : 'a\n\nb\n\n\c\n\n'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>t</p><p>a</p><p>b</p><p>c</p><p>xt</p>');
});
test('paste plain text with entities', function(){
editor.setContent('<p>text</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {text : '< & >'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>t&lt; &amp; &gt;xt</p>');
});
test('paste plain text with paragraphs', function(){
editor.setContent('<p>text</p>');
rng = editor.dom.createRng();
rng.setStart(editor.dom.select('p')[0].firstChild, 1);
rng.setEnd(editor.dom.select('p')[0].firstChild, 2);
editor.selection.setRng(rng);
editor.execCommand('mceInsertClipboardContent', false, {text : 'a\n<b>b</b>\n\nc'});
equal(editor.getContent().replace(/[\r\n]+/g, ''), '<p>ta<br />&lt;b&gt;b&lt;/b&gt;</p><p>c</p><p>xt</p>');
});
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
plugins : 'paste',
setup: function(ed) {
ed.on('NodeChange', false);
},
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
<h1 id="qunit-header">Unit tests for the Paste plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</body>
</html>
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic editor functionality tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
function check_plugin_loaded(name){
var pluginManager = tinymce.PluginManager;
var depPlugin = pluginManager.get(name);
ok(depPlugin, name + " plugin should have loaded");
}
test('Dependency Chain Legacy style test', function() {
expect(3);
check_plugin_loaded("example");
check_plugin_loaded("example_dependency");
check_plugin_loaded("depend_chain");
});
tinymce.create('tinymce.plugins.DependencyChain', {});
// Register plugin
tinymce.PluginManager.add('depend_chain', tinymce.plugins.DependencyChain, ["example_dependency"]);
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
plugins: "depend_chain",
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Plugin Dependency Functional tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
</body>
</html>
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<title>Plugin Dependency Functional tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
function check_plugin_loaded(name){
var pluginManager = tinymce.PluginManager;
var depPlugin = pluginManager.get(name);
ok(depPlugin, name + " plugin should have loaded");
}
test('Dependency Chain Legacy style test', function() {
expect(3);
check_plugin_loaded("example");
check_plugin_loaded("example_dependency");
check_plugin_loaded("depend_chain");
});
tinymce.create('tinymce.plugins.DependencyChain', {});
// Register plugin
tinymce.PluginManager.add('depend_chain', tinymce.plugins.DependencyChain, ["example_dependency"]);
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
plugins: "-depend_chain",
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Plugin Dependency Functional tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
</body>
</html>
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic editor functionality tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
function check_plugin_order(order){
deepEqual(plugin_load_order, order, "Load order for plugins");
}
test('PluginDependencyIsLoaded', function() {
expect(1);
check_plugin_order(["one", "two", "three", "four"]);
});
var plugin_load_order =[];
tinymce.create('tinymce.plugins.One', {
init: function(ed, url) {plugin_load_order.push("one");}
});
tinymce.create('tinymce.plugins.Two', {
init: function(ed, url) {plugin_load_order.push("two");}
});
tinymce.create('tinymce.plugins.Three', {
init: function(ed, url) {plugin_load_order.push("three");}
});
tinymce.create('tinymce.plugins.Four', {
init: function(ed, url) {plugin_load_order.push("four");}
});
// Register plugin
tinymce.PluginManager.add('two', tinymce.plugins.Two, ["one"]);
tinymce.PluginManager.add('three', tinymce.plugins.Three, ["two"]);
tinymce.PluginManager.add('one', tinymce.plugins.One);
tinymce.PluginManager.add('four', tinymce.plugins.Four, ["one", "two"]);
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
plugins: "-three,-four",
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Plugin Dependency Functional tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
</body>
</html>
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic editor functionality tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
test('PluginDependencyIsLoaded', function() {
expect(2);
var pluginManager = tinymce.PluginManager;
var depPlugin = pluginManager.get("example_dependency");
ok(depPlugin, "Example Dependent plugin should have loaded");
var examplePlugin = pluginManager.get("example");
ok(examplePlugin, "Example plugin should have loaded via dependencies");
});
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
plugins: "example_dependency",
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Plugin Dependency Functional tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
</body>
</html>
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<title>Basic editor functionality tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
function check_plugin_loaded(name){
var pluginManager = tinymce.PluginManager;
var depPlugin = pluginManager.get(name);
ok(depPlugin, name + " plugin should have loaded");
}
test('Plugin Dependency Loaded from a Specific location', function() {
expect(2);
check_plugin_loaded("specific_location");
check_plugin_loaded("autolink");
});
tinymce.create('tinymce.plugins.SpecificLocation', {});
// Register plugin
tinymce.PluginManager.add('specific_location', tinymce.plugins.SpecificLocation, [{prefix: "plugins/", resource:"autolink", suffix:'/plugin' + tinymce.suffix + '.js'}]);
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
plugins: "-specific_location",
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
</head>
<body>
<h1 id="qunit-header">Plugin Dependency Functional tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
</body>
</html>
@@ -0,0 +1,345 @@
<!DOCTYPE html>
<html>
<head>
<title>Unit tests for the Table plugin</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
</head>
<body>
<script>
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("Table plugin", {
autostart: false
});
function getFontmostWindow() {
return editor.windowManager.windows[editor.windowManager.windows.length - 1];
}
function fillAndSubmitWindowForm(data) {
var win = getFontmostWindow();
win.fromJSON(data);
win.find('form')[0].submit();
win.close();
}
function cleanTableHtml(html) {
return cleanHtml(html).replace(/<p>(&nbsp;|<br[^>]+>)<\/p>$/, '');
}
test("Table properties dialog (get data from plain table)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceInsertTable');
deepEqual(getFontmostWindow().toJSON(), {
"align": false,
"border": "",
"caption": false,
"cellpadding": "",
"cellspacing": "",
"height": "",
"width": ""
});
getFontmostWindow().close();
});
test("Table properties dialog (get data from full table)", function() {
editor.setContent(
'<table style="width: 100px; height: 101px;" border="4" cellspacing="2" cellpadding="3">' +
'<caption>&nbsp;</caption>' +
'<tbody>' +
'<tr>' +
'<td>&nbsp;</td>' +
'</tr>' +
'</tbody>' +
'</table>'
);
setSelection('td', 0);
editor.execCommand('mceInsertTable');
deepEqual(getFontmostWindow().toJSON(), {
"align": false,
"border": "4",
"caption": true,
"cellpadding": "3",
"cellspacing": "2",
"height": "101",
"width": "100"
});
getFontmostWindow().close();
});
test("Table properties dialog (add caption)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceInsertTable');
fillAndSubmitWindowForm({
caption: true
});
equal(
cleanTableHtml(editor.getContent()),
'<table><caption>&nbsp;</caption><tbody><tr><td>x</td></tr></tbody></table>'
);
});
test("Table properties dialog (remove caption)", function() {
editor.setContent('<table><caption>&nbsp;</caption><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceInsertTable');
fillAndSubmitWindowForm({
caption: false
});
equal(
cleanTableHtml(editor.getContent()),
'<table><tbody><tr><td>x</td></tr></tbody></table>'
);
});
test("Table properties dialog (change size in pixels)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceInsertTable');
fillAndSubmitWindowForm({
width: 100,
height: 101
});
equal(
cleanTableHtml(editor.getContent()),
'<table style="width: 100px; height: 101px;"><tbody><tr><td>x</td></tr></tbody></table>'
);
});
test("Table properties dialog (change size in %)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceInsertTable');
fillAndSubmitWindowForm({
width: "100%",
height: "101%"
});
equal(
cleanTableHtml(editor.getContent()),
'<table style="width: 100%; height: 101%;"><tbody><tr><td>x</td></tr></tbody></table>'
);
});
test("Table properties dialog (change: border,cellpadding,cellspacing,align)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceInsertTable');
fillAndSubmitWindowForm({
border: "1",
cellpadding: "2",
cellspacing: "3",
align: "right"
});
equal(
cleanTableHtml(editor.getContent()),
'<table style="float: right;" border="1" cellspacing="3" cellpadding="2"><tbody><tr><td>x</td></tr></tbody></table>'
);
});
test("Table cell properties dialog (get data from plain cell)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableCellProps');
deepEqual(getFontmostWindow().toJSON(), {
"align": false,
"height": "",
"scope": "",
"type": "td",
"width": ""
});
getFontmostWindow().close();
});
test("Table cell properties dialog (get data from complex cell)", function() {
editor.setContent('<table><tr><th style="text-align: right; width: 10px; height: 11px" scope="row">X</th></tr></table>');
setSelection('th', 0);
editor.execCommand('mceTableCellProps');
deepEqual(getFontmostWindow().toJSON(), {
"align": "right",
"height": "11",
"scope": "row",
"type": "th",
"width": "10"
});
getFontmostWindow().close();
});
test("Table cell properties dialog (update all)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableCellProps');
fillAndSubmitWindowForm({
"align": "right",
"height": "11",
"scope": "row",
"type": "th",
"width": "10"
});
equal(
cleanTableHtml(editor.getContent()),
'<table><tbody><tr><th style="width: 10px; height: 11px; text-align: right;" scope="row">x</th></tr></tbody></table>'
);
});
test("Table row properties dialog (get data from plain cell)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableRowProps');
deepEqual(getFontmostWindow().toJSON(), {
"align": false,
"height": "",
"type": "tbody"
});
getFontmostWindow().close();
});
test("Table row properties dialog (get data from complex cell)", function() {
editor.setContent('<table><thead><tr style="height: 10px; text-align: right"><td>X</td></tr></thead></table>');
setSelection('td', 0);
editor.execCommand('mceTableRowProps');
deepEqual(getFontmostWindow().toJSON(), {
"align": "right",
"height": "10",
"type": "thead"
});
getFontmostWindow().close();
});
test("Table row properties dialog (update all)", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableRowProps');
fillAndSubmitWindowForm({
"align": "right",
"height": "10",
"type": "thead"
});
equal(
cleanTableHtml(editor.getContent({format: 'raw'})),
'<table class="mce-item-table"><thead><tr style="height: 10px; text-align: right;"><td>x</td></tr></thead></table>'
);
});
test("mceTableDelete command", function() {
editor.setContent('<table><tr><td>X</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableDelete');
equal(cleanTableHtml(editor.getContent()), '');
});
test("mceTableDeleteCol command", function() {
editor.setContent('<table><tr><td>1</td><td>2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableDeleteCol');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td>2</td></tr></tbody></table>');
});
test("mceTableDeleteRow command", function() {
editor.setContent('<table><tr><td>1</td></tr><tr><td>2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableDeleteRow');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td>2</td></tr></tbody></table>');
});
test("mceTableInsertColAfter command", function() {
editor.setContent('<table><tr><td>1</td></tr><tr><td>2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableInsertColAfter');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td>1</td><td>&nbsp;</td></tr><tr><td>2</td><td>&nbsp;</td></tr></tbody></table>');
});
test("mceTableInsertColBefore command", function() {
editor.setContent('<table><tr><td>1</td></tr><tr><td>2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableInsertColBefore');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td>&nbsp;</td><td>1</td></tr><tr><td>&nbsp;</td><td>2</td></tr></tbody></table>');
});
test("mceTableInsertRowAfter command", function() {
editor.setContent('<table><tr><td>1</td><td>2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableInsertRowAfter');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td>1</td><td>2</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table>');
});
test("mceTableInsertRowBefore command", function() {
editor.setContent('<table><tr><td>1</td><td>2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableInsertRowBefore');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>1</td><td>2</td></tr></tbody></table>');
});
test("mceTableMergeCells command with cell selection", function() {
editor.setContent('<table><tr><td class="mce-item-selected">1</td><td class="mce-item-selected">2</td></tr></table>');
setSelection('td', 0);
editor.execCommand('mceTableMergeCells');
equal(cleanTableHtml(editor.getContent()), '<table><tbody><tr><td colspan="2">12</td></tr></tbody></table>');
});
test("mceTableSplitCells command", function() {
editor.setContent('<table><tbody><tr><td colspan="2">12</td></tr></tbody></table>');
setSelection('td', 0);
editor.execCommand('mceTableSplitCells');
equal(
cleanTableHtml(editor.getContent()),
'<table><tbody><tr><td>12</td><td>&nbsp;</td></tr></tbody></table>'
);
});
tinymce.init({
selector: "textarea",
add_unload_trigger: false,
plugins: 'table',
init_instance_callback: function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
<h1 id="qunit-header">Unit tests for the Table plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</body>
</html>
@@ -0,0 +1,189 @@
<!DOCTYPE html>
<html>
<head>
<title>Table plugin tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
<script src="js/jsrobot/robot.js"></script>
<script>
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module('Table plugin', {
autostart: false
});
var VK;
var UP_ARROW = 0x26;
var DOWN_ARROW = 0x28;
var ENTER = 0xA;
if (tinymce.isWebKit) {
asyncTest('Selecting Cell and typing should update cell correctly in WebKit', function() {
editor.setContent('<table><tr><td><p>first cell</p></td><td><p>second cell</p></td></tr></table>');
// in order for the robot to work well, we need to focus the editor before performing selection on it.
editor.focus();
// in order to simulate the section on tables as per the plugin we do a select then call out to the fix table selection
// (which is called by selection events).
editor.selection.select(editor.dom.select('td')[0]);
editor.fire('keydown');
robot.type('g',false, function(){
var expected = '<table><tbody><tr><td><p>g</p></td><td><p>second cell</p></td></tr></tbody></table>';
var actual = editor.getContent();
equal(actual, expected);
start();
}, editor.getBody());
});
} else {
asyncTest('Empty stub', function() {
start();
ok(true, "Dummy");
});
}
function testCursorKey(html, nodeToSelect, keyCode, expected) {
editor.setContent(html);
editor.focus();
setSelection(nodeToSelect, 0);
editor.focus();
robot.type(keyCode, false, function() {
var node = editor.selection.getNode();
var actual = node.firstChild.nodeValue;
equal(actual, expected);
start();
}, editor.getBody());
}
asyncTest('space key does not nuke content in th cells', 1, function() {
editor.setContent('<table><tbody><tr><th id="a">abcdef</th></tr></tbody></table>');
editor.focus();
setSelection('#a', 3);
editor.focus();
robot.type(VK.SPACEBAR, false, function() {
var actual = editor.dom.get('a').innerHTML;
var expected = 'abc def';
equal(actual, expected);
start()
}, editor.getBody());
});
asyncTest('arrow up key moves to row above', function() {
var html = '<table><tr><td>0</td><td>1</td></tr><tr><td>0</td><td id="b">2</td></tr></table>';
testCursorKey(html, '#b', UP_ARROW, '1');
});
asyncTest('arrow up key moves to row above for heading cells', function() {
var html = '<table><tr><td>0</td><td>1</td></tr><tr><td>0</td><th id="b">2</th></tr></table>';
testCursorKey(html, '#b', UP_ARROW, '1');
});
asyncTest('arrow down key moves to row below', function() {
var html = '<table><tr><td id="a"></td></tr><tr><td>2</td></tr></table>';
testCursorKey(html, '#a', DOWN_ARROW, '2');
});
asyncTest('arrow up key in cell with colspan moves to row above', function() {
var html = '<table><tr><td>1</td><td></td></tr><tr><td id="b" colspan="2"></td></tr></table>';
testCursorKey(html, '#b', UP_ARROW, '1');
});
asyncTest('arrow down key in cell with colspan moves to row below', function() {
var html = '<table><tr><td id="a" colspan="2"></td></tr><tr><td>2</td><td></td></tr></table>';
testCursorKey(html, '#a', DOWN_ARROW, '2');
});
asyncTest('arrow key up in top row escapes table', function() {
var html = '<p>outside</p><table><tr><td id="a"></td></tr><tr><td></td></tr></table>';
testCursorKey(html, '#a', UP_ARROW, 'outside');
});
asyncTest('arrow key down in bottom row escapes table', function() {
var html = '<table><tr><td></td></tr><tr><td id="b"></td></tr></table><p>outside</p>';
testCursorKey(html, '#b', DOWN_ARROW, 'outside');
});
asyncTest('arrow key up in bottom row to last p in above tr', 1, function() {
var html = "<table><tr><td><p id='a'>a</p><p id='b'>b</p></td></tr><tr><td><p id='c'>c</p><p>d</p></td></tr></table>";
testCursorKey(html, '#c', UP_ARROW, 'b');
});
asyncTest('arrow key down in top row to first p in below tr', 1, function() {
var html = "<table><tr><td><p id='a'>a</p><p id='b'>b</p></td></tr><tr><td><p id='c'>c</p><p>d</p></td></tr></table>";
testCursorKey(html, '#b', DOWN_ARROW, 'c');
});
asyncTest('arrow key down into table cell with br', 1, function() {
var html = "<table><tr><td id='a'></td></tr><tr><td>something<br></td></tr></table>";
testCursorKey(html, '#a', DOWN_ARROW, 'something');
});
asyncTest('shift-enter in table cell ending with BR places caret on new line', function() {
editor.setContent('<table><tr><td>d <strong>e</strong><br></td></tr></table>');
setSelection('strong', 1);
robot.type(ENTER, true, function(){
var expected = '<table><tbody><tr><td>d <strong>e<br /></strong></td></tr></tbody></table>';
var actual = editor.getContent();
var range = editor.selection.getRng(true);
equal(cleanHtml(actual), expected);
equal(range.startContainer.nodeName, 'STRONG');
equal(range.startOffset, 2);
equal(range.collapsed, true);
start();
}, editor.getBody());
});
// Only run on Gecko since WebKit and IE can place a caret after a table
if (tinymce.Env.gecko) {
test("Insert table and remove caret placeholder", function() {
editor.setContent('<table><tbody><tr><td>x</td></tr></tbody></table>');
equal(editor.getBody().firstChild.nodeName, "TABLE");
equal(editor.getBody().lastChild.nodeName, "P");
equal(editor.getContent(), '<table><tbody><tr><td>x</td></tr></tbody></table>');
});
} else {
test("Skipped since it works in this browser", function() {
ok(true, "Dummy assert");
});
}
var initTinyFunction = function(){
tinymce.init({
mode : "exact",
elements : "elm1",
cleanup: true,
indent: false,
add_unload_trigger : false,
webkit_fake_resize: false,
plugins: "table",
init_instance_callback : function(ed) {
editor = ed;
VK = tinymce.util.VK;
}
});
};
</script>
</head>
<body>
<h1 id="qunit-header">Table plugin tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="content">
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</div>
<script>
initWhenTinyAndRobotAreReady(initTinyFunction);
</script>
</body>
</html>
@@ -0,0 +1,21 @@
{
"title": "Plugins tests",
"tests": [
{"title": "Media", "url": "media.html"},
{"title": "Noneditable", "url": "noneditable.html"},
{"title": "Paste", "url": "paste.html"},
{"title": "Table", "url": "table.html"},
{"title": "Table (robot)", "url": "table_robot.html", "jsrobot": true},
{"title": "jQuery", "url": "jquery_plugin.html"},
{"title": "Autolink", "url": "autolink.html", "jsrobot": true},
{"title": "Wordcount", "url": "wordcount.html"},
{"title": "Fullpage", "url": "fullpage.html"},
{"title": "Legacyoutput", "url": "legacyoutput.html"},
{"title": "Plugin Dependencies", "url": "plugin_dependency_simple.html"},
{"title": "Plugin Dependency Chain", "url": "plugin_dependency_chain.html"},
{"title": "Plugin Dependency Chain Legacy", "url": "plugin_dependency_chain_legacy.html"},
{"title": "Dependency Chain Init Call Order", "url": "plugin_dependency_init_call_order.html"},
{"title": "Dependency With Specific Location", "url": "plugin_dependency_specific_location.html"},
{"title": "Lists", "url": "lists.html"}
]
}
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html>
<head>
<title>Unit tests for the Wordcount plugin</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="js/qunit/reporter.js"></script>
<script src="js/utils.js"></script>
<script src="js/tinymce_loader.js"></script>
</head>
<body>
<script>
var editor;
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("tinymce.plugins.Wordcount", {
autostart: false
});
test("Blank document has 0 words", function() {
expect(1);
editor.setContent('');
var result = editor.plugins.wordcount.getCount();
equal(result, 0);
});
test("Simple word count", function() {
expect(1);
editor.setContent('<p>My sentence is this.</p>');
var result = editor.plugins.wordcount.getCount();
equal(result, 4);
});
test("Does not count dashes", function() {
expect(1);
editor.setContent('<p>Something -- ok</p>');
var result = editor.plugins.wordcount.getCount();
equal(result, 2);
});
test("Does not count asterisks, non-word characters", function() {
expect(1);
editor.setContent('<p>* something\n· something else</p>');
var result = editor.plugins.wordcount.getCount();
equal(result, 3);
});
test("Does not count htmlentities", function() {
expect(1);
editor.setContent('<p>It&rsquo;s my life &ndash; don\'t you forget.</p>');
var result = editor.plugins.wordcount.getCount();
equal(result, 6);
});
test("Counts hyphenated words as one word", function() {
expect(1);
editor.setContent('<p>Hello some-word here.</p>');
var result = editor.plugins.wordcount.getCount();
equal(result, 3);
});
test("Counts words between blocks as two words", function() {
expect(1);
editor.setContent('<p>Hello</p><p>world</p>');
var result = editor.plugins.wordcount.getCount();
equal(result, 2);
});
/*
The blocking functionality in the wordcount plugin prevents this code from
being tested correctly.
I'm of the opinion that the blocking code isn't really doing
anything crucial, and should be ripped out, so this module can be tested.
---------
test("should set the word count in the target html element", function() {
expect(1);
editor.setContent('<p>Hey, it\'s me!</p>');
equal(parseInt(document.getElementById('elm1-word-count').innerHTML), 3);
});
*/
tinymce.init({
mode : "exact",
elements : "elm1",
add_unload_trigger : false,
wordcount_target_id: 'current-count',
plugins : 'wordcount',
init_instance_callback : function(ed) {
editor = ed;
QUnit.start();
}
});
</script>
<h1 id="qunit-header">Unit tests for the Wordcount plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="word-count">
Current Count: <span id="current-count"></span>
</div>
<textarea id="elm1" name="elm1"></textarea>
<div>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent({format : 'raw'}));">[getRawContents]</a>
<a href="javascript:alert(tinymce.EditorManager.get('elm1').getContent());">[getContents]</a>
</div>
</body>
</html>