mirror of
https://github.com/KevinMidboe/rohnenedre.git
synced 2026-02-12 20:39:17 +00:00
Initial commit. State 04.2021.
This commit is contained in:
398
wp-includes/js/tinymce/plugins/charmap/plugin.js
Normal file
398
wp-includes/js/tinymce/plugins/charmap/plugin.js
Normal file
@@ -0,0 +1,398 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('charmap', function(editor) {
|
||||
var charmap = [
|
||||
['160', 'no-break space'],
|
||||
['173', 'soft hyphen'],
|
||||
['34', 'quotation mark'],
|
||||
// finance
|
||||
['162', 'cent sign'],
|
||||
['8364', 'euro sign'],
|
||||
['163', 'pound sign'],
|
||||
['165', 'yen sign'],
|
||||
// signs
|
||||
['169', 'copyright sign'],
|
||||
['174', 'registered sign'],
|
||||
['8482', 'trade mark sign'],
|
||||
['8240', 'per mille sign'],
|
||||
['181', 'micro sign'],
|
||||
['183', 'middle dot'],
|
||||
['8226', 'bullet'],
|
||||
['8230', 'three dot leader'],
|
||||
['8242', 'minutes / feet'],
|
||||
['8243', 'seconds / inches'],
|
||||
['167', 'section sign'],
|
||||
['182', 'paragraph sign'],
|
||||
['223', 'sharp s / ess-zed'],
|
||||
// quotations
|
||||
['8249', 'single left-pointing angle quotation mark'],
|
||||
['8250', 'single right-pointing angle quotation mark'],
|
||||
['171', 'left pointing guillemet'],
|
||||
['187', 'right pointing guillemet'],
|
||||
['8216', 'left single quotation mark'],
|
||||
['8217', 'right single quotation mark'],
|
||||
['8220', 'left double quotation mark'],
|
||||
['8221', 'right double quotation mark'],
|
||||
['8218', 'single low-9 quotation mark'],
|
||||
['8222', 'double low-9 quotation mark'],
|
||||
['60', 'less-than sign'],
|
||||
['62', 'greater-than sign'],
|
||||
['8804', 'less-than or equal to'],
|
||||
['8805', 'greater-than or equal to'],
|
||||
['8211', 'en dash'],
|
||||
['8212', 'em dash'],
|
||||
['175', 'macron'],
|
||||
['8254', 'overline'],
|
||||
['164', 'currency sign'],
|
||||
['166', 'broken bar'],
|
||||
['168', 'diaeresis'],
|
||||
['161', 'inverted exclamation mark'],
|
||||
['191', 'turned question mark'],
|
||||
['710', 'circumflex accent'],
|
||||
['732', 'small tilde'],
|
||||
['176', 'degree sign'],
|
||||
['8722', 'minus sign'],
|
||||
['177', 'plus-minus sign'],
|
||||
['247', 'division sign'],
|
||||
['8260', 'fraction slash'],
|
||||
['215', 'multiplication sign'],
|
||||
['185', 'superscript one'],
|
||||
['178', 'superscript two'],
|
||||
['179', 'superscript three'],
|
||||
['188', 'fraction one quarter'],
|
||||
['189', 'fraction one half'],
|
||||
['190', 'fraction three quarters'],
|
||||
// math / logical
|
||||
['402', 'function / florin'],
|
||||
['8747', 'integral'],
|
||||
['8721', 'n-ary sumation'],
|
||||
['8734', 'infinity'],
|
||||
['8730', 'square root'],
|
||||
['8764', 'similar to'],
|
||||
['8773', 'approximately equal to'],
|
||||
['8776', 'almost equal to'],
|
||||
['8800', 'not equal to'],
|
||||
['8801', 'identical to'],
|
||||
['8712', 'element of'],
|
||||
['8713', 'not an element of'],
|
||||
['8715', 'contains as member'],
|
||||
['8719', 'n-ary product'],
|
||||
['8743', 'logical and'],
|
||||
['8744', 'logical or'],
|
||||
['172', 'not sign'],
|
||||
['8745', 'intersection'],
|
||||
['8746', 'union'],
|
||||
['8706', 'partial differential'],
|
||||
['8704', 'for all'],
|
||||
['8707', 'there exists'],
|
||||
['8709', 'diameter'],
|
||||
['8711', 'backward difference'],
|
||||
['8727', 'asterisk operator'],
|
||||
['8733', 'proportional to'],
|
||||
['8736', 'angle'],
|
||||
// undefined
|
||||
['180', 'acute accent'],
|
||||
['184', 'cedilla'],
|
||||
['170', 'feminine ordinal indicator'],
|
||||
['186', 'masculine ordinal indicator'],
|
||||
['8224', 'dagger'],
|
||||
['8225', 'double dagger'],
|
||||
// alphabetical special chars
|
||||
['192', 'A - grave'],
|
||||
['193', 'A - acute'],
|
||||
['194', 'A - circumflex'],
|
||||
['195', 'A - tilde'],
|
||||
['196', 'A - diaeresis'],
|
||||
['197', 'A - ring above'],
|
||||
['198', 'ligature AE'],
|
||||
['199', 'C - cedilla'],
|
||||
['200', 'E - grave'],
|
||||
['201', 'E - acute'],
|
||||
['202', 'E - circumflex'],
|
||||
['203', 'E - diaeresis'],
|
||||
['204', 'I - grave'],
|
||||
['205', 'I - acute'],
|
||||
['206', 'I - circumflex'],
|
||||
['207', 'I - diaeresis'],
|
||||
['208', 'ETH'],
|
||||
['209', 'N - tilde'],
|
||||
['210', 'O - grave'],
|
||||
['211', 'O - acute'],
|
||||
['212', 'O - circumflex'],
|
||||
['213', 'O - tilde'],
|
||||
['214', 'O - diaeresis'],
|
||||
['216', 'O - slash'],
|
||||
['338', 'ligature OE'],
|
||||
['352', 'S - caron'],
|
||||
['217', 'U - grave'],
|
||||
['218', 'U - acute'],
|
||||
['219', 'U - circumflex'],
|
||||
['220', 'U - diaeresis'],
|
||||
['221', 'Y - acute'],
|
||||
['376', 'Y - diaeresis'],
|
||||
['222', 'THORN'],
|
||||
['224', 'a - grave'],
|
||||
['225', 'a - acute'],
|
||||
['226', 'a - circumflex'],
|
||||
['227', 'a - tilde'],
|
||||
['228', 'a - diaeresis'],
|
||||
['229', 'a - ring above'],
|
||||
['230', 'ligature ae'],
|
||||
['231', 'c - cedilla'],
|
||||
['232', 'e - grave'],
|
||||
['233', 'e - acute'],
|
||||
['234', 'e - circumflex'],
|
||||
['235', 'e - diaeresis'],
|
||||
['236', 'i - grave'],
|
||||
['237', 'i - acute'],
|
||||
['238', 'i - circumflex'],
|
||||
['239', 'i - diaeresis'],
|
||||
['240', 'eth'],
|
||||
['241', 'n - tilde'],
|
||||
['242', 'o - grave'],
|
||||
['243', 'o - acute'],
|
||||
['244', 'o - circumflex'],
|
||||
['245', 'o - tilde'],
|
||||
['246', 'o - diaeresis'],
|
||||
['248', 'o slash'],
|
||||
['339', 'ligature oe'],
|
||||
['353', 's - caron'],
|
||||
['249', 'u - grave'],
|
||||
['250', 'u - acute'],
|
||||
['251', 'u - circumflex'],
|
||||
['252', 'u - diaeresis'],
|
||||
['253', 'y - acute'],
|
||||
['254', 'thorn'],
|
||||
['255', 'y - diaeresis'],
|
||||
['913', 'Alpha'],
|
||||
['914', 'Beta'],
|
||||
['915', 'Gamma'],
|
||||
['916', 'Delta'],
|
||||
['917', 'Epsilon'],
|
||||
['918', 'Zeta'],
|
||||
['919', 'Eta'],
|
||||
['920', 'Theta'],
|
||||
['921', 'Iota'],
|
||||
['922', 'Kappa'],
|
||||
['923', 'Lambda'],
|
||||
['924', 'Mu'],
|
||||
['925', 'Nu'],
|
||||
['926', 'Xi'],
|
||||
['927', 'Omicron'],
|
||||
['928', 'Pi'],
|
||||
['929', 'Rho'],
|
||||
['931', 'Sigma'],
|
||||
['932', 'Tau'],
|
||||
['933', 'Upsilon'],
|
||||
['934', 'Phi'],
|
||||
['935', 'Chi'],
|
||||
['936', 'Psi'],
|
||||
['937', 'Omega'],
|
||||
['945', 'alpha'],
|
||||
['946', 'beta'],
|
||||
['947', 'gamma'],
|
||||
['948', 'delta'],
|
||||
['949', 'epsilon'],
|
||||
['950', 'zeta'],
|
||||
['951', 'eta'],
|
||||
['952', 'theta'],
|
||||
['953', 'iota'],
|
||||
['954', 'kappa'],
|
||||
['955', 'lambda'],
|
||||
['956', 'mu'],
|
||||
['957', 'nu'],
|
||||
['958', 'xi'],
|
||||
['959', 'omicron'],
|
||||
['960', 'pi'],
|
||||
['961', 'rho'],
|
||||
['962', 'final sigma'],
|
||||
['963', 'sigma'],
|
||||
['964', 'tau'],
|
||||
['965', 'upsilon'],
|
||||
['966', 'phi'],
|
||||
['967', 'chi'],
|
||||
['968', 'psi'],
|
||||
['969', 'omega'],
|
||||
// symbols
|
||||
['8501', 'alef symbol'],
|
||||
['982', 'pi symbol'],
|
||||
['8476', 'real part symbol'],
|
||||
['978', 'upsilon - hook symbol'],
|
||||
['8472', 'Weierstrass p'],
|
||||
['8465', 'imaginary part'],
|
||||
// arrows
|
||||
['8592', 'leftwards arrow'],
|
||||
['8593', 'upwards arrow'],
|
||||
['8594', 'rightwards arrow'],
|
||||
['8595', 'downwards arrow'],
|
||||
['8596', 'left right arrow'],
|
||||
['8629', 'carriage return'],
|
||||
['8656', 'leftwards double arrow'],
|
||||
['8657', 'upwards double arrow'],
|
||||
['8658', 'rightwards double arrow'],
|
||||
['8659', 'downwards double arrow'],
|
||||
['8660', 'left right double arrow'],
|
||||
['8756', 'therefore'],
|
||||
['8834', 'subset of'],
|
||||
['8835', 'superset of'],
|
||||
['8836', 'not a subset of'],
|
||||
['8838', 'subset of or equal to'],
|
||||
['8839', 'superset of or equal to'],
|
||||
['8853', 'circled plus'],
|
||||
['8855', 'circled times'],
|
||||
['8869', 'perpendicular'],
|
||||
['8901', 'dot operator'],
|
||||
['8968', 'left ceiling'],
|
||||
['8969', 'right ceiling'],
|
||||
['8970', 'left floor'],
|
||||
['8971', 'right floor'],
|
||||
['9001', 'left-pointing angle bracket'],
|
||||
['9002', 'right-pointing angle bracket'],
|
||||
['9674', 'lozenge'],
|
||||
['9824', 'black spade suit'],
|
||||
['9827', 'black club suit'],
|
||||
['9829', 'black heart suit'],
|
||||
['9830', 'black diamond suit'],
|
||||
['8194', 'en space'],
|
||||
['8195', 'em space'],
|
||||
['8201', 'thin space'],
|
||||
['8204', 'zero width non-joiner'],
|
||||
['8205', 'zero width joiner'],
|
||||
['8206', 'left-to-right mark'],
|
||||
['8207', 'right-to-left mark']
|
||||
];
|
||||
|
||||
function showDialog() {
|
||||
var gridHtml, x, y, win;
|
||||
|
||||
function getParentTd(elm) {
|
||||
while (elm) {
|
||||
if (elm.nodeName == 'TD') {
|
||||
return elm;
|
||||
}
|
||||
|
||||
elm = elm.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
gridHtml = '<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>';
|
||||
|
||||
var width = 25;
|
||||
var height = Math.ceil(charmap.length / width);
|
||||
for (y = 0; y < height; y++) {
|
||||
gridHtml += '<tr>';
|
||||
|
||||
for (x = 0; x < width; x++) {
|
||||
var index = y * width + x;
|
||||
if (index < charmap.length) {
|
||||
var chr = charmap[index];
|
||||
|
||||
gridHtml += '<td title="' + chr[1] + '"><div tabindex="-1" title="' + chr[1] + '" role="button">' +
|
||||
(chr ? String.fromCharCode(parseInt(chr[0], 10)) : ' ') + '</div></td>';
|
||||
} else {
|
||||
gridHtml += '<td />';
|
||||
}
|
||||
}
|
||||
|
||||
gridHtml += '</tr>';
|
||||
}
|
||||
|
||||
gridHtml += '</tbody></table>';
|
||||
|
||||
var charMapPanel = {
|
||||
type: 'container',
|
||||
html: gridHtml,
|
||||
onclick: function(e) {
|
||||
var target = e.target;
|
||||
if (/^(TD|DIV)$/.test(target.nodeName)) {
|
||||
if (getParentTd(target).firstChild) {
|
||||
editor.execCommand('mceInsertContent', false, tinymce.trim(target.innerText || target.textContent));
|
||||
|
||||
if (!e.ctrlKey) {
|
||||
win.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onmouseover: function(e) {
|
||||
var td = getParentTd(e.target);
|
||||
|
||||
if (td && td.firstChild) {
|
||||
win.find('#preview').text(td.firstChild.firstChild.data);
|
||||
win.find('#previewTitle').text(td.title);
|
||||
} else {
|
||||
win.find('#preview').text(' ');
|
||||
win.find('#previewTitle').text(' ');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
win = editor.windowManager.open({
|
||||
title: "Special character",
|
||||
spacing: 10,
|
||||
padding: 10,
|
||||
items: [
|
||||
charMapPanel,
|
||||
{
|
||||
type: 'container',
|
||||
layout: 'flex',
|
||||
direction: 'column',
|
||||
align: 'center',
|
||||
spacing: 5,
|
||||
minWidth: 160,
|
||||
minHeight: 160,
|
||||
items: [
|
||||
{
|
||||
type: 'label',
|
||||
name: 'preview',
|
||||
text: ' ',
|
||||
style: 'font-size: 40px; text-align: center',
|
||||
border: 1,
|
||||
minWidth: 140,
|
||||
minHeight: 80
|
||||
},
|
||||
{
|
||||
type: 'label',
|
||||
name: 'previewTitle',
|
||||
text: ' ',
|
||||
style: 'text-align: center',
|
||||
border: 1,
|
||||
minWidth: 140,
|
||||
minHeight: 80
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
buttons: [
|
||||
{text: "Close", onclick: function() {
|
||||
win.close();
|
||||
}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
editor.addCommand('mceShowCharmap', showDialog);
|
||||
|
||||
editor.addButton('charmap', {
|
||||
icon: 'charmap',
|
||||
tooltip: 'Special character',
|
||||
cmd: 'mceShowCharmap'
|
||||
});
|
||||
|
||||
editor.addMenuItem('charmap', {
|
||||
icon: 'charmap',
|
||||
text: 'Special character',
|
||||
cmd: 'mceShowCharmap',
|
||||
context: 'insert'
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/charmap/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/charmap/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
112
wp-includes/js/tinymce/plugins/colorpicker/plugin.js
Normal file
112
wp-includes/js/tinymce/plugins/colorpicker/plugin.js
Normal file
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('colorpicker', function(editor) {
|
||||
function colorPickerCallback(callback, value) {
|
||||
function setColor(value) {
|
||||
var color = new tinymce.util.Color(value), rgb = color.toRgb();
|
||||
|
||||
win.fromJSON({
|
||||
r: rgb.r,
|
||||
g: rgb.g,
|
||||
b: rgb.b,
|
||||
hex: color.toHex().substr(1)
|
||||
});
|
||||
|
||||
showPreview(color.toHex());
|
||||
}
|
||||
|
||||
function showPreview(hexColor) {
|
||||
win.find('#preview')[0].getEl().style.background = hexColor;
|
||||
}
|
||||
|
||||
var win = editor.windowManager.open({
|
||||
title: 'Color',
|
||||
items: {
|
||||
type: 'container',
|
||||
layout: 'flex',
|
||||
direction: 'row',
|
||||
align: 'stretch',
|
||||
padding: 5,
|
||||
spacing: 10,
|
||||
items: [
|
||||
{
|
||||
type: 'colorpicker',
|
||||
value: value,
|
||||
onchange: function() {
|
||||
var rgb = this.rgb();
|
||||
|
||||
if (win) {
|
||||
win.find('#r').value(rgb.r);
|
||||
win.find('#g').value(rgb.g);
|
||||
win.find('#b').value(rgb.b);
|
||||
win.find('#hex').value(this.value().substr(1));
|
||||
showPreview(this.value());
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
padding: 0,
|
||||
labelGap: 5,
|
||||
defaults: {
|
||||
type: 'textbox',
|
||||
size: 7,
|
||||
value: '0',
|
||||
flex: 1,
|
||||
spellcheck: false,
|
||||
onchange: function() {
|
||||
var colorPickerCtrl = win.find('colorpicker')[0];
|
||||
var name, value;
|
||||
|
||||
name = this.name();
|
||||
value = this.value();
|
||||
|
||||
if (name == "hex") {
|
||||
value = '#' + value;
|
||||
setColor(value);
|
||||
colorPickerCtrl.value(value);
|
||||
return;
|
||||
}
|
||||
|
||||
value = {
|
||||
r: win.find('#r').value(),
|
||||
g: win.find('#g').value(),
|
||||
b: win.find('#b').value()
|
||||
};
|
||||
|
||||
colorPickerCtrl.value(value);
|
||||
setColor(value);
|
||||
}
|
||||
},
|
||||
items: [
|
||||
{name: 'r', label: 'R', autofocus: 1},
|
||||
{name: 'g', label: 'G'},
|
||||
{name: 'b', label: 'B'},
|
||||
{name: 'hex', label: '#', value: '000000'},
|
||||
{name: 'preview', type: 'container', border: 1}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
onSubmit: function() {
|
||||
callback('#' + this.toJSON().hex);
|
||||
}
|
||||
});
|
||||
|
||||
setColor(value);
|
||||
}
|
||||
|
||||
if (!editor.settings.color_picker_callback) {
|
||||
editor.settings.color_picker_callback = colorPickerCallback;
|
||||
}
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("colorpicker",function(a){function b(b,c){function d(a){var b=new tinymce.util.Color(a),c=b.toRgb();f.fromJSON({r:c.r,g:c.g,b:c.b,hex:b.toHex().substr(1)}),e(b.toHex())}function e(a){f.find("#preview")[0].getEl().style.background=a}var f=a.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:c,onchange:function(){var a=this.rgb();f&&(f.find("#r").value(a.r),f.find("#g").value(a.g),f.find("#b").value(a.b),f.find("#hex").value(this.value().substr(1)),e(this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var a,b,c=f.find("colorpicker")[0];return a=this.name(),b=this.value(),"hex"==a?(b="#"+b,d(b),void c.value(b)):(b={r:f.find("#r").value(),g:f.find("#g").value(),b:f.find("#b").value()},c.value(b),void d(b))}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){b("#"+this.toJSON().hex)}});d(c)}a.settings.color_picker_callback||(a.settings.color_picker_callback=b)});
|
||||
212
wp-includes/js/tinymce/plugins/compat3x/css/dialog.css
Normal file
212
wp-includes/js/tinymce/plugins/compat3x/css/dialog.css
Normal file
@@ -0,0 +1,212 @@
|
||||
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=latin-ext,latin");
|
||||
|
||||
/* Generic */
|
||||
body {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
font-size:13px;
|
||||
background:#fcfcfc;
|
||||
padding:0;
|
||||
margin:8px 8px 0 8px;
|
||||
}
|
||||
|
||||
textarea {resize:none;outline:none;}
|
||||
|
||||
a:link, a:hover {
|
||||
color: #2B6FB6;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #3C2BB6;
|
||||
}
|
||||
|
||||
.nowrap {white-space: nowrap}
|
||||
|
||||
/* Forms */
|
||||
form {margin: 0;}
|
||||
fieldset {margin:0; padding:4px; border:1px solid #dfdfdf; font-family:Verdana, Arial; font-size:10px;}
|
||||
legend {color:#2B6FB6; font-weight:bold;}
|
||||
label.msg {display:none;}
|
||||
label.invalid {color:#EE0000; display:inline;}
|
||||
input.invalid {border:1px solid #EE0000;}
|
||||
input {background:#FFF; border:1px solid #dfdfdf;}
|
||||
input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
|
||||
input, select, textarea {border:1px solid #dfdfdf;}
|
||||
input.radio {border:1px none #000000; background:transparent; vertical-align:middle;}
|
||||
input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;}
|
||||
.input_noborder {border:0;}
|
||||
|
||||
/* Buttons */
|
||||
#insert,
|
||||
#cancel,
|
||||
#apply,
|
||||
.mceActionPanel .button,
|
||||
input.mceButton,
|
||||
.updateButton {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
border: 1px solid #adadad;
|
||||
margin: 0;
|
||||
padding: 0 10px 1px;
|
||||
font-size: 13px;
|
||||
height: 24px;
|
||||
line-height: 22px;
|
||||
color: #333;
|
||||
cursor: pointer;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-appearance: none;
|
||||
border-radius: 3px;
|
||||
white-space: nowrap;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: #fafafa;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#e9e9e9));
|
||||
background-image: -webkit-linear-gradient(top, #fafafa, #e9e9e9);
|
||||
background-image: -moz-linear-gradient(top, #fafafa, #e9e9e9);
|
||||
background-image: -o-linear-gradient(top, #fafafa, #e9e9e9);
|
||||
background-image: linear-gradient(to bottom, #fafafa, #e9e9e9);
|
||||
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
-webkit-box-shadow: inset 0 1px 0 #fff;
|
||||
-moz-box-shadow: inset 0 1px 0 #fff;
|
||||
box-shadow: inset 0 1px 0 #fff;
|
||||
}
|
||||
|
||||
#insert {
|
||||
background: #2ea2cc;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#2ea2cc), to(#1e8cbe));
|
||||
background: -webkit-linear-gradient(top, #2ea2cc 0%,#1e8cbe 100%);
|
||||
background: linear-gradient(top, #2ea2cc 0%,#1e8cbe 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2ea2cc', endColorstr='#1e8cbe',GradientType=0 );
|
||||
border-color: #0074a2;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
|
||||
box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
text-shadow: 0 1px 0 rgba(0,86,132,0.7);
|
||||
}
|
||||
|
||||
#cancel:hover,
|
||||
input.mceButton:hover,
|
||||
.updateButton:hover,
|
||||
#cancel:focus,
|
||||
input.mceButton:focus,
|
||||
.updateButton:focus {
|
||||
background: #f3f3f3;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f3f3f3));
|
||||
background-image: -webkit-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: -moz-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: -ms-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: -o-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: linear-gradient(to bottom, #fff, #f3f3f3);
|
||||
border-color: #999;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
#insert:hover,
|
||||
#insert:focus {
|
||||
background: #1e8cbe;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#1e8cbe), to(#0074a2));
|
||||
background: -webkit-linear-gradient(top, #1e8cbe 0%,#0074a2 100%);
|
||||
background: linear-gradient(top, #1e8cbe 0%,#0074a2 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e8cbe', endColorstr='#0074a2',GradientType=0 );
|
||||
border-color: #0074a2;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
|
||||
box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.mceActionPanel #insert {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Browse */
|
||||
a.pickcolor, a.browse {text-decoration:none}
|
||||
a.browse span {display:block; width:20px; height:18px; border:1px solid #FFF; margin-left:1px;}
|
||||
.mceOldBoxModel a.browse span {width:22px; height:20px;}
|
||||
a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
|
||||
a.browse span.disabled {border:1px solid white; opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30);}
|
||||
a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
|
||||
a.pickcolor span {display:block; width:20px; height:16px; margin-left:2px;}
|
||||
.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
|
||||
a.pickcolor:hover span {background-color:#B2BBD0;}
|
||||
div.iframecontainer {background: #fff;}
|
||||
|
||||
/* Charmap */
|
||||
table.charmap {border:1px solid #AAA; text-align:center}
|
||||
td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;}
|
||||
#charmap a {display:block; color:#000; text-decoration:none; border:0}
|
||||
#charmap a:hover {background:#CCC;color:#2B6FB6}
|
||||
#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center}
|
||||
#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center}
|
||||
#charmap #charmapView {background-color:#fff;}
|
||||
|
||||
/* Source */
|
||||
.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;}
|
||||
.mceActionPanel {margin-top:5px;}
|
||||
|
||||
/* Tabs classes */
|
||||
.tabs {width:100%; height:19px; line-height:normal; border-bottom: 1px solid #aaa;}
|
||||
.tabs ul {margin:0; padding:0; list-style:none;}
|
||||
.tabs li {float:left; border: 1px solid #aaa; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;}
|
||||
.tabs li.current {border-bottom: 1px solid #fff; margin-right:2px;}
|
||||
.tabs span {float:left; display:block; padding:0px 10px 0 0;}
|
||||
.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;}
|
||||
.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;}
|
||||
|
||||
.wp-core-ui #tabs {
|
||||
padding-bottom: 5px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.wp-core-ui #tabs a {
|
||||
padding: 6px 10px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
/* Panels */
|
||||
.panel_wrapper div.panel {display:none;}
|
||||
.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;}
|
||||
.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;}
|
||||
|
||||
/* Columns */
|
||||
.column {float:left;}
|
||||
.properties {width:100%;}
|
||||
.properties .column1 {}
|
||||
.properties .column2 {text-align:left;}
|
||||
|
||||
/* Titles */
|
||||
h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;}
|
||||
h3 {font-size:14px;}
|
||||
.title {font-size:12px; font-weight:bold; color:#2B6FB6;}
|
||||
|
||||
/* Dialog specific */
|
||||
#link .panel_wrapper, #link div.current {height:125px;}
|
||||
#image .panel_wrapper, #image div.current {height:200px;}
|
||||
#plugintable thead {font-weight:bold; background:#DDD;}
|
||||
#plugintable, #about #plugintable td {border:1px solid #919B9C;}
|
||||
#plugintable {width:96%; margin-top:10px;}
|
||||
#pluginscontainer {height:290px; overflow:auto;}
|
||||
#colorpicker #preview {display:inline-block; padding-left:40px; height:14px; border:1px solid black; margin-left:5px; margin-right: 5px}
|
||||
#colorpicker #previewblock {position: relative; top: -3px; padding-left:5px; padding-top: 0px; display:inline}
|
||||
#colorpicker #preview_wrapper {text-align:center; padding-top:4px; white-space: nowrap; float: right;}
|
||||
#colorpicker #insert, #colorpicker #cancel {width: 90px}
|
||||
#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;}
|
||||
#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;}
|
||||
#colorpicker #light div {overflow:hidden;}
|
||||
#colorpicker .panel_wrapper div.current {height:175px;}
|
||||
#colorpicker #namedcolors {width:150px;}
|
||||
#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;}
|
||||
#colorpicker #colornamecontainer {margin-top:5px;}
|
||||
#colorpicker #picker_panel fieldset {margin:auto;width:325px;}
|
||||
|
||||
|
||||
/* Localization */
|
||||
|
||||
body[dir="rtl"],
|
||||
body[dir="rtl"] fieldset,
|
||||
body[dir="rtl"] input, body[dir="rtl"] select, body[dir="rtl"] textarea,
|
||||
body[dir="rtl"] #charmap #codeN,
|
||||
body[dir="rtl"] .tabs a {
|
||||
font-family: Tahoma, sans-serif;
|
||||
}
|
||||
304
wp-includes/js/tinymce/plugins/compat3x/plugin.js
Normal file
304
wp-includes/js/tinymce/plugins/compat3x/plugin.js
Normal file
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true, console:true */
|
||||
/*eslint no-console:0, new-cap:0 */
|
||||
|
||||
/**
|
||||
* This plugin adds missing events form the 4.x API back. Not every event is
|
||||
* properly supported but most things should work.
|
||||
*
|
||||
* Unsupported things:
|
||||
* - No editor.onEvent
|
||||
* - Can't cancel execCommands with beforeExecCommand
|
||||
*/
|
||||
(function(tinymce) {
|
||||
var reported;
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
||||
function log(apiCall) {
|
||||
if (!reported && window && window.console) {
|
||||
reported = true;
|
||||
console.log("Deprecated TinyMCE API call: " + apiCall);
|
||||
}
|
||||
}
|
||||
|
||||
function Dispatcher(target, newEventName, argsMap, defaultScope) {
|
||||
target = target || this;
|
||||
|
||||
if (!newEventName) {
|
||||
this.add = this.addToTop = this.remove = this.dispatch = noop;
|
||||
return;
|
||||
}
|
||||
|
||||
this.add = function(callback, scope, prepend) {
|
||||
log('<target>.on' + newEventName + ".add(..)");
|
||||
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2)
|
||||
function patchedEventCallback(e) {
|
||||
var callbackArgs = [];
|
||||
|
||||
if (typeof argsMap == "string") {
|
||||
argsMap = argsMap.split(" ");
|
||||
}
|
||||
|
||||
if (argsMap && typeof argsMap != "function") {
|
||||
for (var i = 0; i < argsMap.length; i++) {
|
||||
callbackArgs.push(e[argsMap[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof argsMap == "function") {
|
||||
callbackArgs = argsMap(newEventName, e, target);
|
||||
if (!callbackArgs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!argsMap) {
|
||||
callbackArgs = [e];
|
||||
}
|
||||
|
||||
callbackArgs.unshift(defaultScope || target);
|
||||
|
||||
if (callback.apply(scope || defaultScope || target, callbackArgs) === false) {
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
target.on(newEventName, patchedEventCallback, prepend);
|
||||
|
||||
return patchedEventCallback;
|
||||
};
|
||||
|
||||
this.addToTop = function(callback, scope) {
|
||||
this.add(callback, scope, true);
|
||||
};
|
||||
|
||||
this.remove = function(callback) {
|
||||
return target.off(newEventName, callback);
|
||||
};
|
||||
|
||||
this.dispatch = function() {
|
||||
target.fire(newEventName);
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
tinymce.util.Dispatcher = Dispatcher;
|
||||
tinymce.onBeforeUnload = new Dispatcher(tinymce, "BeforeUnload");
|
||||
tinymce.onAddEditor = new Dispatcher(tinymce, "AddEditor", "editor");
|
||||
tinymce.onRemoveEditor = new Dispatcher(tinymce, "RemoveEditor", "editor");
|
||||
|
||||
tinymce.util.Cookie = {
|
||||
get: noop, getHash: noop, remove: noop, set: noop, setHash: noop
|
||||
};
|
||||
|
||||
function patchEditor(editor) {
|
||||
function patchEditorEvents(oldEventNames, argsMap) {
|
||||
tinymce.each(oldEventNames.split(" "), function(oldName) {
|
||||
editor["on" + oldName] = new Dispatcher(editor, oldName, argsMap);
|
||||
});
|
||||
}
|
||||
|
||||
function convertUndoEventArgs(type, event, target) {
|
||||
return [
|
||||
event.level,
|
||||
target
|
||||
];
|
||||
}
|
||||
|
||||
function filterSelectionEvents(needsSelection) {
|
||||
return function(type, e) {
|
||||
if ((!e.selection && !needsSelection) || e.selection == needsSelection) {
|
||||
return [e];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (editor.controlManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
function cmNoop() {
|
||||
var obj = {}, methods = 'add addMenu addSeparator collapse createMenu destroy displayColor expand focus ' +
|
||||
'getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark ' +
|
||||
'postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex ' +
|
||||
'setActive setAriaProperty setColor setDisabled setSelected setState showMenu update';
|
||||
|
||||
log('editor.controlManager.*');
|
||||
|
||||
function _noop() {
|
||||
return cmNoop();
|
||||
}
|
||||
|
||||
tinymce.each(methods.split(' '), function(method) {
|
||||
obj[method] = _noop;
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
editor.controlManager = {
|
||||
buttons: {},
|
||||
|
||||
setDisabled: function(name, state) {
|
||||
log("controlManager.setDisabled(..)");
|
||||
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].disabled(state);
|
||||
}
|
||||
},
|
||||
|
||||
setActive: function(name, state) {
|
||||
log("controlManager.setActive(..)");
|
||||
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].active(state);
|
||||
}
|
||||
},
|
||||
|
||||
onAdd: new Dispatcher(),
|
||||
onPostRender: new Dispatcher(),
|
||||
|
||||
add: function(obj) {
|
||||
return obj;
|
||||
},
|
||||
createButton: cmNoop,
|
||||
createColorSplitButton: cmNoop,
|
||||
createControl: cmNoop,
|
||||
createDropMenu: cmNoop,
|
||||
createListBox: cmNoop,
|
||||
createMenuButton: cmNoop,
|
||||
createSeparator: cmNoop,
|
||||
createSplitButton: cmNoop,
|
||||
createToolbar: cmNoop,
|
||||
createToolbarGroup: cmNoop,
|
||||
destroy: noop,
|
||||
get: noop,
|
||||
setControlType: cmNoop
|
||||
};
|
||||
|
||||
patchEditorEvents("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate", "editor");
|
||||
patchEditorEvents("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset");
|
||||
patchEditorEvents("BeforeExecCommand ExecCommand", "command ui value args"); // args.terminate not supported
|
||||
patchEditorEvents("PreProcess PostProcess LoadContent SaveContent Change");
|
||||
patchEditorEvents("BeforeSetContent BeforeGetContent SetContent GetContent", filterSelectionEvents(false));
|
||||
patchEditorEvents("SetProgressState", "state time");
|
||||
patchEditorEvents("VisualAid", "element hasVisual");
|
||||
patchEditorEvents("Undo Redo", convertUndoEventArgs);
|
||||
|
||||
patchEditorEvents("NodeChange", function(type, e) {
|
||||
return [
|
||||
editor.controlManager,
|
||||
e.element,
|
||||
editor.selection.isCollapsed(),
|
||||
e
|
||||
];
|
||||
});
|
||||
|
||||
var originalAddButton = editor.addButton;
|
||||
editor.addButton = function(name, settings) {
|
||||
var originalOnPostRender, string, translated;
|
||||
|
||||
function patchedPostRender() {
|
||||
editor.controlManager.buttons[name] = this;
|
||||
|
||||
if (originalOnPostRender) {
|
||||
return originalOnPostRender.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
for (var key in settings) {
|
||||
if (key.toLowerCase() === "onpostrender") {
|
||||
originalOnPostRender = settings[key];
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
}
|
||||
|
||||
if (!originalOnPostRender) {
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
|
||||
if ( settings.title ) {
|
||||
// WP
|
||||
string = (editor.settings.language || "en") + "." + settings.title;
|
||||
translated = tinymce.i18n.translate(string);
|
||||
|
||||
if ( string !== translated ) {
|
||||
settings.title = translated;
|
||||
}
|
||||
// WP end
|
||||
}
|
||||
|
||||
return originalAddButton.call(this, name, settings);
|
||||
};
|
||||
|
||||
editor.on('init', function() {
|
||||
var undoManager = editor.undoManager, selection = editor.selection;
|
||||
|
||||
undoManager.onUndo = new Dispatcher(editor, "Undo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onRedo = new Dispatcher(editor, "Redo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onBeforeAdd = new Dispatcher(editor, "BeforeAddUndo", null, undoManager);
|
||||
undoManager.onAdd = new Dispatcher(editor, "AddUndo", null, undoManager);
|
||||
|
||||
selection.onBeforeGetContent = new Dispatcher(editor, "BeforeGetContent", filterSelectionEvents(true), selection);
|
||||
selection.onGetContent = new Dispatcher(editor, "GetContent", filterSelectionEvents(true), selection);
|
||||
selection.onBeforeSetContent = new Dispatcher(editor, "BeforeSetContent", filterSelectionEvents(true), selection);
|
||||
selection.onSetContent = new Dispatcher(editor, "SetContent", filterSelectionEvents(true), selection);
|
||||
});
|
||||
|
||||
editor.on('BeforeRenderUI', function() {
|
||||
var windowManager = editor.windowManager;
|
||||
|
||||
windowManager.onOpen = new Dispatcher();
|
||||
windowManager.onClose = new Dispatcher();
|
||||
windowManager.createInstance = function(className, a, b, c, d, e) {
|
||||
log("windowManager.createInstance(..)");
|
||||
|
||||
var constr = tinymce.resolve(className);
|
||||
return new constr(a, b, c, d, e);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
tinymce.on('SetupEditor', patchEditor);
|
||||
tinymce.PluginManager.add("compat3x", patchEditor);
|
||||
|
||||
tinymce.addI18n = function(prefix, o) {
|
||||
var I18n = tinymce.util.I18n, each = tinymce.each;
|
||||
|
||||
if (typeof prefix == "string" && prefix.indexOf('.') === -1) {
|
||||
I18n.add(prefix, o);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tinymce.is(prefix, 'string')) {
|
||||
each(prefix, function(o, lc) {
|
||||
each(o, function(o, g) {
|
||||
each(o, function(o, k) {
|
||||
if (g === 'common') {
|
||||
I18n.data[lc + '.' + k] = o;
|
||||
} else {
|
||||
I18n.data[lc + '.' + g + '.' + k] = o;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
each(o, function(o, k) {
|
||||
I18n.data[prefix + '.' + k] = o;
|
||||
});
|
||||
}
|
||||
};
|
||||
})(tinymce);
|
||||
1
wp-includes/js/tinymce/plugins/compat3x/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/compat3x/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a){function b(){}function c(a){!f&&window&&window.console&&(f=!0,console.log("Deprecated TinyMCE API call: "+a))}function d(a,d,e,f){return a=a||this,d?(this.add=function(b,g,h){function i(c){var h=[];if("string"==typeof e&&(e=e.split(" ")),e&&"function"!=typeof e)for(var i=0;i<e.length;i++)h.push(c[e[i]]);("function"!=typeof e||(h=e(d,c,a)))&&(e||(h=[c]),h.unshift(f||a),b.apply(g||f||a,h)===!1&&c.stopImmediatePropagation())}return c("<target>.on"+d+".add(..)"),a.on(d,i,h),i},this.addToTop=function(a,b){this.add(a,b,!0)},this.remove=function(b){return a.off(d,b)},void(this.dispatch=function(){return a.fire(d),!0})):void(this.add=this.addToTop=this.remove=this.dispatch=b)}function e(e){function f(b,c){a.each(b.split(" "),function(a){e["on"+a]=new d(e,a,c)})}function g(a,b,c){return[b.level,c]}function h(a){return function(b,c){return!c.selection&&!a||c.selection==a?[c]:void 0}}function i(){function b(){return i()}var d={},e="add addMenu addSeparator collapse createMenu destroy displayColor expand focus getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex setActive setAriaProperty setColor setDisabled setSelected setState showMenu update";return c("editor.controlManager.*"),a.each(e.split(" "),function(a){d[a]=b}),d}if(!e.controlManager){e.controlManager={buttons:{},setDisabled:function(a,b){c("controlManager.setDisabled(..)"),this.buttons[a]&&this.buttons[a].disabled(b)},setActive:function(a,b){c("controlManager.setActive(..)"),this.buttons[a]&&this.buttons[a].active(b)},onAdd:new d,onPostRender:new d,add:function(a){return a},createButton:i,createColorSplitButton:i,createControl:i,createDropMenu:i,createListBox:i,createMenuButton:i,createSeparator:i,createSplitButton:i,createToolbar:i,createToolbarGroup:i,destroy:b,get:b,setControlType:i},f("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),f("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),f("BeforeExecCommand ExecCommand","command ui value args"),f("PreProcess PostProcess LoadContent SaveContent Change"),f("BeforeSetContent BeforeGetContent SetContent GetContent",h(!1)),f("SetProgressState","state time"),f("VisualAid","element hasVisual"),f("Undo Redo",g),f("NodeChange",function(a,b){return[e.controlManager,b.element,e.selection.isCollapsed(),b]});var j=e.addButton;e.addButton=function(b,c){function d(){return e.controlManager.buttons[b]=this,f?f.call(this):void 0}var f,g,h;for(var i in c)"onpostrender"===i.toLowerCase()&&(f=c[i],c.onPostRender=d);return f||(c.onPostRender=d),c.title&&(g=(e.settings.language||"en")+"."+c.title,h=a.i18n.translate(g),g!==h&&(c.title=h)),j.call(this,b,c)},e.on("init",function(){var a=e.undoManager,b=e.selection;a.onUndo=new d(e,"Undo",g,null,a),a.onRedo=new d(e,"Redo",g,null,a),a.onBeforeAdd=new d(e,"BeforeAddUndo",null,a),a.onAdd=new d(e,"AddUndo",null,a),b.onBeforeGetContent=new d(e,"BeforeGetContent",h(!0),b),b.onGetContent=new d(e,"GetContent",h(!0),b),b.onBeforeSetContent=new d(e,"BeforeSetContent",h(!0),b),b.onSetContent=new d(e,"SetContent",h(!0),b)}),e.on("BeforeRenderUI",function(){var b=e.windowManager;b.onOpen=new d,b.onClose=new d,b.createInstance=function(b,d,e,f,g,h){c("windowManager.createInstance(..)");var i=a.resolve(b);return new i(d,e,f,g,h)}})}}var f;a.util.Dispatcher=d,a.onBeforeUnload=new d(a,"BeforeUnload"),a.onAddEditor=new d(a,"AddEditor","editor"),a.onRemoveEditor=new d(a,"RemoveEditor","editor"),a.util.Cookie={get:b,getHash:b,remove:b,set:b,setHash:b},a.on("SetupEditor",e),a.PluginManager.add("compat3x",e),a.addI18n=function(b,c){var d=a.util.I18n,e=a.each;return"string"==typeof b&&-1===b.indexOf(".")?void d.add(b,c):void(a.is(b,"string")?e(c,function(a,c){d.data[b+"."+c]=a}):e(b,function(a,b){e(a,function(a,c){e(a,function(a,e){"common"===c?d.data[b+"."+e]=a:d.data[b+"."+c+"."+e]=a})})}))}}(tinymce);
|
||||
64
wp-includes/js/tinymce/plugins/directionality/plugin.js
Normal file
64
wp-includes/js/tinymce/plugins/directionality/plugin.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('directionality', function(editor) {
|
||||
function setDir(dir) {
|
||||
var dom = editor.dom, curDir, blocks = editor.selection.getSelectedBlocks();
|
||||
|
||||
if (blocks.length) {
|
||||
curDir = dom.getAttrib(blocks[0], "dir");
|
||||
|
||||
tinymce.each(blocks, function(block) {
|
||||
// Add dir to block if the parent block doesn't already have that dir
|
||||
if (!dom.getParent(block.parentNode, "*[dir='" + dir + "']", dom.getRoot())) {
|
||||
if (curDir != dir) {
|
||||
dom.setAttrib(block, "dir", dir);
|
||||
} else {
|
||||
dom.setAttrib(block, "dir", null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
function generateSelector(dir) {
|
||||
var selector = [];
|
||||
|
||||
tinymce.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function(name) {
|
||||
selector.push(name + '[dir=' + dir + ']');
|
||||
});
|
||||
|
||||
return selector.join(',');
|
||||
}
|
||||
|
||||
editor.addCommand('mceDirectionLTR', function() {
|
||||
setDir("ltr");
|
||||
});
|
||||
|
||||
editor.addCommand('mceDirectionRTL', function() {
|
||||
setDir("rtl");
|
||||
});
|
||||
|
||||
editor.addButton('ltr', {
|
||||
title: 'Left to right',
|
||||
cmd: 'mceDirectionLTR',
|
||||
stateSelector: generateSelector('ltr')
|
||||
});
|
||||
|
||||
editor.addButton('rtl', {
|
||||
title: 'Right to left',
|
||||
cmd: 'mceDirectionRTL',
|
||||
stateSelector: generateSelector('rtl')
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/directionality/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/directionality/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("directionality",function(a){function b(b){var c,d=a.dom,e=a.selection.getSelectedBlocks();e.length&&(c=d.getAttrib(e[0],"dir"),tinymce.each(e,function(a){d.getParent(a.parentNode,"*[dir='"+b+"']",d.getRoot())||(c!=b?d.setAttrib(a,"dir",b):d.setAttrib(a,"dir",null))}),a.nodeChanged())}function c(a){var b=[];return tinymce.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(c){b.push(c+"[dir="+a+"]")}),b.join(",")}a.addCommand("mceDirectionLTR",function(){b("ltr")}),a.addCommand("mceDirectionRTL",function(){b("rtl")}),a.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:c("ltr")}),a.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:c("rtl")})});
|
||||
136
wp-includes/js/tinymce/plugins/fullscreen/plugin.js
Normal file
136
wp-includes/js/tinymce/plugins/fullscreen/plugin.js
Normal file
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('fullscreen', function(editor) {
|
||||
var fullscreenState = false, DOM = tinymce.DOM, iframeWidth, iframeHeight, resizeHandler;
|
||||
var containerWidth, containerHeight;
|
||||
|
||||
if (editor.settings.inline) {
|
||||
return;
|
||||
}
|
||||
|
||||
function getWindowSize() {
|
||||
var w, h, win = window, doc = document;
|
||||
var body = doc.body;
|
||||
|
||||
// Old IE
|
||||
if (body.offsetWidth) {
|
||||
w = body.offsetWidth;
|
||||
h = body.offsetHeight;
|
||||
}
|
||||
|
||||
// Modern browsers
|
||||
if (win.innerWidth && win.innerHeight) {
|
||||
w = win.innerWidth;
|
||||
h = win.innerHeight;
|
||||
}
|
||||
|
||||
return {w: w, h: h};
|
||||
}
|
||||
|
||||
function toggleFullscreen() {
|
||||
var body = document.body, documentElement = document.documentElement, editorContainerStyle;
|
||||
var editorContainer, iframe, iframeStyle;
|
||||
|
||||
function resize() {
|
||||
DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight));
|
||||
}
|
||||
|
||||
fullscreenState = !fullscreenState;
|
||||
|
||||
editorContainer = editor.getContainer();
|
||||
editorContainerStyle = editorContainer.style;
|
||||
iframe = editor.getContentAreaContainer().firstChild;
|
||||
iframeStyle = iframe.style;
|
||||
|
||||
if (fullscreenState) {
|
||||
iframeWidth = iframeStyle.width;
|
||||
iframeHeight = iframeStyle.height;
|
||||
iframeStyle.width = iframeStyle.height = '100%';
|
||||
containerWidth = editorContainerStyle.width;
|
||||
containerHeight = editorContainerStyle.height;
|
||||
editorContainerStyle.width = editorContainerStyle.height = '';
|
||||
|
||||
DOM.addClass(body, 'mce-fullscreen');
|
||||
DOM.addClass(documentElement, 'mce-fullscreen');
|
||||
DOM.addClass(editorContainer, 'mce-fullscreen');
|
||||
|
||||
DOM.bind(window, 'resize', resize);
|
||||
resize();
|
||||
resizeHandler = resize;
|
||||
} else {
|
||||
iframeStyle.width = iframeWidth;
|
||||
iframeStyle.height = iframeHeight;
|
||||
|
||||
if (containerWidth) {
|
||||
editorContainerStyle.width = containerWidth;
|
||||
}
|
||||
|
||||
if (containerHeight) {
|
||||
editorContainerStyle.height = containerHeight;
|
||||
}
|
||||
|
||||
DOM.removeClass(body, 'mce-fullscreen');
|
||||
DOM.removeClass(documentElement, 'mce-fullscreen');
|
||||
DOM.removeClass(editorContainer, 'mce-fullscreen');
|
||||
DOM.unbind(window, 'resize', resizeHandler);
|
||||
}
|
||||
|
||||
editor.fire('FullscreenStateChanged', {state: fullscreenState});
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
editor.addShortcut('Meta+Alt+F', '', toggleFullscreen);
|
||||
});
|
||||
|
||||
editor.on('remove', function() {
|
||||
if (resizeHandler) {
|
||||
DOM.unbind(window, 'resize', resizeHandler);
|
||||
}
|
||||
});
|
||||
|
||||
editor.addCommand('mceFullScreen', toggleFullscreen);
|
||||
|
||||
editor.addMenuItem('fullscreen', {
|
||||
text: 'Fullscreen',
|
||||
shortcut: 'Meta+Alt+F',
|
||||
selectable: true,
|
||||
onClick: toggleFullscreen,
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('FullscreenStateChanged', function(e) {
|
||||
self.active(e.state);
|
||||
});
|
||||
},
|
||||
context: 'view'
|
||||
});
|
||||
|
||||
editor.addButton('fullscreen', {
|
||||
tooltip: 'Fullscreen',
|
||||
shortcut: 'Meta+Alt+F',
|
||||
onClick: toggleFullscreen,
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on('FullscreenStateChanged', function(e) {
|
||||
self.active(e.state);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
isFullscreen: function() {
|
||||
return fullscreenState;
|
||||
}
|
||||
};
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("fullscreen",function(a){function b(){var a,b,c=window,d=document,e=d.body;return e.offsetWidth&&(a=e.offsetWidth,b=e.offsetHeight),c.innerWidth&&c.innerHeight&&(a=c.innerWidth,b=c.innerHeight),{w:a,h:b}}function c(){function c(){j.setStyle(m,"height",b().h-(l.clientHeight-m.clientHeight))}var k,l,m,n,o=document.body,p=document.documentElement;i=!i,l=a.getContainer(),k=l.style,m=a.getContentAreaContainer().firstChild,n=m.style,i?(d=n.width,e=n.height,n.width=n.height="100%",g=k.width,h=k.height,k.width=k.height="",j.addClass(o,"mce-fullscreen"),j.addClass(p,"mce-fullscreen"),j.addClass(l,"mce-fullscreen"),j.bind(window,"resize",c),c(),f=c):(n.width=d,n.height=e,g&&(k.width=g),h&&(k.height=h),j.removeClass(o,"mce-fullscreen"),j.removeClass(p,"mce-fullscreen"),j.removeClass(l,"mce-fullscreen"),j.unbind(window,"resize",f)),a.fire("FullscreenStateChanged",{state:i})}var d,e,f,g,h,i=!1,j=tinymce.DOM;return a.settings.inline?void 0:(a.on("init",function(){a.addShortcut("Meta+Alt+F","",c)}),a.on("remove",function(){f&&j.unbind(window,"resize",f)}),a.addCommand("mceFullScreen",c),a.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Meta+Alt+F",selectable:!0,onClick:c,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})},context:"view"}),a.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Meta+Alt+F",onClick:c,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})}}),{isFullscreen:function(){return i}})});
|
||||
30
wp-includes/js/tinymce/plugins/hr/plugin.js
Normal file
30
wp-includes/js/tinymce/plugins/hr/plugin.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('hr', function(editor) {
|
||||
editor.addCommand('InsertHorizontalRule', function() {
|
||||
editor.execCommand('mceInsertContent', false, '<hr />');
|
||||
});
|
||||
|
||||
editor.addButton('hr', {
|
||||
icon: 'hr',
|
||||
tooltip: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule'
|
||||
});
|
||||
|
||||
editor.addMenuItem('hr', {
|
||||
icon: 'hr',
|
||||
text: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule',
|
||||
context: 'insert'
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/hr/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/hr/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("hr",function(a){a.addCommand("InsertHorizontalRule",function(){a.execCommand("mceInsertContent",!1,"<hr />")}),a.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),a.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})});
|
||||
569
wp-includes/js/tinymce/plugins/image/plugin.js
Normal file
569
wp-includes/js/tinymce/plugins/image/plugin.js
Normal file
@@ -0,0 +1,569 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('image', function(editor) {
|
||||
function getImageSize(url, callback) {
|
||||
var img = document.createElement('img');
|
||||
|
||||
function done(width, height) {
|
||||
if (img.parentNode) {
|
||||
img.parentNode.removeChild(img);
|
||||
}
|
||||
|
||||
callback({width: width, height: height});
|
||||
}
|
||||
|
||||
img.onload = function() {
|
||||
done(Math.max(img.width, img.clientWidth), Math.max(img.height, img.clientHeight));
|
||||
};
|
||||
|
||||
img.onerror = function() {
|
||||
done();
|
||||
};
|
||||
|
||||
var style = img.style;
|
||||
style.visibility = 'hidden';
|
||||
style.position = 'fixed';
|
||||
style.bottom = style.left = 0;
|
||||
style.width = style.height = 'auto';
|
||||
|
||||
document.body.appendChild(img);
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
function buildListItems(inputList, itemCallback, startItems) {
|
||||
function appendItems(values, output) {
|
||||
output = output || [];
|
||||
|
||||
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) {
|
||||
return function() {
|
||||
var imageList = editor.settings.image_list;
|
||||
|
||||
if (typeof imageList == "string") {
|
||||
tinymce.util.XHR.send({
|
||||
url: imageList,
|
||||
success: function(text) {
|
||||
callback(tinymce.util.JSON.parse(text));
|
||||
}
|
||||
});
|
||||
} else if (typeof imageList == "function") {
|
||||
imageList(callback);
|
||||
} else {
|
||||
callback(imageList);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function showDialog(imageList) {
|
||||
var win, data = {}, dom = editor.dom, imgElm = editor.selection.getNode();
|
||||
var width, height, imageListCtrl, classListCtrl, imageDimensions = editor.settings.image_dimensions !== false;
|
||||
|
||||
function recalcSize() {
|
||||
var widthCtrl, heightCtrl, newWidth, newHeight;
|
||||
|
||||
widthCtrl = win.find('#width')[0];
|
||||
heightCtrl = win.find('#height')[0];
|
||||
|
||||
if (!widthCtrl || !heightCtrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
newWidth = widthCtrl.value();
|
||||
newHeight = heightCtrl.value();
|
||||
|
||||
if (win.find('#constrain')[0].checked() && width && height && newWidth && newHeight) {
|
||||
if (width != newWidth) {
|
||||
newHeight = Math.round((newWidth / width) * newHeight);
|
||||
|
||||
if (!isNaN(newHeight)) {
|
||||
heightCtrl.value(newHeight);
|
||||
}
|
||||
} else {
|
||||
newWidth = Math.round((newHeight / height) * newWidth);
|
||||
|
||||
if (!isNaN(newWidth)) {
|
||||
widthCtrl.value(newWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
}
|
||||
|
||||
function onSubmitForm() {
|
||||
function waitLoad(imgElm) {
|
||||
function selectImage() {
|
||||
imgElm.onload = imgElm.onerror = null;
|
||||
|
||||
if (editor.selection) {
|
||||
editor.selection.select(imgElm);
|
||||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
imgElm.onload = function() {
|
||||
if (!data.width && !data.height && imageDimensions) {
|
||||
dom.setAttribs(imgElm, {
|
||||
width: imgElm.clientWidth,
|
||||
height: imgElm.clientHeight
|
||||
});
|
||||
//WP
|
||||
editor.fire( 'wpNewImageRefresh', { node: imgElm } );
|
||||
}
|
||||
|
||||
selectImage();
|
||||
};
|
||||
|
||||
imgElm.onerror = selectImage;
|
||||
}
|
||||
|
||||
updateStyle();
|
||||
recalcSize();
|
||||
|
||||
data = tinymce.extend(data, win.toJSON());
|
||||
var caption = data.caption; // WP
|
||||
|
||||
if (!data.alt) {
|
||||
data.alt = '';
|
||||
}
|
||||
|
||||
if (!data.title) {
|
||||
data.title = '';
|
||||
}
|
||||
|
||||
if (data.width === '') {
|
||||
data.width = null;
|
||||
}
|
||||
|
||||
if (data.height === '') {
|
||||
data.height = null;
|
||||
}
|
||||
|
||||
if (!data.style) {
|
||||
data.style = null;
|
||||
}
|
||||
|
||||
// Setup new data excluding style properties
|
||||
/*eslint dot-notation: 0*/
|
||||
data = {
|
||||
src: data.src,
|
||||
alt: data.alt,
|
||||
title: data.title,
|
||||
width: data.width,
|
||||
height: data.height,
|
||||
style: data.style,
|
||||
"class": data["class"]
|
||||
};
|
||||
|
||||
editor.undoManager.transact(function() {
|
||||
// WP
|
||||
var eventData = { node: imgElm, data: data, caption: caption };
|
||||
|
||||
editor.fire( 'wpImageFormSubmit', { imgData: eventData } );
|
||||
|
||||
if ( eventData.cancel ) {
|
||||
waitLoad( eventData.node );
|
||||
return;
|
||||
}
|
||||
// WP end
|
||||
|
||||
if (!data.src) {
|
||||
if (imgElm) {
|
||||
dom.remove(imgElm);
|
||||
editor.focus();
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.title === "") {
|
||||
data.title = null;
|
||||
}
|
||||
|
||||
if (!imgElm) {
|
||||
data.id = '__mcenew';
|
||||
editor.focus();
|
||||
editor.selection.setContent(dom.createHTML('img', data));
|
||||
imgElm = dom.get('__mcenew');
|
||||
dom.setAttrib(imgElm, 'id', null);
|
||||
} else {
|
||||
dom.setAttribs(imgElm, data);
|
||||
}
|
||||
|
||||
waitLoad(imgElm);
|
||||
});
|
||||
}
|
||||
|
||||
function removePixelSuffix(value) {
|
||||
if (value) {
|
||||
value = value.replace(/px$/, '');
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function srcChange(e) {
|
||||
var srcURL, prependURL, absoluteURLPattern, meta = e.meta || {};
|
||||
|
||||
if (imageListCtrl) {
|
||||
imageListCtrl.value(editor.convertURL(this.value(), 'src'));
|
||||
}
|
||||
|
||||
tinymce.each(meta, function(value, key) {
|
||||
win.find('#' + key).value(value);
|
||||
});
|
||||
|
||||
if (!meta.width && !meta.height) {
|
||||
srcURL = editor.convertURL(this.value(), 'src');
|
||||
|
||||
// Pattern test the src url and make sure we haven't already prepended the url
|
||||
prependURL = editor.settings.image_prepend_url;
|
||||
absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i');
|
||||
if (prependURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, prependURL.length) !== prependURL) {
|
||||
srcURL = prependURL + srcURL;
|
||||
}
|
||||
|
||||
this.value(srcURL);
|
||||
|
||||
getImageSize(editor.documentBaseURI.toAbsolute(this.value()), function(data) {
|
||||
if (data.width && data.height && imageDimensions) {
|
||||
width = data.width;
|
||||
height = data.height;
|
||||
|
||||
win.find('#width').value(width);
|
||||
win.find('#height').value(height);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
width = dom.getAttrib(imgElm, 'width');
|
||||
height = dom.getAttrib(imgElm, 'height');
|
||||
|
||||
if (imgElm.nodeName == 'IMG' && !imgElm.getAttribute('data-mce-object') && !imgElm.getAttribute('data-mce-placeholder')) {
|
||||
data = {
|
||||
src: dom.getAttrib(imgElm, 'src'),
|
||||
alt: dom.getAttrib(imgElm, 'alt'),
|
||||
title: dom.getAttrib(imgElm, 'title'),
|
||||
"class": dom.getAttrib(imgElm, 'class'),
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
|
||||
// WP
|
||||
editor.fire( 'wpLoadImageData', { imgData: { data: data, node: imgElm } } );
|
||||
} else {
|
||||
imgElm = null;
|
||||
}
|
||||
|
||||
if (imageList) {
|
||||
imageListCtrl = {
|
||||
type: 'listbox',
|
||||
label: 'Image list',
|
||||
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'),
|
||||
onselect: function(e) {
|
||||
var altCtrl = win.find('#alt');
|
||||
|
||||
if (!altCtrl.value() || (e.lastControl && altCtrl.value() == e.lastControl.text())) {
|
||||
altCtrl.value(e.control.text());
|
||||
}
|
||||
|
||||
win.find('#src').value(e.control.value()).fire('change');
|
||||
},
|
||||
onPostRender: function() {
|
||||
/*eslint consistent-this: 0*/
|
||||
imageListCtrl = this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (editor.settings.image_class_list) {
|
||||
classListCtrl = {
|
||||
name: 'class',
|
||||
type: 'listbox',
|
||||
label: '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]});
|
||||
};
|
||||
}
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
// General settings shared between simple and advanced dialogs
|
||||
var generalFormItems = [
|
||||
{
|
||||
name: 'src',
|
||||
type: 'filepicker',
|
||||
filetype: 'image',
|
||||
label: 'Source',
|
||||
autofocus: true,
|
||||
onchange: srcChange
|
||||
},
|
||||
imageListCtrl
|
||||
];
|
||||
|
||||
if (editor.settings.image_description !== false) {
|
||||
generalFormItems.push({name: 'alt', type: 'textbox', label: 'Image description'});
|
||||
}
|
||||
|
||||
if (editor.settings.image_title) {
|
||||
generalFormItems.push({name: 'title', type: 'textbox', label: 'Image Title'});
|
||||
}
|
||||
|
||||
if (imageDimensions) {
|
||||
generalFormItems.push({
|
||||
type: 'container',
|
||||
label: 'Dimensions',
|
||||
layout: 'flex',
|
||||
direction: 'row',
|
||||
align: 'center',
|
||||
spacing: 5,
|
||||
items: [
|
||||
{name: 'width', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Width'},
|
||||
{type: 'label', text: 'x'},
|
||||
{name: 'height', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Height'},
|
||||
{name: 'constrain', type: 'checkbox', checked: true, text: 'Constrain proportions'}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
generalFormItems.push(classListCtrl);
|
||||
|
||||
// WP
|
||||
editor.fire( 'wpLoadImageForm', { data: generalFormItems } );
|
||||
|
||||
function mergeMargins(css) {
|
||||
if (css.margin) {
|
||||
|
||||
var splitMargin = css.margin.split(" ");
|
||||
|
||||
switch (splitMargin.length) {
|
||||
case 1: //margin: toprightbottomleft;
|
||||
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
||||
css['margin-right'] = css['margin-right'] || splitMargin[0];
|
||||
css['margin-bottom'] = css['margin-bottom'] || splitMargin[0];
|
||||
css['margin-left'] = css['margin-left'] || splitMargin[0];
|
||||
break;
|
||||
case 2: //margin: topbottom rightleft;
|
||||
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
||||
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
||||
css['margin-bottom'] = css['margin-bottom'] || splitMargin[0];
|
||||
css['margin-left'] = css['margin-left'] || splitMargin[1];
|
||||
break;
|
||||
case 3: //margin: top rightleft bottom;
|
||||
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
||||
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
||||
css['margin-bottom'] = css['margin-bottom'] || splitMargin[2];
|
||||
css['margin-left'] = css['margin-left'] || splitMargin[1];
|
||||
break;
|
||||
case 4: //margin: top right bottom left;
|
||||
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
||||
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
||||
css['margin-bottom'] = css['margin-bottom'] || splitMargin[2];
|
||||
css['margin-left'] = css['margin-left'] || splitMargin[3];
|
||||
}
|
||||
delete css.margin;
|
||||
}
|
||||
return css;
|
||||
}
|
||||
|
||||
function updateStyle() {
|
||||
function addPixelSuffix(value) {
|
||||
if (value.length > 0 && /^[0-9]+$/.test(value)) {
|
||||
value += 'px';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!editor.settings.image_advtab) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = win.toJSON(),
|
||||
css = dom.parseStyle(data.style);
|
||||
|
||||
css = mergeMargins(css);
|
||||
|
||||
if (data.vspace) {
|
||||
css['margin-top'] = css['margin-bottom'] = addPixelSuffix(data.vspace);
|
||||
}
|
||||
if (data.hspace) {
|
||||
css['margin-left'] = css['margin-right'] = addPixelSuffix(data.hspace);
|
||||
}
|
||||
if (data.border) {
|
||||
css['border-width'] = addPixelSuffix(data.border);
|
||||
}
|
||||
|
||||
win.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css))));
|
||||
}
|
||||
|
||||
function updateVSpaceHSpaceBorder() {
|
||||
if (!editor.settings.image_advtab) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = win.toJSON(),
|
||||
css = dom.parseStyle(data.style);
|
||||
|
||||
win.find('#vspace').value("");
|
||||
win.find('#hspace').value("");
|
||||
|
||||
css = mergeMargins(css);
|
||||
|
||||
//Move opposite equal margins to vspace/hspace field
|
||||
if ((css['margin-top'] && css['margin-bottom']) || (css['margin-right'] && css['margin-left'])) {
|
||||
if (css['margin-top'] === css['margin-bottom']) {
|
||||
win.find('#vspace').value(removePixelSuffix(css['margin-top']));
|
||||
} else {
|
||||
win.find('#vspace').value('');
|
||||
}
|
||||
if (css['margin-right'] === css['margin-left']) {
|
||||
win.find('#hspace').value(removePixelSuffix(css['margin-right']));
|
||||
} else {
|
||||
win.find('#hspace').value('');
|
||||
}
|
||||
}
|
||||
|
||||
//Move border-width
|
||||
if (css['border-width']) {
|
||||
win.find('#border').value(removePixelSuffix(css['border-width']));
|
||||
}
|
||||
|
||||
win.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css))));
|
||||
|
||||
}
|
||||
|
||||
if (editor.settings.image_advtab) {
|
||||
// Parse styles from img
|
||||
if (imgElm) {
|
||||
if (imgElm.style.marginLeft && imgElm.style.marginRight && imgElm.style.marginLeft === imgElm.style.marginRight) {
|
||||
data.hspace = removePixelSuffix(imgElm.style.marginLeft);
|
||||
}
|
||||
if (imgElm.style.marginTop && imgElm.style.marginBottom && imgElm.style.marginTop === imgElm.style.marginBottom) {
|
||||
data.vspace = removePixelSuffix(imgElm.style.marginTop);
|
||||
}
|
||||
if (imgElm.style.borderWidth) {
|
||||
data.border = removePixelSuffix(imgElm.style.borderWidth);
|
||||
}
|
||||
|
||||
data.style = editor.dom.serializeStyle(editor.dom.parseStyle(editor.dom.getAttrib(imgElm, 'style')));
|
||||
}
|
||||
|
||||
// Advanced dialog shows general+advanced tabs
|
||||
win = editor.windowManager.open({
|
||||
title: 'Insert/edit image',
|
||||
data: data,
|
||||
bodyType: 'tabpanel',
|
||||
body: [
|
||||
{
|
||||
title: 'General',
|
||||
type: 'form',
|
||||
items: generalFormItems
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Advanced',
|
||||
type: 'form',
|
||||
pack: 'start',
|
||||
items: [
|
||||
{
|
||||
label: 'Style',
|
||||
name: 'style',
|
||||
type: 'textbox',
|
||||
onchange: updateVSpaceHSpaceBorder
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
layout: 'grid',
|
||||
packV: 'start',
|
||||
columns: 2,
|
||||
padding: 0,
|
||||
alignH: ['left', 'right'],
|
||||
defaults: {
|
||||
type: 'textbox',
|
||||
maxWidth: 50,
|
||||
onchange: updateStyle
|
||||
},
|
||||
items: [
|
||||
{label: 'Vertical space', name: 'vspace'},
|
||||
{label: 'Horizontal space', name: 'hspace'},
|
||||
{label: 'Border', name: 'border'}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
onSubmit: onSubmitForm
|
||||
});
|
||||
} else {
|
||||
// Simple default dialog
|
||||
win = editor.windowManager.open({
|
||||
title: 'Insert/edit image',
|
||||
data: data,
|
||||
body: generalFormItems,
|
||||
onSubmit: onSubmitForm
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
editor.addButton('image', {
|
||||
icon: 'image',
|
||||
tooltip: 'Insert/edit image',
|
||||
onclick: createImageList(showDialog),
|
||||
stateSelector: 'img:not([data-mce-object],[data-mce-placeholder])'
|
||||
});
|
||||
|
||||
editor.addMenuItem('image', {
|
||||
icon: 'image',
|
||||
text: 'Insert/edit image',
|
||||
onclick: createImageList(showDialog),
|
||||
context: 'insert',
|
||||
prependToContext: true
|
||||
});
|
||||
|
||||
editor.addCommand('mceImage', createImageList(showDialog));
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/image/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/image/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
811
wp-includes/js/tinymce/plugins/lists/plugin.js
Normal file
811
wp-includes/js/tinymce/plugins/lists/plugin.js
Normal file
@@ -0,0 +1,811 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint consistent-this:0 */
|
||||
|
||||
tinymce.PluginManager.add('lists', function(editor) {
|
||||
var self = this;
|
||||
|
||||
function isListNode(node) {
|
||||
return node && (/^(OL|UL|DL)$/).test(node.nodeName);
|
||||
}
|
||||
|
||||
function isFirstChild(node) {
|
||||
return node.parentNode.firstChild == node;
|
||||
}
|
||||
|
||||
function isLastChild(node) {
|
||||
return node.parentNode.lastChild == node;
|
||||
}
|
||||
|
||||
function isTextBlock(node) {
|
||||
return node && !!editor.schema.getTextBlockElements()[node.nodeName];
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
var dom = editor.dom, selection = editor.selection;
|
||||
|
||||
/**
|
||||
* Returns a range bookmark. This will convert indexed bookmarks into temporary span elements with
|
||||
* index 0 so that they can be restored properly after the DOM has been modified. Text bookmarks will not have spans
|
||||
* added to them since they can be restored after a dom operation.
|
||||
*
|
||||
* So this: <p><b>|</b><b>|</b></p>
|
||||
* becomes: <p><b><span data-mce-type="bookmark">|</span></b><b data-mce-type="bookmark">|</span></b></p>
|
||||
*
|
||||
* @param {DOMRange} rng DOM Range to get bookmark on.
|
||||
* @return {Object} Bookmark object.
|
||||
*/
|
||||
function createBookmark(rng) {
|
||||
var bookmark = {};
|
||||
|
||||
function setupEndPoint(start) {
|
||||
var offsetNode, container, offset;
|
||||
|
||||
container = rng[start ? 'startContainer' : 'endContainer'];
|
||||
offset = rng[start ? 'startOffset' : 'endOffset'];
|
||||
|
||||
if (container.nodeType == 1) {
|
||||
offsetNode = dom.create('span', {'data-mce-type': 'bookmark'});
|
||||
|
||||
if (container.hasChildNodes()) {
|
||||
offset = Math.min(offset, container.childNodes.length - 1);
|
||||
|
||||
if (start) {
|
||||
container.insertBefore(offsetNode, container.childNodes[offset]);
|
||||
} else {
|
||||
dom.insertAfter(offsetNode, container.childNodes[offset]);
|
||||
}
|
||||
} else {
|
||||
container.appendChild(offsetNode);
|
||||
}
|
||||
|
||||
container = offsetNode;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
bookmark[start ? 'startContainer' : 'endContainer'] = container;
|
||||
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
|
||||
}
|
||||
|
||||
setupEndPoint(true);
|
||||
|
||||
if (!rng.collapsed) {
|
||||
setupEndPoint();
|
||||
}
|
||||
|
||||
return bookmark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the selection to the current bookmark and removes any selection container wrappers.
|
||||
*
|
||||
* @param {Object} bookmark Bookmark object to move selection to.
|
||||
*/
|
||||
function moveToBookmark(bookmark) {
|
||||
function restoreEndPoint(start) {
|
||||
var container, offset, node;
|
||||
|
||||
function nodeIndex(container) {
|
||||
var node = container.parentNode.firstChild, idx = 0;
|
||||
|
||||
while (node) {
|
||||
if (node == container) {
|
||||
return idx;
|
||||
}
|
||||
|
||||
// Skip data-mce-type=bookmark nodes
|
||||
if (node.nodeType != 1 || node.getAttribute('data-mce-type') != 'bookmark') {
|
||||
idx++;
|
||||
}
|
||||
|
||||
node = node.nextSibling;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
container = node = bookmark[start ? 'startContainer' : 'endContainer'];
|
||||
offset = bookmark[start ? 'startOffset' : 'endOffset'];
|
||||
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (container.nodeType == 1) {
|
||||
offset = nodeIndex(container);
|
||||
container = container.parentNode;
|
||||
dom.remove(node);
|
||||
}
|
||||
|
||||
bookmark[start ? 'startContainer' : 'endContainer'] = container;
|
||||
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
|
||||
}
|
||||
|
||||
restoreEndPoint(true);
|
||||
restoreEndPoint();
|
||||
|
||||
var rng = dom.createRng();
|
||||
|
||||
rng.setStart(bookmark.startContainer, bookmark.startOffset);
|
||||
|
||||
if (bookmark.endContainer) {
|
||||
rng.setEnd(bookmark.endContainer, bookmark.endOffset);
|
||||
}
|
||||
|
||||
selection.setRng(rng);
|
||||
}
|
||||
|
||||
function createNewTextBlock(contentNode, blockName) {
|
||||
var node, textBlock, fragment = dom.createFragment(), hasContentNode;
|
||||
var blockElements = editor.schema.getBlockElements();
|
||||
|
||||
if (editor.settings.forced_root_block) {
|
||||
blockName = blockName || editor.settings.forced_root_block;
|
||||
}
|
||||
|
||||
if (blockName) {
|
||||
textBlock = dom.create(blockName);
|
||||
|
||||
if (textBlock.tagName === editor.settings.forced_root_block) {
|
||||
dom.setAttribs(textBlock, editor.settings.forced_root_block_attrs);
|
||||
}
|
||||
|
||||
fragment.appendChild(textBlock);
|
||||
}
|
||||
|
||||
if (contentNode) {
|
||||
while ((node = contentNode.firstChild)) {
|
||||
var nodeName = node.nodeName;
|
||||
|
||||
if (!hasContentNode && (nodeName != 'SPAN' || node.getAttribute('data-mce-type') != 'bookmark')) {
|
||||
hasContentNode = true;
|
||||
}
|
||||
|
||||
if (blockElements[nodeName]) {
|
||||
fragment.appendChild(node);
|
||||
textBlock = null;
|
||||
} else {
|
||||
if (blockName) {
|
||||
if (!textBlock) {
|
||||
textBlock = dom.create(blockName);
|
||||
fragment.appendChild(textBlock);
|
||||
}
|
||||
|
||||
textBlock.appendChild(node);
|
||||
} else {
|
||||
fragment.appendChild(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!editor.settings.forced_root_block) {
|
||||
fragment.appendChild(dom.create('br'));
|
||||
} else {
|
||||
// BR is needed in empty blocks on non IE browsers
|
||||
if (!hasContentNode && (!tinymce.Env.ie || tinymce.Env.ie > 10)) {
|
||||
textBlock.appendChild(dom.create('br', {'data-mce-bogus': '1'}));
|
||||
}
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
function getSelectedListItems() {
|
||||
return tinymce.grep(selection.getSelectedBlocks(), function(block) {
|
||||
return /^(LI|DT|DD)$/.test(block.nodeName);
|
||||
});
|
||||
}
|
||||
|
||||
function splitList(ul, li, newBlock) {
|
||||
var tmpRng, fragment, bookmarks, node;
|
||||
|
||||
function removeAndKeepBookmarks(targetNode) {
|
||||
tinymce.each(bookmarks, function(node) {
|
||||
targetNode.parentNode.insertBefore(node, li.parentNode);
|
||||
});
|
||||
|
||||
dom.remove(targetNode);
|
||||
}
|
||||
|
||||
bookmarks = dom.select('span[data-mce-type="bookmark"]', ul);
|
||||
newBlock = newBlock || createNewTextBlock(li);
|
||||
tmpRng = dom.createRng();
|
||||
tmpRng.setStartAfter(li);
|
||||
tmpRng.setEndAfter(ul);
|
||||
fragment = tmpRng.extractContents();
|
||||
|
||||
for (node = fragment.firstChild; node; node = node.firstChild) {
|
||||
if (node.nodeName == 'LI' && dom.isEmpty(node)) {
|
||||
dom.remove(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dom.isEmpty(fragment)) {
|
||||
dom.insertAfter(fragment, ul);
|
||||
}
|
||||
|
||||
dom.insertAfter(newBlock, ul);
|
||||
|
||||
if (dom.isEmpty(li.parentNode)) {
|
||||
removeAndKeepBookmarks(li.parentNode);
|
||||
}
|
||||
|
||||
dom.remove(li);
|
||||
|
||||
if (dom.isEmpty(ul)) {
|
||||
dom.remove(ul);
|
||||
}
|
||||
}
|
||||
|
||||
function mergeWithAdjacentLists(listBlock) {
|
||||
var sibling, node;
|
||||
|
||||
sibling = listBlock.nextSibling;
|
||||
if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName) {
|
||||
while ((node = sibling.firstChild)) {
|
||||
listBlock.appendChild(node);
|
||||
}
|
||||
|
||||
dom.remove(sibling);
|
||||
}
|
||||
|
||||
sibling = listBlock.previousSibling;
|
||||
if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName) {
|
||||
while ((node = sibling.firstChild)) {
|
||||
listBlock.insertBefore(node, listBlock.firstChild);
|
||||
}
|
||||
|
||||
dom.remove(sibling);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the all lists in the specified element.
|
||||
*/
|
||||
function normalizeList(element) {
|
||||
tinymce.each(tinymce.grep(dom.select('ol,ul', element)), function(ul) {
|
||||
var sibling, parentNode = ul.parentNode;
|
||||
|
||||
// Move UL/OL to previous LI if it's the only child of a LI
|
||||
if (parentNode.nodeName == 'LI' && parentNode.firstChild == ul) {
|
||||
sibling = parentNode.previousSibling;
|
||||
if (sibling && sibling.nodeName == 'LI') {
|
||||
sibling.appendChild(ul);
|
||||
|
||||
if (dom.isEmpty(parentNode)) {
|
||||
dom.remove(parentNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append OL/UL to previous LI if it's in a parent OL/UL i.e. old HTML4
|
||||
if (isListNode(parentNode)) {
|
||||
sibling = parentNode.previousSibling;
|
||||
if (sibling && sibling.nodeName == 'LI') {
|
||||
sibling.appendChild(ul);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function outdent(li) {
|
||||
var ul = li.parentNode, ulParent = ul.parentNode, newBlock;
|
||||
|
||||
function removeEmptyLi(li) {
|
||||
if (dom.isEmpty(li)) {
|
||||
dom.remove(li);
|
||||
}
|
||||
}
|
||||
|
||||
if (li.nodeName == 'DD') {
|
||||
dom.rename(li, 'DT');
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isFirstChild(li) && isLastChild(li)) {
|
||||
if (ulParent.nodeName == "LI") {
|
||||
dom.insertAfter(li, ulParent);
|
||||
removeEmptyLi(ulParent);
|
||||
dom.remove(ul);
|
||||
} else if (isListNode(ulParent)) {
|
||||
dom.remove(ul, true);
|
||||
} else {
|
||||
ulParent.insertBefore(createNewTextBlock(li), ul);
|
||||
dom.remove(ul);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (isFirstChild(li)) {
|
||||
if (ulParent.nodeName == "LI") {
|
||||
dom.insertAfter(li, ulParent);
|
||||
li.appendChild(ul);
|
||||
removeEmptyLi(ulParent);
|
||||
} else if (isListNode(ulParent)) {
|
||||
ulParent.insertBefore(li, ul);
|
||||
} else {
|
||||
ulParent.insertBefore(createNewTextBlock(li), ul);
|
||||
dom.remove(li);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (isLastChild(li)) {
|
||||
if (ulParent.nodeName == "LI") {
|
||||
dom.insertAfter(li, ulParent);
|
||||
} else if (isListNode(ulParent)) {
|
||||
dom.insertAfter(li, ul);
|
||||
} else {
|
||||
dom.insertAfter(createNewTextBlock(li), ul);
|
||||
dom.remove(li);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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) {
|
||||
var sibling, newList;
|
||||
|
||||
function mergeLists(from, to) {
|
||||
var node;
|
||||
|
||||
if (isListNode(from)) {
|
||||
while ((node = li.lastChild.firstChild)) {
|
||||
to.appendChild(node);
|
||||
}
|
||||
|
||||
dom.remove(from);
|
||||
}
|
||||
}
|
||||
|
||||
if (li.nodeName == 'DT') {
|
||||
dom.rename(li, 'DD');
|
||||
return true;
|
||||
}
|
||||
|
||||
sibling = li.previousSibling;
|
||||
|
||||
if (sibling && isListNode(sibling)) {
|
||||
sibling.appendChild(li);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sibling && sibling.nodeName == 'LI' && isListNode(sibling.lastChild)) {
|
||||
sibling.lastChild.appendChild(li);
|
||||
mergeLists(li.lastChild, sibling.lastChild);
|
||||
return true;
|
||||
}
|
||||
|
||||
sibling = li.nextSibling;
|
||||
|
||||
if (sibling && isListNode(sibling)) {
|
||||
sibling.insertBefore(li, sibling.firstChild);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sibling && sibling.nodeName == 'LI' && isListNode(li.lastChild)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sibling = li.previousSibling;
|
||||
if (sibling && sibling.nodeName == 'LI') {
|
||||
newList = dom.create(li.parentNode.nodeName);
|
||||
sibling.appendChild(newList);
|
||||
newList.appendChild(li);
|
||||
mergeLists(li.lastChild, newList);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function indentSelection() {
|
||||
var listElements = getSelectedListItems();
|
||||
|
||||
if (listElements.length) {
|
||||
var bookmark = createBookmark(selection.getRng(true));
|
||||
|
||||
for (var i = 0; i < listElements.length; i++) {
|
||||
if (!indent(listElements[i]) && i === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function outdentSelection() {
|
||||
var listElements = getSelectedListItems();
|
||||
|
||||
if (listElements.length) {
|
||||
var bookmark = createBookmark(selection.getRng(true));
|
||||
var i, y, root = editor.getBody();
|
||||
|
||||
i = listElements.length;
|
||||
while (i--) {
|
||||
var node = listElements[i].parentNode;
|
||||
|
||||
while (node && node != root) {
|
||||
y = listElements.length;
|
||||
while (y--) {
|
||||
if (listElements[y] === node) {
|
||||
listElements.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < listElements.length; i++) {
|
||||
if (!outdent(listElements[i]) && i === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function applyList(listName) {
|
||||
var rng = selection.getRng(true), bookmark = createBookmark(rng), listItemName = 'LI';
|
||||
|
||||
listName = listName.toUpperCase();
|
||||
|
||||
if (listName == 'DL') {
|
||||
listItemName = 'DT';
|
||||
}
|
||||
|
||||
function getSelectedTextBlocks() {
|
||||
var textBlocks = [], root = editor.getBody();
|
||||
|
||||
function getEndPointNode(start) {
|
||||
var container, offset;
|
||||
|
||||
container = rng[start ? 'startContainer' : 'endContainer'];
|
||||
offset = rng[start ? 'startOffset' : 'endOffset'];
|
||||
|
||||
// Resolve node index
|
||||
if (container.nodeType == 1) {
|
||||
container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
|
||||
}
|
||||
|
||||
while (container.parentNode != root) {
|
||||
if (isTextBlock(container)) {
|
||||
return container;
|
||||
}
|
||||
|
||||
if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
|
||||
return container;
|
||||
}
|
||||
|
||||
container = container.parentNode;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
var startNode = getEndPointNode(true);
|
||||
var endNode = getEndPointNode();
|
||||
var block, siblings = [];
|
||||
|
||||
for (var node = startNode; node; node = node.nextSibling) {
|
||||
siblings.push(node);
|
||||
|
||||
if (node == endNode) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tinymce.each(siblings, function(node) {
|
||||
if (isTextBlock(node)) {
|
||||
textBlocks.push(node);
|
||||
block = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (dom.isBlock(node) || node.nodeName == 'BR') {
|
||||
if (node.nodeName == 'BR') {
|
||||
dom.remove(node);
|
||||
}
|
||||
|
||||
block = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var nextSibling = node.nextSibling;
|
||||
if (tinymce.dom.BookmarkManager.isBookmarkNode(node)) {
|
||||
if (isTextBlock(nextSibling) || (!nextSibling && node.parentNode == root)) {
|
||||
block = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!block) {
|
||||
block = dom.create('p');
|
||||
node.parentNode.insertBefore(block, node);
|
||||
textBlocks.push(block);
|
||||
}
|
||||
|
||||
block.appendChild(node);
|
||||
});
|
||||
|
||||
return textBlocks;
|
||||
}
|
||||
|
||||
tinymce.each(getSelectedTextBlocks(), function(block) {
|
||||
var listBlock, sibling;
|
||||
|
||||
sibling = block.previousSibling;
|
||||
if (sibling && isListNode(sibling) && sibling.nodeName == listName) {
|
||||
listBlock = sibling;
|
||||
block = dom.rename(block, listItemName);
|
||||
sibling.appendChild(block);
|
||||
} else {
|
||||
listBlock = dom.create(listName);
|
||||
block.parentNode.insertBefore(listBlock, block);
|
||||
listBlock.appendChild(block);
|
||||
block = dom.rename(block, listItemName);
|
||||
}
|
||||
|
||||
mergeWithAdjacentLists(listBlock);
|
||||
});
|
||||
|
||||
moveToBookmark(bookmark);
|
||||
}
|
||||
|
||||
function removeList() {
|
||||
var bookmark = createBookmark(selection.getRng(true)), root = editor.getBody();
|
||||
|
||||
tinymce.each(getSelectedListItems(), function(li) {
|
||||
var node, rootList;
|
||||
|
||||
if (dom.isEmpty(li)) {
|
||||
outdent(li);
|
||||
return;
|
||||
}
|
||||
|
||||
for (node = li; node && node != root; node = node.parentNode) {
|
||||
if (isListNode(node)) {
|
||||
rootList = node;
|
||||
}
|
||||
}
|
||||
|
||||
splitList(rootList, li);
|
||||
});
|
||||
|
||||
moveToBookmark(bookmark);
|
||||
}
|
||||
|
||||
function toggleList(listName) {
|
||||
var parentList = dom.getParent(selection.getStart(), 'OL,UL,DL');
|
||||
|
||||
if (parentList) {
|
||||
if (parentList.nodeName == listName) {
|
||||
removeList(listName);
|
||||
} else {
|
||||
var bookmark = createBookmark(selection.getRng(true));
|
||||
mergeWithAdjacentLists(dom.rename(parentList, listName));
|
||||
moveToBookmark(bookmark);
|
||||
}
|
||||
} else {
|
||||
applyList(listName);
|
||||
}
|
||||
}
|
||||
|
||||
function queryListCommandState(listName) {
|
||||
return function() {
|
||||
var parentList = dom.getParent(editor.selection.getStart(), 'UL,OL,DL');
|
||||
|
||||
return parentList && parentList.nodeName == listName;
|
||||
};
|
||||
}
|
||||
|
||||
self.backspaceDelete = function(isForward) {
|
||||
function findNextCaretContainer(rng, isForward) {
|
||||
var node = rng.startContainer, offset = rng.startOffset;
|
||||
var nonEmptyBlocks, walker;
|
||||
|
||||
if (node.nodeType == 3 && (isForward ? offset < node.data.length : offset > 0)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
nonEmptyBlocks = editor.schema.getNonEmptyElements();
|
||||
walker = new tinymce.dom.TreeWalker(rng.startContainer);
|
||||
|
||||
while ((node = walker[isForward ? 'next' : 'prev']())) {
|
||||
if (node.nodeName == 'LI' && !node.hasChildNodes()) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (nonEmptyBlocks[node.nodeName]) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (node.nodeType == 3 && node.data.length > 0) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mergeLiElements(fromElm, toElm) {
|
||||
var node, listNode, ul = fromElm.parentNode;
|
||||
|
||||
if (isListNode(toElm.lastChild)) {
|
||||
listNode = toElm.lastChild;
|
||||
}
|
||||
|
||||
node = toElm.lastChild;
|
||||
if (node && node.nodeName == 'BR' && fromElm.hasChildNodes()) {
|
||||
dom.remove(node);
|
||||
}
|
||||
|
||||
if (dom.isEmpty(toElm)) {
|
||||
dom.$(toElm).empty();
|
||||
}
|
||||
|
||||
if (!dom.isEmpty(fromElm)) {
|
||||
while ((node = fromElm.firstChild)) {
|
||||
toElm.appendChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
if (listNode) {
|
||||
toElm.appendChild(listNode);
|
||||
}
|
||||
|
||||
dom.remove(fromElm);
|
||||
|
||||
if (dom.isEmpty(ul)) {
|
||||
dom.remove(ul);
|
||||
}
|
||||
}
|
||||
|
||||
if (selection.isCollapsed()) {
|
||||
var li = dom.getParent(selection.getStart(), 'LI');
|
||||
|
||||
if (li) {
|
||||
var rng = selection.getRng(true);
|
||||
var otherLi = dom.getParent(findNextCaretContainer(rng, isForward), 'LI');
|
||||
|
||||
if (otherLi && otherLi != li) {
|
||||
var bookmark = createBookmark(rng);
|
||||
|
||||
if (isForward) {
|
||||
mergeLiElements(otherLi, li);
|
||||
} else {
|
||||
mergeLiElements(li, otherLi);
|
||||
}
|
||||
|
||||
moveToBookmark(bookmark);
|
||||
|
||||
return true;
|
||||
} else if (!otherLi) {
|
||||
if (!isForward && removeList(li.parentNode.nodeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
editor.on('BeforeExecCommand', function(e) {
|
||||
var cmd = e.command.toLowerCase(), isHandled;
|
||||
|
||||
if (cmd == "indent") {
|
||||
if (indentSelection()) {
|
||||
isHandled = true;
|
||||
}
|
||||
} else if (cmd == "outdent") {
|
||||
if (outdentSelection()) {
|
||||
isHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isHandled) {
|
||||
editor.fire('ExecCommand', {command: e.command});
|
||||
e.preventDefault();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
editor.addCommand('InsertUnorderedList', function() {
|
||||
toggleList('UL');
|
||||
});
|
||||
|
||||
editor.addCommand('InsertOrderedList', function() {
|
||||
toggleList('OL');
|
||||
});
|
||||
|
||||
editor.addCommand('InsertDefinitionList', function() {
|
||||
toggleList('DL');
|
||||
});
|
||||
|
||||
editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState('UL'));
|
||||
editor.addQueryStateHandler('InsertOrderedList', queryListCommandState('OL'));
|
||||
editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState('DL'));
|
||||
|
||||
editor.on('keydown', function(e) {
|
||||
// Check for tab but not ctrl/cmd+tab since it switches browser tabs
|
||||
if (e.keyCode != 9 || tinymce.util.VK.metaKeyPressed(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (editor.dom.getParent(editor.selection.getStart(), 'LI,DT,DD')) {
|
||||
e.preventDefault();
|
||||
|
||||
if (e.shiftKey) {
|
||||
outdentSelection();
|
||||
} else {
|
||||
indentSelection();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
editor.addButton('indent', {
|
||||
icon: 'indent',
|
||||
title: 'Increase indent',
|
||||
cmd: 'Indent',
|
||||
onPostRender: function() {
|
||||
var ctrl = this;
|
||||
|
||||
editor.on('nodechange', function() {
|
||||
var blocks = editor.selection.getSelectedBlocks();
|
||||
var disable = false;
|
||||
|
||||
for (var i = 0, l = blocks.length; !disable && i < l; i++) {
|
||||
var tag = blocks[i].nodeName;
|
||||
|
||||
disable = (tag == 'LI' && isFirstChild(blocks[i]) || tag == 'UL' || tag == 'OL' || tag == 'DD');
|
||||
}
|
||||
|
||||
ctrl.disabled(disable);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('keydown', function(e) {
|
||||
if (e.keyCode == tinymce.util.VK.BACKSPACE) {
|
||||
if (self.backspaceDelete()) {
|
||||
e.preventDefault();
|
||||
}
|
||||
} else if (e.keyCode == tinymce.util.VK.DELETE) {
|
||||
if (self.backspaceDelete(true)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/lists/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/lists/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
wp-includes/js/tinymce/plugins/media/moxieplayer.swf
Normal file
BIN
wp-includes/js/tinymce/plugins/media/moxieplayer.swf
Normal file
Binary file not shown.
793
wp-includes/js/tinymce/plugins/media/plugin.js
Normal file
793
wp-includes/js/tinymce/plugins/media/plugin.js
Normal file
@@ -0,0 +1,793 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*jshint maxlen:255 */
|
||||
/*eslint max-len:0 */
|
||||
/*global tinymce:true */
|
||||
|
||||
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', 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';
|
||||
|
||||
function guessMime(url) {
|
||||
url = url.toLowerCase();
|
||||
|
||||
if (url.indexOf('.mp3') != -1) {
|
||||
return 'audio/mpeg';
|
||||
}
|
||||
|
||||
if (url.indexOf('.wav') != -1) {
|
||||
return 'audio/wav';
|
||||
}
|
||||
|
||||
if (url.indexOf('.mp4') != -1) {
|
||||
return 'video/mp4';
|
||||
}
|
||||
|
||||
if (url.indexOf('.webm') != -1) {
|
||||
return 'video/webm';
|
||||
}
|
||||
|
||||
if (url.indexOf('.ogg') != -1) {
|
||||
return 'video/ogg';
|
||||
}
|
||||
|
||||
if (url.indexOf('.swf') != -1) {
|
||||
return 'application/x-shockwave-flash';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getVideoScriptMatch(src) {
|
||||
var prefixes = editor.settings.media_scripts;
|
||||
|
||||
if (prefixes) {
|
||||
for (var i = 0; i < prefixes.length; i++) {
|
||||
if (src.indexOf(prefixes[i].filter) !== -1) {
|
||||
return prefixes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showDialog() {
|
||||
var win, width, height, data;
|
||||
|
||||
var generalFormItems = [
|
||||
{
|
||||
name: 'source1',
|
||||
type: 'filepicker',
|
||||
filetype: 'media',
|
||||
size: 40,
|
||||
autofocus: true,
|
||||
label: 'Source',
|
||||
onchange: function(e) {
|
||||
tinymce.each(e.meta, function(value, key) {
|
||||
win.find('#' + key).value(value);
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function recalcSize(e) {
|
||||
var widthCtrl, heightCtrl, newWidth, newHeight;
|
||||
|
||||
widthCtrl = win.find('#width')[0];
|
||||
heightCtrl = win.find('#height')[0];
|
||||
|
||||
newWidth = widthCtrl.value();
|
||||
newHeight = heightCtrl.value();
|
||||
|
||||
if (win.find('#constrain')[0].checked() && width && height && newWidth && newHeight) {
|
||||
if (e.control == widthCtrl) {
|
||||
newHeight = Math.round((newWidth / width) * newHeight);
|
||||
|
||||
if (!isNaN(newHeight)) {
|
||||
heightCtrl.value(newHeight);
|
||||
}
|
||||
} else {
|
||||
newWidth = Math.round((newHeight / height) * newWidth);
|
||||
|
||||
if (!isNaN(newWidth)) {
|
||||
widthCtrl.value(newWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
}
|
||||
|
||||
if (editor.settings.media_alt_source !== false) {
|
||||
generalFormItems.push({name: 'source2', type: 'filepicker', filetype: 'media', size: 40, label: 'Alternative source'});
|
||||
}
|
||||
|
||||
if (editor.settings.media_poster !== false) {
|
||||
generalFormItems.push({name: 'poster', type: 'filepicker', filetype: 'image', size: 40, label: 'Poster'});
|
||||
}
|
||||
|
||||
if (editor.settings.media_dimensions !== false) {
|
||||
generalFormItems.push({
|
||||
type: 'container',
|
||||
label: 'Dimensions',
|
||||
layout: 'flex',
|
||||
align: 'center',
|
||||
spacing: 5,
|
||||
items: [
|
||||
{name: 'width', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Width'},
|
||||
{type: 'label', text: 'x'},
|
||||
{name: 'height', type: 'textbox', maxLength: 5, size: 3, onchange: recalcSize, ariaLabel: 'Height'},
|
||||
{name: 'constrain', type: 'checkbox', checked: true, text: 'Constrain proportions'}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
data = getData(editor.selection.getNode());
|
||||
width = data.width;
|
||||
height = data.height;
|
||||
|
||||
var embedTextBox = {
|
||||
id: 'mcemediasource',
|
||||
type: 'textbox',
|
||||
flex: 1,
|
||||
name: 'embed',
|
||||
value: getSource(),
|
||||
multiline: true,
|
||||
label: 'Source'
|
||||
};
|
||||
|
||||
function updateValueOnChange() {
|
||||
data = htmlToData(this.value());
|
||||
this.parent().parent().fromJSON(data);
|
||||
}
|
||||
|
||||
embedTextBox[embedChange] = updateValueOnChange;
|
||||
|
||||
win = editor.windowManager.open({
|
||||
title: 'Insert/edit video',
|
||||
data: data,
|
||||
bodyType: 'tabpanel',
|
||||
body: [
|
||||
{
|
||||
title: 'General',
|
||||
type: "form",
|
||||
onShowTab: function() {
|
||||
data = htmlToData(this.next().find('#embed').value());
|
||||
this.fromJSON(data);
|
||||
},
|
||||
items: generalFormItems
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Embed',
|
||||
type: "container",
|
||||
layout: 'flex',
|
||||
direction: 'column',
|
||||
align: 'stretch',
|
||||
padding: 10,
|
||||
spacing: 10,
|
||||
onShowTab: function() {
|
||||
this.find('#embed').value(dataToHtml(this.parent().toJSON()));
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'label',
|
||||
text: 'Paste your embed code below:',
|
||||
forId: 'mcemediasource'
|
||||
},
|
||||
embedTextBox
|
||||
]
|
||||
}
|
||||
],
|
||||
onSubmit: function() {
|
||||
var beforeObjects, afterObjects, i, y;
|
||||
|
||||
beforeObjects = editor.dom.select('img[data-mce-object]');
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getSource() {
|
||||
var elm = editor.selection.getNode();
|
||||
|
||||
if (elm.getAttribute('data-mce-object')) {
|
||||
return editor.selection.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
function dataToHtml(data) {
|
||||
var html = '';
|
||||
|
||||
if (!data.source1) {
|
||||
tinymce.extend(data, htmlToData(data.embed));
|
||||
if (!data.source1) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.source2) {
|
||||
data.source2 = '';
|
||||
}
|
||||
|
||||
if (!data.poster) {
|
||||
data.poster = '';
|
||||
}
|
||||
|
||||
data.source1 = editor.convertURL(data.source1, "source");
|
||||
data.source2 = editor.convertURL(data.source2, "source");
|
||||
data.source1mime = guessMime(data.source1);
|
||||
data.source2mime = guessMime(data.source2);
|
||||
data.poster = editor.convertURL(data.poster, "poster");
|
||||
data.flashPlayerUrl = editor.convertURL(url + '/moxieplayer.swf', "movie");
|
||||
|
||||
tinymce.each(urlPatterns, function(pattern) {
|
||||
var match, i, url;
|
||||
|
||||
if ((match = pattern.regex.exec(data.source1))) {
|
||||
url = pattern.url;
|
||||
|
||||
for (i = 0; match[i]; i++) {
|
||||
/*jshint loopfunc:true*/
|
||||
/*eslint no-loop-func:0 */
|
||||
url = url.replace('$' + i, function() {
|
||||
return match[i];
|
||||
});
|
||||
}
|
||||
|
||||
data.source1 = url;
|
||||
data.type = pattern.type;
|
||||
data.allowFullscreen = pattern.allowFullscreen;
|
||||
data.width = data.width || pattern.w;
|
||||
data.height = data.height || pattern.h;
|
||||
}
|
||||
});
|
||||
|
||||
if (data.embed) {
|
||||
html = updateHtml(data.embed, data, true);
|
||||
} else {
|
||||
var videoScript = getVideoScriptMatch(data.source1);
|
||||
if (videoScript) {
|
||||
data.type = 'script';
|
||||
data.width = videoScript.width;
|
||||
data.height = videoScript.height;
|
||||
}
|
||||
|
||||
data.width = data.width || 300;
|
||||
data.height = data.height || 150;
|
||||
|
||||
tinymce.each(data, function(value, key) {
|
||||
data[key] = editor.dom.encode(value);
|
||||
});
|
||||
|
||||
if (data.type == "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">';
|
||||
|
||||
if (data.poster) {
|
||||
html += '<img src="' + data.poster + '" width="' + data.width + '" height="' + data.height + '" />';
|
||||
}
|
||||
|
||||
html += '</object>';
|
||||
} else if (data.source1mime.indexOf('audio') != -1) {
|
||||
if (editor.settings.audio_template_callback) {
|
||||
html = editor.settings.audio_template_callback(data);
|
||||
} else {
|
||||
html += (
|
||||
'<audio controls="controls" src="' + data.source1 + '">' +
|
||||
(data.source2 ? '\n<source src="' + data.source2 + '"' + (data.source2mime ? ' type="' + data.source2mime + '"' : '') + ' />\n' : '') +
|
||||
'</audio>'
|
||||
);
|
||||
}
|
||||
} else if (data.type == "script") {
|
||||
html += '<script src="' + data.source1 + '"></script>';
|
||||
} else {
|
||||
if (editor.settings.video_template_callback) {
|
||||
html = editor.settings.video_template_callback(data);
|
||||
} else {
|
||||
html = (
|
||||
'<video width="' + data.width + '" height="' + data.height + '"' + (data.poster ? ' poster="' + data.poster + '"' : '') + ' controls="controls">\n' +
|
||||
'<source src="' + data.source1 + '"' + (data.source1mime ? ' type="' + data.source1mime + '"' : '') + ' />\n' +
|
||||
(data.source2 ? '<source src="' + data.source2 + '"' + (data.source2mime ? ' type="' + data.source2mime + '"' : '') + ' />\n' : '') +
|
||||
'</video>'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function htmlToData(html) {
|
||||
var data = {};
|
||||
|
||||
new tinymce.html.SaxParser({
|
||||
validate: false,
|
||||
allow_conditional_comments: true,
|
||||
special: 'script,noscript',
|
||||
start: function(name, attrs) {
|
||||
if (!data.source1 && name == "param") {
|
||||
data.source1 = attrs.map.movie;
|
||||
}
|
||||
|
||||
if (name == "iframe" || name == "object" || name == "embed" || name == "video" || name == "audio") {
|
||||
if (!data.type) {
|
||||
data.type = name;
|
||||
}
|
||||
|
||||
data = tinymce.extend(attrs.map, data);
|
||||
}
|
||||
|
||||
if (name == "script") {
|
||||
var videoScript = getVideoScriptMatch(attrs.map.src);
|
||||
if (!videoScript) {
|
||||
return;
|
||||
}
|
||||
|
||||
data = {
|
||||
type: "script",
|
||||
source1: attrs.map.src,
|
||||
width: videoScript.width,
|
||||
height: videoScript.height
|
||||
};
|
||||
}
|
||||
|
||||
if (name == "source") {
|
||||
if (!data.source1) {
|
||||
data.source1 = attrs.map.src;
|
||||
} else if (!data.source2) {
|
||||
data.source2 = attrs.map.src;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == "img" && !data.poster) {
|
||||
data.poster = attrs.map.src;
|
||||
}
|
||||
}
|
||||
}).parse(html);
|
||||
|
||||
data.source1 = data.source1 || data.src || data.data;
|
||||
data.source2 = data.source2 || '';
|
||||
data.poster = data.poster || '';
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function getData(element) {
|
||||
if (element.getAttribute('data-mce-object')) {
|
||||
return htmlToData(editor.serializer.serialize(element, {selection: true}));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
function sanitize(html) {
|
||||
if (editor.settings.media_filter_html === false) {
|
||||
return html;
|
||||
}
|
||||
|
||||
var writer = new tinymce.html.Writer(), blocked;
|
||||
|
||||
new tinymce.html.SaxParser({
|
||||
validate: false,
|
||||
allow_conditional_comments: false,
|
||||
special: 'script,noscript',
|
||||
|
||||
comment: function(text) {
|
||||
writer.comment(text);
|
||||
},
|
||||
|
||||
cdata: function(text) {
|
||||
writer.cdata(text);
|
||||
},
|
||||
|
||||
text: function(text, raw) {
|
||||
writer.text(text, raw);
|
||||
},
|
||||
|
||||
start: function(name, attrs, empty) {
|
||||
blocked = true;
|
||||
|
||||
if (name == 'script' || name == 'noscript') {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < attrs.length; i++) {
|
||||
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 (blocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
writer.end(name);
|
||||
}
|
||||
}, new tinymce.html.Schema({})).parse(html);
|
||||
|
||||
return writer.getContent();
|
||||
}
|
||||
|
||||
function updateHtml(html, data, updateAll) {
|
||||
var writer = new tinymce.html.Writer();
|
||||
var sourceCount = 0, hasImage;
|
||||
|
||||
function setAttributes(attrs, updatedAttrs) {
|
||||
var name, i, value, attr;
|
||||
|
||||
for (name in updatedAttrs) {
|
||||
value = "" + updatedAttrs[name];
|
||||
|
||||
if (attrs.map[name]) {
|
||||
i = attrs.length;
|
||||
while (i--) {
|
||||
attr = attrs[i];
|
||||
|
||||
if (attr.name == name) {
|
||||
if (value) {
|
||||
attrs.map[name] = value;
|
||||
attr.value = value;
|
||||
} else {
|
||||
delete attrs.map[name];
|
||||
attrs.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value) {
|
||||
attrs.push({
|
||||
name: name,
|
||||
value: value
|
||||
});
|
||||
|
||||
attrs.map[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new tinymce.html.SaxParser({
|
||||
validate: false,
|
||||
allow_conditional_comments: true,
|
||||
special: 'script,noscript',
|
||||
|
||||
comment: function(text) {
|
||||
writer.comment(text);
|
||||
},
|
||||
|
||||
cdata: function(text) {
|
||||
writer.cdata(text);
|
||||
},
|
||||
|
||||
text: function(text, raw) {
|
||||
writer.text(text, raw);
|
||||
},
|
||||
|
||||
start: function(name, attrs, empty) {
|
||||
switch (name) {
|
||||
case "video":
|
||||
case "object":
|
||||
case "embed":
|
||||
case "img":
|
||||
case "iframe":
|
||||
setAttributes(attrs, {
|
||||
width: data.width,
|
||||
height: data.height
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
if (updateAll) {
|
||||
switch (name) {
|
||||
case "video":
|
||||
setAttributes(attrs, {
|
||||
poster: data.poster,
|
||||
src: ""
|
||||
});
|
||||
|
||||
if (data.source2) {
|
||||
setAttributes(attrs, {
|
||||
src: ""
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case "iframe":
|
||||
setAttributes(attrs, {
|
||||
src: data.source1
|
||||
});
|
||||
break;
|
||||
|
||||
case "source":
|
||||
sourceCount++;
|
||||
|
||||
if (sourceCount <= 2) {
|
||||
setAttributes(attrs, {
|
||||
src: data["source" + sourceCount],
|
||||
type: data["source" + sourceCount + "mime"]
|
||||
});
|
||||
|
||||
if (!data["source" + sourceCount]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "img":
|
||||
if (!data.poster) {
|
||||
return;
|
||||
}
|
||||
|
||||
hasImage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
writer.start(name, attrs, empty);
|
||||
},
|
||||
|
||||
end: function(name) {
|
||||
if (name == "video" && updateAll) {
|
||||
for (var index = 1; index <= 2; index++) {
|
||||
if (data["source" + index]) {
|
||||
var attrs = [];
|
||||
attrs.map = {};
|
||||
|
||||
if (sourceCount < index) {
|
||||
setAttributes(attrs, {
|
||||
src: data["source" + index],
|
||||
type: data["source" + index + "mime"]
|
||||
});
|
||||
|
||||
writer.start("source", attrs, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.poster && name == "object" && updateAll && !hasImage) {
|
||||
var imgAttrs = [];
|
||||
imgAttrs.map = {};
|
||||
|
||||
setAttributes(imgAttrs, {
|
||||
src: data.poster,
|
||||
width: data.width,
|
||||
height: data.height
|
||||
});
|
||||
|
||||
writer.start("img", imgAttrs, true);
|
||||
}
|
||||
|
||||
writer.end(name);
|
||||
}
|
||||
}, new tinymce.html.Schema({})).parse(html);
|
||||
|
||||
return writer.getContent();
|
||||
}
|
||||
|
||||
editor.on('ResolveName', function(e) {
|
||||
var name;
|
||||
|
||||
if (e.target.nodeType == 1 && (name = e.target.getAttribute("data-mce-object"))) {
|
||||
e.name = name;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('preInit', function() {
|
||||
// Make sure that any messy HTML is retained inside these
|
||||
var specialElements = editor.schema.getSpecialElements();
|
||||
tinymce.each('video audio iframe object'.split(' '), function(name) {
|
||||
specialElements[name] = new RegExp('<\/' + name + '[^>]*>', 'gi');
|
||||
});
|
||||
|
||||
// Allow elements
|
||||
//editor.schema.addValidElements('object[id|style|width|height|classid|codebase|*],embed[id|style|width|height|type|src|*],video[*],audio[*]');
|
||||
|
||||
// Set allowFullscreen attribs as boolean
|
||||
var boolAttrs = editor.schema.getBoolAttrs();
|
||||
tinymce.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function(name) {
|
||||
boolAttrs[name] = {};
|
||||
});
|
||||
|
||||
// Converts iframe, video etc into placeholder images
|
||||
editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', function(nodes, name) {
|
||||
var i = nodes.length, ai, node, placeHolder, attrName, attrValue, attribs, innerHtml;
|
||||
var videoScript;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
if (!node.parent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.name == 'script') {
|
||||
videoScript = getVideoScriptMatch(node.attr('src'));
|
||||
if (!videoScript) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
placeHolder = new tinymce.html.Node('img', 1);
|
||||
placeHolder.shortEnded = true;
|
||||
|
||||
if (videoScript) {
|
||||
if (videoScript.width) {
|
||||
node.attr('width', videoScript.width.toString());
|
||||
}
|
||||
|
||||
if (videoScript.height) {
|
||||
node.attr('height', videoScript.height.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Prefix all attributes except width, height and style since we
|
||||
// will add these to the placeholder
|
||||
attribs = node.attributes;
|
||||
ai = attribs.length;
|
||||
while (ai--) {
|
||||
attrName = attribs[ai].name;
|
||||
attrValue = attribs[ai].value;
|
||||
|
||||
if (attrName !== "width" && attrName !== "height" && attrName !== "style") {
|
||||
if (attrName == "data" || attrName == "src") {
|
||||
attrValue = editor.convertURL(attrValue, attrName);
|
||||
}
|
||||
|
||||
placeHolder.attr('data-mce-p-' + attrName, attrValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Place the inner HTML contents inside an escaped attribute
|
||||
// This enables us to copy/paste the fake object
|
||||
innerHtml = node.firstChild && node.firstChild.value;
|
||||
if (innerHtml) {
|
||||
placeHolder.attr("data-mce-html", escape(innerHtml));
|
||||
placeHolder.firstChild = null;
|
||||
}
|
||||
|
||||
placeHolder.attr({
|
||||
width: node.attr('width') || "300",
|
||||
height: node.attr('height') || (name == "audio" ? "30" : "150"),
|
||||
style: node.attr('style'),
|
||||
src: tinymce.Env.transparentSrc,
|
||||
"data-mce-object": name,
|
||||
"class": "mce-object mce-object-" + name
|
||||
});
|
||||
|
||||
node.replace(placeHolder);
|
||||
}
|
||||
});
|
||||
|
||||
// Replaces placeholder images with real elements for video, object, iframe etc
|
||||
editor.serializer.addAttributeFilter('data-mce-object', function(nodes, name) {
|
||||
var i = nodes.length, node, realElm, ai, attribs, innerHtml, innerNode, realElmName;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
if (!node.parent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
realElmName = node.attr(name);
|
||||
realElm = new tinymce.html.Node(realElmName, 1);
|
||||
|
||||
// Add width/height to everything but audio
|
||||
if (realElmName != "audio" && realElmName != "script") {
|
||||
realElm.attr({
|
||||
width: node.attr('width'),
|
||||
height: node.attr('height')
|
||||
});
|
||||
}
|
||||
|
||||
realElm.attr({
|
||||
style: node.attr('style')
|
||||
});
|
||||
|
||||
// Unprefix all placeholder attributes
|
||||
attribs = node.attributes;
|
||||
ai = attribs.length;
|
||||
while (ai--) {
|
||||
var attrName = attribs[ai].name;
|
||||
|
||||
if (attrName.indexOf('data-mce-p-') === 0) {
|
||||
realElm.attr(attrName.substr(11), attribs[ai].value);
|
||||
}
|
||||
}
|
||||
|
||||
if (realElmName == "script") {
|
||||
realElm.attr('type', 'text/javascript');
|
||||
}
|
||||
|
||||
// Inject innerhtml
|
||||
innerHtml = node.attr('data-mce-html');
|
||||
if (innerHtml) {
|
||||
innerNode = new tinymce.html.Node('#text', 3);
|
||||
innerNode.raw = true;
|
||||
innerNode.value = sanitize(unescape(innerHtml));
|
||||
realElm.append(innerNode);
|
||||
}
|
||||
|
||||
node.replace(realElm);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
editor.on('ObjectSelected', function(e) {
|
||||
var objectType = e.target.getAttribute('data-mce-object');
|
||||
|
||||
if (objectType == "audio" || objectType == "script") {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('objectResized', function(e) {
|
||||
var target = e.target, html;
|
||||
|
||||
if (target.getAttribute('data-mce-object')) {
|
||||
html = target.getAttribute('data-mce-html');
|
||||
if (html) {
|
||||
html = unescape(html);
|
||||
target.setAttribute('data-mce-html', escape(
|
||||
updateHtml(html, {
|
||||
width: e.width,
|
||||
height: e.height
|
||||
})
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.addButton('media', {
|
||||
tooltip: 'Insert/edit video',
|
||||
onclick: showDialog,
|
||||
stateSelector: ['img[data-mce-object=video]', 'img[data-mce-object=iframe]']
|
||||
});
|
||||
|
||||
editor.addMenuItem('media', {
|
||||
icon: 'media',
|
||||
text: 'Insert/edit video',
|
||||
onclick: showDialog,
|
||||
context: 'insert',
|
||||
prependToContext: true
|
||||
});
|
||||
|
||||
this.showDialog = showDialog;
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/media/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/media/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1644
wp-includes/js/tinymce/plugins/paste/plugin.js
Normal file
1644
wp-includes/js/tinymce/plugins/paste/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
wp-includes/js/tinymce/plugins/paste/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/paste/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
120
wp-includes/js/tinymce/plugins/tabfocus/plugin.js
Normal file
120
wp-includes/js/tinymce/plugins/tabfocus/plugin.js
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('tabfocus', function(editor) {
|
||||
var DOM = tinymce.DOM, each = tinymce.each, explode = tinymce.explode;
|
||||
|
||||
function tabCancel(e) {
|
||||
if (e.keyCode === 9 && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function tabHandler(e) {
|
||||
var x, el, v, i;
|
||||
|
||||
if (e.keyCode !== 9 || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
|
||||
function find(direction) {
|
||||
el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
|
||||
|
||||
function canSelectRecursive(e) {
|
||||
return e.nodeName === "BODY" || (e.type != 'hidden' &&
|
||||
e.style.display != "none" &&
|
||||
e.style.visibility != "hidden" && canSelectRecursive(e.parentNode));
|
||||
}
|
||||
|
||||
function canSelect(el) {
|
||||
return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && tinymce.get(e.id) && el.tabIndex != -1 && canSelectRecursive(el);
|
||||
}
|
||||
|
||||
each(el, function(e, i) {
|
||||
if (e.id == editor.id) {
|
||||
x = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (direction > 0) {
|
||||
for (i = x + 1; i < el.length; i++) {
|
||||
if (canSelect(el[i])) {
|
||||
return el[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = x - 1; i >= 0; i--) {
|
||||
if (canSelect(el[i])) {
|
||||
return el[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
v = explode(editor.getParam('tab_focus', editor.getParam('tabfocus_elements', ':prev,:next')));
|
||||
|
||||
if (v.length == 1) {
|
||||
v[1] = v[0];
|
||||
v[0] = ':prev';
|
||||
}
|
||||
|
||||
// Find element to focus
|
||||
if (e.shiftKey) {
|
||||
if (v[0] == ':prev') {
|
||||
el = find(-1);
|
||||
} else {
|
||||
el = DOM.get(v[0]);
|
||||
}
|
||||
} else {
|
||||
if (v[1] == ':next') {
|
||||
el = find(1);
|
||||
} else {
|
||||
el = DOM.get(v[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (el) {
|
||||
var focusEditor = tinymce.get(el.id || el.name);
|
||||
|
||||
if (el.id && focusEditor) {
|
||||
focusEditor.focus();
|
||||
} else {
|
||||
window.setTimeout(function() {
|
||||
if (!tinymce.Env.webkit) {
|
||||
window.focus();
|
||||
}
|
||||
|
||||
el.focus();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
if (editor.inline) {
|
||||
// Remove default tabIndex in inline mode
|
||||
tinymce.DOM.setAttrib(editor.getBody(), 'tabIndex', null);
|
||||
}
|
||||
|
||||
editor.on('keyup', tabCancel);
|
||||
|
||||
if (tinymce.Env.gecko) {
|
||||
editor.on('keypress keydown', tabHandler);
|
||||
} else {
|
||||
editor.on('keydown', tabHandler);
|
||||
}
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(c){function f(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&f(a.parentNode)}function i(a){return/INPUT|TEXTAREA|BUTTON/.test(a.tagName)&&tinymce.get(b.id)&&-1!=a.tabIndex&&f(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),c>0){for(j=g+1;j<h.length;j++)if(i(h[j]))return h[j]}else for(j=g-1;j>=0;j--)if(i(h[j]))return h[j];return null}var g,h,i,j;if(!(9!==b.keyCode||b.ctrlKey||b.altKey||b.metaKey||b.isDefaultPrevented())&&(i=f(a.getParam("tab_focus",a.getParam("tabfocus_elements",":prev,:next"))),1==i.length&&(i[1]=i[0],i[0]=":prev"),h=b.shiftKey?":prev"==i[0]?c(-1):d.get(i[0]):":next"==i[1]?c(1):d.get(i[1]))){var k=tinymce.get(h.id||h.name);h.id&&k?k.focus():window.setTimeout(function(){tinymce.Env.webkit||window.focus(),h.focus()},10),b.preventDefault()}}var d=tinymce.DOM,e=tinymce.each,f=tinymce.explode;a.on("init",function(){a.inline&&tinymce.DOM.setAttrib(a.getBody(),"tabIndex",null),a.on("keyup",b),tinymce.Env.gecko?a.on("keypress keydown",c):a.on("keydown",c)})});
|
||||
282
wp-includes/js/tinymce/plugins/textcolor/plugin.js
Normal file
282
wp-includes/js/tinymce/plugins/textcolor/plugin.js
Normal file
@@ -0,0 +1,282 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint consistent-this:0 */
|
||||
|
||||
tinymce.PluginManager.add('textcolor', function(editor) {
|
||||
var cols, rows;
|
||||
|
||||
rows = editor.settings.textcolor_rows || 5;
|
||||
cols = editor.settings.textcolor_cols || 8;
|
||||
|
||||
function getCurrentColor(format) {
|
||||
var color;
|
||||
|
||||
editor.dom.getParents(editor.selection.getStart(), function(elm) {
|
||||
var value;
|
||||
|
||||
if ((value = elm.style[format == 'forecolor' ? 'color' : 'background-color'])) {
|
||||
color = value;
|
||||
}
|
||||
});
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
function mapColors() {
|
||||
var i, colors = [], colorMap;
|
||||
|
||||
colorMap = editor.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",
|
||||
"FFFFFF", "White",
|
||||
"FF99CC", "Pink",
|
||||
"FFCC99", "Peach",
|
||||
"FFFF99", "Light yellow",
|
||||
"CCFFCC", "Pale green",
|
||||
"CCFFFF", "Pale cyan",
|
||||
"99CCFF", "Light sky blue",
|
||||
"CC99FF", "Plum"
|
||||
];
|
||||
|
||||
for (i = 0; i < colorMap.length; i += 2) {
|
||||
colors.push({
|
||||
text: colorMap[i + 1],
|
||||
color: '#' + colorMap[i]
|
||||
});
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
function renderColorPicker() {
|
||||
var ctrl = this, colors, color, html, last, x, y, i, id = ctrl._id, count = 0;
|
||||
|
||||
function getColorCellHtml(color, title) {
|
||||
var isNoColor = color == 'transparent';
|
||||
|
||||
return (
|
||||
'<td class="mce-grid-cell' + (isNoColor ? ' mce-colorbtn-trans' : '') + '">' +
|
||||
'<div id="' + id + '-' + (count++) + '"' +
|
||||
' data-mce-color="' + (color ? color : '') + '"' +
|
||||
' role="option"' +
|
||||
' tabIndex="-1"' +
|
||||
' style="' + (color ? 'background-color: ' + color : '') + '"' +
|
||||
' title="' + tinymce.translate(title) + '">' +
|
||||
(isNoColor ? '×' : '') +
|
||||
'</div>' +
|
||||
'</td>'
|
||||
);
|
||||
}
|
||||
|
||||
colors = mapColors();
|
||||
colors.push({
|
||||
text: tinymce.translate("No color"),
|
||||
color: "transparent"
|
||||
});
|
||||
|
||||
html = '<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>';
|
||||
last = colors.length - 1;
|
||||
|
||||
for (y = 0; y < rows; y++) {
|
||||
html += '<tr>';
|
||||
|
||||
for (x = 0; x < cols; x++) {
|
||||
i = y * cols + x;
|
||||
|
||||
if (i > last) {
|
||||
html += '<td></td>';
|
||||
} else {
|
||||
color = colors[i];
|
||||
html += getColorCellHtml(color.color, color.text);
|
||||
}
|
||||
}
|
||||
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
if (editor.settings.color_picker_callback) {
|
||||
html += (
|
||||
'<tr>' +
|
||||
'<td colspan="' + cols + '" class="mce-custom-color-btn">' +
|
||||
'<div id="' + id + '-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" ' +
|
||||
'role="button" tabindex="-1" aria-labelledby="' + id + '-c" style="width: 100%">' +
|
||||
'<button type="button" role="presentation" tabindex="-1">' + tinymce.translate('Custom...') + '</button>' +
|
||||
'</div>' +
|
||||
'</td>' +
|
||||
'</tr>'
|
||||
);
|
||||
|
||||
html += '<tr>';
|
||||
|
||||
for (x = 0; x < cols; x++) {
|
||||
html += getColorCellHtml('', 'Custom color');
|
||||
}
|
||||
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
html += '</tbody></table>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function applyFormat(format, value) {
|
||||
editor.undoManager.transact(function() {
|
||||
editor.focus();
|
||||
editor.formatter.apply(format, {value: value});
|
||||
editor.nodeChanged();
|
||||
});
|
||||
}
|
||||
|
||||
function removeFormat(format) {
|
||||
editor.undoManager.transact(function() {
|
||||
editor.focus();
|
||||
editor.formatter.remove(format, {value: null}, null, true);
|
||||
editor.nodeChanged();
|
||||
});
|
||||
}
|
||||
|
||||
function onPanelClick(e) {
|
||||
var buttonCtrl = this.parent(), value;
|
||||
|
||||
function selectColor(value) {
|
||||
buttonCtrl.hidePanel();
|
||||
buttonCtrl.color(value);
|
||||
applyFormat(buttonCtrl.settings.format, value);
|
||||
}
|
||||
|
||||
function resetColor() {
|
||||
buttonCtrl.hidePanel();
|
||||
buttonCtrl.resetColor();
|
||||
removeFormat(buttonCtrl.settings.format);
|
||||
}
|
||||
|
||||
function setDivColor(div, value) {
|
||||
div.style.background = value;
|
||||
div.setAttribute('data-mce-color', value);
|
||||
}
|
||||
|
||||
if (tinymce.DOM.getParent(e.target, '.mce-custom-color-btn')) {
|
||||
buttonCtrl.hidePanel();
|
||||
|
||||
editor.settings.color_picker_callback.call(editor, function(value) {
|
||||
var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0];
|
||||
var customColorCells, div, i;
|
||||
|
||||
customColorCells = tinymce.map(tableElm.rows[tableElm.rows.length - 1].childNodes, function(elm) {
|
||||
return elm.firstChild;
|
||||
});
|
||||
|
||||
for (i = 0; i < customColorCells.length; i++) {
|
||||
div = customColorCells[i];
|
||||
if (!div.getAttribute('data-mce-color')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Shift colors to the right
|
||||
// TODO: Might need to be the left on RTL
|
||||
if (i == cols) {
|
||||
for (i = 0; i < cols - 1; i++) {
|
||||
setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color'));
|
||||
}
|
||||
}
|
||||
|
||||
setDivColor(div, value);
|
||||
selectColor(value);
|
||||
}, getCurrentColor(buttonCtrl.settings.format));
|
||||
}
|
||||
|
||||
value = e.target.getAttribute('data-mce-color');
|
||||
if (value) {
|
||||
if (this.lastId) {
|
||||
document.getElementById(this.lastId).setAttribute('aria-selected', false);
|
||||
}
|
||||
|
||||
e.target.setAttribute('aria-selected', true);
|
||||
this.lastId = e.target.id;
|
||||
|
||||
if (value == 'transparent') {
|
||||
resetColor();
|
||||
} else {
|
||||
selectColor(value);
|
||||
}
|
||||
} else if (value !== null) {
|
||||
buttonCtrl.hidePanel();
|
||||
}
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
var self = this;
|
||||
|
||||
if (self._color) {
|
||||
applyFormat(self.settings.format, self._color);
|
||||
} else {
|
||||
removeFormat(self.settings.format);
|
||||
}
|
||||
}
|
||||
|
||||
editor.addButton('forecolor', {
|
||||
type: 'colorbutton',
|
||||
tooltip: 'Text color',
|
||||
format: 'forecolor',
|
||||
panel: {
|
||||
role: 'application',
|
||||
ariaRemember: true,
|
||||
html: renderColorPicker,
|
||||
onclick: onPanelClick
|
||||
},
|
||||
onclick: onButtonClick
|
||||
});
|
||||
|
||||
editor.addButton('backcolor', {
|
||||
type: 'colorbutton',
|
||||
tooltip: 'Background color',
|
||||
format: 'hilitecolor',
|
||||
panel: {
|
||||
role: 'application',
|
||||
ariaRemember: true,
|
||||
html: renderColorPicker,
|
||||
onclick: onPanelClick
|
||||
},
|
||||
onclick: onButtonClick
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/textcolor/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/textcolor/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("textcolor",function(a){function b(b){var c;return a.dom.getParents(a.selection.getStart(),function(a){var d;(d=a.style["forecolor"==b?"color":"background-color"])&&(c=d)}),c}function c(){var b,c,d=[];for(c=a.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","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],b=0;b<c.length;b+=2)d.push({text:c[b+1],color:"#"+c[b]});return d}function d(){function b(a,b){var c="transparent"==a;return'<td class="mce-grid-cell'+(c?" mce-colorbtn-trans":"")+'"><div id="'+n+"-"+o++ +'" data-mce-color="'+(a?a:"")+'" role="option" tabIndex="-1" style="'+(a?"background-color: "+a:"")+'" title="'+tinymce.translate(b)+'">'+(c?"×":"")+"</div></td>"}var d,e,f,g,h,k,l,m=this,n=m._id,o=0;for(d=c(),d.push({text:tinymce.translate("No color"),color:"transparent"}),f='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',g=d.length-1,k=0;j>k;k++){for(f+="<tr>",h=0;i>h;h++)l=k*i+h,l>g?f+="<td></td>":(e=d[l],f+=b(e.color,e.text));f+="</tr>"}if(a.settings.color_picker_callback){for(f+='<tr><td colspan="'+i+'" class="mce-custom-color-btn"><div id="'+n+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+n+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",f+="<tr>",h=0;i>h;h++)f+=b("","Custom color");f+="</tr>"}return f+="</tbody></table>"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){k.hidePanel(),k.color(a),e(k.settings.format,a)}function g(){k.hidePanel(),k.resetColor(),f(k.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k=this.parent();tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(k.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=k.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e<b.length&&(c=b[e],c.getAttribute("data-mce-color"));e++);if(e==i)for(e=0;i-1>e;e++)h(b[e],b[e+1].getAttribute("data-mce-color"));h(c,a),d(a)},b(k.settings.format))),j=c.target.getAttribute("data-mce-color"),j?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),c.target.setAttribute("aria-selected",!0),this.lastId=c.target.id,"transparent"==j?g():d(j)):null!==j&&k.hidePanel()}function h(){var a=this;a._color?e(a.settings.format,a._color):f(a.settings.format)}var i,j;j=a.settings.textcolor_rows||5,i=a.settings.textcolor_cols||8,a.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h}),a.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h})});
|
||||
896
wp-includes/js/tinymce/plugins/wordpress/plugin.js
Normal file
896
wp-includes/js/tinymce/plugins/wordpress/plugin.js
Normal file
@@ -0,0 +1,896 @@
|
||||
/* global getUserSetting, setUserSetting */
|
||||
( function( tinymce ) {
|
||||
// Set the minimum value for the modals z-index higher than #wpadminbar (100000)
|
||||
tinymce.ui.FloatPanel.zIndex = 100100;
|
||||
|
||||
tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
var wpAdvButton, style,
|
||||
DOM = tinymce.DOM,
|
||||
each = tinymce.each,
|
||||
__ = editor.editorManager.i18n.translate,
|
||||
$ = window.jQuery,
|
||||
wp = window.wp,
|
||||
hasWpautop = ( wp && wp.editor && wp.editor.autop && editor.getParam( 'wpautop', true ) );
|
||||
|
||||
if ( $ ) {
|
||||
$( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
|
||||
}
|
||||
|
||||
function toggleToolbars( state ) {
|
||||
var iframe, initial, toolbars,
|
||||
pixels = 0;
|
||||
|
||||
initial = ( state === 'hide' );
|
||||
|
||||
if ( editor.theme.panel ) {
|
||||
toolbars = editor.theme.panel.find('.toolbar:not(.menubar)');
|
||||
}
|
||||
|
||||
if ( ! toolbars || toolbars.length < 2 || ( state === 'hide' && ! toolbars[1].visible() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! state && toolbars[1].visible() ) {
|
||||
state = 'hide';
|
||||
}
|
||||
|
||||
each( toolbars, function( toolbar, i ) {
|
||||
if ( i > 0 ) {
|
||||
if ( state === 'hide' ) {
|
||||
toolbar.hide();
|
||||
pixels += 30;
|
||||
} else {
|
||||
toolbar.show();
|
||||
pixels -= 30;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if ( pixels && ! initial ) {
|
||||
// Resize iframe, not needed in iOS
|
||||
if ( ! tinymce.Env.iOS ) {
|
||||
iframe = editor.getContentAreaContainer().firstChild;
|
||||
DOM.setStyle( iframe, 'height', iframe.clientHeight + pixels );
|
||||
}
|
||||
|
||||
if ( state === 'hide' ) {
|
||||
setUserSetting('hidetb', '0');
|
||||
wpAdvButton && wpAdvButton.active( false );
|
||||
} else {
|
||||
setUserSetting('hidetb', '1');
|
||||
wpAdvButton && wpAdvButton.active( true );
|
||||
}
|
||||
}
|
||||
|
||||
editor.fire( 'wp-toolbar-toggle' );
|
||||
}
|
||||
|
||||
// Add the kitchen sink button :)
|
||||
editor.addButton( 'wp_adv', {
|
||||
tooltip: 'Toolbar Toggle',
|
||||
cmd: 'WP_Adv',
|
||||
onPostRender: function() {
|
||||
wpAdvButton = this;
|
||||
wpAdvButton.active( getUserSetting( 'hidetb' ) === '1' ? true : false );
|
||||
}
|
||||
});
|
||||
|
||||
// Hide the toolbars after loading
|
||||
editor.on( 'PostRender', function() {
|
||||
if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) {
|
||||
toggleToolbars( 'hide' );
|
||||
}
|
||||
});
|
||||
|
||||
editor.addCommand( 'WP_Adv', function() {
|
||||
toggleToolbars();
|
||||
});
|
||||
|
||||
editor.on( 'focus', function() {
|
||||
window.wpActiveEditor = editor.id;
|
||||
});
|
||||
|
||||
// Replace Read More/Next Page tags with images
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
var title;
|
||||
|
||||
if ( event.content ) {
|
||||
if ( event.content.indexOf( '<!--more' ) !== -1 ) {
|
||||
title = __( 'Read more...' );
|
||||
|
||||
event.content = event.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
|
||||
return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="more" data-wp-more-text="' + moretext + '" ' +
|
||||
'class="wp-more-tag mce-wp-more" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />';
|
||||
});
|
||||
}
|
||||
|
||||
if ( event.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
|
||||
title = __( 'Page break' );
|
||||
|
||||
event.content = event.content.replace( /<!--nextpage-->/g,
|
||||
'<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" ' +
|
||||
'title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' );
|
||||
}
|
||||
|
||||
if ( event.load && event.format !== 'raw' && hasWpautop ) {
|
||||
event.content = wp.editor.autop( event.content );
|
||||
}
|
||||
|
||||
// Remove spaces from empty paragraphs.
|
||||
event.content = event.content.replace( /<p>(?: |\u00a0|\uFEFF|\s)+<\/p>/gi, '<p><br /></p>' );
|
||||
}
|
||||
});
|
||||
|
||||
// Replace images with tags
|
||||
editor.on( 'PostProcess', function( e ) {
|
||||
if ( e.get ) {
|
||||
e.content = e.content.replace(/<img[^>]+>/g, function( image ) {
|
||||
var match, moretext = '';
|
||||
|
||||
if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) {
|
||||
if ( match = image.match( /data-wp-more-text="([^"]+)"/ ) ) {
|
||||
moretext = match[1];
|
||||
}
|
||||
|
||||
image = '<!--more' + moretext + '-->';
|
||||
} else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) {
|
||||
image = '<!--nextpage-->';
|
||||
}
|
||||
|
||||
return image;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Display the tag name instead of img in element path
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
var attr;
|
||||
|
||||
if ( event.target.nodeName === 'IMG' && ( attr = editor.dom.getAttrib( event.target, 'data-wp-more' ) ) ) {
|
||||
event.name = attr;
|
||||
}
|
||||
});
|
||||
|
||||
// Register commands
|
||||
editor.addCommand( 'WP_More', function( tag ) {
|
||||
var parent, html, title,
|
||||
classname = 'wp-more-tag',
|
||||
dom = editor.dom,
|
||||
node = editor.selection.getNode();
|
||||
|
||||
tag = tag || 'more';
|
||||
classname += ' mce-wp-' + tag;
|
||||
title = tag === 'more' ? 'Read more...' : 'Next page';
|
||||
title = __( title );
|
||||
html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
|
||||
'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />';
|
||||
|
||||
// Most common case
|
||||
if ( node.nodeName === 'BODY' || ( node.nodeName === 'P' && node.parentNode.nodeName === 'BODY' ) ) {
|
||||
editor.insertContent( html );
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the top level parent node
|
||||
parent = dom.getParent( node, function( found ) {
|
||||
if ( found.parentNode && found.parentNode.nodeName === 'BODY' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, editor.getBody() );
|
||||
|
||||
if ( parent ) {
|
||||
if ( parent.nodeName === 'P' ) {
|
||||
parent.appendChild( dom.create( 'p', null, html ).firstChild );
|
||||
} else {
|
||||
dom.insertAfter( dom.create( 'p', null, html ), parent );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
});
|
||||
|
||||
editor.addCommand( 'WP_Code', function() {
|
||||
editor.formatter.toggle('code');
|
||||
});
|
||||
|
||||
editor.addCommand( 'WP_Page', function() {
|
||||
editor.execCommand( 'WP_More', 'nextpage' );
|
||||
});
|
||||
|
||||
editor.addCommand( 'WP_Help', function() {
|
||||
var access = tinymce.Env.mac ? __( 'Ctrl + Alt + letter:' ) : __( 'Shift + Alt + letter:' ),
|
||||
meta = tinymce.Env.mac ? __( 'Cmd + letter:' ) : __( 'Ctrl + letter:' ),
|
||||
table1 = [],
|
||||
table2 = [],
|
||||
header, html, dialog, $wrap;
|
||||
|
||||
each( [
|
||||
{ c: 'Copy', x: 'Cut' },
|
||||
{ v: 'Paste', a: 'Select all' },
|
||||
{ z: 'Undo', y: 'Redo' },
|
||||
{ b: 'Bold', i: 'Italic' },
|
||||
{ u: 'Underline', k: 'Insert/edit link' }
|
||||
], function( row ) {
|
||||
table1.push( tr( row ) );
|
||||
} );
|
||||
|
||||
each( [
|
||||
{ 1: 'Heading 1', 2: 'Heading 2' },
|
||||
{ 3: 'Heading 3', 4: 'Heading 4' },
|
||||
{ 5: 'Heading 5', 6: 'Heading 6' },
|
||||
{ l: 'Align left', c: 'Align center' },
|
||||
{ r: 'Align right', j: 'Justify' },
|
||||
{ d: 'Strikethrough', q: 'Blockquote' },
|
||||
{ u: 'Bullet list', o: 'Numbered list' },
|
||||
{ a: 'Insert/edit link', s: 'Remove link' },
|
||||
{ m: 'Insert/edit image', t: 'Insert Read More tag' },
|
||||
{ h: 'Keyboard Shortcuts', x: 'Code' },
|
||||
{ p: 'Insert Page Break tag', w: 'Distraction-free writing mode' }
|
||||
], function( row ) {
|
||||
table2.push( tr( row ) );
|
||||
} );
|
||||
|
||||
function tr( row ) {
|
||||
var out = '<tr>';
|
||||
|
||||
each( row, function( text, key ) {
|
||||
if ( ! text ) {
|
||||
out += '<td></td><td></td>';
|
||||
} else {
|
||||
out += '<td><kbd>' + key + '</kbd></td><td>' + __( text ) + '</td>';
|
||||
}
|
||||
});
|
||||
|
||||
return out + '</tr>';
|
||||
}
|
||||
|
||||
header = [ __( 'Letter' ), __( 'Action' ), __( 'Letter' ), __( 'Action' ) ];
|
||||
header = '<tr><th>' + header.join( '</th><th>' ) + '</th></tr>';
|
||||
|
||||
html = '<div class="wp-editor-help">';
|
||||
|
||||
// Main section, default and additional shortcuts
|
||||
html = html +
|
||||
'<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' +
|
||||
'<table class="wp-help-th-center">' +
|
||||
header +
|
||||
table1.join('') +
|
||||
'</table>' +
|
||||
'<h2>' + __( 'Additional shortcuts,' ) + ' ' + access + '</h2>' +
|
||||
'<table class="wp-help-th-center">' +
|
||||
header +
|
||||
table2.join('') +
|
||||
'</table>';
|
||||
|
||||
if ( editor.plugins.wptextpattern ) {
|
||||
// Text pattern section
|
||||
html = html +
|
||||
'<h2>' + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ) + '</h2>' +
|
||||
'<table>' +
|
||||
tr({ '*': 'Bullet list' }) +
|
||||
tr({ '-': 'Bullet list' }) +
|
||||
tr({ '1.': 'Numbered list' }) +
|
||||
tr({ '1)': 'Numbered list' }) +
|
||||
'</table>';
|
||||
|
||||
html = html +
|
||||
'<h2>' + __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ) + '</h2>' +
|
||||
'<table>' +
|
||||
tr({ '>': 'Blockquote' }) +
|
||||
tr({ '##': 'Heading 2' }) +
|
||||
tr({ '###': 'Heading 3' }) +
|
||||
tr({ '####': 'Heading 4' }) +
|
||||
tr({ '#####': 'Heading 5' }) +
|
||||
tr({ '######': 'Heading 6' }) +
|
||||
'</table>';
|
||||
}
|
||||
|
||||
// Focus management section
|
||||
html = html +
|
||||
'<h2>' + __( 'Focus shortcuts:' ) + '</h2>' +
|
||||
'<table>' +
|
||||
tr({ 'Alt + F8': 'Inline toolbar (when an image, link or preview is selected)' }) +
|
||||
tr({ 'Alt + F9': 'Editor menu (when enabled)' }) +
|
||||
tr({ 'Alt + F10': 'Editor toolbar' }) +
|
||||
tr({ 'Alt + F11': 'Elements path' }) +
|
||||
'</table>' +
|
||||
'<p>' + __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ) + '</p>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
dialog = editor.windowManager.open( {
|
||||
title: 'Keyboard Shortcuts',
|
||||
items: {
|
||||
type: 'container',
|
||||
classes: 'wp-help',
|
||||
html: html
|
||||
},
|
||||
buttons: {
|
||||
text: 'Close',
|
||||
onclick: 'close'
|
||||
}
|
||||
} );
|
||||
|
||||
if ( dialog.$el ) {
|
||||
dialog.$el.find( 'div[role="application"]' ).attr( 'role', 'document' );
|
||||
$wrap = dialog.$el.find( '.mce-wp-help' );
|
||||
|
||||
if ( $wrap[0] ) {
|
||||
$wrap.attr( 'tabindex', '0' );
|
||||
$wrap[0].focus();
|
||||
$wrap.on( 'keydown', function( event ) {
|
||||
// Prevent use of: page up, page down, end, home, left arrow, up arrow, right arrow, down arrow
|
||||
// in the dialog keydown handler.
|
||||
if ( event.keyCode >= 33 && event.keyCode <= 40 ) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addCommand( 'WP_Medialib', function() {
|
||||
if ( wp && wp.media && wp.media.editor ) {
|
||||
wp.media.editor.open( editor.id );
|
||||
}
|
||||
});
|
||||
|
||||
// Register buttons
|
||||
editor.addButton( 'wp_more', {
|
||||
tooltip: 'Insert Read More tag',
|
||||
onclick: function() {
|
||||
editor.execCommand( 'WP_More', 'more' );
|
||||
}
|
||||
});
|
||||
|
||||
editor.addButton( 'wp_page', {
|
||||
tooltip: 'Page break',
|
||||
onclick: function() {
|
||||
editor.execCommand( 'WP_More', 'nextpage' );
|
||||
}
|
||||
});
|
||||
|
||||
editor.addButton( 'wp_help', {
|
||||
tooltip: 'Keyboard Shortcuts',
|
||||
cmd: 'WP_Help'
|
||||
});
|
||||
|
||||
editor.addButton( 'wp_code', {
|
||||
tooltip: 'Code',
|
||||
cmd: 'WP_Code',
|
||||
stateSelector: 'code'
|
||||
});
|
||||
|
||||
// Menubar
|
||||
// Insert->Add Media
|
||||
if ( wp && wp.media && wp.media.editor ) {
|
||||
editor.addMenuItem( 'add_media', {
|
||||
text: 'Add Media',
|
||||
icon: 'wp-media-library',
|
||||
context: 'insert',
|
||||
cmd: 'WP_Medialib'
|
||||
});
|
||||
}
|
||||
|
||||
// Insert "Read More..."
|
||||
editor.addMenuItem( 'wp_more', {
|
||||
text: 'Insert Read More tag',
|
||||
icon: 'wp_more',
|
||||
context: 'insert',
|
||||
onclick: function() {
|
||||
editor.execCommand( 'WP_More', 'more' );
|
||||
}
|
||||
});
|
||||
|
||||
// Insert "Next Page"
|
||||
editor.addMenuItem( 'wp_page', {
|
||||
text: 'Page break',
|
||||
icon: 'wp_page',
|
||||
context: 'insert',
|
||||
onclick: function() {
|
||||
editor.execCommand( 'WP_More', 'nextpage' );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeExecCommand', function(e) {
|
||||
if ( tinymce.Env.webkit && ( e.command === 'InsertUnorderedList' || e.command === 'InsertOrderedList' ) ) {
|
||||
if ( ! style ) {
|
||||
style = editor.dom.create( 'style', {'type': 'text/css'},
|
||||
'#tinymce,#tinymce span,#tinymce li,#tinymce li>span,#tinymce p,#tinymce p>span{font:medium sans-serif;color:#000;line-height:normal;}');
|
||||
}
|
||||
|
||||
editor.getDoc().head.appendChild( style );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ExecCommand', function( e ) {
|
||||
if ( tinymce.Env.webkit && style &&
|
||||
( 'InsertUnorderedList' === e.command || 'InsertOrderedList' === e.command ) ) {
|
||||
|
||||
editor.dom.remove( style );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var env = tinymce.Env,
|
||||
bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
|
||||
doc = editor.getDoc(),
|
||||
dom = editor.dom;
|
||||
|
||||
if ( env.iOS ) {
|
||||
dom.addClass( doc.documentElement, 'ios' );
|
||||
}
|
||||
|
||||
if ( editor.getParam( 'directionality' ) === 'rtl' ) {
|
||||
bodyClass.push('rtl');
|
||||
dom.setAttrib( doc.documentElement, 'dir', 'rtl' );
|
||||
}
|
||||
|
||||
if ( env.ie ) {
|
||||
if ( parseInt( env.ie, 10 ) === 9 ) {
|
||||
bodyClass.push('ie9');
|
||||
} else if ( parseInt( env.ie, 10 ) === 8 ) {
|
||||
bodyClass.push('ie8');
|
||||
} else if ( env.ie < 8 ) {
|
||||
bodyClass.push('ie7');
|
||||
}
|
||||
} else if ( env.webkit ) {
|
||||
bodyClass.push('webkit');
|
||||
}
|
||||
|
||||
bodyClass.push('wp-editor');
|
||||
|
||||
each( bodyClass, function( cls ) {
|
||||
if ( cls ) {
|
||||
dom.addClass( doc.body, cls );
|
||||
}
|
||||
});
|
||||
|
||||
// Remove invalid parent paragraphs when inserting HTML
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' )
|
||||
.replace( /<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)>\s*<\/p>/gi, '</$1>' );
|
||||
}
|
||||
});
|
||||
|
||||
if ( $ ) {
|
||||
$( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
||||
}
|
||||
|
||||
if ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {
|
||||
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
||||
if ( $ ) {
|
||||
// Trigger the jQuery handlers.
|
||||
$( document ).trigger( new $.Event( event ) );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ( editor.getParam( 'wp_paste_filters', true ) ) {
|
||||
if ( ! tinymce.Env.webkit ) {
|
||||
// In WebKit handled by removeWebKitStyles()
|
||||
editor.on( 'PastePreProcess', function( event ) {
|
||||
// Remove all inline styles
|
||||
event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' );
|
||||
|
||||
// Put back the internal styles
|
||||
event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' );
|
||||
});
|
||||
}
|
||||
|
||||
editor.on( 'PastePostProcess', function( event ) {
|
||||
// Remove empty paragraphs
|
||||
each( dom.select( 'p', event.node ), function( node ) {
|
||||
if ( dom.isEmpty( node ) ) {
|
||||
dom.remove( node );
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'SaveContent', function( event ) {
|
||||
// If editor is hidden, we just want the textarea's value to be saved
|
||||
if ( ! editor.inline && editor.isHidden() ) {
|
||||
event.content = event.element.value;
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep empty paragraphs :(
|
||||
event.content = event.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p> </p>' );
|
||||
|
||||
if ( hasWpautop ) {
|
||||
event.content = wp.editor.removep( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'preInit', function() {
|
||||
var validElementsSetting = '@[id|accesskey|class|dir|lang|style|tabindex|' +
|
||||
'title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],' + // Global attributes.
|
||||
'i,' + // Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty.
|
||||
'b,' +
|
||||
'script[src|async|defer|type|charset|crossorigin|integrity]'; // Add support for <script>.
|
||||
|
||||
editor.schema.addValidElements( validElementsSetting );
|
||||
|
||||
if ( tinymce.Env.iOS ) {
|
||||
editor.settings.height = 300;
|
||||
}
|
||||
|
||||
each( {
|
||||
c: 'JustifyCenter',
|
||||
r: 'JustifyRight',
|
||||
l: 'JustifyLeft',
|
||||
j: 'JustifyFull',
|
||||
q: 'mceBlockQuote',
|
||||
u: 'InsertUnorderedList',
|
||||
o: 'InsertOrderedList',
|
||||
s: 'unlink',
|
||||
m: 'WP_Medialib',
|
||||
z: 'WP_Adv',
|
||||
t: 'WP_More',
|
||||
d: 'Strikethrough',
|
||||
h: 'WP_Help',
|
||||
p: 'WP_Page',
|
||||
x: 'WP_Code'
|
||||
}, function( command, key ) {
|
||||
editor.shortcuts.add( 'access+' + key, '', command );
|
||||
} );
|
||||
|
||||
editor.addShortcut( 'meta+s', '', function() {
|
||||
if ( wp && wp.autosave ) {
|
||||
wp.autosave.server.triggerSave();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Experimental: create a floating toolbar.
|
||||
* This functionality will change in the next releases. Not recommended for use by plugins.
|
||||
*/
|
||||
editor.on( 'preinit', function() {
|
||||
var Factory = tinymce.ui.Factory,
|
||||
settings = editor.settings,
|
||||
activeToolbar,
|
||||
currentSelection,
|
||||
timeout,
|
||||
container = editor.getContainer(),
|
||||
wpAdminbar = document.getElementById( 'wpadminbar' ),
|
||||
mceIframe = document.getElementById( editor.id + '_ifr' ),
|
||||
mceToolbar,
|
||||
mceStatusbar,
|
||||
wpStatusbar;
|
||||
|
||||
if ( container ) {
|
||||
mceToolbar = tinymce.$( '.mce-toolbar-grp', container )[0];
|
||||
mceStatusbar = tinymce.$( '.mce-statusbar', container )[0];
|
||||
}
|
||||
|
||||
if ( editor.id === 'content' ) {
|
||||
wpStatusbar = document.getElementById( 'post-status-info' );
|
||||
}
|
||||
|
||||
function create( buttons, bottom ) {
|
||||
var toolbar,
|
||||
toolbarItems = [],
|
||||
buttonGroup;
|
||||
|
||||
each( buttons, function( item ) {
|
||||
var itemName;
|
||||
|
||||
function bindSelectorChanged() {
|
||||
var selection = editor.selection;
|
||||
|
||||
if ( itemName === 'bullist' ) {
|
||||
selection.selectorChanged( 'ul > li', function( state, args ) {
|
||||
var i = args.parents.length,
|
||||
nodeName;
|
||||
|
||||
while ( i-- ) {
|
||||
nodeName = args.parents[ i ].nodeName;
|
||||
|
||||
if ( nodeName === 'OL' || nodeName == 'UL' ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item.active( state && nodeName === 'UL' );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( itemName === 'numlist' ) {
|
||||
selection.selectorChanged( 'ol > li', function( state, args ) {
|
||||
var i = args.parents.length,
|
||||
nodeName;
|
||||
|
||||
while ( i-- ) {
|
||||
nodeName = args.parents[ i ].nodeName;
|
||||
|
||||
if ( nodeName === 'OL' || nodeName === 'UL' ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item.active( state && nodeName === 'OL' );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( item.settings.stateSelector ) {
|
||||
selection.selectorChanged( item.settings.stateSelector, function( state ) {
|
||||
item.active( state );
|
||||
}, true );
|
||||
}
|
||||
|
||||
if ( item.settings.disabledStateSelector ) {
|
||||
selection.selectorChanged( item.settings.disabledStateSelector, function( state ) {
|
||||
item.disabled( state );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
if ( item === '|' ) {
|
||||
buttonGroup = null;
|
||||
} else {
|
||||
if ( Factory.has( item ) ) {
|
||||
item = {
|
||||
type: item
|
||||
};
|
||||
|
||||
if ( settings.toolbar_items_size ) {
|
||||
item.size = settings.toolbar_items_size;
|
||||
}
|
||||
|
||||
toolbarItems.push( item );
|
||||
|
||||
buttonGroup = null;
|
||||
} else {
|
||||
if ( ! buttonGroup ) {
|
||||
buttonGroup = {
|
||||
type: 'buttongroup',
|
||||
items: []
|
||||
};
|
||||
|
||||
toolbarItems.push( buttonGroup );
|
||||
}
|
||||
|
||||
if ( editor.buttons[ item ] ) {
|
||||
itemName = item;
|
||||
item = editor.buttons[ itemName ];
|
||||
|
||||
if ( typeof item === 'function' ) {
|
||||
item = item();
|
||||
}
|
||||
|
||||
item.type = item.type || 'button';
|
||||
|
||||
if ( settings.toolbar_items_size ) {
|
||||
item.size = settings.toolbar_items_size;
|
||||
}
|
||||
|
||||
item = Factory.create( item );
|
||||
|
||||
buttonGroup.items.push( item );
|
||||
|
||||
if ( editor.initialized ) {
|
||||
bindSelectorChanged();
|
||||
} else {
|
||||
editor.on( 'init', bindSelectorChanged );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
toolbar = Factory.create( {
|
||||
type: 'panel',
|
||||
layout: 'stack',
|
||||
classes: 'toolbar-grp inline-toolbar-grp',
|
||||
ariaRoot: true,
|
||||
ariaRemember: true,
|
||||
items: [ {
|
||||
type: 'toolbar',
|
||||
layout: 'flow',
|
||||
items: toolbarItems
|
||||
} ]
|
||||
} );
|
||||
|
||||
toolbar.bottom = bottom;
|
||||
|
||||
function reposition() {
|
||||
if ( ! currentSelection ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var scrollX = window.pageXOffset || document.documentElement.scrollLeft,
|
||||
scrollY = window.pageYOffset || document.documentElement.scrollTop,
|
||||
windowWidth = window.innerWidth,
|
||||
windowHeight = window.innerHeight,
|
||||
iframeRect = mceIframe ? mceIframe.getBoundingClientRect() : {
|
||||
top: 0,
|
||||
right: windowWidth,
|
||||
bottom: windowHeight,
|
||||
left: 0,
|
||||
width: windowWidth,
|
||||
height: windowHeight
|
||||
},
|
||||
toolbar = this.getEl(),
|
||||
toolbarWidth = toolbar.offsetWidth,
|
||||
toolbarHeight = toolbar.offsetHeight,
|
||||
selection = currentSelection.getBoundingClientRect(),
|
||||
selectionMiddle = ( selection.left + selection.right ) / 2,
|
||||
buffer = 5,
|
||||
margin = 8,
|
||||
spaceNeeded = toolbarHeight + margin + buffer,
|
||||
wpAdminbarBottom = wpAdminbar ? wpAdminbar.getBoundingClientRect().bottom : 0,
|
||||
mceToolbarBottom = mceToolbar ? mceToolbar.getBoundingClientRect().bottom : 0,
|
||||
mceStatusbarTop = mceStatusbar ? windowHeight - mceStatusbar.getBoundingClientRect().top : 0,
|
||||
wpStatusbarTop = wpStatusbar ? windowHeight - wpStatusbar.getBoundingClientRect().top : 0,
|
||||
blockedTop = Math.max( 0, wpAdminbarBottom, mceToolbarBottom, iframeRect.top ),
|
||||
blockedBottom = Math.max( 0, mceStatusbarTop, wpStatusbarTop, windowHeight - iframeRect.bottom ),
|
||||
spaceTop = selection.top + iframeRect.top - blockedTop,
|
||||
spaceBottom = windowHeight - iframeRect.top - selection.bottom - blockedBottom,
|
||||
editorHeight = windowHeight - blockedTop - blockedBottom,
|
||||
className = '',
|
||||
top, left;
|
||||
|
||||
if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) {
|
||||
return this.hide();
|
||||
}
|
||||
|
||||
if ( this.bottom ) {
|
||||
if ( spaceBottom >= spaceNeeded ) {
|
||||
className = ' mce-arrow-up';
|
||||
top = selection.bottom + iframeRect.top + scrollY;
|
||||
} else if ( spaceTop >= spaceNeeded ) {
|
||||
className = ' mce-arrow-down';
|
||||
top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin;
|
||||
}
|
||||
} else {
|
||||
if ( spaceTop >= spaceNeeded ) {
|
||||
className = ' mce-arrow-down';
|
||||
top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin;
|
||||
} else if ( spaceBottom >= spaceNeeded && editorHeight / 2 > selection.bottom + iframeRect.top - blockedTop ) {
|
||||
className = ' mce-arrow-up';
|
||||
top = selection.bottom + iframeRect.top + scrollY;
|
||||
}
|
||||
}
|
||||
|
||||
if ( typeof top === 'undefined' ) {
|
||||
top = scrollY + blockedTop + buffer;
|
||||
}
|
||||
|
||||
left = selectionMiddle - toolbarWidth / 2 + iframeRect.left + scrollX;
|
||||
|
||||
if ( selection.left < 0 || selection.right > iframeRect.width ) {
|
||||
left = iframeRect.left + scrollX + ( iframeRect.width - toolbarWidth ) / 2;
|
||||
} else if ( toolbarWidth >= windowWidth ) {
|
||||
className += ' mce-arrow-full';
|
||||
left = 0;
|
||||
} else if ( ( left < 0 && selection.left + toolbarWidth > windowWidth ) || ( left + toolbarWidth > windowWidth && selection.right - toolbarWidth < 0 ) ) {
|
||||
left = ( windowWidth - toolbarWidth ) / 2;
|
||||
} else if ( left < iframeRect.left + scrollX ) {
|
||||
className += ' mce-arrow-left';
|
||||
left = selection.left + iframeRect.left + scrollX;
|
||||
} else if ( left + toolbarWidth > iframeRect.width + iframeRect.left + scrollX ) {
|
||||
className += ' mce-arrow-right';
|
||||
left = selection.right - toolbarWidth + iframeRect.left + scrollX;
|
||||
}
|
||||
|
||||
toolbar.className = toolbar.className.replace( / ?mce-arrow-[\w]+/g, '' ) + className;
|
||||
|
||||
DOM.setStyles( toolbar, {
|
||||
'left': left,
|
||||
'top': top
|
||||
} );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toolbar.on( 'show', function() {
|
||||
this.reposition();
|
||||
} );
|
||||
|
||||
toolbar.on( 'keydown', function( event ) {
|
||||
if ( event.keyCode === 27 ) {
|
||||
this.hide();
|
||||
editor.focus();
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'remove', function() {
|
||||
toolbar.remove();
|
||||
} );
|
||||
|
||||
toolbar.reposition = reposition;
|
||||
toolbar.hide().renderTo( document.body );
|
||||
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
editor.shortcuts.add( 'alt+119', '', function() {
|
||||
var node;
|
||||
|
||||
if ( activeToolbar ) {
|
||||
node = activeToolbar.find( 'toolbar' )[0];
|
||||
node && node.focus( true );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'nodechange', function( event ) {
|
||||
var collapsed = editor.selection.isCollapsed();
|
||||
|
||||
var args = {
|
||||
element: event.element,
|
||||
parents: event.parents,
|
||||
collapsed: collapsed
|
||||
};
|
||||
|
||||
editor.fire( 'wptoolbar', args );
|
||||
|
||||
currentSelection = args.selection || args.element;
|
||||
|
||||
if ( activeToolbar ) {
|
||||
activeToolbar.hide();
|
||||
}
|
||||
|
||||
if ( args.toolbar ) {
|
||||
activeToolbar = args.toolbar;
|
||||
activeToolbar.show();
|
||||
} else {
|
||||
activeToolbar = false;
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'focus', function() {
|
||||
if ( activeToolbar ) {
|
||||
activeToolbar.show();
|
||||
}
|
||||
} );
|
||||
|
||||
function hide( event ) {
|
||||
if ( activeToolbar ) {
|
||||
activeToolbar.hide();
|
||||
|
||||
if ( event.type === 'hide' ) {
|
||||
activeToolbar = false;
|
||||
} else if ( event.type === 'resize' || event.type === 'scroll' ) {
|
||||
clearTimeout( timeout );
|
||||
|
||||
timeout = setTimeout( function() {
|
||||
if ( activeToolbar && typeof activeToolbar.show === 'function' ) {
|
||||
activeToolbar.show();
|
||||
}
|
||||
}, 250 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DOM.bind( window, 'resize scroll', hide );
|
||||
editor.dom.bind( editor.getWin(), 'resize scroll', hide );
|
||||
|
||||
editor.on( 'remove', function() {
|
||||
DOM.unbind( window, 'resize scroll', hide );
|
||||
editor.dom.unbind( editor.getWin(), 'resize scroll', hide );
|
||||
} );
|
||||
|
||||
editor.on( 'blur hide', hide );
|
||||
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp._createToolbar = create;
|
||||
}, true );
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Expose some functions (back-compat)
|
||||
return {
|
||||
_showButtons: noop,
|
||||
_hideButtons: noop,
|
||||
_setEmbed: noop,
|
||||
_getEmbed: noop
|
||||
};
|
||||
});
|
||||
|
||||
}( window.tinymce ));
|
||||
1
wp-includes/js/tinymce/plugins/wordpress/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wordpress/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
207
wp-includes/js/tinymce/plugins/wpautoresize/plugin.js
Normal file
207
wp-includes/js/tinymce/plugins/wpautoresize/plugin.js
Normal file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
// Forked for WordPress so it can be turned on/off after loading.
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint no-nested-ternary:0 */
|
||||
|
||||
/**
|
||||
* Auto Resize
|
||||
*
|
||||
* This plugin automatically resizes the content area to fit its content height.
|
||||
* It will retain a minimum height, which is the height of the content area when
|
||||
* it's initialized.
|
||||
*/
|
||||
tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
var settings = editor.settings,
|
||||
oldSize = 300,
|
||||
isActive = false;
|
||||
|
||||
if ( editor.settings.inline || tinymce.Env.iOS ) {
|
||||
return;
|
||||
}
|
||||
|
||||
function isFullscreen() {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
}
|
||||
|
||||
function getInt( n ) {
|
||||
return parseInt( n, 10 ) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
function resize( e ) {
|
||||
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight,
|
||||
marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
|
||||
|
||||
if ( ! isActive ) {
|
||||
return;
|
||||
}
|
||||
|
||||
doc = editor.getDoc();
|
||||
if ( ! doc ) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = e || {};
|
||||
body = doc.body;
|
||||
docElm = doc.documentElement;
|
||||
resizeHeight = settings.autoresize_min_height;
|
||||
|
||||
if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) {
|
||||
if ( body && docElm ) {
|
||||
body.style.overflowY = 'auto';
|
||||
docElm.style.overflowY = 'auto'; // Old IE
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate outer height of the body element using CSS styles
|
||||
marginTop = editor.dom.getStyle( body, 'margin-top', true );
|
||||
marginBottom = editor.dom.getStyle( body, 'margin-bottom', true );
|
||||
paddingTop = editor.dom.getStyle( body, 'padding-top', true );
|
||||
paddingBottom = editor.dom.getStyle( body, 'padding-bottom', true );
|
||||
borderTop = editor.dom.getStyle( body, 'border-top-width', true );
|
||||
borderBottom = editor.dom.getStyle( body, 'border-bottom-width', true );
|
||||
myHeight = body.offsetHeight + getInt( marginTop ) + getInt( marginBottom ) +
|
||||
getInt( paddingTop ) + getInt( paddingBottom ) +
|
||||
getInt( borderTop ) + getInt( borderBottom );
|
||||
|
||||
// IE < 11, other?
|
||||
if ( myHeight && myHeight < docElm.offsetHeight ) {
|
||||
myHeight = docElm.offsetHeight;
|
||||
}
|
||||
|
||||
// Make sure we have a valid height
|
||||
if ( isNaN( myHeight ) || myHeight <= 0 ) {
|
||||
// Get height differently depending on the browser used
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight );
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height
|
||||
if ( myHeight > settings.autoresize_min_height ) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height
|
||||
if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) {
|
||||
resizeHeight = settings.autoresize_max_height;
|
||||
body.style.overflowY = 'auto';
|
||||
docElm.style.overflowY = 'auto'; // Old IE
|
||||
} else {
|
||||
body.style.overflowY = 'hidden';
|
||||
docElm.style.overflowY = 'hidden'; // Old IE
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
|
||||
// Resize content element
|
||||
if (resizeHeight !== oldSize) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' );
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
if ( tinymce.isWebKit && deltaSize < 0 ) {
|
||||
resize( e );
|
||||
}
|
||||
|
||||
editor.fire( 'wp-autoresize', { height: resizeHeight, deltaHeight: e.type === 'nodechange' ? deltaSize : null } );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the resize x times in 100ms intervals. We can't wait for load events since
|
||||
* the CSS files might load async.
|
||||
*/
|
||||
function wait( times, interval, callback ) {
|
||||
setTimeout( function() {
|
||||
resize();
|
||||
|
||||
if ( times-- ) {
|
||||
wait( times, interval, callback );
|
||||
} else if ( callback ) {
|
||||
callback();
|
||||
}
|
||||
}, interval );
|
||||
}
|
||||
|
||||
// Define minimum height
|
||||
settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 );
|
||||
|
||||
// Define maximum height
|
||||
settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 );
|
||||
|
||||
function on() {
|
||||
if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {
|
||||
isActive = true;
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
resize();
|
||||
}
|
||||
}
|
||||
|
||||
function off() {
|
||||
var doc;
|
||||
|
||||
// Don't turn off if the setting is 'on'
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
isActive = false;
|
||||
doc = editor.getDoc();
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
doc.body.style.overflowY = 'auto';
|
||||
doc.documentElement.style.overflowY = 'auto'; // Old IE
|
||||
oldSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.wp_autoresize_on ) {
|
||||
// Turn resizing on when the editor loads
|
||||
isActive = true;
|
||||
|
||||
editor.on( 'init', function() {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
});
|
||||
|
||||
editor.on( 'nodechange keyup FullscreenStateChanged', resize );
|
||||
|
||||
editor.on( 'setcontent', function() {
|
||||
wait( 3, 100 );
|
||||
});
|
||||
|
||||
if ( editor.getParam( 'autoresize_on_init', true ) ) {
|
||||
editor.on( 'init', function() {
|
||||
// Hit it 10 times in 200 ms intervals
|
||||
wait( 10, 200, function() {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
wait( 5, 1000 );
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the stored size
|
||||
editor.on( 'show', function() {
|
||||
oldSize = 0;
|
||||
});
|
||||
|
||||
// Register the command
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
|
||||
// On/off
|
||||
editor.addCommand( 'wpAutoResizeOn', on );
|
||||
editor.addCommand( 'wpAutoResizeOff', off );
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("wpautoresize",function(a){function b(){return a.plugins.fullscreen&&a.plugins.fullscreen.isFullscreen()}function c(a){return parseInt(a,10)||0}function d(e){var f,g,k,l,m,n,o,p,q,r,s,t,u=tinymce.DOM;if(j&&(g=a.getDoc())){if(e=e||{},k=g.body,l=g.documentElement,m=h.autoresize_min_height,!k||e&&"setcontent"===e.type&&e.initial||b())return void(k&&l&&(k.style.overflowY="auto",l.style.overflowY="auto"));o=a.dom.getStyle(k,"margin-top",!0),p=a.dom.getStyle(k,"margin-bottom",!0),q=a.dom.getStyle(k,"padding-top",!0),r=a.dom.getStyle(k,"padding-bottom",!0),s=a.dom.getStyle(k,"border-top-width",!0),t=a.dom.getStyle(k,"border-bottom-width",!0),n=k.offsetHeight+c(o)+c(p)+c(q)+c(r)+c(s)+c(t),n&&n<l.offsetHeight&&(n=l.offsetHeight),(isNaN(n)||0>=n)&&(n=tinymce.Env.ie?k.scrollHeight:tinymce.Env.webkit&&0===k.clientHeight?0:k.offsetHeight),n>h.autoresize_min_height&&(m=n),h.autoresize_max_height&&n>h.autoresize_max_height?(m=h.autoresize_max_height,k.style.overflowY="auto",l.style.overflowY="auto"):(k.style.overflowY="hidden",l.style.overflowY="hidden",k.scrollTop=0),m!==i&&(f=m-i,u.setStyle(a.iframeElement,"height",m+"px"),i=m,tinymce.isWebKit&&0>f&&d(e),a.fire("wp-autoresize",{height:m,deltaHeight:"nodechange"===e.type?f:null}))}}function e(a,b,c){setTimeout(function(){d(),a--?e(a,b,c):c&&c()},b)}function f(){a.dom.hasClass(a.getBody(),"wp-autoresize")||(j=!0,a.dom.addClass(a.getBody(),"wp-autoresize"),a.on("nodechange setcontent keyup FullscreenStateChanged",d),d())}function g(){var b;h.wp_autoresize_on||(j=!1,b=a.getDoc(),a.dom.removeClass(a.getBody(),"wp-autoresize"),a.off("nodechange setcontent keyup FullscreenStateChanged",d),b.body.style.overflowY="auto",b.documentElement.style.overflowY="auto",i=0)}var h=a.settings,i=300,j=!1;a.settings.inline||tinymce.Env.iOS||(h.autoresize_min_height=parseInt(a.getParam("autoresize_min_height",a.getElement().offsetHeight),10),h.autoresize_max_height=parseInt(a.getParam("autoresize_max_height",0),10),h.wp_autoresize_on&&(j=!0,a.on("init",function(){a.dom.addClass(a.getBody(),"wp-autoresize")}),a.on("nodechange keyup FullscreenStateChanged",d),a.on("setcontent",function(){e(3,100)}),a.getParam("autoresize_on_init",!0)&&a.on("init",function(){e(10,200,function(){e(5,1e3)})})),a.on("show",function(){i=0}),a.addCommand("wpAutoResize",d),a.addCommand("wpAutoResizeOn",f),a.addCommand("wpAutoResizeOff",g))});
|
||||
92
wp-includes/js/tinymce/plugins/wpdialogs/plugin.js
Normal file
92
wp-includes/js/tinymce/plugins/wpdialogs/plugin.js
Normal file
@@ -0,0 +1,92 @@
|
||||
/* global tinymce */
|
||||
/**
|
||||
* Included for back-compat.
|
||||
* The default WindowManager in TinyMCE 4.0 supports three types of dialogs:
|
||||
* - With HTML created from JS.
|
||||
* - With inline HTML (like WPWindowManager).
|
||||
* - Old type iframe based dialogs.
|
||||
* For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins
|
||||
*/
|
||||
tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
||||
if ( this.wp ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.wp = {};
|
||||
this.parent = editor.windowManager;
|
||||
this.editor = editor;
|
||||
|
||||
tinymce.extend( this, this.parent );
|
||||
|
||||
this.open = function( args, params ) {
|
||||
var $element,
|
||||
self = this,
|
||||
wp = this.wp;
|
||||
|
||||
if ( ! args.wpDialog ) {
|
||||
return this.parent.open.apply( this, arguments );
|
||||
} else if ( ! args.id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) {
|
||||
// wpdialog.js is not loaded
|
||||
if ( window.console && window.console.error ) {
|
||||
window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
wp.$element = $element = jQuery( '#' + args.id );
|
||||
|
||||
if ( ! $element.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( window.console && window.console.log ) {
|
||||
window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.');
|
||||
}
|
||||
|
||||
wp.features = args;
|
||||
wp.params = params;
|
||||
|
||||
// Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
|
||||
editor.nodeChanged();
|
||||
|
||||
// Create the dialog if necessary
|
||||
if ( ! $element.data('wpdialog') ) {
|
||||
$element.wpdialog({
|
||||
title: args.title,
|
||||
width: args.width,
|
||||
height: args.height,
|
||||
modal: true,
|
||||
dialogClass: 'wp-dialog',
|
||||
zIndex: 300000
|
||||
});
|
||||
}
|
||||
|
||||
$element.wpdialog('open');
|
||||
|
||||
$element.on( 'wpdialogclose', function() {
|
||||
if ( self.wp.$element ) {
|
||||
self.wp = {};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.close = function() {
|
||||
if ( ! this.wp.features || ! this.wp.features.wpDialog ) {
|
||||
return this.parent.close.apply( this, arguments );
|
||||
}
|
||||
|
||||
this.wp.$element.wpdialog('close');
|
||||
};
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add( 'wpdialogs', function( editor ) {
|
||||
// Replace window manager
|
||||
editor.on( 'init', function() {
|
||||
editor.windowManager = new tinymce.WPWindowManager( editor );
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.WPWindowManager=tinymce.InlineWindowManager=function(a){return this.wp?this:(this.wp={},this.parent=a.windowManager,this.editor=a,tinymce.extend(this,this.parent),this.open=function(b,c){var d,e=this,f=this.wp;if(!b.wpDialog)return this.parent.open.apply(this,arguments);if(b.id){if("undefined"==typeof jQuery||!jQuery.wp||!jQuery.wp.wpdialog)return void(window.console&&window.console.error&&window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.'));f.$element=d=jQuery("#"+b.id),d.length&&(window.console&&window.console.log&&window.console.log("tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML."),f.features=b,f.params=c,a.nodeChanged(),d.data("wpdialog")||d.wpdialog({title:b.title,width:b.width,height:b.height,modal:!0,dialogClass:"wp-dialog",zIndex:3e5}),d.wpdialog("open"),d.on("wpdialogclose",function(){e.wp.$element&&(e.wp={})}))}},void(this.close=function(){return this.wp.features&&this.wp.features.wpDialog?void this.wp.$element.wpdialog("close"):this.parent.close.apply(this,arguments)}))},tinymce.PluginManager.add("wpdialogs",function(a){a.on("init",function(){a.windowManager=new tinymce.WPWindowManager(a)})});
|
||||
976
wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
Normal file
976
wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
Normal file
@@ -0,0 +1,976 @@
|
||||
/* global tinymce */
|
||||
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
var toolbar, serializer,
|
||||
each = tinymce.each,
|
||||
trim = tinymce.trim,
|
||||
iOS = tinymce.Env.iOS;
|
||||
|
||||
function isPlaceholder( node ) {
|
||||
return !! ( editor.dom.getAttrib( node, 'data-mce-placeholder' ) || editor.dom.getAttrib( node, 'data-mce-object' ) );
|
||||
}
|
||||
|
||||
editor.addButton( 'wp_img_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
onclick: function() {
|
||||
removeImage( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_img_edit', {
|
||||
tooltip: 'Edit ', // trailing space is needed, used for context
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
editImage( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
|
||||
each( {
|
||||
alignleft: 'Align left',
|
||||
aligncenter: 'Align center',
|
||||
alignright: 'Align right',
|
||||
alignnone: 'No alignment'
|
||||
}, function( tooltip, name ) {
|
||||
var direction = name.slice( 5 );
|
||||
|
||||
editor.addButton( 'wp_img_' + name, {
|
||||
tooltip: tooltip,
|
||||
icon: 'dashicon dashicons-align-' + direction,
|
||||
cmd: 'alignnone' === name ? 'wpAlignNone' : 'Justify' + direction.slice( 0, 1 ).toUpperCase() + direction.slice( 1 ),
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on( 'NodeChange', function( event ) {
|
||||
var node;
|
||||
|
||||
// Don't bother.
|
||||
if ( event.element.nodeName !== 'IMG' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = editor.dom.getParent( event.element, '.wp-caption' ) || event.element;
|
||||
|
||||
if ( 'alignnone' === name ) {
|
||||
self.active( ! /\balign(left|center|right)\b/.test( node.className ) );
|
||||
} else {
|
||||
self.active( editor.dom.hasClass( node, name ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
editor.once( 'preinit', function() {
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_img_alignleft',
|
||||
'wp_img_aligncenter',
|
||||
'wp_img_alignright',
|
||||
'wp_img_alignnone',
|
||||
'wp_img_edit',
|
||||
'wp_img_remove'
|
||||
] );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) {
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
} );
|
||||
|
||||
// Safari on iOS fails to select image nodes in contentEditoble mode on touch/click.
|
||||
// Select them again.
|
||||
if ( iOS ) {
|
||||
editor.on( 'click', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' ) {
|
||||
var node = event.target;
|
||||
|
||||
window.setTimeout( function() {
|
||||
editor.selection.select( node );
|
||||
editor.nodeChanged();
|
||||
}, 200 );
|
||||
} else if ( toolbar ) {
|
||||
toolbar.hide();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function parseShortcode( content ) {
|
||||
return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
|
||||
var id, align, classes, caption, img, width;
|
||||
|
||||
id = b.match( /id=['"]([^'"]*)['"] ?/ );
|
||||
if ( id ) {
|
||||
b = b.replace( id[0], '' );
|
||||
}
|
||||
|
||||
align = b.match( /align=['"]([^'"]*)['"] ?/ );
|
||||
if ( align ) {
|
||||
b = b.replace( align[0], '' );
|
||||
}
|
||||
|
||||
classes = b.match( /class=['"]([^'"]*)['"] ?/ );
|
||||
if ( classes ) {
|
||||
b = b.replace( classes[0], '' );
|
||||
}
|
||||
|
||||
width = b.match( /width=['"]([0-9]*)['"] ?/ );
|
||||
if ( width ) {
|
||||
b = b.replace( width[0], '' );
|
||||
}
|
||||
|
||||
c = trim( c );
|
||||
img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i );
|
||||
|
||||
if ( img && img[2] ) {
|
||||
caption = trim( img[2] );
|
||||
img = trim( img[1] );
|
||||
} else {
|
||||
// old captions shortcode style
|
||||
caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' );
|
||||
img = c;
|
||||
}
|
||||
|
||||
id = ( id && id[1] ) ? id[1].replace( /[<>&]+/g, '' ) : '';
|
||||
align = ( align && align[1] ) ? align[1] : 'alignnone';
|
||||
classes = ( classes && classes[1] ) ? ' ' + classes[1].replace( /[<>&]+/g, '' ) : '';
|
||||
|
||||
if ( ! width && img ) {
|
||||
width = img.match( /width=['"]([0-9]*)['"]/ );
|
||||
}
|
||||
|
||||
if ( width && width[1] ) {
|
||||
width = width[1];
|
||||
}
|
||||
|
||||
if ( ! width || ! caption ) {
|
||||
return c;
|
||||
}
|
||||
|
||||
width = parseInt( width, 10 );
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width += 10;
|
||||
}
|
||||
|
||||
return '<div class="mceTemp"><dl id="' + id + '" class="wp-caption ' + align + classes + '" style="width: ' + width + 'px">' +
|
||||
'<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ caption +'</dd></dl></div>';
|
||||
});
|
||||
}
|
||||
|
||||
function getShortcode( content ) {
|
||||
return content.replace( /<div (?:id="attachment_|class="mceTemp)[^>]*>([\s\S]+?)<\/div>/g, function( a, b ) {
|
||||
var out = '';
|
||||
|
||||
if ( b.indexOf('<img ') === -1 ) {
|
||||
// Broken caption. The user managed to drag the image out?
|
||||
// Try to return the caption text as a paragraph.
|
||||
out = b.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
|
||||
|
||||
if ( out && out[1] ) {
|
||||
return '<p>' + out[1] + '</p>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
out = b.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) {
|
||||
var id, classes, align, width;
|
||||
|
||||
width = c.match( /width="([0-9]*)"/ );
|
||||
width = ( width && width[1] ) ? width[1] : '';
|
||||
|
||||
classes = b.match( /class="([^"]*)"/ );
|
||||
classes = ( classes && classes[1] ) ? classes[1] : '';
|
||||
align = classes.match( /align[a-z]+/i ) || 'alignnone';
|
||||
|
||||
if ( ! width || ! caption ) {
|
||||
if ( 'alignnone' !== align[0] ) {
|
||||
c = c.replace( /><img/, ' class="' + align[0] + '"><img' );
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
id = b.match( /id="([^"]*)"/ );
|
||||
id = ( id && id[1] ) ? id[1] : '';
|
||||
|
||||
classes = classes.replace( /wp-caption ?|align[a-z]+ ?/gi, '' );
|
||||
|
||||
if ( classes ) {
|
||||
classes = ' class="' + classes + '"';
|
||||
}
|
||||
|
||||
caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
|
||||
// no line breaks inside HTML tags
|
||||
return a.replace( /[\r\n\t]+/, ' ' );
|
||||
});
|
||||
|
||||
// convert remaining line breaks to <br>
|
||||
caption = caption.replace( /\s*\n\s*/g, '<br />' );
|
||||
|
||||
return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]';
|
||||
});
|
||||
|
||||
if ( out.indexOf('[caption') === -1 ) {
|
||||
// the caption html seems broken, try to find the image that may be wrapped in a link
|
||||
// and may be followed by <p> with the caption text.
|
||||
out = b.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
|
||||
}
|
||||
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
function extractImageData( imageNode ) {
|
||||
var classes, extraClasses, metadata, captionBlock, caption, link, width, height,
|
||||
captionClassName = [],
|
||||
dom = editor.dom,
|
||||
isIntRegExp = /^\d+$/;
|
||||
|
||||
// default attributes
|
||||
metadata = {
|
||||
attachment_id: false,
|
||||
size: 'custom',
|
||||
caption: '',
|
||||
align: 'none',
|
||||
extraClasses: '',
|
||||
link: false,
|
||||
linkUrl: '',
|
||||
linkClassName: '',
|
||||
linkTargetBlank: false,
|
||||
linkRel: '',
|
||||
title: ''
|
||||
};
|
||||
|
||||
metadata.url = dom.getAttrib( imageNode, 'src' );
|
||||
metadata.alt = dom.getAttrib( imageNode, 'alt' );
|
||||
metadata.title = dom.getAttrib( imageNode, 'title' );
|
||||
|
||||
width = dom.getAttrib( imageNode, 'width' );
|
||||
height = dom.getAttrib( imageNode, 'height' );
|
||||
|
||||
if ( ! isIntRegExp.test( width ) || parseInt( width, 10 ) < 1 ) {
|
||||
width = imageNode.naturalWidth || imageNode.width;
|
||||
}
|
||||
|
||||
if ( ! isIntRegExp.test( height ) || parseInt( height, 10 ) < 1 ) {
|
||||
height = imageNode.naturalHeight || imageNode.height;
|
||||
}
|
||||
|
||||
metadata.customWidth = metadata.width = width;
|
||||
metadata.customHeight = metadata.height = height;
|
||||
|
||||
classes = tinymce.explode( imageNode.className, ' ' );
|
||||
extraClasses = [];
|
||||
|
||||
tinymce.each( classes, function( name ) {
|
||||
|
||||
if ( /^wp-image/.test( name ) ) {
|
||||
metadata.attachment_id = parseInt( name.replace( 'wp-image-', '' ), 10 );
|
||||
} else if ( /^align/.test( name ) ) {
|
||||
metadata.align = name.replace( 'align', '' );
|
||||
} else if ( /^size/.test( name ) ) {
|
||||
metadata.size = name.replace( 'size-', '' );
|
||||
} else {
|
||||
extraClasses.push( name );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
metadata.extraClasses = extraClasses.join( ' ' );
|
||||
|
||||
// Extract caption
|
||||
captionBlock = dom.getParents( imageNode, '.wp-caption' );
|
||||
|
||||
if ( captionBlock.length ) {
|
||||
captionBlock = captionBlock[0];
|
||||
|
||||
classes = captionBlock.className.split( ' ' );
|
||||
tinymce.each( classes, function( name ) {
|
||||
if ( /^align/.test( name ) ) {
|
||||
metadata.align = name.replace( 'align', '' );
|
||||
} else if ( name && name !== 'wp-caption' ) {
|
||||
captionClassName.push( name );
|
||||
}
|
||||
} );
|
||||
|
||||
metadata.captionClassName = captionClassName.join( ' ' );
|
||||
|
||||
caption = dom.select( 'dd.wp-caption-dd', captionBlock );
|
||||
if ( caption.length ) {
|
||||
caption = caption[0];
|
||||
|
||||
metadata.caption = editor.serializer.serialize( caption )
|
||||
.replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' );
|
||||
}
|
||||
}
|
||||
|
||||
// Extract linkTo
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) {
|
||||
link = imageNode.parentNode;
|
||||
metadata.linkUrl = dom.getAttrib( link, 'href' );
|
||||
metadata.linkTargetBlank = dom.getAttrib( link, 'target' ) === '_blank' ? true : false;
|
||||
metadata.linkRel = dom.getAttrib( link, 'rel' );
|
||||
metadata.linkClassName = link.className;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
function hasTextContent( node ) {
|
||||
return node && !! ( node.textContent || node.innerText );
|
||||
}
|
||||
|
||||
// Verify HTML in captions
|
||||
function verifyHTML( caption ) {
|
||||
if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) {
|
||||
return caption;
|
||||
}
|
||||
|
||||
if ( ! serializer ) {
|
||||
serializer = new tinymce.html.Serializer( {}, editor.schema );
|
||||
}
|
||||
|
||||
return serializer.serialize( editor.parser.parse( caption, { forced_root_block: false } ) );
|
||||
}
|
||||
|
||||
function updateImage( imageNode, imageData ) {
|
||||
var classes, className, node, html, parent, wrap, linkNode,
|
||||
captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
|
||||
dom = editor.dom;
|
||||
|
||||
classes = tinymce.explode( imageData.extraClasses, ' ' );
|
||||
|
||||
if ( ! classes ) {
|
||||
classes = [];
|
||||
}
|
||||
|
||||
if ( ! imageData.caption ) {
|
||||
classes.push( 'align' + imageData.align );
|
||||
}
|
||||
|
||||
if ( imageData.attachment_id ) {
|
||||
classes.push( 'wp-image-' + imageData.attachment_id );
|
||||
if ( imageData.size && imageData.size !== 'custom' ) {
|
||||
classes.push( 'size-' + imageData.size );
|
||||
}
|
||||
}
|
||||
|
||||
width = imageData.width;
|
||||
height = imageData.height;
|
||||
|
||||
if ( imageData.size === 'custom' ) {
|
||||
width = imageData.customWidth;
|
||||
height = imageData.customHeight;
|
||||
}
|
||||
|
||||
attrs = {
|
||||
src: imageData.url,
|
||||
width: width || null,
|
||||
height: height || null,
|
||||
alt: imageData.alt,
|
||||
title: imageData.title || null,
|
||||
'class': classes.join( ' ' ) || null
|
||||
};
|
||||
|
||||
dom.setAttribs( imageNode, attrs );
|
||||
|
||||
linkAttrs = {
|
||||
href: imageData.linkUrl,
|
||||
rel: imageData.linkRel || null,
|
||||
target: imageData.linkTargetBlank ? '_blank': null,
|
||||
'class': imageData.linkClassName || null
|
||||
};
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
// Update or remove an existing link wrapped around the image
|
||||
if ( imageData.linkUrl ) {
|
||||
dom.setAttribs( imageNode.parentNode, linkAttrs );
|
||||
} else {
|
||||
dom.remove( imageNode.parentNode, true );
|
||||
}
|
||||
} else if ( imageData.linkUrl ) {
|
||||
if ( linkNode = dom.getParent( imageNode, 'a' ) ) {
|
||||
// The image is inside a link together with other nodes,
|
||||
// or is nested in another node, move it out
|
||||
dom.insertAfter( imageNode, linkNode );
|
||||
}
|
||||
|
||||
// Add link wrapped around the image
|
||||
linkNode = dom.create( 'a', linkAttrs );
|
||||
imageNode.parentNode.insertBefore( linkNode, imageNode );
|
||||
linkNode.appendChild( imageNode );
|
||||
}
|
||||
|
||||
captionNode = editor.dom.getParent( imageNode, '.mceTemp' );
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
node = imageNode.parentNode;
|
||||
} else {
|
||||
node = imageNode;
|
||||
}
|
||||
|
||||
if ( imageData.caption ) {
|
||||
imageData.caption = verifyHTML( imageData.caption );
|
||||
|
||||
id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null;
|
||||
align = 'align' + ( imageData.align || 'none' );
|
||||
className = 'wp-caption ' + align;
|
||||
|
||||
if ( imageData.captionClassName ) {
|
||||
className += ' ' + imageData.captionClassName.replace( /[<>&]+/g, '' );
|
||||
}
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width = parseInt( width, 10 );
|
||||
width += 10;
|
||||
}
|
||||
|
||||
if ( captionNode ) {
|
||||
dl = dom.select( 'dl.wp-caption', captionNode );
|
||||
|
||||
if ( dl.length ) {
|
||||
dom.setAttribs( dl, {
|
||||
id: id,
|
||||
'class': className,
|
||||
style: 'width: ' + width + 'px'
|
||||
} );
|
||||
}
|
||||
|
||||
dd = dom.select( '.wp-caption-dd', captionNode );
|
||||
|
||||
if ( dd.length ) {
|
||||
dom.setHTML( dd[0], imageData.caption );
|
||||
}
|
||||
|
||||
} else {
|
||||
id = id ? 'id="'+ id +'" ' : '';
|
||||
|
||||
// should create a new function for generating the caption markup
|
||||
html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' +
|
||||
'<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>';
|
||||
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
|
||||
if ( parent = dom.getParent( node, 'p' ) ) {
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
} else {
|
||||
node.parentNode.insertBefore( wrap, node );
|
||||
}
|
||||
|
||||
editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node );
|
||||
|
||||
if ( parent && dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
}
|
||||
} else if ( captionNode ) {
|
||||
// Remove the caption wrapper and place the image in new paragraph
|
||||
parent = dom.create( 'p' );
|
||||
captionNode.parentNode.insertBefore( parent, captionNode );
|
||||
parent.appendChild( node );
|
||||
dom.remove( captionNode );
|
||||
}
|
||||
|
||||
if ( wp.media.events ) {
|
||||
wp.media.events.trigger( 'editor:image-update', {
|
||||
editor: editor,
|
||||
metadata: imageData,
|
||||
image: imageNode
|
||||
} );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
function editImage( img ) {
|
||||
var frame, callback, metadata;
|
||||
|
||||
if ( typeof wp === 'undefined' || ! wp.media ) {
|
||||
editor.execCommand( 'mceImage' );
|
||||
return;
|
||||
}
|
||||
|
||||
metadata = extractImageData( img );
|
||||
|
||||
// Manipulate the metadata by reference that is fed into the PostImage model used in the media modal
|
||||
wp.media.events.trigger( 'editor:image-edit', {
|
||||
editor: editor,
|
||||
metadata: metadata,
|
||||
image: img
|
||||
} );
|
||||
|
||||
frame = wp.media({
|
||||
frame: 'image',
|
||||
state: 'image-details',
|
||||
metadata: metadata
|
||||
} );
|
||||
|
||||
wp.media.events.trigger( 'editor:frame-create', { frame: frame } );
|
||||
|
||||
callback = function( imageData ) {
|
||||
editor.focus();
|
||||
editor.undoManager.transact( function() {
|
||||
updateImage( img, imageData );
|
||||
} );
|
||||
frame.detach();
|
||||
};
|
||||
|
||||
frame.state('image-details').on( 'update', callback );
|
||||
frame.state('replace-image').on( 'replace', callback );
|
||||
frame.on( 'close', function() {
|
||||
editor.focus();
|
||||
frame.detach();
|
||||
});
|
||||
|
||||
frame.open();
|
||||
}
|
||||
|
||||
function removeImage( node ) {
|
||||
var wrap = editor.dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( ! wrap && node.nodeName === 'IMG' ) {
|
||||
wrap = editor.dom.getParent( node, 'a' );
|
||||
}
|
||||
|
||||
if ( wrap ) {
|
||||
if ( wrap.nextSibling ) {
|
||||
editor.selection.select( wrap.nextSibling );
|
||||
} else if ( wrap.previousSibling ) {
|
||||
editor.selection.select( wrap.previousSibling );
|
||||
} else {
|
||||
editor.selection.select( wrap.parentNode );
|
||||
}
|
||||
|
||||
editor.selection.collapse( true );
|
||||
editor.dom.remove( wrap );
|
||||
} else {
|
||||
editor.dom.remove( node );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
editor.undoManager.add();
|
||||
}
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var dom = editor.dom,
|
||||
captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions';
|
||||
|
||||
dom.addClass( editor.getBody(), captionClass );
|
||||
|
||||
// Add caption field to the default image dialog
|
||||
editor.on( 'wpLoadImageForm', function( event ) {
|
||||
if ( editor.getParam( 'wpeditimage_disable_captions' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var captionField = {
|
||||
type: 'textbox',
|
||||
flex: 1,
|
||||
name: 'caption',
|
||||
minHeight: 60,
|
||||
multiline: true,
|
||||
scroll: true,
|
||||
label: 'Image caption'
|
||||
};
|
||||
|
||||
event.data.splice( event.data.length - 1, 0, captionField );
|
||||
});
|
||||
|
||||
// Fix caption parent width for images added from URL
|
||||
editor.on( 'wpNewImageRefresh', function( event ) {
|
||||
var parent, captionWidth;
|
||||
|
||||
if ( parent = dom.getParent( event.node, 'dl.wp-caption' ) ) {
|
||||
if ( ! parent.style.width ) {
|
||||
captionWidth = parseInt( event.node.clientWidth, 10 ) + 10;
|
||||
captionWidth = captionWidth ? captionWidth + 'px' : '50%';
|
||||
dom.setStyle( parent, 'width', captionWidth );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'wpImageFormSubmit', function( event ) {
|
||||
var data = event.imgData.data,
|
||||
imgNode = event.imgData.node,
|
||||
caption = event.imgData.caption,
|
||||
captionId = '',
|
||||
captionAlign = '',
|
||||
captionWidth = '',
|
||||
wrap, parent, node, html, imgId;
|
||||
|
||||
// Temp image id so we can find the node later
|
||||
data.id = '__wp-temp-img-id';
|
||||
// Cancel the original callback
|
||||
event.imgData.cancel = true;
|
||||
|
||||
if ( ! data.style ) {
|
||||
data.style = null;
|
||||
}
|
||||
|
||||
if ( ! data.src ) {
|
||||
// Delete the image and the caption
|
||||
if ( imgNode ) {
|
||||
if ( wrap = dom.getParent( imgNode, 'div.mceTemp' ) ) {
|
||||
dom.remove( wrap );
|
||||
} else if ( imgNode.parentNode.nodeName === 'A' ) {
|
||||
dom.remove( imgNode.parentNode );
|
||||
} else {
|
||||
dom.remove( imgNode );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( caption ) {
|
||||
caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<\/?[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
|
||||
// No line breaks inside HTML tags
|
||||
return a.replace( /[\r\n\t]+/, ' ' );
|
||||
});
|
||||
|
||||
// Convert remaining line breaks to <br>
|
||||
caption = caption.replace( /(<br[^>]*>)\s*\n\s*/g, '$1' ).replace( /\s*\n\s*/g, '<br />' );
|
||||
caption = verifyHTML( caption );
|
||||
}
|
||||
|
||||
if ( ! imgNode ) {
|
||||
// New image inserted
|
||||
html = dom.createHTML( 'img', data );
|
||||
|
||||
if ( caption ) {
|
||||
node = editor.selection.getNode();
|
||||
|
||||
if ( data.width ) {
|
||||
captionWidth = parseInt( data.width, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
captionWidth += 10;
|
||||
}
|
||||
|
||||
captionWidth = ' style="width: ' + captionWidth + 'px"';
|
||||
}
|
||||
|
||||
html = '<dl class="wp-caption alignnone"' + captionWidth + '>' +
|
||||
'<dt class="wp-caption-dt">'+ html +'</dt><dd class="wp-caption-dd">'+ caption +'</dd></dl>';
|
||||
|
||||
if ( node.nodeName === 'P' ) {
|
||||
parent = node;
|
||||
} else {
|
||||
parent = dom.getParent( node, 'p' );
|
||||
}
|
||||
|
||||
if ( parent && parent.nodeName === 'P' ) {
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
editor.selection.select( wrap );
|
||||
editor.nodeChanged();
|
||||
|
||||
if ( dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
} else {
|
||||
editor.selection.setContent( '<div class="mceTemp">' + html + '</div>' );
|
||||
}
|
||||
} else {
|
||||
editor.selection.setContent( html );
|
||||
}
|
||||
} else {
|
||||
// Edit existing image
|
||||
|
||||
// Store the original image id if any
|
||||
imgId = imgNode.id || null;
|
||||
// Update the image node
|
||||
dom.setAttribs( imgNode, data );
|
||||
wrap = dom.getParent( imgNode, 'dl.wp-caption' );
|
||||
|
||||
if ( caption ) {
|
||||
if ( wrap ) {
|
||||
if ( parent = dom.select( 'dd.wp-caption-dd', wrap )[0] ) {
|
||||
parent.innerHTML = caption;
|
||||
}
|
||||
} else {
|
||||
if ( imgNode.className ) {
|
||||
captionId = imgNode.className.match( /wp-image-([0-9]+)/ );
|
||||
captionAlign = imgNode.className.match( /align(left|right|center|none)/ );
|
||||
}
|
||||
|
||||
if ( captionAlign ) {
|
||||
captionAlign = captionAlign[0];
|
||||
imgNode.className = imgNode.className.replace( /align(left|right|center|none)/g, '' );
|
||||
} else {
|
||||
captionAlign = 'alignnone';
|
||||
}
|
||||
|
||||
captionAlign = ' class="wp-caption ' + captionAlign + '"';
|
||||
|
||||
if ( captionId ) {
|
||||
captionId = ' id="attachment_' + captionId[1] + '"';
|
||||
}
|
||||
|
||||
captionWidth = data.width || imgNode.clientWidth;
|
||||
|
||||
if ( captionWidth ) {
|
||||
captionWidth = parseInt( captionWidth, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
captionWidth += 10;
|
||||
}
|
||||
|
||||
captionWidth = ' style="width: '+ captionWidth +'px"';
|
||||
}
|
||||
|
||||
if ( imgNode.parentNode && imgNode.parentNode.nodeName === 'A' ) {
|
||||
node = imgNode.parentNode;
|
||||
} else {
|
||||
node = imgNode;
|
||||
}
|
||||
|
||||
html = '<dl ' + captionId + captionAlign + captionWidth + '>' +
|
||||
'<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ caption +'</dd></dl>';
|
||||
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
|
||||
if ( parent = dom.getParent( node, 'p' ) ) {
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
} else {
|
||||
node.parentNode.insertBefore( wrap, node );
|
||||
}
|
||||
|
||||
editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node );
|
||||
|
||||
if ( parent && dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( wrap ) {
|
||||
// Remove the caption wrapper and place the image in new paragraph
|
||||
if ( imgNode.parentNode.nodeName === 'A' ) {
|
||||
html = dom.getOuterHTML( imgNode.parentNode );
|
||||
} else {
|
||||
html = dom.getOuterHTML( imgNode );
|
||||
}
|
||||
|
||||
parent = dom.create( 'p', {}, html );
|
||||
dom.insertAfter( parent, wrap.parentNode );
|
||||
editor.selection.select( parent );
|
||||
editor.nodeChanged();
|
||||
dom.remove( wrap.parentNode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imgNode = dom.get('__wp-temp-img-id');
|
||||
dom.setAttrib( imgNode, 'id', imgId );
|
||||
event.imgData.node = imgNode;
|
||||
});
|
||||
|
||||
editor.on( 'wpLoadImageData', function( event ) {
|
||||
var parent,
|
||||
data = event.imgData.data,
|
||||
imgNode = event.imgData.node;
|
||||
|
||||
if ( parent = dom.getParent( imgNode, 'dl.wp-caption' ) ) {
|
||||
parent = dom.select( 'dd.wp-caption-dd', parent )[0];
|
||||
|
||||
if ( parent ) {
|
||||
data.caption = editor.serializer.serialize( parent )
|
||||
.replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dom.bind( editor.getDoc(), 'dragstart', function( event ) {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
// Prevent dragging images out of the caption elements
|
||||
if ( node.nodeName === 'IMG' && dom.getParent( node, '.wp-caption' ) ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent IE11 from making dl.wp-caption resizable
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) {
|
||||
// The 'mscontrolselect' event is supported only in IE11+
|
||||
dom.bind( editor.getBody(), 'mscontrolselect', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) {
|
||||
// Hide the thick border with resize handles around dl.wp-caption
|
||||
editor.getBody().focus(); // :(
|
||||
} else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) {
|
||||
// Trigger the thick border with resize handles...
|
||||
// This will make the caption text editable.
|
||||
event.target.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ObjectResized', function( event ) {
|
||||
var node = event.target;
|
||||
|
||||
if ( node.nodeName === 'IMG' ) {
|
||||
editor.undoManager.transact( function() {
|
||||
var parent, width,
|
||||
dom = editor.dom;
|
||||
|
||||
node.className = node.className.replace( /\bsize-[^ ]+/, '' );
|
||||
|
||||
if ( parent = dom.getParent( node, '.wp-caption' ) ) {
|
||||
width = event.width || dom.getAttrib( node, 'width' );
|
||||
|
||||
if ( width ) {
|
||||
width = parseInt( width, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width += 10;
|
||||
}
|
||||
|
||||
dom.setStyle( parent, 'width', width + 'px' );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeExecCommand', function( event ) {
|
||||
var node, p, DL, align, replacement,
|
||||
cmd = event.command,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( cmd === 'mceInsertContent' ) {
|
||||
// When inserting content, if the caret is inside a caption create new paragraph under
|
||||
// and move the caret there
|
||||
if ( node = dom.getParent( editor.selection.getNode(), 'div.mceTemp' ) ) {
|
||||
p = dom.create( 'p' );
|
||||
dom.insertAfter( p, node );
|
||||
editor.selection.setCursorLocation( p, 0 );
|
||||
editor.nodeChanged();
|
||||
}
|
||||
} else if ( cmd === 'JustifyLeft' || cmd === 'JustifyRight' || cmd === 'JustifyCenter' || cmd === 'wpAlignNone' ) {
|
||||
node = editor.selection.getNode();
|
||||
align = 'align' + cmd.slice( 7 ).toLowerCase();
|
||||
DL = editor.dom.getParent( node, '.wp-caption' );
|
||||
|
||||
if ( node.nodeName !== 'IMG' && ! DL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = DL || node;
|
||||
|
||||
if ( editor.dom.hasClass( node, align ) ) {
|
||||
replacement = ' alignnone';
|
||||
} else {
|
||||
replacement = ' ' + align;
|
||||
}
|
||||
|
||||
node.className = trim( node.className.replace( / ?align(left|center|right|none)/g, '' ) + replacement );
|
||||
|
||||
editor.nodeChanged();
|
||||
event.preventDefault();
|
||||
|
||||
if ( toolbar ) {
|
||||
toolbar.reposition();
|
||||
}
|
||||
|
||||
editor.fire( 'ExecCommand', {
|
||||
command: cmd,
|
||||
ui: event.ui,
|
||||
value: event.value
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'keydown', function( event ) {
|
||||
var node, wrap, P, spacer,
|
||||
selection = editor.selection,
|
||||
keyCode = event.keyCode,
|
||||
dom = editor.dom,
|
||||
VK = tinymce.util.VK;
|
||||
|
||||
if ( keyCode === VK.ENTER ) {
|
||||
// When pressing Enter inside a caption move the caret to a new parapraph under it
|
||||
node = selection.getNode();
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( wrap ) {
|
||||
dom.events.cancel( event ); // Doesn't cancel all :(
|
||||
|
||||
// Remove any extra dt and dd cleated on pressing Enter...
|
||||
tinymce.each( dom.select( 'dt, dd', wrap ), function( element ) {
|
||||
if ( dom.isEmpty( element ) ) {
|
||||
dom.remove( element );
|
||||
}
|
||||
});
|
||||
|
||||
spacer = tinymce.Env.ie && tinymce.Env.ie < 11 ? '' : '<br data-mce-bogus="1" />';
|
||||
P = dom.create( 'p', null, spacer );
|
||||
|
||||
if ( node.nodeName === 'DD' ) {
|
||||
dom.insertAfter( P, wrap );
|
||||
} else {
|
||||
wrap.parentNode.insertBefore( P, wrap );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
selection.setCursorLocation( P, 0 );
|
||||
}
|
||||
} else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) {
|
||||
node = selection.getNode();
|
||||
|
||||
if ( node.nodeName === 'DIV' && dom.hasClass( node, 'mceTemp' ) ) {
|
||||
wrap = node;
|
||||
} else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) {
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
}
|
||||
|
||||
if ( wrap ) {
|
||||
dom.events.cancel( event );
|
||||
removeImage( node );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
|
||||
// This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
|
||||
// Collapse the selection to remove the resize handles.
|
||||
if ( tinymce.Env.gecko ) {
|
||||
editor.on( 'undo redo', function() {
|
||||
if ( editor.selection.getNode().nodeName === 'IMG' ) {
|
||||
editor.selection.collapse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editor.wpSetImgCaption = function( content ) {
|
||||
return parseShortcode( content );
|
||||
};
|
||||
|
||||
editor.wpGetImgCaption = function( content ) {
|
||||
return getShortcode( content );
|
||||
};
|
||||
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
if ( event.format !== 'raw' ) {
|
||||
event.content = editor.wpSetImgCaption( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'PostProcess', function( event ) {
|
||||
if ( event.get ) {
|
||||
event.content = editor.wpGetImgCaption( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
// Add to editor.wp
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.isPlaceholder = isPlaceholder;
|
||||
|
||||
// Back-compat.
|
||||
return {
|
||||
_do_shcode: parseShortcode,
|
||||
_get_shcode: getShortcode
|
||||
};
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
128
wp-includes/js/tinymce/plugins/wpemoji/plugin.js
Normal file
128
wp-includes/js/tinymce/plugins/wpemoji/plugin.js
Normal file
@@ -0,0 +1,128 @@
|
||||
( function( tinymce, wp ) {
|
||||
tinymce.PluginManager.add( 'wpemoji', function( editor ) {
|
||||
var typing,
|
||||
env = tinymce.Env,
|
||||
ua = window.navigator.userAgent,
|
||||
isWin = ua.indexOf( 'Windows' ) > -1,
|
||||
isWin8 = ( function() {
|
||||
var match = ua.match( /Windows NT 6\.(\d)/ );
|
||||
|
||||
if ( match && match[1] > 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}());
|
||||
|
||||
if ( ! wp || ! wp.emoji || ! wp.emoji.replaceEmoji ) {
|
||||
return;
|
||||
}
|
||||
|
||||
function setImgAttr( image ) {
|
||||
image.className = 'emoji';
|
||||
image.setAttribute( 'data-mce-resize', 'false' );
|
||||
image.setAttribute( 'data-mce-placeholder', '1' );
|
||||
image.setAttribute( 'data-wp-emoji', '1' );
|
||||
}
|
||||
|
||||
function replaceEmoji( node ) {
|
||||
var imgAttr = {
|
||||
'data-mce-resize': 'false',
|
||||
'data-mce-placeholder': '1',
|
||||
'data-wp-emoji': '1'
|
||||
};
|
||||
|
||||
wp.emoji.parse( node, { imgAttr: imgAttr } );
|
||||
}
|
||||
|
||||
// Test if the node text contains emoji char(s) and replace.
|
||||
function parseNode( node ) {
|
||||
var selection, bookmark;
|
||||
|
||||
if ( node && window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) {
|
||||
if ( env.webkit ) {
|
||||
selection = editor.selection;
|
||||
bookmark = selection.getBookmark();
|
||||
}
|
||||
|
||||
replaceEmoji( node );
|
||||
|
||||
if ( env.webkit ) {
|
||||
selection.moveToBookmark( bookmark );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isWin8 ) {
|
||||
// Windows 8+ emoji can be "typed" with the onscreen keyboard.
|
||||
// That triggers the normal keyboard events, but not the 'input' event.
|
||||
// Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
|
||||
editor.on( 'keyup', function( event ) {
|
||||
if ( event.keyCode === 231 ) {
|
||||
parseNode( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
} else if ( ! isWin ) {
|
||||
// In MacOS inserting emoji doesn't trigger the stanradr keyboard events.
|
||||
// Thankfully it triggers the 'input' event.
|
||||
// This works in Android and iOS as well.
|
||||
editor.on( 'keydown keyup', function( event ) {
|
||||
typing = ( event.type === 'keydown' );
|
||||
} );
|
||||
|
||||
editor.on( 'input', function() {
|
||||
if ( typing ) {
|
||||
return;
|
||||
}
|
||||
|
||||
parseNode( editor.selection.getNode() );
|
||||
});
|
||||
}
|
||||
|
||||
editor.on( 'setcontent', function( event ) {
|
||||
var selection = editor.selection,
|
||||
node = selection.getNode();
|
||||
|
||||
if ( window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) {
|
||||
replaceEmoji( node );
|
||||
|
||||
// In IE all content in the editor is left selected after wp.emoji.parse()...
|
||||
// Collapse the selection to the beginning.
|
||||
if ( env.ie && env.ie < 9 && event.load && node && node.nodeName === 'BODY' ) {
|
||||
selection.collapse( true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Convert Twemoji compatible pasted emoji replacement images into our format.
|
||||
editor.on( 'PastePostProcess', function( event ) {
|
||||
if ( window.twemoji ) {
|
||||
tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) {
|
||||
if ( image.alt && window.twemoji.test( image.alt ) ) {
|
||||
setImgAttr( image );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'postprocess', function( event ) {
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<img[^>]+data-wp-emoji="[^>]+>/g, function( img ) {
|
||||
var alt = img.match( /alt="([^"]+)"/ );
|
||||
|
||||
if ( alt && alt[1] ) {
|
||||
return alt[1];
|
||||
}
|
||||
|
||||
return img;
|
||||
});
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'resolvename', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && editor.dom.getAttrib( event.target, 'data-wp-emoji' ) ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} )( window.tinymce, window.wp );
|
||||
1
wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b){a.PluginManager.add("wpemoji",function(c){function d(a){a.className="emoji",a.setAttribute("data-mce-resize","false"),a.setAttribute("data-mce-placeholder","1"),a.setAttribute("data-wp-emoji","1")}function e(a){var c={"data-mce-resize":"false","data-mce-placeholder":"1","data-wp-emoji":"1"};b.emoji.parse(a,{imgAttr:c})}function f(a){var b,d;a&&window.twemoji&&window.twemoji.test(a.textContent||a.innerText)&&(h.webkit&&(b=c.selection,d=b.getBookmark()),e(a),h.webkit&&b.moveToBookmark(d))}var g,h=a.Env,i=window.navigator.userAgent,j=i.indexOf("Windows")>-1,k=function(){var a=i.match(/Windows NT 6\.(\d)/);return a&&a[1]>1?!0:!1}();b&&b.emoji&&b.emoji.replaceEmoji&&(k?c.on("keyup",function(a){231===a.keyCode&&f(c.selection.getNode())}):j||(c.on("keydown keyup",function(a){g="keydown"===a.type}),c.on("input",function(){g||f(c.selection.getNode())})),c.on("setcontent",function(a){var b=c.selection,d=b.getNode();window.twemoji&&window.twemoji.test(d.textContent||d.innerText)&&(e(d),h.ie&&h.ie<9&&a.load&&d&&"BODY"===d.nodeName&&b.collapse(!0))}),c.on("PastePostProcess",function(b){window.twemoji&&a.each(c.dom.$("img.emoji",b.node),function(a){a.alt&&window.twemoji.test(a.alt)&&d(a)})}),c.on("postprocess",function(a){a.content&&(a.content=a.content.replace(/<img[^>]+data-wp-emoji="[^>]+>/g,function(a){var b=a.match(/alt="([^"]+)"/);return b&&b[1]?b[1]:a}))}),c.on("resolvename",function(a){"IMG"===a.target.nodeName&&c.dom.getAttrib(a.target,"data-wp-emoji")&&a.preventDefault()}))})}(window.tinymce,window.wp);
|
||||
112
wp-includes/js/tinymce/plugins/wpgallery/plugin.js
Normal file
112
wp-includes/js/tinymce/plugins/wpgallery/plugin.js
Normal file
@@ -0,0 +1,112 @@
|
||||
/* global tinymce */
|
||||
tinymce.PluginManager.add('wpgallery', function( editor ) {
|
||||
|
||||
function replaceGalleryShortcodes( content ) {
|
||||
return content.replace( /\[gallery([^\]]*)\]/g, function( match ) {
|
||||
return html( 'wp-gallery', match );
|
||||
});
|
||||
}
|
||||
|
||||
function html( cls, data ) {
|
||||
data = window.encodeURIComponent( data );
|
||||
return '<img src="' + tinymce.Env.transparentSrc + '" class="wp-media mceItem ' + cls + '" ' +
|
||||
'data-wp-media="' + data + '" data-mce-resize="false" data-mce-placeholder="1" />';
|
||||
}
|
||||
|
||||
function restoreMediaShortcodes( content ) {
|
||||
function getAttr( str, name ) {
|
||||
name = new RegExp( name + '=\"([^\"]+)\"' ).exec( str );
|
||||
return name ? window.decodeURIComponent( name[1] ) : '';
|
||||
}
|
||||
|
||||
return content.replace( /(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g, function( match, image ) {
|
||||
var data = getAttr( image, 'data-wp-media' );
|
||||
|
||||
if ( data ) {
|
||||
return '<p>' + data + '</p>';
|
||||
}
|
||||
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
function editMedia( node ) {
|
||||
var gallery, frame, data;
|
||||
|
||||
if ( node.nodeName !== 'IMG' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the `wp.media` API exists.
|
||||
if ( typeof wp === 'undefined' || ! wp.media ) {
|
||||
return;
|
||||
}
|
||||
|
||||
data = window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) );
|
||||
|
||||
// Make sure we've selected a gallery node.
|
||||
if ( editor.dom.hasClass( node, 'wp-gallery' ) && wp.media.gallery ) {
|
||||
gallery = wp.media.gallery;
|
||||
frame = gallery.edit( data );
|
||||
|
||||
frame.state('gallery-edit').on( 'update', function( selection ) {
|
||||
var shortcode = gallery.shortcode( selection ).string();
|
||||
editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );
|
||||
frame.detach();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
|
||||
editor.addCommand( 'WP_Gallery', function() {
|
||||
editMedia( editor.selection.getNode() );
|
||||
});
|
||||
|
||||
editor.on( 'mouseup', function( event ) {
|
||||
var dom = editor.dom,
|
||||
node = event.target;
|
||||
|
||||
function unselect() {
|
||||
dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' );
|
||||
}
|
||||
|
||||
if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
|
||||
// Don't trigger on right-click
|
||||
if ( event.button !== 2 ) {
|
||||
if ( dom.hasClass( node, 'wp-media-selected' ) ) {
|
||||
editMedia( node );
|
||||
} else {
|
||||
unselect();
|
||||
dom.addClass( node, 'wp-media-selected' );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unselect();
|
||||
}
|
||||
});
|
||||
|
||||
// Display gallery, audio or video instead of img in the element path
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
var dom = editor.dom,
|
||||
node = event.target;
|
||||
|
||||
if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
|
||||
if ( dom.hasClass( node, 'wp-gallery' ) ) {
|
||||
event.name = 'gallery';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
// 'wpview' handles the gallery shortcode when present
|
||||
if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) {
|
||||
event.content = replaceGalleryShortcodes( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'PostProcess', function( event ) {
|
||||
if ( event.get ) {
|
||||
event.content = restoreMediaShortcodes( event.content );
|
||||
}
|
||||
});
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("wpgallery",function(a){function b(a){return a.replace(/\[gallery([^\]]*)\]/g,function(a){return c("wp-gallery",a)})}function c(a,b){return b=window.encodeURIComponent(b),'<img src="'+tinymce.Env.transparentSrc+'" class="wp-media mceItem '+a+'" data-wp-media="'+b+'" data-mce-resize="false" data-mce-placeholder="1" />'}function d(a){function b(a,b){return b=new RegExp(b+'="([^"]+)"').exec(a),b?window.decodeURIComponent(b[1]):""}return a.replace(/(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g,function(a,c){var d=b(c,"data-wp-media");return d?"<p>"+d+"</p>":a})}function e(b){var c,d,e;"IMG"===b.nodeName&&"undefined"!=typeof wp&&wp.media&&(e=window.decodeURIComponent(a.dom.getAttrib(b,"data-wp-media")),a.dom.hasClass(b,"wp-gallery")&&wp.media.gallery&&(c=wp.media.gallery,d=c.edit(e),d.state("gallery-edit").on("update",function(e){var f=c.shortcode(e).string();a.dom.setAttrib(b,"data-wp-media",window.encodeURIComponent(f)),d.detach()})))}a.addCommand("WP_Gallery",function(){e(a.selection.getNode())}),a.on("mouseup",function(b){function c(){d.removeClass(d.select("img.wp-media-selected"),"wp-media-selected")}var d=a.dom,f=b.target;"IMG"===f.nodeName&&d.getAttrib(f,"data-wp-media")?2!==b.button&&(d.hasClass(f,"wp-media-selected")?e(f):(c(),d.addClass(f,"wp-media-selected"))):c()}),a.on("ResolveName",function(b){var c=a.dom,d=b.target;"IMG"===d.nodeName&&c.getAttrib(d,"data-wp-media")&&c.hasClass(d,"wp-gallery")&&(b.name="gallery")}),a.on("BeforeSetContent",function(c){a.plugins.wpview&&"undefined"!=typeof wp&&wp.mce||(c.content=b(c.content))}),a.on("PostProcess",function(a){a.get&&(a.content=d(a.content))})});
|
||||
148
wp-includes/js/tinymce/plugins/wplink/plugin.js
Normal file
148
wp-includes/js/tinymce/plugins/wplink/plugin.js
Normal file
@@ -0,0 +1,148 @@
|
||||
( function( tinymce ) {
|
||||
tinymce.ui.WPLinkPreview = tinymce.ui.Control.extend( {
|
||||
url: '#',
|
||||
renderHtml: function() {
|
||||
return (
|
||||
'<div id="' + this._id + '" class="wp-link-preview">' +
|
||||
'<a href="' + this.url + '" target="_blank" tabindex="-1">' + this.url + '</a>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
setURL: function( url ) {
|
||||
var index, lastIndex;
|
||||
|
||||
if ( this.url !== url ) {
|
||||
this.url = url;
|
||||
|
||||
url = window.decodeURIComponent( url );
|
||||
|
||||
url = url.replace( /^(?:https?:)?\/\/(?:www\.)?/, '' );
|
||||
|
||||
if ( ( index = url.indexOf( '?' ) ) !== -1 ) {
|
||||
url = url.slice( 0, index );
|
||||
}
|
||||
|
||||
if ( ( index = url.indexOf( '#' ) ) !== -1 ) {
|
||||
url = url.slice( 0, index );
|
||||
}
|
||||
|
||||
url = url.replace( /(?:index)?\.html$/, '' );
|
||||
|
||||
if ( url.charAt( url.length - 1 ) === '/' ) {
|
||||
url = url.slice( 0, -1 );
|
||||
}
|
||||
|
||||
// If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with ...
|
||||
if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) {
|
||||
// If the beginning + ending are shorter that 40 chars, show more of the ending
|
||||
if ( index + url.length - lastIndex < 40 ) {
|
||||
lastIndex = -( 40 - ( index + 1 ) );
|
||||
}
|
||||
|
||||
url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex );
|
||||
}
|
||||
|
||||
tinymce.$( this.getEl().firstChild ).attr( 'href', this.url ).text( url );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
tinymce.PluginManager.add( 'wplink', function( editor ) {
|
||||
var toolbar;
|
||||
|
||||
editor.addCommand( 'WP_Link', function() {
|
||||
window.wpLink && window.wpLink.open( editor.id );
|
||||
});
|
||||
|
||||
// WP default shortcut
|
||||
editor.addShortcut( 'Alt+Shift+A', '', 'WP_Link' );
|
||||
// The "de-facto standard" shortcut, see #27305
|
||||
editor.addShortcut( 'Meta+K', '', 'WP_Link' );
|
||||
|
||||
editor.addButton( 'link', {
|
||||
icon: 'link',
|
||||
tooltip: 'Insert/edit link',
|
||||
cmd: 'WP_Link',
|
||||
stateSelector: 'a[href]'
|
||||
});
|
||||
|
||||
editor.addButton( 'unlink', {
|
||||
icon: 'unlink',
|
||||
tooltip: 'Remove link',
|
||||
cmd: 'unlink'
|
||||
});
|
||||
|
||||
editor.addMenuItem( 'link', {
|
||||
icon: 'link',
|
||||
text: 'Insert/edit link',
|
||||
cmd: 'WP_Link',
|
||||
stateSelector: 'a[href]',
|
||||
context: 'insert',
|
||||
prependToContext: true
|
||||
});
|
||||
|
||||
editor.on( 'pastepreprocess', function( event ) {
|
||||
var pastedStr = event.content,
|
||||
regExp = /^(?:https?:)?\/\/\S+$/i;
|
||||
|
||||
if ( ! editor.selection.isCollapsed() && ! regExp.test( editor.selection.getContent() ) ) {
|
||||
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
|
||||
pastedStr = tinymce.trim( pastedStr );
|
||||
|
||||
if ( regExp.test( pastedStr ) ) {
|
||||
editor.execCommand( 'mceInsertLink', false, {
|
||||
href: editor.dom.decode( pastedStr )
|
||||
} );
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_preview', {
|
||||
type: 'WPLinkPreview',
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
var anchor = editor.dom.getParent( event.element, 'a' ),
|
||||
$anchor,
|
||||
href;
|
||||
|
||||
if ( anchor ) {
|
||||
$anchor = editor.$( anchor );
|
||||
href = $anchor.attr( 'href' );
|
||||
|
||||
if ( href && ! $anchor.find( 'img' ).length ) {
|
||||
self.setURL( href );
|
||||
event.element = anchor;
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_edit', {
|
||||
tooltip: 'Edit ', // trailing space is needed, used for context
|
||||
icon: 'dashicon dashicons-edit',
|
||||
cmd: 'WP_Link'
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
cmd: 'unlink'
|
||||
} );
|
||||
|
||||
editor.on( 'preinit', function() {
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_link_preview',
|
||||
'wp_link_edit',
|
||||
'wp_link_remove'
|
||||
], true );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} )( window.tinymce );
|
||||
1
wp-includes/js/tinymce/plugins/wplink/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wplink/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a){a.ui.WPLinkPreview=a.ui.Control.extend({url:"#",renderHtml:function(){return'<div id="'+this._id+'" class="wp-link-preview"><a href="'+this.url+'" target="_blank" tabindex="-1">'+this.url+"</a></div>"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),-1!==(c=b.indexOf("?"))&&(b=b.slice(0,c)),-1!==(c=b.indexOf("#"))&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),b.length>40&&-1!==(c=b.indexOf("/"))&&-1!==(d=b.lastIndexOf("/"))&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}}),a.PluginManager.add("wplink",function(b){var c;b.addCommand("WP_Link",function(){window.wpLink&&window.wpLink.open(b.id)}),b.addShortcut("Alt+Shift+A","","WP_Link"),b.addShortcut("Meta+K","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){var a=this;b.on("wptoolbar",function(d){var e,f,g=b.dom.getParent(d.element,"a");g&&(e=b.$(g),f=e.attr("href"),f&&!e.find("img").length&&(a.setURL(f),d.element=g,d.toolbar=c))})}}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",cmd:"unlink"}),b.on("preinit",function(){b.wp&&b.wp._createToolbar&&(c=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0))})})}(window.tinymce);
|
||||
178
wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
Normal file
178
wp-includes/js/tinymce/plugins/wptextpattern/plugin.js
Normal file
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* Text pattern plugin for TinyMCE
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
* This plugin can automatically format text patterns as you type. It includes two patterns:
|
||||
* - Unordered list (`* ` and `- `).
|
||||
* - Ordered list (`1. ` and `1) `).
|
||||
*
|
||||
* If the transformation in unwanted, the user can undo the change by pressing backspace,
|
||||
* using the undo shortcut, or the undo button in the toolbar.
|
||||
*/
|
||||
( function( tinymce, setTimeout ) {
|
||||
tinymce.PluginManager.add( 'wptextpattern', function( editor ) {
|
||||
var VK = tinymce.util.VK,
|
||||
spacePatterns = [
|
||||
{ regExp: /^[*-]\s/, cmd: 'InsertUnorderedList' },
|
||||
{ regExp: /^1[.)]\s/, cmd: 'InsertOrderedList' }
|
||||
],
|
||||
enterPatterns = [
|
||||
{ start: '##', format: 'h2' },
|
||||
{ start: '###', format: 'h3' },
|
||||
{ start: '####', format: 'h4' },
|
||||
{ start: '#####', format: 'h5' },
|
||||
{ start: '######', format: 'h6' },
|
||||
{ start: '>', format: 'blockquote' }
|
||||
],
|
||||
canUndo, refNode, refPattern;
|
||||
|
||||
editor.on( 'selectionchange', function() {
|
||||
canUndo = null;
|
||||
} );
|
||||
|
||||
editor.on( 'keydown', function( event ) {
|
||||
if ( ( canUndo && event.keyCode === 27 /* ESCAPE */ ) || ( canUndo === 'space' && event.keyCode === VK.BACKSPACE ) ) {
|
||||
editor.undoManager.undo();
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
if ( event.keyCode === VK.ENTER && ! VK.modifierPressed( event ) ) {
|
||||
watchEnter();
|
||||
}
|
||||
}, true );
|
||||
|
||||
editor.on( 'keyup', function( event ) {
|
||||
if ( event.keyCode === VK.SPACEBAR && ! event.ctrlKey && ! event.metaKey && ! event.altKey ) {
|
||||
space();
|
||||
} else if ( event.keyCode === VK.ENTER && ! VK.modifierPressed( event ) ) {
|
||||
enter();
|
||||
}
|
||||
} );
|
||||
|
||||
function firstTextNode( node ) {
|
||||
var parent = editor.dom.getParent( node, 'p' ),
|
||||
child;
|
||||
|
||||
if ( ! parent ) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ( child = parent.firstChild ) {
|
||||
if ( child.nodeType !== 3 ) {
|
||||
parent = child;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! child ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! child.data ) {
|
||||
if ( child.nextSibling && child.nextSibling.nodeType === 3 ) {
|
||||
child = child.nextSibling;
|
||||
} else {
|
||||
child = null;
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
function space() {
|
||||
var rng = editor.selection.getRng(),
|
||||
node = rng.startContainer,
|
||||
parent,
|
||||
text;
|
||||
|
||||
if ( ! node || firstTextNode( node ) !== node ) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent = node.parentNode;
|
||||
text = node.data;
|
||||
|
||||
tinymce.each( spacePatterns, function( pattern ) {
|
||||
var match = text.match( pattern.regExp );
|
||||
|
||||
if ( ! match || rng.startOffset !== match[0].length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.undoManager.add();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
node.deleteData( 0, match[0].length );
|
||||
|
||||
if ( ! parent.innerHTML ) {
|
||||
parent.appendChild( document.createElement( 'br' ) );
|
||||
}
|
||||
|
||||
editor.selection.setCursorLocation( parent );
|
||||
editor.execCommand( pattern.cmd );
|
||||
} );
|
||||
|
||||
// We need to wait for native events to be triggered.
|
||||
setTimeout( function() {
|
||||
canUndo = 'space';
|
||||
} );
|
||||
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
function watchEnter() {
|
||||
var rng = editor.selection.getRng(),
|
||||
start = rng.startContainer,
|
||||
node = firstTextNode( start ),
|
||||
i = enterPatterns.length,
|
||||
text, pattern;
|
||||
|
||||
if ( ! node ) {
|
||||
return;
|
||||
}
|
||||
|
||||
text = node.data;
|
||||
|
||||
while ( i-- ) {
|
||||
if ( text.indexOf( enterPatterns[ i ].start ) === 0 ) {
|
||||
pattern = enterPatterns[ i ];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! pattern ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( node === start && tinymce.trim( text ) === pattern.start ) {
|
||||
return;
|
||||
}
|
||||
|
||||
refNode = node;
|
||||
refPattern = pattern;
|
||||
}
|
||||
|
||||
function enter() {
|
||||
if ( refNode ) {
|
||||
editor.undoManager.add();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
editor.formatter.apply( refPattern.format, {}, refNode );
|
||||
refNode.replaceData( 0, refNode.data.length, tinymce.trim( refNode.data.slice( refPattern.start.length ) ) );
|
||||
} );
|
||||
|
||||
// We need to wait for native events to be triggered.
|
||||
setTimeout( function() {
|
||||
canUndo = 'enter';
|
||||
} );
|
||||
}
|
||||
|
||||
refNode = null;
|
||||
refPattern = null;
|
||||
}
|
||||
} );
|
||||
} )( window.tinymce, window.setTimeout );
|
||||
1
wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a,b){a.PluginManager.add("wptextpattern",function(c){function d(a){var b,d=c.dom.getParent(a,"p");if(d){for(;(b=d.firstChild)&&3!==b.nodeType;)d=b;if(b)return b.data||(b=b.nextSibling&&3===b.nextSibling.nodeType?b.nextSibling:null),b}}function e(){var e,f,g=c.selection.getRng(),i=g.startContainer;i&&d(i)===i&&(e=i.parentNode,f=i.data,a.each(l,function(a){var d=f.match(a.regExp);if(d&&g.startOffset===d[0].length)return c.undoManager.add(),c.undoManager.transact(function(){i.deleteData(0,d[0].length),e.innerHTML||e.appendChild(document.createElement("br")),c.selection.setCursorLocation(e),c.execCommand(a.cmd)}),b(function(){h="space"}),!1}))}function f(){var b,e,f=c.selection.getRng(),g=f.startContainer,h=d(g),k=m.length;if(h){for(b=h.data;k--;)if(0===b.indexOf(m[k].start)){e=m[k];break}e&&(h!==g||a.trim(b)!==e.start)&&(i=h,j=e)}}function g(){i&&(c.undoManager.add(),c.undoManager.transact(function(){c.formatter.apply(j.format,{},i),i.replaceData(0,i.data.length,a.trim(i.data.slice(j.start.length)))}),b(function(){h="enter"})),i=null,j=null}var h,i,j,k=a.util.VK,l=[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],m=[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"}];c.on("selectionchange",function(){h=null}),c.on("keydown",function(a){(h&&27===a.keyCode||"space"===h&&a.keyCode===k.BACKSPACE)&&(c.undoManager.undo(),a.preventDefault(),a.stopImmediatePropagation()),a.keyCode!==k.ENTER||k.modifierPressed(a)||f()},!0),c.on("keyup",function(a){a.keyCode!==k.SPACEBAR||a.ctrlKey||a.metaKey||a.altKey?a.keyCode!==k.ENTER||k.modifierPressed(a)||g():e()})})}(window.tinymce,window.setTimeout);
|
||||
740
wp-includes/js/tinymce/plugins/wpview/plugin.js
Normal file
740
wp-includes/js/tinymce/plugins/wpview/plugin.js
Normal file
@@ -0,0 +1,740 @@
|
||||
/* global tinymce */
|
||||
|
||||
/**
|
||||
* WordPress View plugin.
|
||||
*/
|
||||
tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
var $ = editor.$,
|
||||
selected,
|
||||
Env = tinymce.Env,
|
||||
VK = tinymce.util.VK,
|
||||
TreeWalker = tinymce.dom.TreeWalker,
|
||||
toRemove = false,
|
||||
firstFocus = true,
|
||||
_noop = function() { return false; },
|
||||
isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
|
||||
cursorInterval,
|
||||
lastKeyDownNode,
|
||||
setViewCursorTries,
|
||||
focus,
|
||||
execCommandView,
|
||||
execCommandBefore,
|
||||
toolbar;
|
||||
|
||||
function getView( node ) {
|
||||
return getParent( node, 'wpview-wrap' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node or a parent of the node that has the passed className.
|
||||
* Doing this directly is about 40% faster
|
||||
*/
|
||||
function getParent( node, className ) {
|
||||
while ( node && node.parentNode ) {
|
||||
if ( node.className && ( ' ' + node.className + ' ' ).indexOf( ' ' + className + ' ' ) !== -1 ) {
|
||||
return node;
|
||||
}
|
||||
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _stop( event ) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
function setViewCursor( before, view ) {
|
||||
var location = before ? 'before' : 'after',
|
||||
offset = before ? 0 : 1;
|
||||
deselect();
|
||||
editor.selection.setCursorLocation( editor.dom.select( '.wpview-selection-' + location, view )[0], offset );
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
function handleEnter( view, before, key ) {
|
||||
var dom = editor.dom,
|
||||
padNode = dom.create( 'p' );
|
||||
|
||||
if ( ! ( Env.ie && Env.ie < 11 ) ) {
|
||||
padNode.innerHTML = '<br data-mce-bogus="1">';
|
||||
}
|
||||
|
||||
if ( before ) {
|
||||
view.parentNode.insertBefore( padNode, view );
|
||||
} else {
|
||||
dom.insertAfter( padNode, view );
|
||||
}
|
||||
|
||||
deselect();
|
||||
|
||||
if ( before && key === VK.ENTER ) {
|
||||
setViewCursor( before, view );
|
||||
} else {
|
||||
editor.selection.setCursorLocation( padNode, 0 );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
function removeView( view ) {
|
||||
editor.undoManager.transact( function() {
|
||||
handleEnter( view );
|
||||
wp.mce.views.remove( editor, view );
|
||||
});
|
||||
}
|
||||
|
||||
function select( viewNode ) {
|
||||
var clipboard,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( ! viewNode ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( viewNode !== selected ) {
|
||||
// Make sure that the editor is focused.
|
||||
// It is possible that the editor is not focused when the mouse event fires
|
||||
// without focus, the selection will not work properly.
|
||||
editor.getBody().focus();
|
||||
|
||||
deselect();
|
||||
selected = viewNode;
|
||||
dom.setAttrib( viewNode, 'data-mce-selected', 1 );
|
||||
|
||||
clipboard = dom.create( 'div', {
|
||||
'class': 'wpview-clipboard',
|
||||
'contenteditable': 'true'
|
||||
}, wp.mce.views.getText( viewNode ) );
|
||||
|
||||
editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard );
|
||||
|
||||
// Both of the following are necessary to prevent manipulating the selection/focus
|
||||
dom.bind( clipboard, 'beforedeactivate focusin focusout', _stop );
|
||||
dom.bind( selected, 'beforedeactivate focusin focusout', _stop );
|
||||
|
||||
// select the hidden div
|
||||
if ( isios ) {
|
||||
editor.selection.select( clipboard );
|
||||
} else {
|
||||
editor.selection.select( clipboard, true );
|
||||
}
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
editor.fire( 'wpview-selected', viewNode );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deselect a selected view and remove clipboard
|
||||
*/
|
||||
function deselect() {
|
||||
var clipboard,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( selected ) {
|
||||
clipboard = editor.dom.select( '.wpview-clipboard', selected )[0];
|
||||
dom.unbind( clipboard );
|
||||
dom.remove( clipboard );
|
||||
|
||||
dom.unbind( selected, 'beforedeactivate focusin focusout click mouseup', _stop );
|
||||
dom.setAttrib( selected, 'data-mce-selected', null );
|
||||
}
|
||||
|
||||
selected = null;
|
||||
}
|
||||
|
||||
// Check if the `wp.mce` API exists.
|
||||
if ( typeof wp === 'undefined' || ! wp.mce ) {
|
||||
return {
|
||||
getView: _noop
|
||||
};
|
||||
}
|
||||
|
||||
function resetViewsCallback( match, viewText ) {
|
||||
return '<p>' + window.decodeURIComponent( viewText ) + '</p>';
|
||||
}
|
||||
|
||||
// Replace the view tags with the view string
|
||||
function resetViews( content ) {
|
||||
return content.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*|\.)<\/div>/g, resetViewsCallback )
|
||||
.replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback );
|
||||
}
|
||||
|
||||
// Prevent adding undo levels on changes inside a view wrapper
|
||||
editor.on( 'BeforeAddUndo', function( event ) {
|
||||
if ( event.level.content ) {
|
||||
event.level.content = resetViews( event.level.content );
|
||||
}
|
||||
});
|
||||
|
||||
// When the editor's content changes, scan the new content for
|
||||
// matching view patterns, and transform the matches into
|
||||
// view wrappers.
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
var node;
|
||||
|
||||
if ( ! event.selection ) {
|
||||
wp.mce.views.unbind();
|
||||
}
|
||||
|
||||
if ( ! event.content ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! event.load ) {
|
||||
if ( selected ) {
|
||||
removeView( selected );
|
||||
}
|
||||
|
||||
node = editor.selection.getNode();
|
||||
|
||||
if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
|
||||
// When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
|
||||
node = editor.dom.getParent( node, 'p' );
|
||||
|
||||
if ( node && /^[\s\uFEFF\u00A0]*$/.test( $( node ).text() || '' ) ) {
|
||||
// Make sure there are no empty inline elements in the <p>
|
||||
node.innerHTML = '';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.content = wp.mce.views.setMarkers( event.content );
|
||||
});
|
||||
|
||||
// When pasting strip all tags and check if the string is an URL.
|
||||
// Then replace the pasted content with the cleaned URL.
|
||||
editor.on( 'pastePreProcess', function( event ) {
|
||||
var pastedStr = event.content;
|
||||
|
||||
if ( pastedStr ) {
|
||||
pastedStr = tinymce.trim( pastedStr.replace( /<[^>]+>/g, '' ) );
|
||||
|
||||
if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {
|
||||
event.content = pastedStr;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// When the editor's content has been updated and the DOM has been
|
||||
// processed, render the views in the document.
|
||||
editor.on( 'SetContent', function() {
|
||||
wp.mce.views.render();
|
||||
});
|
||||
|
||||
// Set the cursor before or after a view when clicking next to it.
|
||||
editor.on( 'click', function( event ) {
|
||||
var x = event.clientX,
|
||||
y = event.clientY,
|
||||
body = editor.getBody(),
|
||||
bodyRect = body.getBoundingClientRect(),
|
||||
first = body.firstChild,
|
||||
last = body.lastChild,
|
||||
firstRect, lastRect, view;
|
||||
|
||||
if ( ! first || ! last ) {
|
||||
return;
|
||||
}
|
||||
|
||||
firstRect = first.getBoundingClientRect();
|
||||
lastRect = last.getBoundingClientRect();
|
||||
|
||||
if ( y < firstRect.top && ( view = getView( first ) ) ) {
|
||||
setViewCursor( true, view );
|
||||
event.preventDefault();
|
||||
} else if ( y > lastRect.bottom && ( view = getView( last ) ) ) {
|
||||
setViewCursor( false, view );
|
||||
event.preventDefault();
|
||||
} else if ( x < bodyRect.left || x > bodyRect.right ) {
|
||||
tinymce.each( editor.dom.select( '.wpview-wrap' ), function( view ) {
|
||||
var rect = view.getBoundingClientRect();
|
||||
|
||||
if ( y < rect.top ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( y >= rect.top && y <= rect.bottom ) {
|
||||
if ( x < bodyRect.left ) {
|
||||
setViewCursor( true, view );
|
||||
event.preventDefault();
|
||||
} else if ( x > bodyRect.right ) {
|
||||
setViewCursor( false, view );
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var scrolled = false,
|
||||
selection = editor.selection,
|
||||
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||
|
||||
// When a view is selected, ensure content that is being pasted
|
||||
// or inserted is added to a text node (instead of the view).
|
||||
editor.on( 'BeforeSetContent', function() {
|
||||
var walker, target,
|
||||
view = getView( selection.getNode() );
|
||||
|
||||
// If the selection is not within a view, bail.
|
||||
if ( ! view ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! view.nextSibling || getView( view.nextSibling ) ) {
|
||||
// If there are no additional nodes or the next node is a
|
||||
// view, create a text node after the current view.
|
||||
target = editor.getDoc().createTextNode('');
|
||||
editor.dom.insertAfter( target, view );
|
||||
} else {
|
||||
// Otherwise, find the next text node.
|
||||
walker = new TreeWalker( view.nextSibling, view.nextSibling );
|
||||
target = walker.next();
|
||||
}
|
||||
|
||||
// Select the `target` text node.
|
||||
selection.select( target );
|
||||
selection.collapse( true );
|
||||
});
|
||||
|
||||
editor.dom.bind( editor.getDoc(), 'touchmove', function() {
|
||||
scrolled = true;
|
||||
});
|
||||
|
||||
editor.on( 'mousedown mouseup click touchend', function( event ) {
|
||||
var view = getView( event.target );
|
||||
|
||||
firstFocus = false;
|
||||
|
||||
// Contain clicks inside the view wrapper
|
||||
if ( view ) {
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
|
||||
if ( event.type === 'touchend' && scrolled ) {
|
||||
scrolled = false;
|
||||
} else {
|
||||
select( view );
|
||||
}
|
||||
|
||||
// Returning false stops the ugly bars from appearing in IE11 and stops the view being selected as a range in FF.
|
||||
// Unfortunately, it also inhibits the dragging of views to a new location.
|
||||
return false;
|
||||
} else {
|
||||
if ( event.type === 'touchend' || event.type === 'mousedown' ) {
|
||||
deselect();
|
||||
}
|
||||
}
|
||||
|
||||
if ( event.type === 'touchend' && scrolled ) {
|
||||
scrolled = false;
|
||||
}
|
||||
}, true );
|
||||
|
||||
if ( MutationObserver ) {
|
||||
new MutationObserver( function() {
|
||||
editor.fire( 'wp-body-class-change' );
|
||||
} )
|
||||
.observe( editor.getBody(), {
|
||||
attributes: true,
|
||||
attributeFilter: ['class']
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
||||
// Empty the wpview wrap and marker nodes
|
||||
function emptyViewNodes( rootNode ) {
|
||||
$( 'div[data-wpview-text], p[data-wpview-marker]', rootNode ).each( function( i, node ) {
|
||||
node.innerHTML = '.';
|
||||
});
|
||||
}
|
||||
|
||||
// Run that before the DOM cleanup
|
||||
editor.on( 'PreProcess', function( event ) {
|
||||
emptyViewNodes( event.node );
|
||||
}, true );
|
||||
|
||||
editor.on( 'hide', function() {
|
||||
wp.mce.views.unbind();
|
||||
deselect();
|
||||
emptyViewNodes();
|
||||
});
|
||||
|
||||
editor.on( 'PostProcess', function( event ) {
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g, resetViewsCallback )
|
||||
.replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback );
|
||||
}
|
||||
});
|
||||
|
||||
// Excludes arrow keys, delete, backspace, enter, space bar.
|
||||
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
|
||||
function isSpecialKey( key ) {
|
||||
return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
|
||||
key >= 224 || // OEM or non-printable
|
||||
( key >= 144 && key <= 150 ) || // Num Lock, Scroll Lock, OEM
|
||||
( key >= 91 && key <= 93 ) || // Windows keys
|
||||
( key >= 112 && key <= 135 ) ); // F keys
|
||||
}
|
||||
|
||||
// (De)select views when arrow keys are used to navigate the content of the editor.
|
||||
editor.on( 'keydown', function( event ) {
|
||||
var key = event.keyCode,
|
||||
dom = editor.dom,
|
||||
selection = editor.selection,
|
||||
node, view, cursorBefore, cursorAfter,
|
||||
range, clonedRange, tempRange;
|
||||
|
||||
if ( selected ) {
|
||||
// Ignore key presses that involve the command or control key, but continue when in combination with backspace or v.
|
||||
// Also ignore the F# keys.
|
||||
if ( ( ( event.metaKey || event.ctrlKey ) && key !== VK.BACKSPACE && key !== 86 ) || ( key >= 112 && key <= 123 ) ) {
|
||||
// Remove the view when pressing cmd/ctrl+x on keyup, otherwise the browser can't copy the content.
|
||||
if ( ( event.metaKey || event.ctrlKey ) && key === 88 ) {
|
||||
toRemove = selected;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
view = getView( selection.getNode() );
|
||||
|
||||
// If the caret is not within the selected view, deselect the view and bail.
|
||||
if ( view !== selected ) {
|
||||
deselect();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( key === VK.LEFT ) {
|
||||
setViewCursor( true, view );
|
||||
event.preventDefault();
|
||||
} else if ( key === VK.UP ) {
|
||||
if ( view.previousSibling ) {
|
||||
if ( getView( view.previousSibling ) ) {
|
||||
setViewCursor( true, view.previousSibling );
|
||||
} else {
|
||||
deselect();
|
||||
selection.select( view.previousSibling, true );
|
||||
selection.collapse();
|
||||
}
|
||||
} else {
|
||||
setViewCursor( true, view );
|
||||
}
|
||||
event.preventDefault();
|
||||
} else if ( key === VK.RIGHT ) {
|
||||
setViewCursor( false, view );
|
||||
event.preventDefault();
|
||||
} else if ( key === VK.DOWN ) {
|
||||
if ( view.nextSibling ) {
|
||||
if ( getView( view.nextSibling ) ) {
|
||||
setViewCursor( false, view.nextSibling );
|
||||
} else {
|
||||
deselect();
|
||||
selection.setCursorLocation( view.nextSibling, 0 );
|
||||
}
|
||||
} else {
|
||||
setViewCursor( false, view );
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
// Ignore keys that don't insert anything.
|
||||
} else if ( ! isSpecialKey( key ) ) {
|
||||
removeView( selected );
|
||||
|
||||
if ( key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( event.metaKey || event.ctrlKey || ( key >= 112 && key <= 123 ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = selection.getNode();
|
||||
lastKeyDownNode = node;
|
||||
view = getView( node );
|
||||
|
||||
// Make sure we don't delete part of a view.
|
||||
// If the range ends or starts with the view, we'll need to trim it.
|
||||
if ( ! selection.isCollapsed() ) {
|
||||
range = selection.getRng();
|
||||
|
||||
if ( view = getView( range.endContainer ) ) {
|
||||
clonedRange = range.cloneRange();
|
||||
selection.select( view.previousSibling, true );
|
||||
selection.collapse();
|
||||
tempRange = selection.getRng();
|
||||
clonedRange.setEnd( tempRange.endContainer, tempRange.endOffset );
|
||||
selection.setRng( clonedRange );
|
||||
} else if ( view = getView( range.startContainer ) ) {
|
||||
clonedRange = range.cloneRange();
|
||||
clonedRange.setStart( view.nextSibling, 0 );
|
||||
selection.setRng( clonedRange );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! view ) {
|
||||
// Make sure we don't eat any content.
|
||||
if ( event.keyCode === VK.BACKSPACE ) {
|
||||
if ( editor.dom.isEmpty( node ) ) {
|
||||
if ( view = getView( node.previousSibling ) ) {
|
||||
setViewCursor( false, view );
|
||||
editor.dom.remove( node );
|
||||
event.preventDefault();
|
||||
}
|
||||
} else if ( ( range = selection.getRng() ) &&
|
||||
range.startOffset === 0 &&
|
||||
range.endOffset === 0 &&
|
||||
( view = getView( node.previousSibling ) ) ) {
|
||||
setViewCursor( false, view );
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! ( ( cursorBefore = dom.hasClass( view, 'wpview-selection-before' ) ) ||
|
||||
( cursorAfter = dom.hasClass( view, 'wpview-selection-after' ) ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isSpecialKey( key ) ) {
|
||||
// ignore
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( cursorAfter && key === VK.UP ) || ( cursorBefore && key === VK.BACKSPACE ) ) {
|
||||
if ( view.previousSibling ) {
|
||||
if ( getView( view.previousSibling ) ) {
|
||||
setViewCursor( false, view.previousSibling );
|
||||
} else {
|
||||
if ( dom.isEmpty( view.previousSibling ) && key === VK.BACKSPACE ) {
|
||||
dom.remove( view.previousSibling );
|
||||
} else {
|
||||
selection.select( view.previousSibling, true );
|
||||
selection.collapse();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setViewCursor( true, view );
|
||||
}
|
||||
event.preventDefault();
|
||||
} else if ( cursorAfter && ( key === VK.DOWN || key === VK.RIGHT ) ) {
|
||||
if ( view.nextSibling ) {
|
||||
if ( getView( view.nextSibling ) ) {
|
||||
setViewCursor( key === VK.RIGHT, view.nextSibling );
|
||||
} else {
|
||||
selection.setCursorLocation( view.nextSibling, 0 );
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
} else if ( cursorBefore && ( key === VK.UP || key === VK.LEFT ) ) {
|
||||
if ( view.previousSibling ) {
|
||||
if ( getView( view.previousSibling ) ) {
|
||||
setViewCursor( key === VK.UP, view.previousSibling );
|
||||
} else {
|
||||
selection.select( view.previousSibling, true );
|
||||
selection.collapse();
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
} else if ( cursorBefore && key === VK.DOWN ) {
|
||||
if ( view.nextSibling ) {
|
||||
if ( getView( view.nextSibling ) ) {
|
||||
setViewCursor( true, view.nextSibling );
|
||||
} else {
|
||||
selection.setCursorLocation( view.nextSibling, 0 );
|
||||
}
|
||||
} else {
|
||||
setViewCursor( false, view );
|
||||
}
|
||||
event.preventDefault();
|
||||
} else if ( ( cursorAfter && key === VK.LEFT ) || ( cursorBefore && key === VK.RIGHT ) ) {
|
||||
select( view );
|
||||
event.preventDefault();
|
||||
} else if ( cursorAfter && key === VK.BACKSPACE ) {
|
||||
removeView( view );
|
||||
event.preventDefault();
|
||||
} else if ( cursorAfter ) {
|
||||
handleEnter( view );
|
||||
} else if ( cursorBefore ) {
|
||||
handleEnter( view , true, key );
|
||||
}
|
||||
|
||||
if ( key === VK.ENTER ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'keyup', function() {
|
||||
if ( toRemove ) {
|
||||
removeView( toRemove );
|
||||
toRemove = false;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'focus', function() {
|
||||
var view;
|
||||
|
||||
focus = true;
|
||||
editor.dom.addClass( editor.getBody(), 'has-focus' );
|
||||
|
||||
// Edge case: show the fake caret when the editor is focused for the first time
|
||||
// and the first element is a view.
|
||||
if ( firstFocus && ( view = getView( editor.getBody().firstChild ) ) ) {
|
||||
setViewCursor( true, view );
|
||||
}
|
||||
|
||||
firstFocus = false;
|
||||
} );
|
||||
|
||||
editor.on( 'blur', function() {
|
||||
focus = false;
|
||||
editor.dom.removeClass( editor.getBody(), 'has-focus' );
|
||||
} );
|
||||
|
||||
editor.on( 'NodeChange', function( event ) {
|
||||
var dom = editor.dom,
|
||||
views = editor.dom.select( '.wpview-wrap' ),
|
||||
className = event.element.className,
|
||||
view = getView( event.element ),
|
||||
lKDN = lastKeyDownNode;
|
||||
|
||||
lastKeyDownNode = false;
|
||||
|
||||
clearInterval( cursorInterval );
|
||||
|
||||
// This runs a lot and is faster than replacing each class separately
|
||||
tinymce.each( views, function ( view ) {
|
||||
if ( view.className ) {
|
||||
view.className = view.className.replace( / ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g, '' );
|
||||
}
|
||||
});
|
||||
|
||||
if ( focus && view ) {
|
||||
if ( ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) &&
|
||||
editor.selection.isCollapsed() ) {
|
||||
|
||||
setViewCursorTries = 0;
|
||||
|
||||
deselect();
|
||||
|
||||
// Make sure the cursor arrived in the right node.
|
||||
// This is necessary for Firefox.
|
||||
if ( lKDN === view.previousSibling ) {
|
||||
setViewCursor( true, view );
|
||||
return;
|
||||
} else if ( lKDN === view.nextSibling ) {
|
||||
setViewCursor( false, view );
|
||||
return;
|
||||
}
|
||||
|
||||
dom.addClass( view, className );
|
||||
|
||||
cursorInterval = setInterval( function() {
|
||||
if ( dom.hasClass( view, 'wpview-cursor-hide' ) ) {
|
||||
dom.removeClass( view, 'wpview-cursor-hide' );
|
||||
} else {
|
||||
dom.addClass( view, 'wpview-cursor-hide' );
|
||||
}
|
||||
}, 500 );
|
||||
// If the cursor lands anywhere else in the view, set the cursor before it.
|
||||
// Only try this once to prevent a loop. (You never know.)
|
||||
} else if ( ! getParent( event.element, 'wpview-clipboard' ) && ! setViewCursorTries ) {
|
||||
deselect();
|
||||
setViewCursorTries++;
|
||||
setViewCursor( true, view );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeExecCommand', function() {
|
||||
var node = editor.selection.getNode(),
|
||||
view;
|
||||
|
||||
if ( node && ( ( execCommandBefore = node.className === 'wpview-selection-before' ) || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
|
||||
handleEnter( view, execCommandBefore );
|
||||
execCommandView = view;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ExecCommand', function() {
|
||||
var toSelect, node;
|
||||
|
||||
if ( selected ) {
|
||||
toSelect = selected;
|
||||
deselect();
|
||||
select( toSelect );
|
||||
}
|
||||
|
||||
if ( execCommandView ) {
|
||||
node = execCommandView[ execCommandBefore ? 'previousSibling' : 'nextSibling' ];
|
||||
|
||||
if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
|
||||
editor.dom.remove( node );
|
||||
setViewCursor( execCommandBefore, execCommandView );
|
||||
}
|
||||
|
||||
execCommandView = false;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
if ( editor.dom.hasClass( event.target, 'wpview-wrap' ) ) {
|
||||
event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'wpview';
|
||||
event.stopPropagation();
|
||||
} else if ( getView( event.target ) ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
editor.addButton( 'wp_view_edit', {
|
||||
tooltip: 'Edit ', // trailing space is needed, used for context
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
selected && wp.mce.views.edit( editor, selected );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_view_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
onclick: function() {
|
||||
selected && removeView( selected );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.once( 'preinit', function() {
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_view_edit',
|
||||
'wp_view_remove'
|
||||
] );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
if ( selected ) {
|
||||
event.element = selected;
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
} );
|
||||
|
||||
// Add to editor.wp
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.getView = getView;
|
||||
editor.wp.setViewCursor = setViewCursor;
|
||||
|
||||
// Keep for back-compat.
|
||||
return {
|
||||
getView: getView
|
||||
};
|
||||
});
|
||||
1
wp-includes/js/tinymce/plugins/wpview/plugin.min.js
vendored
Normal file
1
wp-includes/js/tinymce/plugins/wpview/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user