TinyMCE: update to 4.0.28+. Includes all changes until 09-06-2014: 32cb108d41
. Changelog: 32cb108d41/changelog.txt
.
See #28391. Built from https://develop.svn.wordpress.org/trunk@28768 git-svn-id: http://core.svn.wordpress.org/trunk@28581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f0a3d5cfa8
commit
46f17ee039
|
@ -40,14 +40,27 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
img.src = url;
|
img.src = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyPreview(items) {
|
function buildListItems(inputList, itemCallback, startItems) {
|
||||||
tinymce.each(items, function(item) {
|
function appendItems(values, output) {
|
||||||
item.textStyle = function() {
|
output = output || [];
|
||||||
return editor.formatter.getCssText({inline: 'img', classes: [item.value]});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return items;
|
tinymce.each(values, function(item) {
|
||||||
|
var menuItem = {text: item.text || item.title};
|
||||||
|
|
||||||
|
if (item.menu) {
|
||||||
|
menuItem.menu = appendItems(item.menu);
|
||||||
|
} else {
|
||||||
|
menuItem.value = item.value;
|
||||||
|
itemCallback(menuItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
output.push(menuItem);
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return appendItems(inputList, startItems || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createImageList(callback) {
|
function createImageList(callback) {
|
||||||
|
@ -71,53 +84,7 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
|
|
||||||
function showDialog(imageList) {
|
function showDialog(imageList) {
|
||||||
var win, data = {}, dom = editor.dom, imgElm = editor.selection.getNode();
|
var win, data = {}, dom = editor.dom, imgElm = editor.selection.getNode();
|
||||||
var width, height, imageListCtrl, classListCtrl;
|
var width, height, imageListCtrl, classListCtrl, imageDimensions = editor.settings.image_dimensions !== false;
|
||||||
|
|
||||||
function buildValues(listSettingName, dataItemName, defaultItems) {
|
|
||||||
var selectedItem, items = [];
|
|
||||||
|
|
||||||
tinymce.each(editor.settings[listSettingName] || defaultItems, function(target) {
|
|
||||||
var item = {
|
|
||||||
text: target.text || target.title,
|
|
||||||
value: target.value
|
|
||||||
};
|
|
||||||
|
|
||||||
items.push(item);
|
|
||||||
|
|
||||||
if (data[dataItemName] === target.value || (!selectedItem && target.selected)) {
|
|
||||||
selectedItem = item;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (selectedItem && !data[dataItemName]) {
|
|
||||||
data[dataItemName] = selectedItem.value;
|
|
||||||
selectedItem.selected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildImageList() {
|
|
||||||
function appendItems(values, output) {
|
|
||||||
output = output || [];
|
|
||||||
|
|
||||||
tinymce.each(values, function(value) {
|
|
||||||
var item = {text: value.text || value.title};
|
|
||||||
|
|
||||||
if (value.menu) {
|
|
||||||
item.menu = appendItems(value.menu);
|
|
||||||
} else {
|
|
||||||
item.value = editor.convertURL(value.value || value.url, 'src');
|
|
||||||
}
|
|
||||||
|
|
||||||
output.push(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
return appendItems(imageList, [{text: 'None', value: ''}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function recalcSize() {
|
function recalcSize() {
|
||||||
var widthCtrl, heightCtrl, newWidth, newHeight;
|
var widthCtrl, heightCtrl, newWidth, newHeight;
|
||||||
|
@ -125,6 +92,10 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
widthCtrl = win.find('#width')[0];
|
widthCtrl = win.find('#width')[0];
|
||||||
heightCtrl = win.find('#height')[0];
|
heightCtrl = win.find('#height')[0];
|
||||||
|
|
||||||
|
if (!widthCtrl || !heightCtrl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
newWidth = widthCtrl.value();
|
newWidth = widthCtrl.value();
|
||||||
newHeight = heightCtrl.value();
|
newHeight = heightCtrl.value();
|
||||||
|
|
||||||
|
@ -146,12 +117,15 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
function waitLoad(imgElm) {
|
function waitLoad(imgElm) {
|
||||||
function selectImage() {
|
function selectImage() {
|
||||||
imgElm.onload = imgElm.onerror = null;
|
imgElm.onload = imgElm.onerror = null;
|
||||||
editor.selection.select(imgElm);
|
|
||||||
editor.nodeChanged();
|
if (editor.selection) {
|
||||||
|
editor.selection.select(imgElm);
|
||||||
|
editor.nodeChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imgElm.onload = function() {
|
imgElm.onload = function() {
|
||||||
if (!data.width && !data.height) {
|
if (!data.width && !data.height && imageDimensions) {
|
||||||
dom.setAttribs(imgElm, {
|
dom.setAttribs(imgElm, {
|
||||||
width: imgElm.clientWidth,
|
width: imgElm.clientWidth,
|
||||||
height: imgElm.clientHeight
|
height: imgElm.clientHeight
|
||||||
|
@ -188,6 +162,7 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
data.style = null;
|
data.style = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup new data excluding style properties
|
||||||
data = {
|
data = {
|
||||||
src: data.src,
|
src: data.src,
|
||||||
alt: data.alt,
|
alt: data.alt,
|
||||||
|
@ -197,10 +172,6 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
"class": data["class"]
|
"class": data["class"]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!data["class"]) {
|
|
||||||
delete data["class"];
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.undoManager.transact(function() {
|
editor.undoManager.transact(function() {
|
||||||
// WP
|
// WP
|
||||||
var eventData = { node: imgElm, data: data, caption: caption };
|
var eventData = { node: imgElm, data: data, caption: caption };
|
||||||
|
@ -251,7 +222,7 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getImageSize(this.value(), function(data) {
|
getImageSize(this.value(), function(data) {
|
||||||
if (data.width && data.height) {
|
if (data.width && data.height && imageDimensions) {
|
||||||
width = data.width;
|
width = data.width;
|
||||||
height = data.height;
|
height = data.height;
|
||||||
|
|
||||||
|
@ -283,7 +254,13 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
imageListCtrl = {
|
imageListCtrl = {
|
||||||
type: 'listbox',
|
type: 'listbox',
|
||||||
label: 'Image list',
|
label: 'Image list',
|
||||||
values: buildImageList(),
|
values: buildListItems(
|
||||||
|
imageList,
|
||||||
|
function(item) {
|
||||||
|
item.value = editor.convertURL(item.value || item.url, 'src');
|
||||||
|
},
|
||||||
|
[{text: 'None', value: ''}]
|
||||||
|
),
|
||||||
value: data.src && editor.convertURL(data.src, 'src'),
|
value: data.src && editor.convertURL(data.src, 'src'),
|
||||||
onselect: function(e) {
|
onselect: function(e) {
|
||||||
var altCtrl = win.find('#alt');
|
var altCtrl = win.find('#alt');
|
||||||
|
@ -305,7 +282,16 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
name: 'class',
|
name: 'class',
|
||||||
type: 'listbox',
|
type: 'listbox',
|
||||||
label: 'Class',
|
label: 'Class',
|
||||||
values: applyPreview(buildValues('image_class_list', 'class'))
|
values: buildListItems(
|
||||||
|
editor.settings.image_class_list,
|
||||||
|
function(item) {
|
||||||
|
if (item.value) {
|
||||||
|
item.textStyle = function() {
|
||||||
|
return editor.formatter.getCssText({inline: 'img', classes: [item.value]});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +305,7 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
generalFormItems.push({name: 'alt', type: 'textbox', label: 'Image description'});
|
generalFormItems.push({name: 'alt', type: 'textbox', label: 'Image description'});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor.settings.image_dimensions !== false) {
|
if (imageDimensions) {
|
||||||
generalFormItems.push({
|
generalFormItems.push({
|
||||||
type: 'container',
|
type: 'container',
|
||||||
label: 'Dimensions',
|
label: 'Dimensions',
|
||||||
|
@ -430,11 +416,6 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WP
|
|
||||||
editor.addCommand( 'mceImage', function() {
|
|
||||||
createImageList( showDialog )();
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.addButton('image', {
|
editor.addButton('image', {
|
||||||
icon: 'image',
|
icon: 'image',
|
||||||
tooltip: 'Insert/edit image',
|
tooltip: 'Insert/edit image',
|
||||||
|
@ -449,4 +430,6 @@ tinymce.PluginManager.add('image', function(editor) {
|
||||||
context: 'insert',
|
context: 'insert',
|
||||||
prependToContext: true
|
prependToContext: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.addCommand('mceImage', createImageList(showDialog));
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -162,7 +162,23 @@ tinymce.PluginManager.add('media', function(editor, url) {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
onSubmit: function() {
|
onSubmit: function() {
|
||||||
|
var beforeObjects, afterObjects, i, y;
|
||||||
|
|
||||||
|
beforeObjects = editor.dom.select('img[data-mce-object]');
|
||||||
editor.insertContent(dataToHtml(this.toJSON()));
|
editor.insertContent(dataToHtml(this.toJSON()));
|
||||||
|
afterObjects = editor.dom.select('img[data-mce-object]');
|
||||||
|
|
||||||
|
// Find new image placeholder so we can select it
|
||||||
|
for (i = 0; i < beforeObjects.length; i++) {
|
||||||
|
for (y = afterObjects.length - 1; y >= 0; y--) {
|
||||||
|
if (beforeObjects[i] == afterObjects[y]) {
|
||||||
|
afterObjects.splice(y, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.selection.select(afterObjects[0]);
|
||||||
|
editor.nodeChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -223,7 +239,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
|
||||||
|
|
||||||
if (data.embed) {
|
if (data.embed) {
|
||||||
html = updateHtml(data.embed, data, true);
|
html = updateHtml(data.embed, data, true);
|
||||||
} else {
|
} else {
|
||||||
var videoScript = getVideoScriptMatch(data.source1);
|
var videoScript = getVideoScriptMatch(data.source1);
|
||||||
if (videoScript) {
|
if (videoScript) {
|
||||||
data.type = 'script';
|
data.type = 'script';
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -361,7 +361,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
pasteBinElm = dom.add(editor.getBody(), 'div', {
|
pasteBinElm = dom.add(editor.getBody(), 'div', {
|
||||||
id: "mcepastebin",
|
id: "mcepastebin",
|
||||||
contentEditable: true,
|
contentEditable: true,
|
||||||
"data-mce-bogus": "1",
|
"data-mce-bogus": "all",
|
||||||
style: 'position: absolute; top: ' + top + 'px;' +
|
style: 'position: absolute; top: ' + top + 'px;' +
|
||||||
'width: 10px; height: 10px; overflow: hidden; opacity: 0'
|
'width: 10px; height: 10px; overflow: hidden; opacity: 0'
|
||||||
}, pasteBinDefaultContent);
|
}, pasteBinDefaultContent);
|
||||||
|
@ -471,42 +471,44 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
* Checks if the clipboard contains image data if it does it will take that data
|
* Checks if the clipboard contains image data if it does it will take that data
|
||||||
* and convert it into a data url image and paste that image at the caret location.
|
* and convert it into a data url image and paste that image at the caret location.
|
||||||
*
|
*
|
||||||
* @param {ClipboardEvent} e Paste event object.
|
* @param {ClipboardEvent} e Paste/drop event object.
|
||||||
* @param {Object} clipboardContent Collection of clipboard contents.
|
* @param {DOMRange} rng Optional rng object to move selection to.
|
||||||
* @return {Boolean} true/false if the image data was found or not.
|
* @return {Boolean} true/false if the image data was found or not.
|
||||||
*/
|
*/
|
||||||
function pasteImageData(e, clipboardContent) {
|
function pasteImageData(e, rng) {
|
||||||
function pasteImage(item) {
|
var dataTransfer = e.clipboardData || e.dataTransfer;
|
||||||
if (items[i].type == 'image/png') {
|
|
||||||
var reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onload = function() {
|
function processItems(items) {
|
||||||
pasteHtml('<img src="' + reader.result + '">');
|
var i, item, reader;
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsDataURL(item.getAsFile());
|
function pasteImage() {
|
||||||
|
if (rng) {
|
||||||
|
editor.selection.setRng(rng);
|
||||||
|
rng = null;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
pasteHtml('<img src="' + reader.result + '">');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If paste data images are disabled or there is HTML or plain text
|
|
||||||
// contents then proceed with the normal paste process
|
|
||||||
if (!editor.settings.paste_data_images || "text/html" in clipboardContent || "text/plain" in clipboardContent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.clipboardData) {
|
|
||||||
var items = e.clipboardData.items;
|
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (i = 0; i < items.length; i++) {
|
||||||
if (pasteImage(items[i])) {
|
item = items[i];
|
||||||
|
|
||||||
|
if (/^image\/(jpeg|png|gif)$/.test(item.type)) {
|
||||||
|
reader = new FileReader();
|
||||||
|
reader.onload = pasteImage;
|
||||||
|
reader.readAsDataURL(item.getAsFile ? item.getAsFile() : item);
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (editor.settings.paste_data_images && dataTransfer) {
|
||||||
|
return processItems(dataTransfer.items) || processItems(dataTransfer.files);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -546,6 +548,13 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
|
|
||||||
function registerEventHandlers() {
|
function registerEventHandlers() {
|
||||||
editor.on('keydown', function(e) {
|
editor.on('keydown', function(e) {
|
||||||
|
function removePasteBinOnKeyUp(e) {
|
||||||
|
// Ctrl+V or Shift+Insert
|
||||||
|
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
||||||
|
removePasteBin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ctrl+V or Shift+Insert
|
// Ctrl+V or Shift+Insert
|
||||||
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
||||||
keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
|
keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
|
||||||
|
@ -571,13 +580,13 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
|
|
||||||
removePasteBin();
|
removePasteBin();
|
||||||
createPasteBin();
|
createPasteBin();
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.on('keyup', function(e) {
|
// Remove pastebin if we get a keyup and no paste event
|
||||||
// Ctrl+V or Shift+Insert
|
// For example pasting a file in IE 11 will not produce a paste event
|
||||||
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
editor.once('keyup', removePasteBinOnKeyUp);
|
||||||
removePasteBin();
|
editor.once('paste', function() {
|
||||||
|
editor.off('keyup', removePasteBinOnKeyUp);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -593,7 +602,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pasteImageData(e, clipboardContent)) {
|
if (pasteImageData(e)) {
|
||||||
removePasteBin();
|
removePasteBin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -683,7 +692,15 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
editor.on('drop', function(e) {
|
editor.on('drop', function(e) {
|
||||||
var rng = getCaretRangeFromEvent(e);
|
var rng = getCaretRangeFromEvent(e);
|
||||||
|
|
||||||
if (rng && !e.isDefaultPrevented()) {
|
if (e.isDefaultPrevented()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pasteImageData(e, rng)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rng) {
|
||||||
var dropContent = getDataTransferItems(e.dataTransfer);
|
var dropContent = getDataTransferItems(e.dataTransfer);
|
||||||
var content = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
|
var content = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
|
||||||
|
|
||||||
|
@ -706,6 +723,20 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.on('dragover dragend', function(e) {
|
||||||
|
var i, dataTransfer = e.dataTransfer;
|
||||||
|
|
||||||
|
if (editor.settings.paste_data_images && dataTransfer) {
|
||||||
|
for (i = 0; i < dataTransfer.types.length; i++) {
|
||||||
|
// Prevent default if we have files dragged into the editor since the pasteImageData handles that
|
||||||
|
if (dataTransfer.types[i] == "Files") {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
self.pasteHtml = pasteHtml;
|
self.pasteHtml = pasteHtml;
|
||||||
|
@ -722,7 +753,10 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
var src = nodes[i].attributes.map.src;
|
var src = nodes[i].attributes.map.src;
|
||||||
if (src && src.indexOf('data:image') === 0) {
|
|
||||||
|
// Some browsers automatically produce data uris on paste
|
||||||
|
// Safari on Mac produces webkit-fake-url see: https://bugs.webkit.org/show_bug.cgi?id=49141
|
||||||
|
if (src && /^(data:image|webkit\-fake\-url)/.test(src)) {
|
||||||
if (!nodes[i].attr('data-mce-object') && src !== Env.transparentSrc) {
|
if (!nodes[i].attr('data-mce-object') && src !== Env.transparentSrc) {
|
||||||
nodes[i].remove();
|
nodes[i].remove();
|
||||||
}
|
}
|
||||||
|
@ -731,14 +765,6 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.on('BeforeAddUndo', function(e) {
|
|
||||||
// Remove pastebin HTML incase it should be added to an undo
|
|
||||||
// level for example when you paste a file on older IE
|
|
||||||
if (e.level.content) {
|
|
||||||
e.level.content = e.level.content.replace(/<div id="?mcepastebin"?[^>]+>%MCEPASTEBIN%<\/div>/gi, '');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,6 +12,8 @@
|
||||||
/*eslint consistent-this:0 */
|
/*eslint consistent-this:0 */
|
||||||
|
|
||||||
tinymce.PluginManager.add('textcolor', function(editor) {
|
tinymce.PluginManager.add('textcolor', function(editor) {
|
||||||
|
var VK = tinymce.util.VK;
|
||||||
|
|
||||||
function mapColors() {
|
function mapColors() {
|
||||||
var i, colors = [], colorMap;
|
var i, colors = [], colorMap;
|
||||||
|
|
||||||
|
@ -105,6 +107,29 @@ tinymce.PluginManager.add('textcolor', function(editor) {
|
||||||
html += '</tr>';
|
html += '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (editor.settings.textcolor_enable_hex) {
|
||||||
|
var hexIdN = last + 1;
|
||||||
|
var hexInputColSpan = cols - 1;
|
||||||
|
html += (
|
||||||
|
'<tr>' +
|
||||||
|
'<td>' +
|
||||||
|
'<div id="' + ctrl._id + '-' + hexIdN + '"' +
|
||||||
|
'data-mce-color=""' +
|
||||||
|
'style="background-color: #FFFFFF"' +
|
||||||
|
'data-mce-hex-picker="true"' +
|
||||||
|
'role="option" ' +
|
||||||
|
'>' +
|
||||||
|
'</div>' +
|
||||||
|
'</td>' +
|
||||||
|
'<td colspan="' + hexInputColSpan + '">' +
|
||||||
|
'# <input type="text" class="mce-textcolor-hexpicker"' +
|
||||||
|
'role="textbox" name="mce-hexcolorpicker"' +
|
||||||
|
'id="' + ctrl._id + '-hexcolorpicker" maxlength="6" >' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
html += '</tbody></table>';
|
html += '</tbody></table>';
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
@ -112,7 +137,10 @@ tinymce.PluginManager.add('textcolor', function(editor) {
|
||||||
|
|
||||||
function onPanelClick(e) {
|
function onPanelClick(e) {
|
||||||
var buttonCtrl = this.parent(), value;
|
var buttonCtrl = this.parent(), value;
|
||||||
|
|
||||||
|
if (e.target.getAttribute('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((value = e.target.getAttribute('data-mce-color'))) {
|
if ((value = e.target.getAttribute('data-mce-color'))) {
|
||||||
if (this.lastId) {
|
if (this.lastId) {
|
||||||
document.getElementById(this.lastId).setAttribute('aria-selected', false);
|
document.getElementById(this.lastId).setAttribute('aria-selected', false);
|
||||||
|
@ -136,6 +164,95 @@ tinymce.PluginManager.add('textcolor', function(editor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isValidHex checks if the provided string is valid hex color string
|
||||||
|
*
|
||||||
|
* @param {string} hexString 3 or 6 chars string representing a color.
|
||||||
|
* @return {Boolean} [true] the string is valid hex color
|
||||||
|
* [false] the string is not valid hex color
|
||||||
|
*/
|
||||||
|
function isValidHex(hexString) {
|
||||||
|
return /(^[0-9A-F]{3,6}$)/i.test(hexString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* isSpecialStroke checks if the keyCode is currently a special one:
|
||||||
|
* backspace, delete, arrow keys (left/right)
|
||||||
|
* or if it's a special ctrl+x/c/v
|
||||||
|
*
|
||||||
|
* @param {string} keyCode
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
|
function isSpecialStroke(e) {
|
||||||
|
var keyCode = e.keyCode;
|
||||||
|
// Allow delete and backspace
|
||||||
|
if (keyCode === VK.BACKSPACE || keyCode === VK.DELETE ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow arrow movements
|
||||||
|
if (keyCode === VK.LEFT || keyCode === VK.RIGHT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow CTRL/CMD + C/V/X
|
||||||
|
if ((tinymce.isMac ? e.metaKey : e.ctrlKey) && (keyCode == 67 || keyCode == 88 || keyCode == 86)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function initHexPicker(e) {
|
||||||
|
if (!editor.settings.textcolor_enable_hex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var wrapper = document.querySelector('#' + e.target._id);
|
||||||
|
var input = wrapper.querySelector('[name="mce-hexcolorpicker"]');
|
||||||
|
var hexcolorDiv = wrapper.querySelector('[data-mce-hex-picker]');
|
||||||
|
var inputEvent = 'input';
|
||||||
|
|
||||||
|
editor.dom.events.bind(input, 'keydown', function(e){
|
||||||
|
var keyCode = e.keyCode;
|
||||||
|
|
||||||
|
if (isSpecialStroke(e)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for anything which is not A-Z or 0-9 and it is not a special char.
|
||||||
|
if (!((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 70) || (keyCode >= 96 && keyCode <= 105)) ) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
// On Enter, take it like a click on the hexcolorDiv
|
||||||
|
if ( (keyCode === VK.ENTER && isValidHex(input.value) ) ) {
|
||||||
|
hexcolorDiv.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// If IE8 we can't use the input event, so we have to
|
||||||
|
// listen for keypress and paste events.
|
||||||
|
// In IE9 the input implementation is buggy so
|
||||||
|
// we use the same events as we'd like on IE8
|
||||||
|
if (tinymce.Env.ie && tinymce.Env.ie <= 9) {
|
||||||
|
inputEvent = 'keypress paste blur keydown keyup propertychange';
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.dom.events.bind(input, inputEvent, function(){
|
||||||
|
if (isValidHex(input.value)) {
|
||||||
|
hexcolorDiv.setAttribute('data-mce-color', input.value);
|
||||||
|
hexcolorDiv.setAttribute('style', 'background-color:#' + input.value);
|
||||||
|
hexcolorDiv.removeAttribute('disabled');
|
||||||
|
} else {
|
||||||
|
hexcolorDiv.setAttribute('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
editor.addButton('forecolor', {
|
editor.addButton('forecolor', {
|
||||||
type: 'colorbutton',
|
type: 'colorbutton',
|
||||||
tooltip: 'Text color',
|
tooltip: 'Text color',
|
||||||
|
@ -144,7 +261,8 @@ tinymce.PluginManager.add('textcolor', function(editor) {
|
||||||
role: 'application',
|
role: 'application',
|
||||||
ariaRemember: true,
|
ariaRemember: true,
|
||||||
html: renderColorPicker,
|
html: renderColorPicker,
|
||||||
onclick: onPanelClick
|
onclick: onPanelClick,
|
||||||
|
onPostRender: initHexPicker
|
||||||
},
|
},
|
||||||
onclick: onButtonClick
|
onclick: onButtonClick
|
||||||
});
|
});
|
||||||
|
@ -157,7 +275,8 @@ tinymce.PluginManager.add('textcolor', function(editor) {
|
||||||
role: 'application',
|
role: 'application',
|
||||||
ariaRemember: true,
|
ariaRemember: true,
|
||||||
html: renderColorPicker,
|
html: renderColorPicker,
|
||||||
onclick: onPanelClick
|
onclick: onPanelClick,
|
||||||
|
onPostRender: initHexPicker
|
||||||
},
|
},
|
||||||
onclick: onButtonClick
|
onclick: onButtonClick
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
tinymce.PluginManager.add("textcolor",function(e){function t(){var t,o,l=[];for(o=e.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","C0C0C0","Silver","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum","FFFFFF","White"],t=0;t<o.length;t+=2)l.push({text:o[t+1],color:o[t]});return l}function o(){var o,l,r,a,c,i,n,F,d,s=this;for(o=t(),r='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',a=o.length-1,c=e.settings.textcolor_rows||5,i=e.settings.textcolor_cols||8,F=0;c>F;F++){for(r+="<tr>",n=0;i>n;n++)d=F*i+n,d>a?r+="<td></td>":(l=o[d],r+='<td><div id="'+s._id+"-"+d+'" data-mce-color="'+l.color+'" role="option" tabIndex="-1" style="'+(l?"background-color: #"+l.color:"")+'" title="'+l.text+'"></div></td>');r+="</tr>"}return r+="</tbody></table>"}function l(t){var o,l=this.parent();(o=t.target.getAttribute("data-mce-color"))&&(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),t.target.setAttribute("aria-selected",!0),this.lastId=t.target.id,l.hidePanel(),o="#"+o,l.color(o),e.execCommand(l.settings.selectcmd,!1,o))}function r(){var t=this;t._color&&e.execCommand(t.settings.selectcmd,!1,t._color)}e.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",selectcmd:"ForeColor",panel:{role:"application",ariaRemember:!0,html:o,onclick:l},onclick:r}),e.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",selectcmd:"HiliteColor",panel:{role:"application",ariaRemember:!0,html:o,onclick:l},onclick:r})});
|
tinymce.PluginManager.add("textcolor",function(e){function t(){var t,o,r=[];for(o=e.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","C0C0C0","Silver","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum","FFFFFF","White"],t=0;t<o.length;t+=2)r.push({text:o[t+1],color:o[t]});return r}function o(){var o,r,l,c,i,a,n,d,s,u=this;for(o=t(),l='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',c=o.length-1,i=e.settings.textcolor_rows||5,a=e.settings.textcolor_cols||8,d=0;i>d;d++){for(l+="<tr>",n=0;a>n;n++)s=d*a+n,s>c?l+="<td></td>":(r=o[s],l+='<td><div id="'+u._id+"-"+s+'" data-mce-color="'+r.color+'" role="option" tabIndex="-1" style="'+(r?"background-color: #"+r.color:"")+'" title="'+r.text+'"></div></td>');l+="</tr>"}if(e.settings.textcolor_enable_hex){var F=c+1,m=a-1;l+='<tr><td><div id="'+u._id+"-"+F+'"data-mce-color=""style="background-color: #FFFFFF"data-mce-hex-picker="true"role="option" ></div></td><td colspan="'+m+'"># <input type="text" class="mce-textcolor-hexpicker"role="textbox" name="mce-hexcolorpicker"id="'+u._id+'-hexcolorpicker" maxlength="6" ></td></tr>'}return l+="</tbody></table>"}function r(t){var o,r=this.parent();t.target.getAttribute("disabled")||(o=t.target.getAttribute("data-mce-color"))&&(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),t.target.setAttribute("aria-selected",!0),this.lastId=t.target.id,r.hidePanel(),o="#"+o,r.color(o),e.execCommand(r.settings.selectcmd,!1,o))}function l(){var t=this;t._color&&e.execCommand(t.settings.selectcmd,!1,t._color)}function c(e){return/(^[0-9A-F]{3,6}$)/i.test(e)}function i(e){var t=e.keyCode;return t===n.BACKSPACE||t===n.DELETE?!0:t===n.LEFT||t===n.RIGHT?!0:(tinymce.isMac?e.metaKey:e.ctrlKey)&&(67==t||88==t||86==t)?!0:!1}function a(t){if(e.settings.textcolor_enable_hex){var o=document.querySelector("#"+t.target._id),r=o.querySelector('[name="mce-hexcolorpicker"]'),l=o.querySelector("[data-mce-hex-picker]"),a="input";e.dom.events.bind(r,"keydown",function(e){var t=e.keyCode;i(e)||(t>=48&&57>=t||t>=65&&70>=t||t>=96&&105>=t||e.preventDefault(),t===n.ENTER&&c(r.value)&&l.click())}),tinymce.Env.ie&&tinymce.Env.ie<=9&&(a="keypress paste blur keydown keyup propertychange"),e.dom.events.bind(r,a,function(){c(r.value)?(l.setAttribute("data-mce-color",r.value),l.setAttribute("style","background-color:#"+r.value),l.removeAttribute("disabled")):l.setAttribute("disabled","disabled")})}}var n=tinymce.util.VK;e.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",selectcmd:"ForeColor",panel:{role:"application",ariaRemember:!0,html:o,onclick:r,onPostRender:a},onclick:l}),e.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",selectcmd:"HiliteColor",panel:{role:"application",ariaRemember:!0,html:o,onclick:r,onPostRender:a},onclick:l})});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -18,7 +18,7 @@ $wp_db_version = 27916;
|
||||||
*
|
*
|
||||||
* @global string $tinymce_version
|
* @global string $tinymce_version
|
||||||
*/
|
*/
|
||||||
$tinymce_version = '4028-20140528';
|
$tinymce_version = '4028-20140617';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the required PHP version
|
* Holds the required PHP version
|
||||||
|
|
Loading…
Reference in New Issue