Fixes #33782 for 4.3.

git-svn-id: https://develop.svn.wordpress.org/branches/4.3@34029 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-09-10 23:56:25 +00:00
parent 3a7c781c87
commit dcb9873834
27 changed files with 1085 additions and 588 deletions

View File

@ -381,16 +381,18 @@ tinymce.PluginManager.add('charmap', function(editor) {
});
}
editor.addCommand('mceShowCharmap', showDialog);
editor.addButton('charmap', {
icon: 'charmap',
tooltip: 'Special character',
onclick: showDialog
cmd: 'mceShowCharmap'
});
editor.addMenuItem('charmap', {
icon: 'charmap',
text: 'Special character',
onclick: showDialog,
cmd: 'mceShowCharmap',
context: 'insert'
});
});

File diff suppressed because one or more lines are too long

View File

@ -349,24 +349,22 @@ tinymce.PluginManager.add('lists', function(editor) {
dom.remove(li);
}
return true;
} else {
if (ulParent.nodeName == 'LI') {
ul = ulParent;
newBlock = createNewTextBlock(li, 'LI');
} else if (isListNode(ulParent)) {
newBlock = createNewTextBlock(li, 'LI');
} else {
newBlock = createNewTextBlock(li);
}
splitList(ul, li, newBlock);
normalizeList(ul.parentNode);
return true;
}
return false;
if (ulParent.nodeName == 'LI') {
ul = ulParent;
newBlock = createNewTextBlock(li, 'LI');
} else if (isListNode(ulParent)) {
newBlock = createNewTextBlock(li, 'LI');
} else {
newBlock = createNewTextBlock(li);
}
splitList(ul, li, newBlock);
normalizeList(ul.parentNode);
return true;
}
function indent(li) {

View File

@ -14,11 +14,11 @@
tinymce.PluginManager.add('media', function(editor, url) {
var urlPatterns = [
{regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1'},
{regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2'},
{regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc'},
{regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0"},
{regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"'}
{regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1', allowFullscreen: true},
{regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2', allowFullscreen: true},
{regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc', allowfullscreen: true},
{regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0", allowfullscreen: true},
{regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"', allowFullscreen: false}
];
var embedChange = (tinymce.Env.ie && tinymce.Env.ie <= 8) ? 'onChange' : 'onInput';
@ -265,6 +265,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
data.source1 = url;
data.type = pattern.type;
data.allowFullscreen = pattern.allowFullscreen;
data.width = data.width || pattern.w;
data.height = data.height || pattern.h;
}
@ -288,7 +289,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
});
if (data.type == "iframe") {
html += '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"></iframe>';
var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : '';
html += '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
} else if (data.source1mime == "application/x-shockwave-flash") {
html += '<object data="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
@ -394,7 +396,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
return html;
}
var writer = new tinymce.html.Writer();
var writer = new tinymce.html.Writer(), blocked;
new tinymce.html.SaxParser({
validate: false,
@ -414,6 +416,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
},
start: function(name, attrs, empty) {
blocked = true;
if (name == 'script' || name == 'noscript') {
return;
}
@ -422,13 +426,18 @@ tinymce.PluginManager.add('media', function(editor, url) {
if (attrs[i].name.indexOf('on') === 0) {
return;
}
if (attrs[i].name == 'style') {
attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
}
}
writer.start(name, attrs, empty);
blocked = false;
},
end: function(name) {
if (name == 'script' || name == 'noscript') {
if (blocked) {
return;
}
@ -779,4 +788,6 @@ tinymce.PluginManager.add('media', function(editor, url) {
context: 'insert',
prependToContext: true
});
this.showDialog = showDialog;
});

File diff suppressed because one or more lines are too long

View File

@ -63,10 +63,12 @@
}
function expose(ids) {
for (var i = 0; i < ids.length; i++) {
var target = exports;
var id = ids[i];
var fragments = id.split(/[.\/]/);
var i, target, id, fragments, privateModules;
for (i = 0; i < ids.length; i++) {
target = exports;
id = ids[i];
fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length - 1; ++fi) {
if (target[fragments[fi]] === undefined) {
@ -78,6 +80,21 @@
target[fragments[fragments.length - 1]] = modules[id];
}
// Expose private modules for unit tests
if (exports.AMDLC_TESTS) {
privateModules = exports.privateModules || {};
for (id in modules) {
privateModules[id] = modules[id];
}
for (i = 0; i < ids.length; i++) {
delete privateModules[ids[i]];
}
exports.privateModules = privateModules;
}
}
// Included from: js/tinymce/plugins/paste/classes/Utils.js

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}
.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:0 0;text-decoration:none;color:#000;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:400;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}

View File

@ -1 +1 @@
body{background-color:#FFF;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#F0F0EE;scrollbar-arrow-color:#676662;scrollbar-base-color:#F0F0EE;scrollbar-darkshadow-color:#DDD;scrollbar-face-color:#E0E0DD;scrollbar-highlight-color:#F0F0EE;scrollbar-shadow-color:#F0F0EE;scrollbar-track-color:#F5F5F5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}
body{background-color:#FFF;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#F0F0EE;scrollbar-arrow-color:#676662;scrollbar-base-color:#F0F0EE;scrollbar-darkshadow-color:#DDD;scrollbar-face-color:#E0E0DD;scrollbar-highlight-color:#F0F0EE;scrollbar-shadow-color:#F0F0EE;scrollbar-track-color:#F5F5F5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:0 0;text-decoration:none;color:#000;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:400;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
var defaultToolbar = "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | " +
"bullist numlist outdent indent | link image";
function createToolbar(items) {
function createToolbar(items, size) {
var toolbarItems = [], buttonGroup;
if (!items) {
@ -88,12 +88,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
buttonGroup = null;
} else {
if (Factory.has(item)) {
item = {type: item};
if (settings.toolbar_items_size) {
item.size = settings.toolbar_items_size;
}
item = {type: item, size: size};
toolbarItems.push(item);
buttonGroup = null;
} else {
@ -112,10 +107,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
}
item.type = item.type || 'button';
if (settings.toolbar_items_size) {
item.size = settings.toolbar_items_size;
}
item.size = size;
item = Factory.create(item);
buttonGroup.items.push(item);
@ -140,14 +132,15 @@ tinymce.ThemeManager.add('modern', function(editor) {
/**
* Creates the toolbars from config and returns a toolbar array.
*
* @param {String} size Optional toolbar item size.
* @return {Array} Array with toolbars.
*/
function createToolbars() {
function createToolbars(size) {
var toolbars = [];
function addToolbar(items) {
if (items) {
toolbars.push(createToolbar(items));
toolbars.push(createToolbar(items, size));
return true;
}
}
@ -670,7 +663,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
border: 1,
items: [
settings.menubar === false ? null : {type: 'menubar', border: '0 0 1 0', items: createMenuButtons()},
createToolbars()
createToolbars(settings.toolbar_items_size)
]
});
@ -747,7 +740,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
border: 1,
items: [
settings.menubar === false ? null : {type: 'menubar', border: '0 0 1 0', items: createMenuButtons()},
createToolbars(),
createToolbars(settings.toolbar_items_size),
{type: 'panel', name: 'iframe', layout: 'stack', classes: 'edit-area', html: '', border: '1 0 0 0'}
]
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ $wp_db_version = 33056;
*
* @global string $tinymce_version
*/
$tinymce_version = '4203-20150730';
$tinymce_version = '4205-20150910';
/**
* Holds the required PHP version

View File

@ -19,14 +19,19 @@
<script src="http://www.google.com/jsapi"></script>
<script>google.load("jquery", "1");</script>
<script src="js/module_loader.js"></script>
<script src="js/qunit/qunit.js"></script>
<script src="../../../build/wp-includes/js/tinymce/tinymce.min.js"></script>
<!--<script src="../js/tinymce/classes/jquery.tinymce.js"></script> -->
<script src="js/utils.js"></script>
<script src="js/init.js"></script>
<!-- tinymce.data.* -->
<script src="tinymce/data/ObservableObject.js"></script>
<!-- tinymce.file.* -->
<script src="tinymce/file/Conversions.js"></script>
<script src="tinymce/file/ImageScanner.js"></script>
<script>
var wpPlugins = 'charmap colorpicker hr lists media paste tabfocus textcolor ' +

View File

@ -0,0 +1,37 @@
(function(exports) {
exports.AMDLC_TESTS = true;
function resolve(id) {
var i, target = exports, fragments = id.split(/[.\/]/);
for (i = 0; i < fragments.length; i++) {
if (!target[fragments[i]]) {
return;
}
target = target[fragments[i]];
}
return target;
}
function require(ids, callback) {
var i, module, defs = [], privateModules = exports.privateModules || {};
for (i = 0; i < ids.length; i++) {
module = privateModules[ids[i]] || resolve(ids[i]);
if (!module) {
throw 'module definition dependecy not found: ' + ids[i];
}
defs.push(module);
}
callback.apply(null, defs);
}
exports.ModuleLoader = {
require: require
};
})(this);

View File

@ -25,6 +25,38 @@ module("tinymce.plugins.Media", {
}
});
function fillAndSubmitWindowForm(data) {
var win = Utils.getFrontmostWindow();
win.fromJSON(data);
win.find('form')[0].submit();
win.close();
}
test('Default media dialog on empty editor', function() {
editor.setContent('');
editor.plugins.media.showDialog();
deepEqual(Utils.getFrontmostWindow().toJSON(), {
constrain: true,
embed: "",
height: "",
poster: "",
source1: "",
source2: "",
width: ""
});
fillAndSubmitWindowForm({
"source1": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
});
equal(
editor.getContent(),
'<p><iframe src=\"//www.youtube.com/embed/dQw4w9WgXcQ\" width=\"425\" height=\"350\" allowfullscreen=\"allowfullscreen\"></iframe></p>'
);
});
test("Object retain as is", function() {
editor.setContent(
'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355">' +
@ -162,4 +194,8 @@ test("XSS content", function() {
testXss('<video><img src="x" onload="alert(1)"></video>', '<p><video width="300" height=\"150\"></video></p>');
testXss('<video><img src="x"></video>', '<p><video width="300" height="150"><img src="x" /></video></p>');
testXss('<video><!--[if IE]><img src="x"><![endif]--></video>', '<p><video width="300" height="150"><!-- [if IE]><img src="x"><![endif]--></video></p>');
});
testXss('<p><p><audio><audio src=x onerror=alert(1)>', '<p><audio></audio></p>');
testXss('<p><html><audio><br /><audio src=x onerror=alert(1)></p>', '');
testXss('<p><audio><img src="javascript:alert(1)"></audio>', '<p><audio><img /></audio></p>');
testXss('<p><audio><img src="x" style="behavior:url(x); width: 1px"></audio>', '<p><audio><img src="x" style="width: 1px;" /></audio></p>');
});

View File

@ -794,4 +794,4 @@ WP end */
equal(editor.getContent(), '<p style="color: #ff0000;">abc</p>');
});
}
}

View File

@ -10,6 +10,7 @@ module("tinymce.plugins.SearchReplace", {
skin: false,
indent: false,
disable_nodechange: true,
valid_elements: 'b,i',
init_instance_callback : function(ed) {
window.editor = ed;
window.setTimeout(function() {
@ -31,7 +32,7 @@ test('Find single match', function() {
});
test('Find single match in multiple elements', function() {
editor.getBody().innerHTML = 't<b>e</b><em>xt</em>';
editor.getBody().innerHTML = 't<b>e</b><i>xt</i>';
equal(1, editor.plugins.searchreplace.find('text'));
});
@ -79,6 +80,20 @@ test('Find multiple matches, move to next and replace', function() {
equal("<p>a x</p>", editor.getContent());
});
test('Find and replace fragmented match', function() {
editor.getBody().innerHTML = '<b>te<i>s</i>t</b><b>te<i>s</i>t</b>';
editor.plugins.searchreplace.find('test');
ok(editor.plugins.searchreplace.replace('abc'));
equal(editor.getContent(), "<p><b>abc</b><b>te<i>s</i>t</b></p>");
});
test('Find and replace all fragmented matches', function() {
editor.getBody().innerHTML = '<b>te<i>s</i>t</b><b>te<i>s</i>t</b>';
editor.plugins.searchreplace.find('test');
ok(!editor.plugins.searchreplace.replace('abc', true, true));
equal(editor.getContent(), "<p><b>abc</b><b>abc</b></p>");
});
test('Find multiple matches, move to next and replace backwards', function() {
editor.getBody().innerHTML = 'a a';
equal(2, editor.plugins.searchreplace.find('a'));

View File

@ -1,4 +1,7 @@
(function() {
ModuleLoader.require([
"tinymce/file/Conversions",
"tinymce/Env"
], function(Conversions, Env) {
var testBlob, testBlobDataUri;
if (!tinymce.Env.fileApi) {
@ -37,7 +40,7 @@
testBlobDataUri = canvas.toDataURL();
tinymce.file.Conversions.uriToBlob(testBlobDataUri).then(function(blob) {
Conversions.uriToBlob(testBlobDataUri).then(function(blob) {
testBlob = blob;
QUnit.start();
});
@ -61,7 +64,7 @@
var blobInfo = result[0].blobInfo;
QUnit.equal("data:" + blobInfo.blob().type + ";base64," + blobInfo.base64(), testBlobDataUri);
QUnit.equal('<p><img src="' + blobInfo.blobUri() + '" alt=""></p>', editor.getBody().innerHTML);
QUnit.equal(Utils.normalizeHtml(editor.getBody().innerHTML), '<p><img alt="" src="' + blobInfo.blobUri() + '" /></p>');
QUnit.equal('<p><img src="data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64() + '" alt="" /></p>', editor.getContent());
QUnit.strictEqual(editor.editorUpload.blobCache.get(blobInfo.id()), blobInfo);
}).then(QUnit.start);
@ -94,4 +97,61 @@
});
}).then(QUnit.start);
});
})();
asyncTest('uploadConcurrentImages', function() {
var uploadCount = 0, callCount = 0;
function done() {
callCount++;
if (callCount == 2) {
QUnit.start();
equal(uploadCount, 1, 'Should only be one upload.');
}
}
editor.setContent(imageHtml(testBlobDataUri));
editor.settings.images_upload_handler = function(data, success) {
uploadCount++;
success(data.id() + '.png');
};
editor.uploadImages(done);
editor.uploadImages(done);
});
asyncTest('Don\'t upload transparent image', function() {
var uploadCount = 0;
function done() {
QUnit.start();
equal(uploadCount, 0, 'Should not upload.');
}
editor.setContent(imageHtml(Env.transparentSrc));
editor.settings.images_upload_handler = function(data, success) {
uploadCount++;
};
editor.uploadImages(done);
});
asyncTest('Don\'t upload bogus image', function() {
var uploadCount = 0;
function done() {
QUnit.start();
equal(uploadCount, 0, 'Should not upload.');
}
editor.getBody().innerHTML = '<img src="' + testBlobDataUri + '" data-mce-bogus="1">';
editor.settings.images_upload_handler = function(data, success) {
uploadCount++;
};
editor.uploadImages(done);
});
});

View File

@ -13,7 +13,7 @@ module("tinymce.EnterKey", {
schema: 'html5',
extended_valid_elements: 'div[id|style|contenteditable],span[id|style|contenteditable],#dt,#dd',
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,position,top,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,position,top,left'
},
init_instance_callback: function(ed) {
window.editor = ed;
@ -36,7 +36,7 @@ test('Enter at end of H1', function() {
editor.setContent('<h1>abc</h1>');
Utils.setSelection('h1', 3);
Utils.pressEnter();
equal(editor.getContent(),'<h1>abc</h1><p>\u00a0</p>');
equal(editor.getContent(), '<h1>abc</h1><p>\u00a0</p>');
equal(editor.selection.getRng(true).startContainer.nodeName, 'P');
});
@ -44,7 +44,7 @@ test('Enter in midde of H1', function() {
editor.setContent('<h1>abcd</h1>');
Utils.setSelection('h1', 2);
Utils.pressEnter();
equal(editor.getContent(),'<h1>ab</h1><h1>cd</h1>');
equal(editor.getContent(), '<h1>ab</h1><h1>cd</h1>');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'H1');
});
@ -52,7 +52,7 @@ test('Enter before text after EM', function() {
editor.setContent('<p><em>a</em>b</p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(),'<p><em>a</em></p><p>b</p>');
equal(editor.getContent(), '<p><em>a</em></p><p>b</p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeValue, 'b');
});
@ -61,14 +61,14 @@ test('Enter before first IMG in P', function() {
editor.setContent('<p><img alt="" src="about:blank" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><p><img src="about:blank" alt="" /></p>');
equal(editor.getContent(), '<p>\u00a0</p><p><img src="about:blank" alt="" /></p>');
});
test('Enter before last IMG in P with text', function() {
editor.setContent('<p>abc<img alt="" src="about:blank" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(),'<p>abc</p><p><img src="about:blank" alt="" /></p>');
equal(editor.getContent(), '<p>abc</p><p><img src="about:blank" alt="" /></p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'IMG');
@ -78,7 +78,7 @@ test('Enter before last IMG in P with IMG sibling', function() {
editor.setContent('<p><img src="about:blank" alt="" /><img src="about:blank" alt="" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(),'<p><img src="about:blank" alt="" /></p><p><img src="about:blank" alt="" /></p>');
equal(editor.getContent(), '<p><img src="about:blank" alt="" /></p><p><img src="about:blank" alt="" /></p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'IMG');
@ -88,14 +88,14 @@ test('Enter after last IMG in P', function() {
editor.setContent('<p>abc<img alt="" src="about:blank" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 2);
Utils.pressEnter();
equal(editor.getContent(),'<p>abc<img src="about:blank" alt="" /></p><p>\u00a0</p>');
equal(editor.getContent(), '<p>abc<img src="about:blank" alt="" /></p><p>\u00a0</p>');
});
test('Enter before last INPUT in P with text', function() {
editor.setContent('<p>abc<input type="text" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(),'<p>abc</p><p><input type="text" /></p>');
equal(editor.getContent(), '<p>abc</p><p><input type="text" /></p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'INPUT');
@ -105,7 +105,7 @@ test('Enter before last INPUT in P with IMG sibling', function() {
editor.setContent('<p><input type="text" /><input type="text" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 1);
Utils.pressEnter();
equal(editor.getContent(),'<p><input type="text" /></p><p><input type="text" /></p>');
equal(editor.getContent(), '<p><input type="text" /></p><p><input type="text" /></p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'P');
equal(rng.startContainer.childNodes[rng.startOffset].nodeName, 'INPUT');
@ -115,14 +115,14 @@ test('Enter after last INPUT in P', function() {
editor.setContent('<p>abc<input type="text" /></p>');
editor.selection.setCursorLocation(editor.getBody().firstChild, 2);
Utils.pressEnter();
equal(editor.getContent(),'<p>abc<input type="text" /></p><p>\u00a0</p>');
equal(editor.getContent(), '<p>abc<input type="text" /></p><p>\u00a0</p>');
});
test('Enter at end of P', function() {
editor.setContent('<p>abc</p>');
Utils.setSelection('p', 3);
Utils.pressEnter();
equal(editor.getContent(),'<p>abc</p><p>\u00a0</p>');
equal(editor.getContent(), '<p>abc</p><p>\u00a0</p>');
equal(editor.selection.getRng(true).startContainer.nodeName, 'P');
});
@ -138,7 +138,7 @@ test('Enter at middle of EM inside P', function() {
editor.setContent('<p><em>abcd</em></p>');
Utils.setSelection('em', 2);
Utils.pressEnter();
equal(editor.getContent(),'<p><em>ab</em></p><p><em>cd</em></p>');
equal(editor.getContent(), '<p><em>ab</em></p><p><em>cd</em></p>');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'EM');
});
@ -162,7 +162,7 @@ test('Enter at middle of STRONG in EM inside P', function() {
editor.setContent('<p><em><strong>abcd</strong></em></p>');
Utils.setSelection('strong', 2);
Utils.pressEnter();
equal(editor.getContent(),'<p><em><strong>ab</strong></em></p><p><em><strong>cd</strong></em></p>');
equal(editor.getContent(), '<p><em><strong>ab</strong></em></p><p><em><strong>cd</strong></em></p>');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'STRONG');
});
@ -178,7 +178,7 @@ test('Enter at beginning of P', function() {
editor.setContent('<p>abc</p>');
Utils.setSelection('p', 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><p>abc</p>');
equal(editor.getContent(), '<p>\u00a0</p><p>abc</p>');
equal(editor.selection.getRng(true).startContainer.nodeValue, 'abc');
});
@ -186,7 +186,7 @@ test('Enter at middle of P with style, id and class attributes', function() {
editor.setContent('<p id="a" class="b" style="color:#000">abcd</p>');
Utils.setSelection('p', 2);
Utils.pressEnter();
equal(editor.getContent(),'<p id="a" class="b" style="color: #000;">ab</p><p class="b" style="color: #000;">cd</p>');
equal(editor.getContent(), '<p id="a" class="b" style="color: #000;">ab</p><p class="b" style="color: #000;">cd</p>');
equal(editor.selection.getRng(true).startContainer.parentNode.nodeName, 'P');
});
@ -194,7 +194,7 @@ test('Enter at a range between H1 and P', function() {
editor.setContent('<h1>abcd</h1><p>efgh</p>');
Utils.setSelection('h1', 2, 'p', 2);
Utils.pressEnter();
equal(editor.getContent(),'<h1>abgh</h1>');
equal(editor.getContent(), '<h1>abgh</h1>');
equal(editor.selection.getNode().nodeName, 'H1');
});
@ -202,7 +202,7 @@ test('Enter at end of H1 in HGROUP', function() {
editor.setContent('<hgroup><h1>abc</h1></hgroup>');
Utils.setSelection('h1', 3);
Utils.pressEnter();
equal(editor.getContent(),'<hgroup><h1>abc</h1><h1>\u00a0</h1></hgroup>');
equal(editor.getContent(), '<hgroup><h1>abc</h1><h1>\u00a0</h1></hgroup>');
equal(editor.selection.getRng(true).startContainer.nodeName, 'H1');
});
@ -226,7 +226,7 @@ test('Enter inside middle of text node in body', function() {
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 2);
Utils.pressEnter();
equal(editor.getContent(),'<p>ab</p><p>cd</p>');
equal(editor.getContent(), '<p>ab</p><p>cd</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -234,7 +234,7 @@ test('Enter inside at beginning of text node in body', function() {
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><p>abcd</p>');
equal(editor.getContent(), '<p>\u00a0</p><p>abcd</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -242,7 +242,7 @@ test('Enter inside at end of text node in body', function() {
editor.getBody().innerHTML = 'abcd';
Utils.setSelection('body', 4);
Utils.pressEnter();
equal(editor.getContent(),'<p>abcd</p><p>\u00a0</p>');
equal(editor.getContent(), '<p>abcd</p><p>\u00a0</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -250,71 +250,71 @@ test('Enter inside empty body', function() {
editor.getBody().innerHTML = '';
Utils.setSelection('body', 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><p>\u00a0</p>');
equal(editor.getContent(), '<p>\u00a0</p><p>\u00a0</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside empty li in beginning of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li></li><li>a</li></ol>': '<ol><li><br></li><li>a</li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li></li><li>a</li></ol>' : '<ol><li><br></li><li>a</li></ol>';
Utils.setSelection('li', 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><ol><li>a</li></ol>');
equal(editor.getContent(), '<p>\u00a0</p><ol><li>a</li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside empty li at the end of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li></ol>': '<ol><li>a</li><li><br></li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li></ol>' : '<ol><li>a</li><li><br></li></ol>';
Utils.setSelection('li:last', 0);
Utils.pressEnter();
equal(editor.getContent(),'<ol><li>a</li></ol><p>\u00a0</p>');
equal(editor.getContent(), '<ol><li>a</li></ol><p>\u00a0</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Shift+Enter inside empty li in the middle of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li><li>b</li></ol>': '<ol><li>a</li><li><br></li><li>b</li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li><li>b</li></ol>' : '<ol><li>a</li><li><br></li><li>b</li></ol>';
Utils.setSelection('li:nth-child(2)', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<ol><li>a</li></ol><p>\u00a0</p><ol><li>b</li></ol>');
equal(editor.getContent(), '<ol><li>a</li></ol><p>\u00a0</p><ol><li>b</li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Shift+Enter inside empty li in beginning of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li></li><li>a</li></ol>': '<ol><li><br></li><li>a</li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li></li><li>a</li></ol>' : '<ol><li><br></li><li>a</li></ol>';
Utils.setSelection('li', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p>\u00a0</p><ol><li>a</li></ol>');
equal(editor.getContent(), '<p>\u00a0</p><ol><li>a</li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Shift+Enter inside empty li at the end of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li></ol>': '<ol><li>a</li><li><br></li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li></ol>' : '<ol><li>a</li><li><br></li></ol>';
Utils.setSelection('li:last', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<ol><li>a</li></ol><p>\u00a0</p>');
equal(editor.getContent(), '<ol><li>a</li></ol><p>\u00a0</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
test('Enter inside empty li in the middle of ol with forced_root_block: false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li><li>b</li></ol>': '<ol><li>a</li><li><br></li><li>b</li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li><li>b</li></ol>' : '<ol><li>a</li><li><br></li><li>b</li></ol>';
Utils.setSelection('li:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<ol><li>a</li></ol><br /><ol><li>b</li></ol>');
equal(editor.getContent(), '<ol><li>a</li></ol><br /><ol><li>b</li></ol>');
equal(editor.selection.getNode().nodeName, 'BODY');
});
test('Enter inside empty li in beginning of ol with forced_root_block: false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li></li><li>a</li></ol>': '<ol><li><br></li><li>a</li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li></li><li>a</li></ol>' : '<ol><li><br></li><li>a</li></ol>';
Utils.setSelection('li', 0);
Utils.pressEnter();
equal(editor.getContent(),'<br /><ol><li>a</li></ol>');
equal(editor.getContent(), '<br /><ol><li>a</li></ol>');
equal(editor.selection.getNode().nodeName, 'BODY');
});
test('Enter inside empty li at the end of ol with forced_root_block: false', function() {
editor.settings.forced_root_block = false;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li></ol>': '<ol><li>a</li><li><br></li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li></ol>' : '<ol><li>a</li><li><br></li></ol>';
Utils.setSelection('li:last', 0);
Utils.pressEnter();
equal(Utils.cleanHtml(editor.getBody().innerHTML), '<ol><li>a</li></ol><br>');
@ -322,10 +322,10 @@ test('Enter inside empty li at the end of ol with forced_root_block: false', fun
});
test('Enter inside empty li in the middle of ol', function() {
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li><li>b</li></ol>': '<ol><li>a</li><li><br></li><li>b</li></ol>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li>a</li><li></li><li>b</li></ol>' : '<ol><li>a</li><li><br></li><li>b</li></ol>';
Utils.setSelection('li:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<ol><li>a</li></ol><p>\u00a0</p><ol><li>b</li></ol>');
equal(editor.getContent(), '<ol><li>a</li></ol><p>\u00a0</p><ol><li>b</li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -557,7 +557,7 @@ test('Enter at beginning of first DT inside DL', function() {
editor.getBody().innerHTML = '<dl><dt>a</dt></dl>';
Utils.setSelection('dt', 0);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dt>\u00a0</dt><dt>a</dt></dl>');
equal(editor.getContent(), '<dl><dt>\u00a0</dt><dt>a</dt></dl>');
equal(editor.selection.getNode().nodeName, 'DT');
});
@ -565,7 +565,7 @@ test('Enter at beginning of first DD inside DL', function() {
editor.getBody().innerHTML = '<dl><dd>a</dd></dl>';
Utils.setSelection('dd', 0);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dd>\u00a0</dd><dd>a</dd></dl>');
equal(editor.getContent(), '<dl><dd>\u00a0</dd><dd>a</dd></dl>');
equal(editor.selection.getNode().nodeName, 'DD');
});
@ -573,7 +573,7 @@ test('Enter at beginning of middle DT inside DL', function() {
editor.getBody().innerHTML = '<dl><dt>a</dt><dt>b</dt><dt>c</dt></dl>';
Utils.setSelection('dt:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dt>a</dt><dt>\u00a0</dt><dt>b</dt><dt>c</dt></dl>');
equal(editor.getContent(), '<dl><dt>a</dt><dt>\u00a0</dt><dt>b</dt><dt>c</dt></dl>');
equal(editor.selection.getNode().nodeName, 'DT');
});
@ -581,7 +581,7 @@ test('Enter at beginning of middle DD inside DL', function() {
editor.getBody().innerHTML = '<dl><dd>a</dd><dd>b</dd><dd>c</dd></dl>';
Utils.setSelection('dd:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dd>a</dd><dd>\u00a0</dd><dd>b</dd><dd>c</dd></dl>');
equal(editor.getContent(), '<dl><dd>a</dd><dd>\u00a0</dd><dd>b</dd><dd>c</dd></dl>');
equal(editor.selection.getNode().nodeName, 'DD');
});
@ -589,7 +589,7 @@ test('Enter at end of last DT inside DL', function() {
editor.getBody().innerHTML = '<dl><dt>a</dt></dl>';
Utils.setSelection('dt', 1);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dt>a</dt><dt>\u00a0</dt></dl>');
equal(editor.getContent(), '<dl><dt>a</dt><dt>\u00a0</dt></dl>');
equal(editor.selection.getNode().nodeName, 'DT');
});
@ -597,7 +597,7 @@ test('Enter at end of last DD inside DL', function() {
editor.getBody().innerHTML = '<dl><dd>a</dd></dl>';
Utils.setSelection('dd', 1);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dd>a</dd><dd>\u00a0</dd></dl>');
equal(editor.getContent(), '<dl><dd>a</dd><dd>\u00a0</dd></dl>');
equal(editor.selection.getNode().nodeName, 'DD');
});
@ -605,7 +605,7 @@ test('Enter at end of last empty DT inside DL', function() {
editor.getBody().innerHTML = '<dl><dt>a</dt><dt></dt></dl>';
Utils.setSelection('dt:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dt>a</dt></dl><p>\u00a0</p>');
equal(editor.getContent(), '<dl><dt>a</dt></dl><p>\u00a0</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -613,7 +613,7 @@ test('Enter at end of last empty DD inside DL', function() {
editor.getBody().innerHTML = '<dl><dd>a</dd><dd></dd></dl>';
Utils.setSelection('dd:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<dl><dd>a</dd></dl><p>\u00a0</p>');
equal(editor.getContent(), '<dl><dd>a</dd></dl><p>\u00a0</p>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -621,7 +621,7 @@ test('Enter at beginning of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 0);
Utils.pressEnter();
equal(editor.getContent(),'<ol><li></li><li><p>abcd</p></li></ol>');
equal(editor.getContent(), '<ol><li></li><li><p>abcd</p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -629,7 +629,7 @@ test('Enter inside middle of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 2);
Utils.pressEnter();
equal(editor.getContent(),'<ol><li><p>ab</p></li><li><p>cd</p></li></ol>');
equal(editor.getContent(), '<ol><li><p>ab</p></li><li><p>cd</p></li></ol>');
// Ignore on IE 7, 8 this is a known bug not worth fixing
if (!tinymce.Env.ie || tinymce.Env.ie > 8) {
@ -641,7 +641,7 @@ test('Enter at end of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 4);
Utils.pressEnter();
equal(editor.getContent(),'<ol><li><p>abcd</p></li><li></li></ol>');
equal(editor.getContent(), '<ol><li><p>abcd</p></li><li></li></ol>');
equal(editor.selection.getNode().nodeName, 'LI');
});
@ -650,7 +650,7 @@ test('Shift+Enter at beginning of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<ol><li><p><br />abcd</p></li></ol>');
equal(editor.getContent(), '<ol><li><p><br />abcd</p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -658,7 +658,7 @@ test('Shift+Enter inside middle of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 2);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<ol><li><p>ab<br />cd</p></li></ol>');
equal(editor.getContent(), '<ol><li><p>ab<br />cd</p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -666,7 +666,7 @@ test('Shift+Enter at end of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 4);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),(tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li><p>abcd</p></li></ol>': '<ol><li><p>abcd<br /><br /></p></li></ol>');
equal(editor.getContent(), (tinymce.isIE && tinymce.Env.ie < 11) ? '<ol><li><p>abcd</p></li></ol>' : '<ol><li><p>abcd<br /><br /></p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -675,7 +675,7 @@ test('Ctrl+Enter at beginning of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 0);
Utils.pressEnter({ctrlKey: true});
equal(editor.getContent(),'<ol><li><p>\u00a0</p><p>abcd</p></li></ol>');
equal(editor.getContent(), '<ol><li><p>\u00a0</p><p>abcd</p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -683,7 +683,7 @@ test('Ctrl+Enter inside middle of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 2);
Utils.pressEnter({ctrlKey: true});
equal(editor.getContent(),'<ol><li><p>ab</p><p>cd</p></li></ol>');
equal(editor.getContent(), '<ol><li><p>ab</p><p>cd</p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -691,7 +691,7 @@ test('Ctrl+Enter at end of P inside LI', function() {
editor.getBody().innerHTML = '<ol><li><p>abcd</p></li></ol>';
Utils.setSelection('p', 4);
Utils.pressEnter({ctrlKey: true});
equal(editor.getContent(),'<ol><li><p>abcd</p><p>\u00a0</p></li></ol>');
equal(editor.getContent(), '<ol><li><p>abcd</p><p>\u00a0</p></li></ol>');
equal(editor.selection.getNode().nodeName, 'P');
});
@ -701,7 +701,7 @@ test('Enter in the middle of text in P with forced_root_block set to false', fun
editor.getBody().innerHTML = '<p>abc</p>';
Utils.setSelection('p', 2);
Utils.pressEnter();
equal(editor.getContent(),'<p>ab<br />c</p>');
equal(editor.getContent(), '<p>ab<br />c</p>');
});
test('Enter at the end of text in P with forced_root_block set to false', function() {
@ -709,7 +709,7 @@ test('Enter at the end of text in P with forced_root_block set to false', functi
editor.getBody().innerHTML = '<p>abc</p>';
Utils.setSelection('p', 3);
Utils.pressEnter();
equal(Utils.cleanHtml(editor.getBody().innerHTML), (tinymce.isIE && tinymce.Env.ie < 11) ? '<p>abc<br></p>': '<p>abc<br><br></p>');
equal(Utils.cleanHtml(editor.getBody().innerHTML), (tinymce.isIE && tinymce.Env.ie < 11) ? '<p>abc<br></p>' : '<p>abc<br><br></p>');
});
test('Enter at the middle of text in BODY with forced_root_block set to false', function() {
@ -736,31 +736,31 @@ test('Enter at the end of text in BODY with forced_root_block set to false', fun
Utils.setSelection('body', 4);
editor.focus();
Utils.pressEnter();
equal(Utils.cleanHtml(editor.getBody().innerHTML), (tinymce.isIE && tinymce.Env.ie < 11) ? 'abcd<br>': 'abcd<br><br>');
equal(Utils.cleanHtml(editor.getBody().innerHTML), (tinymce.isIE && tinymce.Env.ie < 11) ? 'abcd<br>' : 'abcd<br><br>');
});
test('Enter in empty P at the end of a blockquote and end_container_on_empty_block: true', function() {
editor.settings.end_container_on_empty_block = true;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<blockquote><p>abc</p><p></p></blockquote>': '<blockquote><p>abc</p><p><br></p></blockquote>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<blockquote><p>abc</p><p></p></blockquote>' : '<blockquote><p>abc</p><p><br></p></blockquote>';
Utils.setSelection('p:last', 0);
Utils.pressEnter();
equal(editor.getContent(),'<blockquote><p>abc</p></blockquote><p>\u00a0</p>');
equal(editor.getContent(), '<blockquote><p>abc</p></blockquote><p>\u00a0</p>');
});
test('Enter in empty P at the beginning of a blockquote and end_container_on_empty_block: true', function() {
editor.settings.end_container_on_empty_block = true;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<blockquote><p></p><p>abc</p></blockquote>': '<blockquote><p><br></p><p>abc</p></blockquote>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<blockquote><p></p><p>abc</p></blockquote>' : '<blockquote><p><br></p><p>abc</p></blockquote>';
Utils.setSelection('p', 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><blockquote><p>abc</p></blockquote>');
equal(editor.getContent(), '<p>\u00a0</p><blockquote><p>abc</p></blockquote>');
});
test('Enter in empty P at in the middle of a blockquote and end_container_on_empty_block: true', function() {
editor.settings.end_container_on_empty_block = true;
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<blockquote><p>abc</p><p></p><p>123</p></blockquote>': '<blockquote><p>abc</p><p><br></p><p>123</p></blockquote>';
editor.getBody().innerHTML = (tinymce.isIE && tinymce.Env.ie < 11) ? '<blockquote><p>abc</p><p></p><p>123</p></blockquote>' : '<blockquote><p>abc</p><p><br></p><p>123</p></blockquote>';
Utils.setSelection('p:nth-child(2)', 0);
Utils.pressEnter();
equal(editor.getContent(),'<blockquote><p>abc</p></blockquote><p>\u00a0</p><blockquote><p>123</p></blockquote>');
equal(editor.getContent(), '<blockquote><p>abc</p></blockquote><p>\u00a0</p><blockquote><p>123</p></blockquote>');
});
test('Enter inside empty P with empty P siblings', function() {
@ -768,7 +768,7 @@ test('Enter inside empty P with empty P siblings', function() {
editor.getBody().innerHTML = '<p></p><p></p><p>X</p>';
Utils.setSelection('p', 0);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><p>\u00a0</p><p>\u00a0</p><p>X</p>');
equal(editor.getContent(), '<p>\u00a0</p><p>\u00a0</p><p>\u00a0</p><p>X</p>');
});
test('Enter at end of H1 with forced_root_block_attrs', function() {
@ -776,63 +776,63 @@ test('Enter at end of H1 with forced_root_block_attrs', function() {
editor.getBody().innerHTML = '<h1>a</h1>';
Utils.setSelection('h1', 1);
Utils.pressEnter();
equal(editor.getContent(),'<h1>a</h1><p class="class1">\u00a0</p>');
equal(editor.getContent(), '<h1>a</h1><p class="class1">\u00a0</p>');
});
test('Shift+Enter at beginning of P', function() {
editor.getBody().innerHTML = '<p>abc</p>';
Utils.setSelection('p', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p><br />abc</p>');
equal(editor.getContent(), '<p><br />abc</p>');
});
test('Shift+Enter in the middle of P', function() {
editor.getBody().innerHTML = '<p>abcd</p>';
Utils.setSelection('p', 2);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p>ab<br />cd</p>');
equal(editor.getContent(), '<p>ab<br />cd</p>');
});
test('Shift+Enter at the end of P', function() {
editor.getBody().innerHTML = '<p>abcd</p>';
Utils.setSelection('p', 4);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),(tinymce.isIE && tinymce.Env.ie < 11) ? '<p>abcd</p>': '<p>abcd<br /><br /></p>');
equal(editor.getContent(), (tinymce.isIE && tinymce.Env.ie < 11) ? '<p>abcd</p>' : '<p>abcd<br /><br /></p>');
});
test('Shift+Enter in the middle of B with a BR after it', function() {
editor.getBody().innerHTML = '<p><b>abcd</b><br></p>';
Utils.setSelection('b', 2);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p><b>ab<br />cd</b></p>');
equal(editor.getContent(), '<p><b>ab<br />cd</b></p>');
});
test('Shift+Enter at the end of B with a BR after it', function() {
editor.getBody().innerHTML = '<p><b>abcd</b><br></p>';
Utils.setSelection('b', 4);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p><b>abcd<br /></b></p>');
equal(editor.getContent(), '<p><b>abcd<br /></b></p>');
});
test('Enter in beginning of PRE', function() {
editor.getBody().innerHTML = '<pre>abc</pre>';
Utils.setSelection('pre', 0);
Utils.pressEnter();
equal(editor.getContent(),'<pre><br />abc</pre>');
equal(editor.getContent(), '<pre><br />abc</pre>');
});
test('Enter in the middle of PRE', function() {
editor.getBody().innerHTML = '<pre>abcd</pre>';
Utils.setSelection('pre', 2);
Utils.pressEnter();
equal(editor.getContent(),'<pre>ab<br />cd</pre>');
equal(editor.getContent(), '<pre>ab<br />cd</pre>');
});
test('Enter at the end of PRE', function() {
editor.getBody().innerHTML = '<pre>abcd</pre>';
Utils.setSelection('pre', 4);
Utils.pressEnter();
equal(editor.getContent(),(tinymce.isIE && tinymce.Env.ie < 11) ? '<pre>abcd</pre>': '<pre>abcd<br /><br /></pre>');
equal(editor.getContent(), (tinymce.isIE && tinymce.Env.ie < 11) ? '<pre>abcd</pre>' : '<pre>abcd<br /><br /></pre>');
});
test('Enter in beginning of PRE and br_in_pre: false', function() {
@ -840,7 +840,7 @@ test('Enter in beginning of PRE and br_in_pre: false', function() {
editor.getBody().innerHTML = '<pre>abc</pre>';
Utils.setSelection('pre', 0);
Utils.pressEnter();
equal(editor.getContent(),'<pre>\u00a0</pre><pre>abc</pre>');
equal(editor.getContent(), '<pre>\u00a0</pre><pre>abc</pre>');
});
test('Enter in the middle of PRE and br_in_pre: false', function() {
@ -848,7 +848,7 @@ test('Enter in the middle of PRE and br_in_pre: false', function() {
editor.getBody().innerHTML = '<pre>abcd</pre>';
Utils.setSelection('pre', 2);
Utils.pressEnter();
equal(editor.getContent(),'<pre>ab</pre><pre>cd</pre>');
equal(editor.getContent(), '<pre>ab</pre><pre>cd</pre>');
});
test('Enter at the end of PRE and br_in_pre: false', function() {
@ -856,28 +856,28 @@ test('Enter at the end of PRE and br_in_pre: false', function() {
editor.getBody().innerHTML = '<pre>abcd</pre>';
Utils.setSelection('pre', 4);
Utils.pressEnter();
equal(editor.getContent(),'<pre>abcd</pre><p>\u00a0</p>');
equal(editor.getContent(), '<pre>abcd</pre><p>\u00a0</p>');
});
test('Shift+Enter in beginning of PRE', function() {
editor.getBody().innerHTML = '<pre>abc</pre>';
Utils.setSelection('pre', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<pre>\u00a0</pre><pre>abc</pre>');
equal(editor.getContent(), '<pre>\u00a0</pre><pre>abc</pre>');
});
test('Shift+Enter in the middle of PRE', function() {
editor.getBody().innerHTML = '<pre>abcd</pre>';
Utils.setSelection('pre', 2);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<pre>ab</pre><pre>cd</pre>');
equal(editor.getContent(), '<pre>ab</pre><pre>cd</pre>');
});
test('Shift+Enter at the end of PRE', function() {
editor.getBody().innerHTML = '<pre>abcd</pre>';
Utils.setSelection('pre', 4);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<pre>abcd</pre><p>\u00a0</p>');
equal(editor.getContent(), '<pre>abcd</pre><p>\u00a0</p>');
});
test('Shift+Enter in beginning of P with forced_root_block set to false', function() {
@ -885,7 +885,7 @@ test('Shift+Enter in beginning of P with forced_root_block set to false', functi
editor.getBody().innerHTML = '<p>abc</p>';
Utils.setSelection('p', 0);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p>\u00a0</p><p>abc</p>');
equal(editor.getContent(), '<p>\u00a0</p><p>abc</p>');
});
test('Shift+Enter in middle of P with forced_root_block set to false', function() {
@ -893,7 +893,7 @@ test('Shift+Enter in middle of P with forced_root_block set to false', function(
editor.getBody().innerHTML = '<p>abcd</p>';
Utils.setSelection('p', 2);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p>ab</p><p>cd</p>');
equal(editor.getContent(), '<p>ab</p><p>cd</p>');
});
test('Shift+Enter at the end of P with forced_root_block set to false', function() {
@ -901,7 +901,7 @@ test('Shift+Enter at the end of P with forced_root_block set to false', function
editor.getBody().innerHTML = '<p>abc</p>';
Utils.setSelection('p', 3);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p>abc</p><p>\u00a0</p>');
equal(editor.getContent(), '<p>abc</p><p>\u00a0</p>');
});
test('Shift+Enter in body with forced_root_block set to false', function() {
@ -912,7 +912,7 @@ test('Shift+Enter in body with forced_root_block set to false', function() {
rng.setEnd(editor.getBody().firstChild, 2);
editor.selection.setRng(rng);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<p>ab</p><p>cd</p>');
equal(editor.getContent(), '<p>ab</p><p>cd</p>');
});
test('Enter at the end of DIV layer', function() {
@ -920,7 +920,7 @@ test('Enter at the end of DIV layer', function() {
editor.setContent('<div style="position: absolute; top: 1px; left: 2px;">abcd</div>');
Utils.setSelection('div', 4);
Utils.pressEnter();
equal(editor.getContent(),'<div style="position: absolute; top: 1px; left: 2px;"><p>abcd</p><p>\u00a0</p></div>');
equal(editor.getContent(), '<div style="position: absolute; top: 1px; left: 2px;"><p>abcd</p><p>\u00a0</p></div>');
});
test('Enter in div inside contentEditable:false div', function() {
@ -971,7 +971,7 @@ test('Enter at end of text in a span inside a P and keep_styles: false', functio
editor.getBody().innerHTML = '<p><em><span style="font-size: 13px;">X</span></em></p>';
Utils.setSelection('span', 1);
Utils.pressEnter();
equal(editor.getContent(),'<p><em><span style="font-size: 13px;">X</span></em></p><p>\u00a0</p>');
equal(editor.getContent(), '<p><em><span style="font-size: 13px;">X</span></em></p><p>\u00a0</p>');
});
test('Shift+enter in LI when forced_root_block: false', function() {
@ -979,7 +979,7 @@ test('Shift+enter in LI when forced_root_block: false', function() {
editor.getBody().innerHTML = '<ul><li>text</li></ul>';
Utils.setSelection('li', 2);
Utils.pressEnter({shiftKey: true});
equal(editor.getContent(),'<ul><li>te<br />xt</li></ul>');
equal(editor.getContent(), '<ul><li>te<br />xt</li></ul>');
});
test('Enter when forced_root_block: false and force_p_newlines: true', function() {
@ -988,7 +988,7 @@ test('Enter when forced_root_block: false and force_p_newlines: true', function(
editor.getBody().innerHTML = 'text';
Utils.setSelection('body', 2);
Utils.pressEnter();
equal(editor.getContent(),'<p>te</p><p>xt</p>');
equal(editor.getContent(), '<p>te</p><p>xt</p>');
});
test('Enter at end of br line', function() {
@ -1013,7 +1013,7 @@ if (!tinymce.Env.ie || tinymce.Env.ie > 8) {
rng.setEndBefore(editor.dom.select('br')[0]);
editor.selection.setRng(rng);
Utils.pressEnter();
equal(editor.getContent(),'<div>a<span>b</span>c</div><p>\u00a0</p><p>\u00a0</p><div>d</div>');
equal(editor.getContent(), '<div>a<span>b</span>c</div><p>\u00a0</p><p>\u00a0</p><div>d</div>');
});
}
@ -1028,7 +1028,7 @@ if (window.getSelection) {
editor.selection.setRng(rng);
Utils.pressEnter();
equal(editor.getContent(),'<table><tbody><tr><td>x</td></tr></tbody></table><p>\u00a0</p>');
equal(editor.getContent(), '<table><tbody><tr><td>x</td></tr></tbody></table><p>\u00a0</p>');
});
test('Enter before table element', function() {
@ -1040,7 +1040,7 @@ if (window.getSelection) {
editor.selection.setRng(rng);
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
equal(editor.getContent(), '<p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
});
test('Enter behind table followed by a p', function() {
@ -1052,7 +1052,7 @@ if (window.getSelection) {
editor.selection.setRng(rng);
Utils.pressEnter();
equal(editor.getContent(),'<table><tbody><tr><td>x</td></tr></tbody></table><p>\u00a0</p><p>x</p>');
equal(editor.getContent(), '<table><tbody><tr><td>x</td></tr></tbody></table><p>\u00a0</p><p>x</p>');
});
test('Enter before table element preceded by a p', function() {
@ -1064,7 +1064,7 @@ if (window.getSelection) {
editor.selection.setRng(rng);
Utils.pressEnter();
equal(editor.getContent(),'<p>x</p><p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
equal(editor.getContent(), '<p>x</p><p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
});
test('Enter twice before table element', function(){
@ -1077,6 +1077,17 @@ if (window.getSelection) {
Utils.pressEnter();
Utils.pressEnter();
equal(editor.getContent(),'<p>\u00a0</p><p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
equal(editor.getContent(), '<p>\u00a0</p><p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
});
test('Enter after span with space', function() {
editor.setContent('<p><b>abc </b></p>');
Utils.setSelection('b', 3);
Utils.pressEnter();
equal(editor.getContent(), '<p><b>abc</b></p><p>\u00a0</p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'B');
notEqual(rng.startContainer.data, ' ');
});
}

View File

@ -0,0 +1,51 @@
ModuleLoader.require(["tinymce/data/ObservableObject"], function(ObservableObject) {
module("tinymce.data.ObservableObject");
test("Constructor", function(assert) {
var obj;
obj = new ObservableObject();
assert.ok(!obj.has('a'));
obj = new ObservableObject({a: 1, b: 2});
assert.strictEqual(obj.get('a'), 1);
assert.strictEqual(obj.get('b'), 2);
});
test("set/get and observe all", function(assert) {
var obj = new ObservableObject(), events = [];
obj.on('change', function(e) {
events.push(e);
});
obj.set('a', 'a');
obj.set('a', 'a2');
obj.set('a', 'a3');
obj.set('b', 'b');
assert.strictEqual(obj.get('a'), 'a3');
equal(events[0].type, 'change');
equal(events[0].value, 'a');
equal(events[1].type, 'change');
equal(events[1].value, 'a2');
equal(events[2].type, 'change');
equal(events[2].value, 'a3');
equal(events[3].type, 'change');
equal(events[3].value, 'b');
});
test("set/get and observe specific", function(assert) {
var obj = new ObservableObject(), events = [];
obj.on('change:a', function(e) {
events.push(e);
});
obj.set('a', 'a');
obj.set('b', 'b');
equal(events[0].type, 'change');
equal(events[0].value, 'a');
equal(events.length, 1);
});
});

View File

@ -1,4 +1,4 @@
(function(Conversions) {
ModuleLoader.require(["tinymce/file/Conversions"], function(Conversions) {
module("tinymce.file.Conversions");
if (!tinymce.Env.fileApi) {
@ -14,4 +14,4 @@
QUnit.equal(dataUri, "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==");
}).then(QUnit.start);
});
})(tinymce.file.Conversions);
});

View File

@ -0,0 +1,31 @@
ModuleLoader.require([
"tinymce/file/ImageScanner",
"tinymce/file/BlobCache",
"tinymce/Env"
], function(ImageScanner, BlobCache, Env) {
if (!tinymce.Env.fileApi) {
return;
}
module("tinymce.file.ImageScanner");
var base64Src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==';
QUnit.asyncTest("findAll", function() {
var imageScanner = new ImageScanner(new BlobCache());
document.getElementById('view').innerHTML = (
'<img src="' + base64Src + '">' +
'<img src="' + Env.transparentSrc + '">' +
'<img src="' + base64Src + '" data-mce-bogus="1">' +
'<img src="' + base64Src + '" data-mce-placeholder="1">'
);
imageScanner.findAll(document.getElementById('view')).then(function(result) {
QUnit.start();
equal(result.length, 1);
equal('data:image/gif;base64,' + result[0].blobInfo.base64(), base64Src);
strictEqual(result[0].image, document.getElementById('view').firstChild);
});
});
});

View File

@ -168,7 +168,8 @@ test('getBoolAttrs', function() {
"DECLARE": {}, "COMPACT": {}, "CHECKED": {},
"controls": {}, "loop": {}, "autoplay": {}, "selected": {}, "readonly": {}, "nowrap": {},
"noshade": {}, "noresize": {}, "nohref": {}, "multiple": {}, "ismap": {}, "disabled": {}, "defer": {},
"declare": {}, "compact": {}, "checked": {}
"declare": {}, "compact": {}, "checked": {},
"allowfullscreen": {}, "mozallowfullscreen": {}, "webkitallowfullscreen": {} // WP
});
});