git-svn-id: https://develop.svn.wordpress.org/trunk@30675 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-11-30 23:27:23 +00:00
parent 0632a3de68
commit 45f4403dd0
13 changed files with 145 additions and 31 deletions

View File

@ -228,6 +228,15 @@ tinymce.PluginManager.add('image', function(editor) {
}); });
if (!meta.width && !meta.height) { if (!meta.width && !meta.height) {
var srcURL = this.value(),
absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i'),
baseURL = editor.settings.document_base_url;
//Pattern test the src url and make sure we haven't already prepended the url
if (baseURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, baseURL.length) !== baseURL) {
this.value(baseURL + srcURL);
}
getImageSize(this.value(), function(data) { getImageSize(this.value(), function(data) {
if (data.width && data.height && imageDimensions) { if (data.width && data.height && imageDimensions) {
width = data.width; width = data.width;

File diff suppressed because one or more lines are too long

View File

@ -1331,7 +1331,9 @@ define("tinymce/pasteplugin/WordFilter", [
var rootNode = domParser.parse(content); var rootNode = domParser.parse(content);
// Process DOM // Process DOM
convertFakeListsToProperLists(rootNode); if (settings.paste_convert_word_fake_lists !== false) {
convertFakeListsToProperLists(rootNode);
}
// Serialize DOM back to HTML // Serialize DOM back to HTML
e.content = new Serializer({}, schema).serialize(rootNode); e.content = new Serializer({}, schema).serialize(rootNode);

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
// 4.1.6 (2014-11-19) // 4.1.7 (2014-11-27)
/** /**
* Compiled inline version. (Library mode) * Compiled inline version. (Library mode)
@ -2996,18 +2996,18 @@ define("tinymce/util/Tools", [
* one array list into another. * one array list into another.
* *
* @method map * @method map
* @param {Array} a Array of items to iterate. * @param {Array} array Array of items to iterate.
* @param {function} f Function to call for each item. It's return value will be the new value. * @param {function} callback Function to call for each item. It's return value will be the new value.
* @return {Array} Array with new values based on function return values. * @return {Array} Array with new values based on function return values.
*/ */
function map(a, f) { function map(array, callback) {
var o = []; var out = [];
each(a, function(v) { each(array, function(item) {
o.push(f(v)); out.push(callback(item));
}); });
return o; return out;
} }
/** /**
@ -13700,7 +13700,7 @@ define("tinymce/util/VK", [
UP: 38, UP: 38,
modifierPressed: function(e) { modifierPressed: function(e) {
return e.shiftKey || e.ctrlKey || e.altKey; return e.shiftKey || e.ctrlKey || e.altKey || this.metaKeyPressed(e);
}, },
metaKeyPressed: function(e) { metaKeyPressed: function(e) {
@ -18298,10 +18298,11 @@ define("tinymce/Formatter", [
* @class tinymce.UndoManager * @class tinymce.UndoManager
*/ */
define("tinymce/UndoManager", [ define("tinymce/UndoManager", [
"tinymce/util/VK",
"tinymce/Env", "tinymce/Env",
"tinymce/util/Tools", "tinymce/util/Tools",
"tinymce/html/SaxParser" "tinymce/html/SaxParser"
], function(Env, Tools, SaxParser) { ], function(VK, Env, Tools, SaxParser) {
var trim = Tools.trim, trimContentRegExp; var trim = Tools.trim, trimContentRegExp;
trimContentRegExp = new RegExp([ trimContentRegExp = new RegExp([
@ -18426,7 +18427,8 @@ define("tinymce/UndoManager", [
} }
// If key isn't shift,ctrl,alt,capslock,metakey // If key isn't shift,ctrl,alt,capslock,metakey
if ((keyCode < 16 || keyCode > 20) && keyCode != 224 && keyCode != 91 && !self.typing) { var modKey = VK.modifierPressed(e);
if ((keyCode < 16 || keyCode > 20) && keyCode != 224 && keyCode != 91 && !self.typing && !modKey) {
self.beforeChange(); self.beforeChange();
self.typing = true; self.typing = true;
self.add({}, e); self.add({}, e);
@ -30750,7 +30752,7 @@ define("tinymce/EditorManager", [
* @property minorVersion * @property minorVersion
* @type String * @type String
*/ */
minorVersion: '1.6', minorVersion: '1.7',
/** /**
* Release date of TinyMCE build. * Release date of TinyMCE build.
@ -30758,7 +30760,7 @@ define("tinymce/EditorManager", [
* @property releaseDate * @property releaseDate
* @type String * @type String
*/ */
releaseDate: '2014-11-19', releaseDate: '2014-11-27',
/** /**
* Collection of editor instances. * Collection of editor instances.

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ $wp_db_version = 30133;
* *
* @global string $tinymce_version * @global string $tinymce_version
*/ */
$tinymce_version = '4106-20141119'; $tinymce_version = '4107-20141130';
/** /**
* Holds the required PHP version * Holds the required PHP version

View File

@ -360,6 +360,18 @@
} }
} }
function triggerElementChange(element){
var evt;
if ("createEvent" in document) {
evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
element.dispatchEvent(evt);
} else {
element.fireEvent("onchange");
}
}
window.Utils = { window.Utils = {
fontFace: fontFace, fontFace: fontFace,
findContainer: findContainer, findContainer: findContainer,
@ -379,6 +391,7 @@
pressEnter: pressEnter, pressEnter: pressEnter,
trimBrsOnIE: trimBrsOnIE, trimBrsOnIE: trimBrsOnIE,
patch: patch, patch: patch,
unpatch: unpatch unpatch: unpatch,
triggerElementChange: triggerElementChange
}; };
})(); })();

View File

@ -21,6 +21,7 @@
delete editor.settings.file_browser_callback; delete editor.settings.file_browser_callback;
delete editor.settings.image_list; delete editor.settings.image_list;
delete editor.settings.image_class_list; delete editor.settings.image_class_list;
delete editor.settings.document_base_url;
var win = Utils.getFontmostWindow(); var win = Utils.getFontmostWindow();
@ -125,4 +126,64 @@
'<p><img class="class1" src="src" alt="alt" width="100" height="200" /></p>' '<p><img class="class1" src="src" alt="alt" width="100" height="200" /></p>'
); );
}); });
test("Image recognizes relative src url and prepends relative document_base_url setting.", function () {
var win, elementId, element;
editor.settings.document_base_url = 'testing/images/';
editor.setContent('');
editor.execCommand('mceImage', true);
var data = {
"src": "src",
"alt": "alt"
};
win = Utils.getFontmostWindow();
elementId = win.find('#src')[0]._id;
element = document.getElementById(elementId).childNodes[0];
win.fromJSON(data);
Utils.triggerElementChange(element);
win.find('form')[0].submit();
win.close();
equal(
cleanHtml(editor.getContent()),
'<p><img src="' + editor.settings.document_base_url + 'src" alt="alt" /></p>'
);
});
test("Image recognizes relative src url and prepends absolute document_base_url setting.", function () {
var win, elementId, element;
editor.settings.document_base_url = 'http://testing.com/images/';
editor.setContent('');
editor.execCommand('mceImage', true);
var data = {
"src": "src",
"alt": "alt"
};
win = Utils.getFontmostWindow();
elementId = win.find('#src')[0]._id;
element = document.getElementById(elementId).childNodes[0];
win.fromJSON(data);
Utils.triggerElementChange(element);
win.find('form')[0].submit();
win.close();
equal(
cleanHtml(editor.getContent()),
'<p><img src="' + editor.settings.document_base_url + 'src" alt="alt" /></p>'
);
});
})(); })();

View File

@ -151,6 +151,20 @@ test("Paste list like paragraph and list", function() {
equal(editor.getContent(), '<p>ABC. X</p><ol><li>Y</li></ol>'); equal(editor.getContent(), '<p>ABC. X</p><ol><li>Y</li></ol>');
}); });
test("Paste list like paragraph and list (disabled)", function() {
editor.setContent('');
editor.settings.paste_convert_word_fake_lists = false;
editor.execCommand('mceInsertClipboardContent', false, {
content: '<p class=MsoNormal><span style=\'font-size:10.0pt;line-height:115%;font-family:"Trebuchet MS","sans-serif";color:#666666\'>ABC. X<o:p></o:p></span></p><p class=MsoListParagraph style=\'text-indent:-.25in;mso-list:l0 level1 lfo1\'><![if !supportLists]><span style=\'mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin\'><span style=\'mso-list:Ignore\'>1.<span style=\'font:7.0pt "Times New Roman"\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><![endif]>Y</p>'
});
delete editor.settings.paste_convert_word_fake_lists;
equal(editor.getContent(), '<p>ABC. X</p><p>1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Y</p>');
});
test("Paste Word table", function() { test("Paste Word table", function() {
var rng = editor.dom.createRng(); var rng = editor.dom.createRng();

View File

@ -90,13 +90,26 @@ test('Typing state', function() {
editor.undoManager.clear(); editor.undoManager.clear();
editor.setContent('test'); editor.setContent('test');
expect(2); expect(4);
ok(!editor.undoManager.typing);
editor.dom.fire(editor.getBody(), 'keydown', {keyCode: 65}); editor.dom.fire(editor.getBody(), 'keydown', {keyCode: 65});
ok(editor.undoManager.typing); ok(editor.undoManager.typing);
editor.dom.fire(editor.getBody(), 'keyup', {keyCode: 13}); editor.dom.fire(editor.getBody(), 'keyup', {keyCode: 13});
ok(!editor.undoManager.typing); ok(!editor.undoManager.typing);
selectAllFlags = {keyCode: 65, ctrlKey: false, altKey: false, shiftKey: false};
if (tinymce.Env.mac) {
selectAllFlags.metaKey = true;
} else {
selectAllFlags.ctrlKey = true;
}
editor.dom.fire(editor.getBody(), 'keydown', selectAllFlags);
ok(!editor.undoManager.typing);
}); });
test('Undo and add new level', function() { test('Undo and add new level', function() {