diff options
Diffstat (limited to 'wp-includes/js/tinymce/plugins')
45 files changed, 14290 insertions, 0 deletions
diff --git a/wp-includes/js/tinymce/plugins/charmap/plugin.js b/wp-includes/js/tinymce/plugins/charmap/plugin.js new file mode 100644 index 0000000..48b26f1 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/charmap/plugin.js @@ -0,0 +1,1275 @@ +(function () { +var charmap = (function () { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var fireInsertCustomChar = function (editor, chr) { + return editor.fire('insertCustomChar', { chr: chr }); + }; + var Events = { fireInsertCustomChar: fireInsertCustomChar }; + + var insertChar = function (editor, chr) { + var evtChr = Events.fireInsertCustomChar(editor, chr).chr; + editor.execCommand('mceInsertContent', false, evtChr); + }; + var Actions = { insertChar: insertChar }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var getCharMap = function (editor) { + return editor.settings.charmap; + }; + var getCharMapAppend = function (editor) { + return editor.settings.charmap_append; + }; + var Settings = { + getCharMap: getCharMap, + getCharMapAppend: getCharMapAppend + }; + + var isArray = global$1.isArray; + var getDefaultCharMap = function () { + return [ + [ + '160', + 'no-break space' + ], + [ + '173', + 'soft hyphen' + ], + [ + '34', + 'quotation mark' + ], + [ + '162', + 'cent sign' + ], + [ + '8364', + 'euro sign' + ], + [ + '163', + 'pound sign' + ], + [ + '165', + 'yen sign' + ], + [ + '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' + ], + [ + '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' + ], + [ + '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' + ], + [ + '180', + 'acute accent' + ], + [ + '184', + 'cedilla' + ], + [ + '170', + 'feminine ordinal indicator' + ], + [ + '186', + 'masculine ordinal indicator' + ], + [ + '8224', + 'dagger' + ], + [ + '8225', + 'double dagger' + ], + [ + '192', + 'A - grave' + ], + [ + '193', + 'A - acute' + ], + [ + '194', + 'A - circumflex' + ], + [ + '195', + 'A - tilde' + ], + [ + '196', + 'A - diaeresis' + ], + [ + '197', + 'A - ring above' + ], + [ + '256', + 'A - macron' + ], + [ + '198', + 'ligature AE' + ], + [ + '199', + 'C - cedilla' + ], + [ + '200', + 'E - grave' + ], + [ + '201', + 'E - acute' + ], + [ + '202', + 'E - circumflex' + ], + [ + '203', + 'E - diaeresis' + ], + [ + '274', + 'E - macron' + ], + [ + '204', + 'I - grave' + ], + [ + '205', + 'I - acute' + ], + [ + '206', + 'I - circumflex' + ], + [ + '207', + 'I - diaeresis' + ], + [ + '298', + 'I - macron' + ], + [ + '208', + 'ETH' + ], + [ + '209', + 'N - tilde' + ], + [ + '210', + 'O - grave' + ], + [ + '211', + 'O - acute' + ], + [ + '212', + 'O - circumflex' + ], + [ + '213', + 'O - tilde' + ], + [ + '214', + 'O - diaeresis' + ], + [ + '216', + 'O - slash' + ], + [ + '332', + 'O - macron' + ], + [ + '338', + 'ligature OE' + ], + [ + '352', + 'S - caron' + ], + [ + '217', + 'U - grave' + ], + [ + '218', + 'U - acute' + ], + [ + '219', + 'U - circumflex' + ], + [ + '220', + 'U - diaeresis' + ], + [ + '362', + 'U - macron' + ], + [ + '221', + 'Y - acute' + ], + [ + '376', + 'Y - diaeresis' + ], + [ + '562', + 'Y - macron' + ], + [ + '222', + 'THORN' + ], + [ + '224', + 'a - grave' + ], + [ + '225', + 'a - acute' + ], + [ + '226', + 'a - circumflex' + ], + [ + '227', + 'a - tilde' + ], + [ + '228', + 'a - diaeresis' + ], + [ + '229', + 'a - ring above' + ], + [ + '257', + 'a - macron' + ], + [ + '230', + 'ligature ae' + ], + [ + '231', + 'c - cedilla' + ], + [ + '232', + 'e - grave' + ], + [ + '233', + 'e - acute' + ], + [ + '234', + 'e - circumflex' + ], + [ + '235', + 'e - diaeresis' + ], + [ + '275', + 'e - macron' + ], + [ + '236', + 'i - grave' + ], + [ + '237', + 'i - acute' + ], + [ + '238', + 'i - circumflex' + ], + [ + '239', + 'i - diaeresis' + ], + [ + '299', + 'i - macron' + ], + [ + '240', + 'eth' + ], + [ + '241', + 'n - tilde' + ], + [ + '242', + 'o - grave' + ], + [ + '243', + 'o - acute' + ], + [ + '244', + 'o - circumflex' + ], + [ + '245', + 'o - tilde' + ], + [ + '246', + 'o - diaeresis' + ], + [ + '248', + 'o slash' + ], + [ + '333', + 'o macron' + ], + [ + '339', + 'ligature oe' + ], + [ + '353', + 's - caron' + ], + [ + '249', + 'u - grave' + ], + [ + '250', + 'u - acute' + ], + [ + '251', + 'u - circumflex' + ], + [ + '252', + 'u - diaeresis' + ], + [ + '363', + 'u - macron' + ], + [ + '253', + 'y - acute' + ], + [ + '254', + 'thorn' + ], + [ + '255', + 'y - diaeresis' + ], + [ + '563', + 'y - macron' + ], + [ + '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' + ], + [ + '8501', + 'alef symbol' + ], + [ + '982', + 'pi symbol' + ], + [ + '8476', + 'real part symbol' + ], + [ + '978', + 'upsilon - hook symbol' + ], + [ + '8472', + 'Weierstrass p' + ], + [ + '8465', + 'imaginary part' + ], + [ + '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' + ] + ]; + }; + var charmapFilter = function (charmap) { + return global$1.grep(charmap, function (item) { + return isArray(item) && item.length === 2; + }); + }; + var getCharsFromSetting = function (settingValue) { + if (isArray(settingValue)) { + return [].concat(charmapFilter(settingValue)); + } + if (typeof settingValue === 'function') { + return settingValue(); + } + return []; + }; + var extendCharMap = function (editor, charmap) { + var userCharMap = Settings.getCharMap(editor); + if (userCharMap) { + charmap = getCharsFromSetting(userCharMap); + } + var userCharMapAppend = Settings.getCharMapAppend(editor); + if (userCharMapAppend) { + return [].concat(charmap).concat(getCharsFromSetting(userCharMapAppend)); + } + return charmap; + }; + var getCharMap$1 = function (editor) { + return extendCharMap(editor, getDefaultCharMap()); + }; + var CharMap = { getCharMap: getCharMap$1 }; + + var get = function (editor) { + var getCharMap = function () { + return CharMap.getCharMap(editor); + }; + var insertChar = function (chr) { + Actions.insertChar(editor, chr); + }; + return { + getCharMap: getCharMap, + insertChar: insertChar + }; + }; + var Api = { get: get }; + + var getHtml = function (charmap) { + var gridHtml, x, y; + var width = Math.min(charmap.length, 25); + var height = Math.ceil(charmap.length / width); + gridHtml = '<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>'; + 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]; + var charCode = parseInt(chr[0], 10); + var chrText = chr ? String.fromCharCode(charCode) : ' '; + gridHtml += '<td title="' + chr[1] + '">' + '<div tabindex="-1" title="' + chr[1] + '" role="button" data-chr="' + charCode + '">' + chrText + '</div>' + '</td>'; + } else { + gridHtml += '<td />'; + } + } + gridHtml += '</tr>'; + } + gridHtml += '</tbody></table>'; + return gridHtml; + }; + var GridHtml = { getHtml: getHtml }; + + var getParentTd = function (elm) { + while (elm) { + if (elm.nodeName === 'TD') { + return elm; + } + elm = elm.parentNode; + } + }; + var open = function (editor) { + var win; + var charMapPanel = { + type: 'container', + html: GridHtml.getHtml(CharMap.getCharMap(editor)), + onclick: function (e) { + var target = e.target; + if (/^(TD|DIV)$/.test(target.nodeName)) { + var charDiv = getParentTd(target).firstChild; + if (charDiv && charDiv.hasAttribute('data-chr')) { + var charCodeString = charDiv.getAttribute('data-chr'); + var charCode = parseInt(charCodeString, 10); + if (!isNaN(charCode)) { + Actions.insertChar(editor, String.fromCharCode(charCode)); + } + 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: 'spacer', + minHeight: 20 + }, + { + type: 'label', + name: 'previewTitle', + text: ' ', + style: 'white-space: pre-wrap;', + border: 1, + minWidth: 140 + } + ] + } + ], + buttons: [{ + text: 'Close', + onclick: function () { + win.close(); + } + }] + }); + }; + var Dialog = { open: open }; + + var register = function (editor) { + editor.addCommand('mceShowCharmap', function () { + Dialog.open(editor); + }); + }; + var Commands = { register: register }; + + var register$1 = function (editor) { + editor.addButton('charmap', { + icon: 'charmap', + tooltip: 'Special character', + cmd: 'mceShowCharmap' + }); + editor.addMenuItem('charmap', { + icon: 'charmap', + text: 'Special character', + cmd: 'mceShowCharmap', + context: 'insert' + }); + }; + var Buttons = { register: register$1 }; + + global.add('charmap', function (editor) { + Commands.register(editor); + Buttons.register(editor); + return Api.get(editor); + }); + function Plugin () { + } + + return Plugin; + +}()); +})(); diff --git a/wp-includes/js/tinymce/plugins/charmap/plugin.min.js b/wp-includes/js/tinymce/plugins/charmap/plugin.min.js new file mode 100644 index 0000000..9ea3f75 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/charmap/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(e,t){return e.fire("insertCustomChar",{chr:t})},l=function(e,t){var a=i(e,t).chr;e.execCommand("mceInsertContent",!1,a)},a=tinymce.util.Tools.resolve("tinymce.util.Tools"),r=function(e){return e.settings.charmap},n=function(e){return e.settings.charmap_append},o=a.isArray,c=function(e){return o(e)?[].concat((t=e,a.grep(t,function(e){return o(e)&&2===e.length}))):"function"==typeof e?e():[];var t},s=function(e){return function(e,t){var a=r(e);a&&(t=c(a));var i=n(e);return i?[].concat(t).concat(c(i)):t}(e,[["160","no-break space"],["173","soft hyphen"],["34","quotation mark"],["162","cent sign"],["8364","euro sign"],["163","pound sign"],["165","yen sign"],["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"],["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"],["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"],["180","acute accent"],["184","cedilla"],["170","feminine ordinal indicator"],["186","masculine ordinal indicator"],["8224","dagger"],["8225","double dagger"],["192","A - grave"],["193","A - acute"],["194","A - circumflex"],["195","A - tilde"],["196","A - diaeresis"],["197","A - ring above"],["256","A - macron"],["198","ligature AE"],["199","C - cedilla"],["200","E - grave"],["201","E - acute"],["202","E - circumflex"],["203","E - diaeresis"],["274","E - macron"],["204","I - grave"],["205","I - acute"],["206","I - circumflex"],["207","I - diaeresis"],["298","I - macron"],["208","ETH"],["209","N - tilde"],["210","O - grave"],["211","O - acute"],["212","O - circumflex"],["213","O - tilde"],["214","O - diaeresis"],["216","O - slash"],["332","O - macron"],["338","ligature OE"],["352","S - caron"],["217","U - grave"],["218","U - acute"],["219","U - circumflex"],["220","U - diaeresis"],["362","U - macron"],["221","Y - acute"],["376","Y - diaeresis"],["562","Y - macron"],["222","THORN"],["224","a - grave"],["225","a - acute"],["226","a - circumflex"],["227","a - tilde"],["228","a - diaeresis"],["229","a - ring above"],["257","a - macron"],["230","ligature ae"],["231","c - cedilla"],["232","e - grave"],["233","e - acute"],["234","e - circumflex"],["235","e - diaeresis"],["275","e - macron"],["236","i - grave"],["237","i - acute"],["238","i - circumflex"],["239","i - diaeresis"],["299","i - macron"],["240","eth"],["241","n - tilde"],["242","o - grave"],["243","o - acute"],["244","o - circumflex"],["245","o - tilde"],["246","o - diaeresis"],["248","o slash"],["333","o macron"],["339","ligature oe"],["353","s - caron"],["249","u - grave"],["250","u - acute"],["251","u - circumflex"],["252","u - diaeresis"],["363","u - macron"],["253","y - acute"],["254","thorn"],["255","y - diaeresis"],["563","y - macron"],["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"],["8501","alef symbol"],["982","pi symbol"],["8476","real part symbol"],["978","upsilon - hook symbol"],["8472","Weierstrass p"],["8465","imaginary part"],["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"]])},t=function(t){return{getCharMap:function(){return s(t)},insertChar:function(e){l(t,e)}}},u=function(e){var t,a,i,r=Math.min(e.length,25),n=Math.ceil(e.length/r);for(t='<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>',i=0;i<n;i++){for(t+="<tr>",a=0;a<r;a++){var o=i*r+a;if(o<e.length){var l=e[o],c=parseInt(l[0],10),s=l?String.fromCharCode(c):" ";t+='<td title="'+l[1]+'"><div tabindex="-1" title="'+l[1]+'" role="button" data-chr="'+c+'">'+s+"</div></td>"}else t+="<td />"}t+="</tr>"}return t+="</tbody></table>"},d=function(e){for(;e;){if("TD"===e.nodeName)return e;e=e.parentNode}},m=function(n){var o,e={type:"container",html:u(s(n)),onclick:function(e){var t=e.target;if(/^(TD|DIV)$/.test(t.nodeName)){var a=d(t).firstChild;if(a&&a.hasAttribute("data-chr")){var i=a.getAttribute("data-chr"),r=parseInt(i,10);isNaN(r)||l(n,String.fromCharCode(r)),e.ctrlKey||o.close()}}},onmouseover:function(e){var t=d(e.target);t&&t.firstChild?(o.find("#preview").text(t.firstChild.firstChild.data),o.find("#previewTitle").text(t.title)):(o.find("#preview").text(" "),o.find("#previewTitle").text(" "))}};o=n.windowManager.open({title:"Special character",spacing:10,padding:10,items:[e,{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:"spacer",minHeight:20},{type:"label",name:"previewTitle",text:" ",style:"white-space: pre-wrap;",border:1,minWidth:140}]}],buttons:[{text:"Close",onclick:function(){o.close()}}]})},g=function(e){e.addCommand("mceShowCharmap",function(){m(e)})},p=function(e){e.addButton("charmap",{icon:"charmap",tooltip:"Special character",cmd:"mceShowCharmap"}),e.addMenuItem("charmap",{icon:"charmap",text:"Special character",cmd:"mceShowCharmap",context:"insert"})};e.add("charmap",function(e){return g(e),p(e),t(e)})}();
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/colorpicker/plugin.js b/wp-includes/js/tinymce/plugins/colorpicker/plugin.js new file mode 100644 index 0000000..04872b3 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/colorpicker/plugin.js @@ -0,0 +1,126 @@ +(function () { +var colorpicker = (function () { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Color'); + + var showPreview = function (win, hexColor) { + win.find('#preview')[0].getEl().style.background = hexColor; + }; + var setColor = function (win, value) { + var color = global$1(value), rgb = color.toRgb(); + win.fromJSON({ + r: rgb.r, + g: rgb.g, + b: rgb.b, + hex: color.toHex().substr(1) + }); + showPreview(win, color.toHex()); + }; + var open = function (editor, callback, value) { + 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(win, 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(win, 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(win, 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('#' + win.toJSON().hex); + } + }); + setColor(win, value); + }; + var Dialog = { open: open }; + + global.add('colorpicker', function (editor) { + if (!editor.settings.color_picker_callback) { + editor.settings.color_picker_callback = function (callback, value) { + Dialog.open(editor, callback, value); + }; + } + }); + function Plugin () { + } + + return Plugin; + +}()); +})(); diff --git a/wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js b/wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js new file mode 100644 index 0000000..10317a5 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=tinymce.util.Tools.resolve("tinymce.util.Color"),a=function(e,n){e.find("#preview")[0].getEl().style.background=n},o=function(e,n){var i=l(n),t=i.toRgb();e.fromJSON({r:t.r,g:t.g,b:t.b,hex:i.toHex().substr(1)}),a(e,i.toHex())},t=function(e,n,i){var t=e.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:i,onchange:function(){var e=this.rgb();t&&(t.find("#r").value(e.r),t.find("#g").value(e.g),t.find("#b").value(e.b),t.find("#hex").value(this.value().substr(1)),a(t,this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var e,n,i=t.find("colorpicker")[0];if(e=this.name(),n=this.value(),"hex"===e)return o(t,n="#"+n),void i.value(n);n={r:t.find("#r").value(),g:t.find("#g").value(),b:t.find("#b").value()},i.value(n),o(t,n)}},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(){n("#"+t.toJSON().hex)}});o(t,i)};e.add("colorpicker",function(i){i.settings.color_picker_callback||(i.settings.color_picker_callback=function(e,n){t(i,e,n)})})}();
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/compat3x/css/dialog.css b/wp-includes/js/tinymce/plugins/compat3x/css/dialog.css new file mode 100644 index 0000000..e75543a --- /dev/null +++ b/wp-includes/js/tinymce/plugins/compat3x/css/dialog.css @@ -0,0 +1,215 @@ +/* + * Edited for compatibility with old TinyMCE 3.x plugins in WordPress. + * More info: https://core.trac.wordpress.org/ticket/31596#comment:10 + */ + +/* Generic */ +body { +font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", 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; +} diff --git a/wp-includes/js/tinymce/plugins/compat3x/plugin.js b/wp-includes/js/tinymce/plugins/compat3x/plugin.js new file mode 100644 index 0000000..92d433e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/compat3x/plugin.js @@ -0,0 +1,322 @@ +/** + * plugin.js + * + * Released under LGPL License. + * Copyright (c) 1999-2017 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; + var cbs = []; + + 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); + + var handlers = { + original: callback, + patched: patchedEventCallback + }; + + cbs.push(handlers); + return patchedEventCallback; + }; + + this.addToTop = function (callback, scope) { + this.add(callback, scope, true); + }; + + this.remove = function (callback) { + cbs.forEach(function (item, i) { + if (item.original === callback) { + cbs.splice(i, 1); + return target.off(newEventName, item.patched); + } + }); + + 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 translate(str) { + var prefix = editor.settings.language || "en"; + var prefixedStr = [prefix, str].join('.'); + var translatedStr = tinymce.i18n.translate(prefixedStr); + + return prefixedStr !== translatedStr ? translatedStr : tinymce.i18n.translate(str); + } + + 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; + + function patchedPostRender() { + editor.controlManager.buttons[name] = this; + + if (originalOnPostRender) { + return originalOnPostRender.apply(this, arguments); + } + } + + for (var key in settings) { + if (key.toLowerCase() === "onpostrender") { + originalOnPostRender = settings[key]; + settings.onPostRender = patchedPostRender; + } + } + + if (!originalOnPostRender) { + settings.onPostRender = patchedPostRender; + } + + if (settings.title) { + settings.title = translate(settings.title); + } + + 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', function (e) { + patchEditor(e.editor); + }); + + 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); diff --git a/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js b/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js new file mode 100644 index 0000000..8562cb7 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js @@ -0,0 +1 @@ +!function(u){var t;function l(){}function f(e){!t&&window&&window.console&&(t=!0,console.log("Deprecated TinyMCE API call: "+e))}function i(i,a,d,s){i=i||this;var c=[];a?(this.add=function(o,r,e){function t(e){var t=[];if("string"==typeof d&&(d=d.split(" ")),d&&"function"!=typeof d)for(var n=0;n<d.length;n++)t.push(e[d[n]]);("function"!=typeof d||(t=d(a,e,i)))&&(d||(t=[e]),t.unshift(s||i),!1===o.apply(r||s||i,t)&&e.stopImmediatePropagation())}f("<target>.on"+a+".add(..)"),i.on(a,t,e);var n={original:o,patched:t};return c.push(n),t},this.addToTop=function(e,t){this.add(e,t,!0)},this.remove=function(n){return c.forEach(function(e,t){if(e.original===n)return c.splice(t,1),i.off(a,e.patched)}),i.off(a,n)},this.dispatch=function(){return i.fire(a),!0}):this.add=this.addToTop=this.remove=this.dispatch=l}function n(s){function e(e,t){u.each(e.split(" "),function(e){s["on"+e]=new i(s,e,t)})}function n(e,t,n){return[t.level,n]}function o(n){return function(e,t){if(!t.selection&&!n||t.selection==n)return[t]}}if(!s.controlManager){s.controlManager={buttons:{},setDisabled:function(e,t){f("controlManager.setDisabled(..)"),this.buttons[e]&&this.buttons[e].disabled(t)},setActive:function(e,t){f("controlManager.setActive(..)"),this.buttons[e]&&this.buttons[e].active(t)},onAdd:new i,onPostRender:new i,add:function(e){return e},createButton:r,createColorSplitButton:r,createControl:r,createDropMenu:r,createListBox:r,createMenuButton:r,createSeparator:r,createSplitButton:r,createToolbar:r,createToolbarGroup:r,destroy:l,get:l,setControlType:r},e("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),e("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),e("BeforeExecCommand ExecCommand","command ui value args"),e("PreProcess PostProcess LoadContent SaveContent Change"),e("BeforeSetContent BeforeGetContent SetContent GetContent",o(!1)),e("SetProgressState","state time"),e("VisualAid","element hasVisual"),e("Undo Redo",n),e("NodeChange",function(e,t){return[s.controlManager,t.element,s.selection.isCollapsed(),t]});var c=s.addButton;s.addButton=function(e,t){var n,o,r,i;function a(){if(s.controlManager.buttons[e]=this,n)return n.apply(this,arguments)}for(var d in t)"onpostrender"===d.toLowerCase()&&(n=t[d],t.onPostRender=a);return n||(t.onPostRender=a),t.title&&(t.title=(o=t.title,r=[s.settings.language||"en",o].join("."),i=u.i18n.translate(r),r!==i?i:u.i18n.translate(o))),c.call(this,e,t)},s.on("init",function(){var e=s.undoManager,t=s.selection;e.onUndo=new i(s,"Undo",n,null,e),e.onRedo=new i(s,"Redo",n,null,e),e.onBeforeAdd=new i(s,"BeforeAddUndo",null,e),e.onAdd=new i(s,"AddUndo",null,e),t.onBeforeGetContent=new i(s,"BeforeGetContent",o(!0),t),t.onGetContent=new i(s,"GetContent",o(!0),t),t.onBeforeSetContent=new i(s,"BeforeSetContent",o(!0),t),t.onSetContent=new i(s,"SetContent",o(!0),t)}),s.on("BeforeRenderUI",function(){var e=s.windowManager;e.onOpen=new i,e.onClose=new i,e.createInstance=function(e,t,n,o,r,i){return f("windowManager.createInstance(..)"),new(u.resolve(e))(t,n,o,r,i)}})}function r(){var t={};function n(){return r()}return f("editor.controlManager.*"),u.each("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".split(" "),function(e){t[e]=n}),t}}u.util.Dispatcher=i,u.onBeforeUnload=new i(u,"BeforeUnload"),u.onAddEditor=new i(u,"AddEditor","editor"),u.onRemoveEditor=new i(u,"RemoveEditor","editor"),u.util.Cookie={get:l,getHash:l,remove:l,set:l,setHash:l},u.on("SetupEditor",function(e){n(e.editor)}),u.PluginManager.add("compat3x",n),u.addI18n=function(n,e){var r=u.util.I18n,t=u.each;"string"!=typeof n||-1!==n.indexOf(".")?u.is(n,"string")?t(e,function(e,t){r.data[n+"."+t]=e}):t(n,function(e,o){t(e,function(e,n){t(e,function(e,t){"common"===n?r.data[o+"."+t]=e:r.data[o+"."+n+"."+t]=e})})}):r.add(n,e)}}(tinymce);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/directionality/plugin.js b/wp-includes/js/tinymce/plugins/directionality/plugin.js new file mode 100644 index 0000000..4b8669b --- /dev/null +++ b/wp-includes/js/tinymce/plugins/directionality/plugin.js @@ -0,0 +1,66 @@ +(function () { +var directionality = (function () { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var setDir = function (editor, dir) { + var dom = editor.dom; + var curDir; + var blocks = editor.selection.getSelectedBlocks(); + if (blocks.length) { + curDir = dom.getAttrib(blocks[0], 'dir'); + global$1.each(blocks, function (block) { + if (!dom.getParent(block.parentNode, '*[dir="' + dir + '"]', dom.getRoot())) { + dom.setAttrib(block, 'dir', curDir !== dir ? dir : null); + } + }); + editor.nodeChanged(); + } + }; + var Direction = { setDir: setDir }; + + var register = function (editor) { + editor.addCommand('mceDirectionLTR', function () { + Direction.setDir(editor, 'ltr'); + }); + editor.addCommand('mceDirectionRTL', function () { + Direction.setDir(editor, 'rtl'); + }); + }; + var Commands = { register: register }; + + var generateSelector = function (dir) { + var selector = []; + global$1.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function (name) { + selector.push(name + '[dir=' + dir + ']'); + }); + return selector.join(','); + }; + var register$1 = function (editor) { + editor.addButton('ltr', { + title: 'Left to right', + cmd: 'mceDirectionLTR', + stateSelector: generateSelector('ltr') + }); + editor.addButton('rtl', { + title: 'Right to left', + cmd: 'mceDirectionRTL', + stateSelector: generateSelector('rtl') + }); + }; + var Buttons = { register: register$1 }; + + global.add('directionality', function (editor) { + Commands.register(editor); + Buttons.register(editor); + }); + function Plugin () { + } + + return Plugin; + +}()); +})(); diff --git a/wp-includes/js/tinymce/plugins/directionality/plugin.min.js b/wp-includes/js/tinymce/plugins/directionality/plugin.min.js new file mode 100644 index 0000000..bb48bcf --- /dev/null +++ b/wp-includes/js/tinymce/plugins/directionality/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.util.Tools"),e=function(t,e){var i,n=t.dom,o=t.selection.getSelectedBlocks();o.length&&(i=n.getAttrib(o[0],"dir"),c.each(o,function(t){n.getParent(t.parentNode,'*[dir="'+e+'"]',n.getRoot())||n.setAttrib(t,"dir",i!==e?e:null)}),t.nodeChanged())},i=function(t){t.addCommand("mceDirectionLTR",function(){e(t,"ltr")}),t.addCommand("mceDirectionRTL",function(){e(t,"rtl")})},n=function(e){var i=[];return c.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(t){i.push(t+"[dir="+e+"]")}),i.join(",")},o=function(t){t.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:n("ltr")}),t.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:n("rtl")})};t.add("directionality",function(t){i(t),o(t)})}();
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/fullscreen/plugin.js b/wp-includes/js/tinymce/plugins/fullscreen/plugin.js new file mode 100644 index 0000000..1c5c00e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/fullscreen/plugin.js @@ -0,0 +1,177 @@ +(function () { +var fullscreen = (function (domGlobals) { + 'use strict'; + + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; + }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; + }; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var get = function (fullscreenState) { + return { + isFullscreen: function () { + return fullscreenState.get() !== null; + } + }; + }; + var Api = { get: get }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var fireFullscreenStateChanged = function (editor, state) { + editor.fire('FullscreenStateChanged', { state: state }); + }; + var Events = { fireFullscreenStateChanged: fireFullscreenStateChanged }; + + var DOM = global$1.DOM; + var getWindowSize = function () { + var w; + var h; + var win = domGlobals.window; + var doc = domGlobals.document; + var body = doc.body; + if (body.offsetWidth) { + w = body.offsetWidth; + h = body.offsetHeight; + } + if (win.innerWidth && win.innerHeight) { + w = win.innerWidth; + h = win.innerHeight; + } + return { + w: w, + h: h + }; + }; + var getScrollPos = function () { + var vp = DOM.getViewPort(); + return { + x: vp.x, + y: vp.y + }; + }; + var setScrollPos = function (pos) { + domGlobals.window.scrollTo(pos.x, pos.y); + }; + var toggleFullscreen = function (editor, fullscreenState) { + var body = domGlobals.document.body; + var documentElement = domGlobals.document.documentElement; + var editorContainerStyle; + var editorContainer, iframe, iframeStyle; + var fullscreenInfo = fullscreenState.get(); + var resize = function () { + DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); + }; + var removeResize = function () { + DOM.unbind(domGlobals.window, 'resize', resize); + }; + editorContainer = editor.getContainer(); + editorContainerStyle = editorContainer.style; + iframe = editor.getContentAreaContainer().firstChild; + iframeStyle = iframe.style; + if (!fullscreenInfo) { + var newFullScreenInfo = { + scrollPos: getScrollPos(), + containerWidth: editorContainerStyle.width, + containerHeight: editorContainerStyle.height, + iframeWidth: iframeStyle.width, + iframeHeight: iframeStyle.height, + resizeHandler: resize, + removeHandler: removeResize + }; + iframeStyle.width = iframeStyle.height = '100%'; + editorContainerStyle.width = editorContainerStyle.height = ''; + DOM.addClass(body, 'mce-fullscreen'); + DOM.addClass(documentElement, 'mce-fullscreen'); + DOM.addClass(editorContainer, 'mce-fullscreen'); + DOM.bind(domGlobals.window, 'resize', resize); + editor.on('remove', removeResize); + resize(); + fullscreenState.set(newFullScreenInfo); + Events.fireFullscreenStateChanged(editor, true); + } else { + iframeStyle.width = fullscreenInfo.iframeWidth; + iframeStyle.height = fullscreenInfo.iframeHeight; + if (fullscreenInfo.containerWidth) { + editorContainerStyle.width = fullscreenInfo.containerWidth; + } + if (fullscreenInfo.containerHeight) { + editorContainerStyle.height = fullscreenInfo.containerHeight; + } + DOM.removeClass(body, 'mce-fullscreen'); + DOM.removeClass(documentElement, 'mce-fullscreen'); + DOM.removeClass(editorContainer, 'mce-fullscreen'); + setScrollPos(fullscreenInfo.scrollPos); + DOM.unbind(domGlobals.window, 'resize', fullscreenInfo.resizeHandler); + editor.off('remove', fullscreenInfo.removeHandler); + fullscreenState.set(null); + Events.fireFullscreenStateChanged(editor, false); + } + }; + var Actions = { toggleFullscreen: toggleFullscreen }; + + var register = function (editor, fullscreenState) { + editor.addCommand('mceFullScreen', function () { + Actions.toggleFullscreen(editor, fullscreenState); + }); + }; + var Commands = { register: register }; + + var postRender = function (editor) { + return function (e) { + var ctrl = e.control; + editor.on('FullscreenStateChanged', function (e) { + ctrl.active(e.state); + }); + }; + }; + var register$1 = function (editor) { + editor.addMenuItem('fullscreen', { + text: 'Fullscreen', + shortcut: 'Ctrl+Shift+F', + selectable: true, + cmd: 'mceFullScreen', + onPostRender: postRender(editor), + context: 'view' + }); + editor.addButton('fullscreen', { + active: false, + tooltip: 'Fullscreen', + cmd: 'mceFullScreen', + onPostRender: postRender(editor) + }); + }; + var Buttons = { register: register$1 }; + + global.add('fullscreen', function (editor) { + var fullscreenState = Cell(null); + if (editor.settings.inline) { + return Api.get(fullscreenState); + } + Commands.register(editor, fullscreenState); + Buttons.register(editor); + editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen'); + return Api.get(fullscreenState); + }); + function Plugin () { + } + + return Plugin; + +}(window)); +})(); diff --git a/wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js b/wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js new file mode 100644 index 0000000..259afc9 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js @@ -0,0 +1 @@ +!function(m){"use strict";var i=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return i(t())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(e){return{isFullscreen:function(){return null!==e.get()}}},n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),g=function(e,n){e.fire("FullscreenStateChanged",{state:n})},w=n.DOM,r=function(e,n){var t,r,l,i,o,c,s=m.document.body,u=m.document.documentElement,d=n.get(),a=function(){var e,n,t,i;w.setStyle(l,"height",(t=m.window,i=m.document.body,i.offsetWidth&&(e=i.offsetWidth,n=i.offsetHeight),t.innerWidth&&t.innerHeight&&(e=t.innerWidth,n=t.innerHeight),{w:e,h:n}).h-(r.clientHeight-l.clientHeight))},h=function(){w.unbind(m.window,"resize",a)};if(t=(r=e.getContainer()).style,i=(l=e.getContentAreaContainer().firstChild).style,d)i.width=d.iframeWidth,i.height=d.iframeHeight,d.containerWidth&&(t.width=d.containerWidth),d.containerHeight&&(t.height=d.containerHeight),w.removeClass(s,"mce-fullscreen"),w.removeClass(u,"mce-fullscreen"),w.removeClass(r,"mce-fullscreen"),o=d.scrollPos,m.window.scrollTo(o.x,o.y),w.unbind(m.window,"resize",d.resizeHandler),e.off("remove",d.removeHandler),n.set(null),g(e,!1);else{var f={scrollPos:(c=w.getViewPort(),{x:c.x,y:c.y}),containerWidth:t.width,containerHeight:t.height,iframeWidth:i.width,iframeHeight:i.height,resizeHandler:a,removeHandler:h};i.width=i.height="100%",t.width=t.height="",w.addClass(s,"mce-fullscreen"),w.addClass(u,"mce-fullscreen"),w.addClass(r,"mce-fullscreen"),w.bind(m.window,"resize",a),e.on("remove",h),a(),n.set(f),g(e,!0)}},l=function(e,n){e.addCommand("mceFullScreen",function(){r(e,n)})},o=function(t){return function(e){var n=e.control;t.on("FullscreenStateChanged",function(e){n.active(e.state)})}},c=function(e){e.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Ctrl+Shift+F",selectable:!0,cmd:"mceFullScreen",onPostRender:o(e),context:"view"}),e.addButton("fullscreen",{active:!1,tooltip:"Fullscreen",cmd:"mceFullScreen",onPostRender:o(e)})};e.add("fullscreen",function(e){var n=i(null);return e.settings.inline||(l(e,n),c(e),e.addShortcut("Ctrl+Shift+F","","mceFullScreen")),t(n)})}(window);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/hr/plugin.js b/wp-includes/js/tinymce/plugins/hr/plugin.js new file mode 100644 index 0000000..56f9d08 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/hr/plugin.js @@ -0,0 +1,39 @@ +(function () { +var hr = (function () { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var register = function (editor) { + editor.addCommand('InsertHorizontalRule', function () { + editor.execCommand('mceInsertContent', false, '<hr />'); + }); + }; + var Commands = { register: register }; + + var register$1 = function (editor) { + editor.addButton('hr', { + icon: 'hr', + tooltip: 'Horizontal line', + cmd: 'InsertHorizontalRule' + }); + editor.addMenuItem('hr', { + icon: 'hr', + text: 'Horizontal line', + cmd: 'InsertHorizontalRule', + context: 'insert' + }); + }; + var Buttons = { register: register$1 }; + + global.add('hr', function (editor) { + Commands.register(editor); + Buttons.register(editor); + }); + function Plugin () { + } + + return Plugin; + +}()); +})(); diff --git a/wp-includes/js/tinymce/plugins/hr/plugin.min.js b/wp-includes/js/tinymce/plugins/hr/plugin.min.js new file mode 100644 index 0000000..72bc2ca --- /dev/null +++ b/wp-includes/js/tinymce/plugins/hr/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(n){n.addCommand("InsertHorizontalRule",function(){n.execCommand("mceInsertContent",!1,"<hr />")})},o=function(n){n.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),n.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})};n.add("hr",function(n){t(n),o(n)})}();
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/image/plugin.js b/wp-includes/js/tinymce/plugins/image/plugin.js new file mode 100644 index 0000000..62ccc9d --- /dev/null +++ b/wp-includes/js/tinymce/plugins/image/plugin.js @@ -0,0 +1,1209 @@ +(function () { +var image = (function (domGlobals) { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var hasDimensions = function (editor) { + return editor.settings.image_dimensions === false ? false : true; + }; + var hasAdvTab = function (editor) { + return editor.settings.image_advtab === true ? true : false; + }; + var getPrependUrl = function (editor) { + return editor.getParam('image_prepend_url', ''); + }; + var getClassList = function (editor) { + return editor.getParam('image_class_list'); + }; + var hasDescription = function (editor) { + return editor.settings.image_description === false ? false : true; + }; + var hasImageTitle = function (editor) { + return editor.settings.image_title === true ? true : false; + }; + var hasImageCaption = function (editor) { + return editor.settings.image_caption === true ? true : false; + }; + var getImageList = function (editor) { + return editor.getParam('image_list', false); + }; + var hasUploadUrl = function (editor) { + return editor.getParam('images_upload_url', false); + }; + var hasUploadHandler = function (editor) { + return editor.getParam('images_upload_handler', false); + }; + var getUploadUrl = function (editor) { + return editor.getParam('images_upload_url'); + }; + var getUploadHandler = function (editor) { + return editor.getParam('images_upload_handler'); + }; + var getUploadBasePath = function (editor) { + return editor.getParam('images_upload_base_path'); + }; + var getUploadCredentials = function (editor) { + return editor.getParam('images_upload_credentials'); + }; + var Settings = { + hasDimensions: hasDimensions, + hasAdvTab: hasAdvTab, + getPrependUrl: getPrependUrl, + getClassList: getClassList, + hasDescription: hasDescription, + hasImageTitle: hasImageTitle, + hasImageCaption: hasImageCaption, + getImageList: getImageList, + hasUploadUrl: hasUploadUrl, + hasUploadHandler: hasUploadHandler, + getUploadUrl: getUploadUrl, + getUploadHandler: getUploadHandler, + getUploadBasePath: getUploadBasePath, + getUploadCredentials: getUploadCredentials + }; + + var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')(); + + var path = function (parts, scope) { + var o = scope !== undefined && scope !== null ? scope : Global; + for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) { + o = o[parts[i]]; + } + return o; + }; + var resolve = function (p, scope) { + var parts = p.split('.'); + return path(parts, scope); + }; + + var unsafe = function (name, scope) { + return resolve(name, scope); + }; + var getOrDie = function (name, scope) { + var actual = unsafe(name, scope); + if (actual === undefined || actual === null) { + throw new Error(name + ' not available on this browser'); + } + return actual; + }; + var Global$1 = { getOrDie: getOrDie }; + + function FileReader () { + var f = Global$1.getOrDie('FileReader'); + return new f(); + } + + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Promise'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var global$3 = tinymce.util.Tools.resolve('tinymce.util.XHR'); + + var parseIntAndGetMax = function (val1, val2) { + return Math.max(parseInt(val1, 10), parseInt(val2, 10)); + }; + var getImageSize = function (url, callback) { + var img = domGlobals.document.createElement('img'); + function done(width, height) { + if (img.parentNode) { + img.parentNode.removeChild(img); + } + callback({ + width: width, + height: height + }); + } + img.onload = function () { + var width = parseIntAndGetMax(img.width, img.clientWidth); + var height = parseIntAndGetMax(img.height, img.clientHeight); + done(width, height); + }; + img.onerror = function () { + done(0, 0); + }; + var style = img.style; + style.visibility = 'hidden'; + style.position = 'fixed'; + style.bottom = style.left = '0px'; + style.width = style.height = 'auto'; + domGlobals.document.body.appendChild(img); + img.src = url; + }; + var buildListItems = function (inputList, itemCallback, startItems) { + function appendItems(values, output) { + output = output || []; + global$2.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 || []); + }; + var removePixelSuffix = function (value) { + if (value) { + value = value.replace(/px$/, ''); + } + return value; + }; + var addPixelSuffix = function (value) { + if (value.length > 0 && /^[0-9]+$/.test(value)) { + value += 'px'; + } + return value; + }; + var mergeMargins = function (css) { + if (css.margin) { + var splitMargin = css.margin.split(' '); + switch (splitMargin.length) { + case 1: + 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: + 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: + 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: + 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; + }; + var createImageList = function (editor, callback) { + var imageList = Settings.getImageList(editor); + if (typeof imageList === 'string') { + global$3.send({ + url: imageList, + success: function (text) { + callback(JSON.parse(text)); + } + }); + } else if (typeof imageList === 'function') { + imageList(callback); + } else { + callback(imageList); + } + }; + var waitLoadImage = function (editor, data, 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 && Settings.hasDimensions(editor)) { + editor.dom.setAttribs(imgElm, { + width: imgElm.clientWidth, + height: imgElm.clientHeight + }); + } + selectImage(); + }; + imgElm.onerror = selectImage; + }; + var blobToDataUri = function (blob) { + return new global$1(function (resolve, reject) { + var reader = FileReader(); + reader.onload = function () { + resolve(reader.result); + }; + reader.onerror = function () { + reject(reader.error.message); + }; + reader.readAsDataURL(blob); + }); + }; + var Utils = { + getImageSize: getImageSize, + buildListItems: buildListItems, + removePixelSuffix: removePixelSuffix, + addPixelSuffix: addPixelSuffix, + mergeMargins: mergeMargins, + createImageList: createImageList, + waitLoadImage: waitLoadImage, + blobToDataUri: blobToDataUri + }; + + var global$4 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var hasOwnProperty = Object.prototype.hasOwnProperty; + var shallow = function (old, nu) { + return nu; + }; + var baseMerge = function (merger) { + return function () { + var objects = new Array(arguments.length); + for (var i = 0; i < objects.length; i++) { + objects[i] = arguments[i]; + } + if (objects.length === 0) { + throw new Error('Can\'t merge zero objects'); + } + var ret = {}; + for (var j = 0; j < objects.length; j++) { + var curObject = objects[j]; + for (var key in curObject) { + if (hasOwnProperty.call(curObject, key)) { + ret[key] = merger(ret[key], curObject[key]); + } + } + } + return ret; + }; + }; + var merge = baseMerge(shallow); + + var DOM = global$4.DOM; + var getHspace = function (image) { + if (image.style.marginLeft && image.style.marginRight && image.style.marginLeft === image.style.marginRight) { + return Utils.removePixelSuffix(image.style.marginLeft); + } else { + return ''; + } + }; + var getVspace = function (image) { + if (image.style.marginTop && image.style.marginBottom && image.style.marginTop === image.style.marginBottom) { + return Utils.removePixelSuffix(image.style.marginTop); + } else { + return ''; + } + }; + var getBorder = function (image) { + if (image.style.borderWidth) { + return Utils.removePixelSuffix(image.style.borderWidth); + } else { + return ''; + } + }; + var getAttrib = function (image, name) { + if (image.hasAttribute(name)) { + return image.getAttribute(name); + } else { + return ''; + } + }; + var getStyle = function (image, name) { + return image.style[name] ? image.style[name] : ''; + }; + var hasCaption = function (image) { + return image.parentNode !== null && image.parentNode.nodeName === 'FIGURE'; + }; + var setAttrib = function (image, name, value) { + image.setAttribute(name, value); + }; + var wrapInFigure = function (image) { + var figureElm = DOM.create('figure', { class: 'image' }); + DOM.insertAfter(figureElm, image); + figureElm.appendChild(image); + figureElm.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); + figureElm.contentEditable = 'false'; + }; + var removeFigure = function (image) { + var figureElm = image.parentNode; + DOM.insertAfter(image, figureElm); + DOM.remove(figureElm); + }; + var toggleCaption = function (image) { + if (hasCaption(image)) { + removeFigure(image); + } else { + wrapInFigure(image); + } + }; + var normalizeStyle = function (image, normalizeCss) { + var attrValue = image.getAttribute('style'); + var value = normalizeCss(attrValue !== null ? attrValue : ''); + if (value.length > 0) { + image.setAttribute('style', value); + image.setAttribute('data-mce-style', value); + } else { + image.removeAttribute('style'); + } + }; + var setSize = function (name, normalizeCss) { + return function (image, name, value) { + if (image.style[name]) { + image.style[name] = Utils.addPixelSuffix(value); + normalizeStyle(image, normalizeCss); + } else { + setAttrib(image, name, value); + } + }; + }; + var getSize = function (image, name) { + if (image.style[name]) { + return Utils.removePixelSuffix(image.style[name]); + } else { + return getAttrib(image, name); + } + }; + var setHspace = function (image, value) { + var pxValue = Utils.addPixelSuffix(value); + image.style.marginLeft = pxValue; + image.style.marginRight = pxValue; + }; + var setVspace = function (image, value) { + var pxValue = Utils.addPixelSuffix(value); + image.style.marginTop = pxValue; + image.style.marginBottom = pxValue; + }; + var setBorder = function (image, value) { + var pxValue = Utils.addPixelSuffix(value); + image.style.borderWidth = pxValue; + }; + var setBorderStyle = function (image, value) { + image.style.borderStyle = value; + }; + var getBorderStyle = function (image) { + return getStyle(image, 'borderStyle'); + }; + var isFigure = function (elm) { + return elm.nodeName === 'FIGURE'; + }; + var defaultData = function () { + return { + src: '', + alt: '', + title: '', + width: '', + height: '', + class: '', + style: '', + caption: false, + hspace: '', + vspace: '', + border: '', + borderStyle: '' + }; + }; + var getStyleValue = function (normalizeCss, data) { + var image = domGlobals.document.createElement('img'); + setAttrib(image, 'style', data.style); + if (getHspace(image) || data.hspace !== '') { + setHspace(image, data.hspace); + } + if (getVspace(image) || data.vspace !== '') { + setVspace(image, data.vspace); + } + if (getBorder(image) || data.border !== '') { + setBorder(image, data.border); + } + if (getBorderStyle(image) || data.borderStyle !== '') { + setBorderStyle(image, data.borderStyle); + } + return normalizeCss(image.getAttribute('style')); + }; + var create = function (normalizeCss, data) { + var image = domGlobals.document.createElement('img'); + write(normalizeCss, merge(data, { caption: false }), image); + setAttrib(image, 'alt', data.alt); + if (data.caption) { + var figure = DOM.create('figure', { class: 'image' }); + figure.appendChild(image); + figure.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); + figure.contentEditable = 'false'; + return figure; + } else { + return image; + } + }; + var read = function (normalizeCss, image) { + return { + src: getAttrib(image, 'src'), + alt: getAttrib(image, 'alt'), + title: getAttrib(image, 'title'), + width: getSize(image, 'width'), + height: getSize(image, 'height'), + class: getAttrib(image, 'class'), + style: normalizeCss(getAttrib(image, 'style')), + caption: hasCaption(image), + hspace: getHspace(image), + vspace: getVspace(image), + border: getBorder(image), + borderStyle: getStyle(image, 'borderStyle') + }; + }; + var updateProp = function (image, oldData, newData, name, set) { + if (newData[name] !== oldData[name]) { + set(image, name, newData[name]); + } + }; + var normalized = function (set, normalizeCss) { + return function (image, name, value) { + set(image, value); + normalizeStyle(image, normalizeCss); + }; + }; + var write = function (normalizeCss, newData, image) { + var oldData = read(normalizeCss, image); + updateProp(image, oldData, newData, 'caption', function (image, _name, _value) { + return toggleCaption(image); + }); + updateProp(image, oldData, newData, 'src', setAttrib); + updateProp(image, oldData, newData, 'alt', setAttrib); + updateProp(image, oldData, newData, 'title', setAttrib); + updateProp(image, oldData, newData, 'width', setSize('width', normalizeCss)); + updateProp(image, oldData, newData, 'height', setSize('height', normalizeCss)); + updateProp(image, oldData, newData, 'class', setAttrib); + updateProp(image, oldData, newData, 'style', normalized(function (image, value) { + return setAttrib(image, 'style', value); + }, normalizeCss)); + updateProp(image, oldData, newData, 'hspace', normalized(setHspace, normalizeCss)); + updateProp(image, oldData, newData, 'vspace', normalized(setVspace, normalizeCss)); + updateProp(image, oldData, newData, 'border', normalized(setBorder, normalizeCss)); + updateProp(image, oldData, newData, 'borderStyle', normalized(setBorderStyle, normalizeCss)); + }; + + var normalizeCss = function (editor, cssText) { + var css = editor.dom.styles.parse(cssText); + var mergedCss = Utils.mergeMargins(css); + var compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss)); + return editor.dom.styles.serialize(compressed); + }; + var getSelectedImage = function (editor) { + var imgElm = editor.selection.getNode(); + var figureElm = editor.dom.getParent(imgElm, 'figure.image'); + if (figureElm) { + return editor.dom.select('img', figureElm)[0]; + } + if (imgElm && (imgElm.nodeName !== 'IMG' || imgElm.getAttribute('data-mce-object') || imgElm.getAttribute('data-mce-placeholder'))) { + return null; + } + return imgElm; + }; + var splitTextBlock = function (editor, figure) { + var dom = editor.dom; + var textBlock = dom.getParent(figure.parentNode, function (node) { + return editor.schema.getTextBlockElements()[node.nodeName]; + }, editor.getBody()); + if (textBlock) { + return dom.split(textBlock, figure); + } else { + return figure; + } + }; + var readImageDataFromSelection = function (editor) { + var image = getSelectedImage(editor); + return image ? read(function (css) { + return normalizeCss(editor, css); + }, image) : defaultData(); + }; + var insertImageAtCaret = function (editor, data) { + var elm = create(function (css) { + return normalizeCss(editor, css); + }, data); + editor.dom.setAttrib(elm, 'data-mce-id', '__mcenew'); + editor.focus(); + editor.selection.setContent(elm.outerHTML); + var insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0]; + editor.dom.setAttrib(insertedElm, 'data-mce-id', null); + if (isFigure(insertedElm)) { + var figure = splitTextBlock(editor, insertedElm); + editor.selection.select(figure); + } else { + editor.selection.select(insertedElm); + } + }; + var syncSrcAttr = function (editor, image) { + editor.dom.setAttrib(image, 'src', image.getAttribute('src')); + }; + var deleteImage = function (editor, image) { + if (image) { + var elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image; + editor.dom.remove(elm); + editor.focus(); + editor.nodeChanged(); + if (editor.dom.isEmpty(editor.getBody())) { + editor.setContent(''); + editor.selection.setCursorLocation(); + } + } + }; + var writeImageDataToSelection = function (editor, data) { + var image = getSelectedImage(editor); + write(function (css) { + return normalizeCss(editor, css); + }, data, image); + syncSrcAttr(editor, image); + if (isFigure(image.parentNode)) { + var figure = image.parentNode; + splitTextBlock(editor, figure); + editor.selection.select(image.parentNode); + } else { + editor.selection.select(image); + Utils.waitLoadImage(editor, data, image); + } + }; + var insertOrUpdateImage = function (editor, data) { + var image = getSelectedImage(editor); + if (image) { + if (data.src) { + writeImageDataToSelection(editor, data); + } else { + deleteImage(editor, image); + } + } else if (data.src) { + insertImageAtCaret(editor, data); + } + }; + + var updateVSpaceHSpaceBorder = function (editor) { + return function (evt) { + var dom = editor.dom; + var rootControl = evt.control.rootControl; + if (!Settings.hasAdvTab(editor)) { + return; + } + var data = rootControl.toJSON(); + var css = dom.parseStyle(data.style); + rootControl.find('#vspace').value(''); + rootControl.find('#hspace').value(''); + css = Utils.mergeMargins(css); + if (css['margin-top'] && css['margin-bottom'] || css['margin-right'] && css['margin-left']) { + if (css['margin-top'] === css['margin-bottom']) { + rootControl.find('#vspace').value(Utils.removePixelSuffix(css['margin-top'])); + } else { + rootControl.find('#vspace').value(''); + } + if (css['margin-right'] === css['margin-left']) { + rootControl.find('#hspace').value(Utils.removePixelSuffix(css['margin-right'])); + } else { + rootControl.find('#hspace').value(''); + } + } + if (css['border-width']) { + rootControl.find('#border').value(Utils.removePixelSuffix(css['border-width'])); + } else { + rootControl.find('#border').value(''); + } + if (css['border-style']) { + rootControl.find('#borderStyle').value(css['border-style']); + } else { + rootControl.find('#borderStyle').value(''); + } + rootControl.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css)))); + }; + }; + var updateStyle = function (editor, win) { + win.find('#style').each(function (ctrl) { + var value = getStyleValue(function (css) { + return normalizeCss(editor, css); + }, merge(defaultData(), win.toJSON())); + ctrl.value(value); + }); + }; + var makeTab = function (editor) { + return { + title: 'Advanced', + type: 'form', + pack: 'start', + items: [ + { + label: 'Style', + name: 'style', + type: 'textbox', + onchange: updateVSpaceHSpaceBorder(editor) + }, + { + type: 'form', + layout: 'grid', + packV: 'start', + columns: 2, + padding: 0, + defaults: { + type: 'textbox', + maxWidth: 50, + onchange: function (evt) { + updateStyle(editor, evt.control.rootControl); + } + }, + items: [ + { + label: 'Vertical space', + name: 'vspace' + }, + { + label: 'Border width', + name: 'border' + }, + { + label: 'Horizontal space', + name: 'hspace' + }, + { + label: 'Border style', + type: 'listbox', + name: 'borderStyle', + width: 90, + maxWidth: 90, + onselect: function (evt) { + updateStyle(editor, evt.control.rootControl); + }, + values: [ + { + text: 'Select...', + value: '' + }, + { + text: 'Solid', + value: 'solid' + }, + { + text: 'Dotted', + value: 'dotted' + }, + { + text: 'Dashed', + value: 'dashed' + }, + { + text: 'Double', + value: 'double' + }, + { + text: 'Groove', + value: 'groove' + }, + { + text: 'Ridge', + value: 'ridge' + }, + { + text: 'Inset', + value: 'inset' + }, + { + text: 'Outset', + value: 'outset' + }, + { + text: 'None', + value: 'none' + }, + { + text: 'Hidden', + value: 'hidden' + } + ] + } + ] + } + ] + }; + }; + var AdvTab = { makeTab: makeTab }; + + var doSyncSize = function (widthCtrl, heightCtrl) { + widthCtrl.state.set('oldVal', widthCtrl.value()); + heightCtrl.state.set('oldVal', heightCtrl.value()); + }; + var doSizeControls = function (win, f) { + var widthCtrl = win.find('#width')[0]; + var heightCtrl = win.find('#height')[0]; + var constrained = win.find('#constrain')[0]; + if (widthCtrl && heightCtrl && constrained) { + f(widthCtrl, heightCtrl, constrained.checked()); + } + }; + var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { + var oldWidth = widthCtrl.state.get('oldVal'); + var oldHeight = heightCtrl.state.get('oldVal'); + var newWidth = widthCtrl.value(); + var newHeight = heightCtrl.value(); + if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { + if (newWidth !== oldWidth) { + newHeight = Math.round(newWidth / oldWidth * newHeight); + if (!isNaN(newHeight)) { + heightCtrl.value(newHeight); + } + } else { + newWidth = Math.round(newHeight / oldHeight * newWidth); + if (!isNaN(newWidth)) { + widthCtrl.value(newWidth); + } + } + } + doSyncSize(widthCtrl, heightCtrl); + }; + var syncSize = function (win) { + doSizeControls(win, doSyncSize); + }; + var updateSize = function (win) { + doSizeControls(win, doUpdateSize); + }; + var createUi = function () { + var recalcSize = function (evt) { + updateSize(evt.control.rootControl); + }; + return { + type: 'container', + label: 'Dimensions', + layout: 'flex', + align: 'center', + spacing: 5, + items: [ + { + name: 'width', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Width' + }, + { + type: 'label', + text: 'x' + }, + { + name: 'height', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Height' + }, + { + name: 'constrain', + type: 'checkbox', + checked: true, + text: 'Constrain proportions' + } + ] + }; + }; + var SizeManager = { + createUi: createUi, + syncSize: syncSize, + updateSize: updateSize + }; + + var onSrcChange = function (evt, editor) { + var srcURL, prependURL, absoluteURLPattern; + var meta = evt.meta || {}; + var control = evt.control; + var rootControl = control.rootControl; + var imageListCtrl = rootControl.find('#image-list')[0]; + if (imageListCtrl) { + imageListCtrl.value(editor.convertURL(control.value(), 'src')); + } + global$2.each(meta, function (value, key) { + rootControl.find('#' + key).value(value); + }); + if (!meta.width && !meta.height) { + srcURL = editor.convertURL(control.value(), 'src'); + prependURL = Settings.getPrependUrl(editor); + absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i'); + if (prependURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, prependURL.length) !== prependURL) { + srcURL = prependURL + srcURL; + } + control.value(srcURL); + Utils.getImageSize(editor.documentBaseURI.toAbsolute(control.value()), function (data) { + if (data.width && data.height && Settings.hasDimensions(editor)) { + rootControl.find('#width').value(data.width); + rootControl.find('#height').value(data.height); + SizeManager.syncSize(rootControl); + } + }); + } + }; + var onBeforeCall = function (evt) { + evt.meta = evt.control.rootControl.toJSON(); + }; + var getGeneralItems = function (editor, imageListCtrl) { + var generalFormItems = [ + { + name: 'src', + type: 'filepicker', + filetype: 'image', + label: 'Source', + autofocus: true, + onchange: function (evt) { + onSrcChange(evt, editor); + }, + onbeforecall: onBeforeCall + }, + imageListCtrl + ]; + if (Settings.hasDescription(editor)) { + generalFormItems.push({ + name: 'alt', + type: 'textbox', + label: 'Image description' + }); + } + if (Settings.hasImageTitle(editor)) { + generalFormItems.push({ + name: 'title', + type: 'textbox', + label: 'Image Title' + }); + } + if (Settings.hasDimensions(editor)) { + generalFormItems.push(SizeManager.createUi()); + } + if (Settings.getClassList(editor)) { + generalFormItems.push({ + name: 'class', + type: 'listbox', + label: 'Class', + values: Utils.buildListItems(Settings.getClassList(editor), function (item) { + if (item.value) { + item.textStyle = function () { + return editor.formatter.getCssText({ + inline: 'img', + classes: [item.value] + }); + }; + } + }) + }); + } + if (Settings.hasImageCaption(editor)) { + generalFormItems.push({ + name: 'caption', + type: 'checkbox', + label: 'Caption' + }); + } + return generalFormItems; + }; + var makeTab$1 = function (editor, imageListCtrl) { + return { + title: 'General', + type: 'form', + items: getGeneralItems(editor, imageListCtrl) + }; + }; + var MainTab = { + makeTab: makeTab$1, + getGeneralItems: getGeneralItems + }; + + var url = function () { + return Global$1.getOrDie('URL'); + }; + var createObjectURL = function (blob) { + return url().createObjectURL(blob); + }; + var revokeObjectURL = function (u) { + url().revokeObjectURL(u); + }; + var URL = { + createObjectURL: createObjectURL, + revokeObjectURL: revokeObjectURL + }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.ui.Factory'); + + function XMLHttpRequest () { + var f = Global$1.getOrDie('XMLHttpRequest'); + return new f(); + } + + var noop = function () { + }; + var pathJoin = function (path1, path2) { + if (path1) { + return path1.replace(/\/$/, '') + '/' + path2.replace(/^\//, ''); + } + return path2; + }; + function Uploader (settings) { + var defaultHandler = function (blobInfo, success, failure, progress) { + var xhr, formData; + xhr = XMLHttpRequest(); + xhr.open('POST', settings.url); + xhr.withCredentials = settings.credentials; + xhr.upload.onprogress = function (e) { + progress(e.loaded / e.total * 100); + }; + xhr.onerror = function () { + failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status); + }; + xhr.onload = function () { + var json; + if (xhr.status < 200 || xhr.status >= 300) { + failure('HTTP Error: ' + xhr.status); + return; + } + json = JSON.parse(xhr.responseText); + if (!json || typeof json.location !== 'string') { + failure('Invalid JSON: ' + xhr.responseText); + return; + } + success(pathJoin(settings.basePath, json.location)); + }; + formData = new domGlobals.FormData(); + formData.append('file', blobInfo.blob(), blobInfo.filename()); + xhr.send(formData); + }; + var uploadBlob = function (blobInfo, handler) { + return new global$1(function (resolve, reject) { + try { + handler(blobInfo, resolve, reject, noop); + } catch (ex) { + reject(ex.message); + } + }); + }; + var isDefaultHandler = function (handler) { + return handler === defaultHandler; + }; + var upload = function (blobInfo) { + return !settings.url && isDefaultHandler(settings.handler) ? global$1.reject('Upload url missing from the settings.') : uploadBlob(blobInfo, settings.handler); + }; + settings = global$2.extend({ + credentials: false, + handler: defaultHandler + }, settings); + return { upload: upload }; + } + + var onFileInput = function (editor) { + return function (evt) { + var Throbber = global$5.get('Throbber'); + var rootControl = evt.control.rootControl; + var throbber = new Throbber(rootControl.getEl()); + var file = evt.control.value(); + var blobUri = URL.createObjectURL(file); + var uploader = Uploader({ + url: Settings.getUploadUrl(editor), + basePath: Settings.getUploadBasePath(editor), + credentials: Settings.getUploadCredentials(editor), + handler: Settings.getUploadHandler(editor) + }); + var finalize = function () { + throbber.hide(); + URL.revokeObjectURL(blobUri); + }; + throbber.show(); + return Utils.blobToDataUri(file).then(function (dataUrl) { + var blobInfo = editor.editorUpload.blobCache.create({ + blob: file, + blobUri: blobUri, + name: file.name ? file.name.replace(/\.[^\.]+$/, '') : null, + base64: dataUrl.split(',')[1] + }); + return uploader.upload(blobInfo).then(function (url) { + var src = rootControl.find('#src'); + src.value(url); + rootControl.find('tabpanel')[0].activateTab(0); + src.fire('change'); + finalize(); + return url; + }); + }).catch(function (err) { + editor.windowManager.alert(err); + finalize(); + }); + }; + }; + var acceptExts = '.jpg,.jpeg,.png,.gif'; + var makeTab$2 = function (editor) { + return { + title: 'Upload', + type: 'form', + layout: 'flex', + direction: 'column', + align: 'stretch', + padding: '20 20 20 20', + items: [ + { + type: 'container', + layout: 'flex', + direction: 'column', + align: 'center', + spacing: 10, + items: [ + { + text: 'Browse for an image', + type: 'browsebutton', + accept: acceptExts, + onchange: onFileInput(editor) + }, + { + text: 'OR', + type: 'label' + } + ] + }, + { + text: 'Drop an image here', + type: 'dropzone', + accept: acceptExts, + height: 100, + onchange: onFileInput(editor) + } + ] + }; + }; + var UploadTab = { makeTab: makeTab$2 }; + + function curry(fn) { + var initialArgs = []; + for (var _i = 1; _i < arguments.length; _i++) { + initialArgs[_i - 1] = arguments[_i]; + } + return function () { + var restArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + restArgs[_i] = arguments[_i]; + } + var all = initialArgs.concat(restArgs); + return fn.apply(null, all); + }; + } + + var submitForm = function (editor, evt) { + var win = evt.control.getRoot(); + SizeManager.updateSize(win); + editor.undoManager.transact(function () { + var data = merge(readImageDataFromSelection(editor), win.toJSON()); + insertOrUpdateImage(editor, data); + }); + editor.editorUpload.uploadImagesAuto(); + }; + function Dialog (editor) { + function showDialog(imageList) { + var data = readImageDataFromSelection(editor); + var win, imageListCtrl; + if (imageList) { + imageListCtrl = { + type: 'listbox', + label: 'Image list', + name: 'image-list', + values: Utils.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 () { + imageListCtrl = this; + } + }; + } + if (Settings.hasAdvTab(editor) || Settings.hasUploadUrl(editor) || Settings.hasUploadHandler(editor)) { + var body = [MainTab.makeTab(editor, imageListCtrl)]; + if (Settings.hasAdvTab(editor)) { + body.push(AdvTab.makeTab(editor)); + } + if (Settings.hasUploadUrl(editor) || Settings.hasUploadHandler(editor)) { + body.push(UploadTab.makeTab(editor)); + } + win = editor.windowManager.open({ + title: 'Insert/edit image', + data: data, + bodyType: 'tabpanel', + body: body, + onSubmit: curry(submitForm, editor) + }); + } else { + win = editor.windowManager.open({ + title: 'Insert/edit image', + data: data, + body: MainTab.getGeneralItems(editor, imageListCtrl), + onSubmit: curry(submitForm, editor) + }); + } + SizeManager.syncSize(win); + } + function open() { + Utils.createImageList(editor, showDialog); + } + return { open: open }; + } + + var register = function (editor) { + editor.addCommand('mceImage', Dialog(editor).open); + }; + var Commands = { register: register }; + + var hasImageClass = function (node) { + var className = node.attr('class'); + return className && /\bimage\b/.test(className); + }; + var toggleContentEditableState = function (state) { + return function (nodes) { + var i = nodes.length, node; + var toggleContentEditable = function (node) { + node.attr('contenteditable', state ? 'true' : null); + }; + while (i--) { + node = nodes[i]; + if (hasImageClass(node)) { + node.attr('contenteditable', state ? 'false' : null); + global$2.each(node.getAll('figcaption'), toggleContentEditable); + } + } + }; + }; + var setup = function (editor) { + editor.on('preInit', function () { + editor.parser.addNodeFilter('figure', toggleContentEditableState(true)); + editor.serializer.addNodeFilter('figure', toggleContentEditableState(false)); + }); + }; + var FilterContent = { setup: setup }; + + var register$1 = function (editor) { + editor.addButton('image', { + icon: 'image', + tooltip: 'Insert/edit image', + onclick: Dialog(editor).open, + stateSelector: 'img:not([data-mce-object],[data-mce-placeholder]),figure.image' + }); + editor.addMenuItem('image', { + icon: 'image', + text: 'Image', + onclick: Dialog(editor).open, + context: 'insert', + prependToContext: true + }); + }; + var Buttons = { register: register$1 }; + + global.add('image', function (editor) { + FilterContent.setup(editor); + Buttons.register(editor); + Commands.register(editor); + }); + function Plugin () { + } + + return Plugin; + +}(window)); +})(); diff --git a/wp-includes/js/tinymce/plugins/image/plugin.min.js b/wp-includes/js/tinymce/plugins/image/plugin.min.js new file mode 100644 index 0000000..23473aa --- /dev/null +++ b/wp-includes/js/tinymce/plugins/image/plugin.min.js @@ -0,0 +1 @@ +!function(l){"use strict";var i,e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=function(e){return!1!==e.settings.image_dimensions},u=function(e){return!0===e.settings.image_advtab},m=function(e){return e.getParam("image_prepend_url","")},n=function(e){return e.getParam("image_class_list")},r=function(e){return!1!==e.settings.image_description},a=function(e){return!0===e.settings.image_title},o=function(e){return!0===e.settings.image_caption},c=function(e){return e.getParam("image_list",!1)},s=function(e){return e.getParam("images_upload_url",!1)},g=function(e){return e.getParam("images_upload_handler",!1)},f=function(e){return e.getParam("images_upload_url")},p=function(e){return e.getParam("images_upload_handler")},h=function(e){return e.getParam("images_upload_base_path")},v=function(e){return e.getParam("images_upload_credentials")},b="undefined"!=typeof l.window?l.window:Function("return this;")(),y=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:b,r=0;r<e.length&&n!==undefined&&null!==n;++r)n=n[e[r]];return n}(e.split("."),t)},x={getOrDie:function(e,t){var n=y(e,t);if(n===undefined||null===n)throw new Error(e+" not available on this browser");return n}},w=tinymce.util.Tools.resolve("tinymce.util.Promise"),C=tinymce.util.Tools.resolve("tinymce.util.Tools"),S=tinymce.util.Tools.resolve("tinymce.util.XHR"),N=function(e,t){return Math.max(parseInt(e,10),parseInt(t,10))},_=function(e,n){var r=l.document.createElement("img");function t(e,t){r.parentNode&&r.parentNode.removeChild(r),n({width:e,height:t})}r.onload=function(){t(N(r.width,r.clientWidth),N(r.height,r.clientHeight))},r.onerror=function(){t(0,0)};var a=r.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left="0px",a.width=a.height="auto",l.document.body.appendChild(r),r.src=e},T=function(e,a,t){return function n(e,r){return r=r||[],C.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=n(e.menu):(t.value=e.value,a(t)),r.push(t)}),r}(e,t||[])},A=function(e){return e&&(e=e.replace(/px$/,"")),e},R=function(e){return 0<e.length&&/^[0-9]+$/.test(e)&&(e+="px"),e},I=function(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e},t=function(e,t){var n=c(e);"string"==typeof n?S.send({url:n,success:function(e){t(JSON.parse(e))}}):"function"==typeof n?n(t):t(n)},O=function(e,t,n){function r(){n.onload=n.onerror=null,e.selection&&(e.selection.select(n),e.nodeChanged())}n.onload=function(){t.width||t.height||!d(e)||e.dom.setAttribs(n,{width:n.clientWidth,height:n.clientHeight}),r()},n.onerror=r},L=function(r){return new w(function(e,t){var n=new(x.getOrDie("FileReader"));n.onload=function(){e(n.result)},n.onerror=function(){t(n.error.message)},n.readAsDataURL(r)})},P=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),U=Object.prototype.hasOwnProperty,E=(i=function(e,t){return t},function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var a=e[r];for(var o in a)U.call(a,o)&&(n[o]=i(n[o],a[o]))}return n}),k=P.DOM,M=function(e){return e.style.marginLeft&&e.style.marginRight&&e.style.marginLeft===e.style.marginRight?A(e.style.marginLeft):""},D=function(e){return e.style.marginTop&&e.style.marginBottom&&e.style.marginTop===e.style.marginBottom?A(e.style.marginTop):""},z=function(e){return e.style.borderWidth?A(e.style.borderWidth):""},B=function(e,t){return e.hasAttribute(t)?e.getAttribute(t):""},H=function(e,t){return e.style[t]?e.style[t]:""},j=function(e){return null!==e.parentNode&&"FIGURE"===e.parentNode.nodeName},F=function(e,t,n){e.setAttribute(t,n)},W=function(e){var t,n,r,a;j(e)?(a=(r=e).parentNode,k.insertAfter(r,a),k.remove(a)):(t=e,n=k.create("figure",{"class":"image"}),k.insertAfter(n,t),n.appendChild(t),n.appendChild(k.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable="false")},J=function(e,t){var n=e.getAttribute("style"),r=t(null!==n?n:"");0<r.length?(e.setAttribute("style",r),e.setAttribute("data-mce-style",r)):e.removeAttribute("style")},V=function(e,r){return function(e,t,n){e.style[t]?(e.style[t]=R(n),J(e,r)):F(e,t,n)}},G=function(e,t){return e.style[t]?A(e.style[t]):B(e,t)},$=function(e,t){var n=R(t);e.style.marginLeft=n,e.style.marginRight=n},X=function(e,t){var n=R(t);e.style.marginTop=n,e.style.marginBottom=n},q=function(e,t){var n=R(t);e.style.borderWidth=n},K=function(e,t){e.style.borderStyle=t},Q=function(e){return"FIGURE"===e.nodeName},Y=function(e,t){var n=l.document.createElement("img");return F(n,"style",t.style),(M(n)||""!==t.hspace)&&$(n,t.hspace),(D(n)||""!==t.vspace)&&X(n,t.vspace),(z(n)||""!==t.border)&&q(n,t.border),(H(n,"borderStyle")||""!==t.borderStyle)&&K(n,t.borderStyle),e(n.getAttribute("style"))},Z=function(e,t){return{src:B(t,"src"),alt:B(t,"alt"),title:B(t,"title"),width:G(t,"width"),height:G(t,"height"),"class":B(t,"class"),style:e(B(t,"style")),caption:j(t),hspace:M(t),vspace:D(t),border:z(t),borderStyle:H(t,"borderStyle")}},ee=function(e,t,n,r,a){n[r]!==t[r]&&a(e,r,n[r])},te=function(r,a){return function(e,t,n){r(e,n),J(e,a)}},ne=function(e,t,n){var r=Z(e,n);ee(n,r,t,"caption",function(e,t,n){return W(e)}),ee(n,r,t,"src",F),ee(n,r,t,"alt",F),ee(n,r,t,"title",F),ee(n,r,t,"width",V(0,e)),ee(n,r,t,"height",V(0,e)),ee(n,r,t,"class",F),ee(n,r,t,"style",te(function(e,t){return F(e,"style",t)},e)),ee(n,r,t,"hspace",te($,e)),ee(n,r,t,"vspace",te(X,e)),ee(n,r,t,"border",te(q,e)),ee(n,r,t,"borderStyle",te(K,e))},re=function(e,t){var n=e.dom.styles.parse(t),r=I(n),a=e.dom.styles.parse(e.dom.styles.serialize(r));return e.dom.styles.serialize(a)},ae=function(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"figure.image");return n?e.dom.select("img",n)[0]:t&&("IMG"!==t.nodeName||t.getAttribute("data-mce-object")||t.getAttribute("data-mce-placeholder"))?null:t},oe=function(t,e){var n=t.dom,r=n.getParent(e.parentNode,function(e){return t.schema.getTextBlockElements()[e.nodeName]},t.getBody());return r?n.split(r,e):e},ie=function(t){var e=ae(t);return e?Z(function(e){return re(t,e)},e):{src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""}},le=function(t,e){var n=function(e,t){var n=l.document.createElement("img");if(ne(e,E(t,{caption:!1}),n),F(n,"alt",t.alt),t.caption){var r=k.create("figure",{"class":"image"});return r.appendChild(n),r.appendChild(k.create("figcaption",{contentEditable:!0},"Caption")),r.contentEditable="false",r}return n}(function(e){return re(t,e)},e);t.dom.setAttrib(n,"data-mce-id","__mcenew"),t.focus(),t.selection.setContent(n.outerHTML);var r=t.dom.select('*[data-mce-id="__mcenew"]')[0];if(t.dom.setAttrib(r,"data-mce-id",null),Q(r)){var a=oe(t,r);t.selection.select(a)}else t.selection.select(r)},ue=function(e,t){var n=ae(e);n?t.src?function(t,e){var n,r=ae(t);if(ne(function(e){return re(t,e)},e,r),n=r,t.dom.setAttrib(n,"src",n.getAttribute("src")),Q(r.parentNode)){var a=r.parentNode;oe(t,a),t.selection.select(r.parentNode)}else t.selection.select(r),O(t,e,r)}(e,t):function(e,t){if(t){var n=e.dom.is(t.parentNode,"figure.image")?t.parentNode:t;e.dom.remove(n),e.focus(),e.nodeChanged(),e.dom.isEmpty(e.getBody())&&(e.setContent(""),e.selection.setCursorLocation())}}(e,n):t.src&&le(e,t)},ce=function(n,r){r.find("#style").each(function(e){var t=Y(function(e){return re(n,e)},E({src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""},r.toJSON()));e.value(t)})},se=function(t){return{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:(o=t,function(e){var t=o.dom,n=e.control.rootControl;if(u(o)){var r=n.toJSON(),a=t.parseStyle(r.style);n.find("#vspace").value(""),n.find("#hspace").value(""),((a=I(a))["margin-top"]&&a["margin-bottom"]||a["margin-right"]&&a["margin-left"])&&(a["margin-top"]===a["margin-bottom"]?n.find("#vspace").value(A(a["margin-top"])):n.find("#vspace").value(""),a["margin-right"]===a["margin-left"]?n.find("#hspace").value(A(a["margin-right"])):n.find("#hspace").value("")),a["border-width"]?n.find("#border").value(A(a["border-width"])):n.find("#border").value(""),a["border-style"]?n.find("#borderStyle").value(a["border-style"]):n.find("#borderStyle").value(""),n.find("#style").value(t.serializeStyle(t.parseStyle(t.serializeStyle(a))))}})},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,defaults:{type:"textbox",maxWidth:50,onchange:function(e){ce(t,e.control.rootControl)}},items:[{label:"Vertical space",name:"vspace"},{label:"Border width",name:"border"},{label:"Horizontal space",name:"hspace"},{label:"Border style",type:"listbox",name:"borderStyle",width:90,maxWidth:90,onselect:function(e){ce(t,e.control.rootControl)},values:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]};var o},de=function(e,t){e.state.set("oldVal",e.value()),t.state.set("oldVal",t.value())},me=function(e,t){var n=e.find("#width")[0],r=e.find("#height")[0],a=e.find("#constrain")[0];n&&r&&a&&t(n,r,a.checked())},ge=function(e,t,n){var r=e.state.get("oldVal"),a=t.state.get("oldVal"),o=e.value(),i=t.value();n&&r&&a&&o&&i&&(o!==r?(i=Math.round(o/r*i),isNaN(i)||t.value(i)):(o=Math.round(i/a*o),isNaN(o)||e.value(o))),de(e,t)},fe=function(e){me(e,ge)},pe=function(){var e=function(e){fe(e.control.rootControl)};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}},he=function(e){me(e,de)},ve=fe,be=function(e){e.meta=e.control.rootControl.toJSON()},ye=function(s,e){var t=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:function(e){var t,n,r,a,o,i,l,u,c;n=s,i=(t=e).meta||{},l=t.control,u=l.rootControl,(c=u.find("#image-list")[0])&&c.value(n.convertURL(l.value(),"src")),C.each(i,function(e,t){u.find("#"+t).value(e)}),i.width||i.height||(r=n.convertURL(l.value(),"src"),a=m(n),o=new RegExp("^(?:[a-z]+:)?//","i"),a&&!o.test(r)&&r.substring(0,a.length)!==a&&(r=a+r),l.value(r),_(n.documentBaseURI.toAbsolute(l.value()),function(e){e.width&&e.height&&d(n)&&(u.find("#width").value(e.width),u.find("#height").value(e.height),he(u))}))},onbeforecall:be},e];return r(s)&&t.push({name:"alt",type:"textbox",label:"Image description"}),a(s)&&t.push({name:"title",type:"textbox",label:"Image Title"}),d(s)&&t.push(pe()),n(s)&&t.push({name:"class",type:"listbox",label:"Class",values:T(n(s),function(e){e.value&&(e.textStyle=function(){return s.formatter.getCssText({inline:"img",classes:[e.value]})})})}),o(s)&&t.push({name:"caption",type:"checkbox",label:"Caption"}),t},xe=function(e,t){return{title:"General",type:"form",items:ye(e,t)}},we=ye,Ce=function(){return x.getOrDie("URL")},Se=function(e){return Ce().createObjectURL(e)},Ne=function(e){Ce().revokeObjectURL(e)},_e=tinymce.util.Tools.resolve("tinymce.ui.Factory"),Te=function(){};function Ae(i){var t=function(e,r,a,t){var o,n;(o=new(x.getOrDie("XMLHttpRequest"))).open("POST",i.url),o.withCredentials=i.credentials,o.upload.onprogress=function(e){t(e.loaded/e.total*100)},o.onerror=function(){a("Image upload failed due to a XHR Transport error. Code: "+o.status)},o.onload=function(){var e,t,n;o.status<200||300<=o.status?a("HTTP Error: "+o.status):(e=JSON.parse(o.responseText))&&"string"==typeof e.location?r((t=i.basePath,n=e.location,t?t.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):a("Invalid JSON: "+o.responseText)},(n=new l.FormData).append("file",e.blob(),e.filename()),o.send(n)};return i=C.extend({credentials:!1,handler:t},i),{upload:function(e){return i.url||i.handler!==t?(r=e,a=i.handler,new w(function(e,t){try{a(r,e,t,Te)}catch(n){t(n.message)}})):w.reject("Upload url missing from the settings.");var r,a}}}var Re=function(u){return function(e){var t=_e.get("Throbber"),n=e.control.rootControl,r=new t(n.getEl()),a=e.control.value(),o=Se(a),i=Ae({url:f(u),basePath:h(u),credentials:v(u),handler:p(u)}),l=function(){r.hide(),Ne(o)};return r.show(),L(a).then(function(e){var t=u.editorUpload.blobCache.create({blob:a,blobUri:o,name:a.name?a.name.replace(/\.[^\.]+$/,""):null,base64:e.split(",")[1]});return i.upload(t).then(function(e){var t=n.find("#src");return t.value(e),n.find("tabpanel")[0].activateTab(0),t.fire("change"),l(),e})})["catch"](function(e){u.windowManager.alert(e),l()})}},Ie=".jpg,.jpeg,.png,.gif",Oe=function(e){return{title:"Upload",type:"form",layout:"flex",direction:"column",align:"stretch",padding:"20 20 20 20",items:[{type:"container",layout:"flex",direction:"column",align:"center",spacing:10,items:[{text:"Browse for an image",type:"browsebutton",accept:Ie,onchange:Re(e)},{text:"OR",type:"label"}]},{text:"Drop an image here",type:"dropzone",accept:Ie,height:100,onchange:Re(e)}]}};function Le(r){for(var a=[],e=1;e<arguments.length;e++)a[e-1]=arguments[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=a.concat(e);return r.apply(null,n)}}var Pe=function(t,e){var n=e.control.getRoot();ve(n),t.undoManager.transact(function(){var e=E(ie(t),n.toJSON());ue(t,e)}),t.editorUpload.uploadImagesAuto()};function Ue(o){function e(e){var n,t,r=ie(o);if(e&&(t={type:"listbox",label:"Image list",name:"image-list",values:T(e,function(e){e.value=o.convertURL(e.value||e.url,"src")},[{text:"None",value:""}]),value:r.src&&o.convertURL(r.src,"src"),onselect:function(e){var t=n.find("#alt");(!t.value()||e.lastControl&&t.value()===e.lastControl.text())&&t.value(e.control.text()),n.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){t=this}}),u(o)||s(o)||g(o)){var a=[xe(o,t)];u(o)&&a.push(se(o)),(s(o)||g(o))&&a.push(Oe(o)),n=o.windowManager.open({title:"Insert/edit image",data:r,bodyType:"tabpanel",body:a,onSubmit:Le(Pe,o)})}else n=o.windowManager.open({title:"Insert/edit image",data:r,body:we(o,t),onSubmit:Le(Pe,o)});he(n)}return{open:function(){t(o,e)}}}var Ee=function(e){e.addCommand("mceImage",Ue(e).open)},ke=function(o){return function(e){for(var t,n,r=e.length,a=function(e){e.attr("contenteditable",o?"true":null)};r--;)t=e[r],(n=t.attr("class"))&&/\bimage\b/.test(n)&&(t.attr("contenteditable",o?"false":null),C.each(t.getAll("figcaption"),a))}},Me=function(e){e.on("preInit",function(){e.parser.addNodeFilter("figure",ke(!0)),e.serializer.addNodeFilter("figure",ke(!1))})},De=function(e){e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:Ue(e).open,stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:Ue(e).open,context:"insert",prependToContext:!0})};e.add("image",function(e){Me(e),De(e),Ee(e)})}(window);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/link/plugin.js b/wp-includes/js/tinymce/plugins/link/plugin.js new file mode 100644 index 0000000..47d61c2 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/link/plugin.js @@ -0,0 +1,713 @@ +(function () { +var link = (function (domGlobals) { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var assumeExternalTargets = function (editorSettings) { + return typeof editorSettings.link_assume_external_targets === 'boolean' ? editorSettings.link_assume_external_targets : false; + }; + var hasContextToolbar = function (editorSettings) { + return typeof editorSettings.link_context_toolbar === 'boolean' ? editorSettings.link_context_toolbar : false; + }; + var getLinkList = function (editorSettings) { + return editorSettings.link_list; + }; + var hasDefaultLinkTarget = function (editorSettings) { + return typeof editorSettings.default_link_target === 'string'; + }; + var getDefaultLinkTarget = function (editorSettings) { + return editorSettings.default_link_target; + }; + var getTargetList = function (editorSettings) { + return editorSettings.target_list; + }; + var setTargetList = function (editor, list) { + editor.settings.target_list = list; + }; + var shouldShowTargetList = function (editorSettings) { + return getTargetList(editorSettings) !== false; + }; + var getRelList = function (editorSettings) { + return editorSettings.rel_list; + }; + var hasRelList = function (editorSettings) { + return getRelList(editorSettings) !== undefined; + }; + var getLinkClassList = function (editorSettings) { + return editorSettings.link_class_list; + }; + var hasLinkClassList = function (editorSettings) { + return getLinkClassList(editorSettings) !== undefined; + }; + var shouldShowLinkTitle = function (editorSettings) { + return editorSettings.link_title !== false; + }; + var allowUnsafeLinkTarget = function (editorSettings) { + return typeof editorSettings.allow_unsafe_link_target === 'boolean' ? editorSettings.allow_unsafe_link_target : false; + }; + var Settings = { + assumeExternalTargets: assumeExternalTargets, + hasContextToolbar: hasContextToolbar, + getLinkList: getLinkList, + hasDefaultLinkTarget: hasDefaultLinkTarget, + getDefaultLinkTarget: getDefaultLinkTarget, + getTargetList: getTargetList, + setTargetList: setTargetList, + shouldShowTargetList: shouldShowTargetList, + getRelList: getRelList, + hasRelList: hasRelList, + getLinkClassList: getLinkClassList, + hasLinkClassList: hasLinkClassList, + shouldShowLinkTitle: shouldShowLinkTitle, + allowUnsafeLinkTarget: allowUnsafeLinkTarget + }; + + var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var global$3 = tinymce.util.Tools.resolve('tinymce.Env'); + + var appendClickRemove = function (link, evt) { + domGlobals.document.body.appendChild(link); + link.dispatchEvent(evt); + domGlobals.document.body.removeChild(link); + }; + var open = function (url) { + if (!global$3.ie || global$3.ie > 10) { + var link = domGlobals.document.createElement('a'); + link.target = '_blank'; + link.href = url; + link.rel = 'noreferrer noopener'; + var evt = domGlobals.document.createEvent('MouseEvents'); + evt.initMouseEvent('click', true, true, domGlobals.window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + appendClickRemove(link, evt); + } else { + var win = domGlobals.window.open('', '_blank'); + if (win) { + win.opener = null; + var doc = win.document; + doc.open(); + doc.write('<meta http-equiv="refresh" content="0; url=' + global$2.DOM.encode(url) + '">'); + doc.close(); + } + } + }; + var OpenUrl = { open: open }; + + var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var toggleTargetRules = function (rel, isUnsafe) { + var rules = ['noopener']; + var newRel = rel ? rel.split(/\s+/) : []; + var toString = function (rel) { + return global$4.trim(rel.sort().join(' ')); + }; + var addTargetRules = function (rel) { + rel = removeTargetRules(rel); + return rel.length ? rel.concat(rules) : rules; + }; + var removeTargetRules = function (rel) { + return rel.filter(function (val) { + return global$4.inArray(rules, val) === -1; + }); + }; + newRel = isUnsafe ? addTargetRules(newRel) : removeTargetRules(newRel); + return newRel.length ? toString(newRel) : null; + }; + var trimCaretContainers = function (text) { + return text.replace(/\uFEFF/g, ''); + }; + var getAnchorElement = function (editor, selectedElm) { + selectedElm = selectedElm || editor.selection.getNode(); + if (isImageFigure(selectedElm)) { + return editor.dom.select('a[href]', selectedElm)[0]; + } else { + return editor.dom.getParent(selectedElm, 'a[href]'); + } + }; + var getAnchorText = function (selection, anchorElm) { + var text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' }); + return trimCaretContainers(text); + }; + var isLink = function (elm) { + return elm && elm.nodeName === 'A' && elm.href; + }; + var hasLinks = function (elements) { + return global$4.grep(elements, isLink).length > 0; + }; + var isOnlyTextSelected = function (html) { + if (/</.test(html) && (!/^<a [^>]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') === -1)) { + return false; + } + return true; + }; + var isImageFigure = function (node) { + return node && node.nodeName === 'FIGURE' && /\bimage\b/i.test(node.className); + }; + var link = function (editor, attachState) { + return function (data) { + editor.undoManager.transact(function () { + var selectedElm = editor.selection.getNode(); + var anchorElm = getAnchorElement(editor, selectedElm); + var linkAttrs = { + href: data.href, + target: data.target ? data.target : null, + rel: data.rel ? data.rel : null, + class: data.class ? data.class : null, + title: data.title ? data.title : null + }; + if (!Settings.hasRelList(editor.settings) && Settings.allowUnsafeLinkTarget(editor.settings) === false) { + linkAttrs.rel = toggleTargetRules(linkAttrs.rel, linkAttrs.target === '_blank'); + } + if (data.href === attachState.href) { + attachState.attach(); + attachState = {}; + } + if (anchorElm) { + editor.focus(); + if (data.hasOwnProperty('text')) { + if ('innerText' in anchorElm) { + anchorElm.innerText = data.text; + } else { + anchorElm.textContent = data.text; + } + } + editor.dom.setAttribs(anchorElm, linkAttrs); + editor.selection.select(anchorElm); + editor.undoManager.add(); + } else { + if (isImageFigure(selectedElm)) { + linkImageFigure(editor, selectedElm, linkAttrs); + } else if (data.hasOwnProperty('text')) { + editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(data.text))); + } else { + editor.execCommand('mceInsertLink', false, linkAttrs); + } + } + }); + }; + }; + var unlink = function (editor) { + return function () { + editor.undoManager.transact(function () { + var node = editor.selection.getNode(); + if (isImageFigure(node)) { + unlinkImageFigure(editor, node); + } else { + editor.execCommand('unlink'); + } + }); + }; + }; + var unlinkImageFigure = function (editor, fig) { + var a, img; + img = editor.dom.select('img', fig)[0]; + if (img) { + a = editor.dom.getParents(img, 'a[href]', fig)[0]; + if (a) { + a.parentNode.insertBefore(img, a); + editor.dom.remove(a); + } + } + }; + var linkImageFigure = function (editor, fig, attrs) { + var a, img; + img = editor.dom.select('img', fig)[0]; + if (img) { + a = editor.dom.create('a', attrs); + img.parentNode.insertBefore(a, img); + a.appendChild(img); + } + }; + var Utils = { + link: link, + unlink: unlink, + isLink: isLink, + hasLinks: hasLinks, + isOnlyTextSelected: isOnlyTextSelected, + getAnchorElement: getAnchorElement, + getAnchorText: getAnchorText, + toggleTargetRules: toggleTargetRules + }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.util.Delay'); + + var global$6 = tinymce.util.Tools.resolve('tinymce.util.XHR'); + + var attachState = {}; + var createLinkList = function (editor, callback) { + var linkList = Settings.getLinkList(editor.settings); + if (typeof linkList === 'string') { + global$6.send({ + url: linkList, + success: function (text) { + callback(editor, JSON.parse(text)); + } + }); + } else if (typeof linkList === 'function') { + linkList(function (list) { + callback(editor, list); + }); + } else { + callback(editor, linkList); + } + }; + var buildListItems = function (inputList, itemCallback, startItems) { + var appendItems = function (values, output) { + output = output || []; + global$4.each(values, function (item) { + var menuItem = { text: item.text || item.title }; + if (item.menu) { + menuItem.menu = appendItems(item.menu); + } else { + menuItem.value = item.value; + if (itemCallback) { + itemCallback(menuItem); + } + } + output.push(menuItem); + }); + return output; + }; + return appendItems(inputList, startItems || []); + }; + var delayedConfirm = function (editor, message, callback) { + var rng = editor.selection.getRng(); + global$5.setEditorTimeout(editor, function () { + editor.windowManager.confirm(message, function (state) { + editor.selection.setRng(rng); + callback(state); + }); + }); + }; + var showDialog = function (editor, linkList) { + var data = {}; + var selection = editor.selection; + var dom = editor.dom; + var anchorElm, initialText; + var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value; + var linkListChangeHandler = function (e) { + var textCtrl = win.find('#text'); + if (!textCtrl.value() || e.lastControl && textCtrl.value() === e.lastControl.text()) { + textCtrl.value(e.control.text()); + } + win.find('#href').value(e.control.value()); + }; + var buildAnchorListControl = function (url) { + var anchorList = []; + global$4.each(editor.dom.select('a:not([href])'), function (anchor) { + var id = anchor.name || anchor.id; + if (id) { + anchorList.push({ + text: id, + value: '#' + id, + selected: url.indexOf('#' + id) !== -1 + }); + } + }); + if (anchorList.length) { + anchorList.unshift({ + text: 'None', + value: '' + }); + return { + name: 'anchor', + type: 'listbox', + label: 'Anchors', + values: anchorList, + onselect: linkListChangeHandler + }; + } + }; + var updateText = function () { + if (!initialText && onlyText && !data.text) { + this.parent().parent().find('#text')[0].value(this.value()); + } + }; + var urlChange = function (e) { + var meta = e.meta || {}; + if (linkListCtrl) { + linkListCtrl.value(editor.convertURL(this.value(), 'href')); + } + global$4.each(e.meta, function (value, key) { + var inp = win.find('#' + key); + if (key === 'text') { + if (initialText.length === 0) { + inp.value(value); + data.text = value; + } + } else { + inp.value(value); + } + }); + if (meta.attach) { + attachState = { + href: this.value(), + attach: meta.attach + }; + } + if (!meta.text) { + updateText.call(this); + } + }; + var onBeforeCall = function (e) { + e.meta = win.toJSON(); + }; + onlyText = Utils.isOnlyTextSelected(selection.getContent()); + anchorElm = Utils.getAnchorElement(editor); + data.text = initialText = Utils.getAnchorText(editor.selection, anchorElm); + data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : ''; + if (anchorElm) { + data.target = dom.getAttrib(anchorElm, 'target'); + } else if (Settings.hasDefaultLinkTarget(editor.settings)) { + data.target = Settings.getDefaultLinkTarget(editor.settings); + } + if (value = dom.getAttrib(anchorElm, 'rel')) { + data.rel = value; + } + if (value = dom.getAttrib(anchorElm, 'class')) { + data.class = value; + } + if (value = dom.getAttrib(anchorElm, 'title')) { + data.title = value; + } + if (onlyText) { + textListCtrl = { + name: 'text', + type: 'textbox', + size: 40, + label: 'Text to display', + onchange: function () { + data.text = this.value(); + } + }; + } + if (linkList) { + linkListCtrl = { + type: 'listbox', + label: 'Link list', + values: buildListItems(linkList, function (item) { + item.value = editor.convertURL(item.value || item.url, 'href'); + }, [{ + text: 'None', + value: '' + }]), + onselect: linkListChangeHandler, + value: editor.convertURL(data.href, 'href'), + onPostRender: function () { + linkListCtrl = this; + } + }; + } + if (Settings.shouldShowTargetList(editor.settings)) { + if (Settings.getTargetList(editor.settings) === undefined) { + Settings.setTargetList(editor, [ + { + text: 'None', + value: '' + }, + { + text: 'New window', + value: '_blank' + } + ]); + } + targetListCtrl = { + name: 'target', + type: 'listbox', + label: 'Target', + values: buildListItems(Settings.getTargetList(editor.settings)) + }; + } + if (Settings.hasRelList(editor.settings)) { + relListCtrl = { + name: 'rel', + type: 'listbox', + label: 'Rel', + values: buildListItems(Settings.getRelList(editor.settings), function (item) { + if (Settings.allowUnsafeLinkTarget(editor.settings) === false) { + item.value = Utils.toggleTargetRules(item.value, data.target === '_blank'); + } + }) + }; + } + if (Settings.hasLinkClassList(editor.settings)) { + classListCtrl = { + name: 'class', + type: 'listbox', + label: 'Class', + values: buildListItems(Settings.getLinkClassList(editor.settings), function (item) { + if (item.value) { + item.textStyle = function () { + return editor.formatter.getCssText({ + inline: 'a', + classes: [item.value] + }); + }; + } + }) + }; + } + if (Settings.shouldShowLinkTitle(editor.settings)) { + linkTitleCtrl = { + name: 'title', + type: 'textbox', + label: 'Title', + value: data.title + }; + } + win = editor.windowManager.open({ + title: 'Insert link', + data: data, + body: [ + { + name: 'href', + type: 'filepicker', + filetype: 'file', + size: 40, + autofocus: true, + label: 'Url', + onchange: urlChange, + onkeyup: updateText, + onpaste: updateText, + onbeforecall: onBeforeCall + }, + textListCtrl, + linkTitleCtrl, + buildAnchorListControl(data.href), + linkListCtrl, + relListCtrl, + targetListCtrl, + classListCtrl + ], + onSubmit: function (e) { + var assumeExternalTargets = Settings.assumeExternalTargets(editor.settings); + var insertLink = Utils.link(editor, attachState); + var removeLink = Utils.unlink(editor); + var resultData = global$4.extend({}, data, e.data); + var href = resultData.href; + if (!href) { + removeLink(); + return; + } + if (!onlyText || resultData.text === initialText) { + delete resultData.text; + } + if (href.indexOf('@') > 0 && href.indexOf('//') === -1 && href.indexOf('mailto:') === -1) { + delayedConfirm(editor, 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?', function (state) { + if (state) { + resultData.href = 'mailto:' + href; + } + insertLink(resultData); + }); + return; + } + if (assumeExternalTargets === true && !/^\w+:/i.test(href) || assumeExternalTargets === false && /^\s*www[\.|\d\.]/i.test(href)) { + delayedConfirm(editor, 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?', function (state) { + if (state) { + resultData.href = 'http://' + href; + } + insertLink(resultData); + }); + return; + } + insertLink(resultData); + } + }); + }; + var open$1 = function (editor) { + createLinkList(editor, showDialog); + }; + var Dialog = { open: open$1 }; + + var getLink = function (editor, elm) { + return editor.dom.getParent(elm, 'a[href]'); + }; + var getSelectedLink = function (editor) { + return getLink(editor, editor.selection.getStart()); + }; + var getHref = function (elm) { + var href = elm.getAttribute('data-mce-href'); + return href ? href : elm.getAttribute('href'); + }; + var isContextMenuVisible = function (editor) { + var contextmenu = editor.plugins.contextmenu; + return contextmenu ? contextmenu.isContextMenuVisible() : false; + }; + var hasOnlyAltModifier = function (e) { + return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false; + }; + var gotoLink = function (editor, a) { + if (a) { + var href = getHref(a); + if (/^#/.test(href)) { + var targetEl = editor.$(href); + if (targetEl.length) { + editor.selection.scrollIntoView(targetEl[0], true); + } + } else { + OpenUrl.open(a.href); + } + } + }; + var openDialog = function (editor) { + return function () { + Dialog.open(editor); + }; + }; + var gotoSelectedLink = function (editor) { + return function () { + gotoLink(editor, getSelectedLink(editor)); + }; + }; + var leftClickedOnAHref = function (editor) { + return function (elm) { + var sel, rng, node; + if (Settings.hasContextToolbar(editor.settings) && !isContextMenuVisible(editor) && Utils.isLink(elm)) { + sel = editor.selection; + rng = sel.getRng(); + node = rng.startContainer; + if (node.nodeType === 3 && sel.isCollapsed() && rng.startOffset > 0 && rng.startOffset < node.data.length) { + return true; + } + } + return false; + }; + }; + var setupGotoLinks = function (editor) { + editor.on('click', function (e) { + var link = getLink(editor, e.target); + if (link && global$1.metaKeyPressed(e)) { + e.preventDefault(); + gotoLink(editor, link); + } + }); + editor.on('keydown', function (e) { + var link = getSelectedLink(editor); + if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) { + e.preventDefault(); + gotoLink(editor, link); + } + }); + }; + var toggleActiveState = function (editor) { + return function () { + var self = this; + editor.on('nodechange', function (e) { + self.active(!editor.readonly && !!Utils.getAnchorElement(editor, e.element)); + }); + }; + }; + var toggleViewLinkState = function (editor) { + return function () { + var self = this; + var toggleVisibility = function (e) { + if (Utils.hasLinks(e.parents)) { + self.show(); + } else { + self.hide(); + } + }; + if (!Utils.hasLinks(editor.dom.getParents(editor.selection.getStart()))) { + self.hide(); + } + editor.on('nodechange', toggleVisibility); + self.on('remove', function () { + editor.off('nodechange', toggleVisibility); + }); + }; + }; + var Actions = { + openDialog: openDialog, + gotoSelectedLink: gotoSelectedLink, + leftClickedOnAHref: leftClickedOnAHref, + setupGotoLinks: setupGotoLinks, + toggleActiveState: toggleActiveState, + toggleViewLinkState: toggleViewLinkState + }; + + var register = function (editor) { + editor.addCommand('mceLink', Actions.openDialog(editor)); + }; + var Commands = { register: register }; + + var setup = function (editor) { + editor.addShortcut('Meta+K', '', Actions.openDialog(editor)); + }; + var Keyboard = { setup: setup }; + + var setupButtons = function (editor) { + editor.addButton('link', { + active: false, + icon: 'link', + tooltip: 'Insert/edit link', + onclick: Actions.openDialog(editor), + onpostrender: Actions.toggleActiveState(editor) + }); + editor.addButton('unlink', { + active: false, + icon: 'unlink', + tooltip: 'Remove link', + onclick: Utils.unlink(editor), + onpostrender: Actions.toggleActiveState(editor) + }); + if (editor.addContextToolbar) { + editor.addButton('openlink', { + icon: 'newtab', + tooltip: 'Open link', + onclick: Actions.gotoSelectedLink(editor) + }); + } + }; + var setupMenuItems = function (editor) { + editor.addMenuItem('openlink', { + text: 'Open link', + icon: 'newtab', + onclick: Actions.gotoSelectedLink(editor), + onPostRender: Actions.toggleViewLinkState(editor), + prependToContext: true + }); + editor.addMenuItem('link', { + icon: 'link', + text: 'Link', + shortcut: 'Meta+K', + onclick: Actions.openDialog(editor), + stateSelector: 'a[href]', + context: 'insert', + prependToContext: true + }); + editor.addMenuItem('unlink', { + icon: 'unlink', + text: 'Remove link', + onclick: Utils.unlink(editor), + stateSelector: 'a[href]' + }); + }; + var setupContextToolbars = function (editor) { + if (editor.addContextToolbar) { + editor.addContextToolbar(Actions.leftClickedOnAHref(editor), 'openlink | link unlink'); + } + }; + var Controls = { + setupButtons: setupButtons, + setupMenuItems: setupMenuItems, + setupContextToolbars: setupContextToolbars + }; + + global.add('link', function (editor) { + Controls.setupButtons(editor); + Controls.setupMenuItems(editor); + Controls.setupContextToolbars(editor); + Actions.setupGotoLinks(editor); + Commands.register(editor); + Keyboard.setup(editor); + }); + function Plugin () { + } + + return Plugin; + +}(window)); +})(); diff --git a/wp-includes/js/tinymce/plugins/link/plugin.min.js b/wp-includes/js/tinymce/plugins/link/plugin.min.js new file mode 100644 index 0000000..e07a912 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/link/plugin.min.js @@ -0,0 +1 @@ +!function(l){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.util.VK"),e=function(t){return t.target_list},o=function(t){return t.rel_list},i=function(t){return t.link_class_list},p=function(t){return"boolean"==typeof t.link_assume_external_targets&&t.link_assume_external_targets},a=function(t){return"boolean"==typeof t.link_context_toolbar&&t.link_context_toolbar},r=function(t){return t.link_list},k=function(t){return"string"==typeof t.default_link_target},y=function(t){return t.default_link_target},b=e,_=function(t,e){t.settings.target_list=e},w=function(t){return!1!==e(t)},T=o,C=function(t){return o(t)!==undefined},M=i,O=function(t){return i(t)!==undefined},R=function(t){return!1!==t.link_title},N=function(t){return"boolean"==typeof t.allow_unsafe_link_target&&t.allow_unsafe_link_target},u=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),c=tinymce.util.Tools.resolve("tinymce.Env"),s=function(t){if(!c.ie||10<c.ie){var e=l.document.createElement("a");e.target="_blank",e.href=t,e.rel="noreferrer noopener";var n=l.document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,l.window,0,0,0,0,0,!1,!1,!1,!1,0,null),r=e,a=n,l.document.body.appendChild(r),r.dispatchEvent(a),l.document.body.removeChild(r)}else{var o=l.window.open("","_blank");if(o){o.opener=null;var i=o.document;i.open(),i.write('<meta http-equiv="refresh" content="0; url='+u.DOM.encode(t)+'">'),i.close()}}var r,a},A=tinymce.util.Tools.resolve("tinymce.util.Tools"),f=function(t,e){var n,o,i=["noopener"],r=t?t.split(/\s+/):[],a=function(t){return t.filter(function(t){return-1===A.inArray(i,t)})};return(r=e?(n=a(n=r)).length?n.concat(i):i:a(r)).length?(o=r,A.trim(o.sort().join(" "))):null},d=function(t,e){return e=e||t.selection.getNode(),v(e)?t.dom.select("a[href]",e)[0]:t.dom.getParent(e,"a[href]")},m=function(t){return t&&"A"===t.nodeName&&t.href},v=function(t){return t&&"FIGURE"===t.nodeName&&/\bimage\b/i.test(t.className)},g=function(t,e){var n,o;(o=t.dom.select("img",e)[0])&&(n=t.dom.getParents(o,"a[href]",e)[0])&&(n.parentNode.insertBefore(o,n),t.dom.remove(n))},h=function(t,e,n){var o,i;(i=t.dom.select("img",e)[0])&&(o=t.dom.create("a",n),i.parentNode.insertBefore(o,i),o.appendChild(i))},L=function(i,r){return function(o){i.undoManager.transact(function(){var t=i.selection.getNode(),e=d(i,t),n={href:o.href,target:o.target?o.target:null,rel:o.rel?o.rel:null,"class":o["class"]?o["class"]:null,title:o.title?o.title:null};C(i.settings)||!1!==N(i.settings)||(n.rel=f(n.rel,"_blank"===n.target)),o.href===r.href&&(r.attach(),r={}),e?(i.focus(),o.hasOwnProperty("text")&&("innerText"in e?e.innerText=o.text:e.textContent=o.text),i.dom.setAttribs(e,n),i.selection.select(e),i.undoManager.add()):v(t)?h(i,t,n):o.hasOwnProperty("text")?i.insertContent(i.dom.createHTML("a",n,i.dom.encode(o.text))):i.execCommand("mceInsertLink",!1,n)})}},P=function(e){return function(){e.undoManager.transact(function(){var t=e.selection.getNode();v(t)?g(e,t):e.execCommand("unlink")})}},x=m,E=function(t){return 0<A.grep(t,m).length},S=function(t){return!(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1===t.indexOf("href=")))},I=d,K=function(t,e){var n=e?e.innerText||e.textContent:t.getContent({format:"text"});return n.replace(/\uFEFF/g,"")},U=f,D=tinymce.util.Tools.resolve("tinymce.util.Delay"),B=tinymce.util.Tools.resolve("tinymce.util.XHR"),F={},q=function(t,o,e){var i=function(t,n){return n=n||[],A.each(t,function(t){var e={text:t.text||t.title};t.menu?e.menu=i(t.menu):(e.value=t.value,o&&o(e)),n.push(e)}),n};return i(t,e||[])},V=function(e,t,n){var o=e.selection.getRng();D.setEditorTimeout(e,function(){e.windowManager.confirm(t,function(t){e.selection.setRng(o),n(t)})})},z=function(a,t){var e,l,o,u,n,i,r,c,s,f,d,m={},v=a.selection,g=a.dom,h=function(t){var e=o.find("#text");(!e.value()||t.lastControl&&e.value()===t.lastControl.text())&&e.value(t.control.text()),o.find("#href").value(t.control.value())},x=function(){l||!u||m.text||this.parent().parent().find("#text")[0].value(this.value())};u=S(v.getContent()),e=I(a),m.text=l=K(a.selection,e),m.href=e?g.getAttrib(e,"href"):"",e?m.target=g.getAttrib(e,"target"):k(a.settings)&&(m.target=y(a.settings)),(d=g.getAttrib(e,"rel"))&&(m.rel=d),(d=g.getAttrib(e,"class"))&&(m["class"]=d),(d=g.getAttrib(e,"title"))&&(m.title=d),u&&(n={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){m.text=this.value()}}),t&&(i={type:"listbox",label:"Link list",values:q(t,function(t){t.value=a.convertURL(t.value||t.url,"href")},[{text:"None",value:""}]),onselect:h,value:a.convertURL(m.href,"href"),onPostRender:function(){i=this}}),w(a.settings)&&(b(a.settings)===undefined&&_(a,[{text:"None",value:""},{text:"New window",value:"_blank"}]),c={name:"target",type:"listbox",label:"Target",values:q(b(a.settings))}),C(a.settings)&&(r={name:"rel",type:"listbox",label:"Rel",values:q(T(a.settings),function(t){!1===N(a.settings)&&(t.value=U(t.value,"_blank"===m.target))})}),O(a.settings)&&(s={name:"class",type:"listbox",label:"Class",values:q(M(a.settings),function(t){t.value&&(t.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[t.value]})})})}),R(a.settings)&&(f={name:"title",type:"textbox",label:"Title",value:m.title}),o=a.windowManager.open({title:"Insert link",data:m,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:function(t){var e=t.meta||{};i&&i.value(a.convertURL(this.value(),"href")),A.each(t.meta,function(t,e){var n=o.find("#"+e);"text"===e?0===l.length&&(n.value(t),m.text=t):n.value(t)}),e.attach&&(F={href:this.value(),attach:e.attach}),e.text||x.call(this)},onkeyup:x,onpaste:x,onbeforecall:function(t){t.meta=o.toJSON()}},n,f,function(n){var o=[];if(A.each(a.dom.select("a:not([href])"),function(t){var e=t.name||t.id;e&&o.push({text:e,value:"#"+e,selected:-1!==n.indexOf("#"+e)})}),o.length)return o.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:o,onselect:h}}(m.href),i,r,c,s],onSubmit:function(t){var e=p(a.settings),n=L(a,F),o=P(a),i=A.extend({},m,t.data),r=i.href;r?(u&&i.text!==l||delete i.text,0<r.indexOf("@")&&-1===r.indexOf("//")&&-1===r.indexOf("mailto:")?V(a,"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(t){t&&(i.href="mailto:"+r),n(i)}):!0===e&&!/^\w+:/i.test(r)||!1===e&&/^\s*www[\.|\d\.]/i.test(r)?V(a,"The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){t&&(i.href="http://"+r),n(i)}):n(i)):o()}})},H=function(t){var e,n,o;n=z,"string"==typeof(o=r((e=t).settings))?B.send({url:o,success:function(t){n(e,JSON.parse(t))}}):"function"==typeof o?o(function(t){n(e,t)}):n(e,o)},J=function(t,e){return t.dom.getParent(e,"a[href]")},$=function(t){return J(t,t.selection.getStart())},j=function(t,e){if(e){var n=(i=e).getAttribute("data-mce-href")||i.getAttribute("href");if(/^#/.test(n)){var o=t.$(n);o.length&&t.selection.scrollIntoView(o[0],!0)}else s(e.href)}var i},G=function(t){return function(){H(t)}},X=function(t){return function(){j(t,$(t))}},Q=function(r){return function(t){var e,n,o,i;return!!(a(r.settings)&&(!(i=r.plugins.contextmenu)||!i.isContextMenuVisible())&&x(t)&&3===(o=(n=(e=r.selection).getRng()).startContainer).nodeType&&e.isCollapsed()&&0<n.startOffset&&n.startOffset<o.data.length)}},W=function(o){o.on("click",function(t){var e=J(o,t.target);e&&n.metaKeyPressed(t)&&(t.preventDefault(),j(o,e))}),o.on("keydown",function(t){var e,n=$(o);n&&13===t.keyCode&&!0===(e=t).altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey&&(t.preventDefault(),j(o,n))})},Y=function(n){return function(){var e=this;n.on("nodechange",function(t){e.active(!n.readonly&&!!I(n,t.element))})}},Z=function(n){return function(){var e=this,t=function(t){E(t.parents)?e.show():e.hide()};E(n.dom.getParents(n.selection.getStart()))||e.hide(),n.on("nodechange",t),e.on("remove",function(){n.off("nodechange",t)})}},tt=function(t){t.addCommand("mceLink",G(t))},et=function(t){t.addShortcut("Meta+K","",G(t))},nt=function(t){t.addButton("link",{active:!1,icon:"link",tooltip:"Insert/edit link",onclick:G(t),onpostrender:Y(t)}),t.addButton("unlink",{active:!1,icon:"unlink",tooltip:"Remove link",onclick:P(t),onpostrender:Y(t)}),t.addContextToolbar&&t.addButton("openlink",{icon:"newtab",tooltip:"Open link",onclick:X(t)})},ot=function(t){t.addMenuItem("openlink",{text:"Open link",icon:"newtab",onclick:X(t),onPostRender:Z(t),prependToContext:!0}),t.addMenuItem("link",{icon:"link",text:"Link",shortcut:"Meta+K",onclick:G(t),stateSelector:"a[href]",context:"insert",prependToContext:!0}),t.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onclick:P(t),stateSelector:"a[href]"})},it=function(t){t.addContextToolbar&&t.addContextToolbar(Q(t),"openlink | link unlink")};t.add("link",function(t){nt(t),ot(t),it(t),W(t),tt(t),et(t)})}(window);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/lists/plugin.js b/wp-includes/js/tinymce/plugins/lists/plugin.js new file mode 100644 index 0000000..ed26968 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/lists/plugin.js @@ -0,0 +1,2148 @@ +(function () { +var lists = (function (domGlobals) { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); + + var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var global$4 = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager'); + + var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var global$6 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var isTextNode = function (node) { + return node && node.nodeType === 3; + }; + var isListNode = function (node) { + return node && /^(OL|UL|DL)$/.test(node.nodeName); + }; + var isOlUlNode = function (node) { + return node && /^(OL|UL)$/.test(node.nodeName); + }; + var isListItemNode = function (node) { + return node && /^(LI|DT|DD)$/.test(node.nodeName); + }; + var isDlItemNode = function (node) { + return node && /^(DT|DD)$/.test(node.nodeName); + }; + var isTableCellNode = function (node) { + return node && /^(TH|TD)$/.test(node.nodeName); + }; + var isBr = function (node) { + return node && node.nodeName === 'BR'; + }; + var isFirstChild = function (node) { + return node.parentNode.firstChild === node; + }; + var isLastChild = function (node) { + return node.parentNode.lastChild === node; + }; + var isTextBlock = function (editor, node) { + return node && !!editor.schema.getTextBlockElements()[node.nodeName]; + }; + var isBlock = function (node, blockElements) { + return node && node.nodeName in blockElements; + }; + var isBogusBr = function (dom, node) { + if (!isBr(node)) { + return false; + } + if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) { + return true; + } + return false; + }; + var isEmpty = function (dom, elm, keepBookmarks) { + var empty = dom.isEmpty(elm); + if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) { + return false; + } + return empty; + }; + var isChildOfBody = function (dom, elm) { + return dom.isChildOf(elm, dom.getRoot()); + }; + var NodeType = { + isTextNode: isTextNode, + isListNode: isListNode, + isOlUlNode: isOlUlNode, + isDlItemNode: isDlItemNode, + isListItemNode: isListItemNode, + isTableCellNode: isTableCellNode, + isBr: isBr, + isFirstChild: isFirstChild, + isLastChild: isLastChild, + isTextBlock: isTextBlock, + isBlock: isBlock, + isBogusBr: isBogusBr, + isEmpty: isEmpty, + isChildOfBody: isChildOfBody + }; + + var getNormalizedPoint = function (container, offset) { + if (NodeType.isTextNode(container)) { + return { + container: container, + offset: offset + }; + } + var node = global$1.getNode(container, offset); + if (NodeType.isTextNode(node)) { + return { + container: node, + offset: offset >= container.childNodes.length ? node.data.length : 0 + }; + } else if (node.previousSibling && NodeType.isTextNode(node.previousSibling)) { + return { + container: node.previousSibling, + offset: node.previousSibling.data.length + }; + } else if (node.nextSibling && NodeType.isTextNode(node.nextSibling)) { + return { + container: node.nextSibling, + offset: 0 + }; + } + return { + container: container, + offset: offset + }; + }; + var normalizeRange = function (rng) { + var outRng = rng.cloneRange(); + var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset); + outRng.setStart(rangeStart.container, rangeStart.offset); + var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset); + outRng.setEnd(rangeEnd.container, rangeEnd.offset); + return outRng; + }; + var Range = { + getNormalizedPoint: getNormalizedPoint, + normalizeRange: normalizeRange + }; + + var DOM = global$6.DOM; + var createBookmark = function (rng) { + var bookmark = {}; + var setupEndPoint = function (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; + }; + var resolveBookmark = function (bookmark) { + function restoreEndPoint(start) { + var container, offset, node; + var nodeIndex = function (container) { + var node = container.parentNode.firstChild, idx = 0; + while (node) { + if (node === container) { + return idx; + } + 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); + if (!container.hasChildNodes() && DOM.isBlock(container)) { + container.appendChild(DOM.create('br')); + } + } + 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); + } + return Range.normalizeRange(rng); + }; + var Bookmark = { + createBookmark: createBookmark, + resolveBookmark: resolveBookmark + }; + + var noop = function () { + }; + var constant = function (value) { + return function () { + return value; + }; + }; + var not = function (f) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !f.apply(null, args); + }; + }; + var never = constant(false); + var always = constant(true); + + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never, + isSome: never, + isNone: always, + getOr: id, + getOrThunk: call, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: constant(null), + getOrUndefined: constant(undefined), + or: id, + orThunk: call, + map: none, + each: noop, + bind: none, + exists: never, + forall: always, + filter: none, + equals: eq, + equals_: eq, + toArray: function () { + return []; + }, + toString: constant('none()') + }; + if (Object.freeze) { + Object.freeze(me); + } + return me; + }(); + var some = function (a) { + var constant_a = constant(a); + var self = function () { + return me; + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always, + isNone: never, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: function (f) { + return some(f(a)); + }, + each: function (f) { + f(a); + }, + bind: bind, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never, function (b) { + return elementEq(a, b); + }); + } + }; + return me; + }; + var from = function (value) { + return value === null || value === undefined ? NONE : some(value); + }; + var Option = { + some: some, + none: none, + from: from + }; + + var typeOf = function (x) { + if (x === null) { + return 'null'; + } + var t = typeof x; + if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { + return 'array'; + } + if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { + return 'string'; + } + return t; + }; + var isType = function (type) { + return function (value) { + return typeOf(value) === type; + }; + }; + var isString = isType('string'); + var isArray = isType('array'); + var isBoolean = isType('boolean'); + var isFunction = isType('function'); + var isNumber = isType('number'); + + var nativeSlice = Array.prototype.slice; + var nativePush = Array.prototype.push; + var map = function (xs, f) { + var len = xs.length; + var r = new Array(len); + for (var i = 0; i < len; i++) { + var x = xs[i]; + r[i] = f(x, i); + } + return r; + }; + var each = function (xs, f) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + f(x, i); + } + }; + var filter = function (xs, pred) { + var r = []; + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + if (pred(x, i)) { + r.push(x); + } + } + return r; + }; + var groupBy = function (xs, f) { + if (xs.length === 0) { + return []; + } else { + var wasType = f(xs[0]); + var r = []; + var group = []; + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + var type = f(x); + if (type !== wasType) { + r.push(group); + group = []; + } + wasType = type; + group.push(x); + } + if (group.length !== 0) { + r.push(group); + } + return r; + } + }; + var foldl = function (xs, f, acc) { + each(xs, function (x) { + acc = f(acc, x); + }); + return acc; + }; + var find = function (xs, pred) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + if (pred(x, i)) { + return Option.some(x); + } + } + return Option.none(); + }; + var flatten = function (xs) { + var r = []; + for (var i = 0, len = xs.length; i < len; ++i) { + if (!isArray(xs[i])) { + throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); + } + nativePush.apply(r, xs[i]); + } + return r; + }; + var bind = function (xs, f) { + var output = map(xs, f); + return flatten(output); + }; + var reverse = function (xs) { + var r = nativeSlice.call(xs, 0); + r.reverse(); + return r; + }; + var head = function (xs) { + return xs.length === 0 ? Option.none() : Option.some(xs[0]); + }; + var last = function (xs) { + return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]); + }; + var from$1 = isFunction(Array.from) ? Array.from : function (x) { + return nativeSlice.call(x); + }; + + var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')(); + + var path = function (parts, scope) { + var o = scope !== undefined && scope !== null ? scope : Global; + for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) { + o = o[parts[i]]; + } + return o; + }; + var resolve = function (p, scope) { + var parts = p.split('.'); + return path(parts, scope); + }; + + var unsafe = function (name, scope) { + return resolve(name, scope); + }; + var getOrDie = function (name, scope) { + var actual = unsafe(name, scope); + if (actual === undefined || actual === null) { + throw new Error(name + ' not available on this browser'); + } + return actual; + }; + var Global$1 = { getOrDie: getOrDie }; + + var htmlElement = function (scope) { + return Global$1.getOrDie('HTMLElement', scope); + }; + var isPrototypeOf = function (x) { + var scope = resolve('ownerDocument.defaultView', x); + return htmlElement(scope).prototype.isPrototypeOf(x); + }; + var HTMLElement = { isPrototypeOf: isPrototypeOf }; + + var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery'); + + var getParentList = function (editor) { + var selectionStart = editor.selection.getStart(true); + return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart)); + }; + var isParentListSelected = function (parentList, selectedBlocks) { + return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList; + }; + var findSubLists = function (parentList) { + return global$5.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm) { + return NodeType.isListNode(elm); + }); + }; + var getSelectedSubLists = function (editor) { + var parentList = getParentList(editor); + var selectedBlocks = editor.selection.getSelectedBlocks(); + if (isParentListSelected(parentList, selectedBlocks)) { + return findSubLists(parentList); + } else { + return global$5.grep(selectedBlocks, function (elm) { + return NodeType.isListNode(elm) && parentList !== elm; + }); + } + }; + var findParentListItemsNodes = function (editor, elms) { + var listItemsElms = global$5.map(elms, function (elm) { + var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm)); + return parentLi ? parentLi : elm; + }); + return global$7.unique(listItemsElms); + }; + var getSelectedListItems = function (editor) { + var selectedBlocks = editor.selection.getSelectedBlocks(); + return global$5.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) { + return NodeType.isListItemNode(block); + }); + }; + var getSelectedDlItems = function (editor) { + return filter(getSelectedListItems(editor), NodeType.isDlItemNode); + }; + var getClosestListRootElm = function (editor, elm) { + var parentTableCell = editor.dom.getParents(elm, 'TD,TH'); + var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody(); + return root; + }; + var findLastParentListNode = function (editor, elm) { + var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm)); + return last(parentLists); + }; + var getSelectedLists = function (editor) { + var firstList = findLastParentListNode(editor, editor.selection.getStart()); + var subsequentLists = filter(editor.selection.getSelectedBlocks(), NodeType.isOlUlNode); + return firstList.toArray().concat(subsequentLists); + }; + var getSelectedListRoots = function (editor) { + var selectedLists = getSelectedLists(editor); + return getUniqueListRoots(editor, selectedLists); + }; + var getUniqueListRoots = function (editor, lists) { + var listRoots = map(lists, function (list) { + return findLastParentListNode(editor, list).getOr(list); + }); + return global$7.unique(listRoots); + }; + var isList = function (editor) { + var list = getParentList(editor); + return HTMLElement.isPrototypeOf(list); + }; + var Selection = { + isList: isList, + getParentList: getParentList, + getSelectedSubLists: getSelectedSubLists, + getSelectedListItems: getSelectedListItems, + getClosestListRootElm: getClosestListRootElm, + getSelectedDlItems: getSelectedDlItems, + getSelectedListRoots: getSelectedListRoots + }; + + var fromHtml = function (html, scope) { + var doc = scope || domGlobals.document; + var div = doc.createElement('div'); + div.innerHTML = html; + if (!div.hasChildNodes() || div.childNodes.length > 1) { + domGlobals.console.error('HTML does not have a single root node', html); + throw new Error('HTML must have a single root node'); + } + return fromDom(div.childNodes[0]); + }; + var fromTag = function (tag, scope) { + var doc = scope || domGlobals.document; + var node = doc.createElement(tag); + return fromDom(node); + }; + var fromText = function (text, scope) { + var doc = scope || domGlobals.document; + var node = doc.createTextNode(text); + return fromDom(node); + }; + var fromDom = function (node) { + if (node === null || node === undefined) { + throw new Error('Node cannot be null or undefined'); + } + return { dom: constant(node) }; + }; + var fromPoint = function (docElm, x, y) { + var doc = docElm.dom(); + return Option.from(doc.elementFromPoint(x, y)).map(fromDom); + }; + var Element = { + fromHtml: fromHtml, + fromTag: fromTag, + fromText: fromText, + fromDom: fromDom, + fromPoint: fromPoint + }; + + var lift2 = function (oa, ob, f) { + return oa.isSome() && ob.isSome() ? Option.some(f(oa.getOrDie(), ob.getOrDie())) : Option.none(); + }; + + var fromElements = function (elements, scope) { + var doc = scope || domGlobals.document; + var fragment = doc.createDocumentFragment(); + each(elements, function (element) { + fragment.appendChild(element.dom()); + }); + return Element.fromDom(fragment); + }; + + var Immutable = function () { + var fields = []; + for (var _i = 0; _i < arguments.length; _i++) { + fields[_i] = arguments[_i]; + } + return function () { + var values = []; + for (var _i = 0; _i < arguments.length; _i++) { + values[_i] = arguments[_i]; + } + if (fields.length !== values.length) { + throw new Error('Wrong number of arguments to struct. Expected "[' + fields.length + ']", got ' + values.length + ' arguments'); + } + var struct = {}; + each(fields, function (name, i) { + struct[name] = constant(values[i]); + }); + return struct; + }; + }; + + var keys = Object.keys; + var each$1 = function (obj, f) { + var props = keys(obj); + for (var k = 0, len = props.length; k < len; k++) { + var i = props[k]; + var x = obj[i]; + f(x, i); + } + }; + + var node = function () { + var f = Global$1.getOrDie('Node'); + return f; + }; + var compareDocumentPosition = function (a, b, match) { + return (a.compareDocumentPosition(b) & match) !== 0; + }; + var documentPositionPreceding = function (a, b) { + return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_PRECEDING); + }; + var documentPositionContainedBy = function (a, b) { + return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY); + }; + var Node = { + documentPositionPreceding: documentPositionPreceding, + documentPositionContainedBy: documentPositionContainedBy + }; + + var cached = function (f) { + var called = false; + var r; + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!called) { + called = true; + r = f.apply(null, args); + } + return r; + }; + }; + + var firstMatch = function (regexes, s) { + for (var i = 0; i < regexes.length; i++) { + var x = regexes[i]; + if (x.test(s)) { + return x; + } + } + return undefined; + }; + var find$1 = function (regexes, agent) { + var r = firstMatch(regexes, agent); + if (!r) { + return { + major: 0, + minor: 0 + }; + } + var group = function (i) { + return Number(agent.replace(r, '$' + i)); + }; + return nu(group(1), group(2)); + }; + var detect = function (versionRegexes, agent) { + var cleanedAgent = String(agent).toLowerCase(); + if (versionRegexes.length === 0) { + return unknown(); + } + return find$1(versionRegexes, cleanedAgent); + }; + var unknown = function () { + return nu(0, 0); + }; + var nu = function (major, minor) { + return { + major: major, + minor: minor + }; + }; + var Version = { + nu: nu, + detect: detect, + unknown: unknown + }; + + var edge = 'Edge'; + var chrome = 'Chrome'; + var ie = 'IE'; + var opera = 'Opera'; + var firefox = 'Firefox'; + var safari = 'Safari'; + var isBrowser = function (name, current) { + return function () { + return current === name; + }; + }; + var unknown$1 = function () { + return nu$1({ + current: undefined, + version: Version.unknown() + }); + }; + var nu$1 = function (info) { + var current = info.current; + var version = info.version; + return { + current: current, + version: version, + isEdge: isBrowser(edge, current), + isChrome: isBrowser(chrome, current), + isIE: isBrowser(ie, current), + isOpera: isBrowser(opera, current), + isFirefox: isBrowser(firefox, current), + isSafari: isBrowser(safari, current) + }; + }; + var Browser = { + unknown: unknown$1, + nu: nu$1, + edge: constant(edge), + chrome: constant(chrome), + ie: constant(ie), + opera: constant(opera), + firefox: constant(firefox), + safari: constant(safari) + }; + + var windows = 'Windows'; + var ios = 'iOS'; + var android = 'Android'; + var linux = 'Linux'; + var osx = 'OSX'; + var solaris = 'Solaris'; + var freebsd = 'FreeBSD'; + var isOS = function (name, current) { + return function () { + return current === name; + }; + }; + var unknown$2 = function () { + return nu$2({ + current: undefined, + version: Version.unknown() + }); + }; + var nu$2 = function (info) { + var current = info.current; + var version = info.version; + return { + current: current, + version: version, + isWindows: isOS(windows, current), + isiOS: isOS(ios, current), + isAndroid: isOS(android, current), + isOSX: isOS(osx, current), + isLinux: isOS(linux, current), + isSolaris: isOS(solaris, current), + isFreeBSD: isOS(freebsd, current) + }; + }; + var OperatingSystem = { + unknown: unknown$2, + nu: nu$2, + windows: constant(windows), + ios: constant(ios), + android: constant(android), + linux: constant(linux), + osx: constant(osx), + solaris: constant(solaris), + freebsd: constant(freebsd) + }; + + var DeviceType = function (os, browser, userAgent) { + var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true; + var isiPhone = os.isiOS() && !isiPad; + var isAndroid3 = os.isAndroid() && os.version.major === 3; + var isAndroid4 = os.isAndroid() && os.version.major === 4; + var isTablet = isiPad || isAndroid3 || isAndroid4 && /mobile/i.test(userAgent) === true; + var isTouch = os.isiOS() || os.isAndroid(); + var isPhone = isTouch && !isTablet; + var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false; + return { + isiPad: constant(isiPad), + isiPhone: constant(isiPhone), + isTablet: constant(isTablet), + isPhone: constant(isPhone), + isTouch: constant(isTouch), + isAndroid: os.isAndroid, + isiOS: os.isiOS, + isWebView: constant(iOSwebview) + }; + }; + + var detect$1 = function (candidates, userAgent) { + var agent = String(userAgent).toLowerCase(); + return find(candidates, function (candidate) { + return candidate.search(agent); + }); + }; + var detectBrowser = function (browsers, userAgent) { + return detect$1(browsers, userAgent).map(function (browser) { + var version = Version.detect(browser.versionRegexes, userAgent); + return { + current: browser.name, + version: version + }; + }); + }; + var detectOs = function (oses, userAgent) { + return detect$1(oses, userAgent).map(function (os) { + var version = Version.detect(os.versionRegexes, userAgent); + return { + current: os.name, + version: version + }; + }); + }; + var UaString = { + detectBrowser: detectBrowser, + detectOs: detectOs + }; + + var contains = function (str, substr) { + return str.indexOf(substr) !== -1; + }; + + var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; + var checkContains = function (target) { + return function (uastring) { + return contains(uastring, target); + }; + }; + var browsers = [ + { + name: 'Edge', + versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], + search: function (uastring) { + return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit'); + } + }, + { + name: 'Chrome', + versionRegexes: [ + /.*?chrome\/([0-9]+)\.([0-9]+).*/, + normalVersionRegex + ], + search: function (uastring) { + return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe'); + } + }, + { + name: 'IE', + versionRegexes: [ + /.*?msie\ ?([0-9]+)\.([0-9]+).*/, + /.*?rv:([0-9]+)\.([0-9]+).*/ + ], + search: function (uastring) { + return contains(uastring, 'msie') || contains(uastring, 'trident'); + } + }, + { + name: 'Opera', + versionRegexes: [ + normalVersionRegex, + /.*?opera\/([0-9]+)\.([0-9]+).*/ + ], + search: checkContains('opera') + }, + { + name: 'Firefox', + versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/], + search: checkContains('firefox') + }, + { + name: 'Safari', + versionRegexes: [ + normalVersionRegex, + /.*?cpu os ([0-9]+)_([0-9]+).*/ + ], + search: function (uastring) { + return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit'); + } + } + ]; + var oses = [ + { + name: 'Windows', + search: checkContains('win'), + versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] + }, + { + name: 'iOS', + search: function (uastring) { + return contains(uastring, 'iphone') || contains(uastring, 'ipad'); + }, + versionRegexes: [ + /.*?version\/\ ?([0-9]+)\.([0-9]+).*/, + /.*cpu os ([0-9]+)_([0-9]+).*/, + /.*cpu iphone os ([0-9]+)_([0-9]+).*/ + ] + }, + { + name: 'Android', + search: checkContains('android'), + versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/] + }, + { + name: 'OSX', + search: checkContains('os x'), + versionRegexes: [/.*?os\ x\ ?([0-9]+)_([0-9]+).*/] + }, + { + name: 'Linux', + search: checkContains('linux'), + versionRegexes: [] + }, + { + name: 'Solaris', + search: checkContains('sunos'), + versionRegexes: [] + }, + { + name: 'FreeBSD', + search: checkContains('freebsd'), + versionRegexes: [] + } + ]; + var PlatformInfo = { + browsers: constant(browsers), + oses: constant(oses) + }; + + var detect$2 = function (userAgent) { + var browsers = PlatformInfo.browsers(); + var oses = PlatformInfo.oses(); + var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu); + var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu); + var deviceType = DeviceType(os, browser, userAgent); + return { + browser: browser, + os: os, + deviceType: deviceType + }; + }; + var PlatformDetection = { detect: detect$2 }; + + var detect$3 = cached(function () { + var userAgent = domGlobals.navigator.userAgent; + return PlatformDetection.detect(userAgent); + }); + var PlatformDetection$1 = { detect: detect$3 }; + + var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE; + var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE; + var COMMENT = domGlobals.Node.COMMENT_NODE; + var DOCUMENT = domGlobals.Node.DOCUMENT_NODE; + var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE; + var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE; + var ELEMENT = domGlobals.Node.ELEMENT_NODE; + var TEXT = domGlobals.Node.TEXT_NODE; + var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE; + var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE; + var ENTITY = domGlobals.Node.ENTITY_NODE; + var NOTATION = domGlobals.Node.NOTATION_NODE; + + var ELEMENT$1 = ELEMENT; + var is = function (element, selector) { + var dom = element.dom(); + if (dom.nodeType !== ELEMENT$1) { + return false; + } else { + var elem = dom; + if (elem.matches !== undefined) { + return elem.matches(selector); + } else if (elem.msMatchesSelector !== undefined) { + return elem.msMatchesSelector(selector); + } else if (elem.webkitMatchesSelector !== undefined) { + return elem.webkitMatchesSelector(selector); + } else if (elem.mozMatchesSelector !== undefined) { + return elem.mozMatchesSelector(selector); + } else { + throw new Error('Browser lacks native selectors'); + } + } + }; + + var eq = function (e1, e2) { + return e1.dom() === e2.dom(); + }; + var regularContains = function (e1, e2) { + var d1 = e1.dom(); + var d2 = e2.dom(); + return d1 === d2 ? false : d1.contains(d2); + }; + var ieContains = function (e1, e2) { + return Node.documentPositionContainedBy(e1.dom(), e2.dom()); + }; + var browser = PlatformDetection$1.detect().browser; + var contains$1 = browser.isIE() ? ieContains : regularContains; + var is$1 = is; + + var parent = function (element) { + return Option.from(element.dom().parentNode).map(Element.fromDom); + }; + var children = function (element) { + return map(element.dom().childNodes, Element.fromDom); + }; + var child = function (element, index) { + var cs = element.dom().childNodes; + return Option.from(cs[index]).map(Element.fromDom); + }; + var firstChild = function (element) { + return child(element, 0); + }; + var lastChild = function (element) { + return child(element, element.dom().childNodes.length - 1); + }; + var spot = Immutable('element', 'offset'); + + var before = function (marker, element) { + var parent$1 = parent(marker); + parent$1.each(function (v) { + v.dom().insertBefore(element.dom(), marker.dom()); + }); + }; + var append = function (parent, element) { + parent.dom().appendChild(element.dom()); + }; + + var before$1 = function (marker, elements) { + each(elements, function (x) { + before(marker, x); + }); + }; + var append$1 = function (parent, elements) { + each(elements, function (x) { + append(parent, x); + }); + }; + + var remove = function (element) { + var dom = element.dom(); + if (dom.parentNode !== null) { + dom.parentNode.removeChild(dom); + } + }; + + var name = function (element) { + var r = element.dom().nodeName; + return r.toLowerCase(); + }; + var type = function (element) { + return element.dom().nodeType; + }; + var isType$1 = function (t) { + return function (element) { + return type(element) === t; + }; + }; + var isElement = isType$1(ELEMENT); + + var rawSet = function (dom, key, value) { + if (isString(value) || isBoolean(value) || isNumber(value)) { + dom.setAttribute(key, value + ''); + } else { + domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom); + throw new Error('Attribute value was not simple'); + } + }; + var setAll = function (element, attrs) { + var dom = element.dom(); + each$1(attrs, function (v, k) { + rawSet(dom, k, v); + }); + }; + var clone = function (element) { + return foldl(element.dom().attributes, function (acc, attr) { + acc[attr.name] = attr.value; + return acc; + }, {}); + }; + + var isSupported = function (dom) { + return dom.style !== undefined && isFunction(dom.style.getPropertyValue); + }; + + var internalSet = function (dom, property, value) { + if (!isString(value)) { + domGlobals.console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom); + throw new Error('CSS value must be a string: ' + value); + } + if (isSupported(dom)) { + dom.style.setProperty(property, value); + } + }; + var set = function (element, property, value) { + var dom = element.dom(); + internalSet(dom, property, value); + }; + + var clone$1 = function (original, isDeep) { + return Element.fromDom(original.dom().cloneNode(isDeep)); + }; + var deep = function (original) { + return clone$1(original, true); + }; + var shallowAs = function (original, tag) { + var nu = Element.fromTag(tag); + var attributes = clone(original); + setAll(nu, attributes); + return nu; + }; + var mutate = function (original, tag) { + var nu = shallowAs(original, tag); + before(original, nu); + var children$1 = children(original); + append$1(nu, children$1); + remove(original); + return nu; + }; + + var joinSegment = function (parent, child) { + append(parent.item, child.list); + }; + var joinSegments = function (segments) { + for (var i = 1; i < segments.length; i++) { + joinSegment(segments[i - 1], segments[i]); + } + }; + var appendSegments = function (head$1, tail) { + lift2(last(head$1), head(tail), joinSegment); + }; + var createSegment = function (scope, listType) { + var segment = { + list: Element.fromTag(listType, scope), + item: Element.fromTag('li', scope) + }; + append(segment.list, segment.item); + return segment; + }; + var createSegments = function (scope, entry, size) { + var segments = []; + for (var i = 0; i < size; i++) { + segments.push(createSegment(scope, entry.listType)); + } + return segments; + }; + var populateSegments = function (segments, entry) { + for (var i = 0; i < segments.length - 1; i++) { + set(segments[i].item, 'list-style-type', 'none'); + } + last(segments).each(function (segment) { + setAll(segment.list, entry.listAttributes); + setAll(segment.item, entry.itemAttributes); + append$1(segment.item, entry.content); + }); + }; + var normalizeSegment = function (segment, entry) { + if (name(segment.list) !== entry.listType) { + segment.list = mutate(segment.list, entry.listType); + } + setAll(segment.list, entry.listAttributes); + }; + var createItem = function (scope, attr, content) { + var item = Element.fromTag('li', scope); + setAll(item, attr); + append$1(item, content); + return item; + }; + var appendItem = function (segment, item) { + append(segment.list, item); + segment.item = item; + }; + var writeShallow = function (scope, cast, entry) { + var newCast = cast.slice(0, entry.depth); + last(newCast).each(function (segment) { + var item = createItem(scope, entry.itemAttributes, entry.content); + appendItem(segment, item); + normalizeSegment(segment, entry); + }); + return newCast; + }; + var writeDeep = function (scope, cast, entry) { + var segments = createSegments(scope, entry, entry.depth - cast.length); + joinSegments(segments); + populateSegments(segments, entry); + appendSegments(cast, segments); + return cast.concat(segments); + }; + var composeList = function (scope, entries) { + var cast = foldl(entries, function (cast, entry) { + return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry); + }, []); + return head(cast).map(function (segment) { + return segment.list; + }); + }; + + var isList$1 = function (el) { + return is$1(el, 'OL,UL'); + }; + var hasFirstChildList = function (el) { + return firstChild(el).map(isList$1).getOr(false); + }; + var hasLastChildList = function (el) { + return lastChild(el).map(isList$1).getOr(false); + }; + + var isIndented = function (entry) { + return entry.depth > 0; + }; + var isSelected = function (entry) { + return entry.isSelected; + }; + var cloneItemContent = function (li) { + var children$1 = children(li); + var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1; + return map(content, deep); + }; + var createEntry = function (li, depth, isSelected) { + return parent(li).filter(isElement).map(function (list) { + return { + depth: depth, + isSelected: isSelected, + content: cloneItemContent(li), + itemAttributes: clone(li), + listAttributes: clone(list), + listType: name(list) + }; + }); + }; + + var indentEntry = function (indentation, entry) { + switch (indentation) { + case 'Indent': + entry.depth++; + break; + case 'Outdent': + entry.depth--; + break; + case 'Flatten': + entry.depth = 0; + } + }; + + var hasOwnProperty = Object.prototype.hasOwnProperty; + var shallow = function (old, nu) { + return nu; + }; + var baseMerge = function (merger) { + return function () { + var objects = new Array(arguments.length); + for (var i = 0; i < objects.length; i++) { + objects[i] = arguments[i]; + } + if (objects.length === 0) { + throw new Error('Can\'t merge zero objects'); + } + var ret = {}; + for (var j = 0; j < objects.length; j++) { + var curObject = objects[j]; + for (var key in curObject) { + if (hasOwnProperty.call(curObject, key)) { + ret[key] = merger(ret[key], curObject[key]); + } + } + } + return ret; + }; + }; + var merge = baseMerge(shallow); + + var cloneListProperties = function (target, source) { + target.listType = source.listType; + target.listAttributes = merge({}, source.listAttributes); + }; + var previousSiblingEntry = function (entries, start) { + var depth = entries[start].depth; + for (var i = start - 1; i >= 0; i--) { + if (entries[i].depth === depth) { + return Option.some(entries[i]); + } + if (entries[i].depth < depth) { + break; + } + } + return Option.none(); + }; + var normalizeEntries = function (entries) { + each(entries, function (entry, i) { + previousSiblingEntry(entries, i).each(function (matchingEntry) { + cloneListProperties(entry, matchingEntry); + }); + }); + }; + + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; + }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; + }; + + var parseItem = function (depth, itemSelection, selectionState, item) { + return firstChild(item).filter(isList$1).fold(function () { + itemSelection.each(function (selection) { + if (eq(selection.start, item)) { + selectionState.set(true); + } + }); + var currentItemEntry = createEntry(item, depth, selectionState.get()); + itemSelection.each(function (selection) { + if (eq(selection.end, item)) { + selectionState.set(false); + } + }); + var childListEntries = lastChild(item).filter(isList$1).map(function (list) { + return parseList(depth, itemSelection, selectionState, list); + }).getOr([]); + return currentItemEntry.toArray().concat(childListEntries); + }, function (list) { + return parseList(depth, itemSelection, selectionState, list); + }); + }; + var parseList = function (depth, itemSelection, selectionState, list) { + return bind(children(list), function (element) { + var parser = isList$1(element) ? parseList : parseItem; + var newDepth = depth + 1; + return parser(newDepth, itemSelection, selectionState, element); + }); + }; + var parseLists = function (lists, itemSelection) { + var selectionState = Cell(false); + var initialDepth = 0; + return map(lists, function (list) { + return { + sourceList: list, + entries: parseList(initialDepth, itemSelection, selectionState, list) + }; + }); + }; + + var global$8 = tinymce.util.Tools.resolve('tinymce.Env'); + + var createTextBlock = function (editor, contentNode) { + var dom = editor.dom; + var blockElements = editor.schema.getBlockElements(); + var fragment = dom.createFragment(); + var node, textBlock, blockName, hasContentNode; + if (editor.settings.forced_root_block) { + 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); + } + if (!NodeType.isBlock(contentNode.firstChild, blockElements)) { + 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 (NodeType.isBlock(node, blockElements)) { + 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 { + if (!hasContentNode && (!global$8.ie || global$8.ie > 10)) { + textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' })); + } + } + return fragment; + }; + + var outdentedComposer = function (editor, entries) { + return map(entries, function (entry) { + var content = fromElements(entry.content); + return Element.fromDom(createTextBlock(editor, content.dom())); + }); + }; + var indentedComposer = function (editor, entries) { + normalizeEntries(entries); + return composeList(editor.contentDocument, entries).toArray(); + }; + var composeEntries = function (editor, entries) { + return bind(groupBy(entries, isIndented), function (entries) { + var groupIsIndented = head(entries).map(isIndented).getOr(false); + return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries); + }); + }; + var indentSelectedEntries = function (entries, indentation) { + each(filter(entries, isSelected), function (entry) { + return indentEntry(indentation, entry); + }); + }; + var getItemSelection = function (editor) { + var selectedListItems = map(Selection.getSelectedListItems(editor), Element.fromDom); + return lift2(find(selectedListItems, not(hasFirstChildList)), find(reverse(selectedListItems), not(hasFirstChildList)), function (start, end) { + return { + start: start, + end: end + }; + }); + }; + var listsIndentation = function (editor, lists, indentation) { + var entrySets = parseLists(lists, getItemSelection(editor)); + each(entrySets, function (entrySet) { + indentSelectedEntries(entrySet.entries, indentation); + before$1(entrySet.sourceList, composeEntries(editor, entrySet.entries)); + remove(entrySet.sourceList); + }); + }; + + var DOM$1 = global$6.DOM; + var splitList = function (editor, ul, li) { + var tmpRng, fragment, bookmarks, node, newBlock; + var removeAndKeepBookmarks = function (targetNode) { + global$5.each(bookmarks, function (node) { + targetNode.parentNode.insertBefore(node, li.parentNode); + }); + DOM$1.remove(targetNode); + }; + bookmarks = DOM$1.select('span[data-mce-type="bookmark"]', ul); + newBlock = createTextBlock(editor, li); + tmpRng = DOM$1.createRng(); + tmpRng.setStartAfter(li); + tmpRng.setEndAfter(ul); + fragment = tmpRng.extractContents(); + for (node = fragment.firstChild; node; node = node.firstChild) { + if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) { + DOM$1.remove(node); + break; + } + } + if (!editor.dom.isEmpty(fragment)) { + DOM$1.insertAfter(fragment, ul); + } + DOM$1.insertAfter(newBlock, ul); + if (NodeType.isEmpty(editor.dom, li.parentNode)) { + removeAndKeepBookmarks(li.parentNode); + } + DOM$1.remove(li); + if (NodeType.isEmpty(editor.dom, ul)) { + DOM$1.remove(ul); + } + }; + var SplitList = { splitList: splitList }; + + var outdentDlItem = function (editor, item) { + if (is$1(item, 'dd')) { + mutate(item, 'dt'); + } else if (is$1(item, 'dt')) { + parent(item).each(function (dl) { + return SplitList.splitList(editor, dl.dom(), item.dom()); + }); + } + }; + var indentDlItem = function (item) { + if (is$1(item, 'dt')) { + mutate(item, 'dd'); + } + }; + var dlIndentation = function (editor, indentation, dlItems) { + if (indentation === 'Indent') { + each(dlItems, indentDlItem); + } else { + each(dlItems, function (item) { + return outdentDlItem(editor, item); + }); + } + }; + + var selectionIndentation = function (editor, indentation) { + var lists = map(Selection.getSelectedListRoots(editor), Element.fromDom); + var dlItems = map(Selection.getSelectedDlItems(editor), Element.fromDom); + var isHandled = false; + if (lists.length || dlItems.length) { + var bookmark = editor.selection.getBookmark(); + listsIndentation(editor, lists, indentation); + dlIndentation(editor, indentation, dlItems); + editor.selection.moveToBookmark(bookmark); + editor.selection.setRng(Range.normalizeRange(editor.selection.getRng())); + editor.nodeChanged(); + isHandled = true; + } + return isHandled; + }; + var indentListSelection = function (editor) { + return selectionIndentation(editor, 'Indent'); + }; + var outdentListSelection = function (editor) { + return selectionIndentation(editor, 'Outdent'); + }; + var flattenListSelection = function (editor) { + return selectionIndentation(editor, 'Flatten'); + }; + + var updateListStyle = function (dom, el, detail) { + var type = detail['list-style-type'] ? detail['list-style-type'] : null; + dom.setStyle(el, 'list-style-type', type); + }; + var setAttribs = function (elm, attrs) { + global$5.each(attrs, function (value, key) { + elm.setAttribute(key, value); + }); + }; + var updateListAttrs = function (dom, el, detail) { + setAttribs(el, detail['list-attributes']); + global$5.each(dom.select('li', el), function (li) { + setAttribs(li, detail['list-item-attributes']); + }); + }; + var updateListWithDetails = function (dom, el, detail) { + updateListStyle(dom, el, detail); + updateListAttrs(dom, el, detail); + }; + var removeStyles = function (dom, element, styles) { + global$5.each(styles, function (style) { + var _a; + return dom.setStyle(element, (_a = {}, _a[style] = '', _a)); + }); + }; + var getEndPointNode = function (editor, rng, start, root) { + var container, offset; + container = rng[start ? 'startContainer' : 'endContainer']; + offset = rng[start ? 'startOffset' : 'endOffset']; + if (container.nodeType === 1) { + container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container; + } + if (!start && NodeType.isBr(container.nextSibling)) { + container = container.nextSibling; + } + while (container.parentNode !== root) { + if (NodeType.isTextBlock(editor, container)) { + return container; + } + if (/^(TD|TH)$/.test(container.parentNode.nodeName)) { + return container; + } + container = container.parentNode; + } + return container; + }; + var getSelectedTextBlocks = function (editor, rng, root) { + var textBlocks = [], dom = editor.dom; + var startNode = getEndPointNode(editor, rng, true, root); + var endNode = getEndPointNode(editor, rng, false, root); + var block; + var siblings = []; + for (var node = startNode; node; node = node.nextSibling) { + siblings.push(node); + if (node === endNode) { + break; + } + } + global$5.each(siblings, function (node) { + if (NodeType.isTextBlock(editor, node)) { + textBlocks.push(node); + block = null; + return; + } + if (dom.isBlock(node) || NodeType.isBr(node)) { + if (NodeType.isBr(node)) { + dom.remove(node); + } + block = null; + return; + } + var nextSibling = node.nextSibling; + if (global$4.isBookmarkNode(node)) { + if (NodeType.isTextBlock(editor, 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; + }; + var hasCompatibleStyle = function (dom, sib, detail) { + var sibStyle = dom.getStyle(sib, 'list-style-type'); + var detailStyle = detail ? detail['list-style-type'] : ''; + detailStyle = detailStyle === null ? '' : detailStyle; + return sibStyle === detailStyle; + }; + var applyList = function (editor, listName, detail) { + if (detail === void 0) { + detail = {}; + } + var rng = editor.selection.getRng(true); + var bookmark; + var listItemName = 'LI'; + var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true)); + var dom = editor.dom; + if (dom.getContentEditable(editor.selection.getNode()) === 'false') { + return; + } + listName = listName.toUpperCase(); + if (listName === 'DL') { + listItemName = 'DT'; + } + bookmark = Bookmark.createBookmark(rng); + global$5.each(getSelectedTextBlocks(editor, rng, root), function (block) { + var listBlock, sibling; + sibling = block.previousSibling; + if (sibling && NodeType.isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) { + 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); + } + removeStyles(dom, block, [ + 'margin', + 'margin-right', + 'margin-bottom', + 'margin-left', + 'margin-top', + 'padding', + 'padding-right', + 'padding-bottom', + 'padding-left', + 'padding-top' + ]); + updateListWithDetails(dom, listBlock, detail); + mergeWithAdjacentLists(editor.dom, listBlock); + }); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + }; + var isValidLists = function (list1, list2) { + return list1 && list2 && NodeType.isListNode(list1) && list1.nodeName === list2.nodeName; + }; + var hasSameListStyle = function (dom, list1, list2) { + var targetStyle = dom.getStyle(list1, 'list-style-type', true); + var style = dom.getStyle(list2, 'list-style-type', true); + return targetStyle === style; + }; + var hasSameClasses = function (elm1, elm2) { + return elm1.className === elm2.className; + }; + var shouldMerge = function (dom, list1, list2) { + return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2); + }; + var mergeWithAdjacentLists = function (dom, listBlock) { + var sibling, node; + sibling = listBlock.nextSibling; + if (shouldMerge(dom, listBlock, sibling)) { + while (node = sibling.firstChild) { + listBlock.appendChild(node); + } + dom.remove(sibling); + } + sibling = listBlock.previousSibling; + if (shouldMerge(dom, listBlock, sibling)) { + while (node = sibling.lastChild) { + listBlock.insertBefore(node, listBlock.firstChild); + } + dom.remove(sibling); + } + }; + var updateList = function (dom, list, listName, detail) { + if (list.nodeName !== listName) { + var newList = dom.rename(list, listName); + updateListWithDetails(dom, newList, detail); + } else { + updateListWithDetails(dom, list, detail); + } + }; + var toggleMultipleLists = function (editor, parentList, lists, listName, detail) { + if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { + flattenListSelection(editor); + } else { + var bookmark = Bookmark.createBookmark(editor.selection.getRng(true)); + global$5.each([parentList].concat(lists), function (elm) { + updateList(editor.dom, elm, listName, detail); + }); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + } + }; + var hasListStyleDetail = function (detail) { + return 'list-style-type' in detail; + }; + var toggleSingleList = function (editor, parentList, listName, detail) { + if (parentList === editor.getBody()) { + return; + } + if (parentList) { + if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { + flattenListSelection(editor); + } else { + var bookmark = Bookmark.createBookmark(editor.selection.getRng(true)); + updateListWithDetails(editor.dom, parentList, detail); + mergeWithAdjacentLists(editor.dom, editor.dom.rename(parentList, listName)); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + } + } else { + applyList(editor, listName, detail); + } + }; + var toggleList = function (editor, listName, detail) { + var parentList = Selection.getParentList(editor); + var selectedSubLists = Selection.getSelectedSubLists(editor); + detail = detail ? detail : {}; + if (parentList && selectedSubLists.length > 0) { + toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail); + } else { + toggleSingleList(editor, parentList, listName, detail); + } + }; + var ToggleList = { + toggleList: toggleList, + mergeWithAdjacentLists: mergeWithAdjacentLists + }; + + var DOM$2 = global$6.DOM; + var normalizeList = function (dom, ul) { + var sibling; + var parentNode = ul.parentNode; + if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) { + sibling = parentNode.previousSibling; + if (sibling && sibling.nodeName === 'LI') { + sibling.appendChild(ul); + if (NodeType.isEmpty(dom, parentNode)) { + DOM$2.remove(parentNode); + } + } else { + DOM$2.setStyle(parentNode, 'listStyleType', 'none'); + } + } + if (NodeType.isListNode(parentNode)) { + sibling = parentNode.previousSibling; + if (sibling && sibling.nodeName === 'LI') { + sibling.appendChild(ul); + } + } + }; + var normalizeLists = function (dom, element) { + global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) { + normalizeList(dom, ul); + }); + }; + var NormalizeLists = { + normalizeList: normalizeList, + normalizeLists: normalizeLists + }; + + var findNextCaretContainer = function (editor, rng, isForward, root) { + var node = rng.startContainer; + var offset = rng.startOffset; + var nonEmptyBlocks, walker; + if (node.nodeType === 3 && (isForward ? offset < node.data.length : offset > 0)) { + return node; + } + nonEmptyBlocks = editor.schema.getNonEmptyElements(); + if (node.nodeType === 1) { + node = global$1.getNode(node, offset); + } + walker = new global$2(node, root); + if (isForward) { + if (NodeType.isBogusBr(editor.dom, node)) { + walker.next(); + } + } + while (node = walker[isForward ? 'next' : 'prev2']()) { + if (node.nodeName === 'LI' && !node.hasChildNodes()) { + return node; + } + if (nonEmptyBlocks[node.nodeName]) { + return node; + } + if (node.nodeType === 3 && node.data.length > 0) { + return node; + } + } + }; + var hasOnlyOneBlockChild = function (dom, elm) { + var childNodes = elm.childNodes; + return childNodes.length === 1 && !NodeType.isListNode(childNodes[0]) && dom.isBlock(childNodes[0]); + }; + var unwrapSingleBlockChild = function (dom, elm) { + if (hasOnlyOneBlockChild(dom, elm)) { + dom.remove(elm.firstChild, true); + } + }; + var moveChildren = function (dom, fromElm, toElm) { + var node, targetElm; + targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm; + unwrapSingleBlockChild(dom, fromElm); + if (!NodeType.isEmpty(dom, fromElm, true)) { + while (node = fromElm.firstChild) { + targetElm.appendChild(node); + } + } + }; + var mergeLiElements = function (dom, fromElm, toElm) { + var node, listNode; + var ul = fromElm.parentNode; + if (!NodeType.isChildOfBody(dom, fromElm) || !NodeType.isChildOfBody(dom, toElm)) { + return; + } + if (NodeType.isListNode(toElm.lastChild)) { + listNode = toElm.lastChild; + } + if (ul === toElm.lastChild) { + if (NodeType.isBr(ul.previousSibling)) { + dom.remove(ul.previousSibling); + } + } + node = toElm.lastChild; + if (node && NodeType.isBr(node) && fromElm.hasChildNodes()) { + dom.remove(node); + } + if (NodeType.isEmpty(dom, toElm, true)) { + dom.$(toElm).empty(); + } + moveChildren(dom, fromElm, toElm); + if (listNode) { + toElm.appendChild(listNode); + } + var contains = contains$1(Element.fromDom(toElm), Element.fromDom(fromElm)); + var nestedLists = contains ? dom.getParents(fromElm, NodeType.isListNode, toElm) : []; + dom.remove(fromElm); + each(nestedLists, function (list) { + if (NodeType.isEmpty(dom, list) && list !== dom.getRoot()) { + dom.remove(list); + } + }); + }; + var mergeIntoEmptyLi = function (editor, fromLi, toLi) { + editor.dom.$(toLi).empty(); + mergeLiElements(editor.dom, fromLi, toLi); + editor.selection.setCursorLocation(toLi); + }; + var mergeForward = function (editor, rng, fromLi, toLi) { + var dom = editor.dom; + if (dom.isEmpty(toLi)) { + mergeIntoEmptyLi(editor, fromLi, toLi); + } else { + var bookmark = Bookmark.createBookmark(rng); + mergeLiElements(dom, fromLi, toLi); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + } + }; + var mergeBackward = function (editor, rng, fromLi, toLi) { + var bookmark = Bookmark.createBookmark(rng); + mergeLiElements(editor.dom, fromLi, toLi); + var resolvedBookmark = Bookmark.resolveBookmark(bookmark); + editor.selection.setRng(resolvedBookmark); + }; + var backspaceDeleteFromListToListCaret = function (editor, isForward) { + var dom = editor.dom, selection = editor.selection; + var selectionStartElm = selection.getStart(); + var root = Selection.getClosestListRootElm(editor, selectionStartElm); + var li = dom.getParent(selection.getStart(), 'LI', root); + var ul, rng, otherLi; + if (li) { + ul = li.parentNode; + if (ul === editor.getBody() && NodeType.isEmpty(dom, ul)) { + return true; + } + rng = Range.normalizeRange(selection.getRng(true)); + otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); + if (otherLi && otherLi !== li) { + if (isForward) { + mergeForward(editor, rng, otherLi, li); + } else { + mergeBackward(editor, rng, li, otherLi); + } + return true; + } else if (!otherLi) { + if (!isForward) { + flattenListSelection(editor); + return true; + } + } + } + return false; + }; + var removeBlock = function (dom, block, root) { + var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root); + dom.remove(block); + if (parentBlock && dom.isEmpty(parentBlock)) { + dom.remove(parentBlock); + } + }; + var backspaceDeleteIntoListCaret = function (editor, isForward) { + var dom = editor.dom; + var selectionStartElm = editor.selection.getStart(); + var root = Selection.getClosestListRootElm(editor, selectionStartElm); + var block = dom.getParent(selectionStartElm, dom.isBlock, root); + if (block && dom.isEmpty(block)) { + var rng = Range.normalizeRange(editor.selection.getRng(true)); + var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); + if (otherLi_1) { + editor.undoManager.transact(function () { + removeBlock(dom, block, root); + ToggleList.mergeWithAdjacentLists(dom, otherLi_1.parentNode); + editor.selection.select(otherLi_1, true); + editor.selection.collapse(isForward); + }); + return true; + } + } + return false; + }; + var backspaceDeleteCaret = function (editor, isForward) { + return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward); + }; + var backspaceDeleteRange = function (editor) { + var selectionStartElm = editor.selection.getStart(); + var root = Selection.getClosestListRootElm(editor, selectionStartElm); + var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root); + if (startListParent || Selection.getSelectedListItems(editor).length > 0) { + editor.undoManager.transact(function () { + editor.execCommand('Delete'); + NormalizeLists.normalizeLists(editor.dom, editor.getBody()); + }); + return true; + } + return false; + }; + var backspaceDelete = function (editor, isForward) { + return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor); + }; + var setup = function (editor) { + editor.on('keydown', function (e) { + if (e.keyCode === global$3.BACKSPACE) { + if (backspaceDelete(editor, false)) { + e.preventDefault(); + } + } else if (e.keyCode === global$3.DELETE) { + if (backspaceDelete(editor, true)) { + e.preventDefault(); + } + } + }); + }; + var Delete = { + setup: setup, + backspaceDelete: backspaceDelete + }; + + var get = function (editor) { + return { + backspaceDelete: function (isForward) { + Delete.backspaceDelete(editor, isForward); + } + }; + }; + var Api = { get: get }; + + var queryListCommandState = function (editor, listName) { + return function () { + var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL'); + return parentList && parentList.nodeName === listName; + }; + }; + var register = function (editor) { + editor.on('BeforeExecCommand', function (e) { + var cmd = e.command.toLowerCase(); + if (cmd === 'indent') { + indentListSelection(editor); + } else if (cmd === 'outdent') { + outdentListSelection(editor); + } + }); + editor.addCommand('InsertUnorderedList', function (ui, detail) { + ToggleList.toggleList(editor, 'UL', detail); + }); + editor.addCommand('InsertOrderedList', function (ui, detail) { + ToggleList.toggleList(editor, 'OL', detail); + }); + editor.addCommand('InsertDefinitionList', function (ui, detail) { + ToggleList.toggleList(editor, 'DL', detail); + }); + editor.addCommand('RemoveList', function () { + flattenListSelection(editor); + }); + editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL')); + editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL')); + editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL')); + }; + var Commands = { register: register }; + + var shouldIndentOnTab = function (editor) { + return editor.getParam('lists_indent_on_tab', true); + }; + var Settings = { shouldIndentOnTab: shouldIndentOnTab }; + + var setupTabKey = function (editor) { + editor.on('keydown', function (e) { + if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) { + return; + } + editor.undoManager.transact(function () { + if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) { + e.preventDefault(); + } + }); + }); + }; + var setup$1 = function (editor) { + if (Settings.shouldIndentOnTab(editor)) { + setupTabKey(editor); + } + Delete.setup(editor); + }; + var Keyboard = { setup: setup$1 }; + + var findIndex = function (list, predicate) { + for (var index = 0; index < list.length; index++) { + var element = list[index]; + if (predicate(element)) { + return index; + } + } + return -1; + }; + var listState = function (editor, listName) { + return function (e) { + var ctrl = e.control; + editor.on('NodeChange', function (e) { + var tableCellIndex = findIndex(e.parents, NodeType.isTableCellNode); + var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents; + var lists = global$5.grep(parents, NodeType.isListNode); + ctrl.active(lists.length > 0 && lists[0].nodeName === listName); + }); + }; + }; + var register$1 = function (editor) { + var hasPlugin = function (editor, plugin) { + var plugins = editor.settings.plugins ? editor.settings.plugins : ''; + return global$5.inArray(plugins.split(/[ ,]/), plugin) !== -1; + }; + if (!hasPlugin(editor, 'advlist')) { + editor.addButton('numlist', { + active: false, + title: 'Numbered list', + cmd: 'InsertOrderedList', + onPostRender: listState(editor, 'OL') + }); + editor.addButton('bullist', { + active: false, + title: 'Bullet list', + cmd: 'InsertUnorderedList', + onPostRender: listState(editor, 'UL') + }); + } + editor.addButton('indent', { + icon: 'indent', + title: 'Increase indent', + cmd: 'Indent' + }); + }; + var Buttons = { register: register$1 }; + + global.add('lists', function (editor) { + Keyboard.setup(editor); + Buttons.register(editor); + Commands.register(editor); + return Api.get(editor); + }); + function Plugin () { + } + + return Plugin; + +}(window)); +})(); diff --git a/wp-includes/js/tinymce/plugins/lists/plugin.min.js b/wp-includes/js/tinymce/plugins/lists/plugin.min.js new file mode 100644 index 0000000..d92fc6d --- /dev/null +++ b/wp-includes/js/tinymce/plugins/lists/plugin.min.js @@ -0,0 +1 @@ +!function(u){"use strict";var e,n,t,r,o,i,s,a,c,f=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),l=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),m=tinymce.util.Tools.resolve("tinymce.util.VK"),p=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),g=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),h=function(e){return e&&"BR"===e.nodeName},y=function(e){return e&&3===e.nodeType},N=function(e){return e&&/^(OL|UL|DL)$/.test(e.nodeName)},S=function(e){return e&&/^(OL|UL)$/.test(e.nodeName)},C=function(e){return e&&/^(DT|DD)$/.test(e.nodeName)},O=function(e){return e&&/^(LI|DT|DD)$/.test(e.nodeName)},b=function(e){return e&&/^(TH|TD)$/.test(e.nodeName)},T=h,E=function(e,n){return n&&!!e.schema.getTextBlockElements()[n.nodeName]},L=function(e,n){return e&&e.nodeName in n},D=function(e,n){return!!h(n)&&!(!e.isBlock(n.nextSibling)||h(n.previousSibling))},w=function(e,n,t){var r=e.isEmpty(n);return!(t&&0<e.select("span[data-mce-type=bookmark]",n).length)&&r},k=function(e,n){return e.isChildOf(n,e.getRoot())},A=function(e,n){if(y(e))return{container:e,offset:n};var t=d.getNode(e,n);return y(t)?{container:t,offset:n>=e.childNodes.length?t.data.length:0}:t.previousSibling&&y(t.previousSibling)?{container:t.previousSibling,offset:t.previousSibling.data.length}:t.nextSibling&&y(t.nextSibling)?{container:t.nextSibling,offset:0}:{container:e,offset:n}},x=function(e){var n=e.cloneRange(),t=A(e.startContainer,e.startOffset);n.setStart(t.container,t.offset);var r=A(e.endContainer,e.endOffset);return n.setEnd(r.container,r.offset),n},R=g.DOM,I=function(o){var i={},e=function(e){var n,t,r;t=o[e?"startContainer":"endContainer"],r=o[e?"startOffset":"endOffset"],1===t.nodeType&&(n=R.create("span",{"data-mce-type":"bookmark"}),t.hasChildNodes()?(r=Math.min(r,t.childNodes.length-1),e?t.insertBefore(n,t.childNodes[r]):R.insertAfter(n,t.childNodes[r])):t.appendChild(n),t=n,r=0),i[e?"startContainer":"endContainer"]=t,i[e?"startOffset":"endOffset"]=r};return e(!0),o.collapsed||e(),i},_=function(o){function e(e){var n,t,r;n=r=o[e?"startContainer":"endContainer"],t=o[e?"startOffset":"endOffset"],n&&(1===n.nodeType&&(t=function(e){for(var n=e.parentNode.firstChild,t=0;n;){if(n===e)return t;1===n.nodeType&&"bookmark"===n.getAttribute("data-mce-type")||t++,n=n.nextSibling}return-1}(n),n=n.parentNode,R.remove(r),!n.hasChildNodes()&&R.isBlock(n)&&n.appendChild(R.create("br"))),o[e?"startContainer":"endContainer"]=n,o[e?"startOffset":"endOffset"]=t)}e(!0),e();var n=R.createRng();return n.setStart(o.startContainer,o.startOffset),o.endContainer&&n.setEnd(o.endContainer,o.endOffset),x(n)},B=function(){},P=function(e){return function(){return e}},M=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return!t.apply(null,e)}},U=P(!1),F=P(!0),j=function(){return H},H=(e=function(e){return e.isNone()},r={fold:function(e,n){return e()},is:U,isSome:U,isNone:F,getOr:t=function(e){return e},getOrThunk:n=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:P(null),getOrUndefined:P(undefined),or:t,orThunk:n,map:j,each:B,bind:j,exists:U,forall:F,filter:j,equals:e,equals_:e,toArray:function(){return[]},toString:P("none()")},Object.freeze&&Object.freeze(r),r),$=function(t){var e=P(t),n=function(){return o},r=function(e){return e(t)},o={fold:function(e,n){return n(t)},is:function(e){return t===e},isSome:F,isNone:U,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:n,orThunk:n,map:function(e){return $(e(t))},each:function(e){e(t)},bind:r,exists:r,forall:r,filter:function(e){return e(t)?o:H},toArray:function(){return[t]},toString:function(){return"some("+t+")"},equals:function(e){return e.is(t)},equals_:function(e,n){return e.fold(U,function(e){return n(t,e)})}};return o},q={some:$,none:j,from:function(e){return null===e||e===undefined?H:$(e)}},W=function(n){return function(e){return function(e){if(null===e)return"null";var n=typeof e;return"object"===n&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===n&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":n}(e)===n}},V=W("string"),z=W("array"),K=W("boolean"),X=W("function"),Q=W("number"),Y=Array.prototype.slice,G=Array.prototype.push,J=function(e,n){for(var t=e.length,r=new Array(t),o=0;o<t;o++){var i=e[o];r[o]=n(i,o)}return r},Z=function(e,n){for(var t=0,r=e.length;t<r;t++)n(e[t],t)},ee=function(e,n){for(var t=[],r=0,o=e.length;r<o;r++){var i=e[r];n(i,r)&&t.push(i)}return t},ne=function(e,n,t){return Z(e,function(e){t=n(t,e)}),t},te=function(e,n){for(var t=0,r=e.length;t<r;t++){var o=e[t];if(n(o,t))return q.some(o)}return q.none()},re=function(e,n){return function(e){for(var n=[],t=0,r=e.length;t<r;++t){if(!z(e[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+e);G.apply(n,e[t])}return n}(J(e,n))},oe=function(e){return 0===e.length?q.none():q.some(e[0])},ie=function(e){return 0===e.length?q.none():q.some(e[e.length-1])},ue=(X(Array.from)&&Array.from,"undefined"!=typeof u.window?u.window:Function("return this;")()),se=function(e,n){return function(e,n){for(var t=n!==undefined&&null!==n?n:ue,r=0;r<e.length&&t!==undefined&&null!==t;++r)t=t[e[r]];return t}(e.split("."),n)},ae=function(e,n){var t=se(e,n);if(t===undefined||null===t)throw new Error(e+" not available on this browser");return t},ce=function(e){var n,t=se("ownerDocument.defaultView",e);return(n=t,ae("HTMLElement",n)).prototype.isPrototypeOf(e)},fe=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),de=function(e){var n=e.selection.getStart(!0);return e.dom.getParent(n,"OL,UL,DL",me(e,n))},le=function(e){var t,n,r,o=e.selection.getSelectedBlocks();return v.grep((t=e,n=o,r=v.map(n,function(e){var n=t.dom.getParent(e,"li,dd,dt",me(t,e));return n||e}),fe.unique(r)),function(e){return O(e)})},me=function(e,n){var t=e.dom.getParents(n,"TD,TH");return 0<t.length?t[0]:e.getBody()},ge=function(e,n){var t=e.dom.getParents(n,"ol,ul",me(e,n));return ie(t)},pe=function(n,e){var t=J(e,function(e){return ge(n,e).getOr(e)});return fe.unique(t)},ve={isList:function(e){var n=de(e);return ce(n)},getParentList:de,getSelectedSubLists:function(e){var n,t,r,o=de(e),i=e.selection.getSelectedBlocks();return r=i,(t=o)&&1===r.length&&r[0]===t?(n=o,v.grep(n.querySelectorAll("ol,ul,dl"),function(e){return N(e)})):v.grep(i,function(e){return N(e)&&o!==e})},getSelectedListItems:le,getClosestListRootElm:me,getSelectedDlItems:function(e){return ee(le(e),C)},getSelectedListRoots:function(e){var n,t,r,o=(t=ge(n=e,n.selection.getStart()),r=ee(n.selection.getSelectedBlocks(),S),t.toArray().concat(r));return pe(e,o)}},he=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:P(e)}},ye={fromHtml:function(e,n){var t=(n||u.document).createElement("div");if(t.innerHTML=e,!t.hasChildNodes()||1<t.childNodes.length)throw u.console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return he(t.childNodes[0])},fromTag:function(e,n){var t=(n||u.document).createElement(e);return he(t)},fromText:function(e,n){var t=(n||u.document).createTextNode(e);return he(t)},fromDom:he,fromPoint:function(e,n,t){var r=e.dom();return q.from(r.elementFromPoint(n,t)).map(he)}},Ne=function(e,n,t){return e.isSome()&&n.isSome()?q.some(t(e.getOrDie(),n.getOrDie())):q.none()},Se=Object.keys,Ce=function(){return ae("Node")},Oe=function(e,n,t){return 0!=(e.compareDocumentPosition(n)&t)},be=function(e,n){return Oe(e,n,Ce().DOCUMENT_POSITION_CONTAINED_BY)},Te=function(e,n){var t=function(e,n){for(var t=0;t<e.length;t++){var r=e[t];if(r.test(n))return r}return undefined}(e,n);if(!t)return{major:0,minor:0};var r=function(e){return Number(n.replace(t,"$"+e))};return Le(r(1),r(2))},Ee=function(){return Le(0,0)},Le=function(e,n){return{major:e,minor:n}},De={nu:Le,detect:function(e,n){var t=String(n).toLowerCase();return 0===e.length?Ee():Te(e,t)},unknown:Ee},we="Firefox",ke=function(e,n){return function(){return n===e}},Ae=function(e){var n=e.current;return{current:n,version:e.version,isEdge:ke("Edge",n),isChrome:ke("Chrome",n),isIE:ke("IE",n),isOpera:ke("Opera",n),isFirefox:ke(we,n),isSafari:ke("Safari",n)}},xe={unknown:function(){return Ae({current:undefined,version:De.unknown()})},nu:Ae,edge:P("Edge"),chrome:P("Chrome"),ie:P("IE"),opera:P("Opera"),firefox:P(we),safari:P("Safari")},Re="Windows",Ie="Android",_e="Solaris",Be="FreeBSD",Pe=function(e,n){return function(){return n===e}},Me=function(e){var n=e.current;return{current:n,version:e.version,isWindows:Pe(Re,n),isiOS:Pe("iOS",n),isAndroid:Pe(Ie,n),isOSX:Pe("OSX",n),isLinux:Pe("Linux",n),isSolaris:Pe(_e,n),isFreeBSD:Pe(Be,n)}},Ue={unknown:function(){return Me({current:undefined,version:De.unknown()})},nu:Me,windows:P(Re),ios:P("iOS"),android:P(Ie),linux:P("Linux"),osx:P("OSX"),solaris:P(_e),freebsd:P(Be)},Fe=function(e,n){var t=String(n).toLowerCase();return te(e,function(e){return e.search(t)})},je=function(e,t){return Fe(e,t).map(function(e){var n=De.detect(e.versionRegexes,t);return{current:e.name,version:n}})},He=function(e,t){return Fe(e,t).map(function(e){var n=De.detect(e.versionRegexes,t);return{current:e.name,version:n}})},$e=function(e,n){return-1!==e.indexOf(n)},qe=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,We=function(n){return function(e){return $e(e,n)}},Ve=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return $e(e,"edge/")&&$e(e,"chrome")&&$e(e,"safari")&&$e(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,qe],search:function(e){return $e(e,"chrome")&&!$e(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return $e(e,"msie")||$e(e,"trident")}},{name:"Opera",versionRegexes:[qe,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:We("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:We("firefox")},{name:"Safari",versionRegexes:[qe,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return($e(e,"safari")||$e(e,"mobile/"))&&$e(e,"applewebkit")}}],ze=[{name:"Windows",search:We("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return $e(e,"iphone")||$e(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:We("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:We("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:We("linux"),versionRegexes:[]},{name:"Solaris",search:We("sunos"),versionRegexes:[]},{name:"FreeBSD",search:We("freebsd"),versionRegexes:[]}],Ke={browsers:P(Ve),oses:P(ze)},Xe=function(e){var n,t,r,o,i,u,s,a,c,f,d,l=Ke.browsers(),m=Ke.oses(),g=je(l,e).fold(xe.unknown,xe.nu),p=He(m,e).fold(Ue.unknown,Ue.nu);return{browser:g,os:p,deviceType:(t=g,r=e,o=(n=p).isiOS()&&!0===/ipad/i.test(r),i=n.isiOS()&&!o,u=n.isAndroid()&&3===n.version.major,s=n.isAndroid()&&4===n.version.major,a=o||u||s&&!0===/mobile/i.test(r),c=n.isiOS()||n.isAndroid(),f=c&&!a,d=t.isSafari()&&n.isiOS()&&!1===/safari/i.test(r),{isiPad:P(o),isiPhone:P(i),isTablet:P(a),isPhone:P(f),isTouch:P(c),isAndroid:n.isAndroid,isiOS:n.isiOS,isWebView:P(d)})}},Qe={detect:(o=function(){var e=u.navigator.userAgent;return Xe(e)},s=!1,function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return s||(s=!0,i=o.apply(null,e)),i})},Ye=(u.Node.ATTRIBUTE_NODE,u.Node.CDATA_SECTION_NODE,u.Node.COMMENT_NODE,u.Node.DOCUMENT_NODE,u.Node.DOCUMENT_TYPE_NODE,u.Node.DOCUMENT_FRAGMENT_NODE,u.Node.ELEMENT_NODE),Ge=(u.Node.TEXT_NODE,u.Node.PROCESSING_INSTRUCTION_NODE,u.Node.ENTITY_REFERENCE_NODE,u.Node.ENTITY_NODE,u.Node.NOTATION_NODE,Ye),Je=function(e,n){return e.dom()===n.dom()},Ze=Qe.detect().browser.isIE()?function(e,n){return be(e.dom(),n.dom())}:function(e,n){var t=e.dom(),r=n.dom();return t!==r&&t.contains(r)},en=function(e,n){var t=e.dom();if(t.nodeType!==Ge)return!1;var r=t;if(r.matches!==undefined)return r.matches(n);if(r.msMatchesSelector!==undefined)return r.msMatchesSelector(n);if(r.webkitMatchesSelector!==undefined)return r.webkitMatchesSelector(n);if(r.mozMatchesSelector!==undefined)return r.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")},nn=function(e){return q.from(e.dom().parentNode).map(ye.fromDom)},tn=function(e){return J(e.dom().childNodes,ye.fromDom)},rn=function(e,n){var t=e.dom().childNodes;return q.from(t[n]).map(ye.fromDom)},on=function(e){return rn(e,0)},un=function(e){return rn(e,e.dom().childNodes.length-1)},sn=(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n]}("element","offset"),function(n,t){nn(n).each(function(e){e.dom().insertBefore(t.dom(),n.dom())})}),an=function(e,n){e.dom().appendChild(n.dom())},cn=function(n,e){Z(e,function(e){an(n,e)})},fn=function(e){var n=e.dom();null!==n.parentNode&&n.parentNode.removeChild(n)},dn=function(e){return e.dom().nodeName.toLowerCase()},ln=(a=Ye,function(e){return e.dom().nodeType===a}),mn=function(e,n){var t=e.dom();!function(e,n){for(var t=Se(e),r=0,o=t.length;r<o;r++){var i=t[r];n(e[i],i)}}(n,function(e,n){!function(e,n,t){if(!(V(t)||K(t)||Q(t)))throw u.console.error("Invalid call to Attr.set. Key ",n,":: Value ",t,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(n,t+"")}(t,n,e)})},gn=function(e){return ne(e.dom().attributes,function(e,n){return e[n.name]=n.value,e},{})},pn=function(e,n,t){if(!V(t))throw u.console.error("Invalid call to CSS.set. Property ",n,":: Value ",t,":: Element ",e),new Error("CSS value must be a string: "+t);var r;(r=e).style!==undefined&&X(r.style.getPropertyValue)&&e.style.setProperty(n,t)},vn=function(e){return n=e,t=!0,ye.fromDom(n.dom().cloneNode(t));var n,t},hn=function(e,n){var t,r,o,i,u=(t=e,r=n,o=ye.fromTag(r),i=gn(t),mn(o,i),o);sn(e,u);var s=tn(e);return cn(u,s),fn(e),u},yn=function(e,n){an(e.item,n.list)},Nn=function(f,e,d){var n=e.slice(0,d.depth);return ie(n).each(function(e){var n,t,r,o,i,u,s,a,c=(n=f,t=d.itemAttributes,r=d.content,o=ye.fromTag("li",n),mn(o,t),cn(o,r),o);u=c,an((i=e).list,u),i.item=u,a=d,dn((s=e).list)!==a.listType&&(s.list=hn(s.list,a.listType)),mn(s.list,a.listAttributes)}),n},Sn=function(e,n,t){var r,o=function(e,n,t){for(var r,o,i,u=[],s=0;s<t;s++)u.push((r=e,o=n.listType,i={list:ye.fromTag(o,r),item:ye.fromTag("li",r)},an(i.list,i.item),i));return u}(e,t,t.depth-n.length);return function(e){for(var n=1;n<e.length;n++)yn(e[n-1],e[n])}(o),function(e,n){for(var t=0;t<e.length-1;t++)r=e[t].item,o="list-style-type",i="none",u=r.dom(),pn(u,o,i);var r,o,i,u;ie(e).each(function(e){mn(e.list,n.listAttributes),mn(e.item,n.itemAttributes),cn(e.item,n.content)})}(o,t),r=o,Ne(ie(n),oe(r),yn),n.concat(o)},Cn=function(e){return en(e,"OL,UL")},On=function(e){return on(e).map(Cn).getOr(!1)},bn=function(e){return 0<e.depth},Tn=function(e){return e.isSelected},En=function(e){var n=tn(e),t=un(e).map(Cn).getOr(!1)?n.slice(0,-1):n;return J(t,vn)},Ln=Object.prototype.hasOwnProperty,Dn=(c=function(e,n){return n},function(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Can't merge zero objects");for(var t={},r=0;r<e.length;r++){var o=e[r];for(var i in o)Ln.call(o,i)&&(t[i]=c(t[i],o[i]))}return t}),wn=function(n){Z(n,function(r,e){(function(e,n){for(var t=e[n].depth,r=n-1;0<=r;r--){if(e[r].depth===t)return q.some(e[r]);if(e[r].depth<t)break}return q.none()})(n,e).each(function(e){var n,t;t=e,(n=r).listType=t.listType,n.listAttributes=Dn({},t.listAttributes)})})},kn=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return kn(t())}}},An=function(i,u,s,a){return on(a).filter(Cn).fold(function(){u.each(function(e){Je(e.start,a)&&s.set(!0)});var n,t,r,e=(n=a,t=i,r=s.get(),nn(n).filter(ln).map(function(e){return{depth:t,isSelected:r,content:En(n),itemAttributes:gn(n),listAttributes:gn(e),listType:dn(e)}}));u.each(function(e){Je(e.end,a)&&s.set(!1)});var o=un(a).filter(Cn).map(function(e){return xn(i,u,s,e)}).getOr([]);return e.toArray().concat(o)},function(e){return xn(i,u,s,e)})},xn=function(n,t,r,e){return re(tn(e),function(e){return(Cn(e)?xn:An)(n+1,t,r,e)})},Rn=tinymce.util.Tools.resolve("tinymce.Env"),In=function(e,n){var t,r,o,i,u=e.dom,s=e.schema.getBlockElements(),a=u.createFragment();if(e.settings.forced_root_block&&(o=e.settings.forced_root_block),o&&((r=u.create(o)).tagName===e.settings.forced_root_block&&u.setAttribs(r,e.settings.forced_root_block_attrs),L(n.firstChild,s)||a.appendChild(r)),n)for(;t=n.firstChild;){var c=t.nodeName;i||"SPAN"===c&&"bookmark"===t.getAttribute("data-mce-type")||(i=!0),L(t,s)?(a.appendChild(t),r=null):o?(r||(r=u.create(o),a.appendChild(r)),r.appendChild(t)):a.appendChild(t)}return e.settings.forced_root_block?i||Rn.ie&&!(10<Rn.ie)||r.appendChild(u.create("br",{"data-mce-bogus":"1"})):a.appendChild(u.create("br")),a},_n=function(i,e){return J(e,function(e){var n,t,r,o=(n=e.content,r=(t||u.document).createDocumentFragment(),Z(n,function(e){r.appendChild(e.dom())}),ye.fromDom(r));return ye.fromDom(In(i,o.dom()))})},Bn=function(e,n){return wn(n),(t=e.contentDocument,r=n,o=ne(r,function(e,n){return n.depth>e.length?Sn(t,e,n):Nn(t,e,n)},[]),oe(o).map(function(e){return e.list})).toArray();var t,r,o},Pn=function(e){var n,t,r=J(ve.getSelectedListItems(e),ye.fromDom);return Ne(te(r,M(On)),te((n=r,(t=Y.call(n,0)).reverse(),t),M(On)),function(e,n){return{start:e,end:n}})},Mn=function(s,e,a){var n,t,r,o=(n=e,t=Pn(s),r=kn(!1),J(n,function(e){return{sourceList:e,entries:xn(0,t,r,e)}}));Z(o,function(e){var n,t,r,o,i,u;n=e.entries,t=a,Z(ee(n,Tn),function(e){return function(e,n){switch(e){case"Indent":n.depth++;break;case"Outdent":n.depth--;break;case"Flatten":n.depth=0}}(t,e)}),r=e.sourceList,i=s,u=e.entries,o=re(function(e,n){if(0===e.length)return[];for(var t=n(e[0]),r=[],o=[],i=0,u=e.length;i<u;i++){var s=e[i],a=n(s);a!==t&&(r.push(o),o=[]),t=a,o.push(s)}return 0!==o.length&&r.push(o),r}(u,bn),function(e){return oe(e).map(bn).getOr(!1)?Bn(i,e):_n(i,e)}),Z(o,function(e){sn(r,e)}),fn(e.sourceList)})},Un=g.DOM,Fn=function(e,n,t){var r,o,i,u,s,a;for(i=Un.select('span[data-mce-type="bookmark"]',n),s=In(e,t),(r=Un.createRng()).setStartAfter(t),r.setEndAfter(n),u=(o=r.extractContents()).firstChild;u;u=u.firstChild)if("LI"===u.nodeName&&e.dom.isEmpty(u)){Un.remove(u);break}e.dom.isEmpty(o)||Un.insertAfter(o,n),Un.insertAfter(s,n),w(e.dom,t.parentNode)&&(a=t.parentNode,v.each(i,function(e){a.parentNode.insertBefore(e,t.parentNode)}),Un.remove(a)),Un.remove(t),w(e.dom,n)&&Un.remove(n)},jn=function(e){en(e,"dt")&&hn(e,"dd")},Hn=function(r,e,n){Z(n,"Indent"===e?jn:function(e){return n=r,void(en(t=e,"dd")?hn(t,"dt"):en(t,"dt")&&nn(t).each(function(e){return Fn(n,e.dom(),t.dom())}));var n,t})},$n=function(e,n){var t=J(ve.getSelectedListRoots(e),ye.fromDom),r=J(ve.getSelectedDlItems(e),ye.fromDom),o=!1;if(t.length||r.length){var i=e.selection.getBookmark();Mn(e,t,n),Hn(e,n,r),e.selection.moveToBookmark(i),e.selection.setRng(x(e.selection.getRng())),e.nodeChanged(),o=!0}return o},qn=function(e){return $n(e,"Indent")},Wn=function(e){return $n(e,"Outdent")},Vn=function(e){return $n(e,"Flatten")},zn=function(t,e){v.each(e,function(e,n){t.setAttribute(n,e)})},Kn=function(e,n,t){var r,o,i,u,s,a,c;r=e,o=n,u=(i=t)["list-style-type"]?i["list-style-type"]:null,r.setStyle(o,"list-style-type",u),s=e,zn(a=n,(c=t)["list-attributes"]),v.each(s.select("li",a),function(e){zn(e,c["list-item-attributes"])})},Xn=function(e,n,t,r){var o,i;for(o=n[t?"startContainer":"endContainer"],i=n[t?"startOffset":"endOffset"],1===o.nodeType&&(o=o.childNodes[Math.min(i,o.childNodes.length-1)]||o),!t&&T(o.nextSibling)&&(o=o.nextSibling);o.parentNode!==r;){if(E(e,o))return o;if(/^(TD|TH)$/.test(o.parentNode.nodeName))return o;o=o.parentNode}return o},Qn=function(f,d,l){void 0===l&&(l={});var e,n=f.selection.getRng(!0),m="LI",t=ve.getClosestListRootElm(f,f.selection.getStart(!0)),g=f.dom;"false"!==g.getContentEditable(f.selection.getNode())&&("DL"===(d=d.toUpperCase())&&(m="DT"),e=I(n),v.each(function(t,e,r){for(var o,i=[],u=t.dom,n=Xn(t,e,!0,r),s=Xn(t,e,!1,r),a=[],c=n;c&&(a.push(c),c!==s);c=c.nextSibling);return v.each(a,function(e){if(E(t,e))return i.push(e),void(o=null);if(u.isBlock(e)||T(e))return T(e)&&u.remove(e),void(o=null);var n=e.nextSibling;p.isBookmarkNode(e)&&(E(t,n)||!n&&e.parentNode===r)?o=null:(o||(o=u.create("p"),e.parentNode.insertBefore(o,e),i.push(o)),o.appendChild(e))}),i}(f,n,t),function(e){var n,t,r,o,i,u,s,a,c;(t=e.previousSibling)&&N(t)&&t.nodeName===d&&(r=t,o=l,i=g.getStyle(r,"list-style-type"),u=o?o["list-style-type"]:"",i===(u=null===u?"":u))?(n=t,e=g.rename(e,m),t.appendChild(e)):(n=g.create(d),e.parentNode.insertBefore(n,e),n.appendChild(e),e=g.rename(e,m)),s=g,a=e,c=["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],v.each(c,function(e){var n;return s.setStyle(a,((n={})[e]="",n))}),Kn(g,n,l),Gn(f.dom,n)}),f.selection.setRng(_(e)))},Yn=function(e,n,t){return a=t,(s=n)&&a&&N(s)&&s.nodeName===a.nodeName&&(i=n,u=t,(o=e).getStyle(i,"list-style-type",!0)===o.getStyle(u,"list-style-type",!0))&&(r=t,n.className===r.className);var r,o,i,u,s,a},Gn=function(e,n){var t,r;if(t=n.nextSibling,Yn(e,n,t)){for(;r=t.firstChild;)n.appendChild(r);e.remove(t)}if(t=n.previousSibling,Yn(e,n,t)){for(;r=t.lastChild;)n.insertBefore(r,n.firstChild);e.remove(t)}},Jn=function(n,e,t,r,o){if(e.nodeName!==r||Zn(o)){var i=I(n.selection.getRng(!0));v.each([e].concat(t),function(e){!function(e,n,t,r){if(n.nodeName!==t){var o=e.rename(n,t);Kn(e,o,r)}else Kn(e,n,r)}(n.dom,e,r,o)}),n.selection.setRng(_(i))}else Vn(n)},Zn=function(e){return"list-style-type"in e},et={toggleList:function(e,n,t){var r=ve.getParentList(e),o=ve.getSelectedSubLists(e);t=t||{},r&&0<o.length?Jn(e,r,o,n,t):function(e,n,t,r){if(n!==e.getBody())if(n)if(n.nodeName!==t||Zn(r)){var o=I(e.selection.getRng(!0));Kn(e.dom,n,r),Gn(e.dom,e.dom.rename(n,t)),e.selection.setRng(_(o))}else Vn(e);else Qn(e,t,r)}(e,r,n,t)},mergeWithAdjacentLists:Gn},nt=g.DOM,tt=function(e,n){var t,r=n.parentNode;"LI"===r.nodeName&&r.firstChild===n&&((t=r.previousSibling)&&"LI"===t.nodeName?(t.appendChild(n),w(e,r)&&nt.remove(r)):nt.setStyle(r,"listStyleType","none")),N(r)&&(t=r.previousSibling)&&"LI"===t.nodeName&&t.appendChild(n)},rt=function(n,e){v.each(v.grep(n.select("ol,ul",e)),function(e){tt(n,e)})},ot=function(e,n,t,r){var o,i,u=n.startContainer,s=n.startOffset;if(3===u.nodeType&&(t?s<u.data.length:0<s))return u;for(o=e.schema.getNonEmptyElements(),1===u.nodeType&&(u=d.getNode(u,s)),i=new l(u,r),t&&D(e.dom,u)&&i.next();u=i[t?"next":"prev2"]();){if("LI"===u.nodeName&&!u.hasChildNodes())return u;if(o[u.nodeName])return u;if(3===u.nodeType&&0<u.data.length)return u}},it=function(e,n){var t=n.childNodes;return 1===t.length&&!N(t[0])&&e.isBlock(t[0])},ut=function(e,n,t){var r,o,i,u;if(o=it(e,t)?t.firstChild:t,it(i=e,u=n)&&i.remove(u.firstChild,!0),!w(e,n,!0))for(;r=n.firstChild;)o.appendChild(r)},st=function(n,e,t){var r,o,i=e.parentNode;if(k(n,e)&&k(n,t)){N(t.lastChild)&&(o=t.lastChild),i===t.lastChild&&T(i.previousSibling)&&n.remove(i.previousSibling),(r=t.lastChild)&&T(r)&&e.hasChildNodes()&&n.remove(r),w(n,t,!0)&&n.$(t).empty(),ut(n,e,t),o&&t.appendChild(o);var u=Ze(ye.fromDom(t),ye.fromDom(e))?n.getParents(e,N,t):[];n.remove(e),Z(u,function(e){w(n,e)&&e!==n.getRoot()&&n.remove(e)})}},at=function(e,n,t,r){var o,i,u,s=e.dom;if(s.isEmpty(r))i=t,u=r,(o=e).dom.$(u).empty(),st(o.dom,i,u),o.selection.setCursorLocation(u);else{var a=I(n);st(s,t,r),e.selection.setRng(_(a))}},ct=function(e,n){var t,r,o,i=e.dom,u=e.selection,s=u.getStart(),a=ve.getClosestListRootElm(e,s),c=i.getParent(u.getStart(),"LI",a);if(c){if((t=c.parentNode)===e.getBody()&&w(i,t))return!0;if(r=x(u.getRng(!0)),(o=i.getParent(ot(e,r,n,a),"LI",a))&&o!==c)return n?at(e,r,o,c):function(e,n,t,r){var o=I(n);st(e.dom,t,r);var i=_(o);e.selection.setRng(i)}(e,r,c,o),!0;if(!o&&!n)return Vn(e),!0}return!1},ft=function(e,n){return ct(e,n)||function(o,i){var u=o.dom,e=o.selection.getStart(),s=ve.getClosestListRootElm(o,e),a=u.getParent(e,u.isBlock,s);if(a&&u.isEmpty(a)){var n=x(o.selection.getRng(!0)),c=u.getParent(ot(o,n,i,s),"LI",s);if(c)return o.undoManager.transact(function(){var e,n,t,r;n=a,t=s,r=(e=u).getParent(n.parentNode,e.isBlock,t),e.remove(n),r&&e.isEmpty(r)&&e.remove(r),et.mergeWithAdjacentLists(u,c.parentNode),o.selection.select(c,!0),o.selection.collapse(i)}),!0}return!1}(e,n)},dt=function(e,n){return e.selection.isCollapsed()?ft(e,n):(r=(t=e).selection.getStart(),o=ve.getClosestListRootElm(t,r),!!(t.dom.getParent(r,"LI,DT,DD",o)||0<ve.getSelectedListItems(t).length)&&(t.undoManager.transact(function(){t.execCommand("Delete"),rt(t.dom,t.getBody())}),!0));var t,r,o},lt=function(n){n.on("keydown",function(e){e.keyCode===m.BACKSPACE?dt(n,!1)&&e.preventDefault():e.keyCode===m.DELETE&&dt(n,!0)&&e.preventDefault()})},mt=dt,gt=function(n){return{backspaceDelete:function(e){mt(n,e)}}},pt=function(n,t){return function(){var e=n.dom.getParent(n.selection.getStart(),"UL,OL,DL");return e&&e.nodeName===t}},vt=function(t){t.on("BeforeExecCommand",function(e){var n=e.command.toLowerCase();"indent"===n?qn(t):"outdent"===n&&Wn(t)}),t.addCommand("InsertUnorderedList",function(e,n){et.toggleList(t,"UL",n)}),t.addCommand("InsertOrderedList",function(e,n){et.toggleList(t,"OL",n)}),t.addCommand("InsertDefinitionList",function(e,n){et.toggleList(t,"DL",n)}),t.addCommand("RemoveList",function(){Vn(t)}),t.addQueryStateHandler("InsertUnorderedList",pt(t,"UL")),t.addQueryStateHandler("InsertOrderedList",pt(t,"OL")),t.addQueryStateHandler("InsertDefinitionList",pt(t,"DL"))},ht=function(e){return e.getParam("lists_indent_on_tab",!0)},yt=function(e){var n;ht(e)&&(n=e).on("keydown",function(e){e.keyCode!==m.TAB||m.metaKeyPressed(e)||n.undoManager.transact(function(){(e.shiftKey?Wn(n):qn(n))&&e.preventDefault()})}),lt(e)},Nt=function(n,i){return function(e){var o=e.control;n.on("NodeChange",function(e){var n=function(e,n){for(var t=0;t<e.length;t++)if(n(e[t]))return t;return-1}(e.parents,b),t=-1!==n?e.parents.slice(0,n):e.parents,r=v.grep(t,N);o.active(0<r.length&&r[0].nodeName===i)})}},St=function(e){var n,t,r;t="advlist",r=(n=e).settings.plugins?n.settings.plugins:"",-1===v.inArray(r.split(/[ ,]/),t)&&(e.addButton("numlist",{active:!1,title:"Numbered list",cmd:"InsertOrderedList",onPostRender:Nt(e,"OL")}),e.addButton("bullist",{active:!1,title:"Bullet list",cmd:"InsertUnorderedList",onPostRender:Nt(e,"UL")})),e.addButton("indent",{icon:"indent",title:"Increase indent",cmd:"Indent"})};f.add("lists",function(e){return yt(e),St(e),vt(e),gt(e)})}(window);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/media/plugin.js b/wp-includes/js/tinymce/plugins/media/plugin.js new file mode 100644 index 0000000..dffa0fe --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/plugin.js @@ -0,0 +1,1306 @@ +(function () { +var media = (function () { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var getScripts = function (editor) { + return editor.getParam('media_scripts'); + }; + var getAudioTemplateCallback = function (editor) { + return editor.getParam('audio_template_callback'); + }; + var getVideoTemplateCallback = function (editor) { + return editor.getParam('video_template_callback'); + }; + var hasLiveEmbeds = function (editor) { + return editor.getParam('media_live_embeds', true); + }; + var shouldFilterHtml = function (editor) { + return editor.getParam('media_filter_html', true); + }; + var getUrlResolver = function (editor) { + return editor.getParam('media_url_resolver'); + }; + var hasAltSource = function (editor) { + return editor.getParam('media_alt_source', true); + }; + var hasPoster = function (editor) { + return editor.getParam('media_poster', true); + }; + var hasDimensions = function (editor) { + return editor.getParam('media_dimensions', true); + }; + var Settings = { + getScripts: getScripts, + getAudioTemplateCallback: getAudioTemplateCallback, + getVideoTemplateCallback: getVideoTemplateCallback, + hasLiveEmbeds: hasLiveEmbeds, + shouldFilterHtml: shouldFilterHtml, + getUrlResolver: getUrlResolver, + hasAltSource: hasAltSource, + hasPoster: hasPoster, + hasDimensions: hasDimensions + }; + + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; + }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; + }; + + var noop = function () { + }; + var constant = function (value) { + return function () { + return value; + }; + }; + var never = constant(false); + var always = constant(true); + + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never, + isSome: never, + isNone: always, + getOr: id, + getOrThunk: call, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: constant(null), + getOrUndefined: constant(undefined), + or: id, + orThunk: call, + map: none, + each: noop, + bind: none, + exists: never, + forall: always, + filter: none, + equals: eq, + equals_: eq, + toArray: function () { + return []; + }, + toString: constant('none()') + }; + if (Object.freeze) { + Object.freeze(me); + } + return me; + }(); + var some = function (a) { + var constant_a = constant(a); + var self = function () { + return me; + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always, + isNone: never, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: function (f) { + return some(f(a)); + }, + each: function (f) { + f(a); + }, + bind: bind, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never, function (b) { + return elementEq(a, b); + }); + } + }; + return me; + }; + var from = function (value) { + return value === null || value === undefined ? NONE : some(value); + }; + var Option = { + some: some, + none: none, + from: from + }; + + var hasOwnProperty = Object.hasOwnProperty; + var get = function (obj, key) { + return has(obj, key) ? Option.from(obj[key]) : Option.none(); + }; + var has = function (obj, key) { + return hasOwnProperty.call(obj, key); + }; + + var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var global$4 = tinymce.util.Tools.resolve('tinymce.html.SaxParser'); + + var getVideoScriptMatch = function (prefixes, src) { + if (prefixes) { + for (var i = 0; i < prefixes.length; i++) { + if (src.indexOf(prefixes[i].filter) !== -1) { + return prefixes[i]; + } + } + } + }; + var VideoScript = { getVideoScriptMatch: getVideoScriptMatch }; + + var DOM = global$3.DOM; + var trimPx = function (value) { + return value.replace(/px$/, ''); + }; + var getEphoxEmbedData = function (attrs) { + var style = attrs.map.style; + var styles = style ? DOM.parseStyle(style) : {}; + return { + type: 'ephox-embed-iri', + source1: attrs.map['data-ephox-embed-iri'], + source2: '', + poster: '', + width: get(styles, 'max-width').map(trimPx).getOr(''), + height: get(styles, 'max-height').map(trimPx).getOr('') + }; + }; + var htmlToData = function (prefixes, html) { + var isEphoxEmbed = Cell(false); + var data = {}; + global$4({ + validate: false, + allow_conditional_comments: true, + special: 'script,noscript', + start: function (name, attrs) { + if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) { + isEphoxEmbed.set(true); + data = getEphoxEmbedData(attrs); + } else { + 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 = global$2.extend(attrs.map, data); + } + if (name === 'script') { + var videoScript = VideoScript.getVideoScriptMatch(prefixes, 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; + }; + var HtmlToData = { htmlToData: htmlToData }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.util.Promise'); + + var guess = function (url) { + var mimes = { + mp3: 'audio/mpeg', + wav: 'audio/wav', + mp4: 'video/mp4', + webm: 'video/webm', + ogg: 'video/ogg', + swf: 'application/x-shockwave-flash' + }; + var fileEnd = url.toLowerCase().split('.').pop(); + var mime = mimes[fileEnd]; + return mime ? mime : ''; + }; + var Mime = { guess: guess }; + + var global$6 = tinymce.util.Tools.resolve('tinymce.html.Schema'); + + var global$7 = tinymce.util.Tools.resolve('tinymce.html.Writer'); + + var DOM$1 = global$3.DOM; + var addPx = function (value) { + return /^[0-9.]+$/.test(value) ? value + 'px' : value; + }; + var setAttributes = function (attrs, updatedAttrs) { + for (var name in updatedAttrs) { + var value = '' + updatedAttrs[name]; + if (attrs.map[name]) { + var i = attrs.length; + while (i--) { + var 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; + } + } + }; + var updateEphoxEmbed = function (data, attrs) { + var style = attrs.map.style; + var styleMap = style ? DOM$1.parseStyle(style) : {}; + styleMap['max-width'] = addPx(data.width); + styleMap['max-height'] = addPx(data.height); + setAttributes(attrs, { style: DOM$1.serializeStyle(styleMap) }); + }; + var updateHtml = function (html, data, updateAll) { + var writer = global$7(); + var isEphoxEmbed = Cell(false); + var sourceCount = 0; + var hasImage; + global$4({ + 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) { + if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) { + isEphoxEmbed.set(true); + updateEphoxEmbed(data, attrs); + } else { + switch (name) { + case 'video': + case 'object': + case 'embed': + case 'img': + case 'iframe': + if (data.height !== undefined && data.width !== undefined) { + 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 (!isEphoxEmbed.get()) { + 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); + } + }, global$6({})).parse(html); + return writer.getContent(); + }; + var UpdateHtml = { updateHtml: updateHtml }; + + var urlPatterns = [ + { + regex: /youtu\.be\/([\w\-_\?&=.]+)/i, + type: 'iframe', + w: 560, + h: 314, + url: '//www.youtube.com/embed/$1', + allowFullscreen: true + }, + { + regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i, + type: 'iframe', + w: 560, + h: 314, + url: '//www.youtube.com/embed/$2?$4', + allowFullscreen: true + }, + { + regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i, + type: 'iframe', + w: 560, + h: 314, + url: '//www.youtube.com/embed/$1', + 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 + }, + { + regex: /dailymotion\.com\/video\/([^_]+)/, + type: 'iframe', + w: 480, + h: 270, + url: '//www.dailymotion.com/embed/video/$1', + allowFullscreen: true + }, + { + regex: /dai\.ly\/([^_]+)/, + type: 'iframe', + w: 480, + h: 270, + url: '//www.dailymotion.com/embed/video/$1', + allowFullscreen: true + } + ]; + var getUrl = function (pattern, url) { + var match = pattern.regex.exec(url); + var newUrl = pattern.url; + var _loop_1 = function (i) { + newUrl = newUrl.replace('$' + i, function () { + return match[i] ? match[i] : ''; + }); + }; + for (var i = 0; i < match.length; i++) { + _loop_1(i); + } + return newUrl.replace(/\?$/, ''); + }; + var matchPattern = function (url) { + var pattern = urlPatterns.filter(function (pattern) { + return pattern.regex.test(url); + }); + if (pattern.length > 0) { + return global$2.extend({}, pattern[0], { url: getUrl(pattern[0], url) }); + } else { + return null; + } + }; + + var getIframeHtml = function (data) { + var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : ''; + return '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>'; + }; + var getFlashHtml = function (data) { + var 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>'; + return html; + }; + var getAudioHtml = function (data, audioTemplateCallback) { + if (audioTemplateCallback) { + return audioTemplateCallback(data); + } else { + return '<audio controls="controls" src="' + data.source1 + '">' + (data.source2 ? '\n<source src="' + data.source2 + '"' + (data.source2mime ? ' type="' + data.source2mime + '"' : '') + ' />\n' : '') + '</audio>'; + } + }; + var getVideoHtml = function (data, videoTemplateCallback) { + if (videoTemplateCallback) { + return videoTemplateCallback(data); + } else { + return '<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>'; + } + }; + var getScriptHtml = function (data) { + return '<script src="' + data.source1 + '"></script>'; + }; + var dataToHtml = function (editor, dataIn) { + var data = global$2.extend({}, dataIn); + if (!data.source1) { + global$2.extend(data, HtmlToData.htmlToData(Settings.getScripts(editor), 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 = Mime.guess(data.source1); + data.source2mime = Mime.guess(data.source2); + data.poster = editor.convertURL(data.poster, 'poster'); + var pattern = matchPattern(data.source1); + if (pattern) { + data.source1 = pattern.url; + data.type = pattern.type; + data.allowFullscreen = pattern.allowFullscreen; + data.width = data.width || pattern.w; + data.height = data.height || pattern.h; + } + if (data.embed) { + return UpdateHtml.updateHtml(data.embed, data, true); + } else { + var videoScript = VideoScript.getVideoScriptMatch(Settings.getScripts(editor), data.source1); + if (videoScript) { + data.type = 'script'; + data.width = videoScript.width; + data.height = videoScript.height; + } + var audioTemplateCallback = Settings.getAudioTemplateCallback(editor); + var videoTemplateCallback = Settings.getVideoTemplateCallback(editor); + data.width = data.width || 300; + data.height = data.height || 150; + global$2.each(data, function (value, key) { + data[key] = editor.dom.encode(value); + }); + if (data.type === 'iframe') { + return getIframeHtml(data); + } else if (data.source1mime === 'application/x-shockwave-flash') { + return getFlashHtml(data); + } else if (data.source1mime.indexOf('audio') !== -1) { + return getAudioHtml(data, audioTemplateCallback); + } else if (data.type === 'script') { + return getScriptHtml(data); + } else { + return getVideoHtml(data, videoTemplateCallback); + } + } + }; + var DataToHtml = { dataToHtml: dataToHtml }; + + var cache = {}; + var embedPromise = function (data, dataToHtml, handler) { + return new global$5(function (res, rej) { + var wrappedResolve = function (response) { + if (response.html) { + cache[data.source1] = response; + } + return res({ + url: data.source1, + html: response.html ? response.html : dataToHtml(data) + }); + }; + if (cache[data.source1]) { + wrappedResolve(cache[data.source1]); + } else { + handler({ url: data.source1 }, wrappedResolve, rej); + } + }); + }; + var defaultPromise = function (data, dataToHtml) { + return new global$5(function (res) { + res({ + html: dataToHtml(data), + url: data.source1 + }); + }); + }; + var loadedData = function (editor) { + return function (data) { + return DataToHtml.dataToHtml(editor, data); + }; + }; + var getEmbedHtml = function (editor, data) { + var embedHandler = Settings.getUrlResolver(editor); + return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor)); + }; + var isCached = function (url) { + return cache.hasOwnProperty(url); + }; + var Service = { + getEmbedHtml: getEmbedHtml, + isCached: isCached + }; + + var trimPx$1 = function (value) { + return value.replace(/px$/, ''); + }; + var addPx$1 = function (value) { + return /^[0-9.]+$/.test(value) ? value + 'px' : value; + }; + var getSize = function (name) { + return function (elm) { + return elm ? trimPx$1(elm.style[name]) : ''; + }; + }; + var setSize = function (name) { + return function (elm, value) { + if (elm) { + elm.style[name] = addPx$1(value); + } + }; + }; + var Size = { + getMaxWidth: getSize('maxWidth'), + getMaxHeight: getSize('maxHeight'), + setMaxWidth: setSize('maxWidth'), + setMaxHeight: setSize('maxHeight') + }; + + var doSyncSize = function (widthCtrl, heightCtrl) { + widthCtrl.state.set('oldVal', widthCtrl.value()); + heightCtrl.state.set('oldVal', heightCtrl.value()); + }; + var doSizeControls = function (win, f) { + var widthCtrl = win.find('#width')[0]; + var heightCtrl = win.find('#height')[0]; + var constrained = win.find('#constrain')[0]; + if (widthCtrl && heightCtrl && constrained) { + f(widthCtrl, heightCtrl, constrained.checked()); + } + }; + var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { + var oldWidth = widthCtrl.state.get('oldVal'); + var oldHeight = heightCtrl.state.get('oldVal'); + var newWidth = widthCtrl.value(); + var newHeight = heightCtrl.value(); + if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { + if (newWidth !== oldWidth) { + newHeight = Math.round(newWidth / oldWidth * newHeight); + if (!isNaN(newHeight)) { + heightCtrl.value(newHeight); + } + } else { + newWidth = Math.round(newHeight / oldHeight * newWidth); + if (!isNaN(newWidth)) { + widthCtrl.value(newWidth); + } + } + } + doSyncSize(widthCtrl, heightCtrl); + }; + var syncSize = function (win) { + doSizeControls(win, doSyncSize); + }; + var updateSize = function (win) { + doSizeControls(win, doUpdateSize); + }; + var createUi = function (onChange) { + var recalcSize = function () { + onChange(function (win) { + updateSize(win); + }); + }; + return { + type: 'container', + label: 'Dimensions', + layout: 'flex', + align: 'center', + spacing: 5, + items: [ + { + name: 'width', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Width' + }, + { + type: 'label', + text: 'x' + }, + { + name: 'height', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Height' + }, + { + name: 'constrain', + type: 'checkbox', + checked: true, + text: 'Constrain proportions' + } + ] + }; + }; + var SizeManager = { + createUi: createUi, + syncSize: syncSize, + updateSize: updateSize + }; + + var embedChange = global$1.ie && global$1.ie <= 8 ? 'onChange' : 'onInput'; + var handleError = function (editor) { + return function (error) { + var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.'; + editor.notificationManager.open({ + type: 'error', + text: errorMessage + }); + }; + }; + var getData = function (editor) { + var element = editor.selection.getNode(); + var dataEmbed = element.getAttribute('data-ephox-embed-iri'); + if (dataEmbed) { + return { + 'source1': dataEmbed, + 'data-ephox-embed-iri': dataEmbed, + 'width': Size.getMaxWidth(element), + 'height': Size.getMaxHeight(element) + }; + } + return element.getAttribute('data-mce-object') ? HtmlToData.htmlToData(Settings.getScripts(editor), editor.serializer.serialize(element, { selection: true })) : {}; + }; + var getSource = function (editor) { + var elm = editor.selection.getNode(); + if (elm.getAttribute('data-mce-object') || elm.getAttribute('data-ephox-embed-iri')) { + return editor.selection.getContent(); + } + }; + var addEmbedHtml = function (win, editor) { + return function (response) { + var html = response.html; + var embed = win.find('#embed')[0]; + var data = global$2.extend(HtmlToData.htmlToData(Settings.getScripts(editor), html), { source1: response.url }); + win.fromJSON(data); + if (embed) { + embed.value(html); + SizeManager.updateSize(win); + } + }; + }; + var selectPlaceholder = function (editor, beforeObjects) { + var i; + var y; + var afterObjects = editor.dom.select('img[data-mce-object]'); + 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]); + }; + var handleInsert = function (editor, html) { + var beforeObjects = editor.dom.select('img[data-mce-object]'); + editor.insertContent(html); + selectPlaceholder(editor, beforeObjects); + editor.nodeChanged(); + }; + var submitForm = function (win, editor) { + var data = win.toJSON(); + data.embed = UpdateHtml.updateHtml(data.embed, data); + if (data.embed && Service.isCached(data.source1)) { + handleInsert(editor, data.embed); + } else { + Service.getEmbedHtml(editor, data).then(function (response) { + handleInsert(editor, response.html); + }).catch(handleError(editor)); + } + }; + var populateMeta = function (win, meta) { + global$2.each(meta, function (value, key) { + win.find('#' + key).value(value); + }); + }; + var showDialog = function (editor) { + var win; + var data; + var generalFormItems = [{ + name: 'source1', + type: 'filepicker', + filetype: 'media', + size: 40, + autofocus: true, + label: 'Source', + onpaste: function () { + setTimeout(function () { + Service.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); + }, 1); + }, + onchange: function (e) { + Service.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); + populateMeta(win, e.meta); + }, + onbeforecall: function (e) { + e.meta = win.toJSON(); + } + }]; + var advancedFormItems = []; + var reserialise = function (update) { + update(win); + data = win.toJSON(); + win.find('#embed').value(UpdateHtml.updateHtml(data.embed, data)); + }; + if (Settings.hasAltSource(editor)) { + advancedFormItems.push({ + name: 'source2', + type: 'filepicker', + filetype: 'media', + size: 40, + label: 'Alternative source' + }); + } + if (Settings.hasPoster(editor)) { + advancedFormItems.push({ + name: 'poster', + type: 'filepicker', + filetype: 'image', + size: 40, + label: 'Poster' + }); + } + if (Settings.hasDimensions(editor)) { + var control = SizeManager.createUi(reserialise); + generalFormItems.push(control); + } + data = getData(editor); + var embedTextBox = { + id: 'mcemediasource', + type: 'textbox', + flex: 1, + name: 'embed', + value: getSource(editor), + multiline: true, + rows: 5, + label: 'Source' + }; + var updateValueOnChange = function () { + data = global$2.extend({}, HtmlToData.htmlToData(Settings.getScripts(editor), this.value())); + this.parent().parent().fromJSON(data); + }; + embedTextBox[embedChange] = updateValueOnChange; + var body = [ + { + title: 'General', + type: 'form', + items: generalFormItems + }, + { + title: 'Embed', + type: 'container', + layout: 'flex', + direction: 'column', + align: 'stretch', + padding: 10, + spacing: 10, + items: [ + { + type: 'label', + text: 'Paste your embed code below:', + forId: 'mcemediasource' + }, + embedTextBox + ] + } + ]; + if (advancedFormItems.length > 0) { + body.push({ + title: 'Advanced', + type: 'form', + items: advancedFormItems + }); + } + win = editor.windowManager.open({ + title: 'Insert/edit media', + data: data, + bodyType: 'tabpanel', + body: body, + onSubmit: function () { + SizeManager.updateSize(win); + submitForm(win, editor); + } + }); + SizeManager.syncSize(win); + }; + var Dialog = { showDialog: showDialog }; + + var get$1 = function (editor) { + var showDialog = function () { + Dialog.showDialog(editor); + }; + return { showDialog: showDialog }; + }; + var Api = { get: get$1 }; + + var register = function (editor) { + var showDialog = function () { + Dialog.showDialog(editor); + }; + editor.addCommand('mceMedia', showDialog); + }; + var Commands = { register: register }; + + var global$8 = tinymce.util.Tools.resolve('tinymce.html.Node'); + + var sanitize = function (editor, html) { + if (Settings.shouldFilterHtml(editor) === false) { + return html; + } + var writer = global$7(); + var blocked; + global$4({ + 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' || name === 'svg') { + return; + } + for (var i = attrs.length - 1; i >= 0; i--) { + var attrName = attrs[i].name; + if (attrName.indexOf('on') === 0) { + delete attrs.map[attrName]; + attrs.splice(i, 1); + } + if (attrName === '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); + } + }, global$6({})).parse(html); + return writer.getContent(); + }; + var Sanitize = { sanitize: sanitize }; + + var createPlaceholderNode = function (editor, node) { + var placeHolder; + var name = node.name; + placeHolder = new global$8('img', 1); + placeHolder.shortEnded = true; + retainAttributesAndInnerHtml(editor, node, placeHolder); + placeHolder.attr({ + 'width': node.attr('width') || '300', + 'height': node.attr('height') || (name === 'audio' ? '30' : '150'), + 'style': node.attr('style'), + 'src': global$1.transparentSrc, + 'data-mce-object': name, + 'class': 'mce-object mce-object-' + name + }); + return placeHolder; + }; + var createPreviewIframeNode = function (editor, node) { + var previewWrapper; + var previewNode; + var shimNode; + var name = node.name; + previewWrapper = new global$8('span', 1); + previewWrapper.attr({ + 'contentEditable': 'false', + 'style': node.attr('style'), + 'data-mce-object': name, + 'class': 'mce-preview-object mce-object-' + name + }); + retainAttributesAndInnerHtml(editor, node, previewWrapper); + previewNode = new global$8(name, 1); + previewNode.attr({ + src: node.attr('src'), + allowfullscreen: node.attr('allowfullscreen'), + style: node.attr('style'), + class: node.attr('class'), + width: node.attr('width'), + height: node.attr('height'), + frameborder: '0' + }); + shimNode = new global$8('span', 1); + shimNode.attr('class', 'mce-shim'); + previewWrapper.append(previewNode); + previewWrapper.append(shimNode); + return previewWrapper; + }; + var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) { + var attrName; + var attrValue; + var attribs; + var ai; + var innerHtml; + attribs = sourceNode.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); + } + targetNode.attr('data-mce-p-' + attrName, attrValue); + } + } + innerHtml = sourceNode.firstChild && sourceNode.firstChild.value; + if (innerHtml) { + targetNode.attr('data-mce-html', escape(Sanitize.sanitize(editor, innerHtml))); + targetNode.firstChild = null; + } + }; + var isWithinEphoxEmbed = function (node) { + while (node = node.parent) { + if (node.attr('data-ephox-embed-iri')) { + return true; + } + } + return false; + }; + var placeHolderConverter = function (editor) { + return function (nodes) { + var i = nodes.length; + var node; + var videoScript; + while (i--) { + node = nodes[i]; + if (!node.parent) { + continue; + } + if (node.parent.attr('data-mce-object')) { + continue; + } + if (node.name === 'script') { + videoScript = VideoScript.getVideoScriptMatch(Settings.getScripts(editor), node.attr('src')); + if (!videoScript) { + continue; + } + } + if (videoScript) { + if (videoScript.width) { + node.attr('width', videoScript.width.toString()); + } + if (videoScript.height) { + node.attr('height', videoScript.height.toString()); + } + } + if (node.name === 'iframe' && Settings.hasLiveEmbeds(editor) && global$1.ceFalse) { + if (!isWithinEphoxEmbed(node)) { + node.replace(createPreviewIframeNode(editor, node)); + } + } else { + if (!isWithinEphoxEmbed(node)) { + node.replace(createPlaceholderNode(editor, node)); + } + } + } + }; + }; + var Nodes = { + createPreviewIframeNode: createPreviewIframeNode, + createPlaceholderNode: createPlaceholderNode, + placeHolderConverter: placeHolderConverter + }; + + var setup = function (editor) { + editor.on('preInit', function () { + var specialElements = editor.schema.getSpecialElements(); + global$2.each('video audio iframe object'.split(' '), function (name) { + specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi'); + }); + var boolAttrs = editor.schema.getBoolAttrs(); + global$2.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) { + boolAttrs[name] = {}; + }); + editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', Nodes.placeHolderConverter(editor)); + editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) { + var i = nodes.length; + var node; + var realElm; + var ai; + var attribs; + var innerHtml; + var innerNode; + var realElmName; + var className; + while (i--) { + node = nodes[i]; + if (!node.parent) { + continue; + } + realElmName = node.attr(name); + realElm = new global$8(realElmName, 1); + if (realElmName !== 'audio' && realElmName !== 'script') { + className = node.attr('class'); + if (className && className.indexOf('mce-preview-object') !== -1) { + realElm.attr({ + width: node.firstChild.attr('width'), + height: node.firstChild.attr('height') + }); + } else { + realElm.attr({ + width: node.attr('width'), + height: node.attr('height') + }); + } + } + realElm.attr({ style: node.attr('style') }); + 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'); + } + innerHtml = node.attr('data-mce-html'); + if (innerHtml) { + innerNode = new global$8('#text', 3); + innerNode.raw = true; + innerNode.value = Sanitize.sanitize(editor, unescape(innerHtml)); + realElm.append(innerNode); + } + node.replace(realElm); + } + }); + }); + editor.on('setContent', function () { + editor.$('span.mce-preview-object').each(function (index, elm) { + var $elm = editor.$(elm); + if ($elm.find('span.mce-shim', elm).length === 0) { + $elm.append('<span class="mce-shim"></span>'); + } + }); + }); + }; + var FilterContent = { setup: setup }; + + var setup$1 = function (editor) { + editor.on('ResolveName', function (e) { + var name; + if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { + e.name = name; + } + }); + }; + var ResolveName = { setup: setup$1 }; + + var setup$2 = function (editor) { + editor.on('click keyup', function () { + var selectedNode = editor.selection.getNode(); + if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { + if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { + selectedNode.setAttribute('data-mce-selected', '2'); + } + } + }); + 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; + var 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.updateHtml(html, { + width: e.width, + height: e.height + }))); + } + } + }); + }; + var Selection = { setup: setup$2 }; + + var register$1 = function (editor) { + editor.addButton('media', { + tooltip: 'Insert/edit media', + cmd: 'mceMedia', + stateSelector: [ + 'img[data-mce-object]', + 'span[data-mce-object]', + 'div[data-ephox-embed-iri]' + ] + }); + editor.addMenuItem('media', { + icon: 'media', + text: 'Media', + cmd: 'mceMedia', + context: 'insert', + prependToContext: true + }); + }; + var Buttons = { register: register$1 }; + + global.add('media', function (editor) { + Commands.register(editor); + Buttons.register(editor); + ResolveName.setup(editor); + FilterContent.setup(editor); + Selection.setup(editor); + return Api.get(editor); + }); + function Plugin () { + } + + return Plugin; + +}()); +})(); diff --git a/wp-includes/js/tinymce/plugins/media/plugin.min.js b/wp-includes/js/tinymce/plugins/media/plugin.min.js new file mode 100644 index 0000000..e78d8ef --- /dev/null +++ b/wp-includes/js/tinymce/plugins/media/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var e,t,r,n,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),o=tinymce.util.Tools.resolve("tinymce.Env"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),w=function(e){return e.getParam("media_scripts")},b=function(e){return e.getParam("audio_template_callback")},y=function(e){return e.getParam("video_template_callback")},a=function(e){return e.getParam("media_live_embeds",!0)},u=function(e){return e.getParam("media_filter_html",!0)},s=function(e){return e.getParam("media_url_resolver")},m=function(e){return e.getParam("media_alt_source",!0)},d=function(e){return e.getParam("media_poster",!0)},h=function(e){return e.getParam("media_dimensions",!0)},f=function(e){var t=e,r=function(){return t};return{get:r,set:function(e){t=e},clone:function(){return f(r())}}},c=function(){},l=function(e){return function(){return e}},p=l(!1),g=l(!0),x=function(){return O},O=(e=function(e){return e.isNone()},n={fold:function(e,t){return e()},is:p,isSome:p,isNone:g,getOr:r=function(e){return e},getOrThunk:t=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:l(null),getOrUndefined:l(undefined),or:r,orThunk:t,map:x,each:c,bind:x,exists:p,forall:g,filter:x,equals:e,equals_:e,toArray:function(){return[]},toString:l("none()")},Object.freeze&&Object.freeze(n),n),j=function(r){var e=l(r),t=function(){return i},n=function(e){return e(r)},i={fold:function(e,t){return t(r)},is:function(e){return r===e},isSome:g,isNone:p,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return j(e(r))},each:function(e){e(r)},bind:n,exists:n,forall:n,filter:function(e){return e(r)?i:O},toArray:function(){return[r]},toString:function(){return"some("+r+")"},equals:function(e){return e.is(r)},equals_:function(e,t){return e.fold(p,function(e){return t(r,e)})}};return i},_=x,S=function(e){return null===e||e===undefined?O:j(e)},k=Object.hasOwnProperty,N=function(e,t){return M(e,t)?S(e[t]):_()},M=function(e,t){return k.call(e,t)},T=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),z=tinymce.util.Tools.resolve("tinymce.html.SaxParser"),A=function(e,t){if(e)for(var r=0;r<e.length;r++)if(-1!==t.indexOf(e[r].filter))return e[r]},C=T.DOM,$=function(e){return e.replace(/px$/,"")},P=function(a,e){var c=f(!1),u={};return z({validate:!1,allow_conditional_comments:!0,special:"script,noscript",start:function(e,t){if(c.get());else if(M(t.map,"data-ephox-embed-iri"))c.set(!0),i=(n=t).map.style,o=i?C.parseStyle(i):{},u={type:"ephox-embed-iri",source1:n.map["data-ephox-embed-iri"],source2:"",poster:"",width:N(o,"max-width").map($).getOr(""),height:N(o,"max-height").map($).getOr("")};else{if(u.source1||"param"!==e||(u.source1=t.map.movie),"iframe"!==e&&"object"!==e&&"embed"!==e&&"video"!==e&&"audio"!==e||(u.type||(u.type=e),u=v.extend(t.map,u)),"script"===e){var r=A(a,t.map.src);if(!r)return;u={type:"script",source1:t.map.src,width:r.width,height:r.height}}"source"===e&&(u.source1?u.source2||(u.source2=t.map.src):u.source1=t.map.src),"img"!==e||u.poster||(u.poster=t.map.src)}var n,i,o}}).parse(e),u.source1=u.source1||u.src||u.data,u.source2=u.source2||"",u.poster=u.poster||"",u},F=tinymce.util.Tools.resolve("tinymce.util.Promise"),D=function(e){var t={mp3:"audio/mpeg",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"}[e.toLowerCase().split(".").pop()];return t||""},L=tinymce.util.Tools.resolve("tinymce.html.Schema"),E=tinymce.util.Tools.resolve("tinymce.html.Writer"),J=T.DOM,R=function(e){return/^[0-9.]+$/.test(e)?e+"px":e},U=function(e,t){for(var r in t){var n=""+t[r];if(e.map[r])for(var i=e.length;i--;){var o=e[i];o.name===r&&(n?(e.map[r]=n,o.value=n):(delete e.map[r],e.splice(i,1)))}else n&&(e.push({name:r,value:n}),e.map[r]=n)}},W=function(e,c,u){var s,l=E(),m=f(!1),d=0;return z({validate:!1,allow_conditional_comments:!0,special:"script,noscript",comment:function(e){l.comment(e)},cdata:function(e){l.cdata(e)},text:function(e,t){l.text(e,t)},start:function(e,t,r){if(m.get());else if(M(t.map,"data-ephox-embed-iri"))m.set(!0),n=c,o=(i=t).map.style,(a=o?J.parseStyle(o):{})["max-width"]=R(n.width),a["max-height"]=R(n.height),U(i,{style:J.serializeStyle(a)});else{switch(e){case"video":case"object":case"embed":case"img":case"iframe":c.height!==undefined&&c.width!==undefined&&U(t,{width:c.width,height:c.height})}if(u)switch(e){case"video":U(t,{poster:c.poster,src:""}),c.source2&&U(t,{src:""});break;case"iframe":U(t,{src:c.source1});break;case"source":if(++d<=2&&(U(t,{src:c["source"+d],type:c["source"+d+"mime"]}),!c["source"+d]))return;break;case"img":if(!c.poster)return;s=!0}}var n,i,o,a;l.start(e,t,r)},end:function(e){if(!m.get()){if("video"===e&&u)for(var t=1;t<=2;t++)if(c["source"+t]){var r=[];r.map={},d<t&&(U(r,{src:c["source"+t],type:c["source"+t+"mime"]}),l.start("source",r,!0))}if(c.poster&&"object"===e&&u&&!s){var n=[];n.map={},U(n,{src:c.poster,width:c.width,height:c.height}),l.start("img",n,!0)}}l.end(e)}},L({})).parse(e),l.getContent()},H=[{regex:/youtu\.be\/([\w\-_\?&=.]+)/i,type:"iframe",w:560,h:314,url:"//www.youtube.com/embed/$1",allowFullscreen:!0},{regex:/youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,type:"iframe",w:560,h:314,url:"//www.youtube.com/embed/$2?$4",allowFullscreen:!0},{regex:/youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,type:"iframe",w:560,h:314,url:"//www.youtube.com/embed/$1",allowFullscreen:!0},{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:!0},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"//player.vimeo.com/video/$2?title=0&byline=0",allowFullscreen:!0},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'//maps.google.com/maps/ms?msid=$2&output=embed"',allowFullscreen:!1},{regex:/dailymotion\.com\/video\/([^_]+)/,type:"iframe",w:480,h:270,url:"//www.dailymotion.com/embed/video/$1",allowFullscreen:!0},{regex:/dai\.ly\/([^_]+)/,type:"iframe",w:480,h:270,url:"//www.dailymotion.com/embed/video/$1",allowFullscreen:!0}],I=function(r,e){var n=v.extend({},e);if(!n.source1&&(v.extend(n,P(w(r),n.embed)),!n.source1))return"";n.source2||(n.source2=""),n.poster||(n.poster=""),n.source1=r.convertURL(n.source1,"source"),n.source2=r.convertURL(n.source2,"source"),n.source1mime=D(n.source1),n.source2mime=D(n.source2),n.poster=r.convertURL(n.poster,"poster");var t,i,o=(t=n.source1,0<(i=H.filter(function(e){return e.regex.test(t)})).length?v.extend({},i[0],{url:function(e,t){for(var r=e.regex.exec(t),n=e.url,i=function(e){n=n.replace("$"+e,function(){return r[e]?r[e]:""})},o=0;o<r.length;o++)i(o);return n.replace(/\?$/,"")}(i[0],t)}):null);if(o&&(n.source1=o.url,n.type=o.type,n.allowFullscreen=o.allowFullscreen,n.width=n.width||o.w,n.height=n.height||o.h),n.embed)return W(n.embed,n,!0);var a=A(w(r),n.source1);a&&(n.type="script",n.width=a.width,n.height=a.height);var c,u,s,l,m,d,h,f,p=b(r),g=y(r);return n.width=n.width||300,n.height=n.height||150,v.each(n,function(e,t){n[t]=r.dom.encode(e)}),"iframe"===n.type?(f=(h=n).allowFullscreen?' allowFullscreen="1"':"",'<iframe src="'+h.source1+'" width="'+h.width+'" height="'+h.height+'"'+f+"></iframe>"):"application/x-shockwave-flash"===n.source1mime?(d='<object data="'+(m=n).source1+'" width="'+m.width+'" height="'+m.height+'" type="application/x-shockwave-flash">',m.poster&&(d+='<img src="'+m.poster+'" width="'+m.width+'" height="'+m.height+'" />'),d+="</object>"):-1!==n.source1mime.indexOf("audio")?(s=n,(l=p)?l(s):'<audio controls="controls" src="'+s.source1+'">'+(s.source2?'\n<source src="'+s.source2+'"'+(s.source2mime?' type="'+s.source2mime+'"':"")+" />\n":"")+"</audio>"):"script"===n.type?'<script src="'+n.source1+'"><\/script>':(c=n,(u=g)?u(c):'<video width="'+c.width+'" height="'+c.height+'"'+(c.poster?' poster="'+c.poster+'"':"")+' controls="controls">\n<source src="'+c.source1+'"'+(c.source1mime?' type="'+c.source1mime+'"':"")+" />\n"+(c.source2?'<source src="'+c.source2+'"'+(c.source2mime?' type="'+c.source2mime+'"':"")+" />\n":"")+"</video>")},q={},V=function(t){return function(e){return I(t,e)}},B=function(e,t){var r,n,i,o,a,c=s(e);return c?(i=t,o=V(e),a=c,new F(function(t,e){var r=function(e){return e.html&&(q[i.source1]=e),t({url:i.source1,html:e.html?e.html:o(i)})};q[i.source1]?r(q[i.source1]):a({url:i.source1},r,e)})):(r=t,n=V(e),new F(function(e){e({html:n(r),url:r.source1})}))},G=function(e){return q.hasOwnProperty(e)},K=function(t){return function(e){return e?e.style[t].replace(/px$/,""):""}},Q=function(n){return function(e,t){var r;e&&(e.style[n]=/^[0-9.]+$/.test(r=t)?r+"px":r)}},X={getMaxWidth:K("maxWidth"),getMaxHeight:K("maxHeight"),setMaxWidth:Q("maxWidth"),setMaxHeight:Q("maxHeight")},Y=function(e,t){e.state.set("oldVal",e.value()),t.state.set("oldVal",t.value())},Z=function(e,t){var r=e.find("#width")[0],n=e.find("#height")[0],i=e.find("#constrain")[0];r&&n&&i&&t(r,n,i.checked())},ee=function(e,t,r){var n=e.state.get("oldVal"),i=t.state.get("oldVal"),o=e.value(),a=t.value();r&&n&&i&&o&&a&&(o!==n?(a=Math.round(o/n*a),isNaN(a)||t.value(a)):(o=Math.round(a/i*o),isNaN(o)||e.value(o))),Y(e,t)},te=function(e){Z(e,ee)},re=function(e){var t=function(){e(function(e){te(e)})};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:t,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:t,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}},ne=function(e){Z(e,Y)},ie=te,oe=o.ie&&o.ie<=8?"onChange":"onInput",ae=function(r){return function(e){var t=e&&e.msg?"Media embed handler error: "+e.msg:"Media embed handler threw unknown error.";r.notificationManager.open({type:"error",text:t})}},ce=function(i,o){return function(e){var t=e.html,r=i.find("#embed")[0],n=v.extend(P(w(o),t),{source1:e.url});i.fromJSON(n),r&&(r.value(t),ie(i))}},ue=function(e,t){var r=e.dom.select("img[data-mce-object]");e.insertContent(t),function(e,t){var r,n,i=e.dom.select("img[data-mce-object]");for(r=0;r<t.length;r++)for(n=i.length-1;0<=n;n--)t[r]===i[n]&&i.splice(n,1);e.selection.select(i[0])}(e,r),e.nodeChanged()},se=function(n){var i,t,e,r,o,a=[{name:"source1",type:"filepicker",filetype:"media",size:40,autofocus:!0,label:"Source",onpaste:function(){setTimeout(function(){B(n,i.toJSON()).then(ce(i,n))["catch"](ae(n))},1)},onchange:function(e){var r,t;B(n,i.toJSON()).then(ce(i,n))["catch"](ae(n)),r=i,t=e.meta,v.each(t,function(e,t){r.find("#"+t).value(e)})},onbeforecall:function(e){e.meta=i.toJSON()}}],c=[];if(m(n)&&c.push({name:"source2",type:"filepicker",filetype:"media",size:40,label:"Alternative source"}),d(n)&&c.push({name:"poster",type:"filepicker",filetype:"image",size:40,label:"Poster"}),h(n)){var u=re(function(e){e(i),t=i.toJSON(),i.find("#embed").value(W(t.embed,t))});a.push(u)}r=(e=n).selection.getNode(),o=r.getAttribute("data-ephox-embed-iri"),t=o?{source1:o,"data-ephox-embed-iri":o,width:X.getMaxWidth(r),height:X.getMaxHeight(r)}:r.getAttribute("data-mce-object")?P(w(e),e.serializer.serialize(r,{selection:!0})):{};var s={id:"mcemediasource",type:"textbox",flex:1,name:"embed",value:function(e){var t=e.selection.getNode();if(t.getAttribute("data-mce-object")||t.getAttribute("data-ephox-embed-iri"))return e.selection.getContent()}(n),multiline:!0,rows:5,label:"Source"};s[oe]=function(){t=v.extend({},P(w(n),this.value())),this.parent().parent().fromJSON(t)};var l=[{title:"General",type:"form",items:a},{title:"Embed",type:"container",layout:"flex",direction:"column",align:"stretch",padding:10,spacing:10,items:[{type:"label",text:"Paste your embed code below:",forId:"mcemediasource"},s]}];0<c.length&&l.push({title:"Advanced",type:"form",items:c}),i=n.windowManager.open({title:"Insert/edit media",data:t,bodyType:"tabpanel",body:l,onSubmit:function(){var t,e;ie(i),t=n,(e=i.toJSON()).embed=W(e.embed,e),e.embed&&G(e.source1)?ue(t,e.embed):B(t,e).then(function(e){ue(t,e.html)})["catch"](ae(t))}}),ne(i)},le=function(e){return{showDialog:function(){se(e)}}},me=function(e){e.addCommand("mceMedia",function(){se(e)})},de=tinymce.util.Tools.resolve("tinymce.html.Node"),he=function(o,e){if(!1===u(o))return e;var a,c=E();return z({validate:!1,allow_conditional_comments:!1,special:"script,noscript",comment:function(e){c.comment(e)},cdata:function(e){c.cdata(e)},text:function(e,t){c.text(e,t)},start:function(e,t,r){if(a=!0,"script"!==e&&"noscript"!==e&&"svg"!==e){for(var n=t.length-1;0<=n;n--){var i=t[n].name;0===i.indexOf("on")&&(delete t.map[i],t.splice(n,1)),"style"===i&&(t[n].value=o.dom.serializeStyle(o.dom.parseStyle(t[n].value),e))}c.start(e,t,r),a=!1}},end:function(e){a||c.end(e)}},L({})).parse(e),c.getContent()},fe=function(e,t){var r,n=t.name;return(r=new de("img",1)).shortEnded=!0,ge(e,t,r),r.attr({width:t.attr("width")||"300",height:t.attr("height")||("audio"===n?"30":"150"),style:t.attr("style"),src:o.transparentSrc,"data-mce-object":n,"class":"mce-object mce-object-"+n}),r},pe=function(e,t){var r,n,i,o=t.name;return(r=new de("span",1)).attr({contentEditable:"false",style:t.attr("style"),"data-mce-object":o,"class":"mce-preview-object mce-object-"+o}),ge(e,t,r),(n=new de(o,1)).attr({src:t.attr("src"),allowfullscreen:t.attr("allowfullscreen"),style:t.attr("style"),"class":t.attr("class"),width:t.attr("width"),height:t.attr("height"),frameborder:"0"}),(i=new de("span",1)).attr("class","mce-shim"),r.append(n),r.append(i),r},ge=function(e,t,r){var n,i,o,a,c;for(a=(o=t.attributes).length;a--;)n=o[a].name,i=o[a].value,"width"!==n&&"height"!==n&&"style"!==n&&("data"!==n&&"src"!==n||(i=e.convertURL(i,n)),r.attr("data-mce-p-"+n,i));(c=t.firstChild&&t.firstChild.value)&&(r.attr("data-mce-html",escape(he(e,c))),r.firstChild=null)},ve=function(e){for(;e=e.parent;)if(e.attr("data-ephox-embed-iri"))return!0;return!1},we=function(i){return function(e){for(var t,r,n=e.length;n--;)(t=e[n]).parent&&(t.parent.attr("data-mce-object")||("script"!==t.name||(r=A(w(i),t.attr("src"))))&&(r&&(r.width&&t.attr("width",r.width.toString()),r.height&&t.attr("height",r.height.toString())),"iframe"===t.name&&a(i)&&o.ceFalse?ve(t)||t.replace(pe(i,t)):ve(t)||t.replace(fe(i,t))))}},be=function(d){d.on("preInit",function(){var t=d.schema.getSpecialElements();v.each("video audio iframe object".split(" "),function(e){t[e]=new RegExp("</"+e+"[^>]*>","gi")});var r=d.schema.getBoolAttrs();v.each("webkitallowfullscreen mozallowfullscreen allowfullscreen".split(" "),function(e){r[e]={}}),d.parser.addNodeFilter("iframe,video,audio,object,embed,script",we(d)),d.serializer.addAttributeFilter("data-mce-object",function(e,t){for(var r,n,i,o,a,c,u,s,l=e.length;l--;)if((r=e[l]).parent){for(u=r.attr(t),n=new de(u,1),"audio"!==u&&"script"!==u&&((s=r.attr("class"))&&-1!==s.indexOf("mce-preview-object")?n.attr({width:r.firstChild.attr("width"),height:r.firstChild.attr("height")}):n.attr({width:r.attr("width"),height:r.attr("height")})),n.attr({style:r.attr("style")}),i=(o=r.attributes).length;i--;){var m=o[i].name;0===m.indexOf("data-mce-p-")&&n.attr(m.substr(11),o[i].value)}"script"===u&&n.attr("type","text/javascript"),(a=r.attr("data-mce-html"))&&((c=new de("#text",3)).raw=!0,c.value=he(d,unescape(a)),n.append(c)),r.replace(n)}})}),d.on("setContent",function(){d.$("span.mce-preview-object").each(function(e,t){var r=d.$(t);0===r.find("span.mce-shim",t).length&&r.append('<span class="mce-shim"></span>')})})},ye=function(e){e.on("ResolveName",function(e){var t;1===e.target.nodeType&&(t=e.target.getAttribute("data-mce-object"))&&(e.name=t)})},xe=function(t){t.on("click keyup",function(){var e=t.selection.getNode();e&&t.dom.hasClass(e,"mce-preview-object")&&t.dom.getAttrib(e,"data-mce-selected")&&e.setAttribute("data-mce-selected","2")}),t.on("ObjectSelected",function(e){var t=e.target.getAttribute("data-mce-object");"audio"!==t&&"script"!==t||e.preventDefault()}),t.on("objectResized",function(e){var t,r=e.target;r.getAttribute("data-mce-object")&&(t=r.getAttribute("data-mce-html"))&&(t=unescape(t),r.setAttribute("data-mce-html",escape(W(t,{width:e.width,height:e.height}))))})},Oe=function(e){e.addButton("media",{tooltip:"Insert/edit media",cmd:"mceMedia",stateSelector:["img[data-mce-object]","span[data-mce-object]","div[data-ephox-embed-iri]"]}),e.addMenuItem("media",{icon:"media",text:"Media",cmd:"mceMedia",context:"insert",prependToContext:!0})};i.add("media",function(e){return me(e),Oe(e),ye(e),be(e),xe(e),le(e)})}();
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/paste/plugin.js b/wp-includes/js/tinymce/plugins/paste/plugin.js new file mode 100644 index 0000000..234a8d0 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/plugin.js @@ -0,0 +1,2367 @@ +(function () { +var paste = (function (domGlobals) { + 'use strict'; + + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; + }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; + }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var hasProPlugin = function (editor) { + if (/(^|[ ,])powerpaste([, ]|$)/.test(editor.settings.plugins) && global$1.get('powerpaste')) { + if (typeof domGlobals.window.console !== 'undefined' && domGlobals.window.console.log) { + domGlobals.window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.'); + } + return true; + } else { + return false; + } + }; + var DetectProPlugin = { hasProPlugin: hasProPlugin }; + + var get = function (clipboard, quirks) { + return { + clipboard: clipboard, + quirks: quirks + }; + }; + var Api = { get: get }; + + var firePastePreProcess = function (editor, html, internal, isWordHtml) { + return editor.fire('PastePreProcess', { + content: html, + internal: internal, + wordContent: isWordHtml + }); + }; + var firePastePostProcess = function (editor, node, internal, isWordHtml) { + return editor.fire('PastePostProcess', { + node: node, + internal: internal, + wordContent: isWordHtml + }); + }; + var firePastePlainTextToggle = function (editor, state) { + return editor.fire('PastePlainTextToggle', { state: state }); + }; + var firePaste = function (editor, ieFake) { + return editor.fire('paste', { ieFake: ieFake }); + }; + var Events = { + firePastePreProcess: firePastePreProcess, + firePastePostProcess: firePastePostProcess, + firePastePlainTextToggle: firePastePlainTextToggle, + firePaste: firePaste + }; + + var shouldPlainTextInform = function (editor) { + return editor.getParam('paste_plaintext_inform', true); + }; + var shouldBlockDrop = function (editor) { + return editor.getParam('paste_block_drop', false); + }; + var shouldPasteDataImages = function (editor) { + return editor.getParam('paste_data_images', false); + }; + var shouldFilterDrop = function (editor) { + return editor.getParam('paste_filter_drop', true); + }; + var getPreProcess = function (editor) { + return editor.getParam('paste_preprocess'); + }; + var getPostProcess = function (editor) { + return editor.getParam('paste_postprocess'); + }; + var getWebkitStyles = function (editor) { + return editor.getParam('paste_webkit_styles'); + }; + var shouldRemoveWebKitStyles = function (editor) { + return editor.getParam('paste_remove_styles_if_webkit', true); + }; + var shouldMergeFormats = function (editor) { + return editor.getParam('paste_merge_formats', true); + }; + var isSmartPasteEnabled = function (editor) { + return editor.getParam('smart_paste', true); + }; + var isPasteAsTextEnabled = function (editor) { + return editor.getParam('paste_as_text', false); + }; + var getRetainStyleProps = function (editor) { + return editor.getParam('paste_retain_style_properties'); + }; + var getWordValidElements = function (editor) { + var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'; + return editor.getParam('paste_word_valid_elements', defaultValidElements); + }; + var shouldConvertWordFakeLists = function (editor) { + return editor.getParam('paste_convert_word_fake_lists', true); + }; + var shouldUseDefaultFilters = function (editor) { + return editor.getParam('paste_enable_default_filters', true); + }; + var Settings = { + shouldPlainTextInform: shouldPlainTextInform, + shouldBlockDrop: shouldBlockDrop, + shouldPasteDataImages: shouldPasteDataImages, + shouldFilterDrop: shouldFilterDrop, + getPreProcess: getPreProcess, + getPostProcess: getPostProcess, + getWebkitStyles: getWebkitStyles, + shouldRemoveWebKitStyles: shouldRemoveWebKitStyles, + shouldMergeFormats: shouldMergeFormats, + isSmartPasteEnabled: isSmartPasteEnabled, + isPasteAsTextEnabled: isPasteAsTextEnabled, + getRetainStyleProps: getRetainStyleProps, + getWordValidElements: getWordValidElements, + shouldConvertWordFakeLists: shouldConvertWordFakeLists, + shouldUseDefaultFilters: shouldUseDefaultFilters + }; + + var shouldInformUserAboutPlainText = function (editor, userIsInformedState) { + return userIsInformedState.get() === false && Settings.shouldPlainTextInform(editor); + }; + var displayNotification = function (editor, message) { + editor.notificationManager.open({ + text: editor.translate(message), + type: 'info' + }); + }; + var togglePlainTextPaste = function (editor, clipboard, userIsInformedState) { + if (clipboard.pasteFormat.get() === 'text') { + clipboard.pasteFormat.set('html'); + Events.firePastePlainTextToggle(editor, false); + } else { + clipboard.pasteFormat.set('text'); + Events.firePastePlainTextToggle(editor, true); + if (shouldInformUserAboutPlainText(editor, userIsInformedState)) { + displayNotification(editor, 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.'); + userIsInformedState.set(true); + } + } + editor.focus(); + }; + var Actions = { togglePlainTextPaste: togglePlainTextPaste }; + + var register = function (editor, clipboard, userIsInformedState) { + editor.addCommand('mceTogglePlainTextPaste', function () { + Actions.togglePlainTextPaste(editor, clipboard, userIsInformedState); + }); + editor.addCommand('mceInsertClipboardContent', function (ui, value) { + if (value.content) { + clipboard.pasteHtml(value.content, value.internal); + } + if (value.text) { + clipboard.pasteText(value.text); + } + }); + }; + var Commands = { register: register }; + + var global$2 = tinymce.util.Tools.resolve('tinymce.Env'); + + var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay'); + + var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var global$5 = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var internalMimeType = 'x-tinymce/html'; + var internalMark = '<!-- ' + internalMimeType + ' -->'; + var mark = function (html) { + return internalMark + html; + }; + var unmark = function (html) { + return html.replace(internalMark, ''); + }; + var isMarked = function (html) { + return html.indexOf(internalMark) !== -1; + }; + var InternalHtml = { + mark: mark, + unmark: unmark, + isMarked: isMarked, + internalHtmlMime: function () { + return internalMimeType; + } + }; + + var global$6 = tinymce.util.Tools.resolve('tinymce.html.Entities'); + + var isPlainText = function (text) { + return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text); + }; + var toBRs = function (text) { + return text.replace(/\r?\n/g, '<br>'); + }; + var openContainer = function (rootTag, rootAttrs) { + var key; + var attrs = []; + var tag = '<' + rootTag; + if (typeof rootAttrs === 'object') { + for (key in rootAttrs) { + if (rootAttrs.hasOwnProperty(key)) { + attrs.push(key + '="' + global$6.encodeAllRaw(rootAttrs[key]) + '"'); + } + } + if (attrs.length) { + tag += ' ' + attrs.join(' '); + } + } + return tag + '>'; + }; + var toBlockElements = function (text, rootTag, rootAttrs) { + var blocks = text.split(/\n\n/); + var tagOpen = openContainer(rootTag, rootAttrs); + var tagClose = '</' + rootTag + '>'; + var paragraphs = global$4.map(blocks, function (p) { + return p.split(/\n/).join('<br />'); + }); + var stitch = function (p) { + return tagOpen + p + tagClose; + }; + return paragraphs.length === 1 ? paragraphs[0] : global$4.map(paragraphs, stitch).join(''); + }; + var convert = function (text, rootTag, rootAttrs) { + return rootTag ? toBlockElements(text, rootTag, rootAttrs) : toBRs(text); + }; + var Newlines = { + isPlainText: isPlainText, + convert: convert, + toBRs: toBRs, + toBlockElements: toBlockElements + }; + + var global$7 = tinymce.util.Tools.resolve('tinymce.html.DomParser'); + + var global$8 = tinymce.util.Tools.resolve('tinymce.html.Serializer'); + + var global$9 = tinymce.util.Tools.resolve('tinymce.html.Node'); + + var global$a = tinymce.util.Tools.resolve('tinymce.html.Schema'); + + function filter(content, items) { + global$4.each(items, function (v) { + if (v.constructor === RegExp) { + content = content.replace(v, ''); + } else { + content = content.replace(v[0], v[1]); + } + }); + return content; + } + function innerText(html) { + var schema = global$a(); + var domParser = global$7({}, schema); + var text = ''; + var shortEndedElements = schema.getShortEndedElements(); + var ignoreElements = global$4.makeMap('script noscript style textarea video audio iframe object', ' '); + var blockElements = schema.getBlockElements(); + function walk(node) { + var name = node.name, currentNode = node; + if (name === 'br') { + text += '\n'; + return; + } + if (name === 'wbr') { + return; + } + if (shortEndedElements[name]) { + text += ' '; + } + if (ignoreElements[name]) { + text += ' '; + return; + } + if (node.type === 3) { + text += node.value; + } + if (!node.shortEnded) { + if (node = node.firstChild) { + do { + walk(node); + } while (node = node.next); + } + } + if (blockElements[name] && currentNode.next) { + text += '\n'; + if (name === 'p') { + text += '\n'; + } + } + } + html = filter(html, [/<!\[[^\]]+\]>/g]); + walk(domParser.parse(html)); + return text; + } + function trimHtml(html) { + function trimSpaces(all, s1, s2) { + if (!s1 && !s2) { + return ' '; + } + return '\xA0'; + } + html = filter(html, [ + /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig, + /<!--StartFragment-->|<!--EndFragment-->/g, + [ + /( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, + trimSpaces + ], + /<br class="Apple-interchange-newline">/g, + /<br>$/i + ]); + return html; + } + function createIdGenerator(prefix) { + var count = 0; + return function () { + return prefix + count++; + }; + } + var isMsEdge = function () { + return domGlobals.navigator.userAgent.indexOf(' Edge/') !== -1; + }; + var Utils = { + filter: filter, + innerText: innerText, + trimHtml: trimHtml, + createIdGenerator: createIdGenerator, + isMsEdge: isMsEdge + }; + + function isWordContent(content) { + return /<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(content) || /class="OutlineElement/.test(content) || /id="?docs\-internal\-guid\-/.test(content); + } + function isNumericList(text) { + var found, patterns; + patterns = [ + /^[IVXLMCD]{1,2}\.[ \u00a0]/, + /^[ivxlmcd]{1,2}\.[ \u00a0]/, + /^[a-z]{1,2}[\.\)][ \u00a0]/, + /^[A-Z]{1,2}[\.\)][ \u00a0]/, + /^[0-9]+\.[ \u00a0]/, + /^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/, + /^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/ + ]; + text = text.replace(/^[\u00a0 ]+/, ''); + global$4.each(patterns, function (pattern) { + if (pattern.test(text)) { + found = true; + return false; + } + }); + return found; + } + function isBulletList(text) { + return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(text); + } + function convertFakeListsToProperLists(node) { + var currentListNode, prevListNode, lastLevel = 1; + function getText(node) { + var txt = ''; + if (node.type === 3) { + return node.value; + } + if (node = node.firstChild) { + do { + txt += getText(node); + } while (node = node.next); + } + return txt; + } + function trimListStart(node, regExp) { + if (node.type === 3) { + if (regExp.test(node.value)) { + node.value = node.value.replace(regExp, ''); + return false; + } + } + if (node = node.firstChild) { + do { + if (!trimListStart(node, regExp)) { + return false; + } + } while (node = node.next); + } + return true; + } + function removeIgnoredNodes(node) { + if (node._listIgnore) { + node.remove(); + return; + } + if (node = node.firstChild) { + do { + removeIgnoredNodes(node); + } while (node = node.next); + } + } + function convertParagraphToLi(paragraphNode, listName, start) { + var level = paragraphNode._listLevel || lastLevel; + if (level !== lastLevel) { + if (level < lastLevel) { + if (currentListNode) { + currentListNode = currentListNode.parent.parent; + } + } else { + prevListNode = currentListNode; + currentListNode = null; + } + } + if (!currentListNode || currentListNode.name !== listName) { + prevListNode = prevListNode || currentListNode; + currentListNode = new global$9(listName, 1); + if (start > 1) { + currentListNode.attr('start', '' + start); + } + paragraphNode.wrap(currentListNode); + } else { + currentListNode.append(paragraphNode); + } + paragraphNode.name = 'li'; + if (level > lastLevel && prevListNode) { + prevListNode.lastChild.append(currentListNode); + } + lastLevel = level; + removeIgnoredNodes(paragraphNode); + trimListStart(paragraphNode, /^\u00a0+/); + trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/); + trimListStart(paragraphNode, /^\u00a0+/); + } + var elements = []; + var child = node.firstChild; + while (typeof child !== 'undefined' && child !== null) { + elements.push(child); + child = child.walk(); + if (child !== null) { + while (typeof child !== 'undefined' && child.parent !== node) { + child = child.walk(); + } + } + } + for (var i = 0; i < elements.length; i++) { + node = elements[i]; + if (node.name === 'p' && node.firstChild) { + var nodeText = getText(node); + if (isBulletList(nodeText)) { + convertParagraphToLi(node, 'ul'); + continue; + } + if (isNumericList(nodeText)) { + var matches = /([0-9]+)\./.exec(nodeText); + var start = 1; + if (matches) { + start = parseInt(matches[1], 10); + } + convertParagraphToLi(node, 'ol', start); + continue; + } + if (node._listLevel) { + convertParagraphToLi(node, 'ul', 1); + continue; + } + currentListNode = null; + } else { + prevListNode = currentListNode; + currentListNode = null; + } + } + } + function filterStyles(editor, validStyles, node, styleValue) { + var outputStyles = {}, matches; + var styles = editor.dom.parseStyle(styleValue); + global$4.each(styles, function (value, name) { + switch (name) { + case 'mso-list': + matches = /\w+ \w+([0-9]+)/i.exec(styleValue); + if (matches) { + node._listLevel = parseInt(matches[1], 10); + } + if (/Ignore/i.test(value) && node.firstChild) { + node._listIgnore = true; + node.firstChild._listIgnore = true; + } + break; + case 'horiz-align': + name = 'text-align'; + break; + case 'vert-align': + name = 'vertical-align'; + break; + case 'font-color': + case 'mso-foreground': + name = 'color'; + break; + case 'mso-background': + case 'mso-highlight': + name = 'background'; + break; + case 'font-weight': + case 'font-style': + if (value !== 'normal') { + outputStyles[name] = value; + } + return; + case 'mso-element': + if (/^(comment|comment-list)$/i.test(value)) { + node.remove(); + return; + } + break; + } + if (name.indexOf('mso-comment') === 0) { + node.remove(); + return; + } + if (name.indexOf('mso-') === 0) { + return; + } + if (Settings.getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) { + outputStyles[name] = value; + } + }); + if (/(bold)/i.test(outputStyles['font-weight'])) { + delete outputStyles['font-weight']; + node.wrap(new global$9('b', 1)); + } + if (/(italic)/i.test(outputStyles['font-style'])) { + delete outputStyles['font-style']; + node.wrap(new global$9('i', 1)); + } + outputStyles = editor.dom.serializeStyle(outputStyles, node.name); + if (outputStyles) { + return outputStyles; + } + return null; + } + var filterWordContent = function (editor, content) { + var retainStyleProperties, validStyles; + retainStyleProperties = Settings.getRetainStyleProps(editor); + if (retainStyleProperties) { + validStyles = global$4.makeMap(retainStyleProperties.split(/[, ]/)); + } + content = Utils.filter(content, [ + /<br class="?Apple-interchange-newline"?>/gi, + /<b[^>]+id="?docs-internal-[^>]*>/gi, + /<!--[\s\S]+?-->/gi, + /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, + [ + /<(\/?)s>/gi, + '<$1strike>' + ], + [ + / /gi, + '\xA0' + ], + [ + /<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi, + function (str, spaces) { + return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join('\xA0') : ''; + } + ] + ]); + var validElements = Settings.getWordValidElements(editor); + var schema = global$a({ + valid_elements: validElements, + valid_children: '-li[p]' + }); + global$4.each(schema.elements, function (rule) { + if (!rule.attributes.class) { + rule.attributes.class = {}; + rule.attributesOrder.push('class'); + } + if (!rule.attributes.style) { + rule.attributes.style = {}; + rule.attributesOrder.push('style'); + } + }); + var domParser = global$7({}, schema); + domParser.addAttributeFilter('style', function (nodes) { + var i = nodes.length, node; + while (i--) { + node = nodes[i]; + node.attr('style', filterStyles(editor, validStyles, node, node.attr('style'))); + if (node.name === 'span' && node.parent && !node.attributes.length) { + node.unwrap(); + } + } + }); + domParser.addAttributeFilter('class', function (nodes) { + var i = nodes.length, node, className; + while (i--) { + node = nodes[i]; + className = node.attr('class'); + if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) { + node.remove(); + } + node.attr('class', null); + } + }); + domParser.addNodeFilter('del', function (nodes) { + var i = nodes.length; + while (i--) { + nodes[i].remove(); + } + }); + domParser.addNodeFilter('a', function (nodes) { + var i = nodes.length, node, href, name; + while (i--) { + node = nodes[i]; + href = node.attr('href'); + name = node.attr('name'); + if (href && href.indexOf('#_msocom_') !== -1) { + node.remove(); + continue; + } + if (href && href.indexOf('file://') === 0) { + href = href.split('#')[1]; + if (href) { + href = '#' + href; + } + } + if (!href && !name) { + node.unwrap(); + } else { + if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) { + node.unwrap(); + continue; + } + node.attr({ + href: href, + name: name + }); + } + } + }); + var rootNode = domParser.parse(content); + if (Settings.shouldConvertWordFakeLists(editor)) { + convertFakeListsToProperLists(rootNode); + } + content = global$8({ validate: editor.settings.validate }, schema).serialize(rootNode); + return content; + }; + var preProcess = function (editor, content) { + return Settings.shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content; + }; + var WordFilter = { + preProcess: preProcess, + isWordContent: isWordContent + }; + + var preProcess$1 = function (editor, html) { + var parser = global$7({}, editor.schema); + parser.addNodeFilter('meta', function (nodes) { + global$4.each(nodes, function (node) { + return node.remove(); + }); + }); + var fragment = parser.parse(html, { + forced_root_block: false, + isRootContent: true + }); + return global$8({ validate: editor.settings.validate }, editor.schema).serialize(fragment); + }; + var processResult = function (content, cancelled) { + return { + content: content, + cancelled: cancelled + }; + }; + var postProcessFilter = function (editor, html, internal, isWordHtml) { + var tempBody = editor.dom.create('div', { style: 'display:none' }, html); + var postProcessArgs = Events.firePastePostProcess(editor, tempBody, internal, isWordHtml); + return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented()); + }; + var filterContent = function (editor, content, internal, isWordHtml) { + var preProcessArgs = Events.firePastePreProcess(editor, content, internal, isWordHtml); + var filteredContent = preProcess$1(editor, preProcessArgs.content); + if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) { + return postProcessFilter(editor, filteredContent, internal, isWordHtml); + } else { + return processResult(filteredContent, preProcessArgs.isDefaultPrevented()); + } + }; + var process = function (editor, html, internal) { + var isWordHtml = WordFilter.isWordContent(html); + var content = isWordHtml ? WordFilter.preProcess(editor, html) : html; + return filterContent(editor, content, internal, isWordHtml); + }; + var ProcessFilters = { process: process }; + + var pasteHtml = function (editor, html) { + editor.insertContent(html, { + merge: Settings.shouldMergeFormats(editor), + paste: true + }); + return true; + }; + var isAbsoluteUrl = function (url) { + return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url); + }; + var isImageUrl = function (url) { + return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url); + }; + var createImage = function (editor, url, pasteHtmlFn) { + editor.undoManager.extra(function () { + pasteHtmlFn(editor, url); + }, function () { + editor.insertContent('<img src="' + url + '">'); + }); + return true; + }; + var createLink = function (editor, url, pasteHtmlFn) { + editor.undoManager.extra(function () { + pasteHtmlFn(editor, url); + }, function () { + editor.execCommand('mceInsertLink', false, url); + }); + return true; + }; + var linkSelection = function (editor, html, pasteHtmlFn) { + return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false; + }; + var insertImage = function (editor, html, pasteHtmlFn) { + return isImageUrl(html) ? createImage(editor, html, pasteHtmlFn) : false; + }; + var smartInsertContent = function (editor, html) { + global$4.each([ + linkSelection, + insertImage, + pasteHtml + ], function (action) { + return action(editor, html, pasteHtml) !== true; + }); + }; + var insertContent = function (editor, html) { + if (Settings.isSmartPasteEnabled(editor) === false) { + pasteHtml(editor, html); + } else { + smartInsertContent(editor, html); + } + }; + var SmartPaste = { + isImageUrl: isImageUrl, + isAbsoluteUrl: isAbsoluteUrl, + insertContent: insertContent + }; + + var noop = function () { + }; + var constant = function (value) { + return function () { + return value; + }; + }; + function curry(fn) { + var initialArgs = []; + for (var _i = 1; _i < arguments.length; _i++) { + initialArgs[_i - 1] = arguments[_i]; + } + return function () { + var restArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + restArgs[_i] = arguments[_i]; + } + var all = initialArgs.concat(restArgs); + return fn.apply(null, all); + }; + } + var never = constant(false); + var always = constant(true); + + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never, + isSome: never, + isNone: always, + getOr: id, + getOrThunk: call, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: constant(null), + getOrUndefined: constant(undefined), + or: id, + orThunk: call, + map: none, + each: noop, + bind: none, + exists: never, + forall: always, + filter: none, + equals: eq, + equals_: eq, + toArray: function () { + return []; + }, + toString: constant('none()') + }; + if (Object.freeze) { + Object.freeze(me); + } + return me; + }(); + var some = function (a) { + var constant_a = constant(a); + var self = function () { + return me; + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always, + isNone: never, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: function (f) { + return some(f(a)); + }, + each: function (f) { + f(a); + }, + bind: bind, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never, function (b) { + return elementEq(a, b); + }); + } + }; + return me; + }; + var from = function (value) { + return value === null || value === undefined ? NONE : some(value); + }; + var Option = { + some: some, + none: none, + from: from + }; + + var typeOf = function (x) { + if (x === null) { + return 'null'; + } + var t = typeof x; + if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { + return 'array'; + } + if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { + return 'string'; + } + return t; + }; + var isType = function (type) { + return function (value) { + return typeOf(value) === type; + }; + }; + var isFunction = isType('function'); + + var nativeSlice = Array.prototype.slice; + var map = function (xs, f) { + var len = xs.length; + var r = new Array(len); + for (var i = 0; i < len; i++) { + var x = xs[i]; + r[i] = f(x, i); + } + return r; + }; + var each = function (xs, f) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + f(x, i); + } + }; + var filter$1 = function (xs, pred) { + var r = []; + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + if (pred(x, i)) { + r.push(x); + } + } + return r; + }; + var from$1 = isFunction(Array.from) ? Array.from : function (x) { + return nativeSlice.call(x); + }; + + var exports$1 = {}, module = { exports: exports$1 }; + (function (define, exports, module, require) { + (function (f) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = f(); + } else if (typeof define === 'function' && define.amd) { + define([], f); + } else { + var g; + if (typeof window !== 'undefined') { + g = window; + } else if (typeof global !== 'undefined') { + g = global; + } else if (typeof self !== 'undefined') { + g = self; + } else { + g = this; + } + g.EphoxContactWrapper = f(); + } + }(function () { + return function () { + function r(e, n, t) { + function o(i, f) { + if (!n[i]) { + if (!e[i]) { + var c = 'function' == typeof require && require; + if (!f && c) + return c(i, !0); + if (u) + return u(i, !0); + var a = new Error('Cannot find module \'' + i + '\''); + throw a.code = 'MODULE_NOT_FOUND', a; + } + var p = n[i] = { exports: {} }; + e[i][0].call(p.exports, function (r) { + var n = e[i][1][r]; + return o(n || r); + }, p, p.exports, r, e, n, t); + } + return n[i].exports; + } + for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++) + o(t[i]); + return o; + } + return r; + }()({ + 1: [ + function (require, module, exports) { + var process = module.exports = {}; + var cachedSetTimeout; + var cachedClearTimeout; + function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); + } + function defaultClearTimeout() { + throw new Error('clearTimeout has not been defined'); + } + (function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } + }()); + function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + return setTimeout(fun, 0); + } + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + return cachedSetTimeout(fun, 0); + } catch (e) { + try { + return cachedSetTimeout.call(null, fun, 0); + } catch (e) { + return cachedSetTimeout.call(this, fun, 0); + } + } + } + function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + return clearTimeout(marker); + } + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + return cachedClearTimeout(marker); + } catch (e) { + try { + return cachedClearTimeout.call(null, marker); + } catch (e) { + return cachedClearTimeout.call(this, marker); + } + } + } + var queue = []; + var draining = false; + var currentQueue; + var queueIndex = -1; + function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } + } + function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + var len = queue.length; + while (len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); + } + process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } + }; + function Item(fun, array) { + this.fun = fun; + this.array = array; + } + Item.prototype.run = function () { + this.fun.apply(null, this.array); + }; + process.title = 'browser'; + process.browser = true; + process.env = {}; + process.argv = []; + process.version = ''; + process.versions = {}; + function noop() { + } + process.on = noop; + process.addListener = noop; + process.once = noop; + process.off = noop; + process.removeListener = noop; + process.removeAllListeners = noop; + process.emit = noop; + process.prependListener = noop; + process.prependOnceListener = noop; + process.listeners = function (name) { + return []; + }; + process.binding = function (name) { + throw new Error('process.binding is not supported'); + }; + process.cwd = function () { + return '/'; + }; + process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); + }; + process.umask = function () { + return 0; + }; + }, + {} + ], + 2: [ + function (require, module, exports) { + (function (setImmediate) { + (function (root) { + var setTimeoutFunc = setTimeout; + function noop() { + } + function bind(fn, thisArg) { + return function () { + fn.apply(thisArg, arguments); + }; + } + function Promise(fn) { + if (typeof this !== 'object') + throw new TypeError('Promises must be constructed via new'); + if (typeof fn !== 'function') + throw new TypeError('not a function'); + this._state = 0; + this._handled = false; + this._value = undefined; + this._deferreds = []; + doResolve(fn, this); + } + function handle(self, deferred) { + while (self._state === 3) { + self = self._value; + } + if (self._state === 0) { + self._deferreds.push(deferred); + return; + } + self._handled = true; + Promise._immediateFn(function () { + var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; + if (cb === null) { + (self._state === 1 ? resolve : reject)(deferred.promise, self._value); + return; + } + var ret; + try { + ret = cb(self._value); + } catch (e) { + reject(deferred.promise, e); + return; + } + resolve(deferred.promise, ret); + }); + } + function resolve(self, newValue) { + try { + if (newValue === self) + throw new TypeError('A promise cannot be resolved with itself.'); + if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { + var then = newValue.then; + if (newValue instanceof Promise) { + self._state = 3; + self._value = newValue; + finale(self); + return; + } else if (typeof then === 'function') { + doResolve(bind(then, newValue), self); + return; + } + } + self._state = 1; + self._value = newValue; + finale(self); + } catch (e) { + reject(self, e); + } + } + function reject(self, newValue) { + self._state = 2; + self._value = newValue; + finale(self); + } + function finale(self) { + if (self._state === 2 && self._deferreds.length === 0) { + Promise._immediateFn(function () { + if (!self._handled) { + Promise._unhandledRejectionFn(self._value); + } + }); + } + for (var i = 0, len = self._deferreds.length; i < len; i++) { + handle(self, self._deferreds[i]); + } + self._deferreds = null; + } + function Handler(onFulfilled, onRejected, promise) { + this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; + this.onRejected = typeof onRejected === 'function' ? onRejected : null; + this.promise = promise; + } + function doResolve(fn, self) { + var done = false; + try { + fn(function (value) { + if (done) + return; + done = true; + resolve(self, value); + }, function (reason) { + if (done) + return; + done = true; + reject(self, reason); + }); + } catch (ex) { + if (done) + return; + done = true; + reject(self, ex); + } + } + Promise.prototype['catch'] = function (onRejected) { + return this.then(null, onRejected); + }; + Promise.prototype.then = function (onFulfilled, onRejected) { + var prom = new this.constructor(noop); + handle(this, new Handler(onFulfilled, onRejected, prom)); + return prom; + }; + Promise.all = function (arr) { + var args = Array.prototype.slice.call(arr); + return new Promise(function (resolve, reject) { + if (args.length === 0) + return resolve([]); + var remaining = args.length; + function res(i, val) { + try { + if (val && (typeof val === 'object' || typeof val === 'function')) { + var then = val.then; + if (typeof then === 'function') { + then.call(val, function (val) { + res(i, val); + }, reject); + return; + } + } + args[i] = val; + if (--remaining === 0) { + resolve(args); + } + } catch (ex) { + reject(ex); + } + } + for (var i = 0; i < args.length; i++) { + res(i, args[i]); + } + }); + }; + Promise.resolve = function (value) { + if (value && typeof value === 'object' && value.constructor === Promise) { + return value; + } + return new Promise(function (resolve) { + resolve(value); + }); + }; + Promise.reject = function (value) { + return new Promise(function (resolve, reject) { + reject(value); + }); + }; + Promise.race = function (values) { + return new Promise(function (resolve, reject) { + for (var i = 0, len = values.length; i < len; i++) { + values[i].then(resolve, reject); + } + }); + }; + Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) { + setImmediate(fn); + } : function (fn) { + setTimeoutFunc(fn, 0); + }; + Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { + if (typeof console !== 'undefined' && console) { + console.warn('Possible Unhandled Promise Rejection:', err); + } + }; + Promise._setImmediateFn = function _setImmediateFn(fn) { + Promise._immediateFn = fn; + }; + Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) { + Promise._unhandledRejectionFn = fn; + }; + if (typeof module !== 'undefined' && module.exports) { + module.exports = Promise; + } else if (!root.Promise) { + root.Promise = Promise; + } + }(this)); + }.call(this, require('timers').setImmediate)); + }, + { 'timers': 3 } + ], + 3: [ + function (require, module, exports) { + (function (setImmediate, clearImmediate) { + var nextTick = require('process/browser.js').nextTick; + var apply = Function.prototype.apply; + var slice = Array.prototype.slice; + var immediateIds = {}; + var nextImmediateId = 0; + exports.setTimeout = function () { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); + }; + exports.setInterval = function () { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); + }; + exports.clearTimeout = exports.clearInterval = function (timeout) { + timeout.close(); + }; + function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; + } + Timeout.prototype.unref = Timeout.prototype.ref = function () { + }; + Timeout.prototype.close = function () { + this._clearFn.call(window, this._id); + }; + exports.enroll = function (item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; + }; + exports.unenroll = function (item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; + }; + exports._unrefActive = exports.active = function (item) { + clearTimeout(item._idleTimeoutId); + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } + }; + exports.setImmediate = typeof setImmediate === 'function' ? setImmediate : function (fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); + immediateIds[id] = true; + nextTick(function onNextTick() { + if (immediateIds[id]) { + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + exports.clearImmediate(id); + } + }); + return id; + }; + exports.clearImmediate = typeof clearImmediate === 'function' ? clearImmediate : function (id) { + delete immediateIds[id]; + }; + }.call(this, require('timers').setImmediate, require('timers').clearImmediate)); + }, + { + 'process/browser.js': 1, + 'timers': 3 + } + ], + 4: [ + function (require, module, exports) { + var promisePolyfill = require('promise-polyfill'); + var Global = function () { + if (typeof window !== 'undefined') { + return window; + } else { + return Function('return this;')(); + } + }(); + module.exports = { boltExport: Global.Promise || promisePolyfill }; + }, + { 'promise-polyfill': 2 } + ] + }, {}, [4])(4); + })); + }(undefined, exports$1, module, undefined)); + var Promise = module.exports.boltExport; + + var nu = function (baseFn) { + var data = Option.none(); + var callbacks = []; + var map = function (f) { + return nu(function (nCallback) { + get(function (data) { + nCallback(f(data)); + }); + }); + }; + var get = function (nCallback) { + if (isReady()) { + call(nCallback); + } else { + callbacks.push(nCallback); + } + }; + var set = function (x) { + data = Option.some(x); + run(callbacks); + callbacks = []; + }; + var isReady = function () { + return data.isSome(); + }; + var run = function (cbs) { + each(cbs, call); + }; + var call = function (cb) { + data.each(function (x) { + domGlobals.setTimeout(function () { + cb(x); + }, 0); + }); + }; + baseFn(set); + return { + get: get, + map: map, + isReady: isReady + }; + }; + var pure = function (a) { + return nu(function (callback) { + callback(a); + }); + }; + var LazyValue = { + nu: nu, + pure: pure + }; + + var errorReporter = function (err) { + domGlobals.setTimeout(function () { + throw err; + }, 0); + }; + var make = function (run) { + var get = function (callback) { + run().then(callback, errorReporter); + }; + var map = function (fab) { + return make(function () { + return run().then(fab); + }); + }; + var bind = function (aFutureB) { + return make(function () { + return run().then(function (v) { + return aFutureB(v).toPromise(); + }); + }); + }; + var anonBind = function (futureB) { + return make(function () { + return run().then(function () { + return futureB.toPromise(); + }); + }); + }; + var toLazy = function () { + return LazyValue.nu(get); + }; + var toCached = function () { + var cache = null; + return make(function () { + if (cache === null) { + cache = run(); + } + return cache; + }); + }; + var toPromise = run; + return { + map: map, + bind: bind, + anonBind: anonBind, + toLazy: toLazy, + toCached: toCached, + toPromise: toPromise, + get: get + }; + }; + var nu$1 = function (baseFn) { + return make(function () { + return new Promise(baseFn); + }); + }; + var pure$1 = function (a) { + return make(function () { + return Promise.resolve(a); + }); + }; + var Future = { + nu: nu$1, + pure: pure$1 + }; + + var par = function (asyncValues, nu) { + return nu(function (callback) { + var r = []; + var count = 0; + var cb = function (i) { + return function (value) { + r[i] = value; + count++; + if (count >= asyncValues.length) { + callback(r); + } + }; + }; + if (asyncValues.length === 0) { + callback([]); + } else { + each(asyncValues, function (asyncValue, i) { + asyncValue.get(cb(i)); + }); + } + }); + }; + + var par$1 = function (futures) { + return par(futures, Future.nu); + }; + var traverse = function (array, fn) { + return par$1(map(array, fn)); + }; + var mapM = traverse; + + var value = function () { + var subject = Cell(Option.none()); + var clear = function () { + subject.set(Option.none()); + }; + var set = function (s) { + subject.set(Option.some(s)); + }; + var on = function (f) { + subject.get().each(f); + }; + var isSet = function () { + return subject.get().isSome(); + }; + return { + clear: clear, + set: set, + isSet: isSet, + on: on + }; + }; + + var pasteHtml$1 = function (editor, html, internalFlag) { + var internal = internalFlag ? internalFlag : InternalHtml.isMarked(html); + var args = ProcessFilters.process(editor, InternalHtml.unmark(html), internal); + if (args.cancelled === false) { + SmartPaste.insertContent(editor, args.content); + } + }; + var pasteText = function (editor, text) { + text = editor.dom.encode(text).replace(/\r\n/g, '\n'); + text = Newlines.convert(text, editor.settings.forced_root_block, editor.settings.forced_root_block_attrs); + pasteHtml$1(editor, text, false); + }; + var getDataTransferItems = function (dataTransfer) { + var items = {}; + var mceInternalUrlPrefix = 'data:text/mce-internal,'; + if (dataTransfer) { + if (dataTransfer.getData) { + var legacyText = dataTransfer.getData('Text'); + if (legacyText && legacyText.length > 0) { + if (legacyText.indexOf(mceInternalUrlPrefix) === -1) { + items['text/plain'] = legacyText; + } + } + } + if (dataTransfer.types) { + for (var i = 0; i < dataTransfer.types.length; i++) { + var contentType = dataTransfer.types[i]; + try { + items[contentType] = dataTransfer.getData(contentType); + } catch (ex) { + items[contentType] = ''; + } + } + } + } + return items; + }; + var getClipboardContent = function (editor, clipboardEvent) { + var content = getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer); + return Utils.isMsEdge() ? global$4.extend(content, { 'text/html': '' }) : content; + }; + var hasContentType = function (clipboardContent, mimeType) { + return mimeType in clipboardContent && clipboardContent[mimeType].length > 0; + }; + var hasHtmlOrText = function (content) { + return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain'); + }; + var getBase64FromUri = function (uri) { + var idx; + idx = uri.indexOf(','); + if (idx !== -1) { + return uri.substr(idx + 1); + } + return null; + }; + var isValidDataUriImage = function (settings, imgElm) { + return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true; + }; + var extractFilename = function (editor, str) { + var m = str.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i); + return m ? editor.dom.encode(m[1]) : null; + }; + var uniqueId = Utils.createIdGenerator('mceclip'); + var pasteImage = function (editor, imageItem) { + var base64 = getBase64FromUri(imageItem.uri); + var id = uniqueId(); + var name = editor.settings.images_reuse_filename && imageItem.blob.name ? extractFilename(editor, imageItem.blob.name) : id; + var img = new domGlobals.Image(); + img.src = imageItem.uri; + if (isValidDataUriImage(editor.settings, img)) { + var blobCache = editor.editorUpload.blobCache; + var blobInfo = void 0, existingBlobInfo = void 0; + existingBlobInfo = blobCache.findFirst(function (cachedBlobInfo) { + return cachedBlobInfo.base64() === base64; + }); + if (!existingBlobInfo) { + blobInfo = blobCache.create(id, imageItem.blob, base64, name); + blobCache.add(blobInfo); + } else { + blobInfo = existingBlobInfo; + } + pasteHtml$1(editor, '<img src="' + blobInfo.blobUri() + '">', false); + } else { + pasteHtml$1(editor, '<img src="' + imageItem.uri + '">', false); + } + }; + var isClipboardEvent = function (event) { + return event.type === 'paste'; + }; + var readBlobsAsDataUris = function (items) { + return mapM(items, function (item) { + return Future.nu(function (resolve) { + var blob = item.getAsFile ? item.getAsFile() : item; + var reader = new window.FileReader(); + reader.onload = function () { + resolve({ + blob: blob, + uri: reader.result + }); + }; + reader.readAsDataURL(blob); + }); + }); + }; + var getImagesFromDataTransfer = function (dataTransfer) { + var items = dataTransfer.items ? map(from$1(dataTransfer.items), function (item) { + return item.getAsFile(); + }) : []; + var files = dataTransfer.files ? from$1(dataTransfer.files) : []; + var images = filter$1(items.length > 0 ? items : files, function (file) { + return /^image\/(jpeg|png|gif|bmp)$/.test(file.type); + }); + return images; + }; + var pasteImageData = function (editor, e, rng) { + var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer; + if (editor.settings.paste_data_images && dataTransfer) { + var images = getImagesFromDataTransfer(dataTransfer); + if (images.length > 0) { + e.preventDefault(); + readBlobsAsDataUris(images).get(function (blobResults) { + if (rng) { + editor.selection.setRng(rng); + } + each(blobResults, function (result) { + pasteImage(editor, result); + }); + }); + return true; + } + } + return false; + }; + var isBrokenAndroidClipboardEvent = function (e) { + var clipboardData = e.clipboardData; + return domGlobals.navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0; + }; + var isKeyboardPasteEvent = function (e) { + return global$5.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45; + }; + var registerEventHandlers = function (editor, pasteBin, pasteFormat) { + var keyboardPasteEvent = value(); + var keyboardPastePlainTextState; + editor.on('keydown', function (e) { + function removePasteBinOnKeyUp(e) { + if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { + pasteBin.remove(); + } + } + if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { + keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86; + if (keyboardPastePlainTextState && global$2.webkit && domGlobals.navigator.userAgent.indexOf('Version/') !== -1) { + return; + } + e.stopImmediatePropagation(); + keyboardPasteEvent.set(e); + window.setTimeout(function () { + keyboardPasteEvent.clear(); + }, 100); + if (global$2.ie && keyboardPastePlainTextState) { + e.preventDefault(); + Events.firePaste(editor, true); + return; + } + pasteBin.remove(); + pasteBin.create(); + editor.once('keyup', removePasteBinOnKeyUp); + editor.once('paste', function () { + editor.off('keyup', removePasteBinOnKeyUp); + }); + } + }); + function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) { + var content, isPlainTextHtml; + if (hasContentType(clipboardContent, 'text/html')) { + content = clipboardContent['text/html']; + } else { + content = pasteBin.getHtml(); + internal = internal ? internal : InternalHtml.isMarked(content); + if (pasteBin.isDefaultContent(content)) { + plainTextMode = true; + } + } + content = Utils.trimHtml(content); + pasteBin.remove(); + isPlainTextHtml = internal === false && Newlines.isPlainText(content); + if (!content.length || isPlainTextHtml) { + plainTextMode = true; + } + if (plainTextMode) { + if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) { + content = clipboardContent['text/plain']; + } else { + content = Utils.innerText(content); + } + } + if (pasteBin.isDefaultContent(content)) { + if (!isKeyBoardPaste) { + editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.'); + } + return; + } + if (plainTextMode) { + pasteText(editor, content); + } else { + pasteHtml$1(editor, content, internal); + } + } + var getLastRng = function () { + return pasteBin.getLastRng() || editor.selection.getRng(); + }; + editor.on('paste', function (e) { + var isKeyBoardPaste = keyboardPasteEvent.isSet(); + var clipboardContent = getClipboardContent(editor, e); + var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState; + var internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime()); + keyboardPastePlainTextState = false; + if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) { + pasteBin.remove(); + return; + } + if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) { + pasteBin.remove(); + return; + } + if (!isKeyBoardPaste) { + e.preventDefault(); + } + if (global$2.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) { + pasteBin.create(); + editor.dom.bind(pasteBin.getEl(), 'paste', function (e) { + e.stopPropagation(); + }); + editor.getDoc().execCommand('Paste', false, null); + clipboardContent['text/html'] = pasteBin.getHtml(); + } + if (hasContentType(clipboardContent, 'text/html')) { + e.preventDefault(); + if (!internal) { + internal = InternalHtml.isMarked(clipboardContent['text/html']); + } + insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal); + } else { + global$3.setEditorTimeout(editor, function () { + insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal); + }, 0); + } + }); + }; + var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) { + registerEventHandlers(editor, pasteBin, pasteFormat); + var src; + editor.parser.addNodeFilter('img', function (nodes, name, args) { + var isPasteInsert = function (args) { + return args.data && args.data.paste === true; + }; + var remove = function (node) { + if (!node.attr('data-mce-object') && src !== global$2.transparentSrc) { + node.remove(); + } + }; + var isWebKitFakeUrl = function (src) { + return src.indexOf('webkit-fake-url') === 0; + }; + var isDataUri = function (src) { + return src.indexOf('data:') === 0; + }; + if (!editor.settings.paste_data_images && isPasteInsert(args)) { + var i = nodes.length; + while (i--) { + src = nodes[i].attributes.map.src; + if (!src) { + continue; + } + if (isWebKitFakeUrl(src)) { + remove(nodes[i]); + } else if (!editor.settings.allow_html_data_urls && isDataUri(src)) { + remove(nodes[i]); + } + } + } + }); + }; + + var getPasteBinParent = function (editor) { + return global$2.ie && editor.inline ? domGlobals.document.body : editor.getBody(); + }; + var isExternalPasteBin = function (editor) { + return getPasteBinParent(editor) !== editor.getBody(); + }; + var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) { + if (isExternalPasteBin(editor)) { + editor.dom.bind(pasteBinElm, 'paste keyup', function (e) { + if (!isDefault(editor, pasteBinDefaultContent)) { + editor.fire('paste'); + } + }); + } + }; + var create = function (editor, lastRngCell, pasteBinDefaultContent) { + var dom = editor.dom, body = editor.getBody(); + var pasteBinElm; + lastRngCell.set(editor.selection.getRng()); + pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', { + 'id': 'mcepastebin', + 'class': 'mce-pastebin', + 'contentEditable': true, + 'data-mce-bogus': 'all', + 'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0' + }, pasteBinDefaultContent); + if (global$2.ie || global$2.gecko) { + dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535); + } + dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) { + e.stopPropagation(); + }); + delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent); + pasteBinElm.focus(); + editor.selection.select(pasteBinElm, true); + }; + var remove = function (editor, lastRngCell) { + if (getEl(editor)) { + var pasteBinClone = void 0; + var lastRng = lastRngCell.get(); + while (pasteBinClone = editor.dom.get('mcepastebin')) { + editor.dom.remove(pasteBinClone); + editor.dom.unbind(pasteBinClone); + } + if (lastRng) { + editor.selection.setRng(lastRng); + } + } + lastRngCell.set(null); + }; + var getEl = function (editor) { + return editor.dom.get('mcepastebin'); + }; + var getHtml = function (editor) { + var pasteBinElm, pasteBinClones, i, dirtyWrappers, cleanWrapper; + var copyAndRemove = function (toElm, fromElm) { + toElm.appendChild(fromElm); + editor.dom.remove(fromElm, true); + }; + pasteBinClones = global$4.grep(getPasteBinParent(editor).childNodes, function (elm) { + return elm.id === 'mcepastebin'; + }); + pasteBinElm = pasteBinClones.shift(); + global$4.each(pasteBinClones, function (pasteBinClone) { + copyAndRemove(pasteBinElm, pasteBinClone); + }); + dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm); + for (i = dirtyWrappers.length - 1; i >= 0; i--) { + cleanWrapper = editor.dom.create('div'); + pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]); + copyAndRemove(cleanWrapper, dirtyWrappers[i]); + } + return pasteBinElm ? pasteBinElm.innerHTML : ''; + }; + var getLastRng = function (lastRng) { + return lastRng.get(); + }; + var isDefaultContent = function (pasteBinDefaultContent, content) { + return content === pasteBinDefaultContent; + }; + var isPasteBin = function (elm) { + return elm && elm.id === 'mcepastebin'; + }; + var isDefault = function (editor, pasteBinDefaultContent) { + var pasteBinElm = getEl(editor); + return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML); + }; + var PasteBin = function (editor) { + var lastRng = Cell(null); + var pasteBinDefaultContent = '%MCEPASTEBIN%'; + return { + create: function () { + return create(editor, lastRng, pasteBinDefaultContent); + }, + remove: function () { + return remove(editor, lastRng); + }, + getEl: function () { + return getEl(editor); + }, + getHtml: function () { + return getHtml(editor); + }, + getLastRng: function () { + return getLastRng(lastRng); + }, + isDefault: function () { + return isDefault(editor, pasteBinDefaultContent); + }, + isDefaultContent: function (content) { + return isDefaultContent(pasteBinDefaultContent, content); + } + }; + }; + + var Clipboard = function (editor, pasteFormat) { + var pasteBin = PasteBin(editor); + editor.on('preInit', function () { + return registerEventsAndFilters(editor, pasteBin, pasteFormat); + }); + return { + pasteFormat: pasteFormat, + pasteHtml: function (html, internalFlag) { + return pasteHtml$1(editor, html, internalFlag); + }, + pasteText: function (text) { + return pasteText(editor, text); + }, + pasteImageData: function (e, rng) { + return pasteImageData(editor, e, rng); + }, + getDataTransferItems: getDataTransferItems, + hasHtmlOrText: hasHtmlOrText, + hasContentType: hasContentType + }; + }; + + var noop$1 = function () { + }; + var hasWorkingClipboardApi = function (clipboardData) { + return global$2.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true; + }; + var setHtml5Clipboard = function (clipboardData, html, text) { + if (hasWorkingClipboardApi(clipboardData)) { + try { + clipboardData.clearData(); + clipboardData.setData('text/html', html); + clipboardData.setData('text/plain', text); + clipboardData.setData(InternalHtml.internalHtmlMime(), html); + return true; + } catch (e) { + return false; + } + } else { + return false; + } + }; + var setClipboardData = function (evt, data, fallback, done) { + if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) { + evt.preventDefault(); + done(); + } else { + fallback(data.html, done); + } + }; + var fallback = function (editor) { + return function (html, done) { + var markedHtml = InternalHtml.mark(html); + var outer = editor.dom.create('div', { + 'contenteditable': 'false', + 'data-mce-bogus': 'all' + }); + var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml); + editor.dom.setStyles(outer, { + position: 'fixed', + top: '0', + left: '-3000px', + width: '1000px', + overflow: 'hidden' + }); + outer.appendChild(inner); + editor.dom.add(editor.getBody(), outer); + var range = editor.selection.getRng(); + inner.focus(); + var offscreenRange = editor.dom.createRng(); + offscreenRange.selectNodeContents(inner); + editor.selection.setRng(offscreenRange); + setTimeout(function () { + editor.selection.setRng(range); + outer.parentNode.removeChild(outer); + done(); + }, 0); + }; + }; + var getData = function (editor) { + return { + html: editor.selection.getContent({ contextual: true }), + text: editor.selection.getContent({ format: 'text' }) + }; + }; + var isTableSelection = function (editor) { + return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody()); + }; + var hasSelectedContent = function (editor) { + return !editor.selection.isCollapsed() || isTableSelection(editor); + }; + var cut = function (editor) { + return function (evt) { + if (hasSelectedContent(editor)) { + setClipboardData(evt, getData(editor), fallback(editor), function () { + setTimeout(function () { + editor.execCommand('Delete'); + }, 0); + }); + } + }; + }; + var copy = function (editor) { + return function (evt) { + if (hasSelectedContent(editor)) { + setClipboardData(evt, getData(editor), fallback(editor), noop$1); + } + }; + }; + var register$1 = function (editor) { + editor.on('cut', cut(editor)); + editor.on('copy', copy(editor)); + }; + var CutCopy = { register: register$1 }; + + var global$b = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); + + var getCaretRangeFromEvent = function (editor, e) { + return global$b.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc()); + }; + var isPlainTextFileUrl = function (content) { + var plainTextContent = content['text/plain']; + return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false; + }; + var setFocusedRange = function (editor, rng) { + editor.focus(); + editor.selection.setRng(rng); + }; + var setup = function (editor, clipboard, draggingInternallyState) { + if (Settings.shouldBlockDrop(editor)) { + editor.on('dragend dragover draggesture dragdrop drop drag', function (e) { + e.preventDefault(); + e.stopPropagation(); + }); + } + if (!Settings.shouldPasteDataImages(editor)) { + editor.on('drop', function (e) { + var dataTransfer = e.dataTransfer; + if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) { + e.preventDefault(); + } + }); + } + editor.on('drop', function (e) { + var dropContent, rng; + rng = getCaretRangeFromEvent(editor, e); + if (e.isDefaultPrevented() || draggingInternallyState.get()) { + return; + } + dropContent = clipboard.getDataTransferItems(e.dataTransfer); + var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime()); + if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) { + return; + } + if (rng && Settings.shouldFilterDrop(editor)) { + var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain']; + if (content_1) { + e.preventDefault(); + global$3.setEditorTimeout(editor, function () { + editor.undoManager.transact(function () { + if (dropContent['mce-internal']) { + editor.execCommand('Delete'); + } + setFocusedRange(editor, rng); + content_1 = Utils.trimHtml(content_1); + if (!dropContent['text/html']) { + clipboard.pasteText(content_1); + } else { + clipboard.pasteHtml(content_1, internal); + } + }); + }); + } + } + }); + editor.on('dragstart', function (e) { + draggingInternallyState.set(true); + }); + editor.on('dragover dragend', function (e) { + if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) { + e.preventDefault(); + setFocusedRange(editor, getCaretRangeFromEvent(editor, e)); + } + if (e.type === 'dragend') { + draggingInternallyState.set(false); + } + }); + }; + var DragDrop = { setup: setup }; + + var setup$1 = function (editor) { + var plugin = editor.plugins.paste; + var preProcess = Settings.getPreProcess(editor); + if (preProcess) { + editor.on('PastePreProcess', function (e) { + preProcess.call(plugin, plugin, e); + }); + } + var postProcess = Settings.getPostProcess(editor); + if (postProcess) { + editor.on('PastePostProcess', function (e) { + postProcess.call(plugin, plugin, e); + }); + } + }; + var PrePostProcess = { setup: setup$1 }; + + function addPreProcessFilter(editor, filterFunc) { + editor.on('PastePreProcess', function (e) { + e.content = filterFunc(editor, e.content, e.internal, e.wordContent); + }); + } + function addPostProcessFilter(editor, filterFunc) { + editor.on('PastePostProcess', function (e) { + filterFunc(editor, e.node); + }); + } + function removeExplorerBrElementsAfterBlocks(editor, html) { + if (!WordFilter.isWordContent(html)) { + return html; + } + var blockElements = []; + global$4.each(editor.schema.getBlockElements(), function (block, blockName) { + blockElements.push(blockName); + }); + var explorerBlocksRegExp = new RegExp('(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*', 'g'); + html = Utils.filter(html, [[ + explorerBlocksRegExp, + '$1' + ]]); + html = Utils.filter(html, [ + [ + /<br><br>/g, + '<BR><BR>' + ], + [ + /<br>/g, + ' ' + ], + [ + /<BR><BR>/g, + '<br>' + ] + ]); + return html; + } + function removeWebKitStyles(editor, content, internal, isWordHtml) { + if (isWordHtml || internal) { + return content; + } + var webKitStylesSetting = Settings.getWebkitStyles(editor); + var webKitStyles; + if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') { + return content; + } + if (webKitStylesSetting) { + webKitStyles = webKitStylesSetting.split(/[, ]/); + } + if (webKitStyles) { + var dom_1 = editor.dom, node_1 = editor.selection.getNode(); + content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) { + var inputStyles = dom_1.parseStyle(dom_1.decode(value)); + var outputStyles = {}; + if (webKitStyles === 'none') { + return before + after; + } + for (var i = 0; i < webKitStyles.length; i++) { + var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true); + if (/color/.test(webKitStyles[i])) { + inputValue = dom_1.toHex(inputValue); + currentValue = dom_1.toHex(currentValue); + } + if (currentValue !== inputValue) { + outputStyles[webKitStyles[i]] = inputValue; + } + } + outputStyles = dom_1.serializeStyle(outputStyles, 'span'); + if (outputStyles) { + return before + ' style="' + outputStyles + '"' + after; + } + return before + after; + }); + } else { + content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3'); + } + content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) { + return before + ' style="' + value + '"' + after; + }); + return content; + } + function removeUnderlineAndFontInAnchor(editor, root) { + editor.$('a', root).find('font,u').each(function (i, node) { + editor.dom.remove(node, true); + }); + } + var setup$2 = function (editor) { + if (global$2.webkit) { + addPreProcessFilter(editor, removeWebKitStyles); + } + if (global$2.ie) { + addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks); + addPostProcessFilter(editor, removeUnderlineAndFontInAnchor); + } + }; + var Quirks = { setup: setup$2 }; + + var stateChange = function (editor, clipboard, e) { + var ctrl = e.control; + ctrl.active(clipboard.pasteFormat.get() === 'text'); + editor.on('PastePlainTextToggle', function (e) { + ctrl.active(e.state); + }); + }; + var register$2 = function (editor, clipboard) { + var postRender = curry(stateChange, editor, clipboard); + editor.addButton('pastetext', { + active: false, + icon: 'pastetext', + tooltip: 'Paste as text', + cmd: 'mceTogglePlainTextPaste', + onPostRender: postRender + }); + editor.addMenuItem('pastetext', { + text: 'Paste as text', + selectable: true, + active: clipboard.pasteFormat, + cmd: 'mceTogglePlainTextPaste', + onPostRender: postRender + }); + }; + var Buttons = { register: register$2 }; + + global$1.add('paste', function (editor) { + if (DetectProPlugin.hasProPlugin(editor) === false) { + var userIsInformedState = Cell(false); + var draggingInternallyState = Cell(false); + var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html'); + var clipboard = Clipboard(editor, pasteFormat); + var quirks = Quirks.setup(editor); + Buttons.register(editor, clipboard); + Commands.register(editor, clipboard, userIsInformedState); + PrePostProcess.setup(editor); + CutCopy.register(editor); + DragDrop.setup(editor, clipboard, draggingInternallyState); + return Api.get(clipboard, quirks); + } + }); + function Plugin () { + } + + return Plugin; + +}(window)); +})(); diff --git a/wp-includes/js/tinymce/plugins/paste/plugin.min.js b/wp-includes/js/tinymce/plugins/paste/plugin.min.js new file mode 100644 index 0000000..db2393e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/plugin.min.js @@ -0,0 +1 @@ +!function(v){"use strict";var p=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return p(n())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(t){return!(!/(^|[ ,])powerpaste([, ]|$)/.test(t.settings.plugins)||!e.get("powerpaste")||("undefined"!=typeof v.window.console&&v.window.console.log&&v.window.console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option."),0))},u=function(t,e){return{clipboard:t,quirks:e}},d=function(t,e,n,r){return t.fire("PastePreProcess",{content:e,internal:n,wordContent:r})},m=function(t,e,n,r){return t.fire("PastePostProcess",{node:e,internal:n,wordContent:r})},s=function(t,e){return t.fire("PastePlainTextToggle",{state:e})},n=function(t,e){return t.fire("paste",{ieFake:e})},g={shouldPlainTextInform:function(t){return t.getParam("paste_plaintext_inform",!0)},shouldBlockDrop:function(t){return t.getParam("paste_block_drop",!1)},shouldPasteDataImages:function(t){return t.getParam("paste_data_images",!1)},shouldFilterDrop:function(t){return t.getParam("paste_filter_drop",!0)},getPreProcess:function(t){return t.getParam("paste_preprocess")},getPostProcess:function(t){return t.getParam("paste_postprocess")},getWebkitStyles:function(t){return t.getParam("paste_webkit_styles")},shouldRemoveWebKitStyles:function(t){return t.getParam("paste_remove_styles_if_webkit",!0)},shouldMergeFormats:function(t){return t.getParam("paste_merge_formats",!0)},isSmartPasteEnabled:function(t){return t.getParam("smart_paste",!0)},isPasteAsTextEnabled:function(t){return t.getParam("paste_as_text",!1)},getRetainStyleProps:function(t){return t.getParam("paste_retain_style_properties")},getWordValidElements:function(t){return t.getParam("paste_word_valid_elements","-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody")},shouldConvertWordFakeLists:function(t){return t.getParam("paste_convert_word_fake_lists",!0)},shouldUseDefaultFilters:function(t){return t.getParam("paste_enable_default_filters",!0)}},r=function(t,e,n){var r,o,i;"text"===e.pasteFormat.get()?(e.pasteFormat.set("html"),s(t,!1)):(e.pasteFormat.set("text"),s(t,!0),i=t,!1===n.get()&&g.shouldPlainTextInform(i)&&(o="Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.",(r=t).notificationManager.open({text:r.translate(o),type:"info"}),n.set(!0))),t.focus()},c=function(t,n,e){t.addCommand("mceTogglePlainTextPaste",function(){r(t,n,e)}),t.addCommand("mceInsertClipboardContent",function(t,e){e.content&&n.pasteHtml(e.content,e.internal),e.text&&n.pasteText(e.text)})},h=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Delay"),b=tinymce.util.Tools.resolve("tinymce.util.Tools"),o=tinymce.util.Tools.resolve("tinymce.util.VK"),t="x-tinymce/html",i="\x3c!-- "+t+" --\x3e",l=function(t){return i+t},f=function(t){return t.replace(i,"")},w=function(t){return-1!==t.indexOf(i)},x=function(){return t},_=tinymce.util.Tools.resolve("tinymce.html.Entities"),P=function(t){return t.replace(/\r?\n/g,"<br>")},T=function(t,e,n){var r=t.split(/\n\n/),o=function(t,e){var n,r=[],o="<"+t;if("object"==typeof e){for(n in e)e.hasOwnProperty(n)&&r.push(n+'="'+_.encodeAllRaw(e[n])+'"');r.length&&(o+=" "+r.join(" "))}return o+">"}(e,n),i="</"+e+">",a=b.map(r,function(t){return t.split(/\n/).join("<br />")});return 1===a.length?a[0]:b.map(a,function(t){return o+t+i}).join("")},D=function(t){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(t)},C=function(t,e,n){return e?T(t,e,n):P(t)},k=tinymce.util.Tools.resolve("tinymce.html.DomParser"),F=tinymce.util.Tools.resolve("tinymce.html.Serializer"),E=tinymce.util.Tools.resolve("tinymce.html.Node"),R=tinymce.util.Tools.resolve("tinymce.html.Schema");function I(e,t){return b.each(t,function(t){e=t.constructor===RegExp?e.replace(t,""):e.replace(t[0],t[1])}),e}var O={filter:I,innerText:function(e){var n=R(),r=k({},n),o="",i=n.getShortEndedElements(),a=b.makeMap("script noscript style textarea video audio iframe object"," "),u=n.getBlockElements();return e=I(e,[/<!\[[^\]]+\]>/g]),function t(e){var n=e.name,r=e;if("br"!==n){if("wbr"!==n)if(i[n]&&(o+=" "),a[n])o+=" ";else{if(3===e.type&&(o+=e.value),!e.shortEnded&&(e=e.firstChild))for(;t(e),e=e.next;);u[n]&&r.next&&(o+="\n","p"===n&&(o+="\n"))}}else o+="\n"}(r.parse(e)),o},trimHtml:function(t){return t=I(t,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,function(t,e,n){return e||n?"\xa0":" "}],/<br class="Apple-interchange-newline">/g,/<br>$/i])},createIdGenerator:function(t){var e=0;return function(){return t+e++}},isMsEdge:function(){return-1!==v.navigator.userAgent.indexOf(" Edge/")}};function S(e){var n,t;return t=[/^[IVXLMCD]{1,2}\.[ \u00a0]/,/^[ivxlmcd]{1,2}\.[ \u00a0]/,/^[a-z]{1,2}[\.\)][ \u00a0]/,/^[A-Z]{1,2}[\.\)][ \u00a0]/,/^[0-9]+\.[ \u00a0]/,/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/],e=e.replace(/^[\u00a0 ]+/,""),b.each(t,function(t){if(t.test(e))return!(n=!0)}),n}function A(t){var i,a,u=1;function n(t){var e="";if(3===t.type)return t.value;if(t=t.firstChild)for(;e+=n(t),t=t.next;);return e}function s(t,e){if(3===t.type&&e.test(t.value))return t.value=t.value.replace(e,""),!1;if(t=t.firstChild)do{if(!s(t,e))return!1}while(t=t.next);return!0}function e(e,n,r){var o=e._listLevel||u;o!==u&&(o<u?i&&(i=i.parent.parent):(a=i,i=null)),i&&i.name===n?i.append(e):(a=a||i,i=new E(n,1),1<r&&i.attr("start",""+r),e.wrap(i)),e.name="li",u<o&&a&&a.lastChild.append(i),u=o,function t(e){if(e._listIgnore)e.remove();else if(e=e.firstChild)for(;t(e),e=e.next;);}(e),s(e,/^\u00a0+/),s(e,/^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/),s(e,/^\u00a0+/)}for(var r=[],o=t.firstChild;null!=o;)if(r.push(o),null!==(o=o.walk()))for(;void 0!==o&&o.parent!==t;)o=o.walk();for(var c=0;c<r.length;c++)if("p"===(t=r[c]).name&&t.firstChild){var l=n(t);if(/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(l)){e(t,"ul");continue}if(S(l)){var f=/([0-9]+)\./.exec(l),d=1;f&&(d=parseInt(f[1],10)),e(t,"ol",d);continue}if(t._listLevel){e(t,"ul",1);continue}i=null}else a=i,i=null}function j(n,r,o,i){var a,u={},t=n.dom.parseStyle(i);return b.each(t,function(t,e){switch(e){case"mso-list":(a=/\w+ \w+([0-9]+)/i.exec(i))&&(o._listLevel=parseInt(a[1],10)),/Ignore/i.test(t)&&o.firstChild&&(o._listIgnore=!0,o.firstChild._listIgnore=!0);break;case"horiz-align":e="text-align";break;case"vert-align":e="vertical-align";break;case"font-color":case"mso-foreground":e="color";break;case"mso-background":case"mso-highlight":e="background";break;case"font-weight":case"font-style":return void("normal"!==t&&(u[e]=t));case"mso-element":if(/^(comment|comment-list)$/i.test(t))return void o.remove()}0!==e.indexOf("mso-comment")?0!==e.indexOf("mso-")&&("all"===g.getRetainStyleProps(n)||r&&r[e])&&(u[e]=t):o.remove()}),/(bold)/i.test(u["font-weight"])&&(delete u["font-weight"],o.wrap(new E("b",1))),/(italic)/i.test(u["font-style"])&&(delete u["font-style"],o.wrap(new E("i",1))),(u=n.dom.serializeStyle(u,o.name))||null}var M,L,N,B,H,$,W,U,z,V={preProcess:function(t,e){return g.shouldUseDefaultFilters(t)?function(r,t){var e,o;(e=g.getRetainStyleProps(r))&&(o=b.makeMap(e.split(/[, ]/))),t=O.filter(t,[/<br class="?Apple-interchange-newline"?>/gi,/<b[^>]+id="?docs-internal-[^>]*>/gi,/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(t,e){return 0<e.length?e.replace(/./," ").slice(Math.floor(e.length/2)).split("").join("\xa0"):""}]]);var n=g.getWordValidElements(r),i=R({valid_elements:n,valid_children:"-li[p]"});b.each(i.elements,function(t){t.attributes["class"]||(t.attributes["class"]={},t.attributesOrder.push("class")),t.attributes.style||(t.attributes.style={},t.attributesOrder.push("style"))});var a=k({},i);a.addAttributeFilter("style",function(t){for(var e,n=t.length;n--;)(e=t[n]).attr("style",j(r,o,e,e.attr("style"))),"span"===e.name&&e.parent&&!e.attributes.length&&e.unwrap()}),a.addAttributeFilter("class",function(t){for(var e,n,r=t.length;r--;)n=(e=t[r]).attr("class"),/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(n)&&e.remove(),e.attr("class",null)}),a.addNodeFilter("del",function(t){for(var e=t.length;e--;)t[e].remove()}),a.addNodeFilter("a",function(t){for(var e,n,r,o=t.length;o--;)if(n=(e=t[o]).attr("href"),r=e.attr("name"),n&&-1!==n.indexOf("#_msocom_"))e.remove();else if(n&&0===n.indexOf("file://")&&(n=n.split("#")[1])&&(n="#"+n),n||r){if(r&&!/^_?(?:toc|edn|ftn)/i.test(r)){e.unwrap();continue}e.attr({href:n,name:r})}else e.unwrap()});var u=a.parse(t);return g.shouldConvertWordFakeLists(r)&&A(u),t=F({validate:r.settings.validate},i).serialize(u)}(t,e):e},isWordContent:function(t){return/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(t)||/class="OutlineElement/.test(t)||/id="?docs\-internal\-guid\-/.test(t)}},K=function(t,e){return{content:t,cancelled:e}},q=function(t,e,n,r){var o,i,a,u,s,c,l=d(t,e,n,r),f=function(t,e){var n=k({},t.schema);n.addNodeFilter("meta",function(t){b.each(t,function(t){return t.remove()})});var r=n.parse(e,{forced_root_block:!1,isRootContent:!0});return F({validate:t.settings.validate},t.schema).serialize(r)}(t,l.content);return t.hasEventListeners("PastePostProcess")&&!l.isDefaultPrevented()?(i=f,a=n,u=r,s=(o=t).dom.create("div",{style:"display:none"},i),c=m(o,s,a,u),K(c.node.innerHTML,c.isDefaultPrevented())):K(f,l.isDefaultPrevented())},G=function(t,e,n){var r=V.isWordContent(e),o=r?V.preProcess(t,e):e;return q(t,o,n,r)},X=function(t,e){return t.insertContent(e,{merge:g.shouldMergeFormats(t),paste:!0}),!0},Y=function(t){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(t)},Z=function(t){return Y(t)&&/.(gif|jpe?g|png)$/.test(t)},J=function(t,e,n){return!(!1!==t.selection.isCollapsed()||!Y(e)||(o=e,i=n,(r=t).undoManager.extra(function(){i(r,o)},function(){r.execCommand("mceInsertLink",!1,o)}),0));var r,o,i},Q=function(t,e,n){return!!Z(e)&&(o=e,i=n,(r=t).undoManager.extra(function(){i(r,o)},function(){r.insertContent('<img src="'+o+'">')}),!0);var r,o,i},tt=function(t,e){var n,r;!1===g.isSmartPasteEnabled(t)?X(t,e):(n=t,r=e,b.each([J,Q,X],function(t){return!0!==t(n,r,X)}))},et=function(){},nt=function(t){return function(){return t}},rt=nt(!1),ot=nt(!0),it=function(){return at},at=(M=function(t){return t.isNone()},B={fold:function(t,e){return t()},is:rt,isSome:rt,isNone:ot,getOr:N=function(t){return t},getOrThunk:L=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:nt(null),getOrUndefined:nt(undefined),or:N,orThunk:L,map:it,each:et,bind:it,exists:rt,forall:ot,filter:it,equals:M,equals_:M,toArray:function(){return[]},toString:nt("none()")},Object.freeze&&Object.freeze(B),B),ut=function(n){var t=nt(n),e=function(){return o},r=function(t){return t(n)},o={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:ot,isNone:rt,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return ut(t(n))},each:function(t){t(n)},bind:r,exists:r,forall:r,filter:function(t){return t(n)?o:at},toArray:function(){return[n]},toString:function(){return"some("+n+")"},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(rt,function(t){return e(n,t)})}};return o},st={some:ut,none:it,from:function(t){return null===t||t===undefined?at:ut(t)}},ct=(H="function",function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&(Array.prototype.isPrototypeOf(t)||t.constructor&&"Array"===t.constructor.name)?"array":"object"===e&&(String.prototype.isPrototypeOf(t)||t.constructor&&"String"===t.constructor.name)?"string":e}(t)===H}),lt=Array.prototype.slice,ft=function(t,e){for(var n=t.length,r=new Array(n),o=0;o<n;o++){var i=t[o];r[o]=e(i,o)}return r},dt=function(t,e){for(var n=0,r=t.length;n<r;n++)e(t[n],n)},mt=ct(Array.from)?Array.from:function(t){return lt.call(t)},pt={},gt={exports:pt};$=undefined,W=pt,U=gt,z=undefined,function(t){"object"==typeof W&&void 0!==U?U.exports=t():"function"==typeof $&&$.amd?$([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EphoxContactWrapper=t()}(function(){return function i(a,u,s){function c(e,t){if(!u[e]){if(!a[e]){var n="function"==typeof z&&z;if(!t&&n)return n(e,!0);if(l)return l(e,!0);var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}var o=u[e]={exports:{}};a[e][0].call(o.exports,function(t){return c(a[e][1][t]||t)},o,o.exports,i,a,u,s)}return u[e].exports}for(var l="function"==typeof z&&z,t=0;t<s.length;t++)c(s[t]);return c}({1:[function(t,e,n){var r,o,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(t){r=a}try{o="function"==typeof clearTimeout?clearTimeout:u}catch(t){o=u}}();var c,l=[],f=!1,d=-1;function m(){f&&c&&(f=!1,c.length?l=c.concat(l):d=-1,l.length&&p())}function p(){if(!f){var t=s(m);f=!0;for(var e=l.length;e;){for(c=l,l=[];++d<e;)c&&c[d].run();d=-1,e=l.length}c=null,f=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===u||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(t)}}function g(t,e){this.fun=t,this.array=e}function v(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new g(t,e)),1!==l.length||f||s(p)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=v,i.addListener=v,i.once=v,i.off=v,i.removeListener=v,i.removeAllListeners=v,i.emit=v,i.prependListener=v,i.prependOnceListener=v,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],2:[function(t,f,e){(function(n){!function(t){var e=setTimeout;function r(){}function a(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],l(t,this)}function o(r,o){for(;3===r._state;)r=r._value;0!==r._state?(r._handled=!0,a._immediateFn(function(){var t=1===r._state?o.onFulfilled:o.onRejected;if(null!==t){var e;try{e=t(r._value)}catch(n){return void u(o.promise,n)}i(o.promise,e)}else(1===r._state?i:u)(o.promise,r._value)})):r._deferreds.push(o)}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof a)return t._state=3,t._value=e,void s(t);if("function"==typeof n)return void l((r=n,o=e,function(){r.apply(o,arguments)}),t)}t._state=1,t._value=e,s(t)}catch(i){u(t,i)}var r,o}function u(t,e){t._state=2,t._value=e,s(t)}function s(t){2===t._state&&0===t._deferreds.length&&a._immediateFn(function(){t._handled||a._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e<n;e++)o(t,t._deferreds[e]);t._deferreds=null}function c(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function l(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,u(e,t))})}catch(r){if(n)return;n=!0,u(e,r)}}a.prototype["catch"]=function(t){return this.then(null,t)},a.prototype.then=function(t,e){var n=new this.constructor(r);return o(this,new c(t,e,n)),n},a.all=function(t){var s=Array.prototype.slice.call(t);return new a(function(o,i){if(0===s.length)return o([]);var a=s.length;function u(e,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void n.call(t,function(t){u(e,t)},i)}s[e]=t,0==--a&&o(s)}catch(r){i(r)}}for(var t=0;t<s.length;t++)u(t,s[t])})},a.resolve=function(e){return e&&"object"==typeof e&&e.constructor===a?e:new a(function(t){t(e)})},a.reject=function(n){return new a(function(t,e){e(n)})},a.race=function(o){return new a(function(t,e){for(var n=0,r=o.length;n<r;n++)o[n].then(t,e)})},a._immediateFn="function"==typeof n?function(t){n(t)}:function(t){e(t,0)},a._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)},a._setImmediateFn=function(t){a._immediateFn=t},a._setUnhandledRejectionFn=function(t){a._unhandledRejectionFn=t},void 0!==f&&f.exports?f.exports=a:t.Promise||(t.Promise=a)}(this)}).call(this,t("timers").setImmediate)},{timers:3}],3:[function(s,t,c){(function(t,e){var r=s("process/browser.js").nextTick,n=Function.prototype.apply,o=Array.prototype.slice,i={},a=0;function u(t,e){this._id=t,this._clearFn=e}c.setTimeout=function(){return new u(n.call(setTimeout,window,arguments),clearTimeout)},c.setInterval=function(){return new u(n.call(setInterval,window,arguments),clearInterval)},c.clearTimeout=c.clearInterval=function(t){t.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},c.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},c.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},c._unrefActive=c.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;0<=e&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},c.setImmediate="function"==typeof t?t:function(t){var e=a++,n=!(arguments.length<2)&&o.call(arguments,1);return i[e]=!0,r(function(){i[e]&&(n?t.apply(null,n):t.call(null),c.clearImmediate(e))}),e},c.clearImmediate="function"==typeof e?e:function(t){delete i[t]}}).call(this,s("timers").setImmediate,s("timers").clearImmediate)},{"process/browser.js":1,timers:3}],4:[function(t,e,n){var r=t("promise-polyfill"),o="undefined"!=typeof window?window:Function("return this;")();e.exports={boltExport:o.Promise||r}},{"promise-polyfill":2}]},{},[4])(4)});var vt=gt.exports.boltExport,ht=function(t){var n=st.none(),e=[],r=function(t){o()?a(t):e.push(t)},o=function(){return n.isSome()},i=function(t){dt(t,a)},a=function(e){n.each(function(t){v.setTimeout(function(){e(t)},0)})};return t(function(t){n=st.some(t),i(e),e=[]}),{get:r,map:function(n){return ht(function(e){r(function(t){e(n(t))})})},isReady:o}},yt={nu:ht,pure:function(e){return ht(function(t){t(e)})}},bt=function(t){v.setTimeout(function(){throw t},0)},wt=function(n){var t=function(t){n().then(t,bt)};return{map:function(t){return wt(function(){return n().then(t)})},bind:function(e){return wt(function(){return n().then(function(t){return e(t).toPromise()})})},anonBind:function(t){return wt(function(){return n().then(function(){return t.toPromise()})})},toLazy:function(){return yt.nu(t)},toCached:function(){var t=null;return wt(function(){return null===t&&(t=n()),t})},toPromise:n,get:t}},xt=function(t){return wt(function(){return new vt(t)})},_t=function(a,t){return t(function(r){var o=[],i=0;0===a.length?r([]):dt(a,function(t,e){var n;t.get((n=e,function(t){o[n]=t,++i>=a.length&&r(o)}))})})},Pt=function(t,e){return n=ft(t,e),_t(n,xt);var n},Tt=function(t,e,n){var r=n||w(e),o=G(t,f(e),r);!1===o.cancelled&&tt(t,o.content)},Dt=function(t,e){e=t.dom.encode(e).replace(/\r\n/g,"\n"),e=C(e,t.settings.forced_root_block,t.settings.forced_root_block_attrs),Tt(t,e,!1)},Ct=function(t){var e={};if(t){if(t.getData){var n=t.getData("Text");n&&0<n.length&&-1===n.indexOf("data:text/mce-internal,")&&(e["text/plain"]=n)}if(t.types)for(var r=0;r<t.types.length;r++){var o=t.types[r];try{e[o]=t.getData(o)}catch(i){e[o]=""}}}return e},kt=function(t,e){return e in t&&0<t[e].length},Ft=function(t){return kt(t,"text/html")||kt(t,"text/plain")},Et=O.createIdGenerator("mceclip"),Rt=function(e,t,n){var r,o,i,a,u="paste"===t.type?t.clipboardData:t.dataTransfer;if(e.settings.paste_data_images&&u){var s=(i=(o=u).items?ft(mt(o.items),function(t){return t.getAsFile()}):[],a=o.files?mt(o.files):[],function(t,e){for(var n=[],r=0,o=t.length;r<o;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(0<i.length?i:a,function(t){return/^image\/(jpeg|png|gif|bmp)$/.test(t.type)}));if(0<s.length)return t.preventDefault(),(r=s,Pt(r,function(r){return xt(function(t){var e=r.getAsFile?r.getAsFile():r,n=new window.FileReader;n.onload=function(){t({blob:e,uri:n.result})},n.readAsDataURL(e)})})).get(function(t){n&&e.selection.setRng(n),dt(t,function(t){!function(t,e){var n,r,o,i,a,u,s,c=(n=e.uri,-1!==(r=n.indexOf(","))?n.substr(r+1):null),l=Et(),f=t.settings.images_reuse_filename&&e.blob.name?(o=t,i=e.blob.name,(a=i.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i))?o.dom.encode(a[1]):null):l,d=new v.Image;if(d.src=e.uri,u=t.settings,s=d,!u.images_dataimg_filter||u.images_dataimg_filter(s)){var m,p=t.editorUpload.blobCache,g=void 0;(m=p.findFirst(function(t){return t.base64()===c}))?g=m:(g=p.create(l,e.blob,c,f),p.add(g)),Tt(t,'<img src="'+g.blobUri()+'">',!1)}else Tt(t,'<img src="'+e.uri+'">',!1)}(e,t)})}),!0}return!1},It=function(t){return o.metaKeyPressed(t)&&86===t.keyCode||t.shiftKey&&45===t.keyCode},Ot=function(s,c,l){var e,f,d=(e=p(st.none()),{clear:function(){e.set(st.none())},set:function(t){e.set(st.some(t))},isSet:function(){return e.get().isSome()},on:function(t){e.get().each(t)}});function m(t,e,n,r){var o,i;kt(t,"text/html")?o=t["text/html"]:(o=c.getHtml(),r=r||w(o),c.isDefaultContent(o)&&(n=!0)),o=O.trimHtml(o),c.remove(),i=!1===r&&D(o),o.length&&!i||(n=!0),n&&(o=kt(t,"text/plain")&&i?t["text/plain"]:O.innerText(o)),c.isDefaultContent(o)?e||s.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."):n?Dt(s,o):Tt(s,o,r)}s.on("keydown",function(t){function e(t){It(t)&&!t.isDefaultPrevented()&&c.remove()}if(It(t)&&!t.isDefaultPrevented()){if((f=t.shiftKey&&86===t.keyCode)&&h.webkit&&-1!==v.navigator.userAgent.indexOf("Version/"))return;if(t.stopImmediatePropagation(),d.set(t),window.setTimeout(function(){d.clear()},100),h.ie&&f)return t.preventDefault(),void n(s,!0);c.remove(),c.create(),s.once("keyup",e),s.once("paste",function(){s.off("keyup",e)})}}),s.on("paste",function(t){var e,n,r,o=d.isSet(),i=(e=s,n=Ct(t.clipboardData||e.getDoc().dataTransfer),O.isMsEdge()?b.extend(n,{"text/html":""}):n),a="text"===l.get()||f,u=kt(i,x());f=!1,t.isDefaultPrevented()||(r=t.clipboardData,-1!==v.navigator.userAgent.indexOf("Android")&&r&&r.items&&0===r.items.length)?c.remove():Ft(i)||!Rt(s,t,c.getLastRng()||s.selection.getRng())?(o||t.preventDefault(),!h.ie||o&&!t.ieFake||kt(i,"text/html")||(c.create(),s.dom.bind(c.getEl(),"paste",function(t){t.stopPropagation()}),s.getDoc().execCommand("Paste",!1,null),i["text/html"]=c.getHtml()),kt(i,"text/html")?(t.preventDefault(),u||(u=w(i["text/html"])),m(i,o,a,u)):y.setEditorTimeout(s,function(){m(i,o,a,u)},0)):c.remove()})},St=function(t){return h.ie&&t.inline?v.document.body:t.getBody()},At=function(e,t,n){var r;St(r=e)!==r.getBody()&&e.dom.bind(t,"paste keyup",function(t){Lt(e,n)||e.fire("paste")})},jt=function(t){return t.dom.get("mcepastebin")},Mt=function(t,e){return e===t},Lt=function(t,e){var n,r=jt(t);return(n=r)&&"mcepastebin"===n.id&&Mt(e,r.innerHTML)},Nt=function(a){var u=p(null),s="%MCEPASTEBIN%";return{create:function(){return e=u,n=s,o=(t=a).dom,i=t.getBody(),e.set(t.selection.getRng()),r=t.dom.add(St(t),"div",{id:"mcepastebin","class":"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},n),(h.ie||h.gecko)&&o.setStyle(r,"left","rtl"===o.getStyle(i,"direction",!0)?65535:-65535),o.bind(r,"beforedeactivate focusin focusout",function(t){t.stopPropagation()}),At(t,r,n),r.focus(),void t.selection.select(r,!0);var t,e,n,r,o,i},remove:function(){return function(t,e){if(jt(t)){for(var n=void 0,r=e.get();n=t.dom.get("mcepastebin");)t.dom.remove(n),t.dom.unbind(n);r&&t.selection.setRng(r)}e.set(null)}(a,u)},getEl:function(){return jt(a)},getHtml:function(){return function(n){var e,t,r,o,i,a=function(t,e){t.appendChild(e),n.dom.remove(e,!0)};for(t=b.grep(St(n).childNodes,function(t){return"mcepastebin"===t.id}),e=t.shift(),b.each(t,function(t){a(e,t)}),r=(o=n.dom.select("div[id=mcepastebin]",e)).length-1;0<=r;r--)i=n.dom.create("div"),e.insertBefore(i,o[r]),a(i,o[r]);return e?e.innerHTML:""}(a)},getLastRng:function(){return u.get()},isDefault:function(){return Lt(a,s)},isDefaultContent:function(t){return Mt(s,t)}}},Bt=function(n,t){var e=Nt(n);return n.on("preInit",function(){return Ot(a=n,e,t),void a.parser.addNodeFilter("img",function(t,e,n){var r,o=function(t){t.attr("data-mce-object")||u===h.transparentSrc||t.remove()};if(!a.settings.paste_data_images&&(r=n).data&&!0===r.data.paste)for(var i=t.length;i--;)(u=t[i].attributes.map.src)&&(0===u.indexOf("webkit-fake-url")?o(t[i]):a.settings.allow_html_data_urls||0!==u.indexOf("data:")||o(t[i]))});var a,u}),{pasteFormat:t,pasteHtml:function(t,e){return Tt(n,t,e)},pasteText:function(t){return Dt(n,t)},pasteImageData:function(t,e){return Rt(n,t,e)},getDataTransferItems:Ct,hasHtmlOrText:Ft,hasContentType:kt}},Ht=function(){},$t=function(t,e,n){if(r=t,!1!==h.iOS||r===undefined||"function"!=typeof r.setData||!0===O.isMsEdge())return!1;try{return t.clearData(),t.setData("text/html",e),t.setData("text/plain",n),t.setData(x(),e),!0}catch(o){return!1}var r},Wt=function(t,e,n,r){$t(t.clipboardData,e.html,e.text)?(t.preventDefault(),r()):n(e.html,r)},Ut=function(u){return function(t,e){var n=l(t),r=u.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),o=u.dom.create("div",{contenteditable:"true"},n);u.dom.setStyles(r,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),r.appendChild(o),u.dom.add(u.getBody(),r);var i=u.selection.getRng();o.focus();var a=u.dom.createRng();a.selectNodeContents(o),u.selection.setRng(a),setTimeout(function(){u.selection.setRng(i),r.parentNode.removeChild(r),e()},0)}},zt=function(t){return{html:t.selection.getContent({contextual:!0}),text:t.selection.getContent({format:"text"})}},Vt=function(t){return!t.selection.isCollapsed()||!!(e=t).dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody());var e},Kt=function(t){var e,n;t.on("cut",(e=t,function(t){Vt(e)&&Wt(t,zt(e),Ut(e),function(){setTimeout(function(){e.execCommand("Delete")},0)})})),t.on("copy",(n=t,function(t){Vt(n)&&Wt(t,zt(n),Ut(n),Ht)}))},qt=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),Gt=function(t,e){return qt.getCaretRangeFromPoint(e.clientX,e.clientY,t.getDoc())},Xt=function(t,e){t.focus(),t.selection.setRng(e)},Yt=function(a,u,s){g.shouldBlockDrop(a)&&a.on("dragend dragover draggesture dragdrop drop drag",function(t){t.preventDefault(),t.stopPropagation()}),g.shouldPasteDataImages(a)||a.on("drop",function(t){var e=t.dataTransfer;e&&e.files&&0<e.files.length&&t.preventDefault()}),a.on("drop",function(t){var e,n;if(n=Gt(a,t),!t.isDefaultPrevented()&&!s.get()){e=u.getDataTransferItems(t.dataTransfer);var r,o=u.hasContentType(e,x());if((u.hasHtmlOrText(e)&&(!(r=e["text/plain"])||0!==r.indexOf("file://"))||!u.pasteImageData(t,n))&&n&&g.shouldFilterDrop(a)){var i=e["mce-internal"]||e["text/html"]||e["text/plain"];i&&(t.preventDefault(),y.setEditorTimeout(a,function(){a.undoManager.transact(function(){e["mce-internal"]&&a.execCommand("Delete"),Xt(a,n),i=O.trimHtml(i),e["text/html"]?u.pasteHtml(i,o):u.pasteText(i)})}))}}}),a.on("dragstart",function(t){s.set(!0)}),a.on("dragover dragend",function(t){g.shouldPasteDataImages(a)&&!1===s.get()&&(t.preventDefault(),Xt(a,Gt(a,t))),"dragend"===t.type&&s.set(!1)})},Zt=function(t){var e=t.plugins.paste,n=g.getPreProcess(t);n&&t.on("PastePreProcess",function(t){n.call(e,e,t)});var r=g.getPostProcess(t);r&&t.on("PastePostProcess",function(t){r.call(e,e,t)})};function Jt(e,n){e.on("PastePreProcess",function(t){t.content=n(e,t.content,t.internal,t.wordContent)})}function Qt(t,e){if(!V.isWordContent(e))return e;var n=[];b.each(t.schema.getBlockElements(),function(t,e){n.push(e)});var r=new RegExp("(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?("+n.join("|")+")[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*","g");return e=O.filter(e,[[r,"$1"]]),e=O.filter(e,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}function te(t,e,n,r){if(r||n)return e;var c,o=g.getWebkitStyles(t);if(!1===g.shouldRemoveWebKitStyles(t)||"all"===o)return e;if(o&&(c=o.split(/[, ]/)),c){var l=t.dom,f=t.selection.getNode();e=e.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(t,e,n,r){var o=l.parseStyle(l.decode(n)),i={};if("none"===c)return e+r;for(var a=0;a<c.length;a++){var u=o[c[a]],s=l.getStyle(f,c[a],!0);/color/.test(c[a])&&(u=l.toHex(u),s=l.toHex(s)),s!==u&&(i[c[a]]=u)}return(i=l.serializeStyle(i,"span"))?e+' style="'+i+'"'+r:e+r})}else e=e.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return e=e.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(t,e,n,r){return e+' style="'+n+'"'+r})}function ee(n,t){n.$("a",t).find("font,u").each(function(t,e){n.dom.remove(e,!0)})}var ne=function(t){var e,n;h.webkit&&Jt(t,te),h.ie&&(Jt(t,Qt),n=ee,(e=t).on("PastePostProcess",function(t){n(e,t.node)}))},re=function(t,e,n){var r=n.control;r.active("text"===e.pasteFormat.get()),t.on("PastePlainTextToggle",function(t){r.active(t.state)})},oe=function(t,e){var n=function(r){for(var o=[],t=1;t<arguments.length;t++)o[t-1]=arguments[t];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o.concat(t);return r.apply(null,n)}}(re,t,e);t.addButton("pastetext",{active:!1,icon:"pastetext",tooltip:"Paste as text",cmd:"mceTogglePlainTextPaste",onPostRender:n}),t.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:e.pasteFormat,cmd:"mceTogglePlainTextPaste",onPostRender:n})};e.add("paste",function(t){if(!1===a(t)){var e=p(!1),n=p(!1),r=p(g.isPasteAsTextEnabled(t)?"text":"html"),o=Bt(t,r),i=ne(t);return oe(t,o),c(t,o,e),Zt(t),Kt(t),Yt(t,o,n),u(o,i)}})}(window);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/tabfocus/plugin.js b/wp-includes/js/tinymce/plugins/tabfocus/plugin.js new file mode 100644 index 0000000..44cf944 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/tabfocus/plugin.js @@ -0,0 +1,124 @@ +(function () { +var tabfocus = (function (domGlobals) { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.EditorManager'); + + var global$3 = tinymce.util.Tools.resolve('tinymce.Env'); + + var global$4 = tinymce.util.Tools.resolve('tinymce.util.Delay'); + + var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var global$6 = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var getTabFocusElements = function (editor) { + return editor.getParam('tabfocus_elements', ':prev,:next'); + }; + var getTabFocus = function (editor) { + return editor.getParam('tab_focus', getTabFocusElements(editor)); + }; + var Settings = { getTabFocus: getTabFocus }; + + var DOM = global$1.DOM; + var tabCancel = function (e) { + if (e.keyCode === global$6.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) { + e.preventDefault(); + } + }; + var setup = function (editor) { + function tabHandler(e) { + var x, el, v, i; + if (e.keyCode !== global$6.TAB || 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) && global$2.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el); + } + global$5.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 = global$5.explode(Settings.getTabFocus(editor)); + if (v.length === 1) { + v[1] = v[0]; + v[0] = ':prev'; + } + 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 = global$2.get(el.id || el.name); + if (el.id && focusEditor) { + focusEditor.focus(); + } else { + global$4.setTimeout(function () { + if (!global$3.webkit) { + domGlobals.window.focus(); + } + el.focus(); + }, 10); + } + e.preventDefault(); + } + } + editor.on('init', function () { + if (editor.inline) { + DOM.setAttrib(editor.getBody(), 'tabIndex', null); + } + editor.on('keyup', tabCancel); + if (global$3.gecko) { + editor.on('keypress keydown', tabHandler); + } else { + editor.on('keydown', tabHandler); + } + }); + }; + var Keyboard = { setup: setup }; + + global.add('tabfocus', function (editor) { + Keyboard.setup(editor); + }); + function Plugin () { + } + + return Plugin; + +}(window)); +})(); diff --git a/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js b/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js new file mode 100644 index 0000000..8c460ec --- /dev/null +++ b/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js @@ -0,0 +1 @@ +!function(c){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=tinymce.util.Tools.resolve("tinymce.EditorManager"),a=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Delay"),f=tinymce.util.Tools.resolve("tinymce.util.Tools"),d=tinymce.util.Tools.resolve("tinymce.util.VK"),m=function(e){return e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))},v=t.DOM,n=function(e){e.keyCode!==d.TAB||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()},i=function(r){function e(n){var i,o,e,l;if(!(n.keyCode!==d.TAB||n.ctrlKey||n.altKey||n.metaKey||n.isDefaultPrevented())&&(1===(e=f.explode(m(r))).length&&(e[1]=e[0],e[0]=":prev"),o=n.shiftKey?":prev"===e[0]?u(-1):v.get(e[0]):":next"===e[1]?u(1):v.get(e[1]))){var t=s.get(o.id||o.name);o.id&&t?t.focus():y.setTimeout(function(){a.webkit||c.window.focus(),o.focus()},10),n.preventDefault()}function u(e){function t(t){return/INPUT|TEXTAREA|BUTTON/.test(t.tagName)&&s.get(n.id)&&-1!==t.tabIndex&&function e(t){return"BODY"===t.nodeName||"hidden"!==t.type&&"none"!==t.style.display&&"hidden"!==t.style.visibility&&e(t.parentNode)}(t)}if(o=v.select(":input:enabled,*[tabindex]:not(iframe)"),f.each(o,function(e,t){if(e.id===r.id)return i=t,!1}),0<e){for(l=i+1;l<o.length;l++)if(t(o[l]))return o[l]}else for(l=i-1;0<=l;l--)if(t(o[l]))return o[l];return null}}r.on("init",function(){r.inline&&v.setAttrib(r.getBody(),"tabIndex",null),r.on("keyup",n),a.gecko?r.on("keypress keydown",e):r.on("keydown",e)})};e.add("tabfocus",function(e){i(e)})}(window);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/textcolor/plugin.js b/wp-includes/js/tinymce/plugins/textcolor/plugin.js new file mode 100644 index 0000000..172916b --- /dev/null +++ b/wp-includes/js/tinymce/plugins/textcolor/plugin.js @@ -0,0 +1,346 @@ +(function () { +var textcolor = (function () { + 'use strict'; + + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + + var getCurrentColor = function (editor, format) { + var color; + editor.dom.getParents(editor.selection.getStart(), function (elm) { + var value; + if (value = elm.style[format === 'forecolor' ? 'color' : 'background-color']) { + color = color ? color : value; + } + }); + return color; + }; + var mapColors = function (colorMap) { + var i; + var colors = []; + for (i = 0; i < colorMap.length; i += 2) { + colors.push({ + text: colorMap[i + 1], + color: '#' + colorMap[i] + }); + } + return colors; + }; + var applyFormat = function (editor, format, value) { + editor.undoManager.transact(function () { + editor.focus(); + editor.formatter.apply(format, { value: value }); + editor.nodeChanged(); + }); + }; + var removeFormat = function (editor, format) { + editor.undoManager.transact(function () { + editor.focus(); + editor.formatter.remove(format, { value: null }, null, true); + editor.nodeChanged(); + }); + }; + var TextColor = { + getCurrentColor: getCurrentColor, + mapColors: mapColors, + applyFormat: applyFormat, + removeFormat: removeFormat + }; + + var register = function (editor) { + editor.addCommand('mceApplyTextcolor', function (format, value) { + TextColor.applyFormat(editor, format, value); + }); + editor.addCommand('mceRemoveTextcolor', function (format) { + TextColor.removeFormat(editor, format); + }); + }; + var Commands = { register: register }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var defaultColorMap = [ + '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' + ]; + var getTextColorMap = function (editor) { + return editor.getParam('textcolor_map', defaultColorMap); + }; + var getForeColorMap = function (editor) { + return editor.getParam('forecolor_map', getTextColorMap(editor)); + }; + var getBackColorMap = function (editor) { + return editor.getParam('backcolor_map', getTextColorMap(editor)); + }; + var getTextColorRows = function (editor) { + return editor.getParam('textcolor_rows', 5); + }; + var getTextColorCols = function (editor) { + return editor.getParam('textcolor_cols', 8); + }; + var getForeColorRows = function (editor) { + return editor.getParam('forecolor_rows', getTextColorRows(editor)); + }; + var getBackColorRows = function (editor) { + return editor.getParam('backcolor_rows', getTextColorRows(editor)); + }; + var getForeColorCols = function (editor) { + return editor.getParam('forecolor_cols', getTextColorCols(editor)); + }; + var getBackColorCols = function (editor) { + return editor.getParam('backcolor_cols', getTextColorCols(editor)); + }; + var getColorPickerCallback = function (editor) { + return editor.getParam('color_picker_callback', null); + }; + var hasColorPicker = function (editor) { + return typeof getColorPickerCallback(editor) === 'function'; + }; + var Settings = { + getForeColorMap: getForeColorMap, + getBackColorMap: getBackColorMap, + getForeColorRows: getForeColorRows, + getBackColorRows: getBackColorRows, + getForeColorCols: getForeColorCols, + getBackColorCols: getBackColorCols, + getColorPickerCallback: getColorPickerCallback, + hasColorPicker: hasColorPicker + }; + + var global$3 = tinymce.util.Tools.resolve('tinymce.util.I18n'); + + var getHtml = function (cols, rows, colorMap, hasColorPicker) { + var colors, color, html, last, x, y, i, count = 0; + var id = global$1.DOM.uniqueId('mcearia'); + var getColorCellHtml = function (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="' + global$3.translate(title) + '">' + (isNoColor ? '×' : '') + '</div>' + '</td>'; + }; + colors = TextColor.mapColors(colorMap); + colors.push({ + text: global$3.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 (hasColorPicker) { + 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">' + global$3.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; + }; + var ColorPickerHtml = { getHtml: getHtml }; + + var setDivColor = function setDivColor(div, value) { + div.style.background = value; + div.setAttribute('data-mce-color', value); + }; + var onButtonClick = function (editor) { + return function (e) { + var ctrl = e.control; + if (ctrl._color) { + editor.execCommand('mceApplyTextcolor', ctrl.settings.format, ctrl._color); + } else { + editor.execCommand('mceRemoveTextcolor', ctrl.settings.format); + } + }; + }; + var onPanelClick = function (editor, cols) { + return function (e) { + var buttonCtrl = this.parent(); + var value; + var currentColor = TextColor.getCurrentColor(editor, buttonCtrl.settings.format); + var selectColor = function (value) { + editor.execCommand('mceApplyTextcolor', buttonCtrl.settings.format, value); + buttonCtrl.hidePanel(); + buttonCtrl.color(value); + }; + var resetColor = function () { + editor.execCommand('mceRemoveTextcolor', buttonCtrl.settings.format); + buttonCtrl.hidePanel(); + buttonCtrl.resetColor(); + }; + if (global$1.DOM.getParent(e.target, '.mce-custom-color-btn')) { + buttonCtrl.hidePanel(); + var colorPickerCallback = Settings.getColorPickerCallback(editor); + colorPickerCallback.call(editor, function (value) { + var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0]; + var customColorCells, div, i; + customColorCells = global$2.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; + } + } + 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); + }, currentColor); + } + value = e.target.getAttribute('data-mce-color'); + if (value) { + if (this.lastId) { + global$1.DOM.get(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(); + } + }; + }; + var renderColorPicker = function (editor, foreColor) { + return function () { + var cols = foreColor ? Settings.getForeColorCols(editor) : Settings.getBackColorCols(editor); + var rows = foreColor ? Settings.getForeColorRows(editor) : Settings.getBackColorRows(editor); + var colorMap = foreColor ? Settings.getForeColorMap(editor) : Settings.getBackColorMap(editor); + var hasColorPicker = Settings.hasColorPicker(editor); + return ColorPickerHtml.getHtml(cols, rows, colorMap, hasColorPicker); + }; + }; + var register$1 = function (editor) { + editor.addButton('forecolor', { + type: 'colorbutton', + tooltip: 'Text color', + format: 'forecolor', + panel: { + role: 'application', + ariaRemember: true, + html: renderColorPicker(editor, true), + onclick: onPanelClick(editor, Settings.getForeColorCols(editor)) + }, + onclick: onButtonClick(editor) + }); + editor.addButton('backcolor', { + type: 'colorbutton', + tooltip: 'Background color', + format: 'hilitecolor', + panel: { + role: 'application', + ariaRemember: true, + html: renderColorPicker(editor, false), + onclick: onPanelClick(editor, Settings.getBackColorCols(editor)) + }, + onclick: onButtonClick(editor) + }); + }; + var Buttons = { register: register$1 }; + + global.add('textcolor', function (editor) { + Commands.register(editor); + Buttons.register(editor); + }); + function Plugin () { + } + + return Plugin; + +}()); +})(); diff --git a/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js b/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js new file mode 100644 index 0000000..f0996f1 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js @@ -0,0 +1 @@ +!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=function(t,o){var r;return t.dom.getParents(t.selection.getStart(),function(t){var e;(e=t.style["forecolor"===o?"color":"background-color"])&&(r=r||e)}),r},g=function(t){var e,o=[];for(e=0;e<t.length;e+=2)o.push({text:t[e+1],color:"#"+t[e]});return o},r=function(t,e,o){t.undoManager.transact(function(){t.focus(),t.formatter.apply(e,{value:o}),t.nodeChanged()})},e=function(t,e){t.undoManager.transact(function(){t.focus(),t.formatter.remove(e,{value:null},null,!0),t.nodeChanged()})},o=function(o){o.addCommand("mceApplyTextcolor",function(t,e){r(o,t,e)}),o.addCommand("mceRemoveTextcolor",function(t){e(o,t)})},F=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),i=tinymce.util.Tools.resolve("tinymce.util.Tools"),a=["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"],l=function(t){return t.getParam("textcolor_map",a)},c=function(t){return t.getParam("textcolor_rows",5)},u=function(t){return t.getParam("textcolor_cols",8)},m=function(t){return t.getParam("color_picker_callback",null)},s=function(t){return t.getParam("forecolor_map",l(t))},d=function(t){return t.getParam("backcolor_map",l(t))},f=function(t){return t.getParam("forecolor_rows",c(t))},b=function(t){return t.getParam("backcolor_rows",c(t))},p=function(t){return t.getParam("forecolor_cols",u(t))},C=function(t){return t.getParam("backcolor_cols",u(t))},y=m,v=function(t){return"function"==typeof m(t)},h=tinymce.util.Tools.resolve("tinymce.util.I18n"),P=function(t,e,o,r){var n,a,l,c,i,u,m,s=0,d=F.DOM.uniqueId("mcearia"),f=function(t,e){var o="transparent"===t;return'<td class="mce-grid-cell'+(o?" mce-colorbtn-trans":"")+'"><div id="'+d+"-"+s+++'" data-mce-color="'+(t||"")+'" role="option" tabIndex="-1" style="'+(t?"background-color: "+t:"")+'" title="'+h.translate(e)+'">'+(o?"×":"")+"</div></td>"};for((n=g(o)).push({text:h.translate("No color"),color:"transparent"}),l='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',c=n.length-1,u=0;u<e;u++){for(l+="<tr>",i=0;i<t;i++)l+=c<(m=u*t+i)?"<td></td>":f((a=n[m]).color,a.text);l+="</tr>"}if(r){for(l+='<tr><td colspan="'+t+'" class="mce-custom-color-btn"><div id="'+d+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+d+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+h.translate("Custom...")+"</button></div></td></tr>",l+="<tr>",i=0;i<t;i++)l+=f("","Custom color");l+="</tr>"}return l+="</tbody></table>"},k=function(t,e){t.style.background=e,t.setAttribute("data-mce-color",e)},x=function(o){return function(t){var e=t.control;e._color?o.execCommand("mceApplyTextcolor",e.settings.format,e._color):o.execCommand("mceRemoveTextcolor",e.settings.format)}},T=function(r,c){return function(t){var e,a=this.parent(),o=n(r,a.settings.format),l=function(t){r.execCommand("mceApplyTextcolor",a.settings.format,t),a.hidePanel(),a.color(t)};F.DOM.getParent(t.target,".mce-custom-color-btn")&&(a.hidePanel(),y(r).call(r,function(t){var e,o,r,n=a.panel.getEl().getElementsByTagName("table")[0];for(e=i.map(n.rows[n.rows.length-1].childNodes,function(t){return t.firstChild}),r=0;r<e.length&&(o=e[r]).getAttribute("data-mce-color");r++);if(r===c)for(r=0;r<c-1;r++)k(e[r],e[r+1].getAttribute("data-mce-color"));k(o,t),l(t)},o)),(e=t.target.getAttribute("data-mce-color"))?(this.lastId&&F.DOM.get(this.lastId).setAttribute("aria-selected","false"),t.target.setAttribute("aria-selected",!0),this.lastId=t.target.id,"transparent"===e?(r.execCommand("mceRemoveTextcolor",a.settings.format),a.hidePanel(),a.resetColor()):l(e)):null!==e&&a.hidePanel()}},_=function(n,a){return function(){var t=a?p(n):C(n),e=a?f(n):b(n),o=a?s(n):d(n),r=v(n);return P(t,e,o,r)}},A=function(t){t.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:_(t,!0),onclick:T(t,p(t))},onclick:x(t)}),t.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:_(t,!1),onclick:T(t,C(t))},onclick:x(t)})};t.add("textcolor",function(t){o(t),A(t)})}();
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/wp-includes/js/tinymce/plugins/wordpress/plugin.js new file mode 100644 index 0000000..5aa0bb7 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/plugin.js @@ -0,0 +1,1207 @@ +/* global getUserSetting, setUserSetting */ +( function( tinymce ) { +// Set the minimum value for the modals z-index higher than #wpadminbar (100000). +if ( ! tinymce.ui.FloatPanel.zIndex || tinymce.ui.FloatPanel.zIndex < 100100 ) { + 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 ) ), + wpTooltips = false; + + if ( $ ) { + // Runs as soon as TinyMCE has started initializing, while plugins are loading. + // Handlers attached after the `tinymce.init()` call may not get triggered for this instance. + $( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] ); + } + + function toggleToolbars( state ) { + var initial, toolbars, iframeHeight, + pixels = 0, + classicBlockToolbar = tinymce.$( '.block-library-classic__toolbar' ); + + if ( state === 'hide' ) { + initial = true; + } else if ( classicBlockToolbar.length && ! classicBlockToolbar.hasClass( 'has-advanced-toolbar' ) ) { + // Show the second, third, etc. toolbar rows in the Classic block instance. + classicBlockToolbar.addClass( 'has-advanced-toolbar' ); + state = 'show'; + } + + if ( editor.theme.panel ) { + toolbars = editor.theme.panel.find('.toolbar:not(.menubar)'); + } + + if ( toolbars && toolbars.length > 1 ) { + if ( ! state && toolbars[1].visible() ) { + state = 'hide'; + } + + each( toolbars, function( toolbar, i ) { + if ( i > 0 ) { + if ( state === 'hide' ) { + toolbar.hide(); + pixels += 34; + } else { + toolbar.show(); + pixels -= 34; + } + } + }); + } + + // Resize editor iframe, not needed for iOS and inline instances. + // Don't resize if the editor is in a hidden container. + if ( pixels && ! tinymce.Env.iOS && editor.iframeElement && editor.iframeElement.clientHeight ) { + iframeHeight = editor.iframeElement.clientHeight + pixels; + + // Keep min-height. + if ( iframeHeight > 50 ) { + DOM.setStyle( editor.iframeElement, 'height', iframeHeight ); + } + } + + if ( ! initial ) { + 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' ); + } + }); + + // Hide the toolbars after loading. + editor.on( 'PostRender', function() { + if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) { + toggleToolbars( 'hide' ); + } else { + tinymce.$( '.block-library-classic__toolbar' ).addClass( 'has-advanced-toolbar' ); + } + }); + + editor.addCommand( 'WP_Adv', function() { + toggleToolbars(); + }); + + editor.on( 'focus', function() { + window.wpActiveEditor = editor.id; + }); + + 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" alt="" 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" ' + + 'alt="" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' ); + } + + if ( event.load && event.format !== 'raw' ) { + if ( hasWpautop ) { + event.content = wp.editor.autop( event.content ); + } else { + // Prevent creation of paragraphs out of multiple HTML comments. + event.content = event.content.replace( /-->\s+<!--/g, '--><!--' ); + } + } + + if ( event.content.indexOf( '<script' ) !== -1 || event.content.indexOf( '<style' ) !== -1 ) { + event.content = event.content.replace( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g, function( match, tag ) { + return '<img ' + + 'src="' + tinymce.Env.transparentSrc + '" ' + + 'data-wp-preserve="' + encodeURIComponent( match ) + '" ' + + 'data-mce-resize="false" ' + + 'data-mce-placeholder="1" '+ + 'class="mce-object" ' + + 'width="20" height="20" '+ + 'alt="<' + tag + '>" ' + + 'title="<' + tag + '>" ' + + '/>'; + } ); + } + } + }); + + editor.on( 'setcontent', function() { + // Remove spaces from empty paragraphs. + editor.$( 'p' ).each( function( i, node ) { + if ( node.innerHTML && node.innerHTML.length < 10 ) { + var html = tinymce.trim( node.innerHTML ); + + if ( ! html || html === ' ' ) { + node.innerHTML = ( tinymce.Env.ie && tinymce.Env.ie < 11 ) ? '' : '<br data-mce-bogus="1">'; + } + } + } ); + }); + + editor.on( 'PostProcess', function( event ) { + if ( event.get ) { + event.content = event.content.replace(/<img[^>]+>/g, function( image ) { + var match, + string, + moretext = ''; + + if ( image.indexOf( 'data-wp-more="more"' ) !== -1 ) { + if ( match = image.match( /data-wp-more-text="([^"]+)"/ ) ) { + moretext = match[1]; + } + + string = '<!--more' + moretext + '-->'; + } else if ( image.indexOf( 'data-wp-more="nextpage"' ) !== -1 ) { + string = '<!--nextpage-->'; + } else if ( image.indexOf( 'data-wp-preserve' ) !== -1 ) { + if ( match = image.match( / data-wp-preserve="([^"]+)"/ ) ) { + string = decodeURIComponent( match[1] ); + } + } + + return string || 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(), + rootNode = editor.getBody(); + + tag = tag || 'more'; + classname += ' mce-wp-' + tag; + title = tag === 'more' ? 'Read more...' : 'Next page'; + title = __( title ); + html = '<img src="' + tinymce.Env.transparentSrc + '" alt="" title="' + title + '" class="' + classname + '" ' + + 'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />'; + + // Most common case. + if ( node === rootNode || ( node.nodeName === 'P' && node.parentNode === rootNode ) ) { + editor.insertContent( html ); + return; + } + + // Get the top level parent node. + parent = dom.getParent( node, function( found ) { + if ( found.parentNode && found.parentNode === rootNode ) { + 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 ? __( '⌘ + letter:' ) : __( 'Ctrl + letter:' ), + table1 = [], + table2 = [], + row1 = {}, + row2 = {}, + i1 = 0, + i2 = 0, + labels = editor.settings.wp_shortcut_labels, + header, html, dialog, $wrap; + + if ( ! labels ) { + return; + } + + function tr( row, columns ) { + var out = '<tr>'; + var i = 0; + + columns = columns || 1; + + each( row, function( text, key ) { + out += '<td><kbd>' + key + '</kbd></td><td>' + __( text ) + '</td>'; + i++; + }); + + while ( i < columns ) { + out += '<td></td><td></td>'; + i++; + } + + return out + '</tr>'; + } + + each ( labels, function( label, name ) { + var letter; + + if ( label.indexOf( 'meta' ) !== -1 ) { + i1++; + letter = label.replace( 'meta', '' ).toLowerCase(); + + if ( letter ) { + row1[ letter ] = name; + + if ( i1 % 2 === 0 ) { + table1.push( tr( row1, 2 ) ); + row1 = {}; + } + } + } else if ( label.indexOf( 'access' ) !== -1 ) { + i2++; + letter = label.replace( 'access', '' ).toLowerCase(); + + if ( letter ) { + row2[ letter ] = name; + + if ( i2 % 2 === 0 ) { + table2.push( tr( row2, 2 ) ); + row2 = {}; + } + } + } + } ); + + // Add remaining single entries. + if ( i1 % 2 > 0 ) { + table1.push( tr( row1, 2 ) ); + } + + if ( i2 % 2 > 0 ) { + table2.push( tr( row2, 2 ) ); + } + + 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 fixed">' + + header + + table1.join('') + + '</table>' + + '<h2>' + __( 'Additional shortcuts,' ) + ' ' + access + '</h2>' + + '<table class="wp-help-th-center fixed">' + + header + + table2.join('') + + '</table>'; + + if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) { + // 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 class="wp-help-th-center fixed">' + + tr({ '*': 'Bullet list', '1.': 'Numbered list' }) + + tr({ '-': 'Bullet list', '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 class="wp-help-single">' + + tr({ '>': 'Blockquote' }) + + tr({ '##': 'Heading 2' }) + + tr({ '###': 'Heading 3' }) + + tr({ '####': 'Heading 4' }) + + tr({ '#####': 'Heading 5' }) + + tr({ '######': 'Heading 6' }) + + tr({ '---': 'Horizontal line' }) + + '</table>'; + } + + // Focus management section. + html = html + + '<h2>' + __( 'Focus shortcuts:' ) + '</h2>' + + '<table class="wp-help-single">' + + 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: editor.settings.classic_block_editor ? 'Classic Block Keyboard Shortcuts' : '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' + }); + + // Insert->Add Media. + if ( wp && wp.media && wp.media.editor ) { + editor.addButton( 'wp_add_media', { + tooltip: 'Add Media', + icon: 'dashicon dashicons-admin-media', + cmd: 'WP_Medialib' + } ); + + 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' ); + } + + dom.setAttrib( doc.documentElement, 'lang', editor.getParam( 'wp_lang_attr' ) ); + + 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 ( $ ) { + // Run on DOM ready. Otherwise TinyMCE may initialize earlier and handlers attached + // on DOM ready of after the `tinymce.init()` call may not get triggered. + $( function() { + $( 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 ) ) { + editor.on( 'PastePreProcess', function( event ) { + // Remove trailing <br> added by WebKit browsers to the clipboard. + event.content = event.content.replace( /<br class="?Apple-interchange-newline"?>/gi, '' ); + + // In WebKit this is handled by removeWebKitStyles(). + if ( ! tinymce.Env.webkit ) { + // 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. + editor.$( 'p', event.node ).each( function( i, node ) { + if ( dom.isEmpty( node ) ) { + dom.remove( node ); + } + }); + + if ( tinymce.isIE ) { + editor.$( 'a', event.node ).find( 'font, u' ).each( function( i, node ) { + dom.remove( node, true ); + }); + } + }); + } + }); + + 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 ); + } else { + // Restore formatting of block boundaries. + event.content = event.content.replace( /-->\s*<!-- wp:/g, '-->\n\n<!-- wp:' ); + } + }); + + 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', + m: 'WP_Medialib', + t: 'WP_More', + d: 'Strikethrough', + 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(); + } + } ); + + // Alt+Shift+Z removes a block in the block editor, don't add it to the Classic block. + if ( ! editor.settings.classic_block_editor ) { + editor.addShortcut( 'access+z', '', 'WP_Adv' ); + } + + // Workaround for not triggering the global help modal in the block editor by the Classic block shortcut. + editor.on( 'keydown', function( event ) { + var match; + + if ( tinymce.Env.mac ) { + match = event.ctrlKey && event.altKey && event.code === 'KeyH'; + } else { + match = event.shiftKey && event.altKey && event.code === 'KeyH'; + } + + if ( match ) { + editor.execCommand( 'WP_Help' ); + event.stopPropagation(); + event.stopImmediatePropagation(); + return false; + } + + return true; + }); + + if ( window.getUserSetting( 'editor_plain_text_paste_warning' ) > 1 ) { + editor.settings.paste_plaintext_inform = false; + } + + // Change the editor iframe title on MacOS, add the correct help shortcut. + if ( tinymce.Env.mac ) { + tinymce.$( editor.iframeElement ).attr( 'title', __( 'Rich Text Area. Press Control-Option-H for help.' ) ); + } + } ); + + editor.on( 'PastePlainTextToggle', function( event ) { + // Warn twice, then stop. + if ( event.state === true ) { + var times = parseInt( window.getUserSetting( 'editor_plain_text_paste_warning' ), 10 ) || 0; + + if ( times < 2 ) { + window.setUserSetting( 'editor_plain_text_paste_warning', ++times ); + } + } + }); + + editor.on( 'beforerenderui', function() { + if ( editor.theme.panel ) { + each( [ 'button', 'colorbutton', 'splitbutton' ], function( buttonType ) { + replaceButtonsTooltips( editor.theme.panel.find( buttonType ) ); + } ); + + addShortcutsToListbox(); + } + } ); + + function prepareTooltips() { + var access = 'Shift+Alt+'; + var meta = 'Ctrl+'; + + wpTooltips = {}; + + // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325. + if ( tinymce.Env.mac ) { + access = '\u2303\u2325'; + meta = '\u2318'; + } + + // Some tooltips are translated, others are not... + if ( editor.settings.wp_shortcut_labels ) { + each( editor.settings.wp_shortcut_labels, function( value, tooltip ) { + var translated = editor.translate( tooltip ); + + value = value.replace( 'access', access ).replace( 'meta', meta ); + wpTooltips[ tooltip ] = value; + + // Add the translated so we can match all of them. + if ( tooltip !== translated ) { + wpTooltips[ translated ] = value; + } + } ); + } + } + + function getTooltip( tooltip ) { + var translated = editor.translate( tooltip ); + var label; + + if ( ! wpTooltips ) { + prepareTooltips(); + } + + if ( wpTooltips.hasOwnProperty( translated ) ) { + label = wpTooltips[ translated ]; + } else if ( wpTooltips.hasOwnProperty( tooltip ) ) { + label = wpTooltips[ tooltip ]; + } + + return label ? translated + ' (' + label + ')' : translated; + } + + function replaceButtonsTooltips( buttons ) { + + if ( ! buttons ) { + return; + } + + each( buttons, function( button ) { + var tooltip; + + if ( button && button.settings.tooltip ) { + tooltip = getTooltip( button.settings.tooltip ); + button.settings.tooltip = tooltip; + + // Override the aria label with the translated tooltip + shortcut. + if ( button._aria && button._aria.label ) { + button._aria.label = tooltip; + } + } + } ); + } + + function addShortcutsToListbox() { + // listbox for the "blocks" drop-down. + each( editor.theme.panel.find( 'listbox' ), function( listbox ) { + if ( listbox && listbox.settings.text === 'Paragraph' ) { + each( listbox.settings.values, function( item ) { + if ( item.text && wpTooltips.hasOwnProperty( item.text ) ) { + item.shortcut = '(' + wpTooltips[ item.text ] + ')'; + } + } ); + } + } ); + } + + /** + * 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, + cachedWinSize; + + 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; + var tooltip; + + 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; + } + + tooltip = item.tooltip || item.title; + + if ( tooltip ) { + item.tooltip = getTooltip( tooltip ); + } + + 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.clientHeight, + selection = currentSelection.getBoundingClientRect(), + selectionMiddle = ( selection.left + selection.right ) / 2, + buffer = 5, + spaceNeeded = toolbarHeight + 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 = '', + iosOffsetTop = 0, + iosOffsetBottom = 0, + top, left; + + if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) { + this.scrolling = true; + this.hide(); + this.scrolling = false; + return this; + } + + // Add offset in iOS to move the menu over the image, out of the way of the default iOS menu. + if ( tinymce.Env.iOS && currentSelection.nodeName === 'IMG' ) { + iosOffsetTop = 54; + iosOffsetBottom = 46; + } + + if ( this.bottom ) { + if ( spaceBottom >= spaceNeeded ) { + className = ' mce-arrow-up'; + top = selection.bottom + iframeRect.top + scrollY - iosOffsetBottom; + } else if ( spaceTop >= spaceNeeded ) { + className = ' mce-arrow-down'; + top = selection.top + iframeRect.top + scrollY - toolbarHeight + iosOffsetTop; + } + } else { + if ( spaceTop >= spaceNeeded ) { + className = ' mce-arrow-down'; + top = selection.top + iframeRect.top + scrollY - toolbarHeight + iosOffsetTop; + } else if ( spaceBottom >= spaceNeeded && editorHeight / 2 > selection.bottom + iframeRect.top - blockedTop ) { + className = ' mce-arrow-up'; + top = selection.bottom + iframeRect.top + scrollY - iosOffsetBottom; + } + } + + if ( typeof top === 'undefined' ) { + top = scrollY + blockedTop + buffer + iosOffsetBottom; + } + + 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; + } + + // No up/down arrows on the menu over images in iOS. + if ( tinymce.Env.iOS && currentSelection.nodeName === 'IMG' ) { + className = className.replace( / ?mce-arrow-(up|down)/g, '' ); + } + + 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 !== args.toolbar ) { + activeToolbar.hide(); + } + + if ( args.toolbar ) { + activeToolbar = args.toolbar; + + if ( activeToolbar.visible() ) { + activeToolbar.reposition(); + } else { + activeToolbar.show(); + } + } else { + activeToolbar = false; + } + } ); + + editor.on( 'focus', function() { + if ( activeToolbar ) { + activeToolbar.show(); + } + } ); + + function hide( event ) { + var win; + var size; + + if ( activeToolbar ) { + if ( activeToolbar.tempHide || event.type === 'hide' || event.type === 'blur' ) { + activeToolbar.hide(); + activeToolbar = false; + } else if ( ( + event.type === 'resizewindow' || + event.type === 'scrollwindow' || + event.type === 'resize' || + event.type === 'scroll' + ) && ! activeToolbar.blockHide ) { + /* + * Showing a tooltip may trigger a `resize` event in Chromium browsers. + * That results in a flicketing inline menu; tooltips are shown on hovering over a button, + * which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again. + */ + if ( event.type === 'resize' || event.type === 'resizewindow' ) { + win = editor.getWin(); + size = win.innerHeight + win.innerWidth; + + // Reset old cached size. + if ( cachedWinSize && ( new Date() ).getTime() - cachedWinSize.timestamp > 2000 ) { + cachedWinSize = null; + } + + if ( cachedWinSize ) { + if ( size && Math.abs( size - cachedWinSize.size ) < 2 ) { + // `resize` fired but the window hasn't been resized. Bail. + return; + } + } else { + // First of a new series of `resize` events. Store the cached size and bail. + cachedWinSize = { + timestamp: ( new Date() ).getTime(), + size: size, + }; + + return; + } + } + + clearTimeout( timeout ); + + timeout = setTimeout( function() { + if ( activeToolbar && typeof activeToolbar.show === 'function' ) { + activeToolbar.scrolling = false; + activeToolbar.show(); + } + }, 250 ); + + activeToolbar.scrolling = true; + activeToolbar.hide(); + } + } + } + + if ( editor.inline ) { + editor.on( 'resizewindow', hide ); + + // Enable `capture` for the event. + // This will hide/reposition the toolbar on any scrolling in the document. + document.addEventListener( 'scroll', hide, true ); + } else { + // Bind to the editor iframe and to the parent window. + editor.dom.bind( editor.getWin(), 'resize scroll', hide ); + editor.on( 'resizewindow scrollwindow', hide ); + } + + editor.on( 'remove', function() { + document.removeEventListener( 'scroll', hide, true ); + editor.off( 'resizewindow scrollwindow', 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 )); diff --git a/wp-includes/js/tinymce/plugins/wordpress/plugin.min.js b/wp-includes/js/tinymce/plugins/wordpress/plugin.min.js new file mode 100644 index 0000000..f4f1a99 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/plugin.min.js @@ -0,0 +1 @@ +!function(k){(!k.ui.FloatPanel.zIndex||k.ui.FloatPanel.zIndex<100100)&&(k.ui.FloatPanel.zIndex=100100),k.PluginManager.add("wordpress",function(p){var a,t,E=k.DOM,m=k.each,u=p.editorManager.i18n.translate,i=window.jQuery,o=window.wp,r=o&&o.editor&&o.editor.autop&&p.getParam("wpautop",!0),s=!1;function e(n){var e,t,o=0,i=k.$(".block-library-classic__toolbar");"hide"===n?e=!0:i.length&&!i.hasClass("has-advanced-toolbar")&&(i.addClass("has-advanced-toolbar"),n="show"),(t=p.theme.panel?p.theme.panel.find(".toolbar:not(.menubar)"):t)&&1<t.length&&(!n&&t[1].visible()&&(n="hide"),m(t,function(e,t){0<t&&("hide"===n?(e.hide(),o+=34):(e.show(),o-=34))})),o&&!k.Env.iOS&&p.iframeElement&&p.iframeElement.clientHeight&&50<(i=p.iframeElement.clientHeight+o)&&E.setStyle(p.iframeElement,"height",i),e||("hide"===n?(setUserSetting("hidetb","0"),a&&a.active(!1)):(setUserSetting("hidetb","1"),a&&a.active(!0))),p.fire("wp-toolbar-toggle")}function d(e){var t,o,i,n=p.translate(e);return s||(o="Shift+Alt+",i="Ctrl+",s={},k.Env.mac&&(o="\u2303\u2325",i="\u2318"),p.settings.wp_shortcut_labels&&m(p.settings.wp_shortcut_labels,function(e,t){var n=p.translate(t);e=e.replace("access",o).replace("meta",i),s[t]=e,t!==n&&(s[n]=e)})),s.hasOwnProperty(n)?t=s[n]:s.hasOwnProperty(e)&&(t=s[e]),t?n+" ("+t+")":n}function n(){}return i&&i(document).triggerHandler("tinymce-editor-setup",[p]),p.addButton("wp_adv",{tooltip:"Toolbar Toggle",cmd:"WP_Adv",onPostRender:function(){(a=this).active("1"===getUserSetting("hidetb"))}}),p.on("PostRender",function(){p.getParam("wordpress_adv_hidden",!0)&&"0"===getUserSetting("hidetb","0")?e("hide"):k.$(".block-library-classic__toolbar").addClass("has-advanced-toolbar")}),p.addCommand("WP_Adv",function(){e()}),p.on("focus",function(){window.wpActiveEditor=p.id}),p.on("BeforeSetContent",function(e){var n;e.content&&(-1!==e.content.indexOf("\x3c!--more")&&(n=u("Read more..."),e.content=e.content.replace(/<!--more(.*?)-->/g,function(e,t){return'<img src="'+k.Env.transparentSrc+'" data-wp-more="more" data-wp-more-text="'+t+'" class="wp-more-tag mce-wp-more" alt="" title="'+n+'" data-mce-resize="false" data-mce-placeholder="1" />'})),-1!==e.content.indexOf("\x3c!--nextpage--\x3e")&&(n=u("Page break"),e.content=e.content.replace(/<!--nextpage-->/g,'<img src="'+k.Env.transparentSrc+'" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" alt="" title="'+n+'" data-mce-resize="false" data-mce-placeholder="1" />')),e.load&&"raw"!==e.format&&(e.content=r?o.editor.autop(e.content):e.content.replace(/-->\s+<!--/g,"--\x3e\x3c!--")),-1===e.content.indexOf("<script")&&-1===e.content.indexOf("<style")||(e.content=e.content.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g,function(e,t){return'<img src="'+k.Env.transparentSrc+'" data-wp-preserve="'+encodeURIComponent(e)+'" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="<'+t+'>" title="<'+t+'>" />'})))}),p.on("setcontent",function(){p.$("p").each(function(e,t){var n;t.innerHTML&&t.innerHTML.length<10&&((n=k.trim(t.innerHTML))&&" "!==n||(t.innerHTML=k.Env.ie&&k.Env.ie<11?"":'<br data-mce-bogus="1">'))})}),p.on("PostProcess",function(e){e.get&&(e.content=e.content.replace(/<img[^>]+>/g,function(e){var t,n,o="";return-1!==e.indexOf('data-wp-more="more"')?n="\x3c!--more"+(o=(t=e.match(/data-wp-more-text="([^"]+)"/))?t[1]:o)+"--\x3e":-1!==e.indexOf('data-wp-more="nextpage"')?n="\x3c!--nextpage--\x3e":-1!==e.indexOf("data-wp-preserve")&&(t=e.match(/ data-wp-preserve="([^"]+)"/))&&(n=decodeURIComponent(t[1])),n||e}))}),p.on("ResolveName",function(e){var t;"IMG"===e.target.nodeName&&(t=p.dom.getAttrib(e.target,"data-wp-more"))&&(e.name=t)}),p.addCommand("WP_More",function(e){var t,n="wp-more-tag",o=p.dom,i=p.selection.getNode(),a=p.getBody();n+=" mce-wp-"+(e=e||"more"),t=u("more"===e?"Read more...":"Next page"),t='<img src="'+k.Env.transparentSrc+'" alt="" title="'+t+'" class="'+n+'" data-wp-more="'+e+'" data-mce-resize="false" data-mce-placeholder="1" />',i===a||"P"===i.nodeName&&i.parentNode===a?p.insertContent(t):(n=o.getParent(i,function(e){return!(!e.parentNode||e.parentNode!==a)},p.getBody()))&&("P"===n.nodeName?n.appendChild(o.create("p",null,t).firstChild):o.insertAfter(o.create("p",null,t),n),p.nodeChanged())}),p.addCommand("WP_Code",function(){p.formatter.toggle("code")}),p.addCommand("WP_Page",function(){p.execCommand("WP_More","nextpage")}),p.addCommand("WP_Help",function(){var e,t=k.Env.mac?u("Ctrl + Alt + letter:"):u("Shift + Alt + letter:"),n=k.Env.mac?u("\u2318 + letter:"):u("Ctrl + letter:"),o=[],i=[],a={},r={},s=0,d=0,l=p.settings.wp_shortcut_labels;function c(e,t){var n="<tr>",o=0;for(t=t||1,m(e,function(e,t){n+="<td><kbd>"+t+"</kbd></td><td>"+u(e)+"</td>",o++});o<t;)n+="<td></td><td></td>",o++;return n+"</tr>"}l&&(m(l,function(e,t){var n;-1!==e.indexOf("meta")?(s++,(n=e.replace("meta","").toLowerCase())&&(a[n]=t,s%2==0)&&(o.push(c(a,2)),a={})):-1!==e.indexOf("access")&&(d++,n=e.replace("access","").toLowerCase())&&(r[n]=t,d%2==0)&&(i.push(c(r,2)),r={})}),0<s%2&&o.push(c(a,2)),0<d%2&&i.push(c(r,2)),l="<tr><th>"+(l=[u("Letter"),u("Action"),u("Letter"),u("Action")]).join("</th><th>")+"</th></tr>",e=(e='<div class="wp-editor-help">')+"<h2>"+u("Default shortcuts,")+" "+n+'</h2><table class="wp-help-th-center fixed">'+l+o.join("")+"</table><h2>"+u("Additional shortcuts,")+" "+t+'</h2><table class="wp-help-th-center fixed">'+l+i.join("")+"</table>",e=(e=p.plugins.wptextpattern&&(!k.Env.ie||8<k.Env.ie)?(e=e+"<h2>"+u("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 class="wp-help-th-center fixed">'+c({"*":"Bullet list","1.":"Numbered list"})+c({"-":"Bullet list","1)":"Numbered list"})+"</table>")+"<h2>"+u("The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.")+'</h2><table class="wp-help-single">'+c({">":"Blockquote"})+c({"##":"Heading 2"})+c({"###":"Heading 3"})+c({"####":"Heading 4"})+c({"#####":"Heading 5"})+c({"######":"Heading 6"})+c({"---":"Horizontal line"})+"</table>":e)+"<h2>"+u("Focus shortcuts:")+'</h2><table class="wp-help-single">'+c({"Alt + F8":"Inline toolbar (when an image, link or preview is selected)"})+c({"Alt + F9":"Editor menu (when enabled)"})+c({"Alt + F10":"Editor toolbar"})+c({"Alt + F11":"Elements path"})+"</table><p>"+u("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>",(n=p.windowManager.open({title:p.settings.classic_block_editor?"Classic Block Keyboard Shortcuts":"Keyboard Shortcuts",items:{type:"container",classes:"wp-help",html:e+="</div>"},buttons:{text:"Close",onclick:"close"}})).$el)&&(n.$el.find('div[role="application"]').attr("role","document"),(t=n.$el.find(".mce-wp-help"))[0])&&(t.attr("tabindex","0"),t[0].focus(),t.on("keydown",function(e){33<=e.keyCode&&e.keyCode<=40&&e.stopPropagation()}))}),p.addCommand("WP_Medialib",function(){o&&o.media&&o.media.editor&&o.media.editor.open(p.id)}),p.addButton("wp_more",{tooltip:"Insert Read More tag",onclick:function(){p.execCommand("WP_More","more")}}),p.addButton("wp_page",{tooltip:"Page break",onclick:function(){p.execCommand("WP_More","nextpage")}}),p.addButton("wp_help",{tooltip:"Keyboard Shortcuts",cmd:"WP_Help"}),p.addButton("wp_code",{tooltip:"Code",cmd:"WP_Code",stateSelector:"code"}),o&&o.media&&o.media.editor&&(p.addButton("wp_add_media",{tooltip:"Add Media",icon:"dashicon dashicons-admin-media",cmd:"WP_Medialib"}),p.addMenuItem("add_media",{text:"Add Media",icon:"wp-media-library",context:"insert",cmd:"WP_Medialib"})),p.addMenuItem("wp_more",{text:"Insert Read More tag",icon:"wp_more",context:"insert",onclick:function(){p.execCommand("WP_More","more")}}),p.addMenuItem("wp_page",{text:"Page break",icon:"wp_page",context:"insert",onclick:function(){p.execCommand("WP_More","nextpage")}}),p.on("BeforeExecCommand",function(e){!k.Env.webkit||"InsertUnorderedList"!==e.command&&"InsertOrderedList"!==e.command||(t=t||p.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;}"),p.getDoc().head.appendChild(t))}),p.on("ExecCommand",function(e){k.Env.webkit&&t&&("InsertUnorderedList"===e.command||"InsertOrderedList"===e.command)&&p.dom.remove(t)}),p.on("init",function(){var e=k.Env,t=["mceContentBody"],n=p.getDoc(),o=p.dom;e.iOS&&o.addClass(n.documentElement,"ios"),"rtl"===p.getParam("directionality")&&(t.push("rtl"),o.setAttrib(n.documentElement,"dir","rtl")),o.setAttrib(n.documentElement,"lang",p.getParam("wp_lang_attr")),e.ie?9===parseInt(e.ie,10)?t.push("ie9"):8===parseInt(e.ie,10)?t.push("ie8"):e.ie<8&&t.push("ie7"):e.webkit&&t.push("webkit"),t.push("wp-editor"),m(t,function(e){e&&o.addClass(n.body,e)}),p.on("BeforeSetContent",function(e){e.content&&(e.content=e.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>"))}),i&&i(function(){i(document).triggerHandler("tinymce-editor-init",[p])}),window.tinyMCEPreInit&&window.tinyMCEPreInit.dragDropUpload&&o.bind(n,"dragstart dragend dragover drop",function(e){i&&i(document).trigger(new i.Event(e))}),p.getParam("wp_paste_filters",!0)&&(p.on("PastePreProcess",function(e){e.content=e.content.replace(/<br class="?Apple-interchange-newline"?>/gi,""),k.Env.webkit||(e.content=e.content.replace(/(<[^>]+) style="[^"]*"([^>]*>)/gi,"$1$2"),e.content=e.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi,"$1 style=$2"))}),p.on("PastePostProcess",function(e){p.$("p",e.node).each(function(e,t){o.isEmpty(t)&&o.remove(t)}),k.isIE&&p.$("a",e.node).find("font, u").each(function(e,t){o.remove(t,!0)})}))}),p.on("SaveContent",function(e){!p.inline&&p.isHidden()?e.content=e.element.value:(e.content=e.content.replace(/<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g,"<p> </p>"),e.content=r?o.editor.removep(e.content):e.content.replace(/-->\s*<!-- wp:/g,"--\x3e\n\n\x3c!-- wp:"))}),p.on("preInit",function(){p.schema.addValidElements("@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b,script[src|async|defer|type|charset|crossorigin|integrity]"),k.Env.iOS&&(p.settings.height=300),m({c:"JustifyCenter",r:"JustifyRight",l:"JustifyLeft",j:"JustifyFull",q:"mceBlockQuote",u:"InsertUnorderedList",o:"InsertOrderedList",m:"WP_Medialib",t:"WP_More",d:"Strikethrough",p:"WP_Page",x:"WP_Code"},function(e,t){p.shortcuts.add("access+"+t,"",e)}),p.addShortcut("meta+s","",function(){o&&o.autosave&&o.autosave.server.triggerSave()}),p.settings.classic_block_editor||p.addShortcut("access+z","","WP_Adv"),p.on("keydown",function(e){var t=k.Env.mac?e.ctrlKey&&e.altKey&&"KeyH"===e.code:e.shiftKey&&e.altKey&&"KeyH"===e.code;return!t||(p.execCommand("WP_Help"),e.stopPropagation(),e.stopImmediatePropagation(),!1)}),1<window.getUserSetting("editor_plain_text_paste_warning")&&(p.settings.paste_plaintext_inform=!1),k.Env.mac&&k.$(p.iframeElement).attr("title",u("Rich Text Area. Press Control-Option-H for help."))}),p.on("PastePlainTextToggle",function(e){!0===e.state&&(e=parseInt(window.getUserSetting("editor_plain_text_paste_warning"),10)||0)<2&&window.setUserSetting("editor_plain_text_paste_warning",++e)}),p.on("beforerenderui",function(){p.theme.panel&&(m(["button","colorbutton","splitbutton"],function(e){(e=p.theme.panel.find(e))&&m(e,function(e){var t;e&&e.settings.tooltip&&(t=d(e.settings.tooltip),e.settings.tooltip=t,e._aria)&&e._aria.label&&(e._aria.label=t)})}),m(p.theme.panel.find("listbox"),function(e){e&&"Paragraph"===e.settings.text&&m(e.settings.values,function(e){e.text&&s.hasOwnProperty(e.text)&&(e.shortcut="("+s[e.text]+")")})}))}),p.on("preinit",function(){var n,v,t,_,y,P,o,r=k.ui.Factory,s=p.settings,e=p.getContainer(),x=document.getElementById("wpadminbar"),C=document.getElementById(p.id+"_ifr");function i(e){if(n)if(n.tempHide||"hide"===e.type||"blur"===e.type)n.hide(),n=!1;else if(("resizewindow"===e.type||"scrollwindow"===e.type||"resize"===e.type||"scroll"===e.type)&&!n.blockHide){if("resize"===e.type||"resizewindow"===e.type){if(e=(e=p.getWin()).innerHeight+e.innerWidth,!(o=o&&2e3<(new Date).getTime()-o.timestamp?null:o))return void(o={timestamp:(new Date).getTime(),size:e});if(e&&Math.abs(e-o.size)<2)return}clearTimeout(t),t=setTimeout(function(){n&&"function"==typeof n.show&&(n.scrolling=!1,n.show())},250),n.scrolling=!0,n.hide()}}e&&(_=k.$(".mce-toolbar-grp",e)[0],y=k.$(".mce-statusbar",e)[0]),"content"===p.id&&(P=document.getElementById("post-status-info")),p.shortcuts.add("alt+119","",function(){var e;n&&(e=n.find("toolbar")[0])&&e.focus(!0)}),p.on("nodechange",function(e){var t=p.selection.isCollapsed(),e={element:e.element,parents:e.parents,collapsed:t};p.fire("wptoolbar",e),v=e.selection||e.element,n&&n!==e.toolbar&&n.hide(),e.toolbar?(n=e.toolbar).visible()?n.reposition():n.show():n=!1}),p.on("focus",function(){n&&n.show()}),p.inline?(p.on("resizewindow",i),document.addEventListener("scroll",i,!0)):(p.dom.bind(p.getWin(),"resize scroll",i),p.on("resizewindow scrollwindow",i)),p.on("remove",function(){document.removeEventListener("scroll",i,!0),p.off("resizewindow scrollwindow",i),p.dom.unbind(p.getWin(),"resize scroll",i)}),p.on("blur hide",i),p.wp=p.wp||{},p.wp._createToolbar=function(e,t){var n,o,a=[];return m(e,function(i){var t,e;function n(){var e=p.selection;"bullist"===t&&e.selectorChanged("ul > li",function(e,t){for(var n,o=t.parents.length;o--&&"OL"!==(n=t.parents[o].nodeName)&&"UL"!=n;);i.active(e&&"UL"===n)}),"numlist"===t&&e.selectorChanged("ol > li",function(e,t){for(var n,o=t.parents.length;o--&&"OL"!==(n=t.parents[o].nodeName)&&"UL"!==n;);i.active(e&&"OL"===n)}),i.settings.stateSelector&&e.selectorChanged(i.settings.stateSelector,function(e){i.active(e)},!0),i.settings.disabledStateSelector&&e.selectorChanged(i.settings.disabledStateSelector,function(e){i.disabled(e)})}"|"===i?o=null:r.has(i)?(i={type:i},s.toolbar_items_size&&(i.size=s.toolbar_items_size),a.push(i),o=null):(o||(o={type:"buttongroup",items:[]},a.push(o)),p.buttons[i]&&(t=i,(i="function"==typeof(i=p.buttons[t])?i():i).type=i.type||"button",s.toolbar_items_size&&(i.size=s.toolbar_items_size),(e=i.tooltip||i.title)&&(i.tooltip=d(e)),i=r.create(i),o.items.push(i),p.initialized?n():p.on("init",n)))}),(n=r.create({type:"panel",layout:"stack",classes:"toolbar-grp inline-toolbar-grp",ariaRoot:!0,ariaRemember:!0,items:[{type:"toolbar",layout:"flow",items:a}]})).bottom=t,n.on("show",function(){this.reposition()}),n.on("keydown",function(e){27===e.keyCode&&(this.hide(),p.focus())}),p.on("remove",function(){n.remove()}),n.reposition=function(){var e,t,n,o,i,a,r,s,d,l,c,p,m,u,g,h,f,w,b;return v&&(e=window.pageXOffset||document.documentElement.scrollLeft,t=window.pageYOffset||document.documentElement.scrollTop,n=window.innerWidth,u=window.innerHeight,o=C?C.getBoundingClientRect():{top:0,right:n,bottom:u,left:0,width:n,height:u},a=(i=this.getEl()).offsetWidth,r=i.clientHeight,d=((s=v.getBoundingClientRect()).left+s.right)/2,l=r+5,c=x?x.getBoundingClientRect().bottom:0,b=_?_.getBoundingClientRect().bottom:0,p=y?u-y.getBoundingClientRect().top:0,m=P?u-P.getBoundingClientRect().top:0,c=Math.max(0,c,b,o.top),b=Math.max(0,p,m,u-o.bottom),p=s.top+o.top-c,m=u-o.top-s.bottom-b,g="",f=h=0,(u=u-c-b)<=p||u<=m?(this.scrolling=!0,this.hide(),this.scrolling=!1):(k.Env.iOS&&"IMG"===v.nodeName&&(h=54,f=46),this.bottom?l<=m?(g=" mce-arrow-up",w=s.bottom+o.top+t-f):l<=p&&(g=" mce-arrow-down",w=s.top+o.top+t-r+h):l<=p?(g=" mce-arrow-down",w=s.top+o.top+t-r+h):l<=m&&u/2>s.bottom+o.top-c&&(g=" mce-arrow-up",w=s.bottom+o.top+t-f),void 0===w&&(w=t+c+5+f),b=d-a/2+o.left+e,s.left<0||s.right>o.width?b=o.left+e+(o.width-a)/2:n<=a?(g+=" mce-arrow-full",b=0):b<0&&s.left+a>n||n<b+a&&s.right-a<0?b=(n-a)/2:b<o.left+e?(g+=" mce-arrow-left",b=s.left+o.left+e):b+a>o.width+o.left+e&&(g+=" mce-arrow-right",b=s.right-a+o.left+e),k.Env.iOS&&"IMG"===v.nodeName&&(g=g.replace(/ ?mce-arrow-(up|down)/g,"")),i.className=i.className.replace(/ ?mce-arrow-[\w]+/g,"")+g,E.setStyles(i,{left:b,top:w}))),this},n.hide().renderTo(document.body),n}},!0),{_showButtons:n,_hideButtons:n,_setEmbed:n,_getEmbed:n}})}(window.tinymce);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js b/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js new file mode 100644 index 0000000..6e0a1a8 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpautoresize/plugin.js @@ -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 ); +}); diff --git a/wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js b/wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js new file mode 100644 index 0000000..9b1fd74 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js @@ -0,0 +1 @@ +tinymce.PluginManager.add("wpautoresize",function(g){var m=g.settings,h=300,c=!1;function f(e){return parseInt(e,10)||0}function y(e){var t,o,n,i,a,s,l,u,r,d=tinymce.DOM;c&&(o=g.getDoc())&&(e=e||{},t=o.body,o=o.documentElement,n=m.autoresize_min_height,!t||e&&"setcontent"===e.type&&e.initial||g.plugins.fullscreen&&g.plugins.fullscreen.isFullscreen()?t&&o&&(t.style.overflowY="auto",o.style.overflowY="auto"):(i=g.dom.getStyle(t,"margin-top",!0),a=g.dom.getStyle(t,"margin-bottom",!0),s=g.dom.getStyle(t,"padding-top",!0),l=g.dom.getStyle(t,"padding-bottom",!0),u=g.dom.getStyle(t,"border-top-width",!0),r=g.dom.getStyle(t,"border-bottom-width",!0),(i=t.offsetHeight+f(i)+f(a)+f(s)+f(l)+f(u)+f(r))&&i<o.offsetHeight&&(i=o.offsetHeight),(i=isNaN(i)||i<=0?tinymce.Env.ie?t.scrollHeight:tinymce.Env.webkit&&0===t.clientHeight?0:t.offsetHeight:i)>m.autoresize_min_height&&(n=i),m.autoresize_max_height&&i>m.autoresize_max_height?(n=m.autoresize_max_height,t.style.overflowY="auto",o.style.overflowY="auto"):(t.style.overflowY="hidden",o.style.overflowY="hidden",t.scrollTop=0),n!==h&&(a=n-h,d.setStyle(g.iframeElement,"height",n+"px"),h=n,tinymce.isWebKit&&a<0&&y(e),g.fire("wp-autoresize",{height:n,deltaHeight:"nodechange"===e.type?a:null}))))}function n(e,t,o){setTimeout(function(){y(),e--?n(e,t,o):o&&o()},t)}g.settings.inline||tinymce.Env.iOS||(m.autoresize_min_height=parseInt(g.getParam("autoresize_min_height",g.getElement().offsetHeight),10),m.autoresize_max_height=parseInt(g.getParam("autoresize_max_height",0),10),m.wp_autoresize_on&&(c=!0,g.on("init",function(){g.dom.addClass(g.getBody(),"wp-autoresize")}),g.on("nodechange keyup FullscreenStateChanged",y),g.on("setcontent",function(){n(3,100)}),g.getParam("autoresize_on_init",!0))&&g.on("init",function(){n(10,200,function(){n(5,1e3)})}),g.on("show",function(){h=0}),g.addCommand("wpAutoResize",y),g.addCommand("wpAutoResizeOn",function(){g.dom.hasClass(g.getBody(),"wp-autoresize")||(c=!0,g.dom.addClass(g.getBody(),"wp-autoresize"),g.on("nodechange setcontent keyup FullscreenStateChanged",y),y())}),g.addCommand("wpAutoResizeOff",function(){var e;m.wp_autoresize_on||(c=!1,e=g.getDoc(),g.dom.removeClass(g.getBody(),"wp-autoresize"),g.off("nodechange setcontent keyup FullscreenStateChanged",y),e.body.style.overflowY="auto",e.documentElement.style.overflowY="auto",h=0)}))});
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js b/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js new file mode 100644 index 0000000..11c8d5f --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpdialogs/plugin.js @@ -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 ); + }); +}); diff --git a/wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js b/wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js new file mode 100644 index 0000000..cc31d8a --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js @@ -0,0 +1 @@ +tinymce.WPWindowManager=tinymce.InlineWindowManager=function(a){if(this.wp)return this;this.wp={},this.parent=a.windowManager,this.editor=a,tinymce.extend(this,this.parent),this.open=function(e,i){var n,o=this,t=this.wp;if(!e.wpDialog)return this.parent.open.apply(this,arguments);e.id&&("undefined"!=typeof jQuery&&jQuery.wp&&jQuery.wp.wpdialog?(t.$element=n=jQuery("#"+e.id),n.length&&(window.console&&window.console.log&&window.console.log("tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML."),t.features=e,t.params=i,a.nodeChanged(),n.data("wpdialog")||n.wpdialog({title:e.title,width:e.width,height:e.height,modal:!0,dialogClass:"wp-dialog",zIndex:3e5}),n.wpdialog("open"),n.on("wpdialogclose",function(){o.wp.$element&&(o.wp={})}))):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.'))},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(e){e.on("init",function(){e.windowManager=new tinymce.WPWindowManager(e)})});
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js new file mode 100644 index 0000000..ac6c83b --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -0,0 +1,900 @@ +/* global tinymce */ +tinymce.PluginManager.add( 'wpeditimage', function( editor ) { + var toolbar, serializer, touchOnImage, pasteInCaption, + 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|button', // '|button' is not displayed, only 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; + } + } ); + + function isNonEditable( node ) { + var parent = editor.$( node ).parents( '[contenteditable]' ); + return parent && parent.attr( 'contenteditable' ) === 'false'; + } + + // Safari on iOS fails to select images in contentEditoble mode on touch. + // Select them again. + if ( iOS ) { + editor.on( 'init', function() { + editor.on( 'touchstart', function( event ) { + if ( event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) { + touchOnImage = true; + } + }); + + editor.dom.bind( editor.getDoc(), 'touchmove', function() { + touchOnImage = false; + }); + + editor.on( 'touchend', function( event ) { + if ( touchOnImage && event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) { + var node = event.target; + + touchOnImage = false; + + window.setTimeout( function() { + editor.selection.select( node ); + editor.nodeChanged(); + }, 100 ); + } 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 [^>]+mceTemp[^>]+>)?\s*(<dl [^>]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g, function( all, dl ) { + var out = ''; + + if ( dl.indexOf('<img ') === -1 || dl.indexOf('</p>') !== -1 ) { + // Broken caption. The user managed to drag the image out or type in the wrapper div? + // Remove the <dl>, <dd> and <dt> and return the remaining text. + return dl.replace( /<d[ldt]( [^>]+)?>/g, '' ).replace( /<\/d[ldt]>/g, '' ); + } + + out = dl.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 = dl.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 ).replace( /\ufeff/g, '' ); + } + + // 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, imageNode, + captionNode, dd, dl, id, attrs, linkAttrs, width, height, align, + $imageNode, srcset, src, + dom = editor.dom; + + if ( ! $imageNode || ! $imageNode.length ) { + return; + } + + imageNode = $imageNode[0]; + 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, + title: imageData.title || null, + 'class': classes.join( ' ' ) || null + }; + + dom.setAttribs( imageNode, attrs ); + + // Preserve empty alt attributes. + $imageNode.attr( 'alt', imageData.alt || '' ); + + 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 ); + } + + $imageNode = editor.$( imageNode ); + srcset = $imageNode.attr( 'srcset' ); + src = $imageNode.attr( 'src' ); + + // Remove srcset and sizes if the image file was edited or the image was replaced. + if ( srcset && src ) { + src = src.replace( /[?#].*/, '' ); + + if ( srcset.indexOf( src ) === -1 ) { + $imageNode.attr( 'srcset', null ).attr( 'sizes', null ); + } + } + + 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, imageNode; + + if ( typeof wp === 'undefined' || ! wp.media ) { + editor.execCommand( 'mceImage' ); + return; + } + + metadata = extractImageData( img ); + + // Mark the image node so we can select it later. + editor.$( img ).attr( 'data-wp-editing', 1 ); + + // 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.undoManager.transact( function() { + updateImage( imageNode, 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(); + + /* + * `close` fires first... + * To be able to update the image node, we need to find it here, + * and use it in the callback. + */ + imageNode = editor.$( 'img[data-wp-editing]' ) + imageNode.removeAttr( 'data-wp-editing' ); + }); + + 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 ); + + // 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( 'pastePostProcess', function( event ) { + // Pasting in a caption node. + if ( editor.dom.getParent( editor.selection.getNode(), 'dd.wp-caption-dd' ) ) { + // Remove "non-block" elements that should not be in captions. + editor.$( 'img, audio, video, object, embed, iframe, script, style', event.node ).remove(); + + editor.$( '*', event.node ).each( function( i, node ) { + if ( editor.dom.isBlock( node ) ) { + // Insert <br> where the blocks used to be. Makes it look better after pasting in the caption. + if ( tinymce.trim( node.textContent || node.innerText ) ) { + editor.dom.insertAfter( editor.dom.create( 'br' ), node ); + editor.dom.remove( node, true ); + } else { + editor.dom.remove( node ); + } + } + }); + + // Trim <br> tags. + editor.$( 'br', event.node ).each( function( i, node ) { + if ( ! node.nextSibling || node.nextSibling.nodeName === 'BR' || + ! node.previousSibling || node.previousSibling.nodeName === 'BR' ) { + + editor.dom.remove( node ); + } + } ); + + // Pasted HTML is cleaned up for inserting in the caption. + pasteInCaption = true; + } + }); + + editor.on( 'BeforeExecCommand', function( event ) { + var node, p, DL, align, replacement, captionParent, + cmd = event.command, + dom = editor.dom; + + if ( cmd === 'mceInsertContent' || cmd === 'Indent' || cmd === 'Outdent' ) { + node = editor.selection.getNode(); + captionParent = dom.getParent( node, 'div.mceTemp' ); + + if ( captionParent ) { + if ( cmd === 'mceInsertContent' ) { + if ( pasteInCaption ) { + pasteInCaption = false; + /* + * We are in the caption element, and in 'paste' context, + * and the pasted HTML was cleaned up on 'pastePostProcess' above. + * Let it be pasted in the caption. + */ + return; + } + + /* + * The paste is somewhere else in the caption DL element. + * Prevent pasting in there as it will break the caption. + * Make new paragraph under the caption DL and move the caret there. + */ + p = dom.create( 'p' ); + dom.insertAfter( p, captionParent ); + editor.selection.setCursorLocation( p, 0 ); + + /* + * If the image is selected and the user pastes "over" it, + * replace both the image and the caption elements with the pasted content. + * This matches the behavior when pasting over non-caption images. + */ + if ( node.nodeName === 'IMG' ) { + editor.$( captionParent ).remove(); + } + + editor.nodeChanged(); + } else { + // Clicking Indent or Outdent while an image with a caption is selected breaks the caption. + // See #38313. + event.preventDefault(); + event.stopImmediatePropagation(); + return false; + } + } + } 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( 'beforeGetContent', function( event ) { + if ( event.format !== 'raw' ) { + editor.$( 'img[id="__wp-temp-img-id"]' ).removeAttr( 'id' ); + } + }); + + 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 ); + } + }); + + ( function() { + var wrap; + + editor.on( 'dragstart', function() { + var node = editor.selection.getNode(); + + if ( node.nodeName === 'IMG' ) { + wrap = editor.dom.getParent( node, '.mceTemp' ); + + if ( ! wrap && node.parentNode.nodeName === 'A' && ! hasTextContent( node.parentNode ) ) { + wrap = node.parentNode; + } + } + } ); + + editor.on( 'drop', function( event ) { + var dom = editor.dom, + rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() ); + + // Don't allow anything to be dropped in a captioned image. + if ( rng && dom.getParent( rng.startContainer, '.mceTemp' ) ) { + event.preventDefault(); + } else if ( wrap ) { + event.preventDefault(); + + editor.undoManager.transact( function() { + if ( rng ) { + editor.selection.setRng( rng ); + } + + editor.selection.setNode( wrap ); + dom.remove( wrap ); + } ); + } + + wrap = null; + } ); + } )(); + + // Add to editor.wp. + editor.wp = editor.wp || {}; + editor.wp.isPlaceholder = isPlaceholder; + + // Back-compat. + return { + _do_shcode: parseShortcode, + _get_shcode: getShortcode + }; +}); diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js new file mode 100644 index 0000000..092bb34 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js @@ -0,0 +1 @@ +tinymce.PluginManager.add("wpeditimage",function(g){var r,u,n,c,a,e=tinymce.each,l=tinymce.trim,t=tinymce.Env.iOS;function i(e){return!(!g.dom.getAttrib(e,"data-mce-placeholder")&&!g.dom.getAttrib(e,"data-mce-object"))}function o(e){e=g.$(e).parents("[contenteditable]");return e&&"false"===e.attr("contenteditable")}function d(e){return e.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g,function(e,t,n){var a,i,o,r,c,d=t.match(/id=['"]([^'"]*)['"] ?/);return(c=(t=(i=(t=(a=(t=d?t.replace(d[0],""):t).match(/align=['"]([^'"]*)['"] ?/))?t.replace(a[0],""):t).match(/class=['"]([^'"]*)['"] ?/))?t.replace(i[0],""):t).match(/width=['"]([0-9]*)['"] ?/))&&(t=t.replace(c[0],"")),r=(r=(n=l(n)).match(/((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i))&&r[2]?(o=l(r[2]),l(r[1])):(o=l(t).replace(/caption=['"]/,"").replace(/['"]$/,""),n),d=d&&d[1]?d[1].replace(/[<>&]+/g,""):"",a=a&&a[1]?a[1]:"alignnone",i=i&&i[1]?" "+i[1].replace(/[<>&]+/g,""):"",(c=(c=!c&&r?r.match(/width=['"]([0-9]*)['"]/):c)&&c[1]?c[1]:c)&&o?(c=parseInt(c,10),g.getParam("wpeditimage_html5_captions")||(c+=10),'<div class="mceTemp"><dl id="'+d+'" class="wp-caption '+a+i+'" style="width: '+c+'px"><dt class="wp-caption-dt">'+r+'</dt><dd class="wp-caption-dd">'+o+"</dd></dl></div>"):n})}function s(e){return e.replace(/(?:<div [^>]+mceTemp[^>]+>)?\s*(<dl [^>]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g,function(e,t){var n="";return-1===t.indexOf("<img ")||-1!==t.indexOf("</p>")?t.replace(/<d[ldt]( [^>]+)?>/g,"").replace(/<\/d[ldt]>/g,""):-1===(n=t.replace(/\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi,function(e,t,n,a){var i,o,r=n.match(/width="([0-9]*)"/);return r=r&&r[1]?r[1]:"",o=(i=(i=t.match(/class="([^"]*)"/))&&i[1]?i[1]:"").match(/align[a-z]+/i)||"alignnone",r&&a?'[caption id="'+((t=t.match(/id="([^"]*)"/))&&t[1]?t[1]:"")+'" align="'+o+'" width="'+r+'"'+(i=(i=i.replace(/wp-caption ?|align[a-z]+ ?/gi,""))&&' class="'+i+'"')+"]"+n+" "+(a=(a=a.replace(/\r\n|\r/g,"\n").replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g,function(e){return e.replace(/[\r\n\t]+/," ")})).replace(/\s*\n\s*/g,"<br />"))+"[/caption]":"alignnone"!==o[0]?n.replace(/><img/,' class="'+o[0]+'"><img'):n})).indexOf("[caption")?t.replace(/[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi,"<p>$1</p>$2"):n})}function h(e){return e&&(e.textContent||e.innerText).replace(/\ufeff/g,"")}function m(e){var t=g.dom.getParent(e,"div.mceTemp");(t=t||"IMG"!==e.nodeName?t:g.dom.getParent(e,"a"))?(t.nextSibling?g.selection.select(t.nextSibling):t.previousSibling?g.selection.select(t.previousSibling):g.selection.select(t.parentNode),g.selection.collapse(!0),g.dom.remove(t)):g.dom.remove(e),g.nodeChanged(),g.undoManager.add()}return g.addButton("wp_img_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){m(g.selection.getNode())}}),g.addButton("wp_img_edit",{tooltip:"Edit|button",icon:"dashicon dashicons-edit",onclick:function(){var e,t,n,p;e=g.selection.getNode(),"undefined"!=typeof wp&&wp.media?(n=function(e){var t,n,a,i,o=[],r=g.dom,c=/^\d+$/;(n={attachment_id:!1,size:"custom",caption:"",align:"none",extraClasses:"",link:!1,linkUrl:"",linkClassName:"",linkTargetBlank:!1,linkRel:"",title:""}).url=r.getAttrib(e,"src"),n.alt=r.getAttrib(e,"alt"),n.title=r.getAttrib(e,"title"),a=r.getAttrib(e,"width"),i=r.getAttrib(e,"height"),(!c.test(a)||parseInt(a,10)<1)&&(a=e.naturalWidth||e.width);(!c.test(i)||parseInt(i,10)<1)&&(i=e.naturalHeight||e.height);n.customWidth=n.width=a,n.customHeight=n.height=i,c=tinymce.explode(e.className," "),t=[],tinymce.each(c,function(e){/^wp-image/.test(e)?n.attachment_id=parseInt(e.replace("wp-image-",""),10):/^align/.test(e)?n.align=e.replace("align",""):/^size/.test(e)?n.size=e.replace("size-",""):t.push(e)}),n.extraClasses=t.join(" "),(a=r.getParents(e,".wp-caption")).length&&(a=a[0],c=a.className.split(" "),tinymce.each(c,function(e){/^align/.test(e)?n.align=e.replace("align",""):e&&"wp-caption"!==e&&o.push(e)}),n.captionClassName=o.join(" "),(i=r.select("dd.wp-caption-dd",a)).length)&&(i=i[0],n.caption=g.serializer.serialize(i).replace(/<br[^>]*>/g,"$&\n").replace(/^<p>/,"").replace(/<\/p>$/,""));e.parentNode&&"A"===e.parentNode.nodeName&&(c=e.parentNode,n.linkUrl=r.getAttrib(c,"href"),n.linkTargetBlank="_blank"===r.getAttrib(c,"target"),n.linkRel=r.getAttrib(c,"rel"),n.linkClassName=c.className);return n}(e),g.$(e).attr("data-wp-editing",1),wp.media.events.trigger("editor:image-edit",{editor:g,metadata:n,image:e}),t=wp.media({frame:"image",state:"image-details",metadata:n}),wp.media.events.trigger("editor:frame-create",{frame:t}),e=function(m){g.undoManager.transact(function(){var e,t,n,a,i,o,r,c,d,l,s;e=p,t=m,s=g.dom,e&&e.length&&(a=e[0],r=(r=tinymce.explode(t.extraClasses," "))||[],t.caption||r.push("align"+t.align),t.attachment_id&&(r.push("wp-image-"+t.attachment_id),t.size)&&"custom"!==t.size&&r.push("size-"+t.size),l=t.width,c=t.height,"custom"===t.size&&(l=t.customWidth,c=t.customHeight),c={src:t.url,width:l||null,height:c||null,title:t.title||null,class:r.join(" ")||null},s.setAttribs(a,c),e.attr("alt",t.alt||""),r={href:t.linkUrl,rel:t.linkRel||null,target:t.linkTargetBlank?"_blank":null,class:t.linkClassName||null},a.parentNode&&"A"===a.parentNode.nodeName&&!h(a.parentNode)?t.linkUrl?s.setAttribs(a.parentNode,r):s.remove(a.parentNode,!0):t.linkUrl&&((c=s.getParent(a,"a"))&&s.insertAfter(a,c),c=s.create("a",r),a.parentNode.insertBefore(c,a),c.appendChild(a)),r=g.dom.getParent(a,".mceTemp"),c=a.parentNode&&"A"===a.parentNode.nodeName&&!h(a.parentNode)?a.parentNode:a,t.caption?(t.caption=function(e){if(!e||-1===e.indexOf("<")&&-1===e.indexOf(">"))return e;u=u||new tinymce.html.Serializer({},g.schema);return u.serialize(g.parser.parse(e,{forced_root_block:!1}))}(t.caption),o=t.attachment_id?"attachment_"+t.attachment_id:null,d="wp-caption "+(d="align"+(t.align||"none")),t.captionClassName&&(d+=" "+t.captionClassName.replace(/[<>&]+/g,"")),g.getParam("wpeditimage_html5_captions")||(l=parseInt(l,10),l+=10),r?((i=s.select("dl.wp-caption",r)).length&&s.setAttribs(i,{id:o,class:d,style:"width: "+l+"px"}),(i=s.select(".wp-caption-dd",r)).length&&s.setHTML(i[0],t.caption)):(i="<dl "+(o=o?'id="'+o+'" ':"")+'class="'+d+'" style="width: '+l+'px"><dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+t.caption+"</dd></dl>",o=s.create("div",{class:"mceTemp"},i),(n=s.getParent(c,"p"))?n.parentNode.insertBefore(o,n):c.parentNode.insertBefore(o,c),g.$(o).find("dt.wp-caption-dt").append(c),n&&s.isEmpty(n)&&s.remove(n))):r&&(n=s.create("p"),r.parentNode.insertBefore(n,r),n.appendChild(c),s.remove(r)),e=g.$(a),d=e.attr("srcset"),l=e.attr("src"),d&&l&&(l=l.replace(/[?#].*/,""),-1===d.indexOf(l))&&e.attr("srcset",null).attr("sizes",null),wp.media.events&&wp.media.events.trigger("editor:image-update",{editor:g,metadata:t,image:a}),g.nodeChanged())}),t.detach()},t.state("image-details").on("update",e),t.state("replace-image").on("replace",e),t.on("close",function(){g.focus(),t.detach(),(p=g.$("img[data-wp-editing]")).removeAttr("data-wp-editing")}),t.open()):g.execCommand("mceImage")}}),e({alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",alignnone:"No alignment"},function(e,n){var t=n.slice(5);g.addButton("wp_img_"+n,{tooltip:e,icon:"dashicon dashicons-align-"+t,cmd:"alignnone"===n?"wpAlignNone":"Justify"+t.slice(0,1).toUpperCase()+t.slice(1),onPostRender:function(){var t=this;g.on("NodeChange",function(e){"IMG"===e.element.nodeName&&(e=g.dom.getParent(e.element,".wp-caption")||e.element,"alignnone"===n?t.active(!/\balign(left|center|right)\b/.test(e.className)):t.active(g.dom.hasClass(e,n)))})}})}),g.once("preinit",function(){g.wp&&g.wp._createToolbar&&(r=g.wp._createToolbar(["wp_img_alignleft","wp_img_aligncenter","wp_img_alignright","wp_img_alignnone","wp_img_edit","wp_img_remove"]))}),g.on("wptoolbar",function(e){"IMG"!==e.element.nodeName||i(e.element)||(e.toolbar=r)}),t&&g.on("init",function(){g.on("touchstart",function(e){"IMG"!==e.target.nodeName||o(e.target)||(n=!0)}),g.dom.bind(g.getDoc(),"touchmove",function(){n=!1}),g.on("touchend",function(e){var t;n&&"IMG"===e.target.nodeName&&!o(e.target)?(t=e.target,n=!1,window.setTimeout(function(){g.selection.select(t),g.nodeChanged()},100)):r&&r.hide()})}),g.on("init",function(){var t=g.dom,e=g.getParam("wpeditimage_html5_captions")?"html5-captions":"html4-captions";t.addClass(g.getBody(),e),tinymce.Env.ie&&10<tinymce.Env.ie&&t.bind(g.getBody(),"mscontrolselect",function(e){"IMG"===e.target.nodeName&&t.getParent(e.target,".wp-caption")?g.getBody().focus():"DL"===e.target.nodeName&&t.hasClass(e.target,"wp-caption")&&e.target.focus()})}),g.on("ObjectResized",function(a){var i=a.target;"IMG"===i.nodeName&&g.undoManager.transact(function(){var e,t,n=g.dom;i.className=i.className.replace(/\bsize-[^ ]+/,""),(e=n.getParent(i,".wp-caption"))&&(t=a.width||n.getAttrib(i,"width"))&&(t=parseInt(t,10),g.getParam("wpeditimage_html5_captions")||(t+=10),n.setStyle(e,"width",t+"px"))})}),g.on("pastePostProcess",function(e){g.dom.getParent(g.selection.getNode(),"dd.wp-caption-dd")&&(g.$("img, audio, video, object, embed, iframe, script, style",e.node).remove(),g.$("*",e.node).each(function(e,t){g.dom.isBlock(t)&&(tinymce.trim(t.textContent||t.innerText)?(g.dom.insertAfter(g.dom.create("br"),t),g.dom.remove(t,!0)):g.dom.remove(t))}),g.$("br",e.node).each(function(e,t){t.nextSibling&&"BR"!==t.nextSibling.nodeName&&t.previousSibling&&"BR"!==t.previousSibling.nodeName||g.dom.remove(t)}),c=!0)}),g.on("BeforeExecCommand",function(e){var t,n,a,i=e.command,o=g.dom;if("mceInsertContent"===i||"Indent"===i||"Outdent"===i){if(t=g.selection.getNode(),a=o.getParent(t,"div.mceTemp")){if("mceInsertContent"!==i)return e.preventDefault(),e.stopImmediatePropagation(),!1;c?c=!1:(n=o.create("p"),o.insertAfter(n,a),g.selection.setCursorLocation(n,0),"IMG"===t.nodeName&&g.$(a).remove(),g.nodeChanged())}}else"JustifyLeft"!==i&&"JustifyRight"!==i&&"JustifyCenter"!==i&&"wpAlignNone"!==i||(t=g.selection.getNode(),o="align"+i.slice(7).toLowerCase(),n=g.dom.getParent(t,".wp-caption"),"IMG"!==t.nodeName&&!n)||(a=g.dom.hasClass(t=n||t,o)?" alignnone":" "+o,t.className=l(t.className.replace(/ ?align(left|center|right|none)/g,"")+a),g.nodeChanged(),e.preventDefault(),r&&r.reposition(),g.fire("ExecCommand",{command:i,ui:e.ui,value:e.value}))}),g.on("keydown",function(e){var t,n,a,i=g.selection,o=e.keyCode,r=g.dom,c=tinymce.util.VK;if(o===c.ENTER)t=i.getNode(),(n=r.getParent(t,"div.mceTemp"))&&(r.events.cancel(e),tinymce.each(r.select("dt, dd",n),function(e){r.isEmpty(e)&&r.remove(e)}),a=tinymce.Env.ie&&tinymce.Env.ie<11?"":'<br data-mce-bogus="1" />',a=r.create("p",null,a),"DD"===t.nodeName?r.insertAfter(a,n):n.parentNode.insertBefore(a,n),g.nodeChanged(),i.setCursorLocation(a,0));else if((o===c.DELETE||o===c.BACKSPACE)&&("DIV"===(t=i.getNode()).nodeName&&r.hasClass(t,"mceTemp")?n=t:"IMG"!==t.nodeName&&"DT"!==t.nodeName&&"A"!==t.nodeName||(n=r.getParent(t,"div.mceTemp")),n))return r.events.cancel(e),m(t),!1}),tinymce.Env.gecko&&g.on("undo redo",function(){"IMG"===g.selection.getNode().nodeName&&g.selection.collapse()}),g.wpSetImgCaption=d,g.wpGetImgCaption=s,g.on("beforeGetContent",function(e){"raw"!==e.format&&g.$('img[id="__wp-temp-img-id"]').removeAttr("id")}),g.on("BeforeSetContent",function(e){"raw"!==e.format&&(e.content=g.wpSetImgCaption(e.content))}),g.on("PostProcess",function(e){e.get&&(e.content=g.wpGetImgCaption(e.content))}),g.on("dragstart",function(){var e=g.selection.getNode();"IMG"!==e.nodeName||(a=g.dom.getParent(e,".mceTemp"))||"A"!==e.parentNode.nodeName||h(e.parentNode)||(a=e.parentNode)}),g.on("drop",function(e){var t=g.dom,n=tinymce.dom.RangeUtils.getCaretRangeFromPoint(e.clientX,e.clientY,g.getDoc());n&&t.getParent(n.startContainer,".mceTemp")?e.preventDefault():a&&(e.preventDefault(),g.undoManager.transact(function(){n&&g.selection.setRng(n),g.selection.setNode(a),t.remove(a)})),a=null}),g.wp=g.wp||{},g.wp.isPlaceholder=i,{_do_shcode:d,_get_shcode:s}});
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpemoji/plugin.js b/wp-includes/js/tinymce/plugins/wpemoji/plugin.js new file mode 100644 index 0000000..84de774 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpemoji/plugin.js @@ -0,0 +1,134 @@ +( function( tinymce ) { + tinymce.PluginManager.add( 'wpemoji', function( editor ) { + var typing, + wp = window.wp, + settings = window._wpemojiSettings, + 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 || settings.supports.everything ) { + 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 ); diff --git a/wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js b/wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js new file mode 100644 index 0000000..2fa94f7 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js @@ -0,0 +1 @@ +!function(m){m.PluginManager.add("wpemoji",function(n){var t,o=window.wp,e=window._wpemojiSettings,i=m.Env,a=window.navigator.userAgent,w=-1<a.indexOf("Windows"),a=!!((a=a.match(/Windows NT 6\.(\d)/))&&1<a[1]);function d(e){o.emoji.parse(e,{imgAttr:{"data-mce-resize":"false","data-mce-placeholder":"1","data-wp-emoji":"1"}})}function c(e){var t,o;e&&window.twemoji&&window.twemoji.test(e.textContent||e.innerText)&&(i.webkit&&(o=(t=n.selection).getBookmark()),d(e),i.webkit)&&t.moveToBookmark(o)}o&&o.emoji&&!e.supports.everything&&(a?n.on("keyup",function(e){231===e.keyCode&&c(n.selection.getNode())}):w||(n.on("keydown keyup",function(e){t="keydown"===e.type}),n.on("input",function(){t||c(n.selection.getNode())})),n.on("setcontent",function(e){var t=n.selection,o=t.getNode();window.twemoji&&window.twemoji.test(o.textContent||o.innerText)&&(d(o),i.ie)&&i.ie<9&&e.load&&o&&"BODY"===o.nodeName&&t.collapse(!0)}),n.on("PastePostProcess",function(e){window.twemoji&&m.each(n.dom.$("img.emoji",e.node),function(e){e.alt&&window.twemoji.test(e.alt)&&((e=e).className="emoji",e.setAttribute("data-mce-resize","false"),e.setAttribute("data-mce-placeholder","1"),e.setAttribute("data-wp-emoji","1"))})}),n.on("postprocess",function(e){e.content&&(e.content=e.content.replace(/<img[^>]+data-wp-emoji="[^>]+>/g,function(e){var t=e.match(/alt="([^"]+)"/);return t&&t[1]?t[1]:e}))}),n.on("resolvename",function(e){"IMG"===e.target.nodeName&&n.dom.getAttrib(e.target,"data-wp-emoji")&&e.preventDefault()}))})}(window.tinymce);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpgallery/plugin.js b/wp-includes/js/tinymce/plugins/wpgallery/plugin.js new file mode 100644 index 0000000..54245ef --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpgallery/plugin.js @@ -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" alt="" />'; + } + + 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 ); + } + }); +}); diff --git a/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js b/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js new file mode 100644 index 0000000..83cbcd1 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js @@ -0,0 +1 @@ +tinymce.PluginManager.add("wpgallery",function(d){function t(e){return e.replace(/\[gallery([^\]]*)\]/g,function(e){return t="wp-gallery",n=e,n=window.encodeURIComponent(e),'<img src="'+tinymce.Env.transparentSrc+'" class="wp-media mceItem '+t+'" data-wp-media="'+n+'" data-mce-resize="false" data-mce-placeholder="1" alt="" />';var t,n})}function n(e){return e.replace(/(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g,function(e,t){t=t,n="data-wp-media";var n,t=(n=new RegExp(n+'="([^"]+)"').exec(t))?window.decodeURIComponent(n[1]):"";return t?"<p>"+t+"</p>":e})}function o(t){var n,a,e;"IMG"===t.nodeName&&"undefined"!=typeof wp&&wp.media&&(e=window.decodeURIComponent(d.dom.getAttrib(t,"data-wp-media")),d.dom.hasClass(t,"wp-gallery"))&&wp.media.gallery&&(n=wp.media.gallery,(a=n.edit(e)).state("gallery-edit").on("update",function(e){e=n.shortcode(e).string();d.dom.setAttrib(t,"data-wp-media",window.encodeURIComponent(e)),a.detach()}))}d.addCommand("WP_Gallery",function(){o(d.selection.getNode())}),d.on("mouseup",function(e){var t=d.dom,n=e.target;function a(){t.removeClass(t.select("img.wp-media-selected"),"wp-media-selected")}"IMG"===n.nodeName&&t.getAttrib(n,"data-wp-media")?2!==e.button&&(t.hasClass(n,"wp-media-selected")?o(n):(a(),t.addClass(n,"wp-media-selected"))):a()}),d.on("ResolveName",function(e){var t=d.dom,n=e.target;"IMG"===n.nodeName&&t.getAttrib(n,"data-wp-media")&&t.hasClass(n,"wp-gallery")&&(e.name="gallery")}),d.on("BeforeSetContent",function(e){d.plugins.wpview&&"undefined"!=typeof wp&&wp.mce||(e.content=t(e.content))}),d.on("PostProcess",function(e){e.get&&(e.content=n(e.content))})});
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.js b/wp-includes/js/tinymce/plugins/wplink/plugin.js new file mode 100644 index 0000000..29f98a1 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.js @@ -0,0 +1,610 @@ +( function( tinymce ) { + tinymce.ui.Factory.add( 'WPLinkPreview', tinymce.ui.Control.extend( { + url: '#', + renderHtml: function() { + return ( + '<div id="' + this._id + '" class="wp-link-preview">' + + '<a href="' + this.url + '" target="_blank" rel="noopener" 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 nothing's left (maybe the URL was just a fragment), use the whole URL. + if ( url === '' ) { + url = this.url; + } + + // 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.ui.Factory.add( 'WPLinkInput', tinymce.ui.Control.extend( { + renderHtml: function() { + return ( + '<div id="' + this._id + '" class="wp-link-input">' + + '<input type="text" value="" placeholder="' + tinymce.translate( 'Paste URL or type to search' ) + '" />' + + '<input type="text" style="display:none" value="" />' + + '</div>' + ); + }, + setURL: function( url ) { + this.getEl().firstChild.value = url; + }, + getURL: function() { + return tinymce.trim( this.getEl().firstChild.value ); + }, + getLinkText: function() { + var text = this.getEl().firstChild.nextSibling.value; + + if ( ! tinymce.trim( text ) ) { + return ''; + } + + return text.replace( /[\r\n\t ]+/g, ' ' ); + }, + reset: function() { + var urlInput = this.getEl().firstChild; + + urlInput.value = ''; + urlInput.nextSibling.value = ''; + } + } ) ); + + tinymce.PluginManager.add( 'wplink', function( editor ) { + var toolbar; + var editToolbar; + var previewInstance; + var inputInstance; + var linkNode; + var doingUndoRedo; + var doingUndoRedoTimer; + var $ = window.jQuery; + var emailRegex = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; + var urlRegex1 = /^https?:\/\/([^\s/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i; + var urlRegex2 = /^https?:\/\/[^\/]+\.[^\/]+($|\/)/i; + var speak = ( typeof window.wp !== 'undefined' && window.wp.a11y && window.wp.a11y.speak ) ? window.wp.a11y.speak : function() {}; + var hasLinkError = false; + + function getSelectedLink() { + var href, html, + node = editor.selection.getStart(), + link = editor.dom.getParent( node, 'a[href]' ); + + if ( ! link ) { + html = editor.selection.getContent({ format: 'raw' }); + + if ( html && html.indexOf( '</a>' ) !== -1 ) { + href = html.match( /href="([^">]+)"/ ); + + if ( href && href[1] ) { + link = editor.$( 'a[href="' + href[1] + '"]', node )[0]; + } + + if ( link ) { + editor.selection.select( link ); + } + } + } + + return link; + } + + function removePlaceholders() { + editor.$( 'a' ).each( function( i, element ) { + var $element = editor.$( element ); + + if ( $element.attr( 'href' ) === '_wp_link_placeholder' ) { + editor.dom.remove( element, true ); + } else if ( $element.attr( 'data-wplink-edit' ) ) { + $element.attr( 'data-wplink-edit', null ); + } + }); + } + + function removePlaceholderStrings( content, dataAttr ) { + return content.replace( /(<a [^>]+>)([\s\S]*?)<\/a>/g, function( all, tag, text ) { + if ( tag.indexOf( ' href="_wp_link_placeholder"' ) > -1 ) { + return text; + } + + if ( dataAttr ) { + tag = tag.replace( / data-wplink-edit="true"/g, '' ); + } + + tag = tag.replace( / data-wplink-url-error="true"/g, '' ); + + return tag + text + '</a>'; + }); + } + + function checkLink( node ) { + var $link = editor.$( node ); + var href = $link.attr( 'href' ); + + if ( ! href || typeof $ === 'undefined' ) { + return; + } + + hasLinkError = false; + + if ( /^http/i.test( href ) && ( ! urlRegex1.test( href ) || ! urlRegex2.test( href ) ) ) { + hasLinkError = true; + $link.attr( 'data-wplink-url-error', 'true' ); + speak( editor.translate( 'Warning: the link has been inserted but may have errors. Please test it.' ), 'assertive' ); + } else { + $link.removeAttr( 'data-wplink-url-error' ); + } + } + + editor.on( 'preinit', function() { + if ( editor.wp && editor.wp._createToolbar ) { + toolbar = editor.wp._createToolbar( [ + 'wp_link_preview', + 'wp_link_edit', + 'wp_link_remove' + ], true ); + + var editButtons = [ + 'wp_link_input', + 'wp_link_apply' + ]; + + if ( typeof window.wpLink !== 'undefined' ) { + editButtons.push( 'wp_link_advanced' ); + } + + editToolbar = editor.wp._createToolbar( editButtons, true ); + + editToolbar.on( 'show', function() { + if ( typeof window.wpLink === 'undefined' || ! window.wpLink.modalOpen ) { + window.setTimeout( function() { + var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0], + selection = linkNode && ( linkNode.textContent || linkNode.innerText ); + + if ( element ) { + if ( ! element.value && selection && typeof window.wpLink !== 'undefined' ) { + element.value = window.wpLink.getUrlFromSelection( selection ); + } + + if ( ! doingUndoRedo ) { + element.focus(); + element.select(); + } + } + } ); + } + } ); + + editToolbar.on( 'hide', function() { + if ( ! editToolbar.scrolling ) { + editor.execCommand( 'wp_link_cancel' ); + } + } ); + } + } ); + + editor.addCommand( 'WP_Link', function() { + if ( tinymce.Env.ie && tinymce.Env.ie < 10 && typeof window.wpLink !== 'undefined' ) { + window.wpLink.open( editor.id ); + return; + } + + linkNode = getSelectedLink(); + editToolbar.tempHide = false; + + if ( ! linkNode ) { + removePlaceholders(); + editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); + + linkNode = editor.$( 'a[href="_wp_link_placeholder"]' )[0]; + editor.nodeChanged(); + } + + editor.dom.setAttribs( linkNode, { 'data-wplink-edit': true } ); + } ); + + editor.addCommand( 'wp_link_apply', function() { + if ( editToolbar.scrolling ) { + return; + } + + var href, text; + + if ( linkNode ) { + href = inputInstance.getURL(); + text = inputInstance.getLinkText(); + editor.focus(); + + var parser = document.createElement( 'a' ); + parser.href = href; + + if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line + href = ''; + } + + if ( ! href ) { + editor.dom.remove( linkNode, true ); + return; + } + + if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) { + href = 'http://' + href; + } + + editor.dom.setAttribs( linkNode, { href: href, 'data-wplink-edit': null } ); + + if ( ! tinymce.trim( linkNode.innerHTML ) ) { + editor.$( linkNode ).text( text || href ); + } + + checkLink( linkNode ); + } + + inputInstance.reset(); + editor.nodeChanged(); + + // Audible confirmation message when a link has been inserted in the Editor. + if ( typeof window.wpLinkL10n !== 'undefined' && ! hasLinkError ) { + speak( window.wpLinkL10n.linkInserted ); + } + } ); + + editor.addCommand( 'wp_link_cancel', function() { + inputInstance.reset(); + + if ( ! editToolbar.tempHide ) { + removePlaceholders(); + } + } ); + + editor.addCommand( 'wp_unlink', function() { + editor.execCommand( 'unlink' ); + editToolbar.tempHide = false; + editor.execCommand( 'wp_link_cancel' ); + } ); + + // WP default shortcuts. + editor.addShortcut( 'access+a', '', 'WP_Link' ); + editor.addShortcut( 'access+s', '', 'wp_unlink' ); + // 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(); + } + } + } ); + + // Remove any remaining placeholders on saving. + editor.on( 'savecontent', function( event ) { + event.content = removePlaceholderStrings( event.content, true ); + }); + + // Prevent adding undo levels on inserting link placeholder. + editor.on( 'BeforeAddUndo', function( event ) { + if ( event.lastLevel && event.lastLevel.content && event.level.content && + event.lastLevel.content === removePlaceholderStrings( event.level.content ) ) { + + event.preventDefault(); + } + }); + + // When doing undo and redo with keyboard shortcuts (Ctrl|Cmd+Z, Ctrl|Cmd+Shift+Z, Ctrl|Cmd+Y), + // set a flag to not focus the inline dialog. The editor has to remain focused so the users can do consecutive undo/redo. + editor.on( 'keydown', function( event ) { + if ( event.keyCode === 27 ) { // Esc + editor.execCommand( 'wp_link_cancel' ); + } + + if ( event.altKey || ( tinymce.Env.mac && ( ! event.metaKey || event.ctrlKey ) ) || + ( ! tinymce.Env.mac && ! event.ctrlKey ) ) { + + return; + } + + if ( event.keyCode === 89 || event.keyCode === 90 ) { // Y or Z + doingUndoRedo = true; + + window.clearTimeout( doingUndoRedoTimer ); + doingUndoRedoTimer = window.setTimeout( function() { + doingUndoRedo = false; + }, 500 ); + } + } ); + + editor.addButton( 'wp_link_preview', { + type: 'WPLinkPreview', + onPostRender: function() { + previewInstance = this; + } + } ); + + editor.addButton( 'wp_link_input', { + type: 'WPLinkInput', + onPostRender: function() { + var element = this.getEl(), + input = element.firstChild, + $input, cache, last; + + inputInstance = this; + + if ( $ && $.ui && $.ui.autocomplete ) { + $input = $( input ); + + $input.on( 'keydown', function() { + $input.removeAttr( 'aria-activedescendant' ); + } ) + .autocomplete( { + source: function( request, response ) { + if ( last === request.term ) { + response( cache ); + return; + } + + if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) { + return response(); + } + + $.post( window.ajaxurl, { + action: 'wp-link-ajax', + page: 1, + search: request.term, + _ajax_linking_nonce: $( '#_ajax_linking_nonce' ).val() + }, function( data ) { + cache = data; + response( data ); + }, 'json' ); + + last = request.term; + }, + focus: function( event, ui ) { + $input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID ); + /* + * Don't empty the URL input field, when using the arrow keys to + * highlight items. See api.jqueryui.com/autocomplete/#event-focus + */ + event.preventDefault(); + }, + select: function( event, ui ) { + $input.val( ui.item.permalink ); + $( element.firstChild.nextSibling ).val( ui.item.title ); + + if ( 9 === event.keyCode && typeof window.wpLinkL10n !== 'undefined' ) { + // Audible confirmation message when a link has been selected. + speak( window.wpLinkL10n.linkSelected ); + } + + return false; + }, + open: function() { + $input.attr( 'aria-expanded', 'true' ); + editToolbar.blockHide = true; + }, + close: function() { + $input.attr( 'aria-expanded', 'false' ); + editToolbar.blockHide = false; + }, + minLength: 2, + position: { + my: 'left top+2' + }, + messages: { + noResults: ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.noResults : '', + results: function( number ) { + if ( typeof window.uiAutocompleteL10n !== 'undefined' ) { + if ( number > 1 ) { + return window.uiAutocompleteL10n.manyResults.replace( '%d', number ); + } + + return window.uiAutocompleteL10n.oneResult; + } + } + } + } ).autocomplete( 'instance' )._renderItem = function( ul, item ) { + var fallbackTitle = ( typeof window.wpLinkL10n !== 'undefined' ) ? window.wpLinkL10n.noTitle : '', + title = item.title ? item.title : fallbackTitle; + + return $( '<li role="option" id="mce-wp-autocomplete-' + item.ID + '">' ) + .append( '<span>' + title + '</span> <span class="wp-editor-float-right">' + item.info + '</span>' ) + .appendTo( ul ); + }; + + $input.attr( { + 'role': 'combobox', + 'aria-autocomplete': 'list', + 'aria-expanded': 'false', + 'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' ) + } ) + .on( 'focus', function() { + var inputValue = $input.val(); + /* + * Don't trigger a search if the URL field already has a link or is empty. + * Also, avoids screen readers announce `No search results`. + */ + if ( inputValue && ! /^https?:/.test( inputValue ) ) { + $input.autocomplete( 'search' ); + } + } ) + // Returns a jQuery object containing the menu element. + .autocomplete( 'widget' ) + .addClass( 'wplink-autocomplete' ) + .attr( 'role', 'listbox' ) + .removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI. + /* + * Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301. + * The `menufocus` and `menublur` events are the same events used to add and remove + * the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget. + */ + .on( 'menufocus', function( event, ui ) { + ui.item.attr( 'aria-selected', 'true' ); + }) + .on( 'menublur', function() { + /* + * The `menublur` event returns an object where the item is `null` + * so we need to find the active item with other means. + */ + $( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' ); + }); + } + + tinymce.$( input ).on( 'keydown', function( event ) { + if ( event.keyCode === 13 ) { + editor.execCommand( 'wp_link_apply' ); + event.preventDefault(); + } + } ); + } + } ); + + editor.on( 'wptoolbar', function( event ) { + var linkNode = editor.dom.getParent( event.element, 'a' ), + $linkNode, href, edit; + + if ( typeof window.wpLink !== 'undefined' && window.wpLink.modalOpen ) { + editToolbar.tempHide = true; + return; + } + + editToolbar.tempHide = false; + + if ( linkNode ) { + $linkNode = editor.$( linkNode ); + href = $linkNode.attr( 'href' ); + edit = $linkNode.attr( 'data-wplink-edit' ); + + if ( href === '_wp_link_placeholder' || edit ) { + if ( href !== '_wp_link_placeholder' && ! inputInstance.getURL() ) { + inputInstance.setURL( href ); + } + + event.element = linkNode; + event.toolbar = editToolbar; + } else if ( href && ! $linkNode.find( 'img' ).length ) { + previewInstance.setURL( href ); + event.element = linkNode; + event.toolbar = toolbar; + + if ( $linkNode.attr( 'data-wplink-url-error' ) === 'true' ) { + toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' ); + } else { + toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' ); + hasLinkError = false; + } + } + } else if ( editToolbar.visible() ) { + editor.execCommand( 'wp_link_cancel' ); + } + } ); + + editor.addButton( 'wp_link_edit', { + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. + icon: 'dashicon dashicons-edit', + cmd: 'WP_Link' + } ); + + editor.addButton( 'wp_link_remove', { + tooltip: 'Remove link', + icon: 'dashicon dashicons-editor-unlink', + cmd: 'wp_unlink' + } ); + + editor.addButton( 'wp_link_advanced', { + tooltip: 'Link options', + icon: 'dashicon dashicons-admin-generic', + onclick: function() { + if ( typeof window.wpLink !== 'undefined' ) { + var url = inputInstance.getURL() || null, + text = inputInstance.getLinkText() || null; + + window.wpLink.open( editor.id, url, text ); + + editToolbar.tempHide = true; + editToolbar.hide(); + } + } + } ); + + editor.addButton( 'wp_link_apply', { + tooltip: 'Apply', + icon: 'dashicon dashicons-editor-break', + cmd: 'wp_link_apply', + classes: 'widget btn primary' + } ); + + return { + close: function() { + editToolbar.tempHide = false; + editor.execCommand( 'wp_link_cancel' ); + }, + checkLink: checkLink + }; + } ); +} )( window.tinymce ); diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js new file mode 100644 index 0000000..4846b96 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js @@ -0,0 +1 @@ +!function(v){v.ui.Factory.add("WPLinkPreview",v.ui.Control.extend({url:"#",renderHtml:function(){return'<div id="'+this._id+'" class="wp-link-preview"><a href="'+this.url+'" target="_blank" rel="noopener" tabindex="-1">'+this.url+"</a></div>"},setURL:function(e){var t,n;this.url!==e&&(this.url=e,40<(e=""===(e="/"===(e=(e=-1!==(t=(e=-1!==(t=(e=(e=window.decodeURIComponent(e)).replace(/^(?:https?:)?\/\/(?:www\.)?/,"")).indexOf("?"))?e.slice(0,t):e).indexOf("#"))?e.slice(0,t):e).replace(/(?:index)?\.html$/,"")).charAt(e.length-1)?e.slice(0,-1):e)?this.url:e).length&&-1!==(t=e.indexOf("/"))&&-1!==(n=e.lastIndexOf("/"))&&n!==t&&(t+e.length-n<40&&(n=-(40-(t+1))),e=e.slice(0,t+1)+"\u2026"+e.slice(n)),v.$(this.getEl().firstChild).attr("href",this.url).text(e))}})),v.ui.Factory.add("WPLinkInput",v.ui.Control.extend({renderHtml:function(){return'<div id="'+this._id+'" class="wp-link-input"><input type="text" value="" placeholder="'+v.translate("Paste URL or type to search")+'" /><input type="text" style="display:none" value="" /></div>'},setURL:function(e){this.getEl().firstChild.value=e},getURL:function(){return v.trim(this.getEl().firstChild.value)},getLinkText:function(){var e=this.getEl().firstChild.nextSibling.value;return v.trim(e)?e.replace(/[\r\n\t ]+/g," "):""},reset:function(){var e=this.getEl().firstChild;e.value="",e.nextSibling.value=""}})),v.PluginManager.add("wplink",function(l){var a,r,d,c,i,n,t,p=window.jQuery,o=/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i,s=/^https?:\/\/([^\s/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i,u=/^https?:\/\/[^\/]+\.[^\/]+($|\/)/i,w=void 0!==window.wp&&window.wp.a11y&&window.wp.a11y.speak?window.wp.a11y.speak:function(){},m=!1;function k(){l.$("a").each(function(e,t){var n=l.$(t);"_wp_link_placeholder"===n.attr("href")?l.dom.remove(t,!0):n.attr("data-wplink-edit")&&n.attr("data-wplink-edit",null)})}function f(e,i){return e.replace(/(<a [^>]+>)([\s\S]*?)<\/a>/g,function(e,t,n){return-1<t.indexOf(' href="_wp_link_placeholder"')?n:(t=(t=i?t.replace(/ data-wplink-edit="true"/g,""):t).replace(/ data-wplink-url-error="true"/g,""))+n+"</a>"})}function h(e){var e=l.$(e),t=e.attr("href");t&&void 0!==p&&(m=!1,!/^http/i.test(t)||s.test(t)&&u.test(t)?e.removeAttr("data-wplink-url-error"):(m=!0,e.attr("data-wplink-url-error","true"),w(l.translate("Warning: the link has been inserted but may have errors. Please test it."),"assertive")))}return l.on("preinit",function(){var e;l.wp&&l.wp._createToolbar&&(a=l.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0),e=["wp_link_input","wp_link_apply"],void 0!==window.wpLink&&e.push("wp_link_advanced"),(r=l.wp._createToolbar(e,!0)).on("show",function(){void 0!==window.wpLink&&window.wpLink.modalOpen||window.setTimeout(function(){var e=r.$el.find("input.ui-autocomplete-input")[0],t=i&&(i.textContent||i.innerText);e&&(!e.value&&t&&void 0!==window.wpLink&&(e.value=window.wpLink.getUrlFromSelection(t)),n||(e.focus(),e.select()))})}),r.on("hide",function(){r.scrolling||l.execCommand("wp_link_cancel")}))}),l.addCommand("WP_Link",function(){var e,t,n;v.Env.ie&&v.Env.ie<10&&void 0!==window.wpLink?window.wpLink.open(l.id):(t=l.selection.getStart(),(n=l.dom.getParent(t,"a[href]"))||(e=l.selection.getContent({format:"raw"}))&&-1!==e.indexOf("</a>")&&(n=(e=e.match(/href="([^">]+)"/))&&e[1]?l.$('a[href="'+e[1]+'"]',t)[0]:n)&&l.selection.select(n),i=n,r.tempHide=!1,i||(k(),l.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),i=l.$('a[href="_wp_link_placeholder"]')[0],l.nodeChanged()),l.dom.setAttribs(i,{"data-wplink-edit":!0}))}),l.addCommand("wp_link_apply",function(){if(!r.scrolling){var e,t;if(i){e=c.getURL(),t=c.getLinkText(),l.focus();var n=document.createElement("a");if(n.href=e,!(e="javascript:"!==n.protocol&&"data:"!==n.protocol?e:""))return void l.dom.remove(i,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(e)||o.test(e)||(e="http://"+e),l.dom.setAttribs(i,{href:e,"data-wplink-edit":null}),v.trim(i.innerHTML)||l.$(i).text(t||e),h(i)}c.reset(),l.nodeChanged(),void 0===window.wpLinkL10n||m||w(window.wpLinkL10n.linkInserted)}}),l.addCommand("wp_link_cancel",function(){c.reset(),r.tempHide||k()}),l.addCommand("wp_unlink",function(){l.execCommand("unlink"),r.tempHide=!1,l.execCommand("wp_link_cancel")}),l.addShortcut("access+a","","WP_Link"),l.addShortcut("access+s","","wp_unlink"),l.addShortcut("meta+k","","WP_Link"),l.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),l.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),l.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),l.on("pastepreprocess",function(e){var t=e.content,n=/^(?:https?:)?\/\/\S+$/i;l.selection.isCollapsed()||n.test(l.selection.getContent())||(t=t.replace(/<[^>]+>/g,""),t=v.trim(t),n.test(t)&&(l.execCommand("mceInsertLink",!1,{href:l.dom.decode(t)}),e.preventDefault()))}),l.on("savecontent",function(e){e.content=f(e.content,!0)}),l.on("BeforeAddUndo",function(e){e.lastLevel&&e.lastLevel.content&&e.level.content&&e.lastLevel.content===f(e.level.content)&&e.preventDefault()}),l.on("keydown",function(e){27===e.keyCode&&l.execCommand("wp_link_cancel"),e.altKey||v.Env.mac&&(!e.metaKey||e.ctrlKey)||!v.Env.mac&&!e.ctrlKey||89!==e.keyCode&&90!==e.keyCode||(n=!0,window.clearTimeout(t),t=window.setTimeout(function(){n=!1},500))}),l.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){d=this}}),l.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var n,i,o,a=this.getEl(),e=a.firstChild;c=this,p&&p.ui&&p.ui.autocomplete&&((n=p(e)).on("keydown",function(){n.removeAttr("aria-activedescendant")}).autocomplete({source:function(e,t){if(o===e.term)t(i);else{if(/^https?:/.test(e.term)||-1!==e.term.indexOf("."))return t();p.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:e.term,_ajax_linking_nonce:p("#_ajax_linking_nonce").val()},function(e){t(i=e)},"json"),o=e.term}},focus:function(e,t){n.attr("aria-activedescendant","mce-wp-autocomplete-"+t.item.ID),e.preventDefault()},select:function(e,t){return n.val(t.item.permalink),p(a.firstChild.nextSibling).val(t.item.title),9===e.keyCode&&void 0!==window.wpLinkL10n&&w(window.wpLinkL10n.linkSelected),!1},open:function(){n.attr("aria-expanded","true"),r.blockHide=!0},close:function(){n.attr("aria-expanded","false"),r.blockHide=!1},minLength:2,position:{my:"left top+2"},messages:{noResults:void 0!==window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(e){if(void 0!==window.uiAutocompleteL10n)return 1<e?window.uiAutocompleteL10n.manyResults.replace("%d",e):window.uiAutocompleteL10n.oneResult}}}).autocomplete("instance")._renderItem=function(e,t){var n=void 0!==window.wpLinkL10n?window.wpLinkL10n.noTitle:"",n=t.title||n;return p('<li role="option" id="mce-wp-autocomplete-'+t.ID+'">').append("<span>"+n+'</span> <span class="wp-editor-float-right">'+t.info+"</span>").appendTo(e)},n.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":n.autocomplete("widget").attr("id")}).on("focus",function(){var e=n.val();e&&!/^https?:/.test(e)&&n.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox").removeAttr("tabindex").on("menufocus",function(e,t){t.item.attr("aria-selected","true")}).on("menublur",function(){p(this).find('[aria-selected="true"]').removeAttr("aria-selected")})),v.$(e).on("keydown",function(e){13===e.keyCode&&(l.execCommand("wp_link_apply"),e.preventDefault())})}}),l.on("wptoolbar",function(e){var t,n,i,o=l.dom.getParent(e.element,"a");void 0!==window.wpLink&&window.wpLink.modalOpen?r.tempHide=!0:(r.tempHide=!1,o?(n=(t=l.$(o)).attr("href"),i=t.attr("data-wplink-edit"),"_wp_link_placeholder"===n||i?("_wp_link_placeholder"===n||c.getURL()||c.setURL(n),e.element=o,e.toolbar=r):n&&!t.find("img").length&&(d.setURL(n),e.element=o,e.toolbar=a,"true"===t.attr("data-wplink-url-error")?a.$el.find(".wp-link-preview a").addClass("wplink-url-error"):(a.$el.find(".wp-link-preview a").removeClass("wplink-url-error"),m=!1))):r.visible()&&l.execCommand("wp_link_cancel"))}),l.addButton("wp_link_edit",{tooltip:"Edit|button",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),l.addButton("wp_link_remove",{tooltip:"Remove link",icon:"dashicon dashicons-editor-unlink",cmd:"wp_unlink"}),l.addButton("wp_link_advanced",{tooltip:"Link options",icon:"dashicon dashicons-admin-generic",onclick:function(){var e,t;void 0!==window.wpLink&&(e=c.getURL()||null,t=c.getLinkText()||null,window.wpLink.open(l.id,e,t),r.tempHide=!0,r.hide())}}),l.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){r.tempHide=!1,l.execCommand("wp_link_cancel")},checkLink:h}})}(window.tinymce);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js new file mode 100644 index 0000000..0014233 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js @@ -0,0 +1,348 @@ +/** + * Text pattern plugin for TinyMCE + * + * @since 4.3.0 + * + * This plugin can automatically format text patterns as you type. It includes several groups of patterns. + * + * Start of line patterns: + * As-you-type: + * - Unordered list (`* ` and `- `). + * - Ordered list (`1. ` and `1) `). + * + * On enter: + * - h2 (## ). + * - h3 (### ). + * - h4 (#### ). + * - h5 (##### ). + * - h6 (###### ). + * - blockquote (> ). + * - hr (---). + * + * Inline patterns: + * - <code> (`) (backtick). + * + * 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. + * + * Setting for the patterns can be overridden by plugins by using the `tiny_mce_before_init` PHP filter. + * The setting name is `wptextpattern` and the value is an object containing override arrays for each + * patterns group. There are three groups: "space", "enter", and "inline". Example (PHP): + * + * add_filter( 'tiny_mce_before_init', 'my_mce_init_wptextpattern' ); + * function my_mce_init_wptextpattern( $init ) { + * $init['wptextpattern'] = wp_json_encode( array( + * 'inline' => array( + * array( 'delimiter' => '**', 'format' => 'bold' ), + * array( 'delimiter' => '__', 'format' => 'italic' ), + * ), + * ) ); + * + * return $init; + * } + * + * Note that setting this will override the default text patterns. You will need to include them + * in your settings array if you want to keep them working. + */ +( function( tinymce, setTimeout ) { + if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) { + return; + } + + /** + * Escapes characters for use in a Regular Expression. + * + * @param {String} string Characters to escape + * + * @return {String} Escaped characters + */ + function escapeRegExp( string ) { + return string.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&' ); + } + + tinymce.PluginManager.add( 'wptextpattern', function( editor ) { + var VK = tinymce.util.VK; + var settings = editor.settings.wptextpattern || {}; + + var spacePatterns = settings.space || [ + { regExp: /^[*-]\s/, cmd: 'InsertUnorderedList' }, + { regExp: /^1[.)]\s/, cmd: 'InsertOrderedList' } + ]; + + var enterPatterns = settings.enter || [ + { start: '##', format: 'h2' }, + { start: '###', format: 'h3' }, + { start: '####', format: 'h4' }, + { start: '#####', format: 'h5' }, + { start: '######', format: 'h6' }, + { start: '>', format: 'blockquote' }, + { regExp: /^(-){3,}$/, element: 'hr' } + ]; + + var inlinePatterns = settings.inline || [ + { delimiter: '`', format: 'code' } + ]; + + var canUndo; + + 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 ( VK.metaKeyPressed( event ) ) { + return; + } + + if ( event.keyCode === VK.ENTER ) { + enter(); + // Wait for the browser to insert the character. + } else if ( event.keyCode === VK.SPACEBAR ) { + setTimeout( space ); + } else if ( event.keyCode > 47 && ! ( event.keyCode >= 91 && event.keyCode <= 93 ) ) { + setTimeout( inline ); + } + }, true ); + + function inline() { + var rng = editor.selection.getRng(); + var node = rng.startContainer; + var offset = rng.startOffset; + var startOffset; + var endOffset; + var pattern; + var format; + var zero; + + // We need a non-empty text node with an offset greater than zero. + if ( ! node || node.nodeType !== 3 || ! node.data.length || ! offset ) { + return; + } + + var string = node.data.slice( 0, offset ); + var lastChar = node.data.charAt( offset - 1 ); + + tinymce.each( inlinePatterns, function( p ) { + // Character before selection should be delimiter. + if ( lastChar !== p.delimiter.slice( -1 ) ) { + return; + } + + var escDelimiter = escapeRegExp( p.delimiter ); + var delimiterFirstChar = p.delimiter.charAt( 0 ); + var regExp = new RegExp( '(.*)' + escDelimiter + '.+' + escDelimiter + '$' ); + var match = string.match( regExp ); + + if ( ! match ) { + return; + } + + startOffset = match[1].length; + endOffset = offset - p.delimiter.length; + + var before = string.charAt( startOffset - 1 ); + var after = string.charAt( startOffset + p.delimiter.length ); + + // test*test* => format applied. + // test *test* => applied. + // test* test* => not applied. + if ( startOffset && /\S/.test( before ) ) { + if ( /\s/.test( after ) || before === delimiterFirstChar ) { + return; + } + } + + // Do not replace when only whitespace and delimiter characters. + if ( ( new RegExp( '^[\\s' + escapeRegExp( delimiterFirstChar ) + ']+$' ) ).test( string.slice( startOffset, endOffset ) ) ) { + return; + } + + pattern = p; + + return false; + } ); + + if ( ! pattern ) { + return; + } + + format = editor.formatter.get( pattern.format ); + + if ( format && format[0].inline ) { + editor.undoManager.add(); + + editor.undoManager.transact( function() { + node.insertData( offset, '\uFEFF' ); + + node = node.splitText( startOffset ); + zero = node.splitText( offset - startOffset ); + + node.deleteData( 0, pattern.delimiter.length ); + node.deleteData( node.data.length - pattern.delimiter.length, pattern.delimiter.length ); + + editor.formatter.apply( pattern.format, {}, node ); + + editor.selection.setCursorLocation( zero, 1 ); + } ); + + // We need to wait for native events to be triggered. + setTimeout( function() { + canUndo = 'space'; + + editor.once( 'selectionchange', function() { + var offset; + + if ( zero ) { + offset = zero.data.indexOf( '\uFEFF' ); + + if ( offset !== -1 ) { + zero.deleteData( offset, offset + 1 ); + } + } + } ); + } ); + } + } + + 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 enter() { + var rng = editor.selection.getRng(), + start = rng.startContainer, + node = firstTextNode( start ), + i = enterPatterns.length, + text, pattern, parent; + + if ( ! node ) { + return; + } + + text = node.data; + + while ( i-- ) { + if ( enterPatterns[ i ].start ) { + if ( text.indexOf( enterPatterns[ i ].start ) === 0 ) { + pattern = enterPatterns[ i ]; + break; + } + } else if ( enterPatterns[ i ].regExp ) { + if ( enterPatterns[ i ].regExp.test( text ) ) { + pattern = enterPatterns[ i ]; + break; + } + } + } + + if ( ! pattern ) { + return; + } + + if ( node === start && tinymce.trim( text ) === pattern.start ) { + return; + } + + editor.once( 'keyup', function() { + editor.undoManager.add(); + + editor.undoManager.transact( function() { + if ( pattern.format ) { + editor.formatter.apply( pattern.format, {}, node ); + node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) ); + } else if ( pattern.element ) { + parent = node.parentNode && node.parentNode.parentNode; + + if ( parent ) { + parent.replaceChild( document.createElement( pattern.element ), node.parentNode ); + } + } + } ); + + // We need to wait for native events to be triggered. + setTimeout( function() { + canUndo = 'enter'; + } ); + } ); + } + + function ltrim( text ) { + return text ? text.replace( /^\s+/, '' ) : ''; + } + } ); +} )( window.tinymce, window.setTimeout ); diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js new file mode 100644 index 0000000..ddb9849 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js @@ -0,0 +1 @@ +!function(u,p){function h(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}u.Env.ie&&u.Env.ie<9||u.PluginManager.add("wptextpattern",function(s){var f,d=u.util.VK,e=s.settings.wptextpattern||{},t=e.space||[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],l=e.enter||[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"},{regExp:/^(-){3,}$/,element:"hr"}],a=e.inline||[{delimiter:"`",format:"code"}];function c(){var r,i,o,t,d,l,e=s.selection.getRng(),n=e.startContainer,c=e.startOffset;n&&3===n.nodeType&&n.data.length&&c&&(d=n.data.slice(0,c),l=n.data.charAt(c-1),u.each(a,function(e){if(l===e.delimiter.slice(-1)){var t=h(e.delimiter),n=e.delimiter.charAt(0),t=new RegExp("(.*)"+t+".+"+t+"$"),t=d.match(t);if(t){r=t[1].length,i=c-e.delimiter.length;var t=d.charAt(r-1),a=d.charAt(r+e.delimiter.length);if(!(r&&/\S/.test(t)&&(/\s/.test(a)||t===n)||new RegExp("^[\\s"+h(n)+"]+$").test(d.slice(r,i))))return o=e,!1}}}),o)&&(e=s.formatter.get(o.format))&&e[0].inline&&(s.undoManager.add(),s.undoManager.transact(function(){n.insertData(c,"\ufeff"),n=n.splitText(r),t=n.splitText(c-r),n.deleteData(0,o.delimiter.length),n.deleteData(n.data.length-o.delimiter.length,o.delimiter.length),s.formatter.apply(o.format,{},n),s.selection.setCursorLocation(t,1)}),p(function(){f="space",s.once("selectionchange",function(){var e;t&&-1!==(e=t.data.indexOf("\ufeff"))&&t.deleteData(e,e+1)})}))}function g(e){var t,n=s.dom.getParent(e,"p");if(n){for(;(t=n.firstChild)&&3!==t.nodeType;)n=t;if(t)return t=t.data?t:t.nextSibling&&3===t.nextSibling.nodeType?t.nextSibling:null}}function m(){var n,a,r=s.selection.getRng(),i=r.startContainer;i&&g(i)===i&&(n=i.parentNode,a=i.data,u.each(t,function(e){var t=a.match(e.regExp);if(t&&r.startOffset===t[0].length)return s.undoManager.add(),s.undoManager.transact(function(){i.deleteData(0,t[0].length),n.innerHTML||n.appendChild(document.createElement("br")),s.selection.setCursorLocation(n),s.execCommand(e.cmd)}),p(function(){f="space"}),!1}))}s.on("selectionchange",function(){f=null}),s.on("keydown",function(e){if((f&&27===e.keyCode||"space"===f&&e.keyCode===d.BACKSPACE)&&(s.undoManager.undo(),e.preventDefault(),e.stopImmediatePropagation()),!d.metaKeyPressed(e))if(e.keyCode===d.ENTER){var t,n,a,r=s.selection.getRng().startContainer,i=g(r),o=l.length;if(i){for(t=i.data;o--;)if(l[o].start){if(0===t.indexOf(l[o].start)){n=l[o];break}}else if(l[o].regExp&&l[o].regExp.test(t)){n=l[o];break}!n||i===r&&u.trim(t)===n.start||s.once("keyup",function(){s.undoManager.add(),s.undoManager.transact(function(){var e;n.format?(s.formatter.apply(n.format,{},i),i.replaceData(0,i.data.length,(e=i.data.slice(n.start.length))?e.replace(/^\s+/,""):"")):n.element&&(a=i.parentNode&&i.parentNode.parentNode)&&a.replaceChild(document.createElement(n.element),i.parentNode)}),p(function(){f="enter"})})}}else e.keyCode===d.SPACEBAR?p(m):47<e.keyCode&&!(91<=e.keyCode&&e.keyCode<=93)&&p(c)},!0)})}(window.tinymce,window.setTimeout);
\ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wpview/plugin.js b/wp-includes/js/tinymce/plugins/wpview/plugin.js new file mode 100644 index 0000000..1c21854 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -0,0 +1,225 @@ +/** + * WordPress View plugin. + */ +( function( tinymce ) { + tinymce.PluginManager.add( 'wpview', function( editor ) { + function noop () {} + + // Set this here as wp-tinymce.js may be loaded too early. + var wp = window.wp; + + if ( ! wp || ! wp.mce || ! wp.mce.views ) { + return { + getView: noop + }; + } + + // Check if a node is a view or not. + function isView( node ) { + return editor.dom.hasClass( node, 'wpview' ); + } + + // Replace view tags with their text. + function resetViews( content ) { + function callback( match, $1 ) { + return '<p>' + window.decodeURIComponent( $1 ) + '</p>'; + } + + if ( ! content || content.indexOf( ' data-wpview-' ) === -1 ) { + return content; + } + + return content + .replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g, callback ) + .replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, callback ); + } + + editor.on( 'init', function() { + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + + if ( MutationObserver ) { + new MutationObserver( function() { + editor.fire( 'wp-body-class-change' ); + } ) + .observe( editor.getBody(), { + attributes: true, + attributeFilter: ['class'] + } ); + } + + // Pass on body class name changes from the editor to the wpView iframes. + editor.on( 'wp-body-class-change', function() { + var className = editor.getBody().className; + + editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) { + // Make sure it is a local iframe. + // jshint scripturl: true + if ( ! iframe.src || iframe.src === 'javascript:""' ) { + try { + iframe.contentWindow.document.body.className = className; + } catch( er ) {} + } + }); + } ); + }); + + // Scan new content for matching view patterns and replace them with markers. + editor.on( 'beforesetcontent', function( event ) { + var node; + + if ( ! event.selection ) { + wp.mce.views.unbind(); + } + + if ( ! event.content ) { + return; + } + + if ( ! event.load ) { + 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 paragraph. + node = editor.dom.getParent( node, 'p' ); + + if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( 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, editor ); + } ); + + // Replace any new markers nodes with views. + editor.on( 'setcontent', function() { + wp.mce.views.render(); + } ); + + // Empty view nodes for easier processing. + editor.on( 'preprocess hide', function( event ) { + editor.$( 'div[data-wpview-text], p[data-wpview-marker]', event.node ).each( function( i, node ) { + node.innerHTML = '.'; + } ); + }, true ); + + // Replace views with their text. + editor.on( 'postprocess', function( event ) { + event.content = resetViews( event.content ); + } ); + + // Prevent adding of undo levels when replacing wpview markers + // or when there are changes only in the (non-editable) previews. + editor.on( 'beforeaddundo', function( event ) { + var lastContent; + var newContent = event.level.content || ( event.level.fragments && event.level.fragments.join( '' ) ); + + if ( ! event.lastLevel ) { + lastContent = editor.startContent; + } else { + lastContent = event.lastLevel.content || ( event.lastLevel.fragments && event.lastLevel.fragments.join( '' ) ); + } + + if ( + ! newContent || + ! lastContent || + newContent.indexOf( ' data-wpview-' ) === -1 || + lastContent.indexOf( ' data-wpview-' ) === -1 + ) { + return; + } + + if ( resetViews( lastContent ) === resetViews( newContent ) ) { + event.preventDefault(); + } + } ); + + // Make sure views are copied as their text. + editor.on( 'drop objectselected', function( event ) { + if ( isView( event.targetClone ) ) { + event.targetClone = editor.getDoc().createTextNode( + window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) ) + ); + } + } ); + + // Clean up URLs for easier processing. + editor.on( 'pastepreprocess', function( event ) { + var content = event.content; + + if ( content ) { + content = tinymce.trim( content.replace( /<[^>]+>/g, '' ) ); + + if ( /^https?:\/\/\S+$/i.test( content ) ) { + event.content = content; + } + } + } ); + + // Show the view type in the element path. + editor.on( 'resolvename', function( event ) { + if ( isView( event.target ) ) { + event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'object'; + } + } ); + + // See `media` plugin. + editor.on( 'click keyup', function() { + var node = editor.selection.getNode(); + + if ( isView( node ) ) { + if ( editor.dom.getAttrib( node, 'data-mce-selected' ) ) { + node.setAttribute( 'data-mce-selected', '2' ); + } + } + } ); + + editor.addButton( 'wp_view_edit', { + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. + icon: 'dashicon dashicons-edit', + onclick: function() { + var node = editor.selection.getNode(); + + if ( isView( node ) ) { + wp.mce.views.edit( editor, node ); + } + } + } ); + + editor.addButton( 'wp_view_remove', { + tooltip: 'Remove', + icon: 'dashicon dashicons-no', + onclick: function() { + editor.fire( 'cut' ); + } + } ); + + editor.once( 'preinit', function() { + var toolbar; + + if ( editor.wp && editor.wp._createToolbar ) { + toolbar = editor.wp._createToolbar( [ + 'wp_view_edit', + 'wp_view_remove' + ] ); + + editor.on( 'wptoolbar', function( event ) { + if ( ! event.collapsed && isView( event.element ) ) { + event.toolbar = toolbar; + } + } ); + } + } ); + + editor.wp = editor.wp || {}; + editor.wp.getView = noop; + editor.wp.setViewCursor = noop; + + return { + getView: noop + }; + } ); +} )( window.tinymce ); diff --git a/wp-includes/js/tinymce/plugins/wpview/plugin.min.js b/wp-includes/js/tinymce/plugins/wpview/plugin.min.js new file mode 100644 index 0000000..86cc8ee --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpview/plugin.min.js @@ -0,0 +1 @@ +!function(c){c.PluginManager.add("wpview",function(o){function e(){}var n=window.wp;return n&&n.mce&&n.mce.views&&(o.on("init",function(){var e=window.MutationObserver||window.WebKitMutationObserver;e&&new e(function(){o.fire("wp-body-class-change")}).observe(o.getBody(),{attributes:!0,attributeFilter:["class"]}),o.on("wp-body-class-change",function(){var n=o.getBody().className;o.$('iframe[class="wpview-sandbox"]').each(function(e,t){if(!t.src||'javascript:""'===t.src)try{t.contentWindow.document.body.className=n}catch(e){}})})}),o.on("beforesetcontent",function(e){var t;if(e.selection||n.mce.views.unbind(),e.content){if(!e.load&&(t=o.selection.getNode())&&t!==o.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(e.content)){if(!(t=o.dom.getParent(t,"p"))||!/^[\s\uFEFF\u00A0]*$/.test(o.$(t).text()||""))return;t.innerHTML=""}e.content=n.mce.views.setMarkers(e.content,o)}}),o.on("setcontent",function(){n.mce.views.render()}),o.on("preprocess hide",function(e){o.$("div[data-wpview-text], p[data-wpview-marker]",e.node).each(function(e,t){t.innerHTML="."})},!0),o.on("postprocess",function(e){e.content=a(e.content)}),o.on("beforeaddundo",function(e){var t=e.level.content||e.level.fragments&&e.level.fragments.join(""),n=e.lastLevel?e.lastLevel.content||e.lastLevel.fragments&&e.lastLevel.fragments.join(""):o.startContent;t&&n&&-1!==t.indexOf(" data-wpview-")&&-1!==n.indexOf(" data-wpview-")&&a(n)===a(t)&&e.preventDefault()}),o.on("drop objectselected",function(e){i(e.targetClone)&&(e.targetClone=o.getDoc().createTextNode(window.decodeURIComponent(o.dom.getAttrib(e.targetClone,"data-wpview-text"))))}),o.on("pastepreprocess",function(e){var t=e.content;t&&(t=c.trim(t.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(t))&&(e.content=t)}),o.on("resolvename",function(e){i(e.target)&&(e.name=o.dom.getAttrib(e.target,"data-wpview-type")||"object")}),o.on("click keyup",function(){var e=o.selection.getNode();i(e)&&o.dom.getAttrib(e,"data-mce-selected")&&e.setAttribute("data-mce-selected","2")}),o.addButton("wp_view_edit",{tooltip:"Edit|button",icon:"dashicon dashicons-edit",onclick:function(){var e=o.selection.getNode();i(e)&&n.mce.views.edit(o,e)}}),o.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){o.fire("cut")}}),o.once("preinit",function(){var t;o.wp&&o.wp._createToolbar&&(t=o.wp._createToolbar(["wp_view_edit","wp_view_remove"]),o.on("wptoolbar",function(e){!e.collapsed&&i(e.element)&&(e.toolbar=t)}))}),o.wp=o.wp||{},o.wp.getView=e,o.wp.setViewCursor=e),{getView:e};function i(e){return o.dom.hasClass(e,"wpview")}function a(e){function t(e,t){return"<p>"+window.decodeURIComponent(t)+"</p>"}return e&&-1!==e.indexOf(" data-wpview-")?e.replace(/<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g,t).replace(/<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,t):e}})}(window.tinymce);
\ No newline at end of file |